//=======================================================================
//function : OCC544
-//purpose :
+//purpose :
//=======================================================================
static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if(argc > 6) {
+ if (argc > 6)
+ {
di << "Usage : " << argv[0] << " [[[[[wT [[[[d1 [[[d2 [[R [length]]]]]\n";
return 1;
}
// Used to Display Geometry or Topolgy
- char name[255];
Standard_Boolean check = Standard_True;
// Set default arguments
double radius_l = 20.0;
double radius_r = 80.0;
- // mkv 15.07.03 double bend_angle = M_PI/2.0;
double bend_angle = M_PI/2.0;
double major_rad = 280.0;
double wall_thickness = 10.0;
-
// Convert arguments
if (argc>1) radius_l = Draw::Atof(argv[1]);
if (argc>4) major_rad = Draw::Atof(argv[4]);
if (argc>5) wall_thickness = Draw::Atof(argv[5]);
- // mkv 15.07.03 if ((bend_angle >= 2.0*M_PI)) {
- if ((bend_angle >= 2.0*M_PI)) {
+ if (bend_angle >= 2.0 * M_PI)
+ {
di << "The arguments are invalid.\n";
return 1;
}
+
di << "creating the shape for a bent tube\n";
gp_Ax2 origin(gp_Pnt(500.0,-300.0, 100.0),
TopoDS_Edge E1_1 = BRepBuilderAPI_MakeEdge(faceCircle, 0, M_PI);
TopoDS_Edge E1_2 = BRepBuilderAPI_MakeEdge(faceCircle, M_PI, 2.*M_PI);
TopoDS_Wire Wire1_ = BRepBuilderAPI_MakeWire(E1_1, E1_2);
-
+
// Create the face at the near end for the wall solid, an annular ring.
TopoDS_Edge Eout1_1 = BRepBuilderAPI_MakeEdge(outFaceCircle, 0, M_PI);
TopoDS_Edge Eout1_2 = BRepBuilderAPI_MakeEdge(outFaceCircle, M_PI, 2.*M_PI);
TopoDS_Wire outerWire1_ = BRepBuilderAPI_MakeWire(Eout1_1, Eout1_2);
-
+
TopoDS_Edge E2_1 = BRepBuilderAPI_MakeEdge(faceCircle2, 0, M_PI);
TopoDS_Edge E2_2 = BRepBuilderAPI_MakeEdge(faceCircle2, M_PI, 2.*M_PI);
TopoDS_Wire Wire2_ = BRepBuilderAPI_MakeWire(E2_1, E2_2);
-
+
// Create the face at the far end for the wall solid, an annular ring.
TopoDS_Edge Eout2_1 = BRepBuilderAPI_MakeEdge(outFaceCircle2, 0, M_PI);
TopoDS_Edge Eout2_2 = BRepBuilderAPI_MakeEdge(outFaceCircle2, M_PI, 2.*M_PI);
TopoDS_Wire outerWire2_ = BRepBuilderAPI_MakeWire(Eout2_1, Eout2_2);
- BRepBuilderAPI_MakeFace mkFace;
-
Handle(Geom_Curve) SpineCurve (GC_MakeArcOfCircle (circle, endPoint, origin.Location(), Standard_True).Value());
Handle(Law_Linear) myLaw = new Law_Linear();
Handle(Law_Linear) myLaw2 = new Law_Linear();
di << "radius_r / radius_l is " << radius_r/radius_l << "\n";
BRepBuilderAPI_MakeEdge mkEdge;
-
- mkEdge.Init(SpineCurve);
- if (!mkEdge.IsDone())
+ mkEdge.Init (SpineCurve);
+ if (!mkEdge.IsDone())
+ {
return 1;
- TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire();
-
- Sprintf (name,"SpineWire");
- DBRep::Set(name,SpineWire);
-
- Sprintf (name,"Wire1_");
- DBRep::Set(name,Wire1_);
-
- Sprintf (name,"outerWire1_");
- DBRep::Set(name,outerWire1_);
-
- Sprintf (name,"Wire2_");
- DBRep::Set(name,Wire2_);
-
- Sprintf (name,"outerWire2_");
- DBRep::Set(name,outerWire2_);
+ }
- di.Eval("fit");
+ TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire();
+ DBRep::Set ("SpineWire", SpineWire);
+ DBRep::Set ("Wire1_", Wire1_);
+ DBRep::Set ("outerWire1_", outerWire1_);
+ DBRep::Set ("Wire2_", Wire2_);
+ DBRep::Set ("outerWire2_", outerWire2_);
+ di.Eval ("fit");
TopoDS_Vertex Location1, Location2;
-
TopExp::Vertices(SpineWire, Location2, Location1);
-
- Sprintf (name,"Location1");
- DBRep::Set(name,Location1);
-
- Sprintf (name,"Location2");
- DBRep::Set(name,Location2);
+ DBRep::Set ("Location1", Location1);
+ DBRep::Set ("Location2", Location2);
// Make inner pipe shell
BRepOffsetAPI_MakePipeShell mkPipe1(SpineWire);
mkPipe1.SetMode(Standard_False);
mkPipe1.SetLaw(Wire1_, myLaw, Location1, Standard_False, Standard_False);
mkPipe1.Build();
- if (!mkPipe1.IsDone())
+ if (!mkPipe1.IsDone())
+ {
return 1;
+ }
// Make outer pipe shell
BRepOffsetAPI_MakePipeShell mkPipe2(SpineWire);
mkPipe2.SetTransitionMode(BRepBuilderAPI_Transformed);
mkPipe2.SetMode(Standard_False);
mkPipe2.SetLaw(outerWire1_, myLaw2, Location1, Standard_False, Standard_False);
- mkPipe2.Build();
- if (!mkPipe2.IsDone())
+ mkPipe2.Build();
+ if (!mkPipe2.IsDone())
+ {
return 1;
+ }
-// Sprintf(name,"w1-first");
-// DBRep::Set(name,mkPipe1.FirstShape());
-
-// Sprintf(name,"w1-last");
-// DBRep::Set(name,mkPipe1.LastShape());
-
-// Sprintf(name,"w2-first");
-// DBRep::Set(name,mkPipe2.FirstShape());
-
-// Sprintf(name,"w2-last");
-// DBRep::Set(name,mkPipe2.LastShape());
+//DBRep::Set ("w1-first", mkPipe1.FirstShape());
+//DBRep::Set ("w1-last", mkPipe1.LastShape());
+//DBRep::Set ("w2-first", mkPipe2.FirstShape());
+//DBRep::Set ("w2-last", mkPipe2.LastShape());
BRepOffsetAPI_Sewing SewIt(1.0e-4);
// Make tube
- TopExp_Explorer getFaces;
- TopoDS_Face test_face;
- getFaces.Init(mkPipe1.Shape(), TopAbs_FACE);
- while (getFaces.More())
- {
- SewIt.Add(getFaces.Current().Reversed());
- getFaces.Next();
- }
+ for (TopExp_Explorer aFaceIter (mkPipe1.Shape(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+ {
+ SewIt.Add (aFaceIter.Current().Reversed());
+ }
// Make face for first opening
Handle(Geom_Plane) Plane1 = new Geom_Plane(circ1Plane);
+ BRepBuilderAPI_MakeFace mkFace;
mkFace.Init(Plane1,Standard_False,Precision::Confusion());
mkFace.Add(TopoDS::Wire(outerWire1_));
mkFace.Add(TopoDS::Wire(Wire1_.Reversed()));
- if (!mkFace.IsDone())
+ if (!mkFace.IsDone())
+ {
return 1;
+ }
+
TopoDS_Face Face1 = mkFace.Face();
// Make face for second opening
mkFace.Init(Plane2,Standard_False,Precision::Confusion());
mkFace.Add(TopoDS::Wire(outerWire2_));
mkFace.Add(TopoDS::Wire(Wire2_.Reversed()));
- if (!mkFace.IsDone())
+ if (!mkFace.IsDone())
+ {
return 1;
+ }
+
TopoDS_Face Face2 = mkFace.Face();
// Grab the gas solid now that we've extracted the faces.
mkPipe1.MakeSolid();
myShape = TopoDS::Solid(mkPipe1.Shape());
- getFaces.Clear();
- getFaces.Init(mkPipe2.Shape(), TopAbs_FACE);
- while (getFaces.More())
- {
- SewIt.Add(getFaces.Current());
- getFaces.Next();
- }
-
+ for (TopExp_Explorer aFaceIter (mkPipe2.Shape(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+ {
+ SewIt.Add (aFaceIter.Current());
+ }
SewIt.Add(Face1.Reversed());
SewIt.Add(Face2);
-
SewIt.Perform();
- di << "The result of the Sewing operation is a ";
// Check to see if we have a solid
- switch (SewIt.SewedShape().ShapeType()) {
- case (TopAbs_COMPOUND):
- di << "TopAbs_COMPOUND\n";
- break;
- case (TopAbs_COMPSOLID):
- di << "TopAbs_COMPSOLID\n";
- break;
- case (TopAbs_SOLID):
- di << "TopAbs_SOLID\n";
- break;
- case (TopAbs_SHELL):
- di << "TopAbs_SHELL\n";
- break;
- case (TopAbs_FACE):
- di << "TopAbs_FACE\n";
- break;
- case (TopAbs_WIRE):
- di << "TopAbs_WIRE\n";
- break;
- case (TopAbs_EDGE):
- di << "TopAbs_EDGE\n";
- break;
- case (TopAbs_VERTEX):
- di << "TopAbs_VERTEX\n";
- break;
- case (TopAbs_SHAPE):
- di << "TopAbs_SHAPE\n";
- }
+ di << "The result of the Sewing operation is a " << "TopAbs_" << TopAbs::ShapeTypeToString (SewIt.SewedShape().ShapeType()) << "\n";
BRep_Builder B;
-
- TopoDS_Shell TubeShell;
di << "Can we turn it into a shell? ";
- try {
+ try
+ {
OCC_CATCH_SIGNALS
- TubeShell = TopoDS::Shell(SewIt.SewedShape());
+ TopoDS_Shell TubeShell = TopoDS::Shell(SewIt.SewedShape());
B.MakeSolid(wallSolid);
B.Add(wallSolid,TubeShell);
di << " yes\n";
}
- catch (Standard_TypeMismatch const&) {
+ catch (Standard_TypeMismatch const&)
+ {
di << "Can't convert to shell...\n";
- TopExp_Explorer getSol;
- getSol.Init(SewIt.SewedShape(), TopAbs_SOLID);
- if (getSol.More()) {
+ TopExp_Explorer aSolIter (SewIt.SewedShape(), TopAbs_SOLID);
+ if (aSolIter.More())
+ {
di << "First solid found in compound\n";
- wallSolid = TopoDS::Solid(getSol.Current());
- TopoDS_Solid test_solid;
- while (getSol.More())
+ wallSolid = TopoDS::Solid (aSolIter.Current());
+ for (; aSolIter.More(); aSolIter.Next())
{
di << "Next solid found in compound\n";
- getSol.Next();
- test_solid = TopoDS::Solid(getSol.Current());
+ TopoDS_Solid test_solid = TopoDS::Solid (aSolIter.Current());
di << "BRepAlgoAPI_Fuse fuser(test_solid, wallSolid)\n";
BRepAlgoAPI_Fuse fuser(test_solid, wallSolid);
- TopExp_Explorer aExpS(fuser.Shape(), TopAbs_SOLID);
- if (aExpS.More()) {
+ TopExp_Explorer aExpS (fuser.Shape(), TopAbs_SOLID);
+ if (aExpS.More())
+ {
wallSolid = TopoDS::Solid(aExpS.Current());
}
}
- } else {
+ }
+ else
+ {
// Let's see if we can extract shells instead of solids.
- TopExp_Explorer getShel;
- getShel.Init(SewIt.SewedShape(), TopAbs_SHELL);
- if (getShel.More()) {
- di << "First shell found in compound\n";
- B.MakeSolid(wallSolid);
- di << "B.Add(wallSolid,TopoDS::Shell(getShel.Current()));\n";
- int i = 1;
- while (getShel.More())
- {
- di << "Next shell found in compound\n";
- di << "B.Add(wallSolid,TopoDS::Shell(getShel.Current()));\n";
- Sprintf(name,"shell%d", i++);
- DBRep::Set(name,getShel.Current());
- B.Add(wallSolid,TopoDS::Shell(getShel.Current()));
- getShel.Next();
- }
+ TopExp_Explorer aShellIter (SewIt.SewedShape(), TopAbs_SHELL);
+ if (aShellIter.More())
+ {
+ di << "First shell found in compound\n";
+ B.MakeSolid(wallSolid);
+ di << "B.Add(wallSolid,TopoDS::Shell(aShellIter.Current()));\n";
+ char name[255] = {};
+ for (int i = 1; aShellIter.More(); aShellIter.Next(), ++i)
+ {
+ di << "Next shell found in compound\n";
+ di << "B.Add(wallSolid,TopoDS::Shell(aShellIter.Current()));\n";
+ Sprintf (name,"shell%d", i);
+ DBRep::Set (name,aShellIter.Current());
+ B.Add (wallSolid, TopoDS::Shell (aShellIter.Current()));
+ }
}
}
}
- Sprintf(name,"result");
- DBRep::Set(name,wallSolid);
+ DBRep::Set ("result", wallSolid);
// Now calculated the volume of the outside tube.
GProp_GProps gprops;
BRepGProp::VolumeProperties(wallSolid, gprops);
di << "The wallSolid's volume is: " << gprops.Mass() << "\n";
- if (check) {
+ if (check)
+ {
if (!(BRepCheck_Analyzer(wallSolid).IsValid()))
di << "The TopoDS_Solid was checked, and it was invalid!\n";
else
di << "The TopoDS_Solid is finite.\n";
}
- di << "The result is a ";
// Check to see if we have a solid
- switch (wallSolid.ShapeType()) {
- case (TopAbs_COMPOUND):
- di << "TopAbs_COMPOUND\n";
- break;
- case (TopAbs_COMPSOLID):
- di << "TopAbs_COMPSOLID\n";
- break;
- case (TopAbs_SOLID):
- di << "TopAbs_SOLID\n";
- break;
- case (TopAbs_SHELL):
- di << "TopAbs_SHELL\n";
- break;
- case (TopAbs_FACE):
- di << "TopAbs_FACE\n";
- break;
- case (TopAbs_WIRE):
- di << "TopAbs_WIRE\n";
- break;
- case (TopAbs_EDGE):
- di << "TopAbs_EDGE\n";
- break;
- case (TopAbs_VERTEX):
- di << "TopAbs_VERTEX\n";
- break;
- case (TopAbs_SHAPE):
- di << "TopAbs_SHAPE\n";
- }
-
+ di << "The result is a " << "TopAbs_" << TopAbs::ShapeTypeToString (wallSolid.ShapeType()) << "\n";
return 0;
}
const char *group = "QABugs";
theCommands.Add ("OCC332", "OCC332 [wall_thickness [dia1 [dia2 [length [major_radius]]]]]", __FILE__, OCC332bug, group);
- //////theCommands.Add("OCC544", "OCC544 [[[[[wT [[[[d1 [[[d2 [[R [length]]]]]", __FILE__, OCC544, group);
theCommands.Add("OCC544", "OCC544 [[[[[wT [[[[d1 [[[d2 [[R [length ]]]]]", __FILE__, OCC544, group);
- //////theCommands.Add("OCC817", "OCC817 result mesh_delta", __FILE__, OCC817, group);
theCommands.Add("OCC817", "OCC817 result mesh_delta ", __FILE__, OCC817, group);
return;