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