The algorithm BRepExtrema_DistShapeShape has been protected against exceptions when non-geometric shape data is given on input, like a face containing triangulation only or an edge containing polygon only. Such faces/edges are ignored by the algorithm.
BRepGProps::VolumeProperties() now ignores faces without geometric surface to avoid access violation.
void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
{
- Standard_Real V1,V2;
+ if (!BRep_Tool::IsGeometric(E2))
+ return; // protect against non-geometric type (e.g. polygon)
+ Standard_Real V1, V2;
BRepAdaptor_Curve Curv(E2);
myHC = new BRepAdaptor_HCurve(Curv);
Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion());
void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
{
+ if (!BRep_Tool::IsGeometric(E1))
+ return; // protect against non-geometric type (e.g. polygon)
Standard_Real U1, U2;
BRepAdaptor_Curve Curv(E1);
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
{
BRepAdaptor_Surface Surf(F);
+ if (Surf.GetType() == GeomAbs_OtherSurface ||
+ !BRep_Tool::IsGeometric(E))
+ return; // protect against non-geometric type (e.g. triangulation)
BRepAdaptor_Curve aC(E);
myHS = new BRepAdaptor_HSurface(Surf);
Standard_Real aTolC, aTolS;
myPointsOnS.Clear();
myPointsOnC.Clear();
+ if (myHS.IsNull())
+ return; // protect against non-geometric type (e.g. triangulation)
+
Standard_Real U1, U2;
BRep_Tool::Range(E, U1, U2);
void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
{
BRepAdaptor_Surface Surf(F2);
+ if (Surf.GetType() == GeomAbs_OtherSurface)
+ return; // protect against non-geometric type (e.g. triangulation)
+
myHS = new BRepAdaptor_HSurface(Surf);
Standard_Real Tol = Min(BRep_Tool::Tolerance(F2), Precision::Confusion());
Tol = Min(Surf.UResolution(Tol), Surf.VResolution(Tol));
myPointsOnS2.Clear();
BRepAdaptor_Surface Surf1(F1);
+ if (myHS.IsNull() || Surf1.GetType() == GeomAbs_OtherSurface)
+ return; // protect against non-geometric type (e.g. triangulation)
+
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
Standard_Real Tol1 = Min(BRep_Tool::Tolerance(F1), Precision::Confusion());
Tol1 = Min(Surf1.UResolution(Tol1), Surf1.VResolution(Tol1));
void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
{
- Standard_Real U1,U2;
+ if (!BRep_Tool::IsGeometric(E))
+ return; // protect against non-geometric type (e.g. polygon)
+ Standard_Real U1, U2;
BRepAdaptor_Curve Curv(E);
myHC = new BRepAdaptor_HCurve(Curv);
Standard_Real Tol = Min(BRep_Tool::Tolerance(E), Precision::Confusion());
void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
{
- gp_Pnt P = BRep_Tool::Pnt(V);
- myExtPC.Perform(P);
+ if (!myHC.IsNull())
+ {
+ gp_Pnt P = BRep_Tool::Pnt(V);
+ myExtPC.Perform(P);
+ }
}
// cette surface doit etre en champ. Extrema ne fait
// pas de copie et prend seulement un pointeur dessus.
mySurf.Initialize(TheFace, Standard_False);
+
+ if (mySurf.GetType() == GeomAbs_OtherSurface)
+ return; // protect against non-geometric type (e.g. triangulation)
+
Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion());
Standard_Real aTolU, aTolV;
aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
myPoints.Clear();
const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
+ if (mySurf.GetType() == GeomAbs_OtherSurface)
+ return; // protect against non-geometric type (e.g. triangulation)
+
myExtPS.Perform(P);
// Exploration of points and classification
BRepGProp_Domain BD;
TopTools_MapOfShape aFwdFMap;
TopTools_MapOfShape aRvsFMap;
+ TopLoc_Location aLocDummy;
for (ex.Init(S,TopAbs_FACE), i = 1; ex.More(); ex.Next(), i++) {
const TopoDS_Face& F = TopoDS::Face(ex.Current());
continue;
}
}
+ {
+ const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (F, aLocDummy);
+ if (aSurf.IsNull())
+ {
+ // skip faces without geometry
+ continue;
+ }
+ }
+
if (isFwd || isRvs){
BF.Load(F);
TopoDS_Iterator aWIter(F);
Standard_Real anError = 0.;
TopTools_MapOfShape aFwdFMap;
TopTools_MapOfShape aRvsFMap;
+ TopLoc_Location aLocDummy;
aVProps.SetLocation(aLoc);
continue;
}
}
+ {
+ const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aLocDummy);
+ if (aSurf.IsNull())
+ {
+ // skip faces without geometry
+ continue;
+ }
+ }
+
if (isFwd || isRvs){
aPropFace.Load(aFace);
Standard_Real anError = 0.;
TopTools_MapOfShape aFwdFMap;
TopTools_MapOfShape aRvsFMap;
+ TopLoc_Location aLocDummy;
aVProps.SetLocation(aLoc);
continue;
}
}
+ {
+ const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aLocDummy);
+ if (aSurf.IsNull())
+ {
+ // skip faces without geometry
+ continue;
+ }
+ }
+
if (isFwd || isRvs){
aPropFace.Load(aFace);
}
- else di << "probleme\n";
- //else cout << "probleme"<< endl;
+ else di << "problem: no distance is found\n";
return 0;
}
--- /dev/null
+puts "========"
+puts "OCC27992"
+puts "========"
+puts ""
+#################################################
+# Extrema_ExtPS crashes on face without geometric surface
+#################################################
+
+restore [locate_data_file bug27821_nullsurf.brep] a
+
+# check for exceptions for vertex-face
+vertex v 0 0 0
+distmini d v a
+
+# check for exceptions for face-face
+tcopy a b
+distmini d a b
restore [locate_data_file bug27821_nullsurf.brep] s
explode s F
-# check that sprops does not crash on NULL surface
+# check that sprops and vprops do not crash on NULL surface
sprops s
+vprops s
# check that AIS_Shape does not crash on NULL surface
vclear