1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
bugmaster
8d9ee27278 0032271: Tests - vselect/bugs/bug544 hangs 2021-04-07 10:26:28 +03:00
2 changed files with 107 additions and 168 deletions

View File

@@ -395,25 +395,23 @@ static Standard_Integer OCC332bug (Draw_Interpretor& di, Standard_Integer argc,
//======================================================================= //=======================================================================
static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) 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"; di << "Usage : " << argv[0] << " [[[[[wT [[[[d1 [[[d2 [[R [length]]]]]\n";
return 1; return 1;
} }
// Used to Display Geometry or Topolgy // Used to Display Geometry or Topolgy
char name[255];
Standard_Boolean check = Standard_True; Standard_Boolean check = Standard_True;
// Set default arguments // Set default arguments
double radius_l = 20.0; double radius_l = 20.0;
double radius_r = 80.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 bend_angle = M_PI/2.0;
double major_rad = 280.0; double major_rad = 280.0;
double wall_thickness = 10.0; double wall_thickness = 10.0;
// Convert arguments // Convert arguments
if (argc>1) radius_l = Draw::Atof(argv[1]); if (argc>1) radius_l = Draw::Atof(argv[1]);
if (argc>2) radius_r = Draw::Atof(argv[2]); if (argc>2) radius_r = Draw::Atof(argv[2]);
@@ -421,11 +419,12 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
if (argc>4) major_rad = Draw::Atof(argv[4]); if (argc>4) major_rad = Draw::Atof(argv[4]);
if (argc>5) wall_thickness = Draw::Atof(argv[5]); 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"; di << "The arguments are invalid.\n";
return 1; return 1;
} }
di << "creating the shape for a bent tube\n"; di << "creating the shape for a bent tube\n";
gp_Ax2 origin(gp_Pnt(500.0,-300.0, 100.0), gp_Ax2 origin(gp_Pnt(500.0,-300.0, 100.0),
@@ -480,8 +479,6 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
TopoDS_Edge Eout2_2 = BRepBuilderAPI_MakeEdge(outFaceCircle2, M_PI, 2.*M_PI); TopoDS_Edge Eout2_2 = BRepBuilderAPI_MakeEdge(outFaceCircle2, M_PI, 2.*M_PI);
TopoDS_Wire outerWire2_ = BRepBuilderAPI_MakeWire(Eout2_1, Eout2_2); 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(Geom_Curve) SpineCurve (GC_MakeArcOfCircle (circle, endPoint, origin.Location(), Standard_True).Value());
Handle(Law_Linear) myLaw = new Law_Linear(); Handle(Law_Linear) myLaw = new Law_Linear();
Handle(Law_Linear) myLaw2 = new Law_Linear(); Handle(Law_Linear) myLaw2 = new Law_Linear();
@@ -503,38 +500,24 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
di << "radius_r / radius_l is " << radius_r/radius_l << "\n"; di << "radius_r / radius_l is " << radius_r/radius_l << "\n";
BRepBuilderAPI_MakeEdge mkEdge; BRepBuilderAPI_MakeEdge mkEdge;
mkEdge.Init (SpineCurve);
mkEdge.Init(SpineCurve);
if (!mkEdge.IsDone()) if (!mkEdge.IsDone())
{
return 1; return 1;
}
TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire(); TopoDS_Wire SpineWire = BRepBuilderAPI_MakeWire(mkEdge.Edge()).Wire();
DBRep::Set ("SpineWire", SpineWire);
Sprintf (name,"SpineWire"); DBRep::Set ("Wire1_", Wire1_);
DBRep::Set(name,SpineWire); DBRep::Set ("outerWire1_", outerWire1_);
DBRep::Set ("Wire2_", Wire2_);
Sprintf (name,"Wire1_"); DBRep::Set ("outerWire2_", outerWire2_);
DBRep::Set(name,Wire1_); di.Eval ("fit");
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_Vertex Location1, Location2; TopoDS_Vertex Location1, Location2;
TopExp::Vertices(SpineWire, Location2, Location1); TopExp::Vertices(SpineWire, Location2, Location1);
DBRep::Set ("Location1", Location1);
Sprintf (name,"Location1"); DBRep::Set ("Location2", Location2);
DBRep::Set(name,Location1);
Sprintf (name,"Location2");
DBRep::Set(name,Location2);
// Make inner pipe shell // Make inner pipe shell
BRepOffsetAPI_MakePipeShell mkPipe1(SpineWire); BRepOffsetAPI_MakePipeShell mkPipe1(SpineWire);
@@ -544,7 +527,9 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
mkPipe1.SetLaw(Wire1_, myLaw, Location1, Standard_False, Standard_False); mkPipe1.SetLaw(Wire1_, myLaw, Location1, Standard_False, Standard_False);
mkPipe1.Build(); mkPipe1.Build();
if (!mkPipe1.IsDone()) if (!mkPipe1.IsDone())
{
return 1; return 1;
}
// Make outer pipe shell // Make outer pipe shell
BRepOffsetAPI_MakePipeShell mkPipe2(SpineWire); BRepOffsetAPI_MakePipeShell mkPipe2(SpineWire);
@@ -552,41 +537,36 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
mkPipe2.SetTransitionMode(BRepBuilderAPI_Transformed); mkPipe2.SetTransitionMode(BRepBuilderAPI_Transformed);
mkPipe2.SetMode(Standard_False); mkPipe2.SetMode(Standard_False);
mkPipe2.SetLaw(outerWire1_, myLaw2, Location1, Standard_False, Standard_False); mkPipe2.SetLaw(outerWire1_, myLaw2, Location1, Standard_False, Standard_False);
mkPipe2.Build(); mkPipe2.Build();
if (!mkPipe2.IsDone()) if (!mkPipe2.IsDone())
{
return 1; return 1;
}
// Sprintf(name,"w1-first"); //DBRep::Set ("w1-first", mkPipe1.FirstShape());
// DBRep::Set(name,mkPipe1.FirstShape()); //DBRep::Set ("w1-last", mkPipe1.LastShape());
//DBRep::Set ("w2-first", mkPipe2.FirstShape());
// Sprintf(name,"w1-last"); //DBRep::Set ("w2-last", mkPipe2.LastShape());
// DBRep::Set(name,mkPipe1.LastShape());
// Sprintf(name,"w2-first");
// DBRep::Set(name,mkPipe2.FirstShape());
// Sprintf(name,"w2-last");
// DBRep::Set(name,mkPipe2.LastShape());
BRepOffsetAPI_Sewing SewIt(1.0e-4); BRepOffsetAPI_Sewing SewIt(1.0e-4);
// Make tube // Make tube
TopExp_Explorer getFaces; for (TopExp_Explorer aFaceIter (mkPipe1.Shape(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
TopoDS_Face test_face; {
getFaces.Init(mkPipe1.Shape(), TopAbs_FACE); SewIt.Add (aFaceIter.Current().Reversed());
while (getFaces.More()) }
{
SewIt.Add(getFaces.Current().Reversed());
getFaces.Next();
}
// Make face for first opening // Make face for first opening
Handle(Geom_Plane) Plane1 = new Geom_Plane(circ1Plane); Handle(Geom_Plane) Plane1 = new Geom_Plane(circ1Plane);
BRepBuilderAPI_MakeFace mkFace;
mkFace.Init(Plane1,Standard_False,Precision::Confusion()); mkFace.Init(Plane1,Standard_False,Precision::Confusion());
mkFace.Add(TopoDS::Wire(outerWire1_)); mkFace.Add(TopoDS::Wire(outerWire1_));
mkFace.Add(TopoDS::Wire(Wire1_.Reversed())); mkFace.Add(TopoDS::Wire(Wire1_.Reversed()));
if (!mkFace.IsDone()) if (!mkFace.IsDone())
{
return 1; return 1;
}
TopoDS_Face Face1 = mkFace.Face(); TopoDS_Face Face1 = mkFace.Face();
// Make face for second opening // Make face for second opening
@@ -595,120 +575,90 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
mkFace.Add(TopoDS::Wire(outerWire2_)); mkFace.Add(TopoDS::Wire(outerWire2_));
mkFace.Add(TopoDS::Wire(Wire2_.Reversed())); mkFace.Add(TopoDS::Wire(Wire2_.Reversed()));
if (!mkFace.IsDone()) if (!mkFace.IsDone())
{
return 1; return 1;
}
TopoDS_Face Face2 = mkFace.Face(); TopoDS_Face Face2 = mkFace.Face();
// Grab the gas solid now that we've extracted the faces. // Grab the gas solid now that we've extracted the faces.
mkPipe1.MakeSolid(); mkPipe1.MakeSolid();
myShape = TopoDS::Solid(mkPipe1.Shape()); myShape = TopoDS::Solid(mkPipe1.Shape());
getFaces.Clear(); for (TopExp_Explorer aFaceIter (mkPipe2.Shape(), TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
getFaces.Init(mkPipe2.Shape(), TopAbs_FACE); {
while (getFaces.More()) SewIt.Add (aFaceIter.Current());
{ }
SewIt.Add(getFaces.Current());
getFaces.Next();
}
SewIt.Add(Face1.Reversed()); SewIt.Add(Face1.Reversed());
SewIt.Add(Face2); SewIt.Add(Face2);
SewIt.Perform(); SewIt.Perform();
di << "The result of the Sewing operation is a ";
// Check to see if we have a solid // Check to see if we have a solid
switch (SewIt.SewedShape().ShapeType()) { di << "The result of the Sewing operation is a " << "TopAbs_" << TopAbs::ShapeTypeToString (SewIt.SewedShape().ShapeType()) << "\n";
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";
}
BRep_Builder B; BRep_Builder B;
TopoDS_Shell TubeShell;
di << "Can we turn it into a shell? "; di << "Can we turn it into a shell? ";
try { try
{
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
TubeShell = TopoDS::Shell(SewIt.SewedShape()); TopoDS_Shell TubeShell = TopoDS::Shell(SewIt.SewedShape());
B.MakeSolid(wallSolid); B.MakeSolid(wallSolid);
B.Add(wallSolid,TubeShell); B.Add(wallSolid,TubeShell);
di << " yes\n"; di << " yes\n";
} }
catch (Standard_TypeMismatch const&) { catch (Standard_TypeMismatch const&)
{
di << "Can't convert to shell...\n"; di << "Can't convert to shell...\n";
TopExp_Explorer getSol; TopExp_Explorer aSolIter (SewIt.SewedShape(), TopAbs_SOLID);
getSol.Init(SewIt.SewedShape(), TopAbs_SOLID); if (aSolIter.More())
if (getSol.More()) { {
di << "First solid found in compound\n"; di << "First solid found in compound\n";
wallSolid = TopoDS::Solid(getSol.Current()); wallSolid = TopoDS::Solid (aSolIter.Current());
TopoDS_Solid test_solid; for (; aSolIter.More(); aSolIter.Next())
while (getSol.More())
{ {
di << "Next solid found in compound\n"; di << "Next solid found in compound\n";
getSol.Next(); TopoDS_Solid test_solid = TopoDS::Solid (aSolIter.Current());
test_solid = TopoDS::Solid(getSol.Current());
di << "BRepAlgoAPI_Fuse fuser(test_solid, wallSolid)\n"; di << "BRepAlgoAPI_Fuse fuser(test_solid, wallSolid)\n";
BRepAlgoAPI_Fuse fuser(test_solid, wallSolid); BRepAlgoAPI_Fuse fuser(test_solid, wallSolid);
TopExp_Explorer aExpS(fuser.Shape(), TopAbs_SOLID); TopExp_Explorer aExpS (fuser.Shape(), TopAbs_SOLID);
if (aExpS.More()) { if (aExpS.More())
{
wallSolid = TopoDS::Solid(aExpS.Current()); wallSolid = TopoDS::Solid(aExpS.Current());
} }
} }
} else { }
else
{
// Let's see if we can extract shells instead of solids. // Let's see if we can extract shells instead of solids.
TopExp_Explorer getShel; TopExp_Explorer aShellIter (SewIt.SewedShape(), TopAbs_SHELL);
getShel.Init(SewIt.SewedShape(), TopAbs_SHELL); if (aShellIter.More())
if (getShel.More()) { {
di << "First shell found in compound\n"; di << "First shell found in compound\n";
B.MakeSolid(wallSolid); B.MakeSolid(wallSolid);
di << "B.Add(wallSolid,TopoDS::Shell(getShel.Current()));\n"; di << "B.Add(wallSolid,TopoDS::Shell(aShellIter.Current()));\n";
int i = 1; char name[255] = {};
while (getShel.More()) for (int i = 1; aShellIter.More(); aShellIter.Next(), ++i)
{ {
di << "Next shell found in compound\n"; di << "Next shell found in compound\n";
di << "B.Add(wallSolid,TopoDS::Shell(getShel.Current()));\n"; di << "B.Add(wallSolid,TopoDS::Shell(aShellIter.Current()));\n";
Sprintf(name,"shell%d", i++); Sprintf (name,"shell%d", i);
DBRep::Set(name,getShel.Current()); DBRep::Set (name,aShellIter.Current());
B.Add(wallSolid,TopoDS::Shell(getShel.Current())); B.Add (wallSolid, TopoDS::Shell (aShellIter.Current()));
getShel.Next(); }
}
} }
} }
} }
Sprintf(name,"result"); DBRep::Set ("result", wallSolid);
DBRep::Set(name,wallSolid);
// Now calculated the volume of the outside tube. // Now calculated the volume of the outside tube.
GProp_GProps gprops; GProp_GProps gprops;
BRepGProp::VolumeProperties(wallSolid, gprops); BRepGProp::VolumeProperties(wallSolid, gprops);
di << "The wallSolid's volume is: " << gprops.Mass() << "\n"; di << "The wallSolid's volume is: " << gprops.Mass() << "\n";
if (check) { if (check)
{
if (!(BRepCheck_Analyzer(wallSolid).IsValid())) if (!(BRepCheck_Analyzer(wallSolid).IsValid()))
di << "The TopoDS_Solid was checked, and it was invalid!\n"; di << "The TopoDS_Solid was checked, and it was invalid!\n";
else else
@@ -727,37 +677,8 @@ static Standard_Integer OCC544 (Draw_Interpretor& di, Standard_Integer argc, con
di << "The TopoDS_Solid is finite.\n"; di << "The TopoDS_Solid is finite.\n";
} }
di << "The result is a ";
// Check to see if we have a solid // Check to see if we have a solid
switch (wallSolid.ShapeType()) { di << "The result is a " << "TopAbs_" << TopAbs::ShapeTypeToString (wallSolid.ShapeType()) << "\n";
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";
}
return 0; return 0;
} }
@@ -955,9 +876,7 @@ void QABugs::Commands_13(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; const char *group = "QABugs";
theCommands.Add ("OCC332", "OCC332 [wall_thickness [dia1 [dia2 [length [major_radius]]]]]", __FILE__, OCC332bug, group); 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("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); theCommands.Add("OCC817", "OCC817 result mesh_delta ", __FILE__, OCC817, group);
return; return;

20
tests/vselect/bugs/bug544 Normal file
View File

@@ -0,0 +1,20 @@
puts "========"
puts "OCC544: Problems with the results of MakePipeShell"
puts "========"
puts ""
cpulimit 5
pload MODELING VISUALIZATION QAcommands
vinit View1
vsetdispmode 1
OCC544
vdisplay -dispMode 1 result
vaspects result -material PLASTIC -color MATRABLUE -transparency 0.5
vfit
vviewparams -scale 2.05374 -proj 0.135192 -0.978297 -0.157031 -up -0.399854 -0.198875 0.894743 -at 415.781529476262 349.647084890243 417.026634136105
vmoveto 300 70
checkcolor 220 110 0.04 0.04 0.5
vdump $imagedir/${casename}.png