1 // Created on: 1993-08-12
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // 09/06/97 : JPI : suppression des commandes redondantes suite a la creation de GeomliteTest
19 #include <GeometryTest.hxx>
20 #include <Draw_Appli.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <DrawTrSurf_Curve.hxx>
23 #include <DrawTrSurf_Curve2d.hxx>
24 #include <DrawTrSurf_BezierCurve.hxx>
25 #include <DrawTrSurf_BSplineCurve.hxx>
26 #include <DrawTrSurf_BezierCurve2d.hxx>
27 #include <DrawTrSurf_BSplineCurve2d.hxx>
28 #include <Draw_Marker3D.hxx>
29 #include <Draw_Marker2D.hxx>
31 #include <Draw_Interpretor.hxx>
32 #include <Draw_Color.hxx>
33 #include <Draw_Display.hxx>
35 #include <GeomAPI.hxx>
36 #include <GeomAPI_IntCS.hxx>
37 #include <GeomAPI_IntSS.hxx>
39 //#include <GeomLProp.hxx>
40 #include <GeomProjLib.hxx>
41 #include <BSplCLib.hxx>
45 #include <gp_Parab2d.hxx>
46 #include <gp_Elips2d.hxx>
47 #include <gp_Hypr2d.hxx>
49 #include <Geom_Line.hxx>
50 #include <Geom_Circle.hxx>
51 #include <Geom_Ellipse.hxx>
52 #include <Geom_Parabola.hxx>
53 #include <Geom_Hyperbola.hxx>
54 #include <Geom2d_Line.hxx>
55 #include <Geom2d_Circle.hxx>
56 #include <Geom2d_Ellipse.hxx>
57 #include <Geom2d_Parabola.hxx>
58 #include <Geom2d_Hyperbola.hxx>
59 #include <Geom2d_BSplineCurve.hxx>
60 #include <Geom2d_Curve.hxx>
62 #include <GccAna_Lin2dBisec.hxx>
63 #include <GccAna_Circ2dBisec.hxx>
64 #include <GccAna_CircLin2dBisec.hxx>
65 #include <GccAna_CircPnt2dBisec.hxx>
66 #include <GccAna_LinPnt2dBisec.hxx>
67 #include <GccAna_Pnt2dBisec.hxx>
68 #include <GccInt_Bisec.hxx>
69 #include <GccInt_IType.hxx>
71 #include <Geom_Plane.hxx>
72 #include <Geom_Curve.hxx>
73 #include <Geom2d_Curve.hxx>
74 #include <Geom2d_TrimmedCurve.hxx>
75 #include <Geom_TrimmedCurve.hxx>
77 #include <Law_BSpline.hxx>
79 #include <TColgp_Array1OfPnt.hxx>
80 #include <TColgp_Array1OfPnt2d.hxx>
81 #include <TColStd_Array1OfReal.hxx>
82 #include <TColStd_Array1OfInteger.hxx>
84 #include <Adaptor3d_HCurve.hxx>
85 #include <Adaptor3d_HSurface.hxx>
86 #include <Adaptor3d_CurveOnSurface.hxx>
88 #include <GeomAdaptor_HCurve.hxx>
89 #include <GeomAdaptor_HSurface.hxx>
90 #include <GeomAdaptor.hxx>
91 #include <Geom2dAdaptor_HCurve.hxx>
93 #include <GeomAbs_SurfaceType.hxx>
94 #include <GeomAbs_CurveType.hxx>
96 #include <ProjLib_CompProjectedCurve.hxx>
97 #include <ProjLib_HCompProjectedCurve.hxx>
98 #include <Approx_CurveOnSurface.hxx>
99 #include <Precision.hxx>
100 #include <Geom2dAdaptor.hxx>
103 #include <Precision.hxx>
105 #include <Geom_Surface.hxx>
106 #include <Adaptor2d_HCurve2d.hxx>
108 #include <BSplCLib.hxx>
109 #include <Geom_BSplineSurface.hxx>
110 #include <Geom_BSplineCurve.hxx>
111 #include <GCPnts_QuasiUniformDeflection.hxx>
112 #include <GCPnts_UniformDeflection.hxx>
113 #include <GCPnts_TangentialDeflection.hxx>
114 #include <GCPnts_DistFunction.hxx>
115 #include <GeomAPI_ExtremaCurveCurve.hxx>
116 #include <gce_MakeLin.hxx>
117 #include <TColStd_Array1OfBoolean.hxx>
118 #include <GeomAdaptor_HSurface.hxx>
119 #include <Adaptor3d_TopolTool.hxx>
120 #include <TColgp_Array2OfPnt.hxx>
121 #include <Geom_BSplineSurface.hxx>
122 #include <DrawTrSurf_BSplineSurface.hxx>
123 #include <TColStd_HArray1OfReal.hxx>
126 #include <BRepBuilderAPI_MakeEdge.hxx>
127 #include <AIS_Shape.hxx>
128 #include <TopoDS_Edge.hxx>
129 #include <GeomLProp_CLProps.hxx>
130 #include <GCPnts_AbscissaPoint.hxx>
131 #include <GCPnts_UniformAbscissa.hxx>
135 Standard_IMPORT Draw_Viewer dout;
138 //=======================================================================
139 //function : polecurve2d
141 //=======================================================================
143 static Standard_Integer polelaw (Draw_Interpretor& , Standard_Integer n, const char** a)
152 Standard_Boolean periodic = Standard_False ;
153 Standard_Integer deg = Draw::Atoi(a[2]);
154 Standard_Integer nbk = Draw::Atoi(a[3]);
156 TColStd_Array1OfReal knots(1, nbk);
157 TColStd_Array1OfInteger mults(1, nbk);
159 Standard_Integer Sigma = 0;
160 for (i = 1; i<=nbk; i++) {
161 knots( i) = Draw::Atof(a[k]);
163 mults( i) = Draw::Atoi(a[k]);
170 TColStd_Array1OfReal flat_knots(1, Sigma) ;
172 for (i = 1 ; i <= nbk ; i++) {
173 for(qq = 1 ; qq <= mults(i) ; qq++) {
174 flat_knots(jj) = knots(i) ;
179 TColgp_Array1OfPnt2d poles (1, np);
180 TColStd_Array1OfReal schoenberg_points(1,np) ;
181 BSplCLib::BuildSchoenbergPoints(deg,
184 for (i = 1; i <= np; i++) {
185 poles(i).SetCoord(schoenberg_points(i),Draw::Atof(a[k]));
189 Handle(Geom2d_BSplineCurve) result =
190 new Geom2d_BSplineCurve(poles, knots, mults, deg, periodic);
191 DrawTrSurf::Set(a[1],result);
196 //=======================================================================
199 //=======================================================================
201 static Standard_Integer to2d (Draw_Interpretor& , Standard_Integer n, const char** a)
206 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
210 Handle(Geom_Surface) S;
212 S = DrawTrSurf::GetSurface(a[3]);
213 if (S.IsNull()) return 1;
216 S = new Geom_Plane(gp::XOY());
218 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
219 if (P.IsNull()) return 1;
220 Handle(Geom2d_Curve) r = GeomAPI::To2d(C,P->Pln());
221 DrawTrSurf::Set(a[1],r);
225 //=======================================================================
228 //=======================================================================
230 static Standard_Integer to3d (Draw_Interpretor& , Standard_Integer n, const char** a)
234 Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
235 if (C.IsNull()) return 1;
237 Handle(Geom_Surface) S;
239 S = DrawTrSurf::GetSurface(a[3]);
240 if (S.IsNull()) return 1;
243 S = new Geom_Plane(gp::XOY());
245 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
246 if (P.IsNull()) return 1;
247 Handle(Geom_Curve) r = GeomAPI::To3d(C,P->Pln());
249 DrawTrSurf::Set(a[1],r);
253 //=======================================================================
254 //function : gproject
256 //=======================================================================
259 static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
263 char* temp = newname;
265 char* temp1 = newname1;
267 Standard_Integer ONE = 1;
272 Sprintf(name,"%s",a[1]);
276 di << "gproject wait 2 or 3 arguments\n";
280 Handle(Geom_Curve) Cur = DrawTrSurf::GetCurve(a[ONE]);
281 Handle(Geom_Surface) Sur = DrawTrSurf::GetSurface(a[ONE+1]);
282 if (Cur.IsNull() || Sur.IsNull()) return 1;
284 Handle(GeomAdaptor_HCurve) hcur = new GeomAdaptor_HCurve(Cur);
285 Handle(GeomAdaptor_HSurface) hsur = new GeomAdaptor_HSurface(Sur);
288 Standard_Real myTol3d = 1.e-6;
289 GeomAbs_Shape myContinuity = GeomAbs_C2;
290 Standard_Integer myMaxDegree = 14, myMaxSeg = 16;
293 ProjLib_CompProjectedCurve Projector(hsur, hcur, myTol3d/10, myTol3d/10);
294 Handle(ProjLib_HCompProjectedCurve) HProjector = new ProjLib_HCompProjectedCurve();
295 HProjector->Set(Projector);
298 Standard_Real Udeb, Ufin, UIso, VIso;
299 Standard_Integer Only2d, Only3d;
300 gp_Pnt2d P2d, Pdeb, Pfin;
302 Handle(Adaptor2d_HCurve2d) HPCur;
303 Handle(Geom2d_Curve) PCur2d; // Only for isoparametric projection
305 for(k = 1; k <= Projector.NbCurves(); k++){
306 Sprintf(newname,"%s_%d",name,k);
307 Sprintf(newname1,"%s2d_%d",name,k);
308 if(Projector.IsSinglePnt(k, P2d)){
309 // cout<<"Part "<<k<<" of the projection is punctual"<<endl;
310 Projector.GetSurface()->D0(P2d.X(), P2d.Y(), P);
311 DrawTrSurf::Set(temp, P);
312 DrawTrSurf::Set(temp1, P2d);
313 di<<temp<<" is 3d projected curve\n";
314 di<<temp1<<" is pcurve\n";
317 Only2d = Only3d = Standard_False;
318 Projector.Bounds(k, Udeb, Ufin);
319 gp_Dir2d Dir; // Only for isoparametric projection
321 if (Projector.IsUIso(k, UIso)) {
322 // cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<endl;
323 Projector.D0(Udeb, Pdeb);
324 Projector.D0(Ufin, Pfin);
328 Dir = gp_Dir2d(0, -1);
332 else Dir = gp_Dir2d(0, 1);
333 PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(UIso, 0), Dir), Udeb, Ufin);
334 HPCur = new Geom2dAdaptor_HCurve(PCur2d);
335 Only3d = Standard_True;
337 else if(Projector.IsVIso(k, VIso)) {
338 // cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<endl;
339 Projector.D0(Udeb, Pdeb);
340 Projector.D0(Ufin, Pfin);
344 Dir = gp_Dir2d(-1, 0);
348 else Dir = gp_Dir2d(1, 0);
349 PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(0, VIso), Dir), Udeb, Ufin);
350 HPCur = new Geom2dAdaptor_HCurve(PCur2d);
351 Only3d = Standard_True;
353 else HPCur = HProjector;
355 if(Projector.MaxDistance(k) <= myTol3d)
356 Only2d = Standard_True;
358 if(Only2d && Only3d) {
359 Handle(Geom_Curve) OutCur = new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()), Ufin, Udeb);
360 DrawTrSurf::Set(temp, OutCur);
361 DrawTrSurf::Set(temp1, PCur2d);
362 di<<temp<<" is 3d projected curve\n";
363 di<<temp1<<" is pcurve\n";
367 Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
368 myContinuity, myMaxDegree, myMaxSeg,
371 PCur2d = appr.Curve2d();
372 di << " Error in 2d is " << appr.MaxError2dU()
373 << "; " << appr.MaxError2dV() << "\n";
376 Handle(Geom_Curve) OutCur =
377 new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()),
379 DrawTrSurf::Set(temp, OutCur);
382 di << " Error in 3d is " << appr.MaxError3d() << "\n";
383 DrawTrSurf::Set(temp, appr.Curve3d());
385 DrawTrSurf::Set(temp1, PCur2d);
386 di<<temp<<" is 3d projected curve\n";
387 di<<temp1<<" is pcurve\n";
393 //=======================================================================
396 //=======================================================================
398 static Standard_Integer project (Draw_Interpretor& di,
399 Standard_Integer n, const char** a)
403 di << "project result2d c3d surf [-e p] [-v n] [-t tol]\n";
404 di << " -e p : extent the surface of <p>%\n";
405 di << " -v n : verify the projection at <n> points.\n";
406 di << " -t tol : set the tolerance for approximation\n";
411 Handle(Geom_Surface) GS = DrawTrSurf::GetSurface(a[3]);
412 if (GS.IsNull()) return 1;
414 Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[2]);
415 if (GC.IsNull()) return 1;
417 Standard_Real tolerance = Precision::Confusion() ;
419 Standard_Real U1,U2,V1,V2;
420 GS->Bounds(U1,U2,V1,V2);
422 Standard_Boolean Verif = Standard_False;
423 Standard_Integer NbPoints=0;
425 Standard_Integer index = 4;
426 while ( index+1 < n) {
427 if ( a[index][0] != '-') return 1;
429 if ( a[index][1] == 'e') {
430 Standard_Real p = Draw::Atof(a[index+1]);
431 Standard_Real dU = p * (U2 - U1) / 100.;
432 Standard_Real dV = p * (V2 - V1) / 100.;
433 U1 -= dU; U2 += dU; V1 -= dV; V2 += dV;
435 else if ( a[index][1] == 'v') {
436 Verif = Standard_True;
437 NbPoints = Draw::Atoi(a[index+1]);
439 else if ( a[index][1] == 't') {
440 tolerance = Draw::Atof(a[index+1]);
445 Handle(Geom2d_Curve) G2d =
446 GeomProjLib::Curve2d(GC, GS, U1, U2, V1, V2, tolerance);
448 if ( G2d.IsNull() ) {
449 di << "\nProjection Failed\n";
453 DrawTrSurf::Set(a[1],G2d);
455 if ( Verif) { // verify the projection on n points
456 if ( NbPoints <= 0) {
457 di << " n must be positive\n";
464 Standard_Real Dist,DistMax = -1.;
465 U1 = GC->FirstParameter();
466 U2 = GC->LastParameter();
467 dU = ( U2 - U1) / (NbPoints + 1);
468 for ( Standard_Integer i = 0 ; i <= NbPoints +1; i++) {
472 P2 = GS->Value(P2d.X(), P2d.Y());
473 Dist = P1.Distance(P2);
474 di << " Parameter = " << U << "\tDistance = " << Dist << "\n";
475 if ( Dist > DistMax) DistMax = Dist;
477 di << " **** Distance Maximale : " << DistMax << "\n";
483 //=======================================================================
484 //function : projonplane
486 //=======================================================================
488 Standard_Integer projonplane(Draw_Interpretor& di,
489 Standard_Integer n, const char** a)
491 if ( n < 4 ) return 1;
493 Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[3]);
494 if ( S.IsNull()) return 1;
496 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(S);
498 di << " The surface must be a plane\n";
502 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
503 if ( C.IsNull()) return 1;
505 Standard_Boolean Param = Standard_True;
506 if ((n == 5 && Draw::Atoi(a[4]) == 0) ||
507 (n == 8 && Draw::Atoi(a[7]) == 0)) Param = Standard_False;
512 D = gp_Dir(Draw::Atof(a[4]),Draw::Atof(a[5]),Draw::Atof(a[6]));
515 D = Pl->Pln().Position().Direction();
518 Handle(Geom_Curve) Res =
519 GeomProjLib::ProjectOnPlane(C,Pl,D,Param);
521 DrawTrSurf::Set(a[1],Res);
527 //=======================================================================
530 //=======================================================================
532 static void solution(const Handle(GccInt_Bisec)& Bis,
534 const Standard_Integer i)
538 Sprintf(solname,"%s",name);
540 Sprintf(solname,"%s_%d",name,i);
541 const char* temp = solname; // pour portage WNT
543 switch ( Bis->ArcType()) {
545 DrawTrSurf::Set(temp, new Geom2d_Line(Bis->Line()));
548 DrawTrSurf::Set(temp, new Geom2d_Circle(Bis->Circle()));
551 DrawTrSurf::Set(temp, new Geom2d_Ellipse(Bis->Ellipse()));
554 DrawTrSurf::Set(temp, new Geom2d_Parabola(Bis->Parabola()));
557 DrawTrSurf::Set(temp, new Geom2d_Hyperbola(Bis->Hyperbola()));
560 DrawTrSurf::Set(temp, Bis->Point());
565 static Standard_Integer bisec (Draw_Interpretor& di,
566 Standard_Integer n, const char** a)
570 Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[2]);
571 Handle(Geom2d_Curve) C2 = DrawTrSurf::GetCurve2d(a[3]);
573 Standard_Boolean ip1 = DrawTrSurf::GetPoint2d(a[2],P1);
574 Standard_Boolean ip2 = DrawTrSurf::GetPoint2d(a[3],P2);
575 Standard_Integer i, Compt = 0;
576 Standard_Integer NbSol = 0;
579 Handle(Standard_Type) Type1 = C1->DynamicType();
581 Handle(Standard_Type) Type2 = C2->DynamicType();
582 if ( Type1 == STANDARD_TYPE(Geom2d_Line) &&
583 Type2 == STANDARD_TYPE(Geom2d_Line) ) {
584 GccAna_Lin2dBisec Bis(Handle(Geom2d_Line)::DownCast(C1)->Lin2d(),
585 Handle(Geom2d_Line)::DownCast(C2)->Lin2d());
588 NbSol = Bis.NbSolutions();
589 for ( i = 1; i <= NbSol; i++) {
590 Sprintf(solname,"%s_%d",a[1],i);
591 const char* temp = solname; // pour portage WNT
592 DrawTrSurf::Set(temp,new Geom2d_Line(Bis.ThisSolution(i)));
596 di << " Bisec has failed !!\n";
600 else if ( Type1 == STANDARD_TYPE(Geom2d_Line) &&
601 Type2 == STANDARD_TYPE(Geom2d_Circle) ) {
602 GccAna_CircLin2dBisec
603 Bis(Handle(Geom2d_Circle)::DownCast(C2)->Circ2d(),
604 Handle(Geom2d_Line)::DownCast(C1)->Lin2d());
606 NbSol= Bis.NbSolutions();
607 if ( NbSol >= 2) Compt = 1;
608 for ( i = 1; i <= NbSol; i++) {
609 solution(Bis.ThisSolution(i),a[1],Compt);
614 di << " Bisec has failed !!\n";
618 else if ( Type2 == STANDARD_TYPE(Geom2d_Line) &&
619 Type1 == STANDARD_TYPE(Geom2d_Circle) ) {
620 GccAna_CircLin2dBisec
621 Bis(Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),
622 Handle(Geom2d_Line)::DownCast(C2)->Lin2d());
624 // char solname[200];
625 NbSol = Bis.NbSolutions();
626 if ( NbSol >= 2) Compt = 1;
627 for ( i = 1; i <= NbSol; i++) {
628 solution(Bis.ThisSolution(i),a[1],Compt);
633 di << " Bisec has failed !!\n";
637 else if ( Type2 == STANDARD_TYPE(Geom2d_Circle) &&
638 Type1 == STANDARD_TYPE(Geom2d_Circle) ) {
640 Bis(Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),
641 Handle(Geom2d_Circle)::DownCast(C2)->Circ2d());
643 // char solname[200];
644 NbSol = Bis.NbSolutions();
645 if ( NbSol >= 2) Compt = 1;
646 for ( i = 1; i <= NbSol; i++) {
647 solution(Bis.ThisSolution(i),a[1],Compt);
652 di << " Bisec has failed !!\n";
657 di << " args must be line/circle/point line/circle/point\n";
662 if ( Type1 == STANDARD_TYPE(Geom2d_Circle)) {
663 GccAna_CircPnt2dBisec Bis
664 (Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),P2);
666 NbSol = Bis.NbSolutions();
667 if ( NbSol >= 2) Compt = 1;
668 for ( i = 1; i <= NbSol; i++) {
669 solution(Bis.ThisSolution(i),a[1],Compt);
674 di << " Bisec has failed !!\n";
678 else if ( Type1 == STANDARD_TYPE(Geom2d_Line)) {
679 GccAna_LinPnt2dBisec Bis
680 (Handle(Geom2d_Line)::DownCast(C1)->Lin2d(),P2);
683 solution(Bis.ThisSolution(),a[1],0);
686 di << " Bisec has failed !!\n";
692 di << " the second arg must be line/circle/point \n";
697 Handle(Standard_Type) Type2 = C2->DynamicType();
698 if ( Type2 == STANDARD_TYPE(Geom2d_Circle)) {
699 GccAna_CircPnt2dBisec Bis
700 (Handle(Geom2d_Circle)::DownCast(C2)->Circ2d(),P1);
702 NbSol = Bis.NbSolutions();
703 if ( NbSol >= 2) Compt = 1;
704 for ( i = 1; i <= Bis.NbSolutions(); i++) {
705 solution(Bis.ThisSolution(i),a[1],Compt);
710 di << " Bisec has failed !!\n";
714 else if ( Type2 == STANDARD_TYPE(Geom2d_Line)) {
715 GccAna_LinPnt2dBisec Bis
716 (Handle(Geom2d_Line)::DownCast(C2)->Lin2d(),P1);
719 solution(Bis.ThisSolution(),a[1],0);
722 di << " Bisec has failed !!\n";
728 GccAna_Pnt2dBisec Bis(P1,P2);
729 if ( Bis.HasSolution()) {
731 DrawTrSurf::Set(a[1],new Geom2d_Line(Bis.ThisSolution()));
734 di << " Bisec has failed !!\n";
739 di << " the second arg must be line/circle/point \n";
744 di << " args must be line/circle/point line/circle/point\n";
749 di << "There are " << NbSol << " Solutions.\n";
752 di << "There is " << NbSol << " Solution.\n";
758 //=======================================================================
759 //function : cmovetangent
761 //=======================================================================
763 static Standard_Integer movelaw (Draw_Interpretor& di, Standard_Integer n, const char** a)
774 u = Draw::Atof(a[2]);
775 x = Draw::Atof(a[3]);
780 Handle(Geom2d_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve2d(a[1]);
782 tx = Draw::Atof(a[4]) ;
784 condition = Max(Draw::Atoi(a[5]), -1) ;
785 condition = Min(condition, G2->Degree()-1) ;
787 TColgp_Array1OfPnt2d curve_poles(1,G2->NbPoles()) ;
788 TColStd_Array1OfReal law_poles(1,G2->NbPoles()) ;
789 TColStd_Array1OfReal law_knots(1,G2->NbKnots()) ;
790 TColStd_Array1OfInteger law_mults(1,G2->NbKnots()) ;
792 G2->Knots(law_knots) ;
793 G2->Multiplicities(law_mults) ;
794 G2->Poles(curve_poles) ;
795 for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
796 law_poles(ii) = curve_poles(ii).Coord(2) ;
799 Law_BSpline a_law(law_poles,
805 a_law.MovePointAndTangent(u,
813 for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
814 curve_poles(ii).SetCoord(2,a_law.Pole(ii)) ;
815 G2->SetPole(ii,curve_poles(ii)) ;
819 if (! error_status) {
823 di << "Not enought degree of freedom increase degree please\n";
832 //Static method computing deviation of curve and polyline
833 #include <math_PSO.hxx>
834 #include <math_PSOParticlesPool.hxx>
835 #include <math_MultipleVarFunction.hxx>
836 #include <math_BrentMinimum.hxx>
838 static Standard_Real CompLocalDev(const Handle(Geom_Curve)& theCurve,
839 const Standard_Real u1, const Standard_Real u2);
841 static void ComputeDeviation(const Handle(Geom_Curve)& theCurve,
842 const Handle(Geom_BSplineCurve)& thePnts,
843 Standard_Real& theDmax,
844 Standard_Real& theUfMax,
845 Standard_Real& theUlMax,
846 Standard_Integer& theImax)
854 Standard_Integer nbp = thePnts->NbKnots();
855 TColStd_Array1OfReal aKnots(1, nbp);
856 thePnts->Knots(aKnots);
859 for(i = 1; i < nbp; ++i)
861 Standard_Real u1 = aKnots(i), u2 = aKnots(i+1);
862 Standard_Real d = CompLocalDev(theCurve, u1, u2);
873 Standard_Real CompLocalDev(const Handle(Geom_Curve)& theCurve,
874 const Standard_Real u1, const Standard_Real u2)
876 math_Vector aLowBorder(1,1);
877 math_Vector aUppBorder(1,1);
878 math_Vector aSteps(1,1);
879 GeomAdaptor_Curve TCurve(theCurve);
883 aSteps(1) =(aUppBorder(1) - aLowBorder(1)) * 0.01; // Run PSO on even distribution with 100 points.
885 GCPnts_DistFunction aFunc1(TCurve, u1, u2);
887 Standard_Real aValue;
889 GCPnts_DistFunctionMV aFunc(aFunc1);
891 math_PSO aFinder(&aFunc, aLowBorder, aUppBorder, aSteps); // Choose 32 best points from 100 above.
892 aFinder.Perform(aSteps, aValue, aT);
893 Standard_Real d = 0.;
895 Standard_Real d1, d2;
896 Standard_Real x1 = Max(u1, aT(1) - aSteps(1));
897 Standard_Boolean Ok = aFunc1.Value(x1, d1);
900 return Sqrt(-aValue);
902 Standard_Real x2 = Min(u2, aT(1) + aSteps(1));
903 Ok = aFunc1.Value(x2, d2);
906 return Sqrt(-aValue);
908 if(!(d1 > aValue && d2 > aValue))
910 Standard_Real dmin = Min(d1, Min(aValue, d2));
914 math_BrentMinimum anOptLoc(Precision::PConfusion());
915 anOptLoc.Perform(aFunc1, x1, aT(1), x2);
917 if (anOptLoc.IsDone())
919 d = -anOptLoc.Minimum();
928 //=======================================================================
929 //function : crvpoints
931 //=======================================================================
933 static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
935 Standard_Integer i, nbp;
938 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
939 defl = Draw::Atof(a[3]);
941 GeomAdaptor_Curve GAC(C);
942 GCPnts_QuasiUniformDeflection PntGen(GAC, defl);
944 if(!PntGen.IsDone()) {
945 di << "Points generation failed\n";
949 nbp = PntGen.NbPoints();
950 di << "Nb points : " << nbp << "\n";
952 TColgp_Array1OfPnt aPoles(1, nbp);
953 TColStd_Array1OfReal aKnots(1, nbp);
954 TColStd_Array1OfInteger aMults(1, nbp);
956 for(i = 1; i <= nbp; ++i) {
957 aPoles(i) = PntGen.Value(i);
958 aKnots(i) = PntGen.Parameter(i);
965 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
966 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
968 aDrCrv->ClearPoles();
969 Draw_Color aKnColor(Draw_or);
970 aDrCrv->SetKnotsColor(aKnColor);
971 aDrCrv->SetKnotsShape(Draw_Plus);
973 Draw::Set(a[1], aDrCrv);
975 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
976 Standard_Integer imax = 0;
979 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
980 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
985 //=======================================================================
986 //function : crvtpoints
988 //=======================================================================
990 static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, const char** a)
992 Standard_Integer i, nbp;
993 Standard_Real defl, angle = Precision::Angular();
995 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
996 defl = Draw::Atof(a[3]);
999 angle = Draw::Atof(a[4]);
1001 GeomAdaptor_Curve GAC(C);
1002 GCPnts_TangentialDeflection PntGen(GAC, angle, defl, 2);
1004 nbp = PntGen.NbPoints();
1005 di << "Nb points : " << nbp << "\n";
1007 TColgp_Array1OfPnt aPoles(1, nbp);
1008 TColStd_Array1OfReal aKnots(1, nbp);
1009 TColStd_Array1OfInteger aMults(1, nbp);
1011 for(i = 1; i <= nbp; ++i) {
1012 aPoles(i) = PntGen.Value(i);
1013 aKnots(i) = PntGen.Parameter(i);
1020 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
1021 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
1023 aDrCrv->ClearPoles();
1024 Draw_Color aKnColor(Draw_or);
1025 aDrCrv->SetKnotsColor(aKnColor);
1026 aDrCrv->SetKnotsShape(Draw_Plus);
1028 Draw::Set(a[1], aDrCrv);
1030 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
1031 Standard_Integer imax = 0;
1034 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
1036 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
1040 //=======================================================================
1041 //function : uniformAbscissa
1042 //purpose : epa test (TATA-06-002 (Problem with GCPnts_UniformAbscissa class)
1043 //=======================================================================
1044 static Standard_Integer uniformAbscissa (Draw_Interpretor& di, Standard_Integer n, const char** a)
1049 /*Handle(Geom_BSplineCurve) ellip;
1050 ellip = DrawTrSurf::GetBSplineCurve(a[1]);
1053 di << " BSpline is NULL \n";
1057 Handle(Geom_Curve) ellip;
1058 ellip = DrawTrSurf::GetCurve(a[1]);
1061 di << " Curve is NULL \n";
1065 Standard_Integer nocp;
1066 nocp = Draw::Atoi(a[2]);
1071 //test nbPoints for Geom_Ellipse
1075 GeomLProp_CLProps Prop(ellip,2,Precision::Intersection());
1076 Prop.SetCurve(ellip);
1078 GeomAdaptor_Curve GAC(ellip);
1079 di<<"Type Of curve: "<<GAC.GetType()<<"\n";
1080 Standard_Real Tol = Precision::Confusion();
1083 L = GCPnts_AbscissaPoint::Length(GAC, GAC.FirstParameter(), GAC.LastParameter(), Tol);
1084 di<<"Ellipse length = "<<L<<"\n";
1085 Standard_Real Abscissa = L/(nocp-1);
1086 di << " CUR : Abscissa " << Abscissa << "\n";
1088 GCPnts_UniformAbscissa myAlgo(GAC, Abscissa, ellip->FirstParameter(), ellip->LastParameter());
1089 if ( myAlgo.IsDone() )
1091 di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n";
1092 for(Standard_Integer i = 1; i<= myAlgo.NbPoints(); i++ )
1093 di << i <<" points = " << myAlgo.Parameter( i ) << "\n";
1097 catch (Standard_Failure )
1099 di << " Standard Failure \n";
1104 //=======================================================================
1105 //function : EllipsUniformAbscissa
1106 //purpose : epa test (TATA-06-002 (Problem with GCPnts_UniformAbscissa class)
1107 //=======================================================================
1108 static Standard_Integer EllipsUniformAbscissa (Draw_Interpretor& di, Standard_Integer n, const char** a)
1114 R1 = Draw::Atof(a[1]);
1116 R2 = Draw::Atof(a[2]);
1118 Standard_Integer nocp;
1119 nocp = Draw::Atoi(a[3]);
1123 //test nbPoints for Geom_Ellipse
1124 Handle(Geom_Ellipse) ellip;
1130 location = gp_Pnt( 0.0, 0.0, 0.0);
1131 gp_Dir main_direction(0.0, 0.0, 1.0);
1133 gp_Dir x_direction(1.0, 0.0, 0.0);
1134 gp_Ax2 mainaxis( location, main_direction);
1136 mainaxis.SetXDirection(x_direction);
1137 ellip = new Geom_Ellipse(mainaxis,R1, R2);
1139 BRepBuilderAPI_MakeEdge curve_edge(ellip);
1140 TopoDS_Edge edge_curve = curve_edge.Edge();
1142 DBRep::Set("Ellipse",edge_curve);
1145 catch(Standard_Failure)
1147 di << " Standard Failure \n";
1152 GeomLProp_CLProps Prop(ellip,2,Precision::Intersection());
1153 Prop.SetCurve(ellip);
1155 GeomAdaptor_Curve GAC(ellip);
1156 di<<"Type Of curve: "<<GAC.GetType()<<"\n";
1157 Standard_Real Tol = Precision::Confusion();
1160 L = GCPnts_AbscissaPoint::Length(GAC, GAC.FirstParameter(), GAC.LastParameter(), Tol);
1161 di<<"Ellipse length = "<<L<<"\n";
1162 Standard_Real Abscissa = L/(nocp-1);
1163 di << " CUR : Abscissa " << Abscissa << "\n";
1165 GCPnts_UniformAbscissa myAlgo(GAC, Abscissa, ellip->FirstParameter(), ellip->LastParameter());
1166 if ( myAlgo.IsDone() )
1168 di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n";
1169 for(Standard_Integer i = 1; i<= myAlgo.NbPoints(); i++ )
1170 di << i <<" points = " << myAlgo.Parameter( i ) << "\n";
1174 catch (Standard_Failure )
1176 di << " Standard Failure \n";
1181 //=======================================================================
1182 //function : discrCurve
1184 //=======================================================================
1185 static Standard_Integer discrCurve(Draw_Interpretor& di, Standard_Integer theArgNb, const char** theArgVec)
1189 di << "Invalid number of parameters.\n";
1193 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(theArgVec[2]);
1194 if (aCurve.IsNull())
1196 di << "Curve is NULL.\n";
1200 Standard_Integer aSrcNbPnts = 0;
1201 Standard_Boolean isUniform = Standard_False;
1202 for (Standard_Integer anArgIter = 3; anArgIter < theArgNb; ++anArgIter)
1204 TCollection_AsciiString anArg (theArgVec[anArgIter]);
1205 TCollection_AsciiString anArgCase (anArg);
1206 anArgCase.LowerCase();
1207 if (anArgCase == "nbpnts")
1209 if (++anArgIter >= theArgNb)
1211 di << "Value for argument '" << anArg << "' is absent.\n";
1215 aSrcNbPnts = Draw::Atoi (theArgVec[anArgIter]);
1217 else if (anArgCase == "uniform")
1219 if (++anArgIter >= theArgNb)
1221 di << "Value for argument '" << anArg << "' is absent.\n";
1225 isUniform = (Draw::Atoi (theArgVec[anArgIter]) == 1);
1229 di << "Invalid argument '" << anArg << "'.\n";
1236 di << "Invalid count of points.\n";
1242 di << "Invalid type of discretization.\n";
1246 GeomAdaptor_Curve aCurveAdaptor(aCurve);
1247 GCPnts_UniformAbscissa aSplitter(aCurveAdaptor, aSrcNbPnts, Precision::Confusion());
1248 if (!aSplitter.IsDone())
1250 di << "Error: Invalid result.\n";
1254 const Standard_Integer aDstNbPnts = aSplitter.NbPoints();
1258 di << "Error: Invalid result.\n";
1262 TColgp_Array1OfPnt aPoles(1, aDstNbPnts);
1263 TColStd_Array1OfReal aKnots(1, aDstNbPnts);
1264 TColStd_Array1OfInteger aMultiplicities(1, aDstNbPnts);
1266 for (Standard_Integer aPntIter = 1; aPntIter <= aDstNbPnts; ++aPntIter)
1268 aPoles.ChangeValue(aPntIter) = aCurveAdaptor.Value(aSplitter.Parameter(aPntIter));
1269 aKnots.ChangeValue(aPntIter) = (aPntIter - 1) / (aDstNbPnts - 1.0);
1270 aMultiplicities.ChangeValue(aPntIter) = 1;
1272 aMultiplicities.ChangeValue(1) = 2;
1273 aMultiplicities.ChangeValue(aDstNbPnts) = 2;
1275 Handle(Geom_BSplineCurve) aPolyline =
1276 new Geom_BSplineCurve(aPoles, aKnots, aMultiplicities, 1);
1277 DrawTrSurf::Set(theArgVec[1], aPolyline);
1282 //=======================================================================
1283 //function : mypoints
1285 //=======================================================================
1287 static Standard_Integer mypoints (Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
1289 Standard_Integer i, nbp;
1292 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
1293 defl = Draw::Atof(a[3]);
1294 Handle(Geom_BSplineCurve) aBS (Handle(Geom_BSplineCurve)::DownCast(C));
1296 if(aBS.IsNull()) return 1;
1298 Standard_Integer ui1 = aBS->FirstUKnotIndex();
1299 Standard_Integer ui2 = aBS->LastUKnotIndex();
1301 Standard_Integer nbsu = ui2-ui1+1; nbsu += (nbsu - 1) * (aBS->Degree()-1);
1303 TColStd_Array1OfReal anUPars(1, nbsu);
1304 TColStd_Array1OfBoolean anUFlg(1, nbsu);
1306 Standard_Integer j, k, nbi;
1307 Standard_Real t1, t2, dt;
1309 //Filling of sample parameters
1310 nbi = aBS->Degree();
1312 t1 = aBS->Knot(ui1);
1313 for(i = ui1+1; i <= ui2; ++i) {
1320 anUFlg(k) = Standard_False;
1333 anUFlg(1) = Standard_True;
1334 anUFlg(nbsu) = Standard_True;
1335 Standard_Boolean bCont = Standard_True;
1336 while (j < nbsu-1 && bCont) {
1338 gp_Pnt p1 = aBS->Value(t2);
1339 for(k = j+2; k <= nbsu; ++k) {
1341 gp_Pnt p2 = aBS->Value(t2);
1342 gce_MakeLin MkLin(p1, p2);
1343 const gp_Lin& lin = MkLin.Value();
1344 Standard_Boolean ok = Standard_True;
1345 for(l = j+1; l < k; ++l) {
1346 if(anUFlg(l)) continue;
1347 gp_Pnt pp = aBS->Value(anUPars(l));
1348 Standard_Real d = lin.SquareDistance(pp);
1350 if(d <= defl) continue;
1352 ok = Standard_False;
1359 anUFlg(j) = Standard_True;
1365 if(k >= nbsu) bCont = Standard_False;
1369 for(i = 1; i <= nbsu; ++i) {
1370 if(anUFlg(i)) nbp++;
1373 TColgp_Array1OfPnt aPoles(1, nbp);
1374 TColStd_Array1OfReal aKnots(1, nbp);
1375 TColStd_Array1OfInteger aMults(1, nbp);
1377 for(i = 1; i <= nbsu; ++i) {
1380 aKnots(j) = anUPars(i);
1382 aPoles(j) = aBS->Value(aKnots(j));
1389 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
1390 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
1392 aDrCrv->ClearPoles();
1393 Draw_Color aKnColor(Draw_or);
1394 aDrCrv->SetKnotsColor(aKnColor);
1395 aDrCrv->SetKnotsShape(Draw_Plus);
1397 Draw::Set(a[1], aDrCrv);
1399 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
1400 Standard_Integer imax = 0;
1402 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
1403 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
1410 //=======================================================================
1411 //function : surfpoints
1413 //=======================================================================
1415 static Standard_Integer surfpoints (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char** a)
1420 Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[2]);
1421 defl = Draw::Atof(a[3]);
1423 Handle(GeomAdaptor_HSurface) AS = new GeomAdaptor_HSurface(S);
1425 Handle(Adaptor3d_TopolTool) aTopTool = new Adaptor3d_TopolTool(AS);
1427 aTopTool->SamplePnts(defl, 10, 10);
1429 Standard_Integer nbpu = aTopTool->NbSamplesU();
1430 Standard_Integer nbpv = aTopTool->NbSamplesV();
1431 TColStd_Array1OfReal Upars(1, nbpu), Vpars(1, nbpv);
1432 aTopTool->UParameters(Upars);
1433 aTopTool->VParameters(Vpars);
1435 TColgp_Array2OfPnt aPoles(1, nbpu, 1, nbpv);
1436 TColStd_Array1OfReal anUKnots(1, nbpu);
1437 TColStd_Array1OfReal aVKnots(1, nbpv);
1438 TColStd_Array1OfInteger anUMults(1, nbpu);
1439 TColStd_Array1OfInteger aVMults(1, nbpv);
1442 for(i = 1; i <= nbpu; ++i) {
1443 anUKnots(i) = Upars(i);
1445 for(j = 1; j <= nbpv; ++j) {
1446 aVKnots(j) = Vpars(j);
1448 aPoles(i,j) = S->Value(anUKnots(i),aVKnots(j));
1457 Handle(Geom_BSplineSurface) aPnts = new Geom_BSplineSurface(aPoles, anUKnots, aVKnots,
1458 anUMults, aVMults, 1, 1);
1459 Handle(DrawTrSurf_BSplineSurface) aDrSurf = new DrawTrSurf_BSplineSurface(aPnts);
1461 aDrSurf->ClearPoles();
1462 Draw_Color aKnColor(Draw_or);
1463 aDrSurf->SetKnotsColor(aKnColor);
1464 aDrSurf->SetKnotsShape(Draw_Plus);
1466 Draw::Set(a[1], aDrSurf);
1474 //=======================================================================
1475 //function : intersect
1477 //=======================================================================
1478 static Standard_Integer intersection (Draw_Interpretor& di,
1479 Standard_Integer n, const char** a)
1485 Handle(Geom_Curve) GC1;
1486 Handle(Geom_Surface) GS1 = DrawTrSurf::GetSurface(a[2]);
1489 GC1 = DrawTrSurf::GetCurve(a[2]);
1495 Handle(Geom_Surface) GS2 = DrawTrSurf::GetSurface(a[3]);
1500 Standard_Real tol = Precision::Confusion();
1501 if (n == 5 || n == 9 || n == 13 || n == 17)
1502 tol = Draw::Atof(a[n-1]);
1505 Handle(Geom_Curve) Result;
1511 GeomInt_IntSS Inters;
1517 Inters.Perform(GS1,GS2,tol,Standard_True);
1519 else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
1521 Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
1522 Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
1523 Standard_Real UVsta[4];
1524 Handle(GeomAdaptor_HSurface) AS1,AS2;
1527 if (n <= 9) // user starting point
1529 useBnd = Standard_False;
1533 else if (n <= 13) // user bounding
1535 useStart = Standard_False;
1536 ibnd1 = 4; ibnd2 = 11;
1538 else // both user starting point and bounding
1540 ista1 = 4; ista2 = 7;
1541 ibnd1 = 8; ibnd2 = 15;
1546 for (Standard_Integer i=ista1; i <= ista2; i++)
1548 UVsta[i-ista1] = Draw::Atof(a[i]);
1554 Standard_Real UVbnd[8];
1555 for (Standard_Integer i=ibnd1; i <= ibnd2; i++)
1556 UVbnd[i-ibnd1] = Draw::Atof(a[i]);
1558 AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
1559 AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
1563 if (useStart && !useBnd)
1565 Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
1567 else if (!useStart && useBnd)
1569 Inters.Perform(AS1,AS2,tol);
1573 Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
1575 }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
1578 di<<"incorrect number of arguments\n";
1583 if (!Inters.IsDone())
1585 di<<"No intersections found!\n";
1592 Standard_Integer i, aNbLines, aNbPoints;
1595 aNbLines = Inters.NbLines();
1598 for (i=1; i<=aNbLines; ++i)
1600 Sprintf(buf, "%s_%d",a[1],i);
1602 Result = Inters.Line(i);
1603 const char* temp = buf;
1604 DrawTrSurf::Set(temp,Result);
1607 else if (aNbLines == 1)
1609 Result = Inters.Line(1);
1610 Sprintf(buf,"%s",a[1]);
1612 DrawTrSurf::Set(a[1],Result);
1616 aNbPoints=Inters.NbPoints();
1617 for (i=1; i<=aNbPoints; ++i)
1619 Point=Inters.Point(i);
1620 Sprintf(buf,"%s_p_%d",a[1],i);
1622 const char* temp = buf;
1623 DrawTrSurf::Set(temp, Point);
1625 }// if (GC1.IsNull())
1629 GeomAPI_IntCS Inters(GC1,GS2);
1632 if (!Inters.IsDone())
1634 di<<"No intersections found!\n";
1638 Standard_Integer nblines = Inters.NbSegments();
1639 Standard_Integer nbpoints = Inters.NbPoints();
1643 if ( (nblines+nbpoints) >= 2)
1646 Standard_Integer Compt = 1;
1649 cout << " Lines: " << endl;
1651 for (i = 1; i <= nblines; i++, Compt++)
1653 Sprintf(newname,"%s_%d",a[1],Compt);
1654 di << newname << " ";
1655 Result = Inters.Segment(i);
1656 const char* temp = newname; // pour portage WNT
1657 DrawTrSurf::Set(temp,Result);
1661 cout << " Points: " << endl;
1663 const Standard_Integer imax = nblines+nbpoints;
1665 for (/*i = 1*/; i <= imax; i++, Compt++)
1667 Sprintf(newname,"%s_%d",a[1],i);
1668 di << newname << " ";
1669 Point = Inters.Point(i);
1670 const char* temp = newname; // pour portage WNT
1671 DrawTrSurf::Set(temp,Point);
1674 else if (nblines == 1)
1676 Result = Inters.Segment(1);
1677 Sprintf(newname,"%s",a[1]);
1678 di << newname << " ";
1679 DrawTrSurf::Set(a[1],Result);
1681 else if (nbpoints == 1)
1683 Point = Inters.Point(1);
1684 Sprintf(newname,"%s",a[1]);
1685 di << newname << " ";
1686 DrawTrSurf::Set(a[1],Point);
1694 //=======================================================================
1695 //function : GetCurveContinuity
1696 //purpose : Returns the continuity of the given curve
1697 //=======================================================================
1698 static Standard_Integer GetCurveContinuity( Draw_Interpretor& theDI,
1699 Standard_Integer theNArg,
1700 const char** theArgv)
1704 theDI << "Use: getcurvcontinuity {curve or 2dcurve} \n";
1708 char aContName[7][3] = {"C0", //0
1716 Handle(Geom2d_Curve) GC2d;
1717 Handle(Geom_Curve) GC3d = DrawTrSurf::GetCurve(theArgv[1]);
1720 GC2d = DrawTrSurf::GetCurve2d(theArgv[1]);
1723 theDI << "Argument is not a 2D or 3D curve!\n";
1728 theDI << theArgv[1] << " has " << aContName[GC2d->Continuity()] << " continuity.\n";
1733 theDI << theArgv[1] << " has " << aContName[GC3d->Continuity()] << " continuity.\n";
1739 //=======================================================================
1740 //function : CurveCommands
1742 //=======================================================================
1743 void GeometryTest::CurveCommands(Draw_Interpretor& theCommands)
1746 static Standard_Boolean loaded = Standard_False;
1748 loaded = Standard_True;
1750 DrawTrSurf::BasicCommands(theCommands);
1754 g = "GEOMETRY curves creation";
1756 theCommands.Add("law",
1757 "law name degree nbknots knot, umult value",
1761 theCommands.Add("to2d","to2d c2dname c3d [plane (XOY)]",
1765 theCommands.Add("to3d","to3d c3dname c2d [plane (XOY)]",
1769 theCommands.Add("gproject",
1770 "gproject : [projectname] curve surface",
1774 theCommands.Add("project",
1775 "project : no args to have help",
1779 theCommands.Add("projonplane",
1780 "projonplane r C3d Plane [dx dy dz] [0/1]",
1783 theCommands.Add("bisec",
1784 "bisec result line/circle/point line/circle/point",
1788 g = "GEOMETRY Curves and Surfaces modification";
1791 theCommands.Add("movelaw",
1792 "movelaw name u x tx [ constraint = 0]",
1798 g = "GEOMETRY intersections";
1800 theCommands.Add("intersect",
1801 "intersect result surf1/curv1 surf2 [tolerance]\n\t\t "
1802 "intersect result surf1 surf2 [u1 v1 u2 v2] [U1F U1L V1F V1L U2F U2L V2F V2L] [tolerance]",
1806 theCommands.Add("crvpoints",
1807 "crvpoints result curv deflection",
1811 theCommands.Add("crvtpoints",
1812 "crvtpoints result curv deflection angular deflection - tangential deflection points",
1816 theCommands.Add("uniformAbscissa",
1817 "uniformAbscissa Curve nbPnt",
1821 theCommands.Add("uniformAbscissaEl",
1822 "uniformAbscissaEl maxR minR nbPnt",
1823 __FILE__, EllipsUniformAbscissa,g);
1825 theCommands.Add("discrCurve",
1826 "discrCurve polyline curve params\n"
1827 "Approximates a curve by a polyline (first degree B-spline).\n"
1828 "nbPnts number - creates polylines with the number points\n"
1829 "uniform 0 | 1 - creates polyline with equal length segments",
1830 __FILE__, discrCurve, g);
1832 theCommands.Add("mypoints",
1833 "mypoints result curv deflection",
1836 theCommands.Add("surfpoints",
1837 "surfoints result surf deflection",
1841 theCommands.Add("getcurvcontinuity",
1842 "getcurvcontinuity {curve or 2dcurve}: \n\tReturns the continuity of the given curve",
1844 GetCurveContinuity,g);