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

0024137: math_FunctionSetRoot returns too rough solution

Test case and new draw command for issue CR24137
Modified test case de/iges_1/G9 according to new data
Small correction of test cases for issue CR24137
This commit is contained in:
ifv 2013-10-03 14:34:03 +04:00 committed by bugmaster
parent 91bb31f35e
commit 89d8607f13
6 changed files with 629 additions and 542 deletions

View File

@ -1234,6 +1234,69 @@ static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theN
return 0; return 0;
} }
#include <Extrema_FuncExtPS.hxx>
#include <math_FunctionSetRoot.hxx>
#include <math_Vector.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgv)
{
Standard_Integer anArgIter = 1;
if (theNArg < 5)
{
theDI <<"Usage: " << theArgv[0] << " face vertex U V [N]"<<"\n";
return 1;
}
// get target shape
Standard_CString aFaceName = theArgv[anArgIter++];
Standard_CString aVertName = theArgv[anArgIter++];
const TopoDS_Shape aShapeF = DBRep::Get (aFaceName);
const TopoDS_Shape aShapeV = DBRep::Get (aVertName);
const Standard_Real aUFrom = Atof (theArgv[anArgIter++]);
const Standard_Real aVFrom = Atof (theArgv[anArgIter++]);
const Standard_Integer aNbIts = (anArgIter < theNArg) ? atol (theArgv[anArgIter++]) : 100;
if (aShapeF.IsNull() || aShapeF.ShapeType() != TopAbs_FACE)
{
std::cout << "Error: " << aFaceName << " shape is null / not a face" << std::endl;
return 1;
}
if (aShapeV.IsNull() || aShapeV.ShapeType() != TopAbs_VERTEX)
{
std::cout << "Error: " << aVertName << " shape is null / not a vertex" << std::endl;
return 1;
}
const TopoDS_Face aFace = TopoDS::Face (aShapeF);
const TopoDS_Vertex aVert = TopoDS::Vertex (aShapeV);
GeomAdaptor_Surface aSurf (BRep_Tool::Surface (aFace));
gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
Extrema_FuncExtPS anExtFunc;
math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
math_Vector aTolUV (1, 2), aUVinf (1, 2), aUVsup (1, 2), aFromUV (1, 2);
aTolUV (1) = Precision::Confusion(); aTolUV (2) = Precision::Confusion();
aUVinf (1) = -Precision::Infinite(); aUVinf (2) = -Precision::Infinite();
aUVsup (1) = Precision::Infinite(); aUVsup (2) = Precision::Infinite();
aFromUV(1) = aUFrom; aFromUV(2) = aVFrom;
anExtFunc.Initialize (aSurf);
anExtFunc.SetPoint (aPnt);
aRoot.SetTolerance (aTolUV);
aRoot.Perform (anExtFunc, aFromUV, aUVinf, aUVsup);
if (!aRoot.IsDone())
{
std::cerr << "No results!\n";
return 1;
}
theDI << aRoot.Root()(1) << " " << aRoot.Root()(2) << "\n";
aSurf.D0 (aRoot.Root()(1), aRoot.Root()(2), aRes);
DBRep::Set ("result", BRepBuilderAPI_MakeVertex (aRes));
return 0;
}
void QABugs::Commands_19(Draw_Interpretor& theCommands) { void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; const char *group = "QABugs";
@ -1254,5 +1317,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group); theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group);
theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group); theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group); theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
return; return;
} }

View File

