mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0029939: Modeling Algorithms - add NULL check to BRepGProp_Face::Load()
BRepGProp_Face::Load() has been protected against crash in case of edges without p-curves.
This commit is contained in:
@@ -175,11 +175,14 @@ void BRepGProp_Face::Bounds(Standard_Real& U1,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepGProp_Face::Load(const TopoDS_Edge& E)
|
||||
bool BRepGProp_Face::Load(const TopoDS_Edge& E)
|
||||
{
|
||||
Standard_Real a,b;
|
||||
Handle(Geom2d_Curve) C =
|
||||
BRep_Tool::CurveOnSurface(E, mySurface.Face(), a,b);
|
||||
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E, mySurface.Face(), a,b);
|
||||
if (C.IsNull())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (E.Orientation() == TopAbs_REVERSED) {
|
||||
Standard_Real x = a;
|
||||
a = C->ReversedParameter(b);
|
||||
@@ -187,6 +190,7 @@ void BRepGProp_Face::Load(const TopoDS_Edge& E)
|
||||
C = C->Reversed();
|
||||
}
|
||||
myCurve.Load(C,a,b);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -101,7 +101,8 @@ public:
|
||||
Standard_EXPORT void Normal (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& VNor) const;
|
||||
|
||||
//! Loading the boundary arc.
|
||||
Standard_EXPORT void Load (const TopoDS_Edge& E);
|
||||
//! Returns FALSE if edge has no P-Curve.
|
||||
Standard_EXPORT bool Load (const TopoDS_Edge& E);
|
||||
|
||||
//! Returns the parametric value of the start point of
|
||||
//! the current arc of curve.
|
||||
|
@@ -625,7 +625,10 @@ Standard_Real BRepGProp_Gauss::Compute(
|
||||
}
|
||||
else
|
||||
{
|
||||
theSurface.Load(theDomain.Value());
|
||||
if (!theSurface.Load(theDomain.Value()))
|
||||
{
|
||||
return Precision::Infinite();
|
||||
}
|
||||
NbLGaussP[0] = theSurface.LIntOrder(anEpsilon);
|
||||
}
|
||||
|
||||
@@ -1116,9 +1119,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
||||
math::GaussWeights(NbGaussgp_Pnts, GaussSWV);
|
||||
|
||||
BRepGProp_Gauss::Inertia anInertia;
|
||||
while (theDomain.More())
|
||||
for (; theDomain.More(); theDomain.Next())
|
||||
{
|
||||
theSurface.Load(theDomain.Value());
|
||||
if (!theSurface.Load(theDomain.Value()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Integer NbCGaussgp_Pnts =
|
||||
Min(theSurface.IntegrationOrder(), math::GaussPointsMax());
|
||||
@@ -1171,8 +1177,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
||||
|
||||
multAndRestoreInertia(lr, aCInertia);
|
||||
addAndRestoreInertia (aCInertia, anInertia);
|
||||
|
||||
theDomain.Next();
|
||||
}
|
||||
|
||||
convert(anInertia, theOutGravityCenter, theOutInertia, theOutMass);
|
||||
@@ -1200,9 +1204,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
||||
Standard_Real _u2 = u2; //OCC104
|
||||
|
||||
BRepGProp_Gauss::Inertia anInertia;
|
||||
while (theDomain.More())
|
||||
for (; theDomain.More(); theDomain.Next())
|
||||
{
|
||||
theSurface.Load(theDomain.Value());
|
||||
if (!theSurface.Load(theDomain.Value()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aVNbCGaussgp_Pnts =
|
||||
theSurface.VIntegrationOrder();
|
||||
@@ -1265,8 +1272,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
||||
|
||||
multAndRestoreInertia(lr, aCInertia);
|
||||
addAndRestoreInertia (aCInertia, anInertia);
|
||||
|
||||
theDomain.Next();
|
||||
}
|
||||
|
||||
convert(anInertia, theCoeff, theIsByPoint, theOutGravityCenter, theOutInertia, theOutMass);
|
||||
|
Reference in New Issue
Block a user