0027568: Exception is thrown when a degenerated edge is added to a wire
authorTimo Roth <timo.roth@cfturbo.de>
Wed, 15 Jun 2016 08:04:44 +0000 (11:04 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 23 Jun 2016 15:14:27 +0000 (18:14 +0300)
Test cases for issue CR27568

Other methods of BRep_Tool corrected to ensure that output arguments are always initialized

src/BRep/BRep_Tool.cxx
tests/bugs/modalg_6/bug27568 [new file with mode: 0644]

index 64b03ba..3fa6c65 100644 (file)
@@ -179,6 +179,7 @@ const Handle(Geom_Curve)&  BRep_Tool::Curve(const TopoDS_Edge& E,
     itcr.Next();
   }
   L.Identity();
+  First = Last = 0.;
   return nullCurve;
 }
 
@@ -346,6 +347,7 @@ Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
 
     if (C3d.IsNull())
     {
+      First = Last = 0.;
       return nullPCurve;
     }
 
@@ -384,6 +386,7 @@ Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
     return pc;
   }
   
+  First = Last = 0.;
   return nullPCurve;
 }
 
@@ -416,9 +419,10 @@ void  BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
     itcr.Next();
   }
   
-  C = Handle(Geom2d_Curve)();
-  S = Handle(Geom_Surface)();
-  L = TopLoc_Location();
+  C.Nullify();
+  S.Nullify();
+  L.Identity();
+  First = Last = 0.;
 }
 
 //=======================================================================
@@ -465,9 +469,10 @@ void  BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
     itcr.Next();
   }
   
-  C = Handle(Geom2d_Curve)();
-  S = Handle(Geom_Surface)();
-  L = TopLoc_Location();
+  C.Nullify();
+  S.Nullify();
+  L.Identity();
+  First = Last = 0.;
 }
 
 //=======================================================================
@@ -553,9 +558,9 @@ void BRep_Tool::PolygonOnSurface(const TopoDS_Edge&      E,
     itcr.Next();
   }
   
-  L = TopLoc_Location();
-  P = Handle(Poly_Polygon2D)();
-  S = Handle(Geom_Surface)();
+  L.Identity();
+  P.Nullify();
+  S.Nullify();
 }
 
 //=======================================================================
@@ -591,9 +596,9 @@ void BRep_Tool::PolygonOnSurface(const TopoDS_Edge&      E,
     itcr.Next();
   }
   
-  L = TopLoc_Location();
-  P = Handle(Poly_Polygon2D)();
-  S = Handle(Geom_Surface)();
+  L.Identity();
+  P.Nullify();
+  S.Nullify();
 }
 
 //=======================================================================
@@ -659,9 +664,9 @@ BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge&                   E,
     itcr.Next();
   }
   
-  L = TopLoc_Location();
-  P = Handle(Poly_PolygonOnTriangulation)();
-  T = Handle(Poly_Triangulation)();
+  L.Identity();
+  P.Nullify();
+  T.Nullify();
 }
 
 //=======================================================================
@@ -699,9 +704,9 @@ BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge&                   E,
     itcr.Next();
   }
   
-  L = TopLoc_Location();
-  P = Handle(Poly_PolygonOnTriangulation)();
-  T = Handle(Poly_Triangulation)();
+  L.Identity();
+  P.Nullify();
+  T.Nullify();
 }
 
 //=======================================================================
@@ -839,7 +844,7 @@ void  BRep_Tool::Range(const TopoDS_Edge& E,
   //  set the range to all the representations
   const BRep_TEdge* TE = static_cast<const BRep_TEdge*>(E.TShape().get());
   BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
-
+  
   while (itcr.More()) {
     const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
     if (cr->IsCurve3D()) {
@@ -847,17 +852,18 @@ void  BRep_Tool::Range(const TopoDS_Edge& E,
       if (!CR->Curve3D().IsNull()) {
         First = CR->First(); 
         Last = CR->Last();
-        break;
+        return;
       }
     }
     else if (cr->IsCurveOnSurface()) {
       const BRep_GCurve* CR = static_cast<const BRep_GCurve*>(cr.get());
       First = CR->First(); 
       Last = CR->Last();
-      break;
+      return;
     }
     itcr.Next();
   }
+  First = Last = 0.;
 }
 
 //=======================================================================
@@ -890,7 +896,7 @@ void  BRep_Tool::Range(const TopoDS_Edge& E,
     Range(E,First,Last);
   }
   E.TShape()->Modified(Standard_True);
- }
+}
 
 //=======================================================================
 //function : Range
@@ -979,7 +985,12 @@ void  BRep_Tool::UVPoints(const TopoDS_Edge& E,
       ElSLib::Parameters(pln,PL,u,v);
     }
     PLast.SetCoord(u,v);
-  }    
+  }
+  else
+  {
+    PFirst.SetCoord (0., 0.);
+    PLast.SetCoord (0., 0.);
+  }
 }
 
 //=======================================================================
diff --git a/tests/bugs/modalg_6/bug27568 b/tests/bugs/modalg_6/bug27568
new file mode 100644 (file)
index 0000000..05b61ba
--- /dev/null
@@ -0,0 +1,19 @@
+puts "============"
+puts "OCC27568"
+puts "============"
+puts ""
+######################################################
+# Exception is thrown when a degenerated edge is added to a wire
+######################################################
+
+restore [locate_data_file bug27568_curves.brep] c
+
+explode c
+
+wire result c_1 c_2
+
+checknbshapes result -vertex 2 -edge 2 -wire 1
+
+smallview
+fit
+checkview -screenshot -2d -path ${imagedir}/${casename}.png