mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0030489: Modeling Algorithms - BRepBuilderAPI_GTransform hangs
Approx_ComputeCLine.gxx - criterium to stop interval cutting is increased. ProjLib_ProjectedCurve.cxx - fix regression for bugs modalg_5 bug25886 Other tests are modified according to current state of algorithm
This commit is contained in:
@@ -34,14 +34,14 @@
|
||||
//=======================================================================
|
||||
|
||||
Approx_ComputeCLine::Approx_ComputeCLine
|
||||
(const MultiLine& Line,
|
||||
const Standard_Integer degreemin,
|
||||
const Standard_Integer degreemax,
|
||||
const Standard_Real Tolerance3d,
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Boolean cutting,
|
||||
const AppParCurves_Constraint FirstC,
|
||||
const AppParCurves_Constraint LastC)
|
||||
(const MultiLine& Line,
|
||||
const Standard_Integer degreemin,
|
||||
const Standard_Integer degreemax,
|
||||
const Standard_Real Tolerance3d,
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Boolean cutting,
|
||||
const AppParCurves_Constraint FirstC,
|
||||
const AppParCurves_Constraint LastC)
|
||||
{
|
||||
mydegremin = degreemin;
|
||||
mydegremax = degreemax;
|
||||
@@ -61,13 +61,13 @@ Approx_ComputeCLine::Approx_ComputeCLine
|
||||
//=======================================================================
|
||||
|
||||
Approx_ComputeCLine::Approx_ComputeCLine
|
||||
(const Standard_Integer degreemin,
|
||||
const Standard_Integer degreemax,
|
||||
const Standard_Real Tolerance3d,
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Boolean cutting,
|
||||
const AppParCurves_Constraint FirstC,
|
||||
const AppParCurves_Constraint LastC)
|
||||
(const Standard_Integer degreemin,
|
||||
const Standard_Integer degreemax,
|
||||
const Standard_Real Tolerance3d,
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Boolean cutting,
|
||||
const AppParCurves_Constraint FirstC,
|
||||
const AppParCurves_Constraint LastC)
|
||||
{
|
||||
alldone = Standard_False;
|
||||
mydegremin = degreemin;
|
||||
@@ -88,21 +88,22 @@ Approx_ComputeCLine::Approx_ComputeCLine
|
||||
void Approx_ComputeCLine::Perform(const MultiLine& Line)
|
||||
{
|
||||
Standard_Real UFirst, ULast;
|
||||
Standard_Boolean Finish = Standard_False,
|
||||
begin = Standard_True, Ok = Standard_False;
|
||||
Standard_Boolean Finish = Standard_False,
|
||||
begin = Standard_True, Ok = Standard_False;
|
||||
Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
|
||||
UFirst = Line.FirstParameter();
|
||||
ULast = Line.LastParameter();
|
||||
Standard_Real TolU = Max((ULast-UFirst)*1.e-05, Precision::PApproximation());
|
||||
Standard_Real myfirstU = UFirst;
|
||||
ULast = Line.LastParameter();
|
||||
Standard_Real TolU = Max((ULast - UFirst)*1.e-03, Precision::Confusion());
|
||||
Standard_Real myfirstU = UFirst;
|
||||
Standard_Real mylastU = ULast;
|
||||
Standard_Integer aMaxSegments = 0;
|
||||
Standard_Integer aMaxSegments1 = myMaxSegments - 1;
|
||||
Standard_Integer aNbCut = 0, aNbImp = 0, aNbComp = 5;
|
||||
|
||||
if (!mycut)
|
||||
{
|
||||
alldone = Compute(Line, UFirst, ULast, thetol3d, thetol2d);
|
||||
if (!alldone)
|
||||
if (!alldone)
|
||||
{
|
||||
tolreached = Standard_False;
|
||||
myfirstparam.Append(UFirst);
|
||||
@@ -112,25 +113,27 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
|
||||
Tolers2d.Append(currenttol2d);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
// previous decision to be taken if we get worse with next cut (eap)
|
||||
AppParCurves_MultiCurve KeptMultiCurve;
|
||||
Standard_Real KeptUfirst = 0., KeptUlast = 0., KeptT3d = RealLast(), KeptT2d = 0.;
|
||||
|
||||
while (!Finish)
|
||||
while (!Finish)
|
||||
{
|
||||
|
||||
|
||||
// Gestion du decoupage de la multiline pour approximer:
|
||||
if (!begin)
|
||||
if (!begin)
|
||||
{
|
||||
if (Ok)
|
||||
if (Ok)
|
||||
{
|
||||
// Calcul de la partie a approximer.
|
||||
myfirstU = mylastU;
|
||||
mylastU = ULast;
|
||||
if (Abs(ULast-myfirstU) <= RealEpsilon()
|
||||
mylastU = ULast;
|
||||
aNbCut = 0;
|
||||
aNbImp = 0;
|
||||
if (Abs(ULast - myfirstU) <= RealEpsilon()
|
||||
|| aMaxSegments >= myMaxSegments)
|
||||
{
|
||||
Finish = Standard_True;
|
||||
@@ -147,50 +150,59 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
|
||||
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
|
||||
{
|
||||
KeptMultiCurve = TheMultiCurve;
|
||||
KeptUfirst = myfirstU;
|
||||
KeptUlast = mylastU;
|
||||
KeptT3d = thetol3d;
|
||||
KeptT2d = thetol2d;
|
||||
KeptUfirst = myfirstU;
|
||||
KeptUlast = mylastU;
|
||||
KeptT3d = thetol3d;
|
||||
KeptT2d = thetol2d;
|
||||
aNbImp++;
|
||||
}
|
||||
|
||||
// cut an interval
|
||||
mylastU = (myfirstU + mylastU)/2;
|
||||
mylastU = (myfirstU + mylastU) / 2;
|
||||
aNbCut++;
|
||||
}
|
||||
}
|
||||
|
||||
// Calcul des parametres sur ce nouvel intervalle.
|
||||
Ok = Compute(Line, myfirstU, mylastU, thetol3d, thetol2d);
|
||||
if(Ok)
|
||||
if (Ok)
|
||||
{
|
||||
aMaxSegments++;
|
||||
}
|
||||
|
||||
//cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
|
||||
|
||||
// is new decision better?
|
||||
if (!Ok && (Abs(myfirstU-mylastU) <= TolU || aMaxSegments >= aMaxSegments1))
|
||||
Standard_Boolean aStopCutting = Standard_False;
|
||||
if (aNbCut >= aNbComp)
|
||||
{
|
||||
Ok = Standard_True; // stop interval cutting, approx the rest part
|
||||
|
||||
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
|
||||
{
|
||||
KeptMultiCurve = TheMultiCurve;
|
||||
KeptUfirst = myfirstU;
|
||||
KeptUlast = mylastU;
|
||||
KeptT3d = thetol3d;
|
||||
KeptT2d = thetol2d;
|
||||
}
|
||||
|
||||
mylastU = KeptUlast;
|
||||
|
||||
tolreached = Standard_False; // helas
|
||||
myMultiCurves.Append(KeptMultiCurve);
|
||||
aMaxSegments++;
|
||||
Tolers3d.Append (KeptT3d);
|
||||
Tolers2d.Append (KeptT2d);
|
||||
myfirstparam.Append (KeptUfirst);
|
||||
mylastparam.Append (KeptUlast);
|
||||
if (aNbCut > aNbImp)
|
||||
{
|
||||
aStopCutting = Standard_True;
|
||||
}
|
||||
}
|
||||
// is new decision better?
|
||||
if (!Ok && (Abs(myfirstU - mylastU) <= TolU || aMaxSegments >= aMaxSegments1 || aStopCutting ))
|
||||
{
|
||||
Ok = Standard_True; // stop interval cutting, approx the rest part
|
||||
|
||||
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
|
||||
{
|
||||
KeptMultiCurve = TheMultiCurve;
|
||||
KeptUfirst = myfirstU;
|
||||
KeptUlast = mylastU;
|
||||
KeptT3d = thetol3d;
|
||||
KeptT2d = thetol2d;
|
||||
}
|
||||
|
||||
mylastU = KeptUlast;
|
||||
|
||||
tolreached = Standard_False; // helas
|
||||
myMultiCurves.Append(KeptMultiCurve);
|
||||
aMaxSegments++;
|
||||
Tolers3d.Append(KeptT3d);
|
||||
Tolers2d.Append(KeptT2d);
|
||||
myfirstparam.Append(KeptUfirst);
|
||||
mylastparam.Append(KeptUlast);
|
||||
}
|
||||
|
||||
begin = Standard_False;
|
||||
} // while (!Finish)
|
||||
@@ -225,10 +237,10 @@ const
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
|
||||
const Standard_Real Ufirst,
|
||||
const Standard_Real Ulast,
|
||||
Standard_Real& TheTol3d,
|
||||
Standard_Real& TheTol2d)
|
||||
const Standard_Real Ufirst,
|
||||
const Standard_Real Ulast,
|
||||
Standard_Real& TheTol3d,
|
||||
Standard_Real& TheTol2d)
|
||||
{
|
||||
|
||||
|
||||
@@ -243,14 +255,14 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
|
||||
if (mydone) {
|
||||
LSquare.Error(Fv, TheTol3d, TheTol2d);
|
||||
if (TheTol3d <= mytol3d && TheTol2d <= mytol2d) {
|
||||
// Stockage de la multicurve approximee.
|
||||
tolreached = Standard_True;
|
||||
// Stockage de la multicurve approximee.
|
||||
tolreached = Standard_True;
|
||||
myMultiCurves.Append(LSquare.Value());
|
||||
myfirstparam.Append(Ufirst);
|
||||
mylastparam.Append(Ulast);
|
||||
Tolers3d.Append(TheTol3d);
|
||||
Tolers2d.Append(TheTol2d);
|
||||
return Standard_True;
|
||||
myfirstparam.Append(Ufirst);
|
||||
mylastparam.Append(Ulast);
|
||||
Tolers3d.Append(TheTol3d);
|
||||
Tolers2d.Append(TheTol2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
if (deg == mydegremax) {
|
||||
@@ -258,7 +270,7 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
|
||||
currenttol3d = TheTol3d;
|
||||
currenttol2d = TheTol2d;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -270,11 +282,11 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine::Parameters(const Standard_Integer Index,
|
||||
Standard_Real& firstpar,
|
||||
Standard_Real& lastpar) const
|
||||
Standard_Real& firstpar,
|
||||
Standard_Real& lastpar) const
|
||||
{
|
||||
firstpar = myfirstparam.Value(Index);
|
||||
lastpar = mylastparam.Value(Index);
|
||||
lastpar = mylastparam.Value(Index);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -283,7 +295,7 @@ void Approx_ComputeCLine::Parameters(const Standard_Integer Index,
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine::SetDegrees(const Standard_Integer degreemin,
|
||||
const Standard_Integer degreemax)
|
||||
const Standard_Integer degreemax)
|
||||
{
|
||||
mydegremin = degreemin;
|
||||
mydegremax = degreemax;
|
||||
@@ -295,7 +307,7 @@ void Approx_ComputeCLine::SetDegrees(const Standard_Integer degreemin,
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine::SetTolerances(const Standard_Real Tolerance3d,
|
||||
const Standard_Real Tolerance2d)
|
||||
const Standard_Real Tolerance2d)
|
||||
{
|
||||
mytol3d = Tolerance3d;
|
||||
mytol2d = Tolerance2d;
|
||||
@@ -307,10 +319,10 @@ void Approx_ComputeCLine::SetTolerances(const Standard_Real Tolerance3d,
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine::SetConstraints(const AppParCurves_Constraint FirstC,
|
||||
const AppParCurves_Constraint LastC)
|
||||
const AppParCurves_Constraint LastC)
|
||||
{
|
||||
myfirstC = FirstC;
|
||||
mylastC = LastC;
|
||||
mylastC = LastC;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -318,7 +330,7 @@ void Approx_ComputeCLine::SetConstraints(const AppParCurves_Constraint FirstC,
|
||||
//purpose : Changes the max number of segments, which is allowed for cutting.
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine:: SetMaxSegments(const Standard_Integer theMaxSegments)
|
||||
void Approx_ComputeCLine::SetMaxSegments(const Standard_Integer theMaxSegments)
|
||||
{
|
||||
myMaxSegments = theMaxSegments;
|
||||
}
|
||||
@@ -351,8 +363,8 @@ const {
|
||||
//=======================================================================
|
||||
|
||||
void Approx_ComputeCLine::Error(const Standard_Integer Index,
|
||||
Standard_Real& tol3d,
|
||||
Standard_Real& tol2d) const
|
||||
Standard_Real& tol3d,
|
||||
Standard_Real& tol2d) const
|
||||
{
|
||||
tol3d = Tolers3d.Value(Index);
|
||||
tol2d = Tolers2d.Value(Index);
|
||||
|
Reference in New Issue
Block a user