1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0024377: [Regression-like] OCC 6.7.0 beta contaminates log with more unnecessary debug symbols

These "DEBUG outputs" are replace with analogically comments.
This commit is contained in:
nbv 2013-11-19 12:06:09 +04:00 committed by bugmaster
parent 3cb19cf162
commit 28cec2ba3e
2 changed files with 382 additions and 437 deletions

View File

@ -23,19 +23,19 @@
// GetStateNumber() // GetStateNumber()
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
Fonctions permettant de rechercher une distance extremale entre 2 courbes Fonctions permettant de rechercher une distance extremale entre 2 courbes
C1 et C2 (en partant de points approches C1(u0) et C2(v0)). C1 et C2 (en partant de points approches C1(u0) et C2(v0)).
Cette classe herite de math_FunctionSetWithDerivatives et est utilisee par Cette classe herite de math_FunctionSetWithDerivatives et est utilisee par
l'algorithme math_FunctionSetRoot. l'algorithme math_FunctionSetRoot.
Si on note Du et Dv, les derivees en u et v, les 2 fonctions a annuler sont: Si on note Du et Dv, les derivees en u et v, les 2 fonctions a annuler sont:
{ F1(u,v) = (C2(v)-C1(u)).Du(u)/||Du|| } { F1(u,v) = (C2(v)-C1(u)).Du(u)/||Du|| }
{ F2(u,v) = (C2(v)-C1(u)).Dv(v)||Dv|| } { F2(u,v) = (C2(v)-C1(u)).Dv(v)||Dv|| }
Si on note Duu et Dvv, les derivees secondes de C1 et C2, les derivees de F1 Si on note Duu et Dvv, les derivees secondes de C1 et C2, les derivees de F1
et F2 sont egales a: et F2 sont egales a:
{ Duf1(u,v) = -||Du|| + C1C2.Duu/||Du||- F1(u,v)*Duu*Du/||Du||**2 { Duf1(u,v) = -||Du|| + C1C2.Duu/||Du||- F1(u,v)*Duu*Du/||Du||**2
{ Dvf1(u,v) = Dv.Du/||Du|| { Dvf1(u,v) = Dv.Du/||Du||
{ Duf2(u,v) = -Du.Dv/||Dv|| { Duf2(u,v) = -Du.Dv/||Dv||
{ Dvf2(u,v) = ||Dv|| + C2C1.Dvv/||Dv||- F2(u,v)*Dv*Dvv/||Dv||**2 { Dvf2(u,v) = ||Dv|| + C2C1.Dvv/||Dv||- F2(u,v)*Dv*Dvv/||Dv||**2
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -52,7 +52,7 @@ static const Standard_Integer MaxOrder = 3;
//============================================================================= //=============================================================================
Standard_Real Extrema_FuncExtCC::SearchOfTolerance(const Standard_Address C) Standard_Real Extrema_FuncExtCC::SearchOfTolerance(const Standard_Address C)
{ {
const Standard_Integer NPoint = 10; const Standard_Integer NPoint = 10;
Standard_Real aStartParam, anEndParam; Standard_Real aStartParam, anEndParam;
@ -68,10 +68,7 @@ Standard_Real Extrema_FuncExtCC::SearchOfTolerance(const Standard_Address C)
} }
else else
{ {
#ifdef DEB //Warning: No curve for tolerance computing!
cout << "+++ Function Extrema_FuncExtCC::SearchOfTolerance(...)" << endl;
cout << "Warning: No curve for tolerance computing!---"<<endl;
#endif
return MinTol; return MinTol;
} }
@ -97,11 +94,11 @@ Standard_Real Extrema_FuncExtCC::SearchOfTolerance(const Standard_Address C)
while(++aNum < NPoint+1); while(++aNum < NPoint+1);
return Max(aMax*TolFactor,MinTol); return Max(aMax*TolFactor,MinTol);
} }
//============================================================================= //=============================================================================
Extrema_FuncExtCC::Extrema_FuncExtCC(const Standard_Real thetol) : myC1 (0), myC2 (0), myTol (thetol) Extrema_FuncExtCC::Extrema_FuncExtCC(const Standard_Real thetol) : myC1 (0), myC2 (0), myTol (thetol)
{ {
math_Vector V1(1,2), V2(1,2); math_Vector V1(1,2), V2(1,2);
V1(1) = 0.0; V1(1) = 0.0;
V2(1) = 0.0; V2(1) = 0.0;
@ -112,15 +109,15 @@ Extrema_FuncExtCC::Extrema_FuncExtCC(const Standard_Real thetol) : myC1 (0), myC
myTolC1=MinTol; myTolC1=MinTol;
myMaxDerivOrderC2 = 0; myMaxDerivOrderC2 = 0;
myTolC2=MinTol; myTolC2=MinTol;
} }
//============================================================================= //=============================================================================
Extrema_FuncExtCC::Extrema_FuncExtCC (const Curve1& C1, Extrema_FuncExtCC::Extrema_FuncExtCC (const Curve1& C1,
const Curve2& C2, const Curve2& C2,
const Standard_Real thetol) : const Standard_Real thetol) :
myC1 ((Standard_Address)&C1), myC2 ((Standard_Address)&C2), myC1 ((Standard_Address)&C1), myC2 ((Standard_Address)&C2),
myTol (thetol) myTol (thetol)
{ {
math_Vector V1(1,2), V2(1,2); math_Vector V1(1,2), V2(1,2);
V1(1) = Tool1::FirstParameter(*((Curve1*)myC1)); V1(1) = Tool1::FirstParameter(*((Curve1*)myC1));
V2(1) = Tool1::LastParameter(*((Curve1*)myC1)); V2(1) = Tool1::LastParameter(*((Curve1*)myC1));
@ -155,11 +152,11 @@ Extrema_FuncExtCC::Extrema_FuncExtCC (const Curve1& C1,
myTolC2=MinTol; myTolC2=MinTol;
break; break;
} }
} }
//============================================================================= //=============================================================================
void Extrema_FuncExtCC::SetCurve (const Standard_Integer theRank, const Curve1& C) void Extrema_FuncExtCC::SetCurve (const Standard_Integer theRank, const Curve1& C)
{ {
Standard_OutOfRange_Raise_if (theRank < 1 || theRank > 2, "Extrema_FuncExtCC::SetCurve()") Standard_OutOfRange_Raise_if (theRank < 1 || theRank > 2, "Extrema_FuncExtCC::SetCurve()")
if (theRank == 1) if (theRank == 1)
@ -196,11 +193,11 @@ void Extrema_FuncExtCC::SetCurve (const Standard_Integer theRank, const Curve1&
break; break;
} }
} }
} }
//============================================================================= //=============================================================================
Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F) Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F)
{ {
myU = UV(1); myU = UV(1);
myV = UV(2); myV = UV(2);
Tool1::D1(*((Curve1*)myC1), myU,myP1,myDu); Tool1::D1(*((Curve1*)myC1), myU,myP1,myDu);
@ -294,14 +291,10 @@ Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F
if (Ndu <= MinTol) if (Ndu <= MinTol)
{ {
#ifdef DEB //Warning: 1st derivative of C1 is equal to zero!
cout << "+++Function Extrema_FuncExtCC::Value(...)." << endl;
cout << "Warning: 1st derivative of C1 is equal to zero!---"<<endl;
#endif
return Standard_False; return Standard_False;
} }
Standard_Real Ndv = myDv.Magnitude(); Standard_Real Ndv = myDv.Magnitude();
if(myMaxDerivOrderC2 != 0) if(myMaxDerivOrderC2 != 0)
@ -317,7 +310,7 @@ Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F
const Standard_Real aDelta = Max(dv*DivisionFactor,MinStep); const Standard_Real aDelta = Max(dv*DivisionFactor,MinStep);
//Derivative is approximated by Taylor-series //Derivative is approximated by Taylor-series
Standard_Integer n = 1; //Derivative order Standard_Integer n = 1; //Derivative order
Vec V; Vec V;
@ -389,40 +382,34 @@ Standard_Boolean Extrema_FuncExtCC::Value (const math_Vector& UV, math_Vector& F
if (Ndv <= MinTol) if (Ndv <= MinTol)
{ {
#ifdef DEB //1st derivative of C2 is equal to zero!
cout << "+++Function Extrema_FuncExtCC::Value(...)." << endl;
cout << "1st derivative of C2 is equal to zero!---"<<endl;
#endif
return Standard_False; return Standard_False;
} }
F(1) = P1P2.Dot(myDu)/Ndu; F(1) = P1P2.Dot(myDu)/Ndu;
F(2) = P1P2.Dot(myDv)/Ndv; F(2) = P1P2.Dot(myDv)/Ndv;
return Standard_True; return Standard_True;
} }
//============================================================================= //=============================================================================
Standard_Boolean Extrema_FuncExtCC::Derivatives (const math_Vector& UV, Standard_Boolean Extrema_FuncExtCC::Derivatives (const math_Vector& UV,
math_Matrix& Df) math_Matrix& Df)
{ {
math_Vector F(1,2); math_Vector F(1,2);
return Values(UV,F,Df); return Values(UV,F,Df);
} }
//============================================================================= //=============================================================================
Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV, Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
math_Vector& F, math_Vector& F,
math_Matrix& Df) math_Matrix& Df)
{ {
myU = UV(1); myU = UV(1);
myV = UV(2); myV = UV(2);
if(Value(UV, F) == Standard_False) //Computes F, myDu, myDv if(Value(UV, F) == Standard_False) //Computes F, myDu, myDv
{ {
#ifdef DEB //Warning: No function value found!
cout << "+++Standard_Boolean Extrema_FuncExtCC::Values(...)." << endl;
cout << "Warning: No function value found!---"<<endl;
#endif
return Standard_False; return Standard_False;
}//if(Value(UV, F) == Standard_False) }//if(Value(UV, F) == Standard_False)
@ -430,15 +417,15 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
Tool1::D2(*((Curve1*)myC1), myU,myP1,Du,Duu); Tool1::D2(*((Curve1*)myC1), myU,myP1,Du,Duu);
Tool2::D2(*((Curve2*)myC2), myV,myP2,Dv,Dvv); Tool2::D2(*((Curve2*)myC2), myV,myP2,Dv,Dvv);
//Calling of "Value(...)" function change class member values. //Calling of "Value(...)" function change class member values.
//After running it is necessary to return to previous values. //After running it is necessary to return to previous values.
const Standard_Real myU_old = myU, myV_old = myV; const Standard_Real myU_old = myU, myV_old = myV;
const Pnt myP1_old = myP1, myP2_old = myP2; const Pnt myP1_old = myP1, myP2_old = myP2;
const Vec myDu_old = myDu, myDv_old = myDv; const Vec myDu_old = myDu, myDv_old = myDv;
//Attention: aDelta value must be greater than same value for "Value(...)" //Attention: aDelta value must be greater than same value for "Value(...)"
// function to avoid of points' collisions. // function to avoid of points' collisions.
const Standard_Real DivisionFactor = 0.01; const Standard_Real DivisionFactor = 0.01;
@ -462,12 +449,12 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1)) if((myMaxDerivOrderC1 != 0) && (Du.Magnitude() <= myTolC1))
{ {
//Derivative is approximated by three points //Derivative is approximated by three points
math_Vector FF1(1,2), FF2(1,2), FF3(1,2); math_Vector FF1(1,2), FF2(1,2), FF3(1,2);
Standard_Real F1, F2, F3; Standard_Real F1, F2, F3;
/////////////////////////// Search of DF1_u derivative (begin) /////////////////// /////////////////////////// Search of DF1_u derivative (begin) ///////////////////
if(myU-myUinfium < 2*aDeltaU) if(myU-myUinfium < 2*aDeltaU)
{ {
F1=F(1); F1=F(1);
@ -478,12 +465,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
UV3(2)=myV; UV3(2)=myV;
if(!((Value(UV2,FF2)) && (Value(UV3,FF3)))) if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -503,12 +486,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if(!((Value(UV2,FF2)) && (Value(UV1,FF1)))) if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -517,13 +496,13 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
Df(1,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU); Df(1,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU);
}//else of if(myU-myUinfium < 2*aDeltaU) condition }//else of if(myU-myUinfium < 2*aDeltaU) condition
/////////////////////////// Search of DF1_u derivative (end) /////////////////// /////////////////////////// Search of DF1_u derivative (end) ///////////////////
//Return to previous values //Return to previous values
myU = myU_old; myU = myU_old;
myV = myV_old; myV = myV_old;
/////////////////////////// Search of DF1_v derivative (begin) /////////////////// /////////////////////////// Search of DF1_v derivative (begin) ///////////////////
if(myV-myVinfium < 2*aDeltaV) if(myV-myVinfium < 2*aDeltaV)
{ {
F1=F(1); F1=F(1);
@ -535,12 +514,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if(!((Value(UV2,FF2)) && (Value(UV3,FF3)))) if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
F2 = FF2(1); F2 = FF2(1);
@ -558,12 +533,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
UV1(2)=myV-2*aDeltaV; UV1(2)=myV-2*aDeltaV;
if(!((Value(UV2,FF2)) && (Value(UV1,FF1)))) if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -572,7 +543,7 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
Df(1,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV); Df(1,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV);
}//else of if(myV-myVinfium < 2*aDeltaV) }//else of if(myV-myVinfium < 2*aDeltaV)
/////////////////////////// Search of DF1_v derivative (end) /////////////////// /////////////////////////// Search of DF1_v derivative (end) ///////////////////
//Return to previous values //Return to previous values
myU = myU_old; myU = myU_old;
@ -589,12 +560,12 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2)) if((myMaxDerivOrderC2 != 0) && (Dv.Magnitude() <= myTolC2))
{ {
//Derivative is approximated by three points //Derivative is approximated by three points
math_Vector FF1(1,2), FF2(1,2), FF3(1,2); math_Vector FF1(1,2), FF2(1,2), FF3(1,2);
Standard_Real F1, F2, F3; Standard_Real F1, F2, F3;
/////////////////////////// Search of DF2_v derivative (begin) /////////////////// /////////////////////////// Search of DF2_v derivative (begin) ///////////////////
if(myV-myVinfium < 2*aDeltaV) if(myV-myVinfium < 2*aDeltaV)
{ {
F1=F(2); F1=F(2);
@ -606,12 +577,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if(!((Value(UV2,FF2)) && (Value(UV3,FF3)))) if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -632,12 +599,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if(!((Value(UV2,FF2)) && (Value(UV1,FF1)))) if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -646,13 +609,13 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
Df(2,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV); Df(2,2) = (F1-4*F2+3*F3)/(2.0*aDeltaV);
}//else of if(myV-myVinfium < 2*aDeltaV) }//else of if(myV-myVinfium < 2*aDeltaV)
/////////////////////////// Search of DF2_v derivative (end) /////////////////// /////////////////////////// Search of DF2_v derivative (end) ///////////////////
//Return to previous values //Return to previous values
myU = myU_old; myU = myU_old;
myV = myV_old; myV = myV_old;
/////////////////////////// Search of DF2_u derivative (begin) /////////////////// /////////////////////////// Search of DF2_u derivative (begin) ///////////////////
if(myU-myUinfium < 2*aDeltaU) if(myU-myUinfium < 2*aDeltaU)
{ {
F1=F(2); F1=F(2);
@ -663,12 +626,8 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
UV3(2)=myV; UV3(2)=myV;
if(!((Value(UV2,FF2)) && (Value(UV3,FF3)))) if(!((Value(UV2,FF2)) && (Value(UV3,FF3))))
{ {
#ifdef DEB //There are many points close to singularity points and which have zero-derivative.
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -688,12 +647,9 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
if(!((Value(UV2,FF2)) && (Value(UV1,FF1)))) if(!((Value(UV2,FF2)) && (Value(UV1,FF1))))
{ {
#ifdef DEB //There are many points close to singularity points
cout << "+++ Function Extrema_FuncExtCC::Values(...)" << endl; //and which have zero-derivative.
cout << "There are many points close to singularity points " //Try to decrease aDelta variable's value.
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
return Standard_False; return Standard_False;
} }
@ -702,7 +658,7 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
Df(2,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU); Df(2,1) = (F1-4*F2+3*F3)/(2.0*aDeltaU);
}//else of if(myU-myUinfium < 2*aDeltaU) }//else of if(myU-myUinfium < 2*aDeltaU)
/////////////////////////// Search of DF2_u derivative (end) /////////////////// /////////////////////////// Search of DF2_u derivative (end) ///////////////////
//Return to previous values //Return to previous values
myU = myU_old; myU = myU_old;
@ -721,7 +677,7 @@ Standard_Boolean Extrema_FuncExtCC::Values (const math_Vector& UV,
return Standard_True; return Standard_True;
}//end of function }//end of function
//============================================================================= //=============================================================================
Standard_Integer Extrema_FuncExtCC::GetStateNumber () Standard_Integer Extrema_FuncExtCC::GetStateNumber ()
@ -758,10 +714,10 @@ void Extrema_FuncExtCC::Points (const Standard_Integer N,
void Extrema_FuncExtCC::SubIntervalInitialize(const math_Vector& theInfBound, void Extrema_FuncExtCC::SubIntervalInitialize(const math_Vector& theInfBound,
const math_Vector& theSupBound) const math_Vector& theSupBound)
{ {
myUinfium = theInfBound(1); myUinfium = theInfBound(1);
myUsupremum = theSupBound(1); myUsupremum = theSupBound(1);
myVinfium = theInfBound(2); myVinfium = theInfBound(2);
myVsupremum = theSupBound(2); myVsupremum = theSupBound(2);
} }
//============================================================================= //=============================================================================

View File

@ -27,22 +27,22 @@ static const Standard_Integer MaxOrder = 3;
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
Fonction permettant de rechercher une distance extremale entre un point P et Fonction permettant de rechercher une distance extremale entre un point P et
une courbe C (en partant d'un point approche C(u0)). une courbe C (en partant d'un point approche C(u0)).
Cette classe herite de math_FunctionWithDerivative et est utilisee par Cette classe herite de math_FunctionWithDerivative et est utilisee par
les algorithmes math_FunctionRoot et math_FunctionRoots. les algorithmes math_FunctionRoot et math_FunctionRoots.
Si on note D1c et D2c les derivees premiere et seconde: Si on note D1c et D2c les derivees premiere et seconde:
{ F(u) = (C(u)-P).D1c(u)/ ||Du||} { F(u) = (C(u)-P).D1c(u)/ ||Du||}
{ DF(u) = ||Du|| + (C(u)-P).D2c(u)/||Du|| - F(u)*Duu*Du/||Du||**2 { DF(u) = ||Du|| + (C(u)-P).D2c(u)/||Du|| - F(u)*Duu*Du/||Du||**2
{ F(u) = (C(u)-P).D1c(u) } { F(u) = (C(u)-P).D1c(u) }
{ DF(u) = D1c(u).D1c(u) + (C(u)-P).D2c(u) { DF(u) = D1c(u).D1c(u) + (C(u)-P).D2c(u)
= ||D1c(u)|| ** 2 + (C(u)-P).D2c(u) } = ||D1c(u)|| ** 2 + (C(u)-P).D2c(u) }
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
Standard_Real Extrema_FuncExtPC::SearchOfTolerance() Standard_Real Extrema_FuncExtPC::SearchOfTolerance()
{ {
const Standard_Integer NPoint = 10; const Standard_Integer NPoint = 10;
const Standard_Real aStep = (myUsupremum - myUinfium)/(Standard_Real)NPoint; const Standard_Real aStep = (myUsupremum - myUinfium)/(Standard_Real)NPoint;
@ -67,7 +67,7 @@ Standard_Real Extrema_FuncExtPC::SearchOfTolerance()
return Max(aMax*TolFactor,MinTol); return Max(aMax*TolFactor,MinTol);
} }
//============================================================================= //=============================================================================
@ -88,7 +88,7 @@ myD1f(0.)
Extrema_FuncExtPC::Extrema_FuncExtPC (const Pnt& P, Extrema_FuncExtPC::Extrema_FuncExtPC (const Pnt& P,
const Curve& C): myU(0.), myD1f(0.) const Curve& C): myU(0.), myD1f(0.)
{ {
myP = P; myP = P;
myC = (Standard_Address)&C; myC = (Standard_Address)&C;
myPinit = Standard_True; myPinit = Standard_True;
@ -111,11 +111,11 @@ Extrema_FuncExtPC::Extrema_FuncExtPC (const Pnt& P,
myTol=MinTol; myTol=MinTol;
break; break;
} }
} }
//============================================================================= //=============================================================================
void Extrema_FuncExtPC::Initialize(const Curve& C) void Extrema_FuncExtPC::Initialize(const Curve& C)
{ {
myC = (Standard_Address)&C; myC = (Standard_Address)&C;
myCinit = Standard_True; myCinit = Standard_True;
myPoint.Clear(); myPoint.Clear();
@ -138,7 +138,7 @@ void Extrema_FuncExtPC::Initialize(const Curve& C)
myTol=MinTol; myTol=MinTol;
break; break;
} }
} }
//============================================================================= //=============================================================================
@ -176,7 +176,7 @@ Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real&
du = myUsupremum-myUinfium; du = myUsupremum-myUinfium;
const Standard_Real aDelta = Max(du*DivisionFactor,MinStep); const Standard_Real aDelta = Max(du*DivisionFactor,MinStep);
//Derivative is approximated by Taylor-series //Derivative is approximated by Taylor-series
Standard_Integer n = 1; //Derivative order Standard_Integer n = 1; //Derivative order
Vec V; Vec V;
@ -213,7 +213,7 @@ Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real&
}//if(IsDeriveFound) }//if(IsDeriveFound)
else else
{ {
//Derivative is approximated by three points //Derivative is approximated by three points
Pnt Ptemp; //(0,0,0)-coordinate Pnt Ptemp; //(0,0,0)-coordinate
Pnt P1, P2, P3; Pnt P1, P2, P3;
@ -247,10 +247,7 @@ Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real&
if (Ndu <= MinTol) if (Ndu <= MinTol)
{ {
#ifdef DEB //Warning: 1st derivative is equal to zero!
cout << "+++Function Extrema_FuncExtPC::Value(...)." << endl;
cout << "Warning: 1st derivative is equal to zero!---"<<endl;
#endif
return Standard_False; return Standard_False;
} }
@ -270,8 +267,10 @@ Standard_Boolean Extrema_FuncExtPC::Derivative (const Standard_Real U, Standard_
} }
//============================================================================= //=============================================================================
Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real& F, Standard_Real& D1f) Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U,
{ Standard_Real& F,
Standard_Real& D1f)
{
if (!myPinit || !myCinit) if (!myPinit || !myCinit)
Standard_TypeMismatch::Raise("No init"); Standard_TypeMismatch::Raise("No init");
@ -279,10 +278,7 @@ Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real
if(Value(U,F) == Standard_False) if(Value(U,F) == Standard_False)
{ {
#ifdef DEB //Warning: No function value found!;
cout << "+++Function Extrema_FuncExtPC::Values(...)." << endl;
cout << "Warning: No function value found!---"<<endl;
#endif
myD1Init = Standard_False; myD1Init = Standard_False;
return Standard_False; return Standard_False;
@ -298,10 +294,10 @@ Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real
Standard_Real Ndu = D1c.Magnitude(); Standard_Real Ndu = D1c.Magnitude();
if (Ndu <= myTol) // Cas Singulier (PMN 22/04/1998) if (Ndu <= myTol) // Cas Singulier (PMN 22/04/1998)
{ {
//Derivative is approximated by three points //Derivative is approximated by three points
//Attention: aDelta value must be greater than same value for "Value(...)" //Attention: aDelta value must be greater than same value for "Value(...)"
// function to avoid of points' collisions. // function to avoid of points' collisions.
const Standard_Real DivisionFactor = 0.01; const Standard_Real DivisionFactor = 0.01;
Standard_Real du; Standard_Real du;
if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst())) if((myUsupremum >= RealLast()) || (myUinfium <= RealFirst()))
@ -322,18 +318,15 @@ Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real
if(!((Value(U2,F2)) && (Value(U3,F3)))) if(!((Value(U2,F2)) && (Value(U3,F3))))
{ {
#ifdef DEB //There are many points close to singularity points and
cout << "+++ Function Extrema_FuncExtPC::Values(...)" << endl; //which have zero-derivative. Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
myD1Init = Standard_False; myD1Init = Standard_False;
return Standard_False; return Standard_False;
} }
//After calling of Value(...) function variable myU will be redeterminated. //After calling of Value(...) function variable myU will be redeterminated.
//So we must return it previous value. //So we must return it previous value.
D1f=(-3*F1+4*F2-F3)/(2.0*aDelta); D1f=(-3*F1+4*F2-F3)/(2.0*aDelta);
} }
else else
@ -345,17 +338,13 @@ Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real
if(!((Value(U2,F2)) && (Value(U1,F1)))) if(!((Value(U2,F2)) && (Value(U1,F1))))
{ {
#ifdef DEB //There are many points close to singularity points and
cout << "+++ Function Extrema_FuncExtPC::Values(...)" << endl; //which have zero-derivative. Try to decrease aDelta variable's value.
cout << "There are many points close to singularity points "
"and which have zero-derivative." << endl;
cout << "Try to decrease aDelta variable's value. ---" << endl;
#endif
myD1Init = Standard_False; myD1Init = Standard_False;
return Standard_False; return Standard_False;
} }
//After calling of Value(...) function variable myU will be redeterminated. //After calling of Value(...) function variable myU will be redeterminated.
//So we must return it previous value. //So we must return it previous value.
D1f=(F1-4*F2+3*F3)/(2.0*aDelta); D1f=(F1-4*F2+3*F3)/(2.0*aDelta);
} }
myU = U; myU = U;
@ -372,7 +361,7 @@ Standard_Boolean Extrema_FuncExtPC::Values (const Standard_Real U, Standard_Real
myD1Init = Standard_True; myD1Init = Standard_True;
return Standard_True; return Standard_True;
} }
//============================================================================= //=============================================================================
Standard_Integer Extrema_FuncExtPC::GetStateNumber () Standard_Integer Extrema_FuncExtPC::GetStateNumber ()
@ -419,7 +408,7 @@ const POnC & Extrema_FuncExtPC::Point (const Standard_Integer N) const
//============================================================================= //=============================================================================
void Extrema_FuncExtPC::SubIntervalInitialize(const Standard_Real theUfirst, const Standard_Real theUlast) void Extrema_FuncExtPC::SubIntervalInitialize(const Standard_Real theUfirst, const Standard_Real theUlast)
{ {
myUinfium = theUfirst; myUinfium = theUfirst;
myUsupremum = theUlast; myUsupremum = theUlast;
} }