Correct handling of infinity solutions added for Curve / Curve case.
Unused code deleted.
Test cases updated to the new behavior.
if (myDone)
{
myIsPar = AlgExt.IsParallel();
- if (!myIsPar)
+ NbExt = AlgExt.NbExt();
+ for (i = 1; i <= NbExt; i++)
{
- NbExt = AlgExt.NbExt();
- for (i = 1; i <= NbExt; i++)
+ // Verification de la validite des parametres pour le cas trimme:
+ AlgExt.Points(i, P1, P2);
+ U = P1.Parameter();
+ if (Period1 != 0.0)
+ U = ElCLib::InPeriod(U,Ut11,Ut11+Period1);
+ U2 = P2.Parameter();
+ if (Period2 != 0.0)
+ U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2);
+
+ if ((U >= Ut11 - Precision::PConfusion()) &&
+ (U <= Ut12 + Precision::PConfusion()) &&
+ (U2 >= Ut21 - Precision::PConfusion()) &&
+ (U2 <= Ut22 + Precision::PConfusion()))
{
- // Verification de la validite des parametres pour le cas trimme:
- AlgExt.Points(i, P1, P2);
- U = P1.Parameter();
- if (Period1 != 0.0)
- U = ElCLib::InPeriod(U,Ut11,Ut11+Period1);
- U2 = P2.Parameter();
- if (Period2 != 0.0)
- U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2);
-
- if ((U >= Ut11 - Precision::PConfusion()) &&
- (U <= Ut12 + Precision::PConfusion()) &&
- (U2 >= Ut21 - Precision::PConfusion()) &&
- (U2 <= Ut22 + Precision::PConfusion()))
- {
- mynbext++;
- Val = AlgExt.SquareDistance(i);
- P1.SetValues(U, P1.Value());
- P2.SetValues(U2, P2.Value());
- mySqDist.Append(Val);
- mypoints.Append(P1);
- mypoints.Append(P2);
- }
+ mynbext++;
+ Val = AlgExt.SquareDistance(i);
+ P1.SetValues(U, P1.Value());
+ P2.SetValues(U2, P2.Value());
+ mySqDist.Append(Val);
+ mypoints.Append(P1);
+ mypoints.Append(P2);
}
}
}
-//=======================================================================
-//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 :
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__,
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.;
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);
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)
{
// 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++)
{
char name[100];
Geom2dAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
-
-// modified by APV (compilation error - LINUX)
-// for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
- Standard_Integer i;
+ Standard_Boolean isInfinitySolutions = Ex.Extrema().IsParallel();
const Standard_Integer aNExtr = Ex.NbExtrema();
- for ( i = 1; i <= aNExtr; i++) {
-// modified by APV (compilation error - LINUX)
+ if (aNExtr == 0 || isInfinitySolutions)
+ {
+ // Infinity solutions flag may be set with 0 number of
+ // solutions in analytic extrema Curve/Curve.
+ if (isInfinitySolutions)
+ di << "Infinite number of extremas, distance = " << Ex.LowerDistance() << "\n";
+ else
+ di << "No solutions!\n";
+ }
+
+ for (Standard_Integer i = 1; i <= aNExtr; i++)
+ {
gp_Pnt2d P1,P2;
Ex.Points(i,P1,P2);
di << "dist " << i << ": " << Ex.Distance(i) << " ";
- if (Ex.Distance(i) <= Precision::PConfusion()) {
+ if (Ex.Distance(i) <= Precision::PConfusion())
+ {
Handle(Draw_Marker2D) mark = new Draw_Marker2D( P1, Draw_X, Draw_vert);
dout << mark;
dout.Flush();
DrawTrSurf::Set(temp, P1);
di << name << "\n";
}
- else {
+ 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));
Sprintf(name,"%s%d","ext_",i);
di << name << "\n";
}
}
- if (i==1)
- di << "No solutions!\n";
return 0;
}
mkcurve c2 s2
set bug_info [extrema c1 c2]
-set bug_info [string range $bug_info [expr {[string first "\n" $bug_info] + 1}] [expr {[string last "\n" $bug_info] - 1}]]
-if {$bug_info != "No solutions!"} {
+set bug_info [string range $bug_info [expr {[string first "Infinite" $bug_info]}] [expr {[string first "distance" $bug_info] - 3}]]
+if {$bug_info != "Infinite number of extremas"} {
puts "ERROR: OCC26075 is reproduced. Flag IsParallel is not returned."
}