]> OCCT Git - occt.git/commitdiff
0027063: BRepGProps raises exception on edge with no curves
authorifv <igor.feoktistov@opencascade.com>
Tue, 10 Dec 2013 11:40:40 +0000 (15:40 +0400)
committerabv <abv@opencascade.com>
Fri, 5 Feb 2016 08:14:40 +0000 (11:14 +0300)
Method BRepGProp::LinearProperties() is corrected to treat not geometric edges (their length is zero). To avoid wrong working of command nexplode global properties are calculated as point properties of vertexes. Small value Epsilon(1.) is used as density of points. This prevents exception on shapes that contain such edges, e.g. copy of a wire containing degenerated edge.

Method BRep_Tool::IsGeometric() is optimized to avoid nested iteration for check of 3D curve for Null.
Small bug is fixed in GProp_PGProps.cxx

src/BRep/BRep_Tool.cxx
src/BRepGProp/BRepGProp.cxx
src/GProp/GProp_PGProps.cxx
tests/bugs/modalg_5/bug27063 [new file with mode: 0644]

index 10cf75cfedb43154eca5e2682072412559064308..64b03ba020e4eb11ac02638e4da823481b471451 100644 (file)
@@ -220,10 +220,9 @@ Standard_Boolean  BRep_Tool::IsGeometric(const TopoDS_Edge& E)
   while (itcr.More()) {
     const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
     if (cr->IsCurve3D()) {
-      Standard_Real first, last;
-      TopLoc_Location L;
-      const Handle(Geom_Curve)&  C = BRep_Tool::Curve(E, L, first, last);
-      if (!C.IsNull()) return Standard_True;
+      Handle(BRep_Curve3D) GC (Handle(BRep_Curve3D)::DownCast (cr));
+      if (! GC.IsNull() && ! GC->Curve3D().IsNull())
+        return Standard_True;
     }
     else if (cr->IsCurveOnSurface()) return Standard_True;
     itcr.Next();
index 8367ddaa30f5044f0f0dc251bf64ae41de88c900..b6a757408231f3fc9f9d26fb102ec63737880e20 100644 (file)
@@ -17,6 +17,7 @@
 #include <BRepGProp_Sinert.hxx>
 #include <BRepGProp_Vinert.hxx>
 #include <BRepGProp_VinertGK.hxx>
+#include <GProp_PGProps.hxx>
 #include <BRepGProp_Face.hxx>
 #include <BRepGProp_Domain.hxx>
 #include <TopoDS.hxx>
@@ -47,12 +48,27 @@ void  BRepGProp::LinearProperties(const TopoDS_Shape& S, GProp_GProps& SProps){
   SProps = GProp_GProps(P);
 
   BRepAdaptor_Curve   BAC;
-  //  Standard_Integer n,i;
+  Standard_Real eps = Epsilon(1.);
   TopExp_Explorer ex;
   for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) {
-    BAC.Initialize(TopoDS::Edge(ex.Current()));
-    BRepGProp_Cinert CG(BAC,P);
-    SProps.Add(CG);
+    const TopoDS_Edge& aE = TopoDS::Edge(ex.Current());
+    if(!BRep_Tool::IsGeometric(aE))
+    {
+      GProp_PGProps aPProps;
+      TopoDS_Iterator anIter(aE);
+      for(; anIter.More(); anIter.Next())
+      {
+        const TopoDS_Vertex& aV = TopoDS::Vertex(anIter.Value());
+        aPProps.AddPoint(BRep_Tool::Pnt(aV), eps);
+      }
+      SProps.Add(aPProps);
+    }
+    else
+    {
+      BAC.Initialize(aE);
+      BRepGProp_Cinert CG(BAC,P);
+      SProps.Add(CG);
+    }
   }
 }
 
index ffbde25ed1cebe28a2889bf10cde2161c14fb4e0..86a795257ac92ccda0b7b63ddcba05572f33a547 100644 (file)
@@ -84,7 +84,7 @@ void GProp_PGProps::AddPoint (const gp_Pnt& P, const Standard_Real Density)
   Mat Mp (XYZ (Ixx, Ixy, Ixz), XYZ (Ixy, Iyy, Iyz), XYZ (Ixz, Iyz, Izz));
   if (dim == 0) {
     dim = Density;
-    g.SetXYZ (P.XYZ().Multiplied (Density));
+    g = P;
     inertia = Mp * Density;
   }
   else {
diff --git a/tests/bugs/modalg_5/bug27063 b/tests/bugs/modalg_5/bug27063
new file mode 100644 (file)
index 0000000..ab3d41d
--- /dev/null
@@ -0,0 +1,8 @@
+puts "============"
+puts "0027063: BRepGProps raises  e x c e p t i o n  on edge with no curves"
+puts "============"
+
+restore [locate_data_file bug27063_emptyedge.brep] result
+
+puts "Check that lprops does not crash on empty edge"
+lprops result