mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-06-30 12:14:08 +03:00
0030133: Modeling Data - Crash during visualization of invalid part
Control of number of recursive calls is implemented to avoid stack overflow.
This commit is contained in:
parent
6997ff1c88
commit
dcf0889fc2
@ -26,6 +26,8 @@
|
|||||||
#include <Standard_OutOfRange.hxx>
|
#include <Standard_OutOfRange.hxx>
|
||||||
#include <StdFail_NotDone.hxx>
|
#include <StdFail_NotDone.hxx>
|
||||||
|
|
||||||
|
static const Standard_Integer MyMaxQuasiFleshe = 2000;
|
||||||
|
|
||||||
// mask the return of a Adaptor2d_Curve2d as a gp_Pnt
|
// mask the return of a Adaptor2d_Curve2d as a gp_Pnt
|
||||||
static gp_Pnt Value(const Adaptor3d_Curve & C,
|
static gp_Pnt Value(const Adaptor3d_Curve & C,
|
||||||
const Standard_Real Parameter)
|
const Standard_Real Parameter)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <gp_Circ2d.hxx>
|
#include <gp_Circ2d.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
|
|
||||||
|
|
||||||
static void QuasiFleche(const TheCurve&,
|
static void QuasiFleche(const TheCurve&,
|
||||||
const Standard_Real,
|
const Standard_Real,
|
||||||
const Standard_Real,
|
const Standard_Real,
|
||||||
@ -36,7 +37,8 @@ static void QuasiFleche(const TheCurve&,
|
|||||||
const Standard_Integer,
|
const Standard_Integer,
|
||||||
const Standard_Real,
|
const Standard_Real,
|
||||||
TColStd_SequenceOfReal&,
|
TColStd_SequenceOfReal&,
|
||||||
TColgp_SequenceOfPnt&);
|
TColgp_SequenceOfPnt&,
|
||||||
|
Standard_Integer&);
|
||||||
|
|
||||||
static void QuasiFleche(const TheCurve&,
|
static void QuasiFleche(const TheCurve&,
|
||||||
const Standard_Real,
|
const Standard_Real,
|
||||||
@ -46,7 +48,8 @@ static void QuasiFleche(const TheCurve&,
|
|||||||
const gp_Pnt&,
|
const gp_Pnt&,
|
||||||
const Standard_Integer,
|
const Standard_Integer,
|
||||||
TColStd_SequenceOfReal&,
|
TColStd_SequenceOfReal&,
|
||||||
TColgp_SequenceOfPnt&);
|
TColgp_SequenceOfPnt&,
|
||||||
|
Standard_Integer&);
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -145,6 +148,7 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
|
|||||||
const GeomAbs_Shape Continuity)
|
const GeomAbs_Shape Continuity)
|
||||||
{
|
{
|
||||||
Standard_Integer Nbmin = 2;
|
Standard_Integer Nbmin = 2;
|
||||||
|
Standard_Integer aNbCallQF = 0;
|
||||||
|
|
||||||
gp_Pnt Pdeb;
|
gp_Pnt Pdeb;
|
||||||
if (Continuity <= GeomAbs_G1)
|
if (Continuity <= GeomAbs_G1)
|
||||||
@ -159,7 +163,7 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
|
|||||||
U1, Pdeb,
|
U1, Pdeb,
|
||||||
U2, Pfin,
|
U2, Pfin,
|
||||||
Nbmin,
|
Nbmin,
|
||||||
Parameters, Points);
|
Parameters, Points, aNbCallQF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -178,7 +182,7 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
|
|||||||
Dfin,
|
Dfin,
|
||||||
Nbmin,
|
Nbmin,
|
||||||
EPSILON * EPSILON,
|
EPSILON * EPSILON,
|
||||||
Parameters, Points);
|
Parameters, Points, aNbCallQF);
|
||||||
}
|
}
|
||||||
// cout << "Nb de pts: " << Points.Length()<< endl;
|
// cout << "Nb de pts: " << Points.Length()<< endl;
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
@ -338,9 +342,19 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
const Standard_Integer Nbmin,
|
const Standard_Integer Nbmin,
|
||||||
const Standard_Real Eps,
|
const Standard_Real Eps,
|
||||||
TColStd_SequenceOfReal& Parameters,
|
TColStd_SequenceOfReal& Parameters,
|
||||||
TColgp_SequenceOfPnt& Points)
|
TColgp_SequenceOfPnt& Points,
|
||||||
|
Standard_Integer& theNbCalls)
|
||||||
{
|
{
|
||||||
|
theNbCalls++;
|
||||||
|
if (theNbCalls >= MyMaxQuasiFleshe)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Standard_Integer Ptslength = Points.Length();
|
Standard_Integer Ptslength = Points.Length();
|
||||||
|
if (theNbCalls > 100 && Ptslength < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Standard_Real Udelta = Ufin - Udeb;
|
Standard_Real Udelta = Ufin - Udeb;
|
||||||
gp_Pnt Pdelta;
|
gp_Pnt Pdelta;
|
||||||
gp_Vec Vdelta;
|
gp_Vec Vdelta;
|
||||||
@ -393,7 +407,7 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
Vdelta,
|
Vdelta,
|
||||||
3,
|
3,
|
||||||
Eps,
|
Eps,
|
||||||
Parameters, Points);
|
Parameters, Points, theNbCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Nbmin > 2)
|
if (Nbmin > 2)
|
||||||
@ -404,8 +418,9 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
Vfin,
|
Vfin,
|
||||||
Nbmin - (Points.Length() - Ptslength),
|
Nbmin - (Points.Length() - Ptslength),
|
||||||
Eps,
|
Eps,
|
||||||
Parameters, Points);
|
Parameters, Points, theNbCalls);
|
||||||
}
|
}
|
||||||
|
theNbCalls--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -421,9 +436,19 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
const gp_Pnt& Pfin,
|
const gp_Pnt& Pfin,
|
||||||
const Standard_Integer Nbmin,
|
const Standard_Integer Nbmin,
|
||||||
TColStd_SequenceOfReal& Parameters,
|
TColStd_SequenceOfReal& Parameters,
|
||||||
TColgp_SequenceOfPnt& Points)
|
TColgp_SequenceOfPnt& Points,
|
||||||
|
Standard_Integer& theNbCalls)
|
||||||
{
|
{
|
||||||
|
theNbCalls++;
|
||||||
|
if (theNbCalls >= MyMaxQuasiFleshe)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Standard_Integer Ptslength = Points.Length();
|
Standard_Integer Ptslength = Points.Length();
|
||||||
|
if (theNbCalls > 100 && Ptslength < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Standard_Real Udelta = Ufin - Udeb;
|
Standard_Real Udelta = Ufin - Udeb;
|
||||||
gp_Pnt Pdelta;
|
gp_Pnt Pdelta;
|
||||||
if (Nbmin > 2)
|
if (Nbmin > 2)
|
||||||
@ -450,12 +475,12 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
QuasiFleche (C, Deflection2, Udeb, Pdeb,
|
QuasiFleche (C, Deflection2, Udeb, Pdeb,
|
||||||
Udeb + Udelta * 0.5, Pverif,
|
Udeb + Udelta * 0.5, Pverif,
|
||||||
2,
|
2,
|
||||||
Parameters, Points);
|
Parameters, Points, theNbCalls);
|
||||||
|
|
||||||
QuasiFleche (C, Deflection2, Udeb + Udelta * 0.5, Pverif,
|
QuasiFleche (C, Deflection2, Udeb + Udelta * 0.5, Pverif,
|
||||||
Udeb + Udelta, Pdelta,
|
Udeb + Udelta, Pdelta,
|
||||||
2,
|
2,
|
||||||
Parameters, Points);
|
Parameters, Points, theNbCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Nbmin > 2)
|
if (Nbmin > 2)
|
||||||
@ -463,6 +488,7 @@ void QuasiFleche (const TheCurve& C,
|
|||||||
QuasiFleche (C, Deflection2, Udeb + Udelta, Pdelta,
|
QuasiFleche (C, Deflection2, Udeb + Udelta, Pdelta,
|
||||||
Ufin, Pfin,
|
Ufin, Pfin,
|
||||||
Nbmin - (Points.Length() - Ptslength),
|
Nbmin - (Points.Length() - Ptslength),
|
||||||
Parameters, Points);
|
Parameters, Points, theNbCalls);
|
||||||
}
|
}
|
||||||
|
theNbCalls--;
|
||||||
}
|
}
|
||||||
|
16
tests/bugs/moddata_3/bug30133
Normal file
16
tests/bugs/moddata_3/bug30133
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "OCC30133"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
##########################################
|
||||||
|
# Modeling Data - Crash during visualization of invalid part
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
restore [locate_data_file bug30133.brep] s
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vdisplay s
|
||||||
|
vfit
|
||||||
|
puts "bug30131 is OK"
|
||||||
|
|
||||||
|
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
Loading…
x
Reference in New Issue
Block a user