mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-09 18:50:54 +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:
parent
e119b6c3c7
commit
8ff2e494f5
@ -175,11 +175,14 @@ void BRepGProp_Face::Bounds(Standard_Real& U1,
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void BRepGProp_Face::Load(const TopoDS_Edge& E)
|
bool BRepGProp_Face::Load(const TopoDS_Edge& E)
|
||||||
{
|
{
|
||||||
Standard_Real a,b;
|
Standard_Real a,b;
|
||||||
Handle(Geom2d_Curve) C =
|
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E, mySurface.Face(), a,b);
|
||||||
BRep_Tool::CurveOnSurface(E, mySurface.Face(), a,b);
|
if (C.IsNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (E.Orientation() == TopAbs_REVERSED) {
|
if (E.Orientation() == TopAbs_REVERSED) {
|
||||||
Standard_Real x = a;
|
Standard_Real x = a;
|
||||||
a = C->ReversedParameter(b);
|
a = C->ReversedParameter(b);
|
||||||
@ -187,6 +190,7 @@ void BRepGProp_Face::Load(const TopoDS_Edge& E)
|
|||||||
C = C->Reversed();
|
C = C->Reversed();
|
||||||
}
|
}
|
||||||
myCurve.Load(C,a,b);
|
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;
|
Standard_EXPORT void Normal (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& VNor) const;
|
||||||
|
|
||||||
//! Loading the boundary arc.
|
//! 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
|
//! Returns the parametric value of the start point of
|
||||||
//! the current arc of curve.
|
//! the current arc of curve.
|
||||||
|
@ -625,7 +625,10 @@ Standard_Real BRepGProp_Gauss::Compute(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theSurface.Load(theDomain.Value());
|
if (!theSurface.Load(theDomain.Value()))
|
||||||
|
{
|
||||||
|
return Precision::Infinite();
|
||||||
|
}
|
||||||
NbLGaussP[0] = theSurface.LIntOrder(anEpsilon);
|
NbLGaussP[0] = theSurface.LIntOrder(anEpsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,9 +1119,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
|||||||
math::GaussWeights(NbGaussgp_Pnts, GaussSWV);
|
math::GaussWeights(NbGaussgp_Pnts, GaussSWV);
|
||||||
|
|
||||||
BRepGProp_Gauss::Inertia anInertia;
|
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 =
|
Standard_Integer NbCGaussgp_Pnts =
|
||||||
Min(theSurface.IntegrationOrder(), math::GaussPointsMax());
|
Min(theSurface.IntegrationOrder(), math::GaussPointsMax());
|
||||||
@ -1171,8 +1177,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
|||||||
|
|
||||||
multAndRestoreInertia(lr, aCInertia);
|
multAndRestoreInertia(lr, aCInertia);
|
||||||
addAndRestoreInertia (aCInertia, anInertia);
|
addAndRestoreInertia (aCInertia, anInertia);
|
||||||
|
|
||||||
theDomain.Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
convert(anInertia, theOutGravityCenter, theOutInertia, theOutMass);
|
convert(anInertia, theOutGravityCenter, theOutInertia, theOutMass);
|
||||||
@ -1200,9 +1204,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
|||||||
Standard_Real _u2 = u2; //OCC104
|
Standard_Real _u2 = u2; //OCC104
|
||||||
|
|
||||||
BRepGProp_Gauss::Inertia anInertia;
|
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 =
|
const Standard_Integer aVNbCGaussgp_Pnts =
|
||||||
theSurface.VIntegrationOrder();
|
theSurface.VIntegrationOrder();
|
||||||
@ -1265,8 +1272,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face& theSurface,
|
|||||||
|
|
||||||
multAndRestoreInertia(lr, aCInertia);
|
multAndRestoreInertia(lr, aCInertia);
|
||||||
addAndRestoreInertia (aCInertia, anInertia);
|
addAndRestoreInertia (aCInertia, anInertia);
|
||||||
|
|
||||||
theDomain.Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
convert(anInertia, theCoeff, theIsByPoint, theOutGravityCenter, theOutInertia, theOutMass);
|
convert(anInertia, theCoeff, theIsByPoint, theOutGravityCenter, theOutInertia, theOutMass);
|
||||||
|
215
tests/bugs/modalg_7/bug29939
Normal file
215
tests/bugs/modalg_7/bug29939
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "0029939: Modeling Algorithms - add NULL check to BRepGProp_Face::Load()"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload MODELING VISUALIZATION
|
||||||
|
|
||||||
|
# sample Face with some Curve2ds missing
|
||||||
|
set aShapeData "
|
||||||
|
DBRep_DrawableShape
|
||||||
|
|
||||||
|
CASCADE Topology V1, (c) Matra-Datavision
|
||||||
|
Locations 6
|
||||||
|
1
|
||||||
|
-6.93889390391e-18 1 0 -266.829932547
|
||||||
|
-1 -6.93889390391e-18 0 0
|
||||||
|
0 0 1 8.881784197e-16
|
||||||
|
1
|
||||||
|
1 -1.23204712323214e-17 3.48118418796994e-18 -357.513195371
|
||||||
|
1.23204706275e-17 0.999999999999985 1.73740064720997e-07 5.87091965856e-15
|
||||||
|
-3.48118632852936e-18 -1.73740064720997e-07 0.999999999999985 1.00245277978e-14
|
||||||
|
1
|
||||||
|
1 -3.49249707682408e-17 -1.73723591341045e-16 613.47435459
|
||||||
|
3.30382668395332e-18 0.983888906493258 -0.178780926498047 -24.4029550353
|
||||||
|
1.77168632948486e-16 0.178780926498047 0.983888906493258 17.0096765133
|
||||||
|
1
|
||||||
|
-0.891601662261103 -0.296724731883325 0.34205395676999 289.371401338
|
||||||
|
0.321472550183128 -0.946772534430101 0.0166483490940992 -855.09721987
|
||||||
|
0.318907314641721 0.12480465350928 0.939532821741973 -233.868191989
|
||||||
|
2 1 1 2 1 3 1 4 1 0
|
||||||
|
2 4 -1 3 -1 2 -1 1 -1 0
|
||||||
|
Curve2ds 8
|
||||||
|
1 3.1415926535885261 -3.1415926537565504 -9.6123430370698398e-15 1
|
||||||
|
1 2.6415926535897927 3.1415926535897829 1 3.227912221389625e-15
|
||||||
|
1 -3.641592653589794 3.1415926535899144 1 -2.1627771834064215e-14
|
||||||
|
1 -3.641592653589794 3.1415926535897447 1 8.2694421717546571e-15
|
||||||
|
1 -3.641592653589794 3.1415926535897984 1 -2.5444437451706449e-15
|
||||||
|
1 -3.6415926535891083 3.1415926535895933 1 4.5496352846831891e-14
|
||||||
|
1 0 -3.1415926537565433 0 1
|
||||||
|
1 -3.6415926535884808 1.5707963267948022 1 1.8093822187836176e-14
|
||||||
|
Curves 9
|
||||||
|
2 84.858320332900007 -63 155.33211345500001 -0.87758256189037243 0 0.4794255386042035 -0.4794255386042035 0 -0.87758256189037243 -0 -1 0 2
|
||||||
|
2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175
|
||||||
|
7 0 0 4 5 2 9.51279659315 -64.469009257300002 174.74125643599999 10.8275887261 -63.750060296000001 174.66968003599999 12.261430838000001 -63.2501700292 174.57846249100001 13.7577343107 -62.999999975000001 174.464825784 15.252255180300001 -63 174.33407214900001
|
||||||
|
0 5 8.4865807349600004 5
|
||||||
|
2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175
|
||||||
|
2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175
|
||||||
|
2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175
|
||||||
|
2 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 0 0 1 1 0 -0 175
|
||||||
|
2 -84.858320332900007 -63 -155.33211345500001 0.87758256189037243 -0 -0.4794255386042035 0.4794255386042035 0 0.87758256189037243 0 -1 0 2
|
||||||
|
2 -4.2632564145599997e-14 -61 -2.8421709430399997e-14 0 1 0 0 -0 1 1 0 -0 177
|
||||||
|
Polygon3D 0
|
||||||
|
PolygonOnTriangulations 0
|
||||||
|
Surfaces 1
|
||||||
|
5 -5.6843418860799994e-14 -63 4.2632564145599997e-14 -0 1 0 -0.4794255386042035 0 -0.87758256189037243 -0.87758256189037243 -0 0.4794255386042035 177 2
|
||||||
|
Triangulations 0
|
||||||
|
|
||||||
|
TShapes 20
|
||||||
|
Ve
|
||||||
|
1.00005e-07
|
||||||
|
446.609600903292 -747.182655462685 -128.403390746598
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ve
|
||||||
|
1e-07
|
||||||
|
447.487711636221 -749.041771994926 -130.345710818059
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 1 0 4.71238898051187 6.28318530717959
|
||||||
|
2 1 1 0 4.71238898051187 6.28318530717959
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+20 6 -19 6 *
|
||||||
|
Ve
|
||||||
|
0.000801323308506101
|
||||||
|
439.731321696259 -808.930183254921 -91.6608968795304
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 2 0 0.0872664625995157 0.499999999999316
|
||||||
|
2 2 1 0 0.0872664625995157 0.499999999999316
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+17 6 -19 6 *
|
||||||
|
Ve
|
||||||
|
9.50082811303135e-06
|
||||||
|
439.731308365217 -808.930245083447 -91.6608718249203
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 3 0 8.48648424147889 8.48658045180264
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+15 6 -17 6 *
|
||||||
|
Ve
|
||||||
|
0.000801323588114315
|
||||||
|
400.97481659698 -922.047565623353 -85.9891266596981
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 4 0 5.672320068985 6.37045138103039
|
||||||
|
2 3 1 0 5.672320068985 6.37045138103039
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+13 6 -15 6 *
|
||||||
|
Ve
|
||||||
|
0.000801323173512029
|
||||||
|
346.92570979233 -1004.00637567207 -154.481647187039
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 5 0 4.974188368183 5.672320068985
|
||||||
|
2 4 1 0 4.974188368183 5.672320068985
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+11 6 -13 6 *
|
||||||
|
Ve
|
||||||
|
0.000801323604481778
|
||||||
|
302.874179046209 -1016.45717530592 -265.090046896853
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 6 0 4.27605666738522 4.974188368183
|
||||||
|
2 5 1 0 4.27605666738522 4.974188368183
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+9 6 -11 6 *
|
||||||
|
Ve
|
||||||
|
1e-07
|
||||||
|
289.096508106169 -961.871772388525 -358.63416338841
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 7 0 3.64159265358911 4.27605666738522
|
||||||
|
2 6 1 0 3.64159265358911 4.27605666738522
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+7 6 -9 6 *
|
||||||
|
Ve
|
||||||
|
1.00005e-07
|
||||||
|
286.408212189964 -962.444998719012 -359.300854202584
|
||||||
|
0 0
|
||||||
|
|
||||||
|
0101101
|
||||||
|
*
|
||||||
|
Ed
|
||||||
|
1e-07 1 1 0
|
||||||
|
1 8 0 4.71238898038469 6.28318530717959
|
||||||
|
2 7 1 0 4.71238898038469 6.28318530717959
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+5 6 -7 6 *
|
||||||
|
Ed
|
||||||
|
1.00005e-07 1 1 0
|
||||||
|
1 9 0 3.64159265358848 6.78318530718743
|
||||||
|
2 8 1 0 3.64159265358848 6.78318530718743
|
||||||
|
0
|
||||||
|
|
||||||
|
0101000
|
||||||
|
+5 6 -20 6 *
|
||||||
|
Wi
|
||||||
|
|
||||||
|
0101100
|
||||||
|
+18 0 -16 0 -14 0 -12 0 -10 0 -8 0 -6 0 -4 0 +3 0 *
|
||||||
|
Fa
|
||||||
|
0 1e-07 1 0
|
||||||
|
|
||||||
|
1101000
|
||||||
|
+2 0 *
|
||||||
|
|
||||||
|
-1 5
|
||||||
|
0
|
||||||
|
|
||||||
|
"
|
||||||
|
|
||||||
|
set aFile [open "$imagedir/${casename}.brep" wb]
|
||||||
|
puts $aFile $aShapeData
|
||||||
|
close $aFile
|
||||||
|
restore "$imagedir/${casename}.brep" f
|
||||||
|
file delete "$imagedir/${casename}.brep"
|
||||||
|
|
||||||
|
sprops f
|
||||||
|
vprops f
|
Loading…
x
Reference in New Issue
Block a user