@ -65,11 +65,11 @@
#define FSR_DEBUG(arg) #define FSR_DEBUG(arg)
// Uncomment the following code to have debug output to cout // Uncomment the following code to have debug output to cout
/* //==========================================================
static Standard_Boolean mydebug = Standard_False; //static Standard_Boolean mydebug = Standard_True;
#undef FSR_DEBUG //#undef FSR_DEBUG
#define FSR_DEBUG(arg) {if (mydebug) { cout << arg << endl; }} //#define FSR_DEBUG(arg) {if (mydebug) { cout << arg << endl; }}
*/ //===========================================================
class MyDirFunction : public math_Function class MyDirFunction : public math_Function
{ {
@ -89,13 +89,13 @@ public :
math_FunctionSetWithDerivatives& f) ; math_FunctionSetWithDerivatives& f) ;
void Initialize(const math_Vector& p0, const math_Vector& dir) const; void Initialize(const math_Vector& p0, const math_Vector& dir) const;
//For hp : //For hp :
Standard_Boolean Value(const math_Vector& Sol, math_Vector& FF, Standard_Boolean Value(const math_Vector& Sol, math_Vector& FF,
math_Matrix& DF, math_Vector& GH, math_Matrix& DF, math_Vector& GH,
Standard_Real& F2, Standard_Real& Gnr1); Standard_Real& F2, Standard_Real& Gnr1);
// Standard_Boolean MyDirFunction::Value(const math_Vector& Sol, math_Vector& FF, // Standard_Boolean MyDirFunction::Value(const math_Vector& Sol, math_Vector& FF,
// math_Matrix& DF, math_Vector& GH, // math_Matrix& DF, math_Vector& GH,
// Standard_Real& F2, Standard_Real& Gnr1); // Standard_Real& F2, Standard_Real& Gnr1);
Standard_Boolean Value(const Standard_Real x, Standard_Real& fval) ; Standard_Boolean Value(const Standard_Real x, Standard_Real& fval) ;
}; };
@ -137,8 +137,8 @@ Standard_Boolean MyDirFunction::Value(const Standard_Real x,
aVal = FV->Value(i); aVal = FV->Value(i);
if(aVal < 0.) { if(aVal < 0.) {
if(aVal <= -1.e+100) // Precision::HalfInfinite() later if(aVal <= -1.e+100) // Precision::HalfInfinite() later
// if(Precision::IsInfinite(Abs(FV->Value(i)))) { // if(Precision::IsInfinite(Abs(FV->Value(i)))) {
// fval = Precision::Infinite(); // fval = Precision::Infinite();
return Standard_False; return Standard_False;
} }
else if(aVal >= 1.e+100) // Precision::HalfInfinite() later else if(aVal >= 1.e+100) // Precision::HalfInfinite() later
@ -163,18 +163,18 @@ Standard_Boolean MyDirFunction::Value(const math_Vector& Sol,
Standard_Real aVal = 0.; Standard_Real aVal = 0.;
for(Standard_Integer i = FF.Lower(); i <= FF.Upper(); i++) { for(Standard_Integer i = FF.Lower(); i <= FF.Upper(); i++) {
// modified by NIZHNY-MKK Mon Oct 3 17:56:50 2005.BEGIN // modified by NIZHNY-MKK Mon Oct 3 17:56:50 2005.BEGIN
aVal = FF.Value(i); aVal = FF.Value(i);
if(aVal < 0.) { if(aVal < 0.) {
if(aVal <= -1.e+100) // Precision::HalfInfinite() later if(aVal <= -1.e+100) // Precision::HalfInfinite() later
// if(Precision::IsInfinite(Abs(FF.Value(i)))) { // if(Precision::IsInfinite(Abs(FF.Value(i)))) {
// F2 = Precision::Infinite(); // F2 = Precision::Infinite();
// Gnr1 = Precision::Infinite(); // Gnr1 = Precision::Infinite();
return Standard_False; return Standard_False;
} }
else if(aVal >= 1.e+100) // Precision::HalfInfinite() later else if(aVal >= 1.e+100) // Precision::HalfInfinite() later
return Standard_False; return Standard_False;
// modified by NIZHNY-MKK Mon Oct 3 17:57:05 2005.END // modified by NIZHNY-MKK Mon Oct 3 17:57:05 2005.END
} }
@ -202,8 +202,8 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P0,
math_Vector& Delta, math_Vector& Delta,
const math_Vector& Tol, const math_Vector& Tol,
MyDirFunction& F) MyDirFunction& F)
// Purpose : minimisation a partir de 3 points // Purpose : minimisation a partir de 3 points
//------------------------------------------------------- //-------------------------------------------------------
{ {
// (1) Evaluation d'un tolerance parametrique 1D // (1) Evaluation d'un tolerance parametrique 1D
Standard_Real tol1d = 2.1 , invnorme, tsol; Standard_Real tol1d = 2.1 , invnorme, tsol;
@ -217,11 +217,11 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P0,
if (tol1d > 1.9) return Standard_False; //Pas la peine de se fatiguer if (tol1d > 1.9) return Standard_False; //Pas la peine de se fatiguer
tol1d /= 3; tol1d /= 3;
//JR/Hp : //JR/Hp :
math_Vector PP0 = P0 ; math_Vector PP0 = P0 ;
math_Vector PP1 = P1 ; math_Vector PP1 = P1 ;
Delta = PP1 - PP0; Delta = PP1 - PP0;
// Delta = P1 - P0; // Delta = P1 - P0;
invnorme = Delta.Norm(); invnorme = Delta.Norm();
if (invnorme <= Eps) return Standard_False; if (invnorme <= Eps) return Standard_False;
invnorme = ((Standard_Real) 1) / invnorme; invnorme = ((Standard_Real) 1) / invnorme;
@ -253,8 +253,8 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
const math_Vector& DGradient, const math_Vector& DGradient,
const math_Vector& Tol, const math_Vector& Tol,
MyDirFunction& F) MyDirFunction& F)
// Purpose: minimisation a partir de 2 points et une derives // Purpose: minimisation a partir de 2 points et une derives
//---------------------------------------------------------------------- //----------------------------------------------------------------------
{ {
// (0) Evaluation d'un tolerance parametrique 1D // (0) Evaluation d'un tolerance parametrique 1D
@ -270,7 +270,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
// (1) On realise une premiere interpolation quadratique // (1) On realise une premiere interpolation quadratique
Standard_Real ax, bx, cx, df1, df2, Delta, tsol, fsol, tsolbis; Standard_Real ax, bx, cx, df1, df2, Delta, tsol, fsol, tsolbis;
FSR_DEBUG(" essai d interpolation") FSR_DEBUG(" essai d interpolation");
df1 = Gradient*Dir; df1 = Gradient*Dir;
df2 = DGradient*Dir; df2 = DGradient*Dir;
@ -312,7 +312,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
if (fsol<PValue) { if (fsol<PValue) {
good = Standard_True; good = Standard_True;
Result = fsol; Result = fsol;
FSR_DEBUG("t= "<<tsol<<" F = " << fsol << " OldF = "<<PValue) FSR_DEBUG("t= "<<tsol<<" F = " << fsol << " OldF = "<<PValue);
} }
// (2) Si l'on a pas assez progresser on realise une recherche // (2) Si l'on a pas assez progresser on realise une recherche
@ -325,7 +325,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
else { else {
ax = 0.0; bx = tsol; cx = 1.0; ax = 0.0; bx = tsol; cx = 1.0;
} }
FSR_DEBUG(" minimisation dans la direction") FSR_DEBUG(" minimisation dans la direction");
math_BrentMinimum Sol(F, ax, bx, cx, tol1d, 100, tol1d); math_BrentMinimum Sol(F, ax, bx, cx, tol1d, 100, tol1d);
if(Sol.IsDone()) { if(Sol.IsDone()) {
if (Sol.Minimum() <= Result) { if (Sol.Minimum() <= Result) {
@ -362,7 +362,7 @@ static void SearchDirection(const math_Matrix& DF,
math_Gauss Solut(DF, 1.e-9); math_Gauss Solut(DF, 1.e-9);
if (Solut.IsDone()) Solut.Solve(Direction); if (Solut.IsDone()) Solut.Solve(Direction);
else { // we have to "forget" singular directions. else { // we have to "forget" singular directions.
FSR_DEBUG(" Matrice singuliere : On prend SVD") FSR_DEBUG(" Matrice singuliere : On prend SVD");
math_SVD SolvebySVD(DF); math_SVD SolvebySVD(DF);
if (SolvebySVD.IsDone()) SolvebySVD.Solve(-1*FF, Direction); if (SolvebySVD.IsDone()) SolvebySVD.Solve(-1*FF, Direction);
else ChangeDirection = Standard_True; else ChangeDirection = Standard_True;
@ -412,15 +412,15 @@ static void SearchDirection(const math_Matrix& DF,
const math_Vector& GH, const math_Vector& GH,
const math_Vector& FF, const math_Vector& FF,
const math_IntegerVector& Constraints, const math_IntegerVector& Constraints,
// const math_Vector& X, // Le point d'init // const math_Vector& X, // Le point d'init
const math_Vector& , // Le point d'init const math_Vector& , // Le point d'init
Standard_Boolean ChangeDirection, Standard_Boolean ChangeDirection,
const math_Vector& InvLengthMax, const math_Vector& InvLengthMax,
math_Vector& Direction, math_Vector& Direction,
Standard_Real& Dy) Standard_Real& Dy)
//Purpose : Recherche une direction (et un pas si Newton Fonctionne) le long //Purpose : Recherche une direction (et un pas si Newton Fonctionne) le long
// d'une frontiere // d'une frontiere
//===================================================================== //=====================================================================
{ {
Standard_Integer Ninc = DF.ColNumber(), Neq = DF.RowNumber(); Standard_Integer Ninc = DF.ColNumber(), Neq = DF.RowNumber();
Standard_Integer i, j, k, Cons = 0; Standard_Integer i, j, k, Cons = 0;
@ -491,13 +491,13 @@ Standard_Boolean Bounds(const math_Vector& InfBound,
math_IntegerVector& Constraints, math_IntegerVector& Constraints,
math_Vector& Delta, math_Vector& Delta,
Standard_Boolean& theIsNewSol) Standard_Boolean& theIsNewSol)
// //
// Purpose: Trims an initial solution Sol to be within a domain defined by // Purpose: Trims an initial solution Sol to be within a domain defined by
// InfBound and SupBound. Delta will contain a distance between final Sol and // InfBound and SupBound. Delta will contain a distance between final Sol and
// SolSave. // SolSave.
// IsNewSol returns False, if final Sol fully coincides with SolSave, i.e. // IsNewSol returns False, if final Sol fully coincides with SolSave, i.e.
// if SolSave already lied on a boundary and initial Sol was fully beyond it // if SolSave already lied on a boundary and initial Sol was fully beyond it
//====================================================== //======================================================
{ {
Standard_Boolean Out = Standard_False; Standard_Boolean Out = Standard_False;
Standard_Integer i, Ninc = Sol.Length(); Standard_Integer i, Ninc = Sol.Length();
@ -559,9 +559,9 @@ Standard_Boolean Bounds(const math_Vector& InfBound,
math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F, math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
const math_Vector& Tolerance, const math_Vector& Tolerance,
const Standard_Integer NbIterations) : const Standard_Integer NbIterations) :
Delta(1, F.NbVariables()), Delta(1, F.NbVariables()),
Sol(1, F.NbVariables()), Sol(1, F.NbVariables()),
DF(1, F.NbEquations(), DF(1, F.NbEquations(),
1, F.NbVariables()), 1, F.NbVariables()),
Tol(1,F.NbVariables()), Tol(1,F.NbVariables()),
@ -590,9 +590,9 @@ math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F, math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
const Standard_Integer NbIterations) : const Standard_Integer NbIterations) :
Delta(1, F.NbVariables()), Delta(1, F.NbVariables()),
Sol(1, F.NbVariables()), Sol(1, F.NbVariables()),
DF(1, F.NbEquations(), DF(1, F.NbEquations(),
1, F.NbVariables()), 1, F.NbVariables()),
Tol(1, F.NbVariables()), Tol(1, F.NbVariables()),
@ -625,9 +625,9 @@ math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
const math_Vector& supBound, const math_Vector& supBound,
const Standard_Integer NbIterations, const Standard_Integer NbIterations,
Standard_Boolean theStopOnDivergent) : Standard_Boolean theStopOnDivergent) :
Delta(1, F.NbVariables()), Delta(1, F.NbVariables()),
Sol(1, F.NbVariables()), Sol(1, F.NbVariables()),
DF(1, F.NbEquations(), DF(1, F.NbEquations(),
1, F.NbVariables()), 1, F.NbVariables()),
Tol(1,F.NbVariables()), Tol(1,F.NbVariables()),
@ -661,9 +661,9 @@ math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
const math_Vector& StartingPoint, const math_Vector& StartingPoint,
const math_Vector& Tolerance, const math_Vector& Tolerance,
const Standard_Integer NbIterations) : const Standard_Integer NbIterations) :
Delta(1, F.NbVariables()), Delta(1, F.NbVariables()),
Sol(1, F.NbVariables()), Sol(1, F.NbVariables()),
DF(1, F.NbEquations(), DF(1, F.NbEquations(),
1, StartingPoint.Length()), 1, StartingPoint.Length()),
Tol(1,F.NbVariables()), Tol(1,F.NbVariables()),
@ -683,7 +683,7 @@ math_FunctionSetRoot::math_FunctionSetRoot(math_FunctionSetWithDerivatives& F,
Temp3(1, F.NbVariables()), Temp3(1, F.NbVariables()),
Temp4(1, F.NbEquations()) Temp4(1, F.NbEquations())
{ {
for (Standard_Integer i = 1; i <= Tol.Length(); i++) { for (Standard_Integer i = 1; i <= Tol.Length(); i++) {
Tol(i) = Tolerance(i); Tol(i) = Tolerance(i);
} }
@ -726,8 +726,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
math_Vector InvLengthMax(1, Ninc); // Pour bloquer les pas a 1/4 du domaine math_Vector InvLengthMax(1, Ninc); // Pour bloquer les pas a 1/4 du domaine
math_IntegerVector Constraints(1, Ninc); // Pour savoir sur quels bord on se trouve math_IntegerVector Constraints(1, Ninc); // Pour savoir sur quels bord on se trouve
for (i = 1; i <= Ninc ; i++) { for (i = 1; i <= Ninc ; i++) {
// modified by NIZHNY-MKK Mon Oct 3 18:03:50 2005 // modified by NIZHNY-MKK Mon Oct 3 18:03:50 2005
// InvLengthMax(i) = 1. / Max(Abs(SupBound(i) - InfBound(i))/4, 1.e-9); // InvLengthMax(i) = 1. / Max(Abs(SupBound(i) - InfBound(i))/4, 1.e-9);
InvLengthMax(i) = 1. / Max((SupBound(i) - InfBound(i))/4, 1.e-9); InvLengthMax(i) = 1. / Max((SupBound(i) - InfBound(i))/4, 1.e-9);
} }
@ -770,8 +770,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
// de faire une seconde iteration... // de faire une seconde iteration...
Save(0) = Max (F2, EpsSqrt); Save(0) = Max (F2, EpsSqrt);
Standard_Real aTol_Func = Epsilon(F2); Standard_Real aTol_Func = Epsilon(F2);
FSR_DEBUG("=== Mode Debug de Function Set Root" << endl) FSR_DEBUG("=== Mode Debug de Function Set Root" << endl);
FSR_DEBUG(" F2 Initial = " << F2) FSR_DEBUG(" F2 Initial = " << F2);
if ((F2 <= Eps) || (Gnr1 <= Eps2)) { if ((F2 <= Eps) || (Gnr1 <= Eps2)) {
Done = Standard_False; Done = Standard_False;
@ -830,7 +830,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
DHSave = GH; DHSave = GH;
if (isNewSol) { if (isNewSol) {
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)
@ -841,9 +841,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
} }
FSR_DEBUG("Kount = " << Kount) FSR_DEBUG("Kount = " << Kount);
FSR_DEBUG("Le premier F2 = " << F2) FSR_DEBUG("Le premier F2 = " << F2);
FSR_DEBUG("Direction = " << ChangeDirection) FSR_DEBUG("Direction = " << ChangeDirection);
if ((F2 <= Eps) || (Gnr1 <= Eps2)) { if ((F2 <= Eps) || (Gnr1 <= Eps2)) {
Done = Standard_False; Done = Standard_False;
@ -873,7 +873,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
while((F2/PreviousMinimum > Progres) && !Stop) { while((F2/PreviousMinimum > Progres) && !Stop) {
if (F2 < OldF && (Dy < 0.0)) { if (F2 < OldF && (Dy < 0.0)) {
// On essaye de progresser dans cette direction. // On essaye de progresser dans cette direction.
FSR_DEBUG(" iteration de descente = " << DescenteIter) FSR_DEBUG(" iteration de descente = " << DescenteIter);
DescenteIter++; DescenteIter++;
SolSave = Sol; SolSave = Sol;
OldF = F2; OldF = F2;
@ -892,7 +892,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
// //
Stop = Bounds(InfBound, SupBound, Tol, Sol, SolSave, Stop = Bounds(InfBound, SupBound, Tol, Sol, SolSave,
Constraints, Delta, isNewSol); Constraints, Delta, isNewSol);
FSR_DEBUG(" Augmentation de lambda") FSR_DEBUG(" Augmentation de lambda");
Ambda *= 1.7; Ambda *= 1.7;
} }
else { else {
@ -937,7 +937,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
DHSave = GH; DHSave = GH;
if (isNewSol) { if (isNewSol) {
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)
@ -962,12 +962,12 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
return; return;
} }
if (DescenteIter >= 10) { if (DescenteIter >= 100) {
Stop = Standard_True; Stop = Standard_True;
} }
} }
FSR_DEBUG("--- Sortie du Traitement Standard") FSR_DEBUG("--- Sortie du Traitement Standard");
FSR_DEBUG(" DescenteIter = "<<DescenteIter << " F2 = " << F2) FSR_DEBUG(" DescenteIter = "<<DescenteIter << " F2 = " << F2);
} }
// ------------------------------------ // ------------------------------------
// on passe au traitement des bords // on passe au traitement des bords
@ -984,11 +984,11 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
OldF = F2; OldF = F2;
SearchDirection(DF, GH, FF, Constraints, Sol, SearchDirection(DF, GH, FF, Constraints, Sol,
ChangeDirection, InvLengthMax, DH, Dy); ChangeDirection, InvLengthMax, DH, Dy);
FSR_DEBUG(" Conditional Direction = " << ChangeDirection) FSR_DEBUG(" Conditional Direction = " << ChangeDirection);
if (Dy<-Eps) { //Pour eviter des calculs inutiles et des /0... if (Dy<-Eps) { //Pour eviter des calculs inutiles et des /0...
if (ChangeDirection) { if (ChangeDirection) {
// Ambda = Ambda2 / Sqrt(Abs(Dy)); // Ambda = Ambda2 / Sqrt(Abs(Dy));
Ambda = Ambda2 / Sqrt(-Dy); Ambda = Ambda2 / Sqrt(-Dy);
if (Ambda > 1.0) Ambda = 1.0; if (Ambda > 1.0) Ambda = 1.0;
} }
@ -1015,7 +1015,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
DHSave = GH; DHSave = GH;
if (isNewSol) { if (isNewSol) {
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)
@ -1026,8 +1026,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
} }
Ambda2 = Gnr1; Ambda2 = Gnr1;
FSR_DEBUG("--- Iteration au bords : " << DescenteIter) FSR_DEBUG("--- Iteration au bords : " << DescenteIter);
FSR_DEBUG("--- F2 = " << F2) FSR_DEBUG("--- F2 = " << F2);
} }
else { else {
Stop = Standard_True; Stop = Standard_True;
@ -1035,7 +1035,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
while((F2/PreviousMinimum > Progres) && (F2<OldF) && (!Stop) ) { while((F2/PreviousMinimum > Progres) && (F2<OldF) && (!Stop) ) {
DescenteIter++; DescenteIter++;
FSR_DEBUG("--- Iteration de descente conditionnel = " << DescenteIter) FSR_DEBUG("--- Iteration de descente conditionnel = " << DescenteIter);
if (F2 < OldF && Dy < 0.0) { if (F2 < OldF && Dy < 0.0) {
// On essaye de progresser dans cette direction. // On essaye de progresser dans cette direction.
SolSave = Sol; SolSave = Sol;
@ -1058,7 +1058,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
DHSave = GH; DHSave = GH;
if (isNewSol) { if (isNewSol) {
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)
@ -1099,7 +1099,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
Sort = Bounds(InfBound, SupBound, Tol, Sol, SolSave, Sort = Bounds(InfBound, SupBound, Tol, Sol, SolSave,
Constraints, Delta, isNewSol); Constraints, Delta, isNewSol);
if (isNewSol) { if (isNewSol) {
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)
@ -1112,8 +1112,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
} }
Dy = GH*DH; Dy = GH*DH;
} }
FSR_DEBUG("--- Sortie du Traitement des Bords") FSR_DEBUG("--- Sortie du Traitement des Bords");
FSR_DEBUG("--- DescenteIter = "<<DescenteIter << " F2 = " << F2) FSR_DEBUG("--- DescenteIter = "<<DescenteIter << " F2 = " << F2);
} }
} }
@ -1208,7 +1208,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
if (!ChangeDirection) { // On passe au gradient if (!ChangeDirection) { // On passe au gradient
ChangeDirection = Standard_True; ChangeDirection = Standard_True;
Sol = PreviousSolution; Sol = PreviousSolution;
// F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1); // F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1);
if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) { if(!F_Dir.Value(Sol, FF, DF, GH, F2, Gnr1)) {
Done = Standard_False; Done = Standard_False;
if (!theStopOnDivergent || !myIsDivergent) if (!theStopOnDivergent || !myIsDivergent)

22
tests/bugs/fclasses/bug24137 Executable file
View File

@ -0,0 +1,22 @@
puts "================"
puts "OCC24137"
puts "================"
puts ""
#######################################################################
# math_FunctionSetRoot returns too rough solution
#######################################################################
pload QAcommands
vertex v 6.65634 -0.201746 2.51477
restore [locate_data_file bug24137_face.brep] f
OCC24137 f v 508.326 77.6999
distmini d v result
regexp {([-0-9.+eE]+)$} [dump d_val] full dist
set good_dist 0
set toler 2.0e-06
if { [expr abs( ${dist} - ${good_dist} )] > ${toler} } {
puts "Faulty : the distanse is ${dist}. It is bad value"
}

View File

@ -39,7 +39,8 @@ puts "CPU_user_time=${CPU_user_time}"
set CPU_user_time [expr ${CPU_user_time} / ${NbTests}] set CPU_user_time [expr ${CPU_user_time} / ${NbTests}]
puts "CPU_user_time=${CPU_user_time}" puts "CPU_user_time=${CPU_user_time}"
set square 3.56087e+07 #CR24137 set square 3.56087e+07
set square 3.52471e+07
# Analysis of "nbshapes res" # Analysis of "nbshapes res"
set nb_v_good 24 set nb_v_good 24
@ -53,4 +54,3 @@ set nb_compound_good 1
set nb_shape_good 102 set nb_shape_good 102
set 2dviewer 0 set 2dviewer 0

View File

@ -39,7 +39,8 @@ puts "CPU_user_time=${CPU_user_time}"
set CPU_user_time [expr ${CPU_user_time} / ${NbTests}] set CPU_user_time [expr ${CPU_user_time} / ${NbTests}]
puts "CPU_user_time=${CPU_user_time}" puts "CPU_user_time=${CPU_user_time}"
set square 782201 #CR24317 set square 782201
set square 766474
# Analysis of "nbshapes res" # Analysis of "nbshapes res"
set nb_v_good 53 set nb_v_good 53

View File

@ -6,11 +6,11 @@ set filename lh93wsddr3370z4.igs
set ref_data { set ref_data {
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
TPSTAT : Faulties = 0 ( 0 ) Warnings = 162 ( 4127 ) Summary = 162 ( 4127 ) TPSTAT : Faulties = 0 ( 0 ) Warnings = 164 ( 4127 ) Summary = 164 ( 4127 )
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) Summary = 7237 ( 7237 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) Summary = 7239 ( 7237 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 3192 ( 3192 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 3193 ( 3192 )
TOLERANCE : MaxTol = 0.08683083502 ( 0.04341528762 ) AvgTol = 0.000870172875 ( 0.0007502917279 ) TOLERANCE : MaxTol = 0.08683083502 ( 0.04341528762 ) AvgTol = 0.0008697846249 ( 0.0007558849075 )
LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 0 ( 0 ) NCOLORS : NColors = 0 ( 0 )