1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0027063: BRepGProps raises exception on edge with no curves

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
This commit is contained in:
ifv 2013-12-10 15:40:40 +04:00 committed by abv
parent 5747059b21
commit a4ed7309ff
4 changed files with 32 additions and 9 deletions

View 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();

View 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);
}
}
}

View 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 {

View File

@ -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