//purpose :
//=======================================================================
static Standard_Integer intersection (Draw_Interpretor& di, Standard_Integer n, const char** a)
-{
- if (n < 4) {
+ {
+ if (n < 4)
return 1;
- }
+
//
Handle(Geom_Curve) GC1;
Handle(Geom_Surface) GS1 = DrawTrSurf::GetSurface(a[2]);
- if (GS1.IsNull()) {
+ if (GS1.IsNull())
+ {
GC1 = DrawTrSurf::GetCurve(a[2]);
if (GC1.IsNull())
return 1;
- }
+ }
+
//
Handle(Geom_Surface) GS2 = DrawTrSurf::GetSurface(a[3]);
- if (GS2.IsNull()) {
+ if (GS2.IsNull())
return 1;
- }
+
//
Standard_Real tol = Precision::Confusion();
- if (n == 5 || n == 9 || n == 13 || n == 17) tol = Draw::Atof(a[n-1]);
+ if (n == 5 || n == 9 || n == 13 || n == 17)
+ tol = Draw::Atof(a[n-1]);
+
//
Handle(Geom_Curve) Result;
gp_Pnt Point;
+
//
- if (GC1.IsNull()) {
+ if (GC1.IsNull())
+ {
GeomInt_IntSS Inters;
//
// Surface Surface
- if (n <= 5) {
+ if (n <= 5)
+ {
// General case
Inters.Perform(GS1,GS2,tol,Standard_True);
- }
- else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17) {
+ }
+ else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
+ {
Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
Standard_Real UVsta[4];
Handle(GeomAdaptor_HSurface) AS1,AS2;
+
//
- if (n <= 9) { // user starting point
+ if (n <= 9) // user starting point
+ {
useBnd = Standard_False;
- ista1 = 4; ista2 = 7;
- }
- else if (n <= 13) { // user bounding
+ ista1 = 4;
+ ista2 = 7;
+ }
+ else if (n <= 13) // user bounding
+ {
useStart = Standard_False;
ibnd1 = 4; ibnd2 = 11;
- }
- else { // both user starting point and bounding
+ }
+ else // both user starting point and bounding
+ {
ista1 = 4; ista2 = 7;
ibnd1 = 8; ibnd2 = 15;
- }
+ }
+
if (useStart)
+ {
for (Standard_Integer i=ista1; i <= ista2; i++)
+ {
UVsta[i-ista1] = Draw::Atof(a[i]);
- if (useBnd) {
+ }
+ }
+
+ if (useBnd)
+ {
Standard_Real UVbnd[8];
for (Standard_Integer i=ibnd1; i <= ibnd2; i++)
UVbnd[i-ibnd1] = Draw::Atof(a[i]);
+
AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
- }
+ }
+
//
- if (useStart && !useBnd) {
+ if (useStart && !useBnd)
+ {
Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
- }
- else if (!useStart && useBnd) {
+ }
+ else if (!useStart && useBnd)
+ {
Inters.Perform(AS1,AS2,tol);
- }
- else {
+ }
+ else
+ {
Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
- }
- }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17) {
- else {
+ }
+ }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
+ else
+ {
di<<"incorrect number of arguments"<<"\n";
return 1;
- }
+ }
+
//
- if (!Inters.IsDone()) {
+ if (!Inters.IsDone())
+ {
+ di<<"No intersections found!"<<"\n";
+
return 1;
- }
+ }
+
//
char buf[1024];
Standard_Integer i, aNbLines, aNbPoints;
- //
+
+ //
aNbLines = Inters.NbLines();
- if (aNbLines >= 2) {
- for (i=1; i<=aNbLines; ++i) {
- Sprintf(buf, "%s_%d",a[1],i);
- Result = Inters.Line(i);
- const char* temp = buf;
- DrawTrSurf::Set(temp,Result);
+ if (aNbLines >= 2)
+ {
+ for (i=1; i<=aNbLines; ++i)
+ {
+ Sprintf(buf, "%s_%d",a[1],i);
+ di << buf << " ";
+ Result = Inters.Line(i);
+ const char* temp = buf;
+ DrawTrSurf::Set(temp,Result);
+ }
}
- }
- else if (aNbLines == 1) {
+ else if (aNbLines == 1)
+ {
Result = Inters.Line(1);
+ Sprintf(buf,"%s",a[1]);
+ di << buf << " ";
DrawTrSurf::Set(a[1],Result);
}
+
//
aNbPoints=Inters.NbPoints();
- for (i=1; i<=aNbPoints; ++i) {
+ for (i=1; i<=aNbPoints; ++i)
+ {
Point=Inters.Point(i);
Sprintf(buf,"%s_p_%d",a[1],i);
- const char* temp =buf;
+ di << buf << " ";
+ const char* temp = buf;
DrawTrSurf::Set(temp, Point);
- }
- }// if (GC1.IsNull()) {
- //
- else {
+ }
+ }// if (GC1.IsNull())
+ else
+ {
// Curve Surface
GeomAPI_IntCS Inters(GC1,GS2);
- //
- if (!Inters.IsDone()) return 1;
+ //
+ if (!Inters.IsDone())
+ {
+ di<<"No intersections found!"<<"\n";
+ return 1;
+ }
+
Standard_Integer nblines = Inters.NbSegments();
Standard_Integer nbpoints = Inters.NbPoints();
- if ( (nblines+nbpoints) >= 2) {
- char newname[1024];
+
+ char newname[1024];
+
+ if ( (nblines+nbpoints) >= 2)
+ {
Standard_Integer i;
Standard_Integer Compt = 1;
- for (i = 1; i <= nblines; i++, Compt++) {
- Sprintf(newname,"%s_%d",a[1],Compt);
- Result = Inters.Segment(i);
- const char* temp = newname; // pour portage WNT
- DrawTrSurf::Set(temp,Result);
- }
- for (i = 1; i <= nbpoints; i++, Compt++) {
- Sprintf(newname,"%s_%d",a[1],i);
- Point = Inters.Point(i);
- const char* temp = newname; // pour portage WNT
- DrawTrSurf::Set(temp,Point);
+
+ if(nblines >= 1)
+ cout << " Lines: " << endl;
+
+ for (i = 1; i <= nblines; i++, Compt++)
+ {
+ Sprintf(newname,"%s_%d",a[1],Compt);
+ di << newname << " ";
+ Result = Inters.Segment(i);
+ const char* temp = newname; // pour portage WNT
+ DrawTrSurf::Set(temp,Result);
+ }
+
+ if(nbpoints >= 1)
+ cout << " Points: " << endl;
+
+ const Standard_Integer imax = nblines+nbpoints;
+
+ for (/*i = 1*/; i <= imax; i++, Compt++)
+ {
+ Sprintf(newname,"%s_%d",a[1],i);
+ di << newname << " ";
+ Point = Inters.Point(i);
+ const char* temp = newname; // pour portage WNT
+ DrawTrSurf::Set(temp,Point);
+ }
}
- }
- else if (nblines == 1) {
+ else if (nblines == 1)
+ {
Result = Inters.Segment(1);
+ Sprintf(newname,"%s",a[1]);
+ di << newname << " ";
DrawTrSurf::Set(a[1],Result);
- }
- else if (nbpoints == 1) {
+ }
+ else if (nbpoints == 1)
+ {
Point = Inters.Point(1);
+ Sprintf(newname,"%s",a[1]);
+ di << newname << " ";
DrawTrSurf::Set(a[1],Point);
+ }
}
- }
dout.Flush();
return 0;
-}
+ }
//=======================================================================
//function : CurveCommands