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

Merge CR32225 for regression 32189

This commit is contained in:
jfa 2021-03-23 16:54:57 +03:00
parent a6a553752d
commit 0c61d93892
3 changed files with 116 additions and 30 deletions

View File

@ -84,14 +84,21 @@ public:
//! Return the Nth extremum on S. //! Return the Nth extremum on S.
Standard_EXPORT const Extrema_POnSurf& PointOnSurface (const Standard_Integer N) const; Standard_EXPORT const Extrema_POnSurf& PointOnSurface (const Standard_Integer N) const;
//! Change Sequence of SquareDistance
Standard_EXPORT TColStd_SequenceOfReal& SquareDistances()
{
protected: return mySqDist;
}
//! Change Sequence of PointOnCurv
Standard_EXPORT Extrema_SequenceOfPOnCurv& PointsOnCurve()
{
return myPoint1;
}
//! Change Sequence of PointOnSurf
Standard_EXPORT Extrema_SequenceOfPOnSurf& PointsOnSurf()
{
return myPoint2;
}
private: private:

View File

@ -304,17 +304,31 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
Tol(2) = mytol2; Tol(2) = mytol2;
Tol(3) = mytol2; Tol(3) = mytol2;
// //
TUVinf(1) = mytmin; // Number of particles used in PSO algorithm (particle swarm optimization).
const Standard_Integer aNbParticles = 48;
Standard_Integer aNbIntC = 1;
if (C.IsClosed() || C.IsPeriodic())
{
Standard_Real aPeriod = C.Period();
if (C.LastParameter() - C.FirstParameter() > 2. * aPeriod / 3.)
{
aNbIntC = 2;
}
}
Standard_Integer anInt;
Standard_Real dT = (mytsup - mytmin) / aNbIntC;
for (anInt = 1; anInt <= aNbIntC; anInt++)
{
TUVinf(1) = mytmin + (anInt - 1) * dT;
TUVinf(2) = trimumin; TUVinf(2) = trimumin;
TUVinf(3) = trimvmin; TUVinf(3) = trimvmin;
// //
TUVsup(1) = mytsup; TUVsup(1) = TUVinf(1) + dT; // mytsup;
TUVsup(2) = trimusup; TUVsup(2) = trimusup;
TUVsup(3) = trimvsup; TUVsup(3) = trimvsup;
// //
// Number of particles used in PSO algorithm (particle swarm optimization).
const Standard_Integer aNbParticles = 48;
//
if (aNbVar == 3) if (aNbVar == 3)
{ {
GlobMinGenCS(C, aNbParticles, TUVinf, TUVsup, TUV); GlobMinGenCS(C, aNbParticles, TUVinf, TUVsup, TUV);
@ -331,6 +345,43 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
// Find min approximation // Find min approximation
math_FunctionSetRoot anA(myF, Tol); math_FunctionSetRoot anA(myF, Tol);
anA.Perform(myF, TUV, TUVinf, TUVsup); anA.Perform(myF, TUV, TUVinf, TUVsup);
}
if (aNbIntC > 1 && myF.NbExt() > 1)
{
//Try to remove "false" extrema caused by dividing curve interval
TColStd_SequenceOfReal& aSqDists = myF.SquareDistances();
Extrema_SequenceOfPOnCurv& aPntsOnCrv = myF.PointsOnCurve();
Extrema_SequenceOfPOnSurf& aPntsOnSurf = myF.PointsOnSurf();
TColStd_SequenceOfReal aSqDists1(aSqDists);
Extrema_SequenceOfPOnCurv aPntsOnCrv1(aPntsOnCrv);
Extrema_SequenceOfPOnSurf aPntsOnSurf1(aPntsOnSurf);
Standard_Real aMinDist = aSqDists(1);
Standard_Integer imin = 1, i;
for (i = 2; i <= aSqDists.Length(); ++i)
{
Standard_Real aDist = aSqDists(i);
if (aDist < aMinDist)
{
aMinDist = aDist;
imin = i;
}
}
aSqDists.Clear();
aPntsOnCrv.Clear();
aPntsOnSurf.Clear();
Standard_Real aTol = Precision::SquareConfusion();
for (i = 1; i <= aSqDists1.Length(); ++i)
{
Standard_Real aDist = aSqDists1(i);
if (Abs(aDist - aMinDist) <= aTol)
{
aSqDists.Append(aDist);
aPntsOnCrv.Append(aPntsOnCrv1(i));
aPntsOnSurf.Append(aPntsOnSurf1(i));
}
}
}
myDone = Standard_True; myDone = Standard_True;
} }

View File

@ -0,0 +1,28 @@
puts "========"
puts "OCC32225: Modeling Data - Wrong result of extrema curve-surface"
puts "========"
puts ""
restore [locate_data_file bug32225_curve.draw] c
restore [locate_data_file bug32225_surf.draw] s
extrema c s
if {[isdraw ext_1]} {
set ext_dist [lindex [length ext_1] end]
checkreal "Ext_1 min distance" $ext_dist 0. 1.e-10 1.e-10
} else {
puts "Error: invalid result"
}
if {[isdraw ext_2]} {
set ext_dist [lindex [length ext_2] end]
checkreal "Ext_2 min distance" $ext_dist 0. 1.e-10 1.e-10
} else {
puts "Error: invalid result"
}
smallview
donly c ext_1 ext_2
fit
disp s
checkview -screenshot -2d -path ${imagedir}/${test_image}.png