mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-09 18:50:54 +03:00
0027992: Modeling Algorithms - Extrema_ExtPS crashes on face without geometric surface
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.
This commit is contained in:
parent
6dd6e5c758
commit
c894a5fdfc
@ -40,7 +40,9 @@ BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E
|
|||||||
|
|
||||||
void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
|
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);
|
BRepAdaptor_Curve Curv(E2);
|
||||||
myHC = new BRepAdaptor_HCurve(Curv);
|
myHC = new BRepAdaptor_HCurve(Curv);
|
||||||
Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion());
|
Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion());
|
||||||
@ -57,6 +59,8 @@ void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
|
|||||||
|
|
||||||
void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
|
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;
|
Standard_Real U1, U2;
|
||||||
BRepAdaptor_Curve Curv(E1);
|
BRepAdaptor_Curve Curv(E1);
|
||||||
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
|
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
|
||||||
|
@ -45,6 +45,9 @@ BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F)
|
|||||||
void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
|
void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
|
||||||
{
|
{
|
||||||
BRepAdaptor_Surface Surf(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);
|
BRepAdaptor_Curve aC(E);
|
||||||
myHS = new BRepAdaptor_HSurface(Surf);
|
myHS = new BRepAdaptor_HSurface(Surf);
|
||||||
Standard_Real aTolC, aTolS;
|
Standard_Real aTolC, aTolS;
|
||||||
@ -73,6 +76,9 @@ void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2)
|
|||||||
myPointsOnS.Clear();
|
myPointsOnS.Clear();
|
||||||
myPointsOnC.Clear();
|
myPointsOnC.Clear();
|
||||||
|
|
||||||
|
if (myHS.IsNull())
|
||||||
|
return; // protect against non-geometric type (e.g. triangulation)
|
||||||
|
|
||||||
Standard_Real U1, U2;
|
Standard_Real U1, U2;
|
||||||
BRep_Tool::Range(E, U1, U2);
|
BRep_Tool::Range(E, U1, U2);
|
||||||
|
|
||||||
|
@ -46,6 +46,9 @@ BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F
|
|||||||
void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
|
void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
|
||||||
{
|
{
|
||||||
BRepAdaptor_Surface Surf(F2);
|
BRepAdaptor_Surface Surf(F2);
|
||||||
|
if (Surf.GetType() == GeomAbs_OtherSurface)
|
||||||
|
return; // protect against non-geometric type (e.g. triangulation)
|
||||||
|
|
||||||
myHS = new BRepAdaptor_HSurface(Surf);
|
myHS = new BRepAdaptor_HSurface(Surf);
|
||||||
Standard_Real Tol = Min(BRep_Tool::Tolerance(F2), Precision::Confusion());
|
Standard_Real Tol = Min(BRep_Tool::Tolerance(F2), Precision::Confusion());
|
||||||
Tol = Min(Surf.UResolution(Tol), Surf.VResolution(Tol));
|
Tol = Min(Surf.UResolution(Tol), Surf.VResolution(Tol));
|
||||||
@ -67,6 +70,9 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
|
|||||||
myPointsOnS2.Clear();
|
myPointsOnS2.Clear();
|
||||||
|
|
||||||
BRepAdaptor_Surface Surf1(F1);
|
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);
|
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
|
||||||
Standard_Real Tol1 = Min(BRep_Tool::Tolerance(F1), Precision::Confusion());
|
Standard_Real Tol1 = Min(BRep_Tool::Tolerance(F1), Precision::Confusion());
|
||||||
Tol1 = Min(Surf1.UResolution(Tol1), Surf1.VResolution(Tol1));
|
Tol1 = Min(Surf1.UResolution(Tol1), Surf1.VResolution(Tol1));
|
||||||
|
@ -41,7 +41,9 @@ BRepExtrema_ExtPC::BRepExtrema_ExtPC(const TopoDS_Vertex& V, const TopoDS_Edge&
|
|||||||
|
|
||||||
void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
|
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);
|
BRepAdaptor_Curve Curv(E);
|
||||||
myHC = new BRepAdaptor_HCurve(Curv);
|
myHC = new BRepAdaptor_HCurve(Curv);
|
||||||
Standard_Real Tol = Min(BRep_Tool::Tolerance(E), Precision::Confusion());
|
Standard_Real Tol = Min(BRep_Tool::Tolerance(E), Precision::Confusion());
|
||||||
@ -57,6 +59,9 @@ void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
|
|||||||
|
|
||||||
void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
|
void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
|
||||||
{
|
{
|
||||||
gp_Pnt P = BRep_Tool::Pnt(V);
|
if (!myHC.IsNull())
|
||||||
myExtPC.Perform(P);
|
{
|
||||||
|
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||||
|
myExtPC.Perform(P);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,10 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
|
|||||||
// cette surface doit etre en champ. Extrema ne fait
|
// cette surface doit etre en champ. Extrema ne fait
|
||||||
// pas de copie et prend seulement un pointeur dessus.
|
// pas de copie et prend seulement un pointeur dessus.
|
||||||
mySurf.Initialize(TheFace, Standard_False);
|
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 Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion());
|
||||||
Standard_Real aTolU, aTolV;
|
Standard_Real aTolU, aTolV;
|
||||||
aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
|
aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
|
||||||
@ -71,6 +75,9 @@ void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Fac
|
|||||||
myPoints.Clear();
|
myPoints.Clear();
|
||||||
|
|
||||||
const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
|
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);
|
myExtPS.Perform(P);
|
||||||
|
|
||||||
// Exploration of points and classification
|
// Exploration of points and classification
|
||||||
|
@ -170,6 +170,7 @@ static Standard_Real volumeProperties(const TopoDS_Shape& S, GProp_GProps& Props
|
|||||||
BRepGProp_Domain BD;
|
BRepGProp_Domain BD;
|
||||||
TopTools_MapOfShape aFwdFMap;
|
TopTools_MapOfShape aFwdFMap;
|
||||||
TopTools_MapOfShape aRvsFMap;
|
TopTools_MapOfShape aRvsFMap;
|
||||||
|
TopLoc_Location aLocDummy;
|
||||||
|
|
||||||
for (ex.Init(S,TopAbs_FACE), i = 1; ex.More(); ex.Next(), i++) {
|
for (ex.Init(S,TopAbs_FACE), i = 1; ex.More(); ex.Next(), i++) {
|
||||||
const TopoDS_Face& F = TopoDS::Face(ex.Current());
|
const TopoDS_Face& F = TopoDS::Face(ex.Current());
|
||||||
@ -187,6 +188,15 @@ static Standard_Real volumeProperties(const TopoDS_Shape& S, GProp_GProps& Props
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (F, aLocDummy);
|
||||||
|
if (aSurf.IsNull())
|
||||||
|
{
|
||||||
|
// skip faces without geometry
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFwd || isRvs){
|
if (isFwd || isRvs){
|
||||||
BF.Load(F);
|
BF.Load(F);
|
||||||
TopoDS_Iterator aWIter(F);
|
TopoDS_Iterator aWIter(F);
|
||||||
@ -306,6 +316,7 @@ static Standard_Real volumePropertiesGK(const TopoDS_Shape &theShape,
|
|||||||
Standard_Real anError = 0.;
|
Standard_Real anError = 0.;
|
||||||
TopTools_MapOfShape aFwdFMap;
|
TopTools_MapOfShape aFwdFMap;
|
||||||
TopTools_MapOfShape aRvsFMap;
|
TopTools_MapOfShape aRvsFMap;
|
||||||
|
TopLoc_Location aLocDummy;
|
||||||
|
|
||||||
aVProps.SetLocation(aLoc);
|
aVProps.SetLocation(aLoc);
|
||||||
|
|
||||||
@ -325,6 +336,15 @@ static Standard_Real volumePropertiesGK(const TopoDS_Shape &theShape,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aLocDummy);
|
||||||
|
if (aSurf.IsNull())
|
||||||
|
{
|
||||||
|
// skip faces without geometry
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFwd || isRvs){
|
if (isFwd || isRvs){
|
||||||
aPropFace.Load(aFace);
|
aPropFace.Load(aFace);
|
||||||
|
|
||||||
@ -444,6 +464,7 @@ static Standard_Real volumePropertiesGK(const TopoDS_Shape &theShape,
|
|||||||
Standard_Real anError = 0.;
|
Standard_Real anError = 0.;
|
||||||
TopTools_MapOfShape aFwdFMap;
|
TopTools_MapOfShape aFwdFMap;
|
||||||
TopTools_MapOfShape aRvsFMap;
|
TopTools_MapOfShape aRvsFMap;
|
||||||
|
TopLoc_Location aLocDummy;
|
||||||
|
|
||||||
aVProps.SetLocation(aLoc);
|
aVProps.SetLocation(aLoc);
|
||||||
|
|
||||||
@ -463,6 +484,15 @@ static Standard_Real volumePropertiesGK(const TopoDS_Shape &theShape,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aLocDummy);
|
||||||
|
if (aSurf.IsNull())
|
||||||
|
{
|
||||||
|
// skip faces without geometry
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFwd || isRvs){
|
if (isFwd || isRvs){
|
||||||
aPropFace.Load(aFace);
|
aPropFace.Load(aFace);
|
||||||
|
|
||||||
|
@ -138,8 +138,7 @@ static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else di << "probleme\n";
|
else di << "problem: no distance is found\n";
|
||||||
//else cout << "probleme"<< endl;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
tests/bugs/modalg_6/bug27992
Normal file
17
tests/bugs/modalg_6/bug27992
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
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
|
@ -7,8 +7,9 @@ pload MODELING VISUALIZATION
|
|||||||
restore [locate_data_file bug27821_nullsurf.brep] s
|
restore [locate_data_file bug27821_nullsurf.brep] s
|
||||||
explode s F
|
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
|
sprops s
|
||||||
|
vprops s
|
||||||
|
|
||||||
# check that AIS_Shape does not crash on NULL surface
|
# check that AIS_Shape does not crash on NULL surface
|
||||||
vclear
|
vclear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user