From 8d52a74d037bf832ccce08e5b371e07382b9f4ca Mon Sep 17 00:00:00 2001 From: akaftasev Date: Thu, 29 Apr 2021 13:40:58 +0300 Subject: [PATCH] 0031147: Modeling Algorithms - BRepOffsetAPI_MakePipeShell null access Added to Draw command 'setsweep ' posibility to change degmax and segmax parameter manually by '-SM' and '-DM' options Added test Added new condition to prevent crash --- src/BRepFill/BRepFill_PipeShell.cxx | 4 +++ src/BRepTest/BRepTest_SweepCommands.cxx | 45 +++++++++++++++++++++++-- tests/pipe/bugs/bug31147 | 35 +++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 tests/pipe/bugs/bug31147 diff --git a/src/BRepFill/BRepFill_PipeShell.cxx b/src/BRepFill/BRepFill_PipeShell.cxx index a51ccc6b35..e8d408a0a7 100644 --- a/src/BRepFill/BRepFill_PipeShell.cxx +++ b/src/BRepFill/BRepFill_PipeShell.cxx @@ -1450,6 +1450,10 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep) for (Standard_Integer i = 1; i <= aVEdges->UpperRow(); i++) { const TopoDS_Shape& aVshape = aVEdges->Value(i, inde); + if (aVshape.IsNull()) + { + continue; + } if (aVshape.ShapeType() == TopAbs_EDGE || aVshape.ShapeType() == TopAbs_FACE) ListVshapes->Append(aVshape); diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx index c7f2ddc5c5..be6dce7a25 100644 --- a/src/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/BRepTest/BRepTest_SweepCommands.cxx @@ -560,6 +560,10 @@ static Standard_Integer setsweep(Draw_Interpretor& di, di << " -CN dx dy dz : BiNormal is given by dx dy dz\n"; di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n"; di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n"; + di << " -SM : Set the maximum degree of approximation\n"; + di << " paramvalue more then 0 (100 by default)\n"; + di << " -DM : Set the maximum number of span of approximation\n"; + di << " paramvalue [1; 14] (11 by default)\n"; return 0; } @@ -630,6 +634,42 @@ static Standard_Integer setsweep(Draw_Interpretor& di, (BRepFill_TypeOfContact)KeepContact); } } + else if (!strcmp(a[1], "-DM")) + { + if (n != 3) + { + di << "bad arguments !\n"; + return 1; + } + + if (Draw::Atoi(a[2]) > 0 && Draw::Atoi(a[2]) < 15) + { + Sweep->SetMaxDegree(Draw::Atoi(a[2])); + } + else + { + di << " -DM paramvalue must be [1; 14]\n"; + return 1; + } + } + else if (!strcmp(a[1], "-SM")) + { + if (n != 3) + { + di << "bad arguments !\n"; + return 1; + } + + if (Draw::Atoi(a[2]) > 0) + { + Sweep->SetMaxSegments(Draw::Atoi(a[2])); + } + else + { + di << " -SM paramvalue must be more then 0\n"; + return 1; + } + } else { di << "The option " << a[1] << " is unknown !\n"; @@ -638,7 +678,6 @@ static Standard_Integer setsweep(Draw_Interpretor& di, return 0; } - //======================================================================= // addsweep //======================================================================= @@ -985,9 +1024,9 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands) theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep", __FILE__, errorsweep, g); - theCommands.Add("simulsweep", "simulsweep r [n] [option]" + theCommands.Add("simulsweep", "simulsweep r [n] [option]", __FILE__, simulsweep, g); - theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]" + theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]", __FILE__, geompipe, g); theCommands.Add("middlepath", "middlepath res shape startshape endshape", diff --git a/tests/pipe/bugs/bug31147 b/tests/pipe/bugs/bug31147 new file mode 100644 index 0000000000..485b5b895c --- /dev/null +++ b/tests/pipe/bugs/bug31147 @@ -0,0 +1,35 @@ +puts "============" +puts "0031147: Modeling Algorithms - BRepOffsetAPI_MakePipeShell null access" +puts "============" +puts "" + +pload VISUALIZATION + +restore [locate_data_file bug31147.brep] s +explode s e +wire spine s_1 +wire profile s_2 + +mksweep spine +addsweep profile +setsweep -SM 1000 +setsweep -DM 14 +buildsweep result -S -C + +set info1 [errorsweep] + +set check [regexp {Tolerance on surfaces = ([0-9\-+Ee.]+)} $info1 str error] + +if { $error > 1.e-4 } { + puts "Error: bad tolerance of result" +} + +vinit +vdisplay result +vsetdispmode 1 +vfit + +checkshape result +checkview -screenshot -3d -path ${imagedir}/${test_image}.png + +puts "TEST COMPLETED"