0024023: Revamp the OCCT Handle -- downcast (automatic)
[occt.git] / src / GeometryTest / GeometryTest_CurveCommands.cxx
CommitLineData
b311480e 1// Created on: 1993-08-12
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// 09/06/97 : JPI : suppression des commandes redondantes suite a la creation de GeomliteTest
18
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>
30#include <Draw.hxx>
31#include <Draw_Interpretor.hxx>
32#include <Draw_Color.hxx>
33#include <Draw_Display.hxx>
34
35#include <GeomAPI.hxx>
36#include <GeomAPI_IntCS.hxx>
37#include <GeomAPI_IntSS.hxx>
38
39//#include <GeomLProp.hxx>
40#include <GeomProjLib.hxx>
41#include <BSplCLib.hxx>
42
43#include <gp.hxx>
44#include <gp_Pln.hxx>
45#include <gp_Parab2d.hxx>
46#include <gp_Elips2d.hxx>
47#include <gp_Hypr2d.hxx>
48
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>
61
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>
70
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>
76
77#include <Law_BSpline.hxx>
78
79#include <TColgp_Array1OfPnt.hxx>
80#include <TColgp_Array1OfPnt2d.hxx>
81#include <TColStd_Array1OfReal.hxx>
82#include <TColStd_Array1OfInteger.hxx>
83
84#include <Adaptor3d_HCurve.hxx>
85#include <Adaptor3d_HSurface.hxx>
86#include <Adaptor3d_CurveOnSurface.hxx>
87
88#include <GeomAdaptor_HCurve.hxx>
89#include <GeomAdaptor_HSurface.hxx>
90#include <GeomAdaptor.hxx>
91#include <Geom2dAdaptor_HCurve.hxx>
92
93#include <GeomAbs_SurfaceType.hxx>
94#include <GeomAbs_CurveType.hxx>
95
96#include <ProjLib_CompProjectedCurve.hxx>
97#include <ProjLib_HCompProjectedCurve.hxx>
98#include <Approx_CurveOnSurface.hxx>
99#include <Precision.hxx>
100#include <Geom2dAdaptor.hxx>
101
102
103#include <Precision.hxx>
104
105#include <Geom_Surface.hxx>
106#include <Adaptor2d_HCurve2d.hxx>
107#include <stdio.h>
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 <GeomAPI_ExtremaCurveCurve.hxx>
115#include <gce_MakeLin.hxx>
116#include <TColStd_Array1OfBoolean.hxx>
117#include <GeomAdaptor_HSurface.hxx>
118#include <Adaptor3d_TopolTool.hxx>
119#include <TColgp_Array2OfPnt.hxx>
120#include <Geom_BSplineSurface.hxx>
121#include <DrawTrSurf_BSplineSurface.hxx>
122#include <TColStd_HArray1OfReal.hxx>
123
124//epa test
125#include <BRepBuilderAPI_MakeEdge.hxx>
126#include <AIS_Shape.hxx>
127#include <TopoDS_Edge.hxx>
128#include <GeomLProp_CLProps.hxx>
129#include <GCPnts_AbscissaPoint.hxx>
130#include <GCPnts_UniformAbscissa.hxx>
131#include <DBRep.hxx>
132
133#ifdef WNT
134Standard_IMPORT Draw_Viewer dout;
135#endif
136
137//=======================================================================
138//function : polecurve2d
139//purpose :
140//=======================================================================
141
142static Standard_Integer polelaw (Draw_Interpretor& , Standard_Integer n, const char** a)
143{
144 Standard_Integer k,
145 jj,
146 qq,
147 i;
148
149
150 if (n < 3) return 1;
151 Standard_Boolean periodic = Standard_False ;
91322f44 152 Standard_Integer deg = Draw::Atoi(a[2]);
153 Standard_Integer nbk = Draw::Atoi(a[3]);
7fd59977 154
155 TColStd_Array1OfReal knots(1, nbk);
156 TColStd_Array1OfInteger mults(1, nbk);
157 k = 4;
158 Standard_Integer Sigma = 0;
159 for (i = 1; i<=nbk; i++) {
91322f44 160 knots( i) = Draw::Atof(a[k]);
7fd59977 161 k++;
91322f44 162 mults( i) = Draw::Atoi(a[k]);
7fd59977 163 Sigma += mults(i);
164 k++;
165 }
166
167 Standard_Integer np;
168 np = Sigma - deg -1;
169 TColStd_Array1OfReal flat_knots(1, Sigma) ;
170 jj = 1 ;
171 for (i = 1 ; i <= nbk ; i++) {
172 for(qq = 1 ; qq <= mults(i) ; qq++) {
173 flat_knots(jj) = knots(i) ;
174 jj ++ ;
175 }
176 }
177
178 TColgp_Array1OfPnt2d poles (1, np);
179 TColStd_Array1OfReal schoenberg_points(1,np) ;
180 BSplCLib::BuildSchoenbergPoints(deg,
181 flat_knots,
182 schoenberg_points) ;
183 for (i = 1; i <= np; i++) {
91322f44 184 poles(i).SetCoord(schoenberg_points(i),Draw::Atof(a[k]));
7fd59977 185 k++;
186 }
187
188 Handle(Geom2d_BSplineCurve) result =
189 new Geom2d_BSplineCurve(poles, knots, mults, deg, periodic);
190 DrawTrSurf::Set(a[1],result);
191
192
193 return 0;
194}
195//=======================================================================
196//function : to2d
197//purpose :
198//=======================================================================
199
200static Standard_Integer to2d (Draw_Interpretor& , Standard_Integer n, const char** a)
201{
202 if (n < 3) return 1;
203
204 // get the curve
205 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
206 if (C.IsNull())
207 return 1;
208
209 Handle(Geom_Surface) S;
210 if (n >= 4) {
211 S = DrawTrSurf::GetSurface(a[3]);
212 if (S.IsNull()) return 1;
213 }
214 else
215 S = new Geom_Plane(gp::XOY());
216
217 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
218 if (P.IsNull()) return 1;
219 Handle(Geom2d_Curve) r = GeomAPI::To2d(C,P->Pln());
220 DrawTrSurf::Set(a[1],r);
221 return 0;
222}
223
224//=======================================================================
225//function : to3d
226//purpose :
227//=======================================================================
228
229static Standard_Integer to3d (Draw_Interpretor& , Standard_Integer n, const char** a)
230{
231 if (n < 3) return 1;
232
233 Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
234 if (C.IsNull()) return 1;
235
236 Handle(Geom_Surface) S;
237 if (n >= 4) {
238 S = DrawTrSurf::GetSurface(a[3]);
239 if (S.IsNull()) return 1;
240 }
241 else
242 S = new Geom_Plane(gp::XOY());
243
244 Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(S);
245 if (P.IsNull()) return 1;
246 Handle(Geom_Curve) r = GeomAPI::To3d(C,P->Pln());
247
248 DrawTrSurf::Set(a[1],r);
249 return 0;
250}
251
252//=======================================================================
253//function : gproject
254//purpose :
255//=======================================================================
256
257
258static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
259{
260
261 char newname[1024];
262 char* temp = newname;
263 char newname1[10];
264 char* temp1 = newname1;
265 char name[100];
266 Standard_Integer ONE = 1;
267
268 if (n == 3)
91322f44 269 Sprintf(name,"p");
7fd59977 270 else if (n == 4) {
91322f44 271 Sprintf(name,"%s",a[1]);
7fd59977 272 ONE = 2;
273 }
274 else {
275 di << "gproject wait 2 or 3 arguments" << "\n";
276 return 1;
277 }
278
279 Handle(Geom_Curve) Cur = DrawTrSurf::GetCurve(a[ONE]);
280 Handle(Geom_Surface) Sur = DrawTrSurf::GetSurface(a[ONE+1]);
281 if (Cur.IsNull() || Sur.IsNull()) return 1;
282
283 Handle(GeomAdaptor_HCurve) hcur = new GeomAdaptor_HCurve(Cur);
284 Handle(GeomAdaptor_HSurface) hsur = new GeomAdaptor_HSurface(Sur);
285
286
287 Standard_Real myTol3d = 1.e-6;
288 GeomAbs_Shape myContinuity = GeomAbs_C2;
289 Standard_Integer myMaxDegree = 14, myMaxSeg = 16;
290
291
292 ProjLib_CompProjectedCurve Projector(hsur, hcur, myTol3d/10, myTol3d/10);
293 Handle(ProjLib_HCompProjectedCurve) HProjector = new ProjLib_HCompProjectedCurve();
294 HProjector->Set(Projector);
295
296 Standard_Integer k;
297 Standard_Real Udeb, Ufin, UIso, VIso;
298 Standard_Integer Only2d, Only3d;
299 gp_Pnt2d P2d, Pdeb, Pfin;
300 gp_Pnt P;
301 Handle(Adaptor2d_HCurve2d) HPCur;
302 Handle(Geom2d_Curve) PCur2d; // Only for isoparametric projection
303
304 for(k = 1; k <= Projector.NbCurves(); k++){
91322f44 305 Sprintf(newname,"%s_%d",name,k);
306 Sprintf(newname1,"%s2d_%d",name,k);
7fd59977 307 if(Projector.IsSinglePnt(k, P2d)){
308// cout<<"Part "<<k<<" of the projection is punctual"<<endl;
309 Projector.GetSurface()->D0(P2d.X(), P2d.Y(), P);
310 DrawTrSurf::Set(temp, P);
311 DrawTrSurf::Set(temp1, P2d);
312 di<<temp<<" is 3d projected curve"<<"\n";
313 di<<temp1<<" is pcurve"<<"\n";
314 }
315 else {
316 Only2d = Only3d = Standard_False;
317 Projector.Bounds(k, Udeb, Ufin);
318 gp_Dir2d Dir; // Only for isoparametric projection
319
320 if (Projector.IsUIso(k, UIso)) {
321// cout<<"Part "<<k<<" of the projection is U-isoparametric curve"<<endl;
322 Projector.D0(Udeb, Pdeb);
323 Projector.D0(Ufin, Pfin);
324 Udeb = Pdeb.Y();
325 Ufin = Pfin.Y();
326 if (Udeb > Ufin) {
327 Dir = gp_Dir2d(0, -1);
328 Udeb = - Udeb;
329 Ufin = - Ufin;
330 }
331 else Dir = gp_Dir2d(0, 1);
332 PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(UIso, 0), Dir), Udeb, Ufin);
333 HPCur = new Geom2dAdaptor_HCurve(PCur2d);
334 Only3d = Standard_True;
335 }
336 else if(Projector.IsVIso(k, VIso)) {
337// cout<<"Part "<<k<<" of the projection is V-isoparametric curve"<<endl;
338 Projector.D0(Udeb, Pdeb);
339 Projector.D0(Ufin, Pfin);
340 Udeb = Pdeb.X();
341 Ufin = Pfin.X();
342 if (Udeb > Ufin) {
343 Dir = gp_Dir2d(-1, 0);
344 Udeb = - Udeb;
345 Ufin = - Ufin;
346 }
347 else Dir = gp_Dir2d(1, 0);
348 PCur2d = new Geom2d_TrimmedCurve(new Geom2d_Line(gp_Pnt2d(0, VIso), Dir), Udeb, Ufin);
349 HPCur = new Geom2dAdaptor_HCurve(PCur2d);
350 Only3d = Standard_True;
351 }
352 else HPCur = HProjector;
353
354 if(Projector.MaxDistance(k) <= myTol3d)
355 Only2d = Standard_True;
356
357 if(Only2d && Only3d) {
358 Handle(Geom_Curve) OutCur = new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()), Ufin, Udeb);
359 DrawTrSurf::Set(temp, OutCur);
360 DrawTrSurf::Set(temp1, PCur2d);
361 di<<temp<<" is 3d projected curve"<<"\n";
362 di<<temp1<<" is pcurve"<<"\n";
363 return 0;
364 }
365 else {
366 Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
367 myContinuity, myMaxDegree, myMaxSeg,
368 Only3d, Only2d);
369 if(!Only3d) {
370 PCur2d = appr.Curve2d();
371 di << " Error in 2d is " << appr.MaxError2dU()
372 << "; " << appr.MaxError2dV() << "\n";
373 }
374 if(Only2d) {
375 Handle(Geom_Curve) OutCur =
376 new Geom_TrimmedCurve(GeomAdaptor::MakeCurve(hcur->Curve()),
377 Ufin, Udeb);
378 DrawTrSurf::Set(temp, OutCur);
379 }
380 else {
381 di << " Error in 3d is " << appr.MaxError3d() << "\n";
382 DrawTrSurf::Set(temp, appr.Curve3d());
383 }
384 DrawTrSurf::Set(temp1, PCur2d);
385 di<<temp<<" is 3d projected curve"<<"\n";
386 di<<temp1<<" is pcurve"<<"\n";
387 }
388 }
389 }
390return 0;
391}
392//=======================================================================
393//function : project
394//purpose :
395//=======================================================================
396
397static Standard_Integer project (Draw_Interpretor& di,
398 Standard_Integer n, const char** a)
399{
400 if ( n == 1) {
401
402 di << "project result2d c3d surf [-e p] [-v n] [-t tol]" << "\n";
403 di << " -e p : extent the surface of <p>%" << "\n";
404 di << " -v n : verify the projection at <n> points." << "\n";
405 di << " -t tol : set the tolerance for approximation" << "\n";
406 return 0;
407 }
408
409 if (n < 4) return 1;
410 Handle(Geom_Surface) GS = DrawTrSurf::GetSurface(a[3]);
411 if (GS.IsNull()) return 1;
412
413 Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[2]);
414 if (GC.IsNull()) return 1;
415
416 Standard_Real tolerance = Precision::Confusion() ;
417
418 Standard_Real U1,U2,V1,V2;
419 GS->Bounds(U1,U2,V1,V2);
420
96a95605 421 Standard_Boolean Verif = Standard_False;
7fd59977 422 Standard_Integer NbPoints=0;
423
424 Standard_Integer index = 4;
425 while ( index+1 < n) {
426 if ( a[index][0] != '-') return 1;
427
428 if ( a[index][1] == 'e') {
91322f44 429 Standard_Real p = Draw::Atof(a[index+1]);
7fd59977 430 Standard_Real dU = p * (U2 - U1) / 100.;
431 Standard_Real dV = p * (V2 - V1) / 100.;
432 U1 -= dU; U2 += dU; V1 -= dV; V2 += dV;
7fd59977 433 }
434 else if ( a[index][1] == 'v') {
435 Verif = Standard_True;
91322f44 436 NbPoints = Draw::Atoi(a[index+1]);
7fd59977 437 }
438 else if ( a[index][1] == 't') {
91322f44 439 tolerance = Draw::Atof(a[index+1]);
7fd59977 440 }
441 index += 2;
442 }
443
444 Handle(Geom2d_Curve) G2d =
445 GeomProjLib::Curve2d(GC, GS, U1, U2, V1, V2, tolerance);
446
447 if ( G2d.IsNull() ) {
448 di << "\n" << "Projection Failed" << "\n";
449 return 1;
450 }
451 else {
452 DrawTrSurf::Set(a[1],G2d);
453 }
454 if ( Verif) { // verify the projection on n points
455 if ( NbPoints <= 0) {
456 di << " n must be positive" << "\n";
457 return 0;
458 }
459 gp_Pnt P1,P2;
460 gp_Pnt2d P2d;
461
462 Standard_Real U, dU;
463 Standard_Real Dist,DistMax = -1.;
464 U1 = GC->FirstParameter();
465 U2 = GC->LastParameter();
466 dU = ( U2 - U1) / (NbPoints + 1);
467 for ( Standard_Integer i = 0 ; i <= NbPoints +1; i++) {
468 U = U1 + i *dU;
469 P1 = GC->Value(U);
470 P2d = G2d->Value(U);
471 P2 = GS->Value(P2d.X(), P2d.Y());
472 Dist = P1.Distance(P2);
473 di << " Parameter = " << U << "\tDistance = " << Dist << "\n";
474 if ( Dist > DistMax) DistMax = Dist;
475 }
476 di << " **** Distance Maximale : " << DistMax << "\n";
477 }
478
479 return 0;
480}
481
482//=======================================================================
483//function : projonplane
484//purpose :
485//=======================================================================
486
487Standard_Integer projonplane(Draw_Interpretor& di,
488 Standard_Integer n, const char** a)
489{
490 if ( n < 4 ) return 1;
491
492 Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[3]);
493 if ( S.IsNull()) return 1;
494
495 Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(S);
496 if ( Pl.IsNull()) {
497 di << " The surface must be a plane" << "\n";
498 return 1;
499 }
500
501 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
502 if ( C.IsNull()) return 1;
503
504 Standard_Boolean Param = Standard_True;
91322f44 505 if ((n == 5 && Draw::Atoi(a[4]) == 0) ||
506 (n == 8 && Draw::Atoi(a[7]) == 0)) Param = Standard_False;
7fd59977 507
508 gp_Dir D;
509
510 if ( n == 8) {
91322f44 511 D = gp_Dir(Draw::Atof(a[4]),Draw::Atof(a[5]),Draw::Atof(a[6]));
7fd59977 512 }
513 else {
514 D = Pl->Pln().Position().Direction();
515 }
516
517 Handle(Geom_Curve) Res =
518 GeomProjLib::ProjectOnPlane(C,Pl,D,Param);
519
520 DrawTrSurf::Set(a[1],Res);
521 return 0;
522
523}
524
525
526//=======================================================================
527//function : bisec
528//purpose :
529//=======================================================================
530
531static void solution(const Handle(GccInt_Bisec)& Bis,
532 const char* name,
533 const Standard_Integer i)
534{
535 char solname[200];
536 if ( i == 0)
91322f44 537 Sprintf(solname,"%s",name);
7fd59977 538 else
91322f44 539 Sprintf(solname,"%s_%d",name,i);
7fd59977 540 const char* temp = solname; // pour portage WNT
541
542 switch ( Bis->ArcType()) {
543 case GccInt_Lin:
544 DrawTrSurf::Set(temp, new Geom2d_Line(Bis->Line()));
545 break;
546 case GccInt_Cir:
547 DrawTrSurf::Set(temp, new Geom2d_Circle(Bis->Circle()));
548 break;
549 case GccInt_Ell:
550 DrawTrSurf::Set(temp, new Geom2d_Ellipse(Bis->Ellipse()));
551 break;
552 case GccInt_Par:
553 DrawTrSurf::Set(temp, new Geom2d_Parabola(Bis->Parabola()));
554 break;
555 case GccInt_Hpr:
556 DrawTrSurf::Set(temp, new Geom2d_Hyperbola(Bis->Hyperbola()));
557 break;
558 case GccInt_Pnt:
559 DrawTrSurf::Set(temp, Bis->Point());
560 break;
561 }
562}
563
564static Standard_Integer bisec (Draw_Interpretor& di,
565 Standard_Integer n, const char** a)
566{
567 if (n < 4) return 1;
568
569 Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[2]);
570 Handle(Geom2d_Curve) C2 = DrawTrSurf::GetCurve2d(a[3]);
571 gp_Pnt2d P1,P2;
572 Standard_Boolean ip1 = DrawTrSurf::GetPoint2d(a[2],P1);
573 Standard_Boolean ip2 = DrawTrSurf::GetPoint2d(a[3],P2);
574 Standard_Integer i, Compt = 0;
575 Standard_Integer NbSol = 0;
576
577 if ( !C1.IsNull()) {
578 Handle(Standard_Type) Type1 = C1->DynamicType();
579 if ( !C2.IsNull()) {
580 Handle(Standard_Type) Type2 = C2->DynamicType();
581 if ( Type1 == STANDARD_TYPE(Geom2d_Line) &&
582 Type2 == STANDARD_TYPE(Geom2d_Line) ) {
583 GccAna_Lin2dBisec Bis(Handle(Geom2d_Line)::DownCast(C1)->Lin2d(),
584 Handle(Geom2d_Line)::DownCast(C2)->Lin2d());
585 if ( Bis.IsDone()) {
586 char solname[200];
587 NbSol = Bis.NbSolutions();
588 for ( i = 1; i <= NbSol; i++) {
91322f44 589 Sprintf(solname,"%s_%d",a[1],i);
7fd59977 590 const char* temp = solname; // pour portage WNT
591 DrawTrSurf::Set(temp,new Geom2d_Line(Bis.ThisSolution(i)));
592 }
593 }
594 else {
595 di << " Bisec has failed !!" << "\n";
596 return 1;
597 }
598 }
599 else if ( Type1 == STANDARD_TYPE(Geom2d_Line) &&
600 Type2 == STANDARD_TYPE(Geom2d_Circle) ) {
601 GccAna_CircLin2dBisec
602 Bis(Handle(Geom2d_Circle)::DownCast(C2)->Circ2d(),
603 Handle(Geom2d_Line)::DownCast(C1)->Lin2d());
604 if ( Bis.IsDone()) {
605 NbSol= Bis.NbSolutions();
606 if ( NbSol >= 2) Compt = 1;
607 for ( i = 1; i <= NbSol; i++) {
608 solution(Bis.ThisSolution(i),a[1],Compt);
609 Compt++;
610 }
611 }
612 else {
613 di << " Bisec has failed !!" << "\n";
614 return 1;
615 }
616 }
617 else if ( Type2 == STANDARD_TYPE(Geom2d_Line) &&
618 Type1 == STANDARD_TYPE(Geom2d_Circle) ) {
619 GccAna_CircLin2dBisec
620 Bis(Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),
621 Handle(Geom2d_Line)::DownCast(C2)->Lin2d());
622 if ( Bis.IsDone()) {
623// char solname[200];
624 NbSol = Bis.NbSolutions();
625 if ( NbSol >= 2) Compt = 1;
626 for ( i = 1; i <= NbSol; i++) {
627 solution(Bis.ThisSolution(i),a[1],Compt);
628 Compt++;
629 }
630 }
631 else {
632 di << " Bisec has failed !!" << "\n";
633 return 1;
634 }
635 }
636 else if ( Type2 == STANDARD_TYPE(Geom2d_Circle) &&
637 Type1 == STANDARD_TYPE(Geom2d_Circle) ) {
638 GccAna_Circ2dBisec
639 Bis(Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),
640 Handle(Geom2d_Circle)::DownCast(C2)->Circ2d());
641 if ( Bis.IsDone()) {
642// char solname[200];
643 NbSol = Bis.NbSolutions();
644 if ( NbSol >= 2) Compt = 1;
645 for ( i = 1; i <= NbSol; i++) {
646 solution(Bis.ThisSolution(i),a[1],Compt);
647 Compt++;
648 }
649 }
650 else {
651 di << " Bisec has failed !!" << "\n";
652 return 1;
653 }
654 }
655 else {
656 di << " args must be line/circle/point line/circle/point" << "\n";
657 return 1;
658 }
659 }
660 else if (ip2) {
661 if ( Type1 == STANDARD_TYPE(Geom2d_Circle)) {
662 GccAna_CircPnt2dBisec Bis
663 (Handle(Geom2d_Circle)::DownCast(C1)->Circ2d(),P2);
664 if ( Bis.IsDone()) {
665 NbSol = Bis.NbSolutions();
666 if ( NbSol >= 2) Compt = 1;
667 for ( i = 1; i <= NbSol; i++) {
668 solution(Bis.ThisSolution(i),a[1],Compt);
669 Compt++;
670 }
671 }
672 else {
673 di << " Bisec has failed !!" << "\n";
674 return 1;
675 }
676 }
677 else if ( Type1 == STANDARD_TYPE(Geom2d_Line)) {
678 GccAna_LinPnt2dBisec Bis
679 (Handle(Geom2d_Line)::DownCast(C1)->Lin2d(),P2);
680 if ( Bis.IsDone()) {
681 NbSol = 1;
682 solution(Bis.ThisSolution(),a[1],0);
683 }
684 else {
685 di << " Bisec has failed !!" << "\n";
686 return 1;
687 }
688 }
689 }
690 else {
691 di << " the second arg must be line/circle/point " << "\n";
692 }
693 }
694 else if ( ip1) {
695 if ( !C2.IsNull()) {
696 Handle(Standard_Type) Type2 = C2->DynamicType();
697 if ( Type2 == STANDARD_TYPE(Geom2d_Circle)) {
698 GccAna_CircPnt2dBisec Bis
699 (Handle(Geom2d_Circle)::DownCast(C2)->Circ2d(),P1);
700 if ( Bis.IsDone()) {
701 NbSol = Bis.NbSolutions();
702 if ( NbSol >= 2) Compt = 1;
703 for ( i = 1; i <= Bis.NbSolutions(); i++) {
704 solution(Bis.ThisSolution(i),a[1],Compt);
705 Compt++;
706 }
707 }
708 else {
709 di << " Bisec has failed !!" << "\n";
710 return 1;
711 }
712 }
713 else if ( Type2 == STANDARD_TYPE(Geom2d_Line)) {
714 GccAna_LinPnt2dBisec Bis
715 (Handle(Geom2d_Line)::DownCast(C2)->Lin2d(),P1);
716 if ( Bis.IsDone()) {
717 NbSol = 1;
718 solution(Bis.ThisSolution(),a[1],0);
719 }
720 else {
721 di << " Bisec has failed !!" << "\n";
722 return 1;
723 }
724 }
725 }
726 else if (ip2) {
727 GccAna_Pnt2dBisec Bis(P1,P2);
728 if ( Bis.HasSolution()) {
729 NbSol = 1;
730 DrawTrSurf::Set(a[1],new Geom2d_Line(Bis.ThisSolution()));
731 }
732 else {
733 di << " Bisec has failed !!" << "\n";
734 return 1;
735 }
736 }
737 else {
738 di << " the second arg must be line/circle/point " << "\n";
739 return 1;
740 }
741 }
742 else {
743 di << " args must be line/circle/point line/circle/point" << "\n";
744 return 1;
745 }
746
747 if ( NbSol >= 2) {
748 di << "There are " << NbSol << " Solutions." << "\n";
749 }
750 else {
751 di << "There is " << NbSol << " Solution." << "\n";
752 }
753
754 return 0;
755}
756
757//=======================================================================
758//function : cmovetangent
759//purpose :
760//=======================================================================
761
762static Standard_Integer movelaw (Draw_Interpretor& di, Standard_Integer n, const char** a)
763{
96a95605 764 Standard_Integer
b92f3572 765 ii,
766 condition=0,
767 error_status ;
7fd59977 768 Standard_Real u,
b92f3572 769 x,
770 tolerance,
771 tx ;
7fd59977 772
91322f44 773 u = Draw::Atof(a[2]);
774 x = Draw::Atof(a[3]);
7fd59977 775 tolerance = 1.0e-5 ;
7fd59977 776 if (n < 5) {
b92f3572 777 return 1 ;
7fd59977 778 }
779 Handle(Geom2d_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve2d(a[1]);
780 if (!G2.IsNull()) {
b92f3572 781 tx = Draw::Atof(a[4]) ;
782 if (n == 6) {
783 condition = Max(Draw::Atoi(a[5]), -1) ;
784 condition = Min(condition, G2->Degree()-1) ;
785 }
786 TColgp_Array1OfPnt2d curve_poles(1,G2->NbPoles()) ;
787 TColStd_Array1OfReal law_poles(1,G2->NbPoles()) ;
788 TColStd_Array1OfReal law_knots(1,G2->NbKnots()) ;
789 TColStd_Array1OfInteger law_mults(1,G2->NbKnots()) ;
790
791 G2->Knots(law_knots) ;
792 G2->Multiplicities(law_mults) ;
793 G2->Poles(curve_poles) ;
794 for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
795 law_poles(ii) = curve_poles(ii).Coord(2) ;
796 }
7fd59977 797
b92f3572 798 Law_BSpline a_law(law_poles,
799 law_knots,
800 law_mults,
801 G2->Degree(),
802 Standard_False) ;
803
804 a_law.MovePointAndTangent(u,
805 x,
806 tx,
807 tolerance,
808 condition,
809 condition,
810 error_status) ;
811
812 for (ii = 1 ; ii <= G2->NbPoles() ; ii++) {
813 curve_poles(ii).SetCoord(2,a_law.Pole(ii)) ;
814 G2->SetPole(ii,curve_poles(ii)) ;
815 }
7fd59977 816
b92f3572 817
818 if (! error_status) {
819 Draw::Repaint();
7fd59977 820 }
b92f3572 821 else {
822 di << "Not enought degree of freedom increase degree please" << "\n";
823 }
824
825
826 }
7fd59977 827 return 0;
828}
829
830
3492f422 831//Static method computing deviation of curve and polyline
edbf88ba 832#include <math_PSO.hxx>
833#include <math_PSOParticlesPool.hxx>
834#include <math_MultipleVarFunctionWithHessian.hxx>
835#include <math_NewtonMinimum.hxx>
836
837class aMaxCCDist : public math_MultipleVarFunctionWithHessian
838{
839public:
840 aMaxCCDist(const Handle(Geom_Curve)& theCurve,
841 const Handle(Geom_BSplineCurve)& thePnts)
842: myCurve(theCurve),
843 myPnts(thePnts)
844 {
845 }
846
847 virtual Standard_Boolean Value (const math_Vector& X,
848 Standard_Real& F)
849 {
850 if (!CheckInputData(X(1)))
851 {
852 return Standard_False;
853 }
854 F = -myCurve->Value(X(1)).SquareDistance(myPnts->Value(X(1)));
855 return Standard_True;
856 }
857
858
859 virtual Standard_Boolean Gradient (const math_Vector& X, math_Vector& G)
860 {
861 if (!CheckInputData(X(1)))
862 {
863 return Standard_False;
864 }
865 gp_Pnt aPnt1, aPnt2;
866 gp_Vec aVec1, aVec2;
867 myCurve->D1(X(1), aPnt1, aVec1);
868 myPnts->D1 (X(1), aPnt2, aVec2);
869
870 G(1) = 2 * (aPnt1.X() - aPnt2.X()) * (aVec1.X() - aVec2.X())
871 + 2 * (aPnt1.Y() - aPnt2.Y()) * (aVec1.Y() - aVec2.Y())
872 + 2 * (aPnt1.Z() - aPnt2.Z()) * (aVec1.Z() - aVec2.Z());
873 G(1) *= -1.0; // Maximum search.
874
875 return Standard_True;
876 }
877
878 virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G, math_Matrix& H)
879 {
880 if (Value(X, F) && Gradient(X, G))
881 {
882 gp_Pnt aPnt1, aPnt2;
883 gp_Vec aVec11, aVec12, aVec21, aVec22;
884 myCurve->D2(X(1), aPnt1, aVec11, aVec12);
885 myPnts->D2 (X(1), aPnt2, aVec21, aVec22);
886
887 H(1,1) = 2 * (aVec11.X() - aVec21.X()) * (aVec11.X() - aVec21.X())
888 + 2 * (aVec11.Y() - aVec21.Y()) * (aVec11.Y() - aVec21.Y())
889 + 2 * (aVec11.Z() - aVec21.Z()) * (aVec11.Z() - aVec21.Z())
890 + 2 * (aPnt1.X() - aPnt2.X()) * (aVec12.X() - aVec22.X())
891 + 2 * (aPnt1.Y() - aPnt2.Y()) * (aVec12.Y() - aVec22.Y())
892 + 2 * (aPnt1.Z() - aPnt2.Z()) * (aVec12.Z() - aVec22.Z());
893 H(1,1) *= -1.0; // Maximum search.
894
895 return Standard_True;
896 }
897 return Standard_False;
898 }
899
900 virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G)
901 {
902 return (Value(X, F) && Gradient(X, G));
903 }
904
905 virtual Standard_Integer NbVariables() const
906 {
907 return 1;
908 }
909
910private:
911 aMaxCCDist & operator = (const aMaxCCDist & theOther);
912
913 Standard_Boolean CheckInputData(Standard_Real theParam)
914 {
915 if (theParam < myCurve->FirstParameter() ||
916 theParam > myCurve->LastParameter())
917 return Standard_False;
918 return Standard_True;
919 }
920
921 const Handle(Geom_Curve)& myCurve;
922 const Handle(Geom_BSplineCurve)& myPnts;
923};
924
3492f422
PA
925
926static void ComputeDeviation(const Handle(Geom_Curve)& theCurve,
927 const Handle(Geom_BSplineCurve)& thePnts,
928 Standard_Real& theDmax,
929 Standard_Real& theUfMax,
930 Standard_Real& theUlMax,
931 Standard_Integer& theImax)
932{
933 theDmax = 0.;
934 theUfMax = 0.;
935 theUlMax = 0.;
936 theImax = 0;
3492f422
PA
937
938 //take knots
939 Standard_Integer nbp = thePnts->NbKnots();
940 TColStd_Array1OfReal aKnots(1, nbp);
941 thePnts->Knots(aKnots);
edbf88ba 942 math_Vector aLowBorder(1,1);
943 math_Vector aUppBorder(1,1);
944 math_Vector aSteps(1,1);
3492f422
PA
945
946 Standard_Integer i;
edbf88ba 947 for(i = 1; i < nbp; ++i)
948 {
949 aLowBorder(1) = aKnots(i);
950 aUppBorder(1) = aKnots(i+1);
951 aSteps(1) =(aUppBorder(1) - aLowBorder(1)) * 0.01; // Run PSO on even distribution with 100 points.
952
953 Standard_Real aValue;
954 math_Vector aT(1,1);
955 aMaxCCDist aFunc(theCurve, thePnts);
956 math_PSO aFinder(&aFunc, aLowBorder, aUppBorder, aSteps); // Choose 32 best points from 100 above.
957 aFinder.Perform(aSteps, aValue, aT);
958 Standard_Real d = 0.;
959
960 math_NewtonMinimum anOptLoc(aFunc);
961 anOptLoc.Perform(aFunc, aT);
962
963 if (anOptLoc.IsDone())
964 {
965 d = -anOptLoc.Minimum();
966 if(d > theDmax)
967 {
3492f422 968 theDmax = d;
edbf88ba 969 theUfMax = aLowBorder(1);
970 theUlMax = aUppBorder(1);
971 theImax = i;
3492f422
PA
972 }
973 }
974 }
edbf88ba 975 theDmax = Sqrt(theDmax); // Convert to Euclidean distance.
3492f422
PA
976}
977
978
7fd59977 979//=======================================================================
980//function : crvpoints
981//purpose :
982//=======================================================================
983
984static Standard_Integer crvpoints (Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
985{
986 Standard_Integer i, nbp;
987 Standard_Real defl;
988
989 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
91322f44 990 defl = Draw::Atof(a[3]);
7fd59977 991
992 GeomAdaptor_Curve GAC(C);
7fd59977 993 GCPnts_QuasiUniformDeflection PntGen(GAC, defl);
3492f422 994
7fd59977 995 if(!PntGen.IsDone()) {
996 di << "Points generation failed" << "\n";
997 return 1;
998 }
999
1000 nbp = PntGen.NbPoints();
1001 di << "Nb points : " << nbp << "\n";
1002
1003 TColgp_Array1OfPnt aPoles(1, nbp);
1004 TColStd_Array1OfReal aKnots(1, nbp);
1005 TColStd_Array1OfInteger aMults(1, nbp);
1006
1007 for(i = 1; i <= nbp; ++i) {
1008 aPoles(i) = PntGen.Value(i);
1009 aKnots(i) = PntGen.Parameter(i);
1010 aMults(i) = 1;
1011 }
1012
1013 aMults(1) = 2;
1014 aMults(nbp) = 2;
1015
1016 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
1017 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
1018
1019 aDrCrv->ClearPoles();
1020 Draw_Color aKnColor(Draw_or);
1021 aDrCrv->SetKnotsColor(aKnColor);
1022 aDrCrv->SetKnotsShape(Draw_Plus);
1023
1024 Draw::Set(a[1], aDrCrv);
1025
1026 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
1027 Standard_Integer imax = 0;
1028
3492f422
PA
1029 //check deviation
1030 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
edbf88ba 1031 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
7fd59977 1032
3492f422
PA
1033 return 0;
1034}
7fd59977 1035
3492f422
PA
1036//=======================================================================
1037//function : crvtpoints
1038//purpose :
1039//=======================================================================
7fd59977 1040
3492f422
PA
1041static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, const char** a)
1042{
1043 Standard_Integer i, nbp;
1044 Standard_Real defl, angle = Precision::Angular();
1045
1046 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
91322f44 1047 defl = Draw::Atof(a[3]);
3492f422
PA
1048
1049 if(n > 3)
91322f44 1050 angle = Draw::Atof(a[4]);
3492f422
PA
1051
1052 GeomAdaptor_Curve GAC(C);
1053 GCPnts_TangentialDeflection PntGen(GAC, angle, defl, 2);
1054
1055 nbp = PntGen.NbPoints();
1056 di << "Nb points : " << nbp << "\n";
1057
1058 TColgp_Array1OfPnt aPoles(1, nbp);
1059 TColStd_Array1OfReal aKnots(1, nbp);
1060 TColStd_Array1OfInteger aMults(1, nbp);
1061
1062 for(i = 1; i <= nbp; ++i) {
1063 aPoles(i) = PntGen.Value(i);
1064 aKnots(i) = PntGen.Parameter(i);
1065 aMults(i) = 1;
7fd59977 1066 }
3492f422
PA
1067
1068 aMults(1) = 2;
1069 aMults(nbp) = 2;
7fd59977 1070
3492f422
PA
1071 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
1072 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
1073
1074 aDrCrv->ClearPoles();
1075 Draw_Color aKnColor(Draw_or);
1076 aDrCrv->SetKnotsColor(aKnColor);
1077 aDrCrv->SetKnotsShape(Draw_Plus);
1078
1079 Draw::Set(a[1], aDrCrv);
1080
1081 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
1082 Standard_Integer imax = 0;
1083
1084 //check deviation
1085 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
edbf88ba 1086 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
7fd59977 1087
1088 return 0;
1089}
7fd59977 1090//=======================================================================
1091//function : uniformAbscissa
1092//purpose : epa test (TATA-06-002 (Problem with GCPnts_UniformAbscissa class)
1093//=======================================================================
1094static Standard_Integer uniformAbscissa (Draw_Interpretor& di, Standard_Integer n, const char** a)
1095{
1096 if( n != 3 )
1097 return 1;
1098
1099 /*Handle(Geom_BSplineCurve) ellip;
1100 ellip = DrawTrSurf::GetBSplineCurve(a[1]);
1101 if (ellip.IsNull())
1102 {
1103 di << " BSpline is NULL "<<"\n";
1104 return 1;
1105 }*/
1106
1107 Handle(Geom_Curve) ellip;
1108 ellip = DrawTrSurf::GetCurve(a[1]);
1109 if (ellip.IsNull())
1110 {
1111 di << " Curve is NULL "<<"\n";
1112 return 1;
1113 }
1114
1115 Standard_Integer nocp;
91322f44 1116 nocp = Draw::Atoi(a[2]);
7fd59977 1117 if(nocp < 2)
1118 return 1;
1119
1120
1121 //test nbPoints for Geom_Ellipse
1122
1123 try
1124 {
1125 GeomLProp_CLProps Prop(ellip,2,Precision::Intersection());
1126 Prop.SetCurve(ellip);
1127
1128 GeomAdaptor_Curve GAC(ellip);
1129 di<<"Type Of curve: "<<GAC.GetType()<<"\n";
1130 Standard_Real Tol = Precision::Confusion();
1131 Standard_Real L;
1132
1133 L = GCPnts_AbscissaPoint::Length(GAC, GAC.FirstParameter(), GAC.LastParameter(), Tol);
1134 di<<"Ellipse length = "<<L<<"\n";
1135 Standard_Real Abscissa = L/(nocp-1);
1136 di << " CUR : Abscissa " << Abscissa << "\n";
1137
1138 GCPnts_UniformAbscissa myAlgo(GAC, Abscissa, ellip->FirstParameter(), ellip->LastParameter());
1139 if ( myAlgo.IsDone() )
1140 {
1141 di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n";
1142 for(Standard_Integer i = 1; i<= myAlgo.NbPoints(); i++ )
1143 di << i <<" points = " << myAlgo.Parameter( i ) << "\n";
1144 }
1145 }
1146
1147 catch (Standard_Failure )
1148 {
1149 di << " Standard Failure " <<"\n";
1150 }
1151 return 0;
1152}
1153
1154//=======================================================================
1155//function : EllipsUniformAbscissa
1156//purpose : epa test (TATA-06-002 (Problem with GCPnts_UniformAbscissa class)
1157//=======================================================================
1158static Standard_Integer EllipsUniformAbscissa (Draw_Interpretor& di, Standard_Integer n, const char** a)
1159{
1160 if( n != 4 )
1161 return 1;
1162
1163 Standard_Real R1;
91322f44 1164 R1 = Draw::Atof(a[1]);
7fd59977 1165 Standard_Real R2;
91322f44 1166 R2 = Draw::Atof(a[2]);
7fd59977 1167
1168 Standard_Integer nocp;
91322f44 1169 nocp = Draw::Atoi(a[3]);
7fd59977 1170 if(nocp < 2)
1171 return 1;
1172
1173 //test nbPoints for Geom_Ellipse
857ffd5e 1174 Handle(Geom_Ellipse) ellip;
7fd59977 1175
1176
1177 try
1178 {
1179 gp_Pnt location;
1180 location = gp_Pnt( 0.0, 0.0, 0.0);
1181 gp_Dir main_direction(0.0, 0.0, 1.0);
1182
1183 gp_Dir x_direction(1.0, 0.0, 0.0);
1184 gp_Ax2 mainaxis( location, main_direction);
1185
1186 mainaxis.SetXDirection(x_direction);
1187 ellip = new Geom_Ellipse(mainaxis,R1, R2);
1188
1189 BRepBuilderAPI_MakeEdge curve_edge(ellip);
1190 TopoDS_Edge edge_curve = curve_edge.Edge();
1191
1192 DBRep::Set("Ellipse",edge_curve);
1193 }
1194
1195 catch(Standard_Failure)
1196 {
1197 di << " Standard Failure "<<"\n";
1198 }
1199
1200 try
1201 {
1202 GeomLProp_CLProps Prop(ellip,2,Precision::Intersection());
1203 Prop.SetCurve(ellip);
1204
1205 GeomAdaptor_Curve GAC(ellip);
1206 di<<"Type Of curve: "<<GAC.GetType()<<"\n";
1207 Standard_Real Tol = Precision::Confusion();
1208 Standard_Real L;
1209
1210 L = GCPnts_AbscissaPoint::Length(GAC, GAC.FirstParameter(), GAC.LastParameter(), Tol);
1211 di<<"Ellipse length = "<<L<<"\n";
1212 Standard_Real Abscissa = L/(nocp-1);
1213 di << " CUR : Abscissa " << Abscissa << "\n";
1214
1215 GCPnts_UniformAbscissa myAlgo(GAC, Abscissa, ellip->FirstParameter(), ellip->LastParameter());
1216 if ( myAlgo.IsDone() )
1217 {
1218 di << " CasCurve - nbpoints " << myAlgo.NbPoints() << "\n";
1219 for(Standard_Integer i = 1; i<= myAlgo.NbPoints(); i++ )
1220 di << i <<" points = " << myAlgo.Parameter( i ) << "\n";
1221 }
1222 }
1223
1224 catch (Standard_Failure )
1225 {
1226 di << " Standard Failure " <<"\n";
1227 }
1228 return 0;
1229}
1230
1231//=======================================================================
bb0e6b9b 1232//function : discrCurve
1233//purpose :
1234//=======================================================================
1235static Standard_Integer discrCurve(Draw_Interpretor& di, Standard_Integer theArgNb, const char** theArgVec)
1236{
1237 if (theArgNb < 3)
1238 {
1239 di << "Invalid number of parameters.\n";
1240 return 1;
1241 }
1242
1243 Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(theArgVec[2]);
1244 if (aCurve.IsNull())
1245 {
1246 di << "Curve is NULL.\n";
1247 return 1;
1248 }
1249
1250 Standard_Integer aSrcNbPnts = 0;
1251 Standard_Boolean isUniform = Standard_False;
1252 for (Standard_Integer anArgIter = 3; anArgIter < theArgNb; ++anArgIter)
1253 {
1254 TCollection_AsciiString anArg (theArgVec[anArgIter]);
1255 TCollection_AsciiString anArgCase (anArg);
1256 anArgCase.LowerCase();
1257 if (anArgCase == "nbpnts")
1258 {
1259 if (++anArgIter >= theArgNb)
1260 {
1261 di << "Value for argument '" << anArg << "' is absent.\n";
1262 return 1;
1263 }
1264
1265 aSrcNbPnts = Draw::Atoi (theArgVec[anArgIter]);
1266 }
1267 else if (anArgCase == "uniform")
1268 {
1269 if (++anArgIter >= theArgNb)
1270 {
1271 di << "Value for argument '" << anArg << "' is absent.\n";
1272 return 1;
1273 }
1274
1275 isUniform = (Draw::Atoi (theArgVec[anArgIter]) == 1);
1276 }
1277 else
1278 {
1279 di << "Invalid argument '" << anArg << "'.\n";
1280 return 1;
1281 }
1282 }
1283
1284 if (aSrcNbPnts < 2)
1285 {
1286 di << "Invalid count of points.\n";
1287 return 1;
1288 }
1289
1290 if (!isUniform)
1291 {
1292 di << "Invalid type of discretization.\n";
1293 return 1;
1294 }
1295
1296 GeomAdaptor_Curve aCurveAdaptor(aCurve);
1297 GCPnts_UniformAbscissa aSplitter(aCurveAdaptor, aSrcNbPnts, Precision::Confusion());
1298 if (!aSplitter.IsDone())
1299 {
1300 di << "Error: Invalid result.\n";
1301 return 0;
1302 }
1303
1304 const Standard_Integer aDstNbPnts = aSplitter.NbPoints();
1305
1306 if (aDstNbPnts < 2)
1307 {
1308 di << "Error: Invalid result.\n";
1309 return 0;
1310 }
1311
1312 TColgp_Array1OfPnt aPoles(1, aDstNbPnts);
1313 TColStd_Array1OfReal aKnots(1, aDstNbPnts);
1314 TColStd_Array1OfInteger aMultiplicities(1, aDstNbPnts);
1315
1316 for (Standard_Integer aPntIter = 1; aPntIter <= aDstNbPnts; ++aPntIter)
1317 {
1318 aPoles.ChangeValue(aPntIter) = aCurveAdaptor.Value(aSplitter.Parameter(aPntIter));
1319 aKnots.ChangeValue(aPntIter) = (aPntIter - 1) / (aDstNbPnts - 1.0);
1320 aMultiplicities.ChangeValue(aPntIter) = 1;
1321 }
1322 aMultiplicities.ChangeValue(1) = 2;
1323 aMultiplicities.ChangeValue(aDstNbPnts) = 2;
1324
1325 Handle(Geom_BSplineCurve) aPolyline =
1326 new Geom_BSplineCurve(aPoles, aKnots, aMultiplicities, 1);
1327 DrawTrSurf::Set(theArgVec[1], aPolyline);
1328
1329 return 0;
1330}
1331
1332//=======================================================================
7fd59977 1333//function : mypoints
1334//purpose :
1335//=======================================================================
1336
1337static Standard_Integer mypoints (Draw_Interpretor& di, Standard_Integer /*n*/, const char** a)
1338{
1339 Standard_Integer i, nbp;
1340 Standard_Real defl;
1341
1342 Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
91322f44 1343 defl = Draw::Atof(a[3]);
c5f3a425 1344 Handle(Geom_BSplineCurve) aBS (Handle(Geom_BSplineCurve)::DownCast(C));
7fd59977 1345
1346 if(aBS.IsNull()) return 1;
1347
1348 Standard_Integer ui1 = aBS->FirstUKnotIndex();
1349 Standard_Integer ui2 = aBS->LastUKnotIndex();
1350
1351 Standard_Integer nbsu = ui2-ui1+1; nbsu += (nbsu - 1) * (aBS->Degree()-1);
1352
1353 TColStd_Array1OfReal anUPars(1, nbsu);
1354 TColStd_Array1OfBoolean anUFlg(1, nbsu);
1355
1356 Standard_Integer j, k, nbi;
1357 Standard_Real t1, t2, dt;
1358
1359 //Filling of sample parameters
1360 nbi = aBS->Degree();
1361 k = 0;
1362 t1 = aBS->Knot(ui1);
1363 for(i = ui1+1; i <= ui2; ++i) {
1364 t2 = aBS->Knot(i);
1365 dt = (t2 - t1)/nbi;
1366 j = 1;
1367 do {
1368 ++k;
1369 anUPars(k) = t1;
1370 anUFlg(k) = Standard_False;
1371 t1 += dt;
1372 }
1373 while (++j <= nbi);
1374 t1 = t2;
1375 }
1376 ++k;
1377 anUPars(k) = t1;
1378
1379 Standard_Integer l;
1380 defl *= defl;
1381
1382 j = 1;
1383 anUFlg(1) = Standard_True;
1384 anUFlg(nbsu) = Standard_True;
1385 Standard_Boolean bCont = Standard_True;
1386 while (j < nbsu-1 && bCont) {
1387 t2 = anUPars(j);
1388 gp_Pnt p1 = aBS->Value(t2);
1389 for(k = j+2; k <= nbsu; ++k) {
1390 t2 = anUPars(k);
1391 gp_Pnt p2 = aBS->Value(t2);
1392 gce_MakeLin MkLin(p1, p2);
1393 const gp_Lin& lin = MkLin.Value();
1394 Standard_Boolean ok = Standard_True;
1395 for(l = j+1; l < k; ++l) {
1396 if(anUFlg(l)) continue;
1397 gp_Pnt pp = aBS->Value(anUPars(l));
1398 Standard_Real d = lin.SquareDistance(pp);
1399
1400 if(d <= defl) continue;
1401
1402 ok = Standard_False;
1403 break;
1404 }
1405
1406
1407 if(!ok) {
1408 j = k - 1;
1409 anUFlg(j) = Standard_True;
1410 break;
1411 }
1412
1413 }
1414
1415 if(k >= nbsu) bCont = Standard_False;
1416 }
1417
1418 nbp = 0;
1419 for(i = 1; i <= nbsu; ++i) {
1420 if(anUFlg(i)) nbp++;
1421 }
1422
1423 TColgp_Array1OfPnt aPoles(1, nbp);
1424 TColStd_Array1OfReal aKnots(1, nbp);
1425 TColStd_Array1OfInteger aMults(1, nbp);
1426 j = 0;
1427 for(i = 1; i <= nbsu; ++i) {
1428 if(anUFlg(i)) {
1429 ++j;
1430 aKnots(j) = anUPars(i);
1431 aMults(j) = 1;
1432 aPoles(j) = aBS->Value(aKnots(j));
1433 }
1434 }
1435
1436 aMults(1) = 2;
1437 aMults(nbp) = 2;
1438
1439 Handle(Geom_BSplineCurve) aPnts = new Geom_BSplineCurve(aPoles, aKnots, aMults, 1);
1440 Handle(DrawTrSurf_BSplineCurve) aDrCrv = new DrawTrSurf_BSplineCurve(aPnts);
1441
1442 aDrCrv->ClearPoles();
1443 Draw_Color aKnColor(Draw_or);
1444 aDrCrv->SetKnotsColor(aKnColor);
1445 aDrCrv->SetKnotsShape(Draw_Plus);
1446
1447 Draw::Set(a[1], aDrCrv);
1448
6e6cd5d9 1449 Standard_Real dmax = 0., ufmax = 0., ulmax = 0.;
7fd59977 1450 Standard_Integer imax = 0;
1451
3492f422 1452 ComputeDeviation(C,aPnts,dmax,ufmax,ulmax,imax);
7fd59977 1453 di << "Max defl: " << dmax << " " << ufmax << " " << ulmax << " " << imax << "\n";
1454
1455 return 0;
1456}
1457
1458
1459
1460//=======================================================================
1461//function : surfpoints
1462//purpose :
1463//=======================================================================
1464
1465static Standard_Integer surfpoints (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char** a)
1466{
1467 Standard_Integer i;
1468 Standard_Real defl;
1469
1470 Handle(Geom_Surface) S = DrawTrSurf::GetSurface(a[2]);
91322f44 1471 defl = Draw::Atof(a[3]);
7fd59977 1472
1473 Handle(GeomAdaptor_HSurface) AS = new GeomAdaptor_HSurface(S);
1474
1475 Handle(Adaptor3d_TopolTool) aTopTool = new Adaptor3d_TopolTool(AS);
1476
1477 aTopTool->SamplePnts(defl, 10, 10);
1478
1479 Standard_Integer nbpu = aTopTool->NbSamplesU();
1480 Standard_Integer nbpv = aTopTool->NbSamplesV();
1481 TColStd_Array1OfReal Upars(1, nbpu), Vpars(1, nbpv);
1482 aTopTool->UParameters(Upars);
1483 aTopTool->VParameters(Vpars);
1484
1485 TColgp_Array2OfPnt aPoles(1, nbpu, 1, nbpv);
1486 TColStd_Array1OfReal anUKnots(1, nbpu);
1487 TColStd_Array1OfReal aVKnots(1, nbpv);
1488 TColStd_Array1OfInteger anUMults(1, nbpu);
1489 TColStd_Array1OfInteger aVMults(1, nbpv);
1490
1491 Standard_Integer j;
1492 for(i = 1; i <= nbpu; ++i) {
1493 anUKnots(i) = Upars(i);
1494 anUMults(i) = 1;
1495 for(j = 1; j <= nbpv; ++j) {
1496 aVKnots(j) = Vpars(j);
1497 aVMults(j) = 1;
1498 aPoles(i,j) = S->Value(anUKnots(i),aVKnots(j));
1499 }
1500 }
1501
1502 anUMults(1) = 2;
1503 anUMults(nbpu) = 2;
1504 aVMults(1) = 2;
1505 aVMults(nbpv) = 2;
1506
1507 Handle(Geom_BSplineSurface) aPnts = new Geom_BSplineSurface(aPoles, anUKnots, aVKnots,
1508 anUMults, aVMults, 1, 1);
1509 Handle(DrawTrSurf_BSplineSurface) aDrSurf = new DrawTrSurf_BSplineSurface(aPnts);
1510
1511 aDrSurf->ClearPoles();
1512 Draw_Color aKnColor(Draw_or);
1513 aDrSurf->SetKnotsColor(aKnColor);
1514 aDrSurf->SetKnotsShape(Draw_Plus);
1515
1516 Draw::Set(a[1], aDrSurf);
1517
1518
1519 return 0;
1520}
1521
1522
1523
1524//=======================================================================
1525//function : intersect
1526//purpose :
1527//=======================================================================
b92f3572 1528static Standard_Integer intersection (Draw_Interpretor& di,
1529 Standard_Integer n, const char** a)
1530{
32ca7a51 1531 if (n < 4)
c5c34473 1532 return 1;
b92f3572 1533
c5c34473 1534 //
7fd59977 1535 Handle(Geom_Curve) GC1;
1536 Handle(Geom_Surface) GS1 = DrawTrSurf::GetSurface(a[2]);
32ca7a51 1537 if (GS1.IsNull())
b92f3572 1538 {
7fd59977 1539 GC1 = DrawTrSurf::GetCurve(a[2]);
1540 if (GC1.IsNull())
1541 return 1;
b92f3572 1542 }
32ca7a51 1543
c5c34473 1544 //
7fd59977 1545 Handle(Geom_Surface) GS2 = DrawTrSurf::GetSurface(a[3]);
32ca7a51 1546 if (GS2.IsNull())
c5c34473 1547 return 1;
32ca7a51 1548
c5c34473 1549 //
7fd59977 1550 Standard_Real tol = Precision::Confusion();
32ca7a51 1551 if (n == 5 || n == 9 || n == 13 || n == 17)
1552 tol = Draw::Atof(a[n-1]);
1553
c5c34473 1554 //
7fd59977 1555 Handle(Geom_Curve) Result;
1556 gp_Pnt Point;
b92f3572 1557
c5c34473 1558 //
32ca7a51 1559 if (GC1.IsNull())
b92f3572 1560 {
c5c34473
J
1561 GeomInt_IntSS Inters;
1562 //
7fd59977 1563 // Surface Surface
32ca7a51 1564 if (n <= 5)
b92f3572 1565 {
7fd59977 1566 // General case
c5c34473 1567 Inters.Perform(GS1,GS2,tol,Standard_True);
b92f3572 1568 }
32ca7a51 1569 else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
b92f3572 1570 {
7fd59977 1571 Standard_Boolean useStart = Standard_True, useBnd = Standard_True;
1572 Standard_Integer ista1=0,ista2=0,ibnd1=0,ibnd2=0;
1573 Standard_Real UVsta[4];
1574 Handle(GeomAdaptor_HSurface) AS1,AS2;
b92f3572 1575
c5c34473 1576 //
32ca7a51 1577 if (n <= 9) // user starting point
b92f3572 1578 {
7fd59977 1579 useBnd = Standard_False;
32ca7a51 1580 ista1 = 4;
1581 ista2 = 7;
b92f3572 1582 }
32ca7a51 1583 else if (n <= 13) // user bounding
b92f3572 1584 {
7fd59977 1585 useStart = Standard_False;
1586 ibnd1 = 4; ibnd2 = 11;
b92f3572 1587 }
32ca7a51 1588 else // both user starting point and bounding
b92f3572 1589 {
7fd59977 1590 ista1 = 4; ista2 = 7;
1591 ibnd1 = 8; ibnd2 = 15;
b92f3572 1592 }
32ca7a51 1593
7fd59977 1594 if (useStart)
b92f3572 1595 {
7fd59977 1596 for (Standard_Integer i=ista1; i <= ista2; i++)
b92f3572 1597 {
91322f44 1598 UVsta[i-ista1] = Draw::Atof(a[i]);
32ca7a51 1599 }
b92f3572 1600 }
32ca7a51 1601
1602 if (useBnd)
b92f3572 1603 {
7fd59977 1604 Standard_Real UVbnd[8];
1605 for (Standard_Integer i=ibnd1; i <= ibnd2; i++)
91322f44 1606 UVbnd[i-ibnd1] = Draw::Atof(a[i]);
32ca7a51 1607
7fd59977 1608 AS1 = new GeomAdaptor_HSurface(GS1,UVbnd[0],UVbnd[1],UVbnd[2],UVbnd[3]);
1609 AS2 = new GeomAdaptor_HSurface(GS2,UVbnd[4],UVbnd[5],UVbnd[6],UVbnd[7]);
b92f3572 1610 }
32ca7a51 1611
c5c34473 1612 //
32ca7a51 1613 if (useStart && !useBnd)
b92f3572 1614 {
7fd59977 1615 Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
b92f3572 1616 }
32ca7a51 1617 else if (!useStart && useBnd)
b92f3572 1618 {
c5c34473 1619 Inters.Perform(AS1,AS2,tol);
b92f3572 1620 }
32ca7a51 1621 else
b92f3572 1622 {
c5c34473 1623 Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3]);
b92f3572 1624 }
1625 }//else if (n == 8 || n == 9 || n == 12 || n == 13 || n == 16 || n == 17)
32ca7a51 1626 else
b92f3572 1627 {
7fd59977 1628 di<<"incorrect number of arguments"<<"\n";
1629 return 1;
b92f3572 1630 }
32ca7a51 1631
c5c34473 1632 //
32ca7a51 1633 if (!Inters.IsDone())
b92f3572 1634 {
32ca7a51 1635 di<<"No intersections found!"<<"\n";
1636
c5c34473 1637 return 1;
b92f3572 1638 }
1639
c5c34473
J
1640 //
1641 char buf[1024];
1642 Standard_Integer i, aNbLines, aNbPoints;
b92f3572 1643
32ca7a51 1644 //
c5c34473 1645 aNbLines = Inters.NbLines();
32ca7a51 1646 if (aNbLines >= 2)
b92f3572 1647 {
32ca7a51 1648 for (i=1; i<=aNbLines; ++i)
b92f3572 1649 {
32ca7a51 1650 Sprintf(buf, "%s_%d",a[1],i);
1651 di << buf << " ";
1652 Result = Inters.Line(i);
1653 const char* temp = buf;
1654 DrawTrSurf::Set(temp,Result);
c5c34473 1655 }
b92f3572 1656 }
32ca7a51 1657 else if (aNbLines == 1)
b92f3572 1658 {
c5c34473 1659 Result = Inters.Line(1);
32ca7a51 1660 Sprintf(buf,"%s",a[1]);
1661 di << buf << " ";
c5c34473
J
1662 DrawTrSurf::Set(a[1],Result);
1663 }
32ca7a51 1664
c5c34473
J
1665 //
1666 aNbPoints=Inters.NbPoints();
32ca7a51 1667 for (i=1; i<=aNbPoints; ++i)
b92f3572 1668 {
c5c34473 1669 Point=Inters.Point(i);
91322f44 1670 Sprintf(buf,"%s_p_%d",a[1],i);
32ca7a51 1671 di << buf << " ";
1672 const char* temp = buf;
c5c34473 1673 DrawTrSurf::Set(temp, Point);
b92f3572 1674 }
1675 }// if (GC1.IsNull())
32ca7a51 1676 else
b92f3572 1677 {
7fd59977 1678 // Curve Surface
1679 GeomAPI_IntCS Inters(GC1,GS2);
b92f3572 1680
32ca7a51 1681 //
1682 if (!Inters.IsDone())
b92f3572 1683 {
32ca7a51 1684 di<<"No intersections found!"<<"\n";
1685 return 1;
b92f3572 1686 }
32ca7a51 1687
7fd59977 1688 Standard_Integer nblines = Inters.NbSegments();
1689 Standard_Integer nbpoints = Inters.NbPoints();
32ca7a51 1690
1691 char newname[1024];
1692
1693 if ( (nblines+nbpoints) >= 2)
b92f3572 1694 {
7fd59977 1695 Standard_Integer i;
1696 Standard_Integer Compt = 1;
32ca7a51 1697
1698 if(nblines >= 1)
1699 cout << " Lines: " << endl;
1700
1701 for (i = 1; i <= nblines; i++, Compt++)
b92f3572 1702 {
32ca7a51 1703 Sprintf(newname,"%s_%d",a[1],Compt);
1704 di << newname << " ";
1705 Result = Inters.Segment(i);
1706 const char* temp = newname; // pour portage WNT
1707 DrawTrSurf::Set(temp,Result);
b92f3572 1708 }
32ca7a51 1709
1710 if(nbpoints >= 1)
1711 cout << " Points: " << endl;
1712
1713 const Standard_Integer imax = nblines+nbpoints;
1714
1715 for (/*i = 1*/; i <= imax; i++, Compt++)
b92f3572 1716 {
32ca7a51 1717 Sprintf(newname,"%s_%d",a[1],i);
1718 di << newname << " ";
1719 Point = Inters.Point(i);
1720 const char* temp = newname; // pour portage WNT
1721 DrawTrSurf::Set(temp,Point);
7fd59977 1722 }
b92f3572 1723 }
32ca7a51 1724 else if (nblines == 1)
b92f3572 1725 {
7fd59977 1726 Result = Inters.Segment(1);
32ca7a51 1727 Sprintf(newname,"%s",a[1]);
1728 di << newname << " ";
7fd59977 1729 DrawTrSurf::Set(a[1],Result);
b92f3572 1730 }
32ca7a51 1731 else if (nbpoints == 1)
b92f3572 1732 {
7fd59977 1733 Point = Inters.Point(1);
32ca7a51 1734 Sprintf(newname,"%s",a[1]);
1735 di << newname << " ";
7fd59977 1736 DrawTrSurf::Set(a[1],Point);
1737 }
b92f3572 1738 }
7fd59977 1739
1740 dout.Flush();
1741 return 0;
b92f3572 1742}
7fd59977 1743
1744//=======================================================================
9e20ed57 1745//function : GetCurveContinuity
1746//purpose : Returns the continuity of the given curve
1747//=======================================================================
1748static Standard_Integer GetCurveContinuity( Draw_Interpretor& theDI,
1749 Standard_Integer theNArg,
1750 const char** theArgv)
1751{
1752 if(theNArg != 2)
1753 {
1754 theDI << "Use: getcurvcontinuity {curve or 2dcurve} \n";
1755 return 1;
1756 }
1757
1758 char aContName[7][3] = {"C0", //0
1759 "G1", //1
1760 "C1", //2
1761 "G2", //3
1762 "C2", //4
1763 "C3", //5
1764 "CN"}; //6
1765
1766 Handle(Geom2d_Curve) GC2d;
1767 Handle(Geom_Curve) GC3d = DrawTrSurf::GetCurve(theArgv[1]);
1768 if(GC3d.IsNull())
1769 {
1770 GC2d = DrawTrSurf::GetCurve2d(theArgv[1]);
1771 if(GC2d.IsNull())
1772 {
1773 theDI << "Argument is not a 2D or 3D curve!\n";
1774 return 1;
1775 }
1776 else
1777 {
1778 theDI << theArgv[1] << " has " << aContName[GC2d->Continuity()] << " continuity.\n";
1779 }
1780 }
1781 else
1782 {
1783 theDI << theArgv[1] << " has " << aContName[GC3d->Continuity()] << " continuity.\n";
1784 }
1785
1786 return 0;
1787}
1788
1789//=======================================================================
7fd59977 1790//function : CurveCommands
1791//purpose :
1792//=======================================================================
7fd59977 1793void GeometryTest::CurveCommands(Draw_Interpretor& theCommands)
1794{
1795
1796 static Standard_Boolean loaded = Standard_False;
1797 if (loaded) return;
1798 loaded = Standard_True;
1799
1800 DrawTrSurf::BasicCommands(theCommands);
1801
1802 const char* g;
1803
1804 g = "GEOMETRY curves creation";
1805
1806 theCommands.Add("law",
1807 "law name degree nbknots knot, umult value",
1808 __FILE__,
1809 polelaw,g);
1810
1811 theCommands.Add("to2d","to2d c2dname c3d [plane (XOY)]",
1812 __FILE__,
1813 to2d,g);
1814
1815 theCommands.Add("to3d","to3d c3dname c2d [plane (XOY)]",
1816 __FILE__,
1817 to3d,g);
1818
1819 theCommands.Add("gproject",
1820 "gproject : [projectname] curve surface",
1821 __FILE__,
1822 gproject,g);
1823
1824 theCommands.Add("project",
1825 "project : no args to have help",
1826 __FILE__,
1827 project,g);
1828
1829 theCommands.Add("projonplane",
1830 "projonplane r C3d Plane [dx dy dz] [0/1]",
1831 projonplane);
1832
1833 theCommands.Add("bisec",
1834 "bisec result line/circle/point line/circle/point",
1835 __FILE__,
1836 bisec, g);
1837
1838 g = "GEOMETRY Curves and Surfaces modification";
1839
1840
1841 theCommands.Add("movelaw",
1842 "movelaw name u x tx [ constraint = 0]",
1843 __FILE__,
1844 movelaw,g) ;
1845
1846
1847
1848 g = "GEOMETRY intersections";
1849
1850 theCommands.Add("intersect",
1851 "intersect result surf1/curv1 surf2 [tolerance]\n\t\t "
1852 "intersect result surf1 surf2 [u1 v1 u2 v2] [U1F U1L V1F V1L U2F U2L V2F V2L] [tolerance]",
1853 __FILE__,
1854 intersection,g);
1855
1856 theCommands.Add("crvpoints",
1857 "crvpoints result curv deflection",
1858 __FILE__,
1859 crvpoints,g);
3492f422
PA
1860
1861 theCommands.Add("crvtpoints",
1862 "crvtpoints result curv deflection angular deflection - tangential deflection points",
1863 __FILE__,
1864 crvtpoints,g);
7fd59977 1865
1866 theCommands.Add("uniformAbscissa",
1867 "uniformAbscissa Curve nbPnt",
1868 __FILE__,
1869 uniformAbscissa,g);
1870
1871 theCommands.Add("uniformAbscissaEl",
1872 "uniformAbscissaEl maxR minR nbPnt",
1873 __FILE__, EllipsUniformAbscissa,g);
1874
bb0e6b9b 1875 theCommands.Add("discrCurve",
1876 "discrCurve polyline curve params\n"
1877 "Approximates a curve by a polyline (first degree B-spline).\n"
1878 "nbPnts number - creates polylines with the number points\n"
1879 "uniform 0 | 1 - creates polyline with equal length segments",
1880 __FILE__, discrCurve, g);
1881
7fd59977 1882 theCommands.Add("mypoints",
1883 "mypoints result curv deflection",
1884 __FILE__,
1885 mypoints,g);
1886 theCommands.Add("surfpoints",
1887 "surfoints result surf deflection",
1888 __FILE__,
1889 surfpoints,g);
1890
9e20ed57 1891 theCommands.Add("getcurvcontinuity",
1892 "getcurvcontinuity {curve or 2dcurve}: \n\tReturns the continuity of the given curve",
1893 __FILE__,
1894 GetCurveContinuity,g);
1895
1896
7fd59977 1897}
1898