mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0032225: Modeling Data - Wrong result of extrema curve-surface
Extrema_GenExtCS.cxx: subdivision on intervals for periodic c curves is added Extrema_FuncExtCS.hxx: access to fields mySqDist, myPoint1, myPoint2 is added bug32225: new test case is added
This commit is contained in:
parent
c69e0e408f
commit
bff660919f
@ -82,6 +82,22 @@ public:
|
||||
//! Return the Nth extremum on S.
|
||||
Standard_EXPORT const Extrema_POnSurf& PointOnSurface (const Standard_Integer N) const;
|
||||
|
||||
//! Change Sequence of SquareDistance
|
||||
TColStd_SequenceOfReal& SquareDistances()
|
||||
{
|
||||
return mySqDist;
|
||||
}
|
||||
//! Change Sequence of PointOnCurv
|
||||
Extrema_SequenceOfPOnCurv& PointsOnCurve()
|
||||
{
|
||||
return myPoint1;
|
||||
}
|
||||
//! Change Sequence of PointOnSurf
|
||||
Extrema_SequenceOfPOnSurf& PointsOnSurf()
|
||||
{
|
||||
return myPoint2;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const Adaptor3d_Curve* myC;
|
||||
|
@ -304,33 +304,83 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
|
||||
Tol(2) = mytol2;
|
||||
Tol(3) = mytol2;
|
||||
//
|
||||
TUVinf(1) = mytmin;
|
||||
TUVinf(2) = trimumin;
|
||||
TUVinf(3) = trimvmin;
|
||||
//
|
||||
TUVsup(1) = mytsup;
|
||||
TUVsup(2) = trimusup;
|
||||
TUVsup(3) = trimvsup;
|
||||
//
|
||||
// Number of particles used in PSO algorithm (particle swarm optimization).
|
||||
const Standard_Integer aNbParticles = 48;
|
||||
//
|
||||
if (aNbVar == 3)
|
||||
|
||||
Standard_Integer aNbIntC = 1;
|
||||
if (C.IsClosed() || C.IsPeriodic())
|
||||
{
|
||||
GlobMinGenCS(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
}
|
||||
else if (aNbVar == 2)
|
||||
{
|
||||
GlobMinConicS(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobMinCQuadric(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
Standard_Real aPeriod = C.Period();
|
||||
if (C.LastParameter() - C.FirstParameter() > 2. * aPeriod / 3.)
|
||||
{
|
||||
aNbIntC = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Find min approximation
|
||||
math_FunctionSetRoot anA(myF, Tol);
|
||||
anA.Perform(myF, TUV, TUVinf, TUVsup);
|
||||
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(3) = trimvmin;
|
||||
//
|
||||
TUVsup(1) = TUVinf(1) + dT; // mytsup;
|
||||
TUVsup(2) = trimusup;
|
||||
TUVsup(3) = trimvsup;
|
||||
//
|
||||
if (aNbVar == 3)
|
||||
{
|
||||
GlobMinGenCS(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
}
|
||||
else if (aNbVar == 2)
|
||||
{
|
||||
GlobMinConicS(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobMinCQuadric(C, aNbParticles, TUVinf, TUVsup, TUV);
|
||||
}
|
||||
|
||||
// Find min approximation
|
||||
math_FunctionSetRoot anA(myF, Tol);
|
||||
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 i;
|
||||
for (i = 2; i <= aSqDists.Length(); ++i)
|
||||
{
|
||||
Standard_Real aDist = aSqDists(i);
|
||||
if (aDist < aMinDist)
|
||||
{
|
||||
aMinDist = aDist;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
|
28
tests/lowalgos/extcs/bug32225
Normal file
28
tests/lowalgos/extcs/bug32225
Normal 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
|
@ -1,22 +0,0 @@
|
||||
puts "========"
|
||||
puts "OCC544: Problems with the results of MakePipeShell"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
pload MODELING VISUALIZATION QAcommands
|
||||
|
||||
vinit View1
|
||||
vsetdispmode 1
|
||||
OCC544
|
||||
vdisplay result
|
||||
vsetmaterial result PLASTIC
|
||||
vsetcolor result MATRABLUE
|
||||
vsettransparency result 0.5
|
||||
vsetdispmode 1
|
||||
vfit
|
||||
vviewparams -scale 2.05374 -proj 0.135192 -0.978297 -0.157031 -up -0.399854 -0.198875 0.894743 -at 415.781529476262 349.647084890243 417.026634136105
|
||||
|
||||
vmoveto 300 70
|
||||
checkcolor 220 110 0.04 0.04 0.5
|
||||
|
||||
vdump $imagedir/${casename}.png
|
Loading…
x
Reference in New Issue
Block a user