1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025635: Wrong result of 2D-extrema between two ellipsis

Fixed Lipschitz constant evaluation in case co-parametrized objects.
Fixed 2dextrema output.
Testcase update to new behavior.

Test cases for issue CR25635

Correction of test cases for issue CR25635
This commit is contained in:
aml
2015-02-05 16:13:39 +03:00
committed by bugmaster
parent 3f733bb126
commit e8746a262f
5 changed files with 131 additions and 17 deletions

View File

@@ -250,20 +250,23 @@ static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const
gp_Pnt2d P1,P2;
Ex.Points(i,P1,P2);
di << "dist " << i << ": " << Ex.Distance(i) << " \n";
di << "dist " << i << ": " << Ex.Distance(i) << " ";
if (Ex.Distance(i) <= Precision::PConfusion()) {
Handle(Draw_Marker2D) mark = new Draw_Marker2D( P1, Draw_X, Draw_vert);
dout << mark;
dout.Flush();
Sprintf(name,"%s%d","ext_",i);
char* temp = name;
DrawTrSurf::Set(temp, P1);
di << name << "\n";
}
else {
Handle(Geom2d_Line) L = new Geom2d_Line(P1,gp_Vec2d(P1,P2));
Handle(Geom2d_TrimmedCurve) CT =
new Geom2d_TrimmedCurve(L, 0., P1.Distance(P2));
Handle(Geom2d_TrimmedCurve) CT = new Geom2d_TrimmedCurve(L, 0., P1.Distance(P2));
Sprintf(name,"%s%d","ext_",i);
char* temp = name; // portage WNT
DrawTrSurf::Set(temp, CT);
di << name << " ";
di << name << "\n";
}
}
if (i==1)

View File

@@ -23,6 +23,7 @@
#include <math_Powell.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Precision.hxx>
//=======================================================================
@@ -194,9 +195,6 @@ void math_GlobOptMin::Perform()
{
Standard_Integer i;
// Compute initial values for myF, myY, myC.
computeInitialValues();
// Compute parameters range
Standard_Real minLength = RealLast();
Standard_Real maxLength = RealFirst();
@@ -209,6 +207,18 @@ void math_GlobOptMin::Perform()
maxLength = currentLength;
}
if (minLength < Precision::PConfusion())
{
#ifdef OCCT_DEBUG
cout << "math_GlobOptMin::Perform(): Degenerated parameters space" << endl;
#endif
return;
}
// Compute initial values for myF, myY, myC.
computeInitialValues();
myE1 = minLength * myTol;
myE2 = maxLength * myTol;
if (myC > 1.0)
@@ -293,7 +303,7 @@ void math_GlobOptMin::computeInitialValues()
Standard_Integer i;
math_Vector aCurrPnt(1, myN);
math_Vector aBestPnt(1, myN);
math_Vector aParamStep(1, myN);
Standard_Real aCurrVal = RealLast();
Standard_Real aBestVal = RealLast();
@@ -324,21 +334,29 @@ void math_GlobOptMin::computeInitialValues()
mySolCount++;
// Lipschitz const approximation
Standard_Real aLipConst = 0.0, aPrevVal;
Standard_Real aLipConst = 0.0, aPrevValDiag, aPrevValProj;
Standard_Integer aPntNb = 13;
myFunc->Value(myA, aPrevVal);
myFunc->Value(myA, aPrevValDiag);
aPrevValProj = aPrevValDiag;
Standard_Real aStep = (myB - myA).Norm() / aPntNb;
aParamStep = (myB - myA) / aPntNb;
for(i = 1; i <= aPntNb; i++)
{
aCurrPnt = myA + (myB - myA) * i / (aPntNb - 1);
aCurrPnt = myA + aParamStep * i;
// Walk over diagonal.
myFunc->Value(aCurrPnt, aCurrVal);
aLipConst = Max (Abs(aCurrVal - aPrevValDiag), aLipConst);
aPrevValDiag = aCurrVal;
if(Abs(aCurrVal - aPrevVal) / aStep > aLipConst)
aLipConst = Abs(aCurrVal - aPrevVal) / aStep;
aPrevVal = aCurrVal;
// Walk over diag in projected space aPnt(1) = myA(1) = const.
aCurrPnt(1) = myA(1);
myFunc->Value(aCurrPnt, aCurrVal);
aLipConst = Max (Abs(aCurrVal - aPrevValProj), aLipConst);
aPrevValProj = aCurrVal;
}
aLipConst *= Sqrt(myN);
aLipConst *= Sqrt(myN) / aStep;
if (aLipConst < myC * 0.1)
{