mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +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:
parent
91bb31f35e
commit
89d8607f13
@ -1234,6 +1234,69 @@ static Standard_Integer OCC24005 (Draw_Interpretor& theDI, Standard_Integer theN
|
||||
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) {
|
||||
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 ("OCC11758", "OCC11758", __FILE__, OCC11758, group);
|
||||
theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group);
|
||||
theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group);
|
||||
return;
|
||||
}
|
||||
|
@ -65,11 +65,11 @@
|
||||
|
||||
#define FSR_DEBUG(arg)
|
||||
// Uncomment the following code to have debug output to cout
|
||||
/*
|
||||
static Standard_Boolean mydebug = Standard_False;
|
||||
#undef FSR_DEBUG
|
||||
#define FSR_DEBUG(arg) {if (mydebug) { cout << arg << endl; }}
|
||||
*/
|
||||
//==========================================================
|
||||
//static Standard_Boolean mydebug = Standard_True;
|
||||
//#undef FSR_DEBUG
|
||||
//#define FSR_DEBUG(arg) {if (mydebug) { cout << arg << endl; }}
|
||||
//===========================================================
|
||||
|
||||
class MyDirFunction : public math_Function
|
||||
{
|
||||
@ -270,7 +270,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
|
||||
|
||||
// (1) On realise une premiere interpolation quadratique
|
||||
Standard_Real ax, bx, cx, df1, df2, Delta, tsol, fsol, tsolbis;
|
||||
FSR_DEBUG(" essai d interpolation")
|
||||
FSR_DEBUG(" essai d interpolation");
|
||||
|
||||
df1 = Gradient*Dir;
|
||||
df2 = DGradient*Dir;
|
||||
@ -312,7 +312,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
|
||||
if (fsol<PValue) {
|
||||
good = Standard_True;
|
||||
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
|
||||
@ -325,7 +325,7 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P,
|
||||
else {
|
||||
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);
|
||||
if(Sol.IsDone()) {
|
||||
if (Sol.Minimum() <= Result) {
|
||||
@ -362,7 +362,7 @@ static void SearchDirection(const math_Matrix& DF,
|
||||
math_Gauss Solut(DF, 1.e-9);
|
||||
if (Solut.IsDone()) Solut.Solve(Direction);
|
||||
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);
|
||||
if (SolvebySVD.IsDone()) SolvebySVD.Solve(-1*FF, Direction);
|
||||
else ChangeDirection = Standard_True;
|
||||
@ -770,8 +770,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
// de faire une seconde iteration...
|
||||
Save(0) = Max (F2, EpsSqrt);
|
||||
Standard_Real aTol_Func = Epsilon(F2);
|
||||
FSR_DEBUG("=== Mode Debug de Function Set Root" << endl)
|
||||
FSR_DEBUG(" F2 Initial = " << F2)
|
||||
FSR_DEBUG("=== Mode Debug de Function Set Root" << endl);
|
||||
FSR_DEBUG(" F2 Initial = " << F2);
|
||||
|
||||
if ((F2 <= Eps) || (Gnr1 <= Eps2)) {
|
||||
Done = Standard_False;
|
||||
@ -841,9 +841,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
}
|
||||
}
|
||||
|
||||
FSR_DEBUG("Kount = " << Kount)
|
||||
FSR_DEBUG("Le premier F2 = " << F2)
|
||||
FSR_DEBUG("Direction = " << ChangeDirection)
|
||||
FSR_DEBUG("Kount = " << Kount);
|
||||
FSR_DEBUG("Le premier F2 = " << F2);
|
||||
FSR_DEBUG("Direction = " << ChangeDirection);
|
||||
|
||||
if ((F2 <= Eps) || (Gnr1 <= Eps2)) {
|
||||
Done = Standard_False;
|
||||
@ -873,7 +873,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
while((F2/PreviousMinimum > Progres) && !Stop) {
|
||||
if (F2 < OldF && (Dy < 0.0)) {
|
||||
// On essaye de progresser dans cette direction.
|
||||
FSR_DEBUG(" iteration de descente = " << DescenteIter)
|
||||
FSR_DEBUG(" iteration de descente = " << DescenteIter);
|
||||
DescenteIter++;
|
||||
SolSave = Sol;
|
||||
OldF = F2;
|
||||
@ -892,7 +892,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
//
|
||||
Stop = Bounds(InfBound, SupBound, Tol, Sol, SolSave,
|
||||
Constraints, Delta, isNewSol);
|
||||
FSR_DEBUG(" Augmentation de lambda")
|
||||
FSR_DEBUG(" Augmentation de lambda");
|
||||
Ambda *= 1.7;
|
||||
}
|
||||
else {
|
||||
@ -962,12 +962,12 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (DescenteIter >= 10) {
|
||||
if (DescenteIter >= 100) {
|
||||
Stop = Standard_True;
|
||||
}
|
||||
}
|
||||
FSR_DEBUG("--- Sortie du Traitement Standard")
|
||||
FSR_DEBUG(" DescenteIter = "<<DescenteIter << " F2 = " << F2)
|
||||
FSR_DEBUG("--- Sortie du Traitement Standard");
|
||||
FSR_DEBUG(" DescenteIter = "<<DescenteIter << " F2 = " << F2);
|
||||
}
|
||||
// ------------------------------------
|
||||
// on passe au traitement des bords
|
||||
@ -984,7 +984,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
OldF = F2;
|
||||
SearchDirection(DF, GH, FF, Constraints, Sol,
|
||||
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 (ChangeDirection) {
|
||||
|
||||
@ -1026,8 +1026,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
}
|
||||
}
|
||||
Ambda2 = Gnr1;
|
||||
FSR_DEBUG("--- Iteration au bords : " << DescenteIter)
|
||||
FSR_DEBUG("--- F2 = " << F2)
|
||||
FSR_DEBUG("--- Iteration au bords : " << DescenteIter);
|
||||
FSR_DEBUG("--- F2 = " << F2);
|
||||
}
|
||||
else {
|
||||
Stop = Standard_True;
|
||||
@ -1035,7 +1035,7 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
|
||||
while((F2/PreviousMinimum > Progres) && (F2<OldF) && (!Stop) ) {
|
||||
DescenteIter++;
|
||||
FSR_DEBUG("--- Iteration de descente conditionnel = " << DescenteIter)
|
||||
FSR_DEBUG("--- Iteration de descente conditionnel = " << DescenteIter);
|
||||
if (F2 < OldF && Dy < 0.0) {
|
||||
// On essaye de progresser dans cette direction.
|
||||
SolSave = Sol;
|
||||
@ -1112,8 +1112,8 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
|
||||
}
|
||||
Dy = GH*DH;
|
||||
}
|
||||
FSR_DEBUG("--- Sortie du Traitement des Bords")
|
||||
FSR_DEBUG("--- DescenteIter = "<<DescenteIter << " F2 = " << F2)
|
||||
FSR_DEBUG("--- Sortie du Traitement des Bords");
|
||||
FSR_DEBUG("--- DescenteIter = "<<DescenteIter << " F2 = " << F2);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
tests/bugs/fclasses/bug24137
Executable file
22
tests/bugs/fclasses/bug24137
Executable 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"
|
||||
}
|
@ -39,7 +39,8 @@ puts "CPU_user_time=${CPU_user_time}"
|
||||
set CPU_user_time [expr ${CPU_user_time} / ${NbTests}]
|
||||
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"
|
||||
set nb_v_good 24
|
||||
@ -53,4 +54,3 @@ set nb_compound_good 1
|
||||
set nb_shape_good 102
|
||||
|
||||
set 2dviewer 0
|
||||
|
||||
|
@ -39,7 +39,8 @@ puts "CPU_user_time=${CPU_user_time}"
|
||||
set CPU_user_time [expr ${CPU_user_time} / ${NbTests}]
|
||||
puts "CPU_user_time=${CPU_user_time}"
|
||||
|
||||
set square 782201
|
||||
#CR24317 set square 782201
|
||||
set square 766474
|
||||
|
||||
# Analysis of "nbshapes res"
|
||||
set nb_v_good 53
|
||||
|
@ -6,11 +6,11 @@ set filename lh93wsddr3370z4.igs
|
||||
|
||||
set ref_data {
|
||||
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 )
|
||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) Summary = 7237 ( 7237 )
|
||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 448 ( 448 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 3192 ( 3192 )
|
||||
TOLERANCE : MaxTol = 0.08683083502 ( 0.04341528762 ) AvgTol = 0.000870172875 ( 0.0007502917279 )
|
||||
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 = 3193 ( 3192 )
|
||||
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 )
|
||||
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
|
||||
NCOLORS : NColors = 0 ( 0 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user