From: kgv Date: Sat, 16 Mar 2019 10:22:47 +0000 (+0300) Subject: 0030584: Modeling Algorithms, BRepFill_OffsetWire - access violation on Face having... X-Git-Tag: V7_4_0_beta~208 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=6b121e2b48f0331c5914ba0652aacc1bcd2e1c36 0030584: Modeling Algorithms, BRepFill_OffsetWire - access violation on Face having no boundaries Added missing NULL and empty result checks. Updated test cases using offset_wire_092.brep shape containing all Edges with TopAbs_INTERNAL orientation (hense no boundary to make offset). --- diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx index 876501e15e..279c3d3401 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/BRepFill/BRepFill_OffsetWire.cxx @@ -238,19 +238,27 @@ static Standard_Boolean KPartCircle BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap, Standard_Boolean& myIsDone) { - TopExp_Explorer exp(mySpine,TopAbs_EDGE); - Standard_Integer NbEdges = 0; - TopoDS_Edge E; - - for (; exp.More(); exp.Next()) { - NbEdges++; - E = TopoDS::Edge(exp.Current()); - if (NbEdges > 1) return Standard_False; + TopoDS_Edge E; + for (TopExp_Explorer anEdgeIter (mySpine, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next()) + { + if (!E.IsNull()) + { + return Standard_False; + } + E = TopoDS::Edge (anEdgeIter.Current()); + } + if (E.IsNull()) + { + return Standard_False; } Standard_Real f,l; TopLoc_Location L; Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,f,l); + if (C.IsNull()) + { + return Standard_False; + } if (C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { Handle(Geom_TrimmedCurve) Ct = Handle(Geom_TrimmedCurve)::DownCast(C); @@ -741,7 +749,6 @@ void BRepFill_OffsetWire::PerformWithBiLo return; BRep_Builder myBuilder; - myBuilder.MakeCompound(TopoDS::Compound(myShape)); //--------------------------------------------------------------------- // MapNodeVertex : associate to each node of the map (key1) and to @@ -785,6 +792,11 @@ void BRepFill_OffsetWire::PerformWithBiLo TopExp::Vertices(theWire, Ends[0], Ends[1]); } + if (Locus.NumberOfContours() == 0) + { + return; + } + for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) { TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic))); TopoDS_Shape& PE = PEE ; diff --git a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx index 2f9b0bc52a..1ae8546ab4 100644 --- a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx +++ b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx @@ -70,7 +70,12 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, Standard_Integer i; nbSect.Clear(); + theGraph = new MAT_Graph(); nbContours = anExplo.NumberOfContours(); + if (nbContours == 0) + { + return; + } //--------------------------------- // Lecture des donnees de anExplo. @@ -121,7 +126,6 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, TheRoots->BackAdd(TheMAT.Bisector()); } - theGraph = new MAT_Graph(); theGraph->Perform(TheMAT.SemiInfinite(), TheRoots, theTool.NumberOfItems(), diff --git a/src/BRepMAT2d/BRepMAT2d_Explorer.cxx b/src/BRepMAT2d/BRepMAT2d_Explorer.cxx index 662a0cd622..e231f4029f 100644 --- a/src/BRepMAT2d/BRepMAT2d_Explorer.cxx +++ b/src/BRepMAT2d/BRepMAT2d_Explorer.cxx @@ -123,12 +123,6 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, const TopoDS_Face& aFace, TopoDS_Face& aNewFace) { - // Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin - // This method is totally rewroted to include check - // of connection and creation of a new spine. - NewContour(); - myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False; - // Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin // Taking into account side of bisecting loci construction. // TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD)); @@ -136,10 +130,15 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine, BRepTools_WireExplorer anExp(Spine, aFace); // Modified by skv - Wed Jun 23 12:23:02 2004 Integration End TopTools_IndexedDataMapOfShapeShape anOldNewE; - if (!anExp.More()) return; + // Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin + // This method is totally rewroted to include check + // of connection and creation of a new spine. + NewContour(); + myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False; + TopoDS_Edge aFirstEdge = anExp.Current(); TopoDS_Edge aPrevEdge = aFirstEdge; Standard_Real UFirst,ULast, aD; diff --git a/tests/offset/wire_closed_inside_0_005/H6 b/tests/offset/wire_closed_inside_0_005/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_inside_0_005/H6 +++ b/tests/offset/wire_closed_inside_0_005/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 - diff --git a/tests/offset/wire_closed_inside_0_025/H6 b/tests/offset/wire_closed_inside_0_025/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_inside_0_025/H6 +++ b/tests/offset/wire_closed_inside_0_025/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 - diff --git a/tests/offset/wire_closed_inside_0_075/H6 b/tests/offset/wire_closed_inside_0_075/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_inside_0_075/H6 +++ b/tests/offset/wire_closed_inside_0_075/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 - diff --git a/tests/offset/wire_closed_outside_0_005/H6 b/tests/offset/wire_closed_outside_0_005/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_outside_0_005/H6 +++ b/tests/offset/wire_closed_outside_0_005/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 - diff --git a/tests/offset/wire_closed_outside_0_025/H6 b/tests/offset/wire_closed_outside_0_025/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_outside_0_025/H6 +++ b/tests/offset/wire_closed_outside_0_025/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 - diff --git a/tests/offset/wire_closed_outside_0_075/H6 b/tests/offset/wire_closed_outside_0_075/H6 index 5a55f95b95..b64760a759 100644 --- a/tests/offset/wire_closed_outside_0_075/H6 +++ b/tests/offset/wire_closed_outside_0_075/H6 @@ -1,8 +1,7 @@ -puts "TODO OCC23748 ALL: Error : The offset cannot be built." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC23748 Windows: Error: Offset is not done." -puts "TODO OCC23748 Linux: An exception was caught" -puts "TODO OCC23748 Linux: \\*\\* Exception \\*\\*" +puts "Tested shape has no Face boundaries (all Edges have TopAbs_INTERNAL flag), therefore offset will NOT be created" +puts "REQUIRED ALL: Error : The offset cannot be built." +puts "REQUIRED ALL: Error: The command cannot be built" +puts "REQUIRED ALL: Error: Offset is not done." restore [locate_data_file offset_wire_092.brep] s @@ -10,4 +9,3 @@ set length 0 set nbsh_v 0 set nbsh_e 0 set nbsh_w 0 -