1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027162: Draw command "(2d)extrema" incorrectly represent underlying algorithm results

Correct handling of infinity solutions added for Curve / Curve case.
Unused code deleted.
Test cases updated to the new behavior.
This commit is contained in:
aml
2016-02-16 15:47:38 +03:00
committed by abv
parent 6273fa4b6c
commit 92a206a3dd
5 changed files with 55 additions and 94 deletions

View File

@@ -205,50 +205,6 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
}
//=======================================================================
//function : extrema
//purpose :
//=======================================================================
static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if ( n<3) return 1;
Handle(Geom2d_Curve) GC1, GC2;
Standard_Real U1f,U1l,U2f,U2l;
GC1 = DrawTrSurf::GetCurve2d(a[1]);
if ( GC1.IsNull())
return 1;
U1f = GC1->FirstParameter();
U1l = GC1->LastParameter();
GC2 = DrawTrSurf::GetCurve2d(a[2]);
if ( GC2.IsNull())
return 1;
U2f = GC2->FirstParameter();
U2l = GC2->LastParameter();
char name[100];
Geom2dAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
gp_Pnt2d P1,P2;
Ex.Points(i,P1,P2);
Handle(Geom2d_Line) L = new Geom2d_Line(P1,gp_Vec2d(P1,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 << " ";
}
return 0;
}
//=======================================================================
//function : intersect
//purpose :
@@ -324,9 +280,6 @@ void GeometryTest::API2dCommands(Draw_Interpretor& theCommands)
g = "GEOMETRY curves and surfaces analysis";
theCommands.Add("2dextrema", "extrema curve curve",__FILE__,
extrema,g);
g = "GEOMETRY intersections";
theCommands.Add("2dintersect", "intersect curve curve",__FILE__,

View File

@@ -332,6 +332,8 @@ static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const
Standard_Boolean C2 = Standard_False;
Standard_Boolean S1 = Standard_False;
Standard_Boolean S2 = Standard_False;
Standard_Boolean isInfinitySolutions = Standard_False;
Standard_Real aMinDist = RealLast();
Standard_Real U1f, U1l, U2f, U2l, V1f = 0., V1l = 0., V2f = 0., V2l = 0.;
@@ -368,10 +370,9 @@ static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const
if (C1 && C2)
{
GeomAPI_ExtremaCurveCurve Ex(GC1, GC2, U1f, U1l, U2f, U2l);
if (!Ex.Extrema().IsParallel())
for (Standard_Integer aJ = 1; aJ <= Ex.NbExtrema(); ++aJ)
{
for (Standard_Integer aJ = 1; aJ <= Ex.NbExtrema(); ++aJ)
{
gp_Pnt aP1, aP2;
Ex.Points(aJ, aP1, aP2);
aPnts1.Append(aP1);
@@ -381,12 +382,10 @@ static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const
Ex.Parameters(aJ, aU1, aU2);
aPrms[0].Append(aU1);
aPrms[2].Append(aU2);
}
}
else
{
di << "Infinite number of extremas, distance = " << Ex.LowerDistance() << "\n";
}
// Since GeomAPI cannot provide access to flag directly.
isInfinitySolutions = Ex.Extrema().IsParallel();
aMinDist = Ex.LowerDistance();
}
else if (C1 && S2)
{
@@ -447,9 +446,14 @@ static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const
// Output points.
const Standard_Integer aPntCount = aPnts1.Size();
if (aPntCount == 0)
if (aPntCount == 0 || isInfinitySolutions)
{
di << "No solutions!\n";
// Infinity solutions flag may be set with 0 number of
// solutions in analytic extrema Curve/Curve.
if (isInfinitySolutions)
di << "Infinite number of extremas, distance = " << aMinDist << "\n";
else
di << "No solutions!\n";
}
for (Standard_Integer aJ = 1; aJ <= aPntCount; aJ++)
{