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