diff --git a/src/BRep/BRep_Tool.cxx b/src/BRep/BRep_Tool.cxx index 10cf75cfed..64b03ba020 100644 --- a/src/BRep/BRep_Tool.cxx +++ b/src/BRep/BRep_Tool.cxx @@ -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(); diff --git a/src/BRepGProp/BRepGProp.cxx b/src/BRepGProp/BRepGProp.cxx index 8367ddaa30..b6a7574082 100644 --- a/src/BRepGProp/BRepGProp.cxx +++ b/src/BRepGProp/BRepGProp.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -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); + } } } diff --git a/src/GProp/GProp_PGProps.cxx b/src/GProp/GProp_PGProps.cxx index ffbde25ed1..86a795257a 100644 --- a/src/GProp/GProp_PGProps.cxx +++ b/src/GProp/GProp_PGProps.cxx @@ -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 index 0000000000..ab3d41db35 --- /dev/null +++ b/tests/bugs/modalg_5/bug27063 @@ -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