0030584: Modeling Algorithms, BRepFill_OffsetWire - access violation on Face having...
authorkgv <kgv@opencascade.com>
Sat, 16 Mar 2019 10:22:47 +0000 (13:22 +0300)
committerapn <apn@opencascade.com>
Mon, 18 Mar 2019 16:42:47 +0000 (19:42 +0300)
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).

src/BRepFill/BRepFill_OffsetWire.cxx
src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx
src/BRepMAT2d/BRepMAT2d_Explorer.cxx
tests/offset/wire_closed_inside_0_005/H6
tests/offset/wire_closed_inside_0_025/H6
tests/offset/wire_closed_inside_0_075/H6
tests/offset/wire_closed_outside_0_005/H6
tests/offset/wire_closed_outside_0_025/H6
tests/offset/wire_closed_outside_0_075/H6

index 876501e15eec4e9ef2d87c98a1d65ca1b896146c..279c3d3401f133a2afd4df2303f87cae12598f95 100644 (file)
@@ -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 ;      
index 2f9b0bc52ad8e6196123542094e0e376ec4a2389..1ae8546ab45da210d2f745c1eed5e6986012c5a2 100644 (file)
@@ -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(), 
index 662a0cd6225459c970ad6b817dbfe129e8b1cb6a..e231f4029f8fffe41341f4ca513518502e52045a 100644 (file)
@@ -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;
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-
index 5a55f95b95b58ef081a1690e20af84c172cc44d5..b64760a759bc68511cf493b7f358de897e9d5d57 100644 (file)
@@ -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
-