0023024: Update headers of OCCT files
[occt.git] / src / GeomliteTest / GeomliteTest_CurveCommands.cxx
1 // Created on: 1993-08-12
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21 // Modified by xab, Tue Mar 11 18:31:18 1997
22 // Modified by PMN 14/04/97 : Passage a Geomlite
23 // Modified by JPI 01/08/97 : ajout de la commande approxcurve
24
25 #include <GeomliteTest.hxx>
26 #include <Draw_Appli.hxx>
27 #include <DrawTrSurf.hxx>
28 #include <DrawTrSurf_Curve.hxx>
29 #include <DrawTrSurf_Curve2d.hxx>
30 #include <DrawTrSurf_BezierCurve.hxx>
31 #include <DrawTrSurf_BSplineCurve.hxx>
32 #include <DrawTrSurf_BezierCurve2d.hxx>
33 #include <DrawTrSurf_BSplineCurve2d.hxx>
34 #include <Draw_Marker3D.hxx>
35 #include <Draw_Marker2D.hxx>
36 #include <Draw.hxx>
37 #include <Draw_Interpretor.hxx>
38 #include <Draw_Color.hxx>
39 #include <Draw_Display.hxx>
40
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 <Geom_BezierCurve.hxx>
55 #include <Geom_BSplineCurve.hxx>
56 #include <GeomAdaptor_Surface.hxx>
57 #include <GeomAdaptor_HSurface.hxx>
58
59 #include <GeomLib.hxx>
60 #include <GeomConvert.hxx>
61 #include <Geom2dConvert.hxx>
62
63 #include <Geom2d_Line.hxx>
64 #include <Geom2d_Circle.hxx>
65 #include <Geom2d_Ellipse.hxx>
66 #include <Geom2d_Parabola.hxx>
67 #include <Geom2d_Hyperbola.hxx>
68 #include <Geom2d_BezierCurve.hxx>
69 #include <Geom2d_BSplineCurve.hxx>
70
71 #include <GeomLProp.hxx>
72 #include <GeomLProp_CLProps.hxx>
73 #include <Geom2dLProp_CLProps2d.hxx>
74 #include <Geom2dLProp_CurAndInf2d.hxx>
75
76 #include <TColgp_Array1OfPnt.hxx>
77 #include <TColgp_Array1OfPnt2d.hxx>
78 #include <TColStd_Array1OfReal.hxx>
79 #include <TColStd_Array1OfInteger.hxx>
80
81 #include <GeomAbs_SurfaceType.hxx>
82 #include <GeomAbs_CurveType.hxx>
83
84 #include <Precision.hxx>
85
86 #include <stdio.h>
87
88 #include <TColStd_HArray1OfReal.hxx>
89 #include <TColStd_HArray2OfReal.hxx>
90 #include <TColStd_HArray1OfInteger.hxx>
91 #include <TColStd_Array1OfReal.hxx>
92 #include <TColStd_Array1OfInteger.hxx>
93
94 #include <TColGeom_HArray1OfBSplineCurve.hxx>
95 #include <TColGeom2d_HArray1OfBSplineCurve.hxx>
96 #include <Convert_CompPolynomialToPoles.hxx>
97 #include <CPnts_AbscissaPoint.hxx>
98 #include <GCPnts_AbscissaPoint.hxx>
99
100 #include <PLib.hxx> 
101 #include <GeomAbs_Shape.hxx>
102 #include <Geom_Curve.hxx>
103 #include <GeomConvert.hxx>
104 #include <GeomConvert_ApproxCurve.hxx>
105 #include <Geom2dConvert_ApproxCurve.hxx>
106 #include <Geom2d_Curve.hxx>
107
108 #include <GeomAdaptor_HCurve.hxx>
109 #include <GeomAdaptor_Curve.hxx>
110 #include <Geom2dAdaptor_HCurve.hxx>
111 #include <GeomAdaptor_HCurve.hxx>
112 #include <Approx_CurvilinearParameter.hxx>
113 #include <Approx_CurveOnSurface.hxx>
114 #ifdef WNT
115 Standard_IMPORT Draw_Viewer dout;
116 #endif
117
118 //=======================================================================
119 //function : anacurve
120 //purpose  : 
121 //=======================================================================
122
123 static Standard_Integer anacurve (Draw_Interpretor& , Standard_Integer n, const char** a)
124 {
125   if (n < 5) return 1;
126
127   Handle(Geom_Geometry) result;
128   Handle(Geom2d_Curve)  result2d;
129
130   if (!strcmp(a[0],"line")) {
131     if (n == 6)
132       result2d = new Geom2d_Line(gp_Pnt2d(atof(a[2]),atof(a[3])),
133                                  gp_Dir2d(atof(a[4]),atof(a[5])));
134     else if (n == 8)
135       result = new Geom_Line(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
136                              gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])));
137     else
138       return 1;
139   }
140
141   else if (!strcmp(a[0],"circle")) {
142     if (n == 5)
143       result2d = 
144         new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
145                                    gp_Dir2d(1,0)),
146                           atof(a[4]));
147     else if (n == 6)
148       result = 
149         new Geom_Circle(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
150                                gp_Dir(0,0,1)),
151                         atof(a[5]));
152     else if (n == 7)
153       result2d =
154         new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
155                                    gp_Dir2d(atof(a[4]),atof(a[5]))),
156                           atof(a[6]));
157     else if (n == 9)
158       result = 
159         new Geom_Circle(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
160                                gp_Dir(atof(a[5]),atof(a[6]),atof(a[7]))),
161                         atof(a[8]));
162     else if (n == 12)
163       result = 
164         new Geom_Circle(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
165                                gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
166                                gp_Dir(atof(a[8]),atof(a[9]),atof(a[10]))),
167                         atof(a[11]));
168     else
169       return 1;
170   }
171   
172   else if (!strcmp(a[0],"parabola")) {
173     if (n == 5)
174       result2d = 
175         new Geom2d_Parabola(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
176                                      gp_Dir2d(1,0)),
177                             atof(a[4]));
178     else if (n == 6)
179       result = 
180         new Geom_Parabola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
181                                  gp_Dir(0,0,1)),
182                           atof(a[5]));
183     else if (n == 7)
184       result2d = 
185         new Geom2d_Parabola(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
186                                      gp_Dir2d(atof(a[4]),atof(a[5]))),
187                             atof(a[6]));
188     else if (n == 9)
189       result = 
190         new Geom_Parabola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
191                                  gp_Dir(atof(a[5]),atof(a[6]),atof(a[7]))),
192                           atof(a[8]));
193     else if (n == 12)
194       result = 
195         new Geom_Parabola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
196                                  gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
197                                  gp_Dir(atof(a[8]),atof(a[9]),atof(a[10]))),
198                           atof(a[11]));
199     else
200       return 1;
201   }
202   
203   else if (!strcmp(a[0],"ellipse")) {
204     if (n == 6)
205       result2d = 
206         new Geom2d_Ellipse(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
207                                     gp_Dir2d(1,0)),
208                            atof(a[4]),atof(a[5]));
209     else if (n == 7)
210       result = 
211         new Geom_Ellipse(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
212                                 gp_Dir(0,0,1)),
213                          atof(a[5]),atof(a[6]));
214     else if (n == 8)
215       result2d = 
216         new Geom2d_Ellipse(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
217                                     gp_Dir2d(atof(a[4]),atof(a[5]))),
218                            atof(a[6]), atof(a[7]));
219     else if (n == 10)
220       result = 
221         new Geom_Ellipse(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
222                                 gp_Dir(atof(a[5]),atof(a[6]),atof(a[7]))),
223                          atof(a[8]), atof(a[9]));
224     else if (n == 13)
225       result = 
226         new Geom_Ellipse(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
227                                 gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
228                                 gp_Dir(atof(a[8]),atof(a[9]),atof(a[10]))),
229                          atof(a[11]), atof(a[12]));
230     else
231       return 1;
232   }
233   
234   else if (!strcmp(a[0],"hyperbola")) {
235     if (n == 6)
236       result2d = 
237         new Geom2d_Hyperbola(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
238                                       gp_Dir2d(1,0)),
239                              atof(a[4]),atof(a[5]));
240     else if (n == 7)
241       result = 
242         new Geom_Hyperbola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
243                                   gp_Dir(0,0,1)),
244                            atof(a[5]),atof(a[6]));
245     else if (n == 8)
246       result2d = 
247         new Geom2d_Hyperbola(gp_Ax22d(gp_Pnt2d(atof(a[2]),atof(a[3])),
248                                       gp_Dir2d(atof(a[4]),atof(a[5]))),
249                              atof(a[6]), atof(a[7]));
250     else if (n == 10)
251       result = 
252         new Geom_Hyperbola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
253                                   gp_Dir(atof(a[5]),atof(a[6]),atof(a[7]))),
254                            atof(a[8]), atof(a[9]));
255     else if (n == 13)
256       result = 
257         new Geom_Hyperbola(gp_Ax2(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4])),
258                                   gp_Dir(atof(a[5]),atof(a[6]),atof(a[7])),
259                                   gp_Dir(atof(a[8]),atof(a[9]),atof(a[10]))),
260                            atof(a[11]), atof(a[12]));
261     else
262       return 1;
263   }
264   
265   if (!result.IsNull())
266     DrawTrSurf::Set(a[1],result);
267   else if (!result2d.IsNull())
268     DrawTrSurf::Set(a[1],result2d);
269   else
270     return 1;
271
272   return 0;
273 }
274
275 //=======================================================================
276 //function : polecurve
277 //purpose  : 
278 //=======================================================================
279
280 static Standard_Integer polecurve (Draw_Interpretor& , Standard_Integer n, const char** a)
281 {
282   Standard_Integer k,i;
283
284
285   if (n < 3) return 1;
286
287   if (!strcmp(a[0],"beziercurve")) {
288     
289     Standard_Integer np = atoi(a[2]);
290     if (np == 0) return 1;
291     
292     i = (n - 3) / (np);
293     if (i < 3 || i > 4) return 1;
294     Standard_Boolean hasw = i == 4;
295     
296     TColgp_Array1OfPnt poles(1,np);
297     TColStd_Array1OfReal weights(1,np);
298     
299     k = 3;
300     for (i = 1; i <= np; i++) {
301       poles(i).SetCoord(atof(a[k]),atof(a[k+1]),atof(a[k+2]));
302       k += 3;
303       if (hasw) {
304         weights(i) = atof(a[k]);
305         k++;
306       }
307     }
308     
309     Handle(Geom_BezierCurve) result;
310     if (hasw)
311       result = new Geom_BezierCurve(poles,weights);
312     else
313       result = new Geom_BezierCurve(poles);
314     
315     DrawTrSurf::Set(a[1],result);
316   }
317   
318   else if (!strcmp((*a[0] == 'p') ? a[0]+1 : a[0],"bsplinecurve")) {
319     Standard_Integer deg = atoi(a[2]);
320     Standard_Integer nbk = atoi(a[3]);
321
322     TColStd_Array1OfReal    knots(1, nbk);
323     TColStd_Array1OfInteger mults(1, nbk);
324     k = 4;
325     Standard_Integer Sigma = 0;
326     for (i = 1; i<=nbk; i++) {
327       knots( i) = atof(a[k]);
328       k++;
329       mults( i) = atoi(a[k]);
330       Sigma += mults(i);
331       k++;
332     }
333
334     Standard_Boolean periodic = *a[0] == 'p';
335     Standard_Integer np;
336     if (periodic)
337       np = Sigma - mults(nbk);
338     else
339       np = Sigma - deg  -1;
340
341     TColgp_Array1OfPnt   poles  (1, np);
342     TColStd_Array1OfReal weights(1, np);
343     
344     for (i = 1; i <= np; i++) {
345       poles(i).SetCoord(atof(a[k]),atof(a[k+1]),atof(a[k+2]));
346       k += 3;
347       weights(i) = atof(a[k]);
348       k++;
349     }
350     
351     Handle(Geom_BSplineCurve) result =
352       new Geom_BSplineCurve(poles, weights, knots, mults, deg, periodic);
353     DrawTrSurf::Set(a[1],result);
354   }
355   
356   return 0;
357 }
358
359 //=======================================================================
360 //function : polecurve2d
361 //purpose  : 
362 //=======================================================================
363
364 static Standard_Integer polecurve2d (Draw_Interpretor& , Standard_Integer n, const char** a)
365 {
366   Standard_Integer k,i;
367
368
369   if (n < 3) return 1;
370
371   if (!strcmp(a[0],"2dbeziercurve")) {
372     
373     Standard_Integer np = atoi(a[2]);
374     if (np == 0) return 1;
375     
376     i = (n - 2) / (np);
377     if (i < 2 || i > 3) return 1;
378     Standard_Boolean hasw = i == 3;
379     
380     TColgp_Array1OfPnt2d poles(1,np);
381     TColStd_Array1OfReal weights(1,np);
382     
383     k = 3;
384     for (i = 1; i <= np; i++) {
385       poles(i).SetCoord(atof(a[k]),atof(a[k+1]));
386       k += 2;
387       if (hasw) {
388         weights(i) = atof(a[k]);
389         k++;
390       }
391     }
392     
393     Handle(Geom2d_BezierCurve) result;
394     if (hasw)
395       result = new Geom2d_BezierCurve(poles,weights);
396     else
397       result = new Geom2d_BezierCurve(poles);
398     
399     DrawTrSurf::Set(a[1],result);
400   }
401   
402   else if (!strcmp((*(a[0]+2) == 'p') ? a[0]+3 : a[0]+2,"bsplinecurve")) {
403     Standard_Integer deg = atoi(a[2]);
404     Standard_Integer nbk = atoi(a[3]);
405
406     TColStd_Array1OfReal    knots(1, nbk);
407     TColStd_Array1OfInteger mults(1, nbk);
408     k = 4;
409     Standard_Integer Sigma = 0;
410     for (i = 1; i<=nbk; i++) {
411       knots( i) = atof(a[k]);
412       k++;
413       mults( i) = atoi(a[k]);
414       Sigma += mults(i);
415       k++;
416     }
417
418     Standard_Boolean periodic = *(a[0]+2) == 'p';
419     Standard_Integer np;
420     if (periodic)
421       np = Sigma - mults(nbk);
422     else
423       np = Sigma - deg  -1;
424
425     TColgp_Array1OfPnt2d poles  (1, np);
426     TColStd_Array1OfReal weights(1, np);
427     
428     for (i = 1; i <= np; i++) {
429       poles(i).SetCoord(atof(a[k]),atof(a[k+1]));
430       k += 2;
431       weights(i) = atof(a[k]);
432       k++;
433     }
434     
435     Handle(Geom2d_BSplineCurve) result =
436       new Geom2d_BSplineCurve(poles, weights, knots, mults, deg, periodic);
437     DrawTrSurf::Set(a[1],result);
438   }
439   
440   return 0;
441 }
442
443 //=======================================================================
444 //function : reverse
445 //purpose  : 
446 //=======================================================================
447
448 static Standard_Integer reverse (Draw_Interpretor& , Standard_Integer n, const char** a)
449 {
450   if (n < 2) return 1;
451
452   Standard_Integer i;
453   for (i = 1; i < n; i++) {
454
455     Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[i]);
456     if (!GC.IsNull()) {
457       GC->Reverse();
458       Draw::Repaint();
459     }
460     Handle(Geom2d_Curve) GC2d = DrawTrSurf::GetCurve2d(a[i]);
461     if (!GC2d.IsNull()) {
462       GC2d->Reverse();
463       Draw::Repaint();
464     }
465   }
466   return 0;
467 }
468
469 //=======================================================================
470 //function : cmovepole
471 //purpose  : 
472 //=======================================================================
473
474 static Standard_Integer cmovepole (Draw_Interpretor& , Standard_Integer n, const char** a)
475 {
476   if (n < 5) return 1;
477
478   Standard_Real dx = atof(a[3]);
479   Standard_Real dy = atof(a[4]);
480   Standard_Real dz=0;
481   if (n >= 6) dz = atof(a[5]);
482   Standard_Integer Index = atoi(a[2]);
483
484   Handle(Geom_BezierCurve) G1 = DrawTrSurf::GetBezierCurve(a[1]);
485   if (!G1.IsNull()) {
486     gp_Pnt P = G1->Pole(Index);
487     P.SetCoord(P.X()+dx, P.Y()+dy, P.Z()+dz);
488     G1->SetPole(Index,P);
489     Draw::Repaint();
490     return 0;
491   }
492
493
494   Handle(Geom_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve(a[1]);
495   if (!G2.IsNull()) {
496     gp_Pnt P = G2->Pole(Index);
497     P.SetCoord(P.X()+dx, P.Y()+dy, P.Z()+dz);
498     G2->SetPole(Index,P);
499     Draw::Repaint();
500     return 0;
501   }
502
503   Handle(Geom2d_BezierCurve) G3 = DrawTrSurf::GetBezierCurve2d(a[1]);
504   if (!G3.IsNull()) {
505     gp_Pnt2d P = G3->Pole(Index);
506     P.SetCoord(P.X()+dx, P.Y()+dy);
507     G3->SetPole(Index,P);
508     Draw::Repaint();
509     return 0;
510   }
511
512
513   Handle(Geom2d_BSplineCurve) G4 = DrawTrSurf::GetBSplineCurve2d(a[1]);
514   if (!G4.IsNull()) {
515     gp_Pnt2d P = G4->Pole(Index);
516     P.SetCoord(P.X()+dx, P.Y()+dy);
517     G4->SetPole(Index,P);
518     Draw::Repaint();
519     return 0;
520   }
521
522
523
524   return 0;
525 }
526
527 //=======================================================================
528 //function : cmovetangent
529 //purpose  : 
530 //=======================================================================
531
532 static Standard_Integer cmovetangent (Draw_Interpretor& di, Standard_Integer n, const char** a)
533 {
534   Standard_Integer dimension,
535   condition,
536   error_status ;
537   Standard_Real u,
538   x,
539   y,
540   z,
541   tolerance,
542   tx,
543   ty,
544   tz ;
545   u = atof(a[2]);
546   x = atof(a[3]);
547   y = atof(a[4]);
548   z = 0.0e0,
549   tolerance = 1.0e-5 ;
550   dimension = 3 ;
551   if (n <= 8) {
552     dimension = 2 ;
553     if (n < 7) {
554       return 1 ;
555     }
556   }
557   else {
558     dimension = 3 ;
559     if (n < 9) {
560       return 1 ;
561     }
562   }
563   condition = 0 ;
564   error_status  = 0 ;
565   if (dimension == 3) {
566     Handle(Geom_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve(a[1]);
567     if (!G2.IsNull()) {
568       z  = atof(a[5]) ;
569       tx = atof(a[6]) ;
570       ty = atof(a[7]) ;
571       tz = atof(a[8]) ;
572       if (n == 10) {
573         condition = Max(atoi(a[9]), -1)  ;
574         condition = Min(condition, G2->Degree()-1) ;
575       }
576       gp_Pnt p;
577       gp_Vec tangent ;
578       p.SetCoord(x,y,z);
579       tangent.SetCoord(tx,ty,tz) ;
580       
581       G2->MovePointAndTangent(u, 
582                               p, 
583                               tangent,
584                               tolerance,
585                               condition,
586                               condition,
587                               error_status) ;
588       if (! error_status) {
589         Draw::Repaint();
590         }
591       else {
592         di << "Not enought degree of freedom increase degree please" << "\n";
593       }
594       
595       return 0;
596     }
597   }
598   else {
599     Handle(Geom2d_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve2d(a[1]);
600     if (!G2.IsNull()) {
601       tx = atof(a[5]) ;
602       ty = atof(a[6]) ;
603       if (n == 8) {
604         condition = Max(atoi(a[7]), -1)  ;
605         condition = Min(condition, G2->Degree()-1) ;
606       }
607       gp_Pnt2d p;
608       gp_Vec2d tangent ;
609       p.SetCoord(x,y);
610       tangent.SetCoord(tx,ty) ;
611       
612       G2->MovePointAndTangent(u, 
613                               p, 
614                               tangent,
615                               tolerance,
616                               condition,
617                               condition,
618                               error_status) ;
619       if (! error_status) {
620         Draw::Repaint();
621         }
622       else {
623         di << "Not enought degree of freedom increase degree please" << "\n";
624       }
625       
626       return 0;
627     }
628    } 
629   return 0;
630 }
631
632
633 //=======================================================================
634 //function : cmovepoint
635 //purpose  : 
636 //=======================================================================
637
638 static Standard_Integer cmovepoint (Draw_Interpretor& , Standard_Integer n, const char** a)
639 {
640   if (n < 5) return 1;
641
642   Standard_Real dx = atof(a[3]);
643   Standard_Real dy = atof(a[4]);
644   Standard_Real dz=0;
645   if (n >= 6 && n != 7) dz = atof(a[5]);
646   Standard_Real u = atof(a[2]);
647   Standard_Integer index1 = 0;
648   Standard_Integer index2 = 0;
649   Standard_Integer fmodif, lmodif;
650   if (n == 7) {
651     index1 = atoi(a[5]);
652     index2 = atoi(a[6]);
653   }
654   else if (n == 8) {
655     index1 = atoi(a[6]);
656     index2 = atoi(a[7]);
657   }
658
659   Handle(Geom_BSplineCurve) G2 = DrawTrSurf::GetBSplineCurve(a[1]);
660   if (!G2.IsNull()) {
661     if (index1 == 0) {
662       index1 = 2;
663       index2 = G2->NbPoles()-1;
664     }
665     gp_Pnt p;
666     G2->D0(u, p);
667     p.SetCoord(p.X()+dx, p.Y()+dy, p.Z()+dz);
668     G2->MovePoint(u, p, index1, index2, fmodif, lmodif);
669     Draw::Repaint();
670     return 0;
671   }
672
673   Handle(Geom2d_BSplineCurve) G4 = DrawTrSurf::GetBSplineCurve2d(a[1]);
674   if (!G4.IsNull()) {
675     if (index1 == 0) {
676       index1 = 2;
677       index2 = G4->NbPoles()-1;
678     }
679     gp_Pnt2d p;
680     G4->D0(u, p);
681     p.SetCoord(p.X()+dx, p.Y()+dy);
682     G4->MovePoint(u, p, index1, index2, fmodif, lmodif);
683     Draw::Repaint();
684     return 0;
685   }
686   return 0;
687 }
688
689 //=======================================================================
690 //function : cinsertknot
691 //purpose  : 
692 //=======================================================================
693
694 static Standard_Integer cinsertknot (Draw_Interpretor& , Standard_Integer n, const char** a)
695 {
696   if (n < 4) return 1;
697
698   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
699   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
700
701   if (GBs.IsNull() && GBs2d.IsNull()) return 1;
702
703   if (n <= 4) {
704     Standard_Real    knot = atof(a[2]);
705     Standard_Integer mult = 1;
706     if (n == 4) mult = atoi(a[3]);
707     if (!GBs.IsNull())
708       GBs->InsertKnot(knot,mult,Precision::PConfusion());
709     else
710       GBs2d->InsertKnot(knot,mult,Precision::PConfusion());
711   }
712
713   else {
714     // multiple insertion
715     if (n % 2 != 0) return 1;
716     Standard_Integer i,nbk = (n-2) / 2;
717     TColStd_Array1OfReal    knots(1,nbk);
718     TColStd_Array1OfInteger mults(1,nbk);
719     for (i = 2; i < n; i += 2) {
720       knots(i/2) = atof(a[i]);
721       mults(i/2) = atoi(a[i+1]);
722     }
723
724     if (!GBs.IsNull())
725       GBs->InsertKnots(knots,mults,Precision::PConfusion());
726     else
727       GBs2d->InsertKnots(knots,mults,Precision::PConfusion());
728
729   }
730
731   Draw::Repaint();
732   return 0;
733 }
734
735 //=======================================================================
736 //function : csetknot
737 //purpose  : 
738 //=======================================================================
739
740 static Standard_Integer csetknot (Draw_Interpretor& , Standard_Integer n, const char** a)
741 {
742   if (n < 4) return 1;
743
744   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
745   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
746
747   if (GBs.IsNull() && GBs2d.IsNull()) return 1;
748
749   Standard_Integer index = atoi(a[2]);
750   Standard_Real    knot  = atof(a[3]);
751
752   if ( n == 4) {
753     if (!GBs.IsNull())
754       GBs->SetKnot(index,knot);
755     else
756       GBs2d->SetKnot(index,knot);
757   }
758   else {
759     Standard_Integer mult  = atoi(a[4]);
760     if (!GBs.IsNull())
761       GBs->SetKnot(index,knot,mult);
762     else
763       GBs2d->SetKnot(index,knot,mult);
764   }
765
766   Draw::Repaint();
767   return 0;
768 }
769
770 //=======================================================================
771 //function : cremknot
772 //purpose  : 
773 //=======================================================================
774
775 static Standard_Integer cremknot (Draw_Interpretor& di, Standard_Integer n, const char** a)
776 {
777   if (n < 3) return 1;
778
779   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
780   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
781
782   if (GBs.IsNull() && GBs2d.IsNull()) return 1;
783
784   Standard_Integer index = atoi(a[2]);
785   Standard_Integer mult  = 0;
786   if (n >= 4) mult = atoi(a[3]);
787
788   Standard_Real tol = RealLast();
789   if (n >= 5) tol = atof(a[4]);
790
791   if (!GBs.IsNull()) {
792     if (!GBs->RemoveKnot(index,mult,tol))
793       di << "Remove knots failed"<<"\n";
794   }
795   else {
796     if (!GBs2d->RemoveKnot(index,mult,tol))
797       di << "Remove knots failed"<<"\n";
798   }
799
800   Draw::Repaint();
801   return 0;
802 }
803
804 //=======================================================================
805 //function : increasedegree
806 //purpose  : 
807 //=======================================================================
808
809 static Standard_Integer increasedegree (Draw_Interpretor& , Standard_Integer n, const char** a)
810 {
811   if (n < 3) return 1;
812
813   Standard_Integer Deg = atoi(a[2]);
814
815   Handle(Geom_BezierCurve) GBz = DrawTrSurf::GetBezierCurve(a[1]);
816   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
817   Handle(Geom2d_BezierCurve) GBz2d = DrawTrSurf::GetBezierCurve2d(a[1]);
818   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
819
820   if (!GBz.IsNull()) 
821     GBz->Increase(Deg);
822   else if (!GBs.IsNull())
823     GBs->IncreaseDegree(Deg);
824   else if (!GBz2d.IsNull()) 
825     GBz2d->Increase(Deg);
826   else if (!GBs2d.IsNull())
827     GBs2d->IncreaseDegree(Deg);
828   else
829     return 1;
830
831   Draw::Repaint();
832   return 0;
833 }
834
835 //=======================================================================
836 //function : removepole
837 //purpose  : 
838 //=======================================================================
839
840 static Standard_Integer removepole (Draw_Interpretor& di, Standard_Integer n, const char** a)
841 {
842   if (n < 3) return 1;
843
844   Standard_Integer Index = atoi(a[2]);
845
846   Handle(Geom_BezierCurve)   GBZ   = DrawTrSurf::GetBezierCurve(a[1]);
847   Handle(Geom2d_BezierCurve) GBZ2d = DrawTrSurf::GetBezierCurve2d(a[1]);
848   if (!GBZ.IsNull()) {
849     GBZ->RemovePole(Index);
850   }
851   else if (!GBZ2d.IsNull()) {
852     GBZ2d->RemovePole(Index);
853   }
854   else {
855     di << "rempole needs a bezier curve";
856     return 1;
857   }
858
859   Draw::Repaint();
860   return 0;
861 }
862
863 //=======================================================================
864 //function : insertpole
865 //purpose  : 
866 //=======================================================================
867
868 static Standard_Integer insertpole (Draw_Interpretor& di, Standard_Integer n, const char** a)
869 {
870   if (n < 6) return 1;
871
872   Standard_Integer Index = atoi(a[2]);
873
874   Handle(Geom_BezierCurve)   GBZ   = DrawTrSurf::GetBezierCurve(a[1]);
875   Handle(Geom2d_BezierCurve) GBZ2d = DrawTrSurf::GetBezierCurve2d(a[1]);
876   if (!GBZ.IsNull()) {
877     gp_Pnt P (atof(a[3]),atof(a[4]),atof(a[5]));
878     if ( n == 7)
879       GBZ->InsertPoleAfter(Index,P,atof(a[6]));
880     else
881       GBZ->InsertPoleAfter(Index,P);
882   }
883   else if (!GBZ2d.IsNull()) {
884     gp_Pnt2d P (atof(a[3]),atof(a[4]));
885     if ( n == 6)
886       GBZ2d->InsertPoleAfter(Index,P,atof(a[5]));
887     else
888       GBZ2d->InsertPoleAfter(Index,P);
889   }
890   else {
891     di << "insertpole needs a bezier curve";
892     return 1;
893   }
894
895   Draw::Repaint();
896   return 0;
897 }
898
899 //=======================================================================
900 //function : cfindp
901 //purpose  : 
902 //=======================================================================
903
904 static Standard_Integer cfindp (Draw_Interpretor& , Standard_Integer n, const char** a)
905 {
906   if (n < 6) return 1;
907
908   Standard_Integer Index = 0;
909   Standard_Integer view = atoi(a[2]);
910   Standard_Real x = atof(a[3]);
911   Standard_Real y = atof(a[4]);
912
913   Draw_Display d = dout.MakeDisplay(view);
914
915   Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
916
917   Handle(DrawTrSurf_BezierCurve) DBz = 
918     Handle(DrawTrSurf_BezierCurve)::DownCast(D);
919   if( !DBz.IsNull())
920     DBz->FindPole( x, y, d, 5, Index);
921   else {
922     Handle(DrawTrSurf_BSplineCurve) DBs = 
923       Handle(DrawTrSurf_BSplineCurve)::DownCast(D);
924     if (!DBs.IsNull())
925       DBs->FindPole( x, y, d, 5, Index);
926     else {
927       Handle(DrawTrSurf_BezierCurve2d) DBz = 
928         Handle(DrawTrSurf_BezierCurve2d)::DownCast(D);
929       if( !DBz.IsNull())
930         DBz->FindPole( x, y, d, 5, Index);
931       else {
932         Handle(DrawTrSurf_BSplineCurve2d) DBs = 
933           Handle(DrawTrSurf_BSplineCurve2d)::DownCast(D);
934         if (!DBs.IsNull())
935           DBs->FindPole( x, y, d, 5, Index);
936         else 
937           return 1;
938       }
939     }
940   }
941   
942   Draw::Set(a[5],Index);
943   
944   return 0;
945 }
946
947
948 //=======================================================================
949 //function : csetperiodic
950 //purpose  : 
951 //=======================================================================
952
953 static Standard_Integer csetperiodic (Draw_Interpretor& , Standard_Integer n, const char** a)
954 {
955   if (n < 2) return 1;
956
957   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
958   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
959   
960   if (GBs.IsNull() && GBs2d.IsNull()) return 1;
961   
962   if (!strcmp(a[0],"setperiodic")) {
963     if (!GBs.IsNull()) 
964       GBs->SetPeriodic();
965     else
966       GBs2d->SetPeriodic();
967   }
968   else if (!strcmp(a[0],"setnotperiodic")) {
969     if (!GBs.IsNull()) 
970       GBs->SetNotPeriodic();
971     else
972       GBs2d->SetNotPeriodic();
973   }
974
975   Draw::Repaint();
976   return 0;
977 }
978
979 //=======================================================================
980 //function : value
981 //purpose  : 
982 //=======================================================================
983
984 static Standard_Integer value (Draw_Interpretor& ,
985                                Standard_Integer n, const char** a)
986 {
987   if (n < 4) return 1;
988
989   Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[1]);
990   if (GC.IsNull()) return 1;
991
992   Standard_Real U = atof(a[2]);
993
994   Standard_Boolean DrawPoint = ( n%3 == 1);
995   if ( DrawPoint) n--;
996
997   gp_Pnt P;
998   if (n > 6) {
999     if (n < 9) return 1;
1000     gp_Vec D1;
1001     if (n > 9) {
1002       if (n < 12) return 1;
1003       gp_Vec D2;
1004       GC->D2(U,P,D1,D2);
1005       Draw::Set(a[9] ,D2.X());
1006       Draw::Set(a[10],D2.Y());
1007       Draw::Set(a[11],D2.Z());
1008     }
1009     else 
1010       GC->D1(U,P,D1);
1011     Draw::Set(a[6],D1.X());
1012     Draw::Set(a[7],D1.Y());
1013     Draw::Set(a[8],D1.Z());
1014   }
1015   else 
1016     GC->D0(U,P);
1017
1018   if ( n > 3) {
1019     Draw::Set(a[3],P.X());
1020     Draw::Set(a[4],P.Y());
1021     Draw::Set(a[5],P.Z());
1022   }
1023   if ( DrawPoint) {
1024     DrawTrSurf::Set(a[n],P);
1025   }
1026   
1027   return 0;
1028 }
1029
1030
1031 //=======================================================================
1032 //function : value2d
1033 //purpose  : 
1034 //=======================================================================
1035
1036 static Standard_Integer value2d (Draw_Interpretor& , 
1037                                  Standard_Integer n, const char** a)
1038 {
1039   if (n < 4) return 1;
1040
1041   Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(a[1]);
1042   if (GC.IsNull()) return 1;
1043
1044   Standard_Real U = atof(a[2]);
1045
1046   Standard_Boolean DrawPoint = ( n%2 == 0);
1047   if ( DrawPoint ) n--;
1048
1049   gp_Pnt2d P;
1050   if (n > 5) {
1051     if (n < 7) return 1;
1052     gp_Vec2d D1;
1053     if (n > 7) {
1054       if (n < 9) return 1;
1055       gp_Vec2d D2;
1056       GC->D2(U,P,D1,D2);
1057       Draw::Set(a[7] ,D2.X());
1058       Draw::Set(a[8],D2.Y());
1059     }
1060     else 
1061       GC->D1(U,P,D1);
1062     Draw::Set(a[5],D1.X());
1063     Draw::Set(a[6],D1.Y());
1064   }
1065   else 
1066     GC->D0(U,P);
1067
1068   if ( n > 3 ) {
1069     Draw::Set(a[3],P.X());
1070     Draw::Set(a[4],P.Y());
1071   }
1072   if ( DrawPoint ) {
1073     DrawTrSurf::Set(a[n], P);
1074   }
1075   
1076   return 0;
1077 }
1078
1079 //=======================================================================
1080 //function : segment
1081 //purpose  : 
1082 //=======================================================================
1083
1084 static Standard_Integer segment (Draw_Interpretor& , Standard_Integer n, const char** a)
1085 {
1086   if (n < 4) return 1;
1087
1088   Handle(Geom_BezierCurve) GBz = DrawTrSurf::GetBezierCurve(a[1]);
1089   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
1090   Handle(Geom2d_BezierCurve) GBz2d = DrawTrSurf::GetBezierCurve2d(a[1]);
1091   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
1092
1093   Standard_Real f = atof(a[2]), l = atof(a[3]);
1094
1095   if (!GBz.IsNull()) 
1096     GBz->Segment(f,l);
1097   else if (!GBs.IsNull())
1098     GBs->Segment(f,l);
1099   else if (!GBz2d.IsNull()) 
1100     GBz2d->Segment(f,l);
1101   else if (!GBs2d.IsNull())
1102     GBs2d->Segment(f,l);
1103   else
1104     return 1;
1105
1106   Draw::Repaint();
1107   return 0;
1108 }
1109
1110
1111 //=======================================================================
1112 //function : setorigin
1113 //purpose  : 
1114 //=======================================================================
1115
1116 static Standard_Integer setorigin (Draw_Interpretor& , Standard_Integer n, const char** a)
1117 {
1118   if (n < 3) return 1;
1119
1120   Handle(Geom_BSplineCurve) GBs = DrawTrSurf::GetBSplineCurve(a[1]);
1121   Handle(Geom2d_BSplineCurve) GBs2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
1122
1123   if (!GBs.IsNull())
1124     GBs->SetOrigin(atoi(a[2])); 
1125   if (!GBs2d.IsNull())
1126     GBs2d->SetOrigin(atoi(a[2])); 
1127   else
1128     return 1;
1129
1130   Draw::Repaint();
1131   return 0;
1132 }
1133
1134
1135 //=======================================================================
1136 //function : point
1137 //purpose  : 
1138 //=======================================================================
1139
1140 static Standard_Integer point(Draw_Interpretor& , Standard_Integer n, const char** a)
1141 {
1142   if (n < 4) return 1;
1143   if (n >= 5) {
1144     gp_Pnt P(atof(a[2]),atof(a[3]),atof(a[4]));
1145     DrawTrSurf::Set(a[1],P);
1146   }
1147   else {
1148     gp_Pnt2d P(atof(a[2]),atof(a[3]));
1149     DrawTrSurf::Set(a[1],P);
1150   }
1151
1152   return 0;
1153 }
1154
1155 //=======================================================================
1156 //function : coord
1157 //purpose  : 
1158 //=======================================================================
1159
1160 static Standard_Integer coord(Draw_Interpretor&,
1161                               Standard_Integer n, const char** a) 
1162 {
1163   if ( n == 4) {
1164     gp_Pnt2d P;
1165     if ( !DrawTrSurf::GetPoint2d(a[1],P)) return 1;
1166     Draw::Set(a[2],P.X());
1167     Draw::Set(a[3],P.Y());
1168   }
1169   else if ( n == 5) {
1170     gp_Pnt  P;
1171     if ( !DrawTrSurf::GetPoint(a[1],P)) return 1;
1172     Draw::Set(a[2],P.X());
1173     Draw::Set(a[3],P.Y());
1174     Draw::Set(a[4],P.Z());
1175   }
1176   else 
1177     return 1;
1178
1179   return 0;
1180 }
1181
1182 //=======================================================================
1183 //function : 
1184 //purpose  : 
1185 //=======================================================================
1186 static Standard_Integer minmaxcurandinf(Draw_Interpretor& di, 
1187                                    Standard_Integer argc, const char** argv)
1188 {
1189   if (argc < 2) return 1;
1190
1191   Handle(Geom2d_Curve)  C1 = DrawTrSurf::GetCurve2d(argv[1]);
1192   if (C1.IsNull()) return 1;
1193
1194   Draw_Color              Couleur;
1195   Geom2dLProp_CurAndInf2d Sommets;  
1196
1197   Sommets.PerformCurExt (C1);
1198   if (Sommets.IsDone() && !Sommets.IsEmpty()) {
1199     for (Standard_Integer i = 1; i <= Sommets.NbPoints(); i++){      
1200       Couleur = Draw_vert;
1201       if (Sommets.Type(i) == LProp_MinCur) {
1202         Couleur = Draw_orange;
1203         di << "  Maximum of curvature at U ="<<Sommets.Parameter(i)<<"\n";
1204       }
1205       else {
1206         di << "  Minimum of curvature at U ="<<Sommets.Parameter(i)<<"\n";
1207       }
1208       gp_Pnt2d P = C1->Value(Sommets.Parameter(i));
1209       Handle(Draw_Marker2D) dr = new Draw_Marker2D(P,Draw_Plus,Couleur); 
1210       dout << dr;
1211     }
1212     dout.Flush();
1213   }
1214    
1215   Geom2dLProp_CurAndInf2d Sommets2;
1216   Sommets2.PerformInf (C1);
1217   
1218   if (Sommets2.IsDone() && !Sommets2.IsEmpty()) {
1219     for (Standard_Integer i = 1; i <= Sommets2.NbPoints(); i++){
1220       gp_Pnt2d P = C1->Value(Sommets2.Parameter(i));
1221       Handle(Draw_Marker2D) dr = new Draw_Marker2D(P,Draw_Plus,Draw_bleu); 
1222       dout << dr;
1223       di << "  Inflexion at U ="<<Sommets2.Parameter(i)<<"\n";
1224     }
1225     dout.Flush();
1226   }
1227   return 0;
1228 }
1229 //=======================================================================
1230 //function :  shcurvature
1231 //purpose  :  affiche le peigne de courbure
1232 //=======================================================================
1233 static Standard_Integer shcurvature(Draw_Interpretor&, 
1234                                    Standard_Integer argc, const char** argv)
1235 {
1236   if (argc < 2) return 1;
1237
1238    Handle(DrawTrSurf_Curve2d) C2d =  Handle(DrawTrSurf_Curve2d)
1239                                   ::DownCast(Draw::Get(argv[1]));
1240    Handle(DrawTrSurf_Curve) C3d =  Handle(DrawTrSurf_Curve)
1241                                   ::DownCast(Draw::Get(argv[1]));
1242    
1243   if (C2d.IsNull()) {
1244     if (C3d.IsNull()) return 1;
1245     C3d->ShowCurvature();
1246   }
1247   else {
1248     C2d->ShowCurvature();
1249   }
1250   Draw::Repaint();
1251   return 0;
1252 }
1253
1254 //=======================================================================
1255 //function :  clcurvature
1256 //purpose  :  efface le peigne de courbure
1257 //=======================================================================
1258 static Standard_Integer clcurvature(Draw_Interpretor&, 
1259                                    Standard_Integer argc, const char** argv)
1260 {
1261   if (argc < 2) return 1; 
1262    Handle(DrawTrSurf_Curve2d) C2d =  Handle(DrawTrSurf_Curve2d)
1263                                   ::DownCast(Draw::Get(argv[1]));
1264    Handle(DrawTrSurf_Curve) C3d =  Handle(DrawTrSurf_Curve)
1265                                   ::DownCast(Draw::Get(argv[1]));
1266
1267   if (C2d.IsNull()) {
1268     if (C3d.IsNull()) return 1;
1269     C3d->ClearCurvature();
1270   }
1271   else {
1272     C2d->ClearCurvature();
1273   }
1274   Draw::Repaint();
1275   return 0;
1276 }
1277
1278 //=======================================================================
1279 //function :  radiusmax
1280 //purpose  :  definit le rayon de courbure maximum a afficher
1281 //=======================================================================
1282 static Standard_Integer radiusmax(Draw_Interpretor&, 
1283                                   Standard_Integer argc, const char** argv)
1284 {
1285   if (argc < 3) return 1; 
1286   Standard_Real Radius = atof(argv[2]);
1287    Handle(DrawTrSurf_Curve2d) C2d =  Handle(DrawTrSurf_Curve2d)
1288                                   ::DownCast(Draw::Get(argv[1]));
1289    Handle(DrawTrSurf_Curve) C3d =  Handle(DrawTrSurf_Curve)
1290                                   ::DownCast(Draw::Get(argv[1]));
1291
1292   if (C2d.IsNull()) {
1293     if (C3d.IsNull()) return 1;
1294     C3d->SetRadiusMax(Radius);
1295   }
1296   else {
1297     C2d->SetRadiusMax(Radius);
1298   }
1299   Draw::Repaint();
1300   return 0;
1301 }
1302
1303 //=======================================================================
1304 //function :  radiusratio
1305 //purpose  :  definit le ratio du rayon de courbure a afficher
1306 //=======================================================================
1307 static Standard_Integer radiusratio(Draw_Interpretor&, 
1308                                   Standard_Integer argc, const char** argv)
1309 {
1310   if (argc < 3) return 1;
1311   Standard_Real Ratio = atof(argv[2]);
1312   Handle(DrawTrSurf_Curve2d) C2d =  Handle(DrawTrSurf_Curve2d)
1313                                   ::DownCast(Draw::Get(argv[1]));
1314   Handle(DrawTrSurf_Curve) C3d =  Handle(DrawTrSurf_Curve)
1315                                   ::DownCast(Draw::Get(argv[1]));
1316
1317   if (C2d.IsNull()) { 
1318     if (C3d.IsNull()) return 1;
1319     C3d->SetRadiusRatio(Ratio);
1320   }
1321   else {
1322     C2d->SetRadiusRatio(Ratio);
1323   }
1324   Draw::Repaint();
1325   return 0;
1326 }
1327
1328 //=======================================================================
1329 //function : 
1330 //purpose  : 
1331 //=======================================================================
1332 static Standard_Integer localprop(Draw_Interpretor& di, 
1333                                   Standard_Integer argc, const char** argv)
1334 {
1335   if (argc < 3) return 1;
1336
1337   Standard_Real U =  atof(argv[2]);
1338
1339   Handle(Geom2d_Curve)  C2d = DrawTrSurf::GetCurve2d(argv[1]);
1340   Handle(Geom_Curve)    C3d;
1341
1342
1343   if (C2d.IsNull()) {
1344     C3d = DrawTrSurf::GetCurve(argv[1]);
1345     if (C3d.IsNull()) return 1;
1346     GeomLProp_CLProps Prop (C3d,2,Precision::Confusion());
1347     Prop.SetParameter(U);
1348     Handle(Draw_Marker3D)drp = new Draw_Marker3D(Prop.Value(),
1349                                                  Draw_Plus,
1350                                                  Draw_vert );
1351     dout << drp;
1352     if (Prop.IsTangentDefined()) {
1353       Standard_Real K = Prop.Curvature();
1354       di <<" Curvature : "<<K<<"\n";
1355
1356       if (Abs(K) > Precision::Confusion()) {
1357         Standard_Real R = 1/Abs(K);
1358         gp_Pnt        Center;
1359         Prop.CentreOfCurvature(Center);
1360         gp_Dir Tang;
1361         gp_Dir Nor;
1362         Prop.Tangent(Tang);
1363         Prop.Normal(Nor);
1364         gp_Dir AxC = Nor^Tang;
1365         gp_Ax2 Axe(Center,AxC,Nor);
1366         Handle(Geom_Circle) Cir3d = new Geom_Circle(Axe,R);
1367         Handle(DrawTrSurf_Curve) dr;
1368         dr = new DrawTrSurf_Curve(Cir3d);
1369         dout << dr;
1370         dout.Flush();
1371       }
1372     }
1373     else 
1374       di <<"Tangent undefined."<<"\n";  
1375   }
1376   else {
1377     Geom2dLProp_CLProps2d Prop (C2d,2,Precision::Confusion());
1378     Prop.SetParameter(U);
1379     Handle(Draw_Marker2D) drp = new Draw_Marker2D(Prop.Value(),
1380                                                   Draw_Plus,
1381                                                   Draw_vert);
1382     dout << drp;
1383     if (Prop.IsTangentDefined()) {
1384       Standard_Real K = Prop.Curvature();
1385       gp_Pnt2d      Center;
1386
1387       di <<" Curvature : "<<K<<"\n";
1388
1389       if (Abs(K) > Precision::Confusion()) {
1390         Standard_Real R = 1/Abs(K);
1391         Prop.CentreOfCurvature(Center);
1392         gp_Ax2d Axe(Center,gp::DX2d());
1393         Handle(Geom2d_Circle) Cir2d = new Geom2d_Circle(Axe,R);
1394         Handle(DrawTrSurf_Curve2d) dr;
1395         dr = new DrawTrSurf_Curve2d(Cir2d,Draw_rouge,30,Standard_False);
1396         dout << dr;
1397         dout.Flush();
1398       }
1399     }
1400     else 
1401       di <<"Tangent undefined."<<"\n";
1402   }
1403   return 0;
1404 }  
1405 //=======================================================================
1406 //function : rawcont
1407 //purpose  : 
1408 //=======================================================================
1409
1410 static Standard_Integer rawcont(Draw_Interpretor& di, Standard_Integer n, const char** a)
1411 {
1412   if (n < 5) return 1;
1413
1414   Handle(Geom_Curve) GC1;
1415   GC1 = DrawTrSurf::GetCurve(a[1]);
1416   Handle(Geom_Curve) GC2;
1417   GC2 = DrawTrSurf::GetCurve(a[2]);
1418   Standard_Real param1 =
1419     atof(a[3]) ;
1420   Standard_Real param2 =
1421     atof(a[4]) ;
1422   if (GC1.IsNull() || GC2.IsNull())
1423     return 1;
1424   gp_Pnt a_point1,
1425     a_point2 ;
1426   GC1->D0(param1,
1427           a_point1) ;
1428   GC2->D0(param2,
1429           a_point2) ;
1430   if (a_point2.SquareDistance(a_point1) < Precision::Confusion()) {
1431     GeomAbs_Shape cont =
1432       GeomLProp::Continuity(GC1,
1433                             GC2,
1434                             param1,
1435                             param2,
1436                             Standard_True,
1437                             Standard_True,
1438                             Precision::Confusion(),
1439                             Precision::Angular()) ;
1440     switch (cont) {
1441     case GeomAbs_C0: 
1442       di << " C0 Continuity " << "\n" ;
1443       break ;
1444     case GeomAbs_G1:
1445       di << " G1 Continuity " << "\n" ;
1446       break ;
1447     case GeomAbs_C1 :
1448       di << " C1 Continuity " << "\n" ;
1449       break ;
1450     case GeomAbs_G2 :
1451       di << " G2 Continuity " << "\n" ;
1452       break ; 
1453     case GeomAbs_C2 :
1454       di << " C2 Continuity " << "\n" ;
1455       break ; 
1456     case GeomAbs_C3 :
1457       di << " C3 Continuity " << "\n" ;
1458       break ; 
1459     case GeomAbs_CN :
1460       di << " CN Continuity " << "\n" ;
1461       break ; 
1462     default:
1463       break ; 
1464     }
1465   }
1466   else {
1467     di << " not C0 continuity " << "\n" ;
1468   }
1469   return 0 ;
1470 }
1471 //=======================================================================
1472 //function : approxcurveonsurf
1473 //purpose  : 
1474 //=======================================================================
1475 static Standard_Integer approxcurveonsurf(Draw_Interpretor& di, Standard_Integer n, const char** a)
1476 {
1477   Standard_Real Tol = 1.e-7;              // Tolerance (default 0.1mm) 
1478   GeomAbs_Shape Continuity = GeomAbs_C1;  // Continuity order : 0, 1 or 2 (default 1)
1479   Standard_Integer MaxDeg = 14;           // Maximum degree
1480   Standard_Integer MaxSeg = 16; /*1*/          // Maximum number of segments
1481
1482   if ( n>8 || n<4) return 1;
1483
1484   if (n>4) Tol = Max(atof(a[4]),1.e-10);
1485
1486   if (n>5) {
1487     if (atoi(a[5]) == 0) Continuity = GeomAbs_C0;
1488     if (atoi(a[5]) == 2) Continuity = GeomAbs_C2;
1489   }
1490
1491   if (n>6) {
1492     MaxDeg = atoi(a[6]);
1493     if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
1494   }
1495
1496   if (n>7) MaxSeg = atoi(a[7]);
1497   Handle(Geom2d_Curve) curve2d = DrawTrSurf::GetCurve2d(a[2]);
1498   Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[3]);
1499
1500   Handle(Geom2dAdaptor_HCurve) A2d = new (Geom2dAdaptor_HCurve)(curve2d);
1501   Handle(GeomAdaptor_HSurface) AS = new (GeomAdaptor_HSurface)(Surf);
1502
1503   Approx_CurveOnSurface App(A2d, AS, A2d->FirstParameter(), A2d->LastParameter(),
1504                             Tol,  Continuity,  MaxDeg, MaxSeg,
1505                             Standard_True, Standard_False);
1506
1507   if(App.HasResult()) {
1508     Handle(Geom_BSplineCurve) BSCurve = App.Curve3d(); 
1509     DrawTrSurf::Set(a[1], BSCurve);
1510     return 0;
1511   }
1512
1513   di << "Approximation failed !" << "\n";
1514   return 1;
1515                             
1516 }
1517
1518 //=======================================================================
1519 //function : approxcurve
1520 //purpose  : 
1521 //=======================================================================
1522 static Standard_Integer approxcurve(Draw_Interpretor& di, Standard_Integer n, const char** a)
1523
1524   Standard_Real Tol = 1.e-7;              // Tolerance (default 0.1mm) 
1525   GeomAbs_Shape Continuity = GeomAbs_C1;  // Continuity order : 0, 1 or 2 (default 1)
1526   Standard_Integer MaxDeg = 14;           // Maximum degree
1527   Standard_Integer MaxSeg = 16;           // Maximum number of segments
1528   
1529   Standard_Integer Case, shift;
1530 // Case == 1 : 3d approximation without reparametrization
1531 // Case == 2 : 2d approximation without reparametrization
1532 // Case == 3 : 3d approximation with reparametrization
1533 // Case == 4 : curve_on_surface approximation with reparametrization
1534 // Case == 5 : 2 curves_on_surfaces approximation with reparametrization
1535
1536   Handle(Geom_Curve) curve;
1537   Handle(Geom2d_Curve) curve2d, curve2d2;
1538   Handle(Geom_Surface) surface, surface2;
1539
1540   if(n < 2) return 1;
1541
1542   if (!strcmp(a[1],"-L")) {
1543 // aproximation with curvilinear abscissa reparametrization
1544     if (n > 11 || n < 4) return 1;
1545     Tol = 1.e-4;
1546     curve = DrawTrSurf::GetCurve(a[3]);
1547     if (!curve.IsNull()) {
1548       shift = 4;
1549       Case = 3;
1550     }
1551     else {
1552 // approx curve_on_surface
1553       if (n < 5) return 1;
1554       curve2d = DrawTrSurf::GetCurve2d(a[3]); 
1555       surface = DrawTrSurf::GetSurface(a[4]);
1556       if (curve2d.IsNull() || surface.IsNull()) {
1557         return 1;
1558       }
1559       if (n >= 7) {
1560         curve2d2 = DrawTrSurf::GetCurve2d(a[5]); 
1561         surface2 = DrawTrSurf::GetSurface(a[6]);
1562         if (curve2d2.IsNull() || surface2.IsNull()) {
1563           shift = 5;
1564           Case = 4;
1565         }
1566         else {
1567 // approx 2 curves_on_surfaces
1568           shift = 7;
1569           Case = 5;
1570         }
1571       }
1572       else {
1573         shift = 5;
1574         Case = 4;
1575       }
1576     }
1577   }
1578   else {
1579 // aproximation without reparamitrization
1580     if ( n>7 || n<3) return 1;
1581     shift = 3;
1582     curve = DrawTrSurf::GetCurve(a[2]);
1583     if (curve.IsNull()) {
1584       curve2d = DrawTrSurf::GetCurve2d(a[2]); 
1585       if (curve2d.IsNull()) {
1586         return 1;
1587       }
1588       Case = 2;
1589     }
1590     else
1591       Case = 1;
1592   }
1593   
1594   if (n>shift) Tol = Max(atof(a[shift]),1.e-10);
1595   
1596   if (n>shift+1) {
1597     if (atoi(a[shift+1]) == 0) Continuity = GeomAbs_C0;
1598     if (atoi(a[shift+1]) == 2) Continuity = GeomAbs_C2;
1599   }
1600   
1601   if (n>shift+2) {
1602       MaxDeg = atoi(a[shift+2]);
1603       if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
1604     }
1605   
1606   if (n>shift+3) MaxSeg = atoi(a[shift+3]);
1607     
1608   if (Case == 1) {
1609     GeomConvert_ApproxCurve appr(curve, Tol, Continuity, MaxSeg, MaxDeg);
1610     if(appr.HasResult()) {
1611       //appr.Dump(cout);
1612       Standard_SStream aSStream;
1613       appr.Dump(aSStream);
1614       di << aSStream;
1615       Handle(Geom_BSplineCurve) BSCurve = appr.Curve(); 
1616       DrawTrSurf::Set(a[1], BSCurve);
1617     }
1618  }   
1619
1620   else if (Case == 2) {
1621     Geom2dConvert_ApproxCurve appr(curve2d, Tol, Continuity, MaxSeg, MaxDeg);
1622     if(appr.HasResult()) {
1623       //appr.Dump(cout);
1624       Standard_SStream aSStream;
1625       appr.Dump(aSStream);
1626       di << aSStream;
1627       Handle(Geom2d_BSplineCurve) BSCurve = appr.Curve(); 
1628       DrawTrSurf::Set(a[1], BSCurve);
1629     }
1630   }    
1631
1632   else if (Case == 3) {
1633     Handle(Adaptor3d_HCurve) HACur = new GeomAdaptor_HCurve(curve);
1634     Approx_CurvilinearParameter appr(HACur, Tol, Continuity, MaxDeg, MaxSeg);
1635     if(appr.HasResult()) {
1636       //appr.Dump(cout);
1637       Standard_SStream aSStream;
1638       appr.Dump(aSStream);
1639       di << aSStream;
1640       Handle(Geom_BSplineCurve) BSCurve = appr.Curve3d(); 
1641       DrawTrSurf::Set(a[2], BSCurve);
1642     }
1643 }    
1644   else if (Case == 4) {
1645     Handle(Adaptor2d_HCurve2d) HACur2d = new Geom2dAdaptor_HCurve(curve2d);
1646     Handle(Adaptor3d_HSurface) HASur = new GeomAdaptor_HSurface(surface);
1647     Approx_CurvilinearParameter appr(HACur2d, HASur, Tol, Continuity, MaxDeg, MaxSeg);
1648     if(appr.HasResult()) {
1649       //appr.Dump(cout);
1650       Standard_SStream aSStream;
1651       appr.Dump(aSStream);
1652       di << aSStream;
1653       Handle(Geom_BSplineCurve) BSCurve = appr.Curve3d(); 
1654       DrawTrSurf::Set(a[2], BSCurve);
1655     }
1656   }
1657
1658   else if (Case == 5) {
1659     Handle(Adaptor2d_HCurve2d) HACur2d = new Geom2dAdaptor_HCurve(curve2d);
1660     Handle(Adaptor3d_HSurface) HASur = new GeomAdaptor_HSurface(surface);
1661     Handle(Adaptor2d_HCurve2d) HACur2d2 = new Geom2dAdaptor_HCurve(curve2d2);
1662     Handle(Adaptor3d_HSurface) HASur2 = new GeomAdaptor_HSurface(surface2);
1663     Approx_CurvilinearParameter appr(HACur2d, HASur, HACur2d2, HASur2, Tol, Continuity, MaxDeg, MaxSeg);
1664     if(appr.HasResult()) {
1665       //appr.Dump(cout);
1666       Standard_SStream aSStream;
1667       appr.Dump(aSStream);
1668       di << aSStream;
1669       Handle(Geom_BSplineCurve) BSCurve = appr.Curve3d(); 
1670       DrawTrSurf::Set(a[2], BSCurve);
1671     }
1672   }
1673   
1674
1675   return 0;
1676 }
1677
1678 //=======================================================================
1679 //function : newbspline
1680 //purpose  : reduce the multiplicity of the knots to their minimum 
1681 //           compared to the degree of the curve
1682 //=======================================================================
1683
1684 static Standard_Integer splitc1(Draw_Interpretor& di,
1685                                    Standard_Integer n, const char** c)
1686
1687 {Standard_Real      tolerance=1.0e-5,
1688    angular_tolerance = 1.0e-4 ;
1689  Standard_Integer   optiontab,i;
1690  char name[100];
1691
1692  if (n<3) return 1;
1693  optiontab=atoi(c[2]);
1694  if (n >= 4 )
1695    tolerance=atof(c[3]);
1696  if (n >= 5) {
1697    angular_tolerance = atof(c[4]) ;
1698  }
1699  Handle(Geom_Curve) ACurve = Handle(Geom_Curve)::DownCast(DrawTrSurf::Get(c[1])) ;
1700  
1701  Standard_Real f = ACurve->FirstParameter();
1702  Standard_Real l = ACurve->LastParameter();
1703
1704  if ( Precision::IsInfinite(f) || Precision::IsInfinite(l)) {
1705    di << " Error: Infinite curves" << "\n";
1706    return 1;
1707  }
1708
1709  Handle(Geom_BSplineCurve) BS = GeomConvert::CurveToBSplineCurve(ACurve);
1710  
1711  if ( BS.IsNull()) return 1;
1712
1713  if (optiontab){
1714    Handle(TColGeom_HArray1OfBSplineCurve)  tabBS;
1715    GeomConvert::C0BSplineToArrayOfC1BSplineCurve(BS,
1716                                                  tabBS,
1717                                                  angular_tolerance,
1718                                                  tolerance);
1719    for (i=0;i<=(tabBS->Length()-1);i++){
1720      sprintf(name,"%s_%d",c[1],i+1);
1721      Standard_CString new_name = name ;
1722      DrawTrSurf::Set(new_name,
1723                      tabBS->Value(i));
1724      di.AppendElement(name);
1725    }
1726  }
1727  else{
1728    GeomConvert::C0BSplineToC1BSplineCurve(BS,
1729                                           tolerance,
1730                                           angular_tolerance) ;
1731
1732    DrawTrSurf::Set(c[1],BS);
1733  }
1734  return 0;
1735 }
1736
1737 //=======================================================================
1738 //function : splitc12d
1739 //purpose  : reduce the multiplicity of the knots to their minimum 
1740 //           compared to the degree of the curve
1741 //=======================================================================
1742
1743 static Standard_Integer splitc12d(Draw_Interpretor& di,
1744                                      Standard_Integer n, const char** c)
1745
1746 {Standard_Real      tolerance=1.0e-5,
1747    angular_tolerance = 1.0e-4 ;
1748  Standard_Integer   optiontab,i;
1749  char name[100];
1750
1751  if (n<3) return 1;
1752  optiontab=atoi(c[2]);
1753  if (n==4)
1754    tolerance=atof(c[3]);
1755  if (n==5) 
1756    angular_tolerance = atof(c[4]) ;
1757  Handle(Geom2d_Curve) ACurve = Handle(Geom2d_Curve)::DownCast(DrawTrSurf::GetCurve2d(c[1])) ;
1758  
1759  Standard_Real f = ACurve->FirstParameter();
1760  Standard_Real l = ACurve->LastParameter();
1761
1762  if ( Precision::IsInfinite(f) || Precision::IsInfinite(l)) {
1763    di << " Error: Infinite curves" << "\n";
1764    return 1;
1765  }
1766
1767  Handle(Geom2d_BSplineCurve) BS = Geom2dConvert::CurveToBSplineCurve(ACurve);
1768  
1769  if ( BS.IsNull()) return 1;
1770
1771  if (optiontab){
1772    Handle(TColGeom2d_HArray1OfBSplineCurve)  tabBS;
1773    Geom2dConvert::C0BSplineToArrayOfC1BSplineCurve(BS,
1774                                                    tabBS,
1775                                                    angular_tolerance,
1776                                                    tolerance);
1777    for (i=0;i<=(tabBS->Length()-1);i++){
1778      sprintf(name,"%s_%d",c[1],i+1);
1779      Standard_CString new_name = name ;
1780      DrawTrSurf::Set(new_name,
1781                      tabBS->Value(i));
1782      di.AppendElement(name);
1783    }
1784  }
1785  else{
1786    Geom2dConvert::C0BSplineToC1BSplineCurve(BS,tolerance);
1787    DrawTrSurf::Set(c[1],BS);
1788  }
1789  return 0;
1790 }
1791
1792 //=======================================================================
1793 //function : canceldenom
1794 //purpose  : set the value of the denominator cancel its first 
1795 //           derivative on the boundaries of the surface if possible
1796 //=======================================================================
1797
1798 static Standard_Integer canceldenom(Draw_Interpretor& ,
1799                                      Standard_Integer n, const char** c)
1800
1801 {Standard_Integer    uoption,voption;
1802  Standard_Boolean    udirection=Standard_False;
1803  Standard_Boolean    vdirection=Standard_False;
1804  if (n<4) return 1;
1805  uoption=atoi(c[2]);
1806  voption=atoi(c[3]);
1807  if (uoption)
1808    udirection=Standard_True;
1809  if (voption)
1810    vdirection=Standard_True;
1811  Handle(Geom_BSplineSurface) BSurf = Handle(Geom_BSplineSurface)::DownCast(DrawTrSurf::GetBSplineSurface(c[1]));
1812  GeomLib::CancelDenominatorDerivative(BSurf,udirection,vdirection);
1813  DrawTrSurf::Set(c[1],BSurf);
1814  return 0;
1815 }
1816
1817 //=======================================================================
1818 //function : length
1819 //purpose  : eval curve's length
1820 //=======================================================================
1821
1822 static Standard_Integer length(Draw_Interpretor& di,
1823                                Standard_Integer n, const char** a)
1824 {
1825   if (n<2) return 1;
1826   Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[1]);
1827   Handle(Geom2d_Curve) GC2d = DrawTrSurf::GetCurve2d(a[1]);
1828   Standard_Real Tol = Precision::Confusion(), L;
1829   if (n==3) Tol = atof(a[2]);
1830
1831   if (!GC.IsNull()) {
1832     GeomAdaptor_Curve AC(GC);
1833     L = GCPnts_AbscissaPoint::Length(AC, Tol);
1834   }  
1835   else if (!GC2d.IsNull()) {
1836     Geom2dAdaptor_Curve AC(GC2d);
1837     L = GCPnts_AbscissaPoint::Length(AC, Tol);
1838   }
1839   else {
1840     di << a[1] << "is not a curve" << "\n";
1841     return 1;
1842   }
1843
1844   di << "The length " << a[1] << " is " << L << "\n";
1845   return 0;
1846 }
1847
1848
1849
1850 //=======================================================================
1851 //function : CurveCommands
1852 //purpose  : 
1853 //=======================================================================
1854
1855 void  GeomliteTest::CurveCommands(Draw_Interpretor& theCommands)
1856 {
1857   
1858   static Standard_Boolean loaded = Standard_False;
1859   if (loaded) return;
1860   loaded = Standard_True;
1861   
1862   DrawTrSurf::BasicCommands(theCommands);
1863   
1864   const char* g;
1865   
1866   
1867   // analytic curves
1868   g = "GEOMETRY curves creation";
1869
1870
1871   theCommands.Add("point",
1872                   "point name x y [z]",
1873                   __FILE__,
1874                   point ,g);
1875   
1876   theCommands.Add("line",
1877                   "line name pos dir",
1878                   __FILE__,
1879                   anacurve,g);
1880   
1881   theCommands.Add("circle",
1882                   "circle name x y [z [dx dy dz]] [ux uy [uz]] radius",
1883                   __FILE__,
1884                   anacurve,g);
1885   
1886   theCommands.Add("ellipse",
1887                   "ellipse name x y [z [dx dy dz]] [ux uy [uz]] major minor",
1888                   __FILE__,
1889                   anacurve,g);
1890   theCommands.Add("parabola",
1891                   "parabola name x y [z [dx dy dz]] [ux uy [uz]] focal",
1892                   __FILE__,
1893                   anacurve,g);
1894   theCommands.Add("hyperbola",
1895                   "hyperbola name x y [z [dx dy dz]] [ux uy [uz]] major minor",
1896                   __FILE__,
1897                   anacurve,g);
1898
1899   theCommands.Add("beziercurve",
1900                   "beziercurve name nbpole pole, [weight]",
1901                   __FILE__,
1902                   polecurve,g);
1903
1904   theCommands.Add("bsplinecurve",
1905                   "bsplinecurve name degree nbknots  knot, umult  pole, weight",
1906                   __FILE__,
1907                   polecurve,g);
1908
1909   theCommands.Add("pbsplinecurve",
1910                   "pbsplinecurve name degree nbknots  knot, umult  pole, weight (periodic)",
1911                   __FILE__,
1912                   polecurve,g);
1913
1914   theCommands.Add("2dbeziercurve",
1915                   "2dbeziercurve name nbpole pole, [weight]",
1916                   __FILE__,
1917                   polecurve2d,g);
1918
1919   theCommands.Add("2dbsplinecurve",
1920                   "2dbsplinecurve name degree nbknots  knot, umult  pole, weight",
1921                   __FILE__,
1922                   polecurve2d,g);
1923
1924   theCommands.Add("2dpbsplinecurve",
1925                   "2dpbsplinecurve name degree nbknots  knot, umult  pole, weight (periodic)",
1926                   __FILE__,
1927                   polecurve2d,g);
1928
1929   g = "GEOMETRY Curves and Surfaces modification";
1930
1931   theCommands.Add("reverse",
1932                   "reverse name ... ",
1933                   __FILE__,
1934                   reverse,g);
1935
1936   theCommands.Add("cmovep",
1937                   "cmovep name index dx dy dz",
1938                   __FILE__,
1939                   cmovepole,g);
1940
1941   theCommands.Add("cmovepoint",
1942                   "cmovepoint name u dx dy [dz index1 index2]",
1943                   __FILE__,
1944                   cmovepoint,g);
1945
1946   theCommands.Add("cmovetangent",
1947                   "cmovetangent name u  x y [z] tx ty [tz constraint = 0]",
1948                   __FILE__,
1949                   cmovetangent,g) ;
1950
1951   theCommands.Add("insertknot",
1952                   "insertknot name knot [mult = 1] [knot mult ...]",
1953                   __FILE__,
1954                   cinsertknot,g);
1955
1956   theCommands.Add("setknot",
1957                   "setknot name index knot [mult]",
1958                   __FILE__,
1959                   csetknot,g);
1960
1961   theCommands.Add("remknot",
1962                   "remknot name index [mult] [tol]",
1963                   __FILE__,
1964                   cremknot,g);
1965
1966   theCommands.Add("incdeg",
1967                   "incdeg name degree",
1968                   __FILE__,
1969                   increasedegree,g);
1970
1971   theCommands.Add("rempole",
1972                   "rempole name index",
1973                   __FILE__,
1974                   removepole,g);
1975
1976   theCommands.Add("insertpole",
1977                   "insertpole name index x y [z] [weight]",
1978                   __FILE__,
1979                   insertpole,g);
1980
1981   theCommands.Add("cfindp",
1982                   "cfindp name view x y index",
1983                   __FILE__,
1984                   cfindp,g);
1985
1986   theCommands.Add("setperiodic",
1987                   "setperiodic name ...",
1988                   __FILE__,
1989                   csetperiodic,g);
1990
1991   theCommands.Add("setnotperiodic",
1992                   "setnotperiodic name",
1993                   __FILE__,
1994                   csetperiodic,g);
1995
1996   theCommands.Add("segment",
1997                   "segment name Ufirst Ulast",
1998                    __FILE__,
1999                   segment , g);
2000
2001   theCommands.Add("setorigin",
2002                   "setorigin name knotindex",
2003                    __FILE__,
2004                   setorigin , g);
2005
2006   g = "GEOMETRY curves and surfaces analysis";
2007
2008   theCommands.Add("cvalue",
2009                   "cvalue curvename U  X Y Z [D1X D1Y D1Z D2X D2Y D2Z]",
2010                   __FILE__,
2011                   value,g);
2012
2013   theCommands.Add("2dcvalue",
2014                   "2dcvalue curvename U  X Y [D1X D1Y D2X D2Y]",
2015                   __FILE__,
2016                   value2d,g);
2017
2018   theCommands.Add("coord",
2019                   "coord P x y [z]: set in x y [z] the coordinates of P",
2020                   __FILE__,
2021                   coord,g);
2022
2023   theCommands.Add("minmaxcurandinf",
2024                   "minmaxcurandinf curve",
2025                   __FILE__,
2026                   minmaxcurandinf,g);
2027   
2028   theCommands.Add("shcurvature",
2029                   "shcurvature curvename",
2030                   __FILE__,
2031                   shcurvature,g);
2032
2033   theCommands.Add("clcurvature",
2034                   "clcurvature curvename",
2035                   __FILE__,
2036                   clcurvature,g);
2037   
2038
2039  theCommands.Add("radiusmax",
2040                   "radiusmax curvename  radius",
2041                   __FILE__,
2042                   radiusmax,g);
2043
2044  theCommands.Add("radiusratio",
2045                   "radiusratio curvename ratio",
2046                   __FILE__,
2047                   radiusratio,g); 
2048   theCommands.Add("localprop",
2049                   "localprop curvename U",
2050                   __FILE__,
2051                   localprop,g);
2052   theCommands.Add("rawcont",
2053                   "rawcont curve1 curve2 u1 u2",
2054                   __FILE__,
2055                   rawcont,g) ;
2056   theCommands.Add("approxcurve",
2057                   "approxcurve [-L] name curve1 [Surf1] [curve2d2 Surf2] [Tol [cont [maxdeg [maxseg]]]] ",
2058                   __FILE__,
2059                   approxcurve,g);
2060
2061   theCommands.Add("approxcurveonsurf",
2062                   "approxcurveonsurf name curve2d surface [Tol [cont [maxdeg [maxseg]]]] ",
2063                   __FILE__,
2064                   approxcurveonsurf,g);
2065
2066  theCommands.Add("length", "length curve [Tol]", 
2067                   __FILE__,
2068                   length, g);
2069
2070
2071   theCommands.Add("splitc1",
2072                   "splitc1 bspline resultinarray(0/1) [tol] [angtol] ",
2073                   __FILE__,
2074                   splitc1,g);
2075
2076   theCommands.Add("splitc12d",
2077                   "splitc12d bspline2d resultinarray(0/1) [tol] [angtol] ",
2078                   __FILE__,
2079                   splitc12d,g);
2080   theCommands.Add("canceldenom",
2081                   "canceldenom BSpline-Surface UDirection(0/1) VDirection(0/1)",
2082                   __FILE__,
2083                   canceldenom,g);
2084
2085  
2086
2087 }