Commit | Line | Data |
---|---|---|
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. | |
7fd59977 | 16 | |
7fd59977 | 17 | |
42cf5bc1 | 18 | #include <Draw.hxx> |
19 | #include <Draw_Appli.hxx> | |
7fd59977 | 20 | #include <Draw_Color.hxx> |
42cf5bc1 | 21 | #include <DrawTrSurf.hxx> |
7fd59977 | 22 | #include <DrawTrSurf_BezierCurve.hxx> |
7fd59977 | 23 | #include <DrawTrSurf_BezierCurve2d.hxx> |
42cf5bc1 | 24 | #include <DrawTrSurf_BezierSurface.hxx> |
25 | #include <DrawTrSurf_BSplineCurve.hxx> | |
7fd59977 | 26 | #include <DrawTrSurf_BSplineCurve2d.hxx> |
42cf5bc1 | 27 | #include <DrawTrSurf_BSplineSurface.hxx> |
28 | #include <DrawTrSurf_Curve.hxx> | |
29 | #include <DrawTrSurf_Curve2d.hxx> | |
30 | #include <DrawTrSurf_Drawable.hxx> | |
31 | #include <DrawTrSurf_Point.hxx> | |
7fd59977 | 32 | #include <DrawTrSurf_Polygon2D.hxx> |
42cf5bc1 | 33 | #include <DrawTrSurf_Polygon3D.hxx> |
34 | #include <DrawTrSurf_Surface.hxx> | |
35 | #include <DrawTrSurf_Triangulation.hxx> | |
36 | #include <Geom2d_BezierCurve.hxx> | |
37 | #include <Geom2d_BSplineCurve.hxx> | |
38 | #include <Geom2d_Curve.hxx> | |
39 | #include <Geom_BezierCurve.hxx> | |
40 | #include <Geom_BezierSurface.hxx> | |
41 | #include <Geom_BSplineCurve.hxx> | |
42 | #include <Geom_BSplineSurface.hxx> | |
43 | #include <Geom_Curve.hxx> | |
44 | #include <Geom_Geometry.hxx> | |
45 | #include <Geom_Surface.hxx> | |
7fd59977 | 46 | #include <GeomTools_Curve2dSet.hxx> |
42cf5bc1 | 47 | #include <GeomTools_CurveSet.hxx> |
7fd59977 | 48 | #include <GeomTools_SurfaceSet.hxx> |
7fd59977 | 49 | #include <gp_Ax2.hxx> |
42cf5bc1 | 50 | #include <gp_Ax2d.hxx> |
51 | #include <gp_Pln.hxx> | |
52 | #include <gp_Pnt.hxx> | |
53 | #include <gp_Pnt2d.hxx> | |
7fd59977 | 54 | #include <gp_Trsf2d.hxx> |
55 | #include <Poly.hxx> | |
42cf5bc1 | 56 | #include <Poly_Polygon2D.hxx> |
57 | #include <Poly_Polygon3D.hxx> | |
58 | #include <Poly_Triangulation.hxx> | |
59 | #include <Standard_Stream.hxx> | |
445f3267 | 60 | #include <TCollection_AsciiString.hxx> |
7fd59977 | 61 | |
62 | static Draw_Color PntColor(Draw_rouge); | |
63 | static Draw_Color CurvColor(Draw_jaune); | |
64 | static Draw_Color BoundsColor(Draw_vert); | |
65 | static Draw_Color IsosColor(Draw_bleu); | |
66 | static Draw_Color PolesColor(Draw_rouge); | |
67 | static Draw_Color KnotsColor(Draw_violet); | |
68 | ||
69 | static Draw_MarkerShape PntShape = Draw_Plus; | |
70 | static Draw_MarkerShape KnotsShape = Draw_Losange; | |
71 | static Standard_Boolean ShowPoles = Standard_True; | |
72 | static Standard_Boolean ShowKnots = Standard_True; | |
73 | static Standard_Boolean knotsIsos =Standard_True; | |
74 | static Standard_Real Deflection = 0.01; | |
75 | static Standard_Integer KnotsSize = 5; | |
76 | static Standard_Integer Discret = 30; | |
77 | static Standard_Integer DrawMode = 0; | |
78 | static Standard_Integer NbUIsos = 10; | |
79 | static Standard_Integer NbVIsos = 10; | |
80 | ||
445f3267 S |
81 | static TCollection_AsciiString ColorsHint( |
82 | "The possible colors are: \n\ | |
83 | white, red, green, blue, cyan,\n\ | |
84 | golden, magenta, brown, orange, pink,\n\ | |
85 | salmon, violet, yellow, darkgreen, coral"); | |
86 | ||
87 | static TCollection_AsciiString MarkersHint( | |
88 | "The possible markers are: \n\ | |
89 | square, diamond, x, plus, circle, circle_zoom"); | |
90 | ||
91 | //======================================================================= | |
92 | //function : DrawTrSurf_CurveColor | |
93 | //purpose : Sets new color for rendering of curves. Returns the | |
94 | // previous one to keep possibility to restore the initial | |
95 | // state | |
96 | //======================================================================= | |
97 | ||
7fd59977 | 98 | Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col) |
99 | { | |
100 | Draw_Color c = CurvColor; | |
101 | CurvColor = col; | |
102 | return c; | |
103 | } | |
104 | ||
445f3267 S |
105 | //======================================================================= |
106 | //function : DrawTrSurf_PointColor | |
107 | //purpose : Sets new color for rendering of points. Returns the | |
108 | // previous one to keep possibility to restore the initial | |
109 | // state | |
110 | //======================================================================= | |
111 | ||
112 | Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color col) | |
113 | { | |
114 | Draw_Color c = PntColor; | |
115 | PntColor = col; | |
116 | return c; | |
117 | } | |
118 | ||
119 | //======================================================================= | |
120 | //function : DrawTrSurf_PointMarker | |
121 | //purpose : Sets new marker for rendering of points. Returns the | |
122 | // previous one to keep possibility to restore the initial | |
123 | // state | |
124 | //======================================================================= | |
125 | ||
126 | Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape marker) | |
127 | { | |
128 | Draw_MarkerShape prev = PntShape; | |
129 | PntShape = marker; | |
130 | return prev; | |
131 | } | |
132 | ||
7fd59977 | 133 | //======================================================================= |
134 | //function : GetDrawable | |
135 | //purpose : | |
136 | //======================================================================= | |
137 | static Handle(DrawTrSurf_Drawable) GetDrawable(Standard_CString& Name) | |
138 | { | |
139 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
140 | Handle(DrawTrSurf_Drawable) Dr; | |
141 | if (!D.IsNull()) | |
142 | Dr = Handle(DrawTrSurf_Drawable)::DownCast(D); | |
143 | return Dr; | |
144 | } | |
145 | ||
146 | //======================================================================= | |
147 | //function : GetSurface | |
148 | //purpose : | |
149 | //======================================================================= | |
150 | static Handle(DrawTrSurf_Surface) GetSurface(Standard_CString& Name) | |
151 | { | |
152 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
153 | Handle(DrawTrSurf_Surface) Dr; | |
154 | if (!D.IsNull()) | |
155 | Dr = Handle(DrawTrSurf_Surface)::DownCast(D); | |
156 | return Dr; | |
157 | } | |
158 | ||
159 | //======================================================================= | |
160 | //function : GetBezierSurface | |
161 | //purpose : | |
162 | //======================================================================= | |
163 | static Handle(DrawTrSurf_BezierSurface) GetBezierSurface(Standard_CString& Name) | |
164 | { | |
165 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
166 | Handle(DrawTrSurf_BezierSurface) Dr; | |
167 | if (!D.IsNull()) | |
168 | Dr = Handle(DrawTrSurf_BezierSurface)::DownCast(D); | |
169 | return Dr; | |
170 | } | |
171 | ||
172 | //======================================================================= | |
173 | //function : GetBSplineSurface | |
174 | //purpose : | |
175 | //======================================================================= | |
176 | static Handle(DrawTrSurf_BSplineSurface) GetBSplineSurface(Standard_CString& Name) | |
177 | { | |
178 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
179 | Handle(DrawTrSurf_BSplineSurface) Dr; | |
180 | if (!D.IsNull()) | |
181 | Dr = Handle(DrawTrSurf_BSplineSurface)::DownCast(D); | |
182 | return Dr; | |
183 | } | |
184 | ||
7fd59977 | 185 | //======================================================================= |
186 | //function : GetBezierCurve | |
187 | //purpose : | |
188 | //======================================================================= | |
189 | static Handle(DrawTrSurf_BezierCurve) GetBezierCurve(Standard_CString& Name) | |
190 | { | |
191 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
192 | Handle(DrawTrSurf_BezierCurve) Dr; | |
193 | if (!D.IsNull()) | |
194 | Dr = Handle(DrawTrSurf_BezierCurve)::DownCast(D); | |
195 | return Dr; | |
196 | } | |
197 | ||
198 | //======================================================================= | |
199 | //function : GetBSplineCurve | |
200 | //purpose : | |
201 | //======================================================================= | |
202 | static Handle(DrawTrSurf_BSplineCurve) GetBSplineCurve(Standard_CString& Name) | |
203 | { | |
204 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
205 | Handle(DrawTrSurf_BSplineCurve) Dr; | |
206 | if (!D.IsNull()) | |
207 | Dr = Handle(DrawTrSurf_BSplineCurve)::DownCast(D); | |
208 | return Dr; | |
209 | } | |
210 | ||
211 | //======================================================================= | |
212 | //function : GetBezierCurve2d | |
213 | //purpose : | |
214 | //======================================================================= | |
215 | static Handle(DrawTrSurf_BezierCurve2d) GetBezierCurve2d(Standard_CString& Name) | |
216 | { | |
217 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
218 | Handle(DrawTrSurf_BezierCurve2d) Dr; | |
219 | if (!D.IsNull()) | |
220 | Dr = Handle(DrawTrSurf_BezierCurve2d)::DownCast(D); | |
221 | return Dr; | |
222 | } | |
223 | ||
224 | //======================================================================= | |
225 | //function : GetBSplineCurve2d | |
226 | //purpose : | |
227 | //======================================================================= | |
228 | static Handle(DrawTrSurf_BSplineCurve2d) GetBSplineCurve2d(Standard_CString& Name) | |
229 | { | |
230 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
231 | Handle(DrawTrSurf_BSplineCurve2d) Dr; | |
232 | if (!D.IsNull()) | |
233 | Dr = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(D); | |
234 | return Dr; | |
235 | } | |
236 | ||
237 | ||
238 | //======================================================================= | |
239 | //function : nbiso | |
240 | //purpose : | |
241 | //======================================================================= | |
242 | static Standard_Integer nbiso (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
243 | { | |
244 | if (n < 4) { | |
245 | if (n == 3) { | |
91322f44 | 246 | NbUIsos = Draw::Atoi(a[1]); |
247 | NbVIsos = Draw::Atoi(a[2]); | |
7fd59977 | 248 | } |
249 | di << NbUIsos << " " << NbVIsos; | |
250 | } | |
251 | else { | |
252 | for (Standard_Integer i = 1; i < n - 2; i++) { | |
253 | Handle(DrawTrSurf_Surface) DS = GetSurface(a[i]); | |
254 | if (!DS.IsNull()) { | |
91322f44 | 255 | DS->ShowIsos(Draw::Atoi(a[n-2]),Draw::Atoi(a[n-1])); |
7fd59977 | 256 | Draw::Repaint(); |
257 | } | |
258 | } | |
259 | } | |
260 | return 0; | |
261 | } | |
262 | ||
263 | //======================================================================= | |
264 | //function : drawpoles | |
265 | //purpose : | |
266 | //======================================================================= | |
267 | ||
268 | static Standard_Integer drawpoles(Draw_Interpretor&, | |
269 | Standard_Integer n, | |
270 | const char** a) | |
271 | { | |
272 | if ( n == 1) { | |
273 | if ( !strcmp(a[0],"shpoles")) { | |
274 | ShowPoles = Standard_True; | |
275 | } | |
276 | else if ( !strcmp(a[0],"clpoles")) { | |
277 | ShowPoles = Standard_False; | |
278 | } | |
279 | else if ( !strcmp(a[0],"shknots")) { | |
280 | ShowKnots = Standard_True; | |
281 | } | |
282 | else if ( !strcmp(a[0],"clknots")) { | |
283 | ShowKnots = Standard_False; | |
284 | } | |
285 | } | |
286 | ||
287 | if ( n<2) return 1; | |
288 | ||
289 | Handle(DrawTrSurf_BezierSurface) BZS; | |
290 | BZS = GetBezierSurface(a[1]); | |
291 | if ( !BZS.IsNull()) { | |
292 | if ( !strcmp(a[0],"shpoles")) { | |
293 | BZS->ShowPoles(); | |
294 | } | |
295 | else if ( !strcmp(a[0],"clpoles")) { | |
296 | BZS->ClearPoles(); | |
297 | } | |
298 | else { | |
299 | return 1; | |
300 | } | |
301 | } | |
302 | else { | |
303 | Handle(DrawTrSurf_BSplineSurface) BSS = GetBSplineSurface(a[1]); | |
304 | if ( !BSS.IsNull()) { | |
305 | if ( !strcmp(a[0],"shpoles")) { | |
306 | BSS->ShowPoles(); | |
307 | } | |
308 | else if ( !strcmp(a[0],"clpoles")) { | |
309 | BSS->ClearPoles(); | |
310 | } | |
311 | else if ( !strcmp(a[0],"shknots")) { | |
312 | BSS->ShowKnots(); | |
313 | } | |
314 | else if ( !strcmp(a[0],"clknots")) { | |
315 | BSS->ClearKnots(); | |
316 | } | |
317 | } | |
318 | else { | |
319 | Handle(DrawTrSurf_BezierCurve) BZC = GetBezierCurve(a[1]); | |
320 | if ( !BZC.IsNull()) { | |
321 | if ( !strcmp(a[0],"shpoles")) { | |
322 | BZC->ShowPoles(); | |
323 | } | |
324 | else if ( !strcmp(a[0],"clpoles")) { | |
325 | BZC->ClearPoles(); | |
326 | } | |
327 | else { | |
328 | return 1; | |
329 | } | |
330 | } | |
331 | else { | |
332 | Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]); | |
333 | if ( !BSC.IsNull()) { | |
334 | if ( !strcmp(a[0],"shpoles")) { | |
335 | BSC->ShowPoles(); | |
336 | } | |
337 | else if ( !strcmp(a[0],"clpoles")) { | |
338 | BSC->ClearPoles(); | |
339 | } | |
340 | else if ( !strcmp(a[0],"shknots")) { | |
341 | BSC->ShowKnots(); | |
342 | } | |
343 | else if ( !strcmp(a[0],"clknots")) { | |
344 | BSC->ClearKnots(); | |
345 | } | |
346 | } | |
347 | else { | |
348 | Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]); | |
349 | if ( !BZ2.IsNull()) { | |
350 | if ( !strcmp(a[0],"shpoles")) { | |
351 | BZ2->ShowPoles(); | |
352 | } | |
353 | else if ( !strcmp(a[0],"clpoles")) { | |
354 | BZ2->ClearPoles(); | |
355 | } | |
356 | else { | |
357 | return 1; | |
358 | } | |
359 | } | |
360 | else { | |
361 | Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]); | |
362 | if ( !BS2.IsNull()) { | |
363 | if ( !strcmp(a[0],"shpoles")) { | |
364 | BS2->ShowPoles(); | |
365 | } | |
366 | else if ( !strcmp(a[0],"clpoles")) { | |
367 | BS2->ClearPoles(); | |
368 | } | |
369 | else if ( !strcmp(a[0],"shknots")) { | |
370 | BS2->ShowKnots(); | |
371 | } | |
372 | else if ( !strcmp(a[0],"clknots")) { | |
373 | BS2->ClearKnots(); | |
374 | } | |
375 | } | |
376 | else { | |
377 | return 1; | |
378 | } | |
379 | } | |
380 | } | |
381 | } | |
382 | } | |
383 | } | |
384 | Draw::Repaint(); | |
385 | return 0; | |
386 | } | |
387 | ||
388 | //======================================================================= | |
389 | //function : draw | |
390 | //purpose : | |
391 | //======================================================================= | |
392 | ||
393 | static Standard_Integer draw (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
394 | { | |
395 | if (n <= 2) { | |
396 | if (!strcmp(a[0],"dmode")) { | |
397 | if (n == 2) { | |
7fd59977 | 398 | DrawMode = 1; |
399 | } | |
400 | if (DrawMode) | |
401 | di << "u"; | |
402 | else | |
403 | di << "d"; | |
404 | } | |
405 | ||
406 | else if (!strcmp(a[0],"discr")) { | |
407 | if (n == 2) | |
91322f44 | 408 | Discret = Draw::Atoi(a[n-1]); |
7fd59977 | 409 | di << Discret; |
410 | } | |
411 | ||
412 | else if (!strcmp(a[0],"defle")) { | |
413 | if (n == 2) | |
91322f44 | 414 | Deflection = Draw::Atof(a[n-1]); |
7fd59977 | 415 | di << Deflection; |
416 | } | |
417 | } | |
418 | else { | |
419 | for (Standard_Integer i = 1; i < n - 1; i++) { | |
420 | Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]); | |
421 | if (!D.IsNull()) { | |
422 | if (!strcmp(a[0],"dmode")) { | |
423 | Standard_Integer mod = 0; | |
424 | if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1; | |
425 | D->SetDrawMode(mod); | |
426 | } | |
427 | ||
428 | else if (!strcmp(a[0],"discr")) { | |
91322f44 | 429 | D->SetDiscretisation(Draw::Atoi(a[n-1])); |
7fd59977 | 430 | } |
431 | ||
432 | else if (!strcmp(a[0],"defle")) { | |
91322f44 | 433 | D->SetDeflection(Draw::Atof(a[n-1])); |
7fd59977 | 434 | } |
435 | ||
436 | Draw::Repaint(); | |
437 | } | |
438 | } | |
439 | } | |
440 | return 0; | |
441 | } | |
442 | ||
443 | //======================================================================= | |
444 | //function : transform | |
445 | //purpose : | |
446 | //======================================================================= | |
447 | ||
448 | static Standard_Integer transform (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
449 | { | |
450 | if (n < 5) return 1; | |
451 | gp_Trsf T; | |
452 | Standard_Integer i,last = n-1; | |
453 | if (!strcmp(a[0],"pscale")) { | |
91322f44 | 454 | Standard_Real s = Draw::Atof(a[last]); |
7fd59977 | 455 | last--; |
456 | if (last < 4) return 1; | |
91322f44 | 457 | gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 458 | T.SetScale(P,s); |
459 | } | |
460 | else if (!strcmp(a[0]+1,"mirror")) { | |
461 | if (last < 4) return 1; | |
91322f44 | 462 | gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 463 | if (*a[0] == 'p') { |
464 | T.SetMirror(P); | |
465 | } | |
466 | else { | |
467 | last -= 3; | |
468 | if (last < 4) return 1; | |
91322f44 | 469 | gp_Pnt O(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 470 | last -= 3; |
471 | gp_Dir D(P.X(),P.Y(),P.Z()); | |
472 | if (*a[0] == 'l') { | |
473 | T.SetMirror(gp_Ax1(O,D)); | |
474 | } | |
475 | else if (*a[0] == 's') { | |
476 | gp_Pln Pl(O,D); | |
477 | T.SetMirror(Pl.Position().Ax2()); | |
478 | } | |
479 | } | |
480 | } | |
481 | ||
482 | else if (!strcmp(a[0],"translate")) { | |
483 | if (last < 4) return 1; | |
91322f44 | 484 | gp_Vec V(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 485 | last -= 3; |
486 | T.SetTranslation(V); | |
487 | } | |
488 | ||
489 | else if (!strcmp(a[0],"rotate")) { | |
490 | if (last < 8) return 1; | |
91322f44 | 491 | Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0); |
7fd59977 | 492 | last --; |
91322f44 | 493 | gp_Dir D(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 494 | last -= 3; |
91322f44 | 495 | gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 496 | last -= 3; |
497 | T.SetRotation(gp_Ax1(P,D),ang); | |
498 | } | |
499 | ||
500 | for (i = 1; i <= last; i++) { | |
501 | Handle(Geom_Geometry) G = DrawTrSurf::Get(a[i]); | |
502 | if (!G.IsNull()) { | |
503 | G->Transform(T); | |
504 | Draw::Repaint(); | |
505 | } | |
506 | else { | |
507 | gp_Pnt P; | |
508 | if (DrawTrSurf::GetPoint(a[i],P)) { | |
509 | P.Transform(T); | |
510 | DrawTrSurf::Set(a[i],P); | |
511 | } | |
512 | } | |
513 | di << a[i] << " "; | |
514 | } | |
515 | return 0; | |
516 | } | |
517 | ||
518 | //======================================================================= | |
519 | //function : d2transform | |
520 | //purpose : | |
521 | //======================================================================= | |
522 | ||
523 | static Standard_Integer d2transform (Draw_Interpretor& di, Standard_Integer n, const char** a) | |
524 | { | |
525 | if (n < 4) return 1; | |
526 | gp_Trsf2d T; | |
527 | Standard_Integer i,last = n-1; | |
528 | if (!strcmp(a[0],"2dpscale")) { | |
91322f44 | 529 | Standard_Real s = Draw::Atof(a[last]); |
7fd59977 | 530 | last--; |
531 | if (last < 3) return 1; | |
91322f44 | 532 | gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 533 | T.SetScale(P,s); |
534 | } | |
535 | else if ( (!strcmp(a[0],"2dpmirror")) || | |
536 | (!strcmp(a[0],"2dlmirror")) ) { | |
537 | if (last < 3) return 1; | |
91322f44 | 538 | gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 539 | if (!strcmp(a[0],"2dpmirror")) { |
540 | T.SetMirror(P); | |
541 | } | |
542 | else { | |
543 | last -= 2; | |
544 | if (last < 3) return 1; | |
91322f44 | 545 | gp_Pnt2d O(Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 546 | last -= 2; |
547 | gp_Dir2d D(P.X(),P.Y()); | |
548 | T.SetMirror(gp_Ax2d(O,D)); | |
549 | } | |
550 | } | |
551 | ||
552 | else if (!strcmp(a[0],"2dtranslate")) { | |
553 | if (last < 3) return 1; | |
91322f44 | 554 | gp_Vec2d V(Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 555 | last -= 2; |
556 | T.SetTranslation(V); | |
557 | } | |
558 | ||
559 | else if (!strcmp(a[0],"2drotate")) { | |
560 | if (last < 4) return 1; | |
91322f44 | 561 | Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0); |
7fd59977 | 562 | last --; |
91322f44 | 563 | gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last])); |
7fd59977 | 564 | last -= 2; |
565 | T.SetRotation(P,ang); | |
566 | } | |
567 | ||
568 | for (i = 1; i <= last; i++) { | |
569 | Handle(Geom2d_Curve) G = DrawTrSurf::GetCurve2d(a[i]); | |
570 | if (!G.IsNull()) { | |
571 | G->Transform(T); | |
572 | Draw::Repaint(); | |
573 | } | |
574 | else { | |
575 | gp_Pnt2d P; | |
576 | if (DrawTrSurf::GetPoint2d(a[i],P)) { | |
577 | P.Transform(T); | |
578 | DrawTrSurf::Set(a[i],P); | |
579 | } | |
580 | } | |
581 | di << a[i] << " "; | |
582 | } | |
583 | return 0; | |
584 | } | |
585 | ||
586 | //======================================================================= | |
587 | //function : Set | |
588 | //purpose : point | |
589 | //======================================================================= | |
590 | void DrawTrSurf::Set(const Standard_CString Name, | |
591 | const gp_Pnt& P) | |
592 | { | |
593 | Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor); | |
594 | Draw::Set(Name,DP); | |
595 | } | |
596 | ||
597 | //======================================================================= | |
598 | //function : Set | |
599 | //purpose : point | |
600 | //======================================================================= | |
601 | void DrawTrSurf::Set(const Standard_CString Name, | |
602 | const gp_Pnt2d& P) | |
603 | { | |
604 | Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor); | |
605 | Draw::Set(Name,DP); | |
606 | } | |
607 | ||
608 | //======================================================================= | |
609 | //function : Set | |
610 | //purpose : Geometry from Geom | |
611 | //======================================================================= | |
612 | void DrawTrSurf::Set(const Standard_CString Name, | |
445f3267 S |
613 | const Handle(Geom_Geometry)& G, |
614 | const Standard_Boolean isSenseMarker) | |
7fd59977 | 615 | { |
616 | Handle(DrawTrSurf_Drawable) D; | |
617 | if (!G.IsNull()) { | |
618 | ||
619 | Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G); | |
620 | if (!C.IsNull()) { | |
621 | ||
622 | Handle(Geom_BezierCurve) Bez = | |
623 | Handle(Geom_BezierCurve)::DownCast(C); | |
624 | if (!Bez.IsNull()) { | |
625 | Handle(DrawTrSurf_BezierCurve) DBez = | |
626 | new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles, | |
627 | Discret,Deflection,DrawMode); | |
628 | D = DBez; | |
629 | } | |
630 | ||
631 | ||
632 | Handle(Geom_BSplineCurve) BS = | |
633 | Handle(Geom_BSplineCurve)::DownCast(C); | |
634 | if (!BS.IsNull()) { | |
635 | Handle(DrawTrSurf_BSplineCurve) DBS = | |
636 | new DrawTrSurf_BSplineCurve(BS, | |
637 | CurvColor,PolesColor, | |
638 | KnotsColor, | |
639 | KnotsShape,KnotsSize, | |
640 | ShowPoles,ShowKnots, | |
641 | Discret,Deflection,DrawMode); | |
642 | D = DBS; | |
643 | } | |
644 | ||
645 | if (Bez.IsNull() && BS.IsNull()) { | |
646 | Handle(DrawTrSurf_Curve) DC = | |
445f3267 | 647 | new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker); |
7fd59977 | 648 | D = DC; |
649 | } | |
650 | } | |
651 | ||
652 | ||
653 | Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G); | |
654 | if (!S.IsNull()) { | |
655 | ||
656 | Handle(Geom_BezierSurface) Bez = | |
657 | Handle(Geom_BezierSurface)::DownCast(S); | |
658 | if (!Bez.IsNull()) { | |
659 | Handle(DrawTrSurf_BezierSurface) DBez = | |
660 | new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos, | |
661 | BoundsColor,IsosColor,PolesColor, | |
662 | ShowPoles, | |
663 | Discret,Deflection,DrawMode); | |
664 | D = DBez; | |
665 | } | |
666 | ||
667 | ||
668 | Handle(Geom_BSplineSurface) BS = | |
669 | Handle(Geom_BSplineSurface)::DownCast(S); | |
670 | if (!BS.IsNull()) { | |
671 | Handle(DrawTrSurf_BSplineSurface) DBS ; | |
672 | if (!knotsIsos) | |
673 | DBS = new DrawTrSurf_BSplineSurface(BS, | |
674 | NbUIsos,NbVIsos, | |
675 | BoundsColor,IsosColor, | |
676 | PolesColor,KnotsColor, | |
677 | KnotsShape,KnotsSize, | |
678 | ShowPoles,ShowKnots, | |
679 | Discret,Deflection,DrawMode); | |
680 | else | |
681 | DBS = new DrawTrSurf_BSplineSurface(BS, | |
682 | BoundsColor,IsosColor, | |
683 | PolesColor,KnotsColor, | |
684 | KnotsShape,KnotsSize, | |
685 | ShowPoles,ShowKnots, | |
686 | Discret,Deflection,DrawMode); | |
687 | ||
688 | D = DBS; | |
689 | } | |
690 | ||
691 | if (Bez.IsNull() && BS.IsNull()) { | |
692 | Handle(DrawTrSurf_Surface) DS = | |
693 | new DrawTrSurf_Surface(S, | |
694 | NbUIsos,NbVIsos, | |
695 | BoundsColor,IsosColor, | |
696 | Discret,Deflection,DrawMode); | |
697 | D = DS; | |
698 | } | |
699 | } | |
700 | ||
701 | } | |
702 | Draw::Set(Name,D); | |
703 | } | |
704 | ||
705 | ||
706 | //======================================================================= | |
707 | //function : Set | |
708 | //purpose : Curve from Geom2d | |
709 | //======================================================================= | |
710 | void DrawTrSurf::Set(const Standard_CString Name, | |
445f3267 S |
711 | const Handle(Geom2d_Curve)& C, |
712 | const Standard_Boolean isSenseMarker) | |
7fd59977 | 713 | { |
714 | Handle(DrawTrSurf_Drawable) D; | |
715 | if (!C.IsNull()) { | |
716 | ||
717 | Handle(Geom2d_BezierCurve) Bez = | |
718 | Handle(Geom2d_BezierCurve)::DownCast(C); | |
719 | if (!Bez.IsNull()) { | |
720 | Handle(DrawTrSurf_BezierCurve2d) DBez = | |
721 | new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles, | |
722 | Discret); | |
723 | D = DBez; | |
724 | } | |
725 | ||
726 | ||
727 | Handle(Geom2d_BSplineCurve) BS = | |
728 | Handle(Geom2d_BSplineCurve)::DownCast(C); | |
729 | if (!BS.IsNull()) { | |
730 | Handle(DrawTrSurf_BSplineCurve2d) DBS = | |
731 | new DrawTrSurf_BSplineCurve2d(BS, | |
732 | CurvColor,PolesColor, | |
733 | KnotsColor, | |
734 | KnotsShape,KnotsSize, | |
735 | ShowPoles,ShowKnots, | |
736 | Discret); | |
737 | D = DBS; | |
738 | } | |
739 | ||
740 | if (Bez.IsNull() && BS.IsNull()) { | |
741 | Handle(DrawTrSurf_Curve2d) DC = | |
445f3267 | 742 | new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker); |
7fd59977 | 743 | D = DC; |
744 | } | |
745 | } | |
746 | ||
747 | Draw::Set(Name,D); | |
748 | } | |
749 | ||
750 | //======================================================================= | |
751 | //function : Set | |
752 | //purpose : | |
753 | //======================================================================= | |
754 | void DrawTrSurf::Set(const Standard_CString Name, | |
755 | const Handle(Poly_Triangulation)& T) | |
756 | { | |
757 | Handle(DrawTrSurf_Triangulation) D = new DrawTrSurf_Triangulation(T); | |
758 | Draw::Set(Name,D); | |
759 | } | |
760 | //======================================================================= | |
761 | //function : Set | |
762 | //purpose : | |
763 | //======================================================================= | |
764 | void DrawTrSurf::Set(const Standard_CString Name, | |
765 | const Handle(Poly_Polygon3D)& P) | |
766 | { | |
767 | Handle(DrawTrSurf_Polygon3D) D = new DrawTrSurf_Polygon3D(P); | |
768 | Draw::Set(Name,D); | |
769 | } | |
770 | ||
771 | //======================================================================= | |
772 | //function : Set | |
773 | //purpose : | |
774 | //======================================================================= | |
775 | void DrawTrSurf::Set(const Standard_CString Name, | |
776 | const Handle(Poly_Polygon2D)& P) | |
777 | { | |
778 | Handle(DrawTrSurf_Polygon2D) D = new DrawTrSurf_Polygon2D(P); | |
779 | Draw::Set(Name,D); | |
780 | } | |
781 | ||
782 | //======================================================================= | |
783 | //function : Get | |
784 | //purpose : | |
785 | //======================================================================= | |
786 | Handle(Geom_Geometry) DrawTrSurf::Get(Standard_CString& Name) | |
787 | { | |
788 | Handle(Draw_Drawable3D) D = Draw::Get(Name); | |
789 | ||
790 | Handle(DrawTrSurf_Curve) DC = | |
791 | Handle(DrawTrSurf_Curve)::DownCast(D); | |
792 | if (!DC.IsNull()) | |
793 | return DC->GetCurve(); | |
794 | ||
795 | Handle(DrawTrSurf_Surface) DS = | |
796 | Handle(DrawTrSurf_Surface)::DownCast(D); | |
797 | if (!DS.IsNull()) | |
798 | return DS->GetSurface(); | |
799 | ||
800 | return Handle(Geom_Geometry) (); | |
801 | } | |
802 | ||
803 | ||
804 | //======================================================================= | |
805 | //function : GetPoint | |
806 | //purpose : | |
807 | //======================================================================= | |
808 | Standard_Boolean DrawTrSurf::GetPoint(Standard_CString& Name, | |
809 | gp_Pnt& P) | |
810 | { | |
811 | Handle(DrawTrSurf_Point) D = | |
812 | Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name)); | |
813 | if (D.IsNull()) | |
814 | return Standard_False; | |
815 | else if (!D->Is3D()) | |
816 | return Standard_False; | |
817 | else { | |
818 | P = D->Point(); | |
819 | return Standard_True; | |
820 | } | |
821 | } | |
822 | ||
823 | //======================================================================= | |
824 | //function : GetPoint2d | |
825 | //purpose : | |
826 | //======================================================================= | |
827 | Standard_Boolean DrawTrSurf::GetPoint2d(Standard_CString& Name, | |
828 | gp_Pnt2d& P) | |
829 | { | |
830 | Handle(DrawTrSurf_Point) D = | |
831 | Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name)); | |
832 | if (D.IsNull()) | |
833 | return Standard_False; | |
834 | else if (D->Is3D()) | |
835 | return Standard_False; | |
836 | else { | |
837 | P = D->Point2d(); | |
838 | return Standard_True; | |
839 | } | |
840 | } | |
841 | ||
842 | //======================================================================= | |
843 | //function : GetCurve | |
844 | //purpose : | |
845 | //======================================================================= | |
846 | Handle(Geom_Curve) DrawTrSurf::GetCurve(Standard_CString& Name) | |
847 | { | |
848 | Handle(DrawTrSurf_Curve) D = | |
849 | Handle(DrawTrSurf_Curve)::DownCast(Draw::Get(Name)); | |
850 | if (D.IsNull()) | |
851 | return Handle(Geom_Curve)(); | |
852 | else | |
853 | return D->GetCurve(); | |
854 | } | |
855 | ||
856 | ||
857 | //======================================================================= | |
858 | //function : GetBezierCurve | |
859 | //purpose : | |
860 | //======================================================================= | |
861 | Handle(Geom_BezierCurve) DrawTrSurf::GetBezierCurve(Standard_CString& Name) | |
862 | { | |
863 | Handle(DrawTrSurf_BezierCurve) D = | |
864 | Handle(DrawTrSurf_BezierCurve)::DownCast(Draw::Get(Name)); | |
865 | if (D.IsNull()) | |
866 | return Handle(Geom_BezierCurve)(); | |
867 | else | |
868 | return Handle(Geom_BezierCurve)::DownCast(D->GetCurve()); | |
869 | } | |
870 | ||
871 | ||
872 | //======================================================================= | |
873 | //function : GetBSplineCurve | |
874 | //purpose : | |
875 | //======================================================================= | |
876 | Handle(Geom_BSplineCurve) DrawTrSurf::GetBSplineCurve(Standard_CString& Name) | |
877 | { | |
878 | Handle(DrawTrSurf_BSplineCurve) D = | |
879 | Handle(DrawTrSurf_BSplineCurve)::DownCast(Draw::Get(Name)); | |
880 | if (D.IsNull()) | |
881 | return Handle(Geom_BSplineCurve)(); | |
882 | else | |
883 | return Handle(Geom_BSplineCurve)::DownCast(D->GetCurve()); | |
884 | } | |
885 | //======================================================================= | |
886 | //function : GetCurve2d | |
887 | //purpose : | |
888 | //======================================================================= | |
889 | Handle(Geom2d_Curve) DrawTrSurf::GetCurve2d(Standard_CString& Name) | |
890 | { | |
891 | Handle(DrawTrSurf_Curve2d) D = | |
892 | Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name)); | |
893 | if (D.IsNull()) | |
894 | return Handle(Geom2d_Curve)(); | |
895 | else | |
896 | return D->GetCurve(); | |
897 | } | |
898 | //======================================================================= | |
899 | //function : GetBezierCurve2d | |
900 | //purpose : | |
901 | //======================================================================= | |
902 | Handle(Geom2d_BezierCurve) DrawTrSurf::GetBezierCurve2d(Standard_CString& Name) | |
903 | { | |
904 | Handle(DrawTrSurf_Curve2d) D = | |
905 | Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name)); | |
906 | if (D.IsNull()) | |
907 | return Handle(Geom2d_BezierCurve)(); | |
908 | else | |
909 | return Handle(Geom2d_BezierCurve)::DownCast(D->GetCurve()); | |
910 | } | |
911 | //======================================================================= | |
912 | //function : GetBSplineCurve2d | |
913 | //purpose : | |
914 | //======================================================================= | |
915 | Handle(Geom2d_BSplineCurve) DrawTrSurf::GetBSplineCurve2d | |
916 | (Standard_CString& Name) | |
917 | { | |
918 | Handle(DrawTrSurf_Curve2d) D = | |
919 | Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name)); | |
920 | if (D.IsNull()) | |
921 | return Handle(Geom2d_BSplineCurve)(); | |
922 | else | |
923 | return Handle(Geom2d_BSplineCurve)::DownCast(D->GetCurve()); | |
924 | } | |
925 | //======================================================================= | |
926 | //function : GetSurface | |
927 | //purpose : | |
928 | //======================================================================= | |
929 | Handle(Geom_Surface) DrawTrSurf::GetSurface | |
930 | (Standard_CString& Name) | |
931 | { | |
932 | Handle(DrawTrSurf_Surface) D = | |
933 | Handle(DrawTrSurf_Surface)::DownCast(Draw::Get(Name)); | |
934 | if (D.IsNull()) | |
935 | return Handle(Geom_Surface)(); | |
936 | else | |
937 | return D->GetSurface(); | |
938 | } | |
939 | //======================================================================= | |
940 | //function : GetBezierSurface | |
941 | //purpose : | |
942 | //======================================================================= | |
943 | Handle(Geom_BezierSurface) DrawTrSurf::GetBezierSurface | |
944 | (Standard_CString& Name) | |
945 | { | |
946 | Handle(DrawTrSurf_BezierSurface) D = | |
947 | Handle(DrawTrSurf_BezierSurface)::DownCast(Draw::Get(Name)); | |
948 | if (D.IsNull()) | |
949 | return Handle(Geom_BezierSurface)(); | |
950 | else | |
951 | return Handle(Geom_BezierSurface)::DownCast(D->GetSurface()); | |
952 | } | |
953 | //======================================================================= | |
954 | //function : GetBSplineSurface | |
955 | //purpose : | |
956 | //======================================================================= | |
957 | Handle(Geom_BSplineSurface) DrawTrSurf::GetBSplineSurface | |
958 | (Standard_CString& Name) | |
959 | { | |
960 | Handle(DrawTrSurf_BSplineSurface) D = | |
961 | Handle(DrawTrSurf_BSplineSurface)::DownCast(Draw::Get(Name)); | |
962 | if (D.IsNull()) | |
963 | return Handle(Geom_BSplineSurface)(); | |
964 | else | |
965 | return Handle(Geom_BSplineSurface)::DownCast(D->GetSurface()); | |
966 | } | |
967 | //======================================================================= | |
968 | //function : GetTriangulation | |
969 | //purpose : | |
970 | //======================================================================= | |
971 | Handle(Poly_Triangulation) DrawTrSurf::GetTriangulation(Standard_CString& Name) | |
972 | { | |
973 | Handle(DrawTrSurf_Triangulation) D = | |
974 | Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(Name)); | |
975 | if (D.IsNull()) | |
976 | return Handle(Poly_Triangulation)(); | |
977 | else | |
978 | return D->Triangulation(); | |
979 | } | |
980 | //======================================================================= | |
981 | //function : GetPolygon3D | |
982 | //purpose : | |
983 | //======================================================================= | |
984 | Handle(Poly_Polygon3D) DrawTrSurf::GetPolygon3D(Standard_CString& Name) | |
985 | { | |
986 | Handle(DrawTrSurf_Polygon3D) D = | |
987 | Handle(DrawTrSurf_Polygon3D)::DownCast(Draw::Get(Name)); | |
988 | if (D.IsNull()) | |
989 | return Handle(Poly_Polygon3D)(); | |
990 | else | |
991 | return D->Polygon3D(); | |
992 | } | |
993 | //======================================================================= | |
994 | //function : GetPolygon2D | |
995 | //purpose : | |
996 | //======================================================================= | |
997 | Handle(Poly_Polygon2D) DrawTrSurf::GetPolygon2D(Standard_CString& Name) | |
998 | { | |
999 | Handle(DrawTrSurf_Polygon2D) D = | |
1000 | Handle(DrawTrSurf_Polygon2D)::DownCast(Draw::Get(Name)); | |
1001 | if (D.IsNull()) | |
1002 | return Handle(Poly_Polygon2D)(); | |
1003 | else | |
1004 | return D->Polygon2D(); | |
1005 | } | |
445f3267 S |
1006 | |
1007 | //======================================================================= | |
1008 | //function : printColor | |
1009 | //purpose : | |
1010 | //======================================================================= | |
1011 | ||
1012 | static void printColor(Draw_Interpretor& di, const Draw_Color& theColor) | |
1013 | { | |
1014 | switch ( theColor.ID() ) | |
1015 | { | |
1016 | case Draw_blanc: di << "white " << "\n"; break; | |
1017 | case Draw_rouge: di << "red " << "\n"; break; | |
1018 | case Draw_vert: di << "green " << "\n"; break; | |
1019 | case Draw_bleu: di << "blue " << "\n"; break; | |
1020 | case Draw_cyan: di << "cyan " << "\n"; break; | |
1021 | case Draw_or: di << "golden " << "\n"; break; | |
1022 | case Draw_magenta: di << "magenta " << "\n"; break; | |
1023 | case Draw_marron: di << "brown " << "\n"; break; | |
1024 | case Draw_orange: di << "orange " << "\n"; break; | |
1025 | case Draw_rose: di << "pink " << "\n"; break; | |
1026 | case Draw_saumon: di << "salmon " << "\n"; break; | |
1027 | case Draw_violet: di << "violet " << "\n"; break; | |
1028 | case Draw_jaune: di << "yellow " << "\n"; break; | |
1029 | case Draw_kaki: di << "dark-olive green " << "\n"; break; | |
1030 | case Draw_corail: di << "coral " << "\n"; break; | |
1031 | } | |
1032 | } | |
1033 | ||
1034 | //======================================================================= | |
1035 | //function : recognizeColor | |
1036 | //purpose : | |
1037 | //======================================================================= | |
1038 | ||
1039 | static Draw_Color recognizeColor(const char* theColorStr, | |
1040 | const Draw_Color& theDefaultColor) | |
1041 | { | |
1042 | Draw_Color aResult = theDefaultColor; | |
1043 | ||
1044 | if ( !strcasecmp(theColorStr,"white") ) | |
1045 | aResult = Draw_blanc; | |
1046 | if ( !strcasecmp(theColorStr, "red") ) | |
1047 | aResult = Draw_rouge; | |
1048 | if ( !strcasecmp(theColorStr, "green") ) | |
1049 | aResult = Draw_vert; | |
1050 | if ( !strcasecmp(theColorStr, "blue") ) | |
1051 | aResult = Draw_bleu; | |
1052 | if ( !strcasecmp(theColorStr, "cyan") ) | |
1053 | aResult = Draw_cyan; | |
1054 | if ( !strcasecmp(theColorStr, "golden") ) | |
1055 | aResult = Draw_or; | |
1056 | if ( !strcasecmp(theColorStr, "magenta") ) | |
1057 | aResult = Draw_magenta; | |
1058 | if ( !strcasecmp(theColorStr, "brown") ) | |
1059 | aResult = Draw_marron; | |
1060 | if ( !strcasecmp(theColorStr, "orange") ) | |
1061 | aResult = Draw_orange; | |
1062 | if ( !strcasecmp(theColorStr, "pink") ) | |
1063 | aResult = Draw_rose; | |
1064 | if ( !strcasecmp(theColorStr, "salmon") ) | |
1065 | aResult = Draw_saumon; | |
1066 | if ( !strcasecmp(theColorStr, "violet") ) | |
1067 | aResult = Draw_violet; | |
1068 | if ( !strcasecmp(theColorStr, "yellow") ) | |
1069 | aResult = Draw_jaune; | |
1070 | if ( !strcasecmp(theColorStr, "darkgreen") ) | |
1071 | aResult = Draw_kaki; | |
1072 | if ( !strcasecmp(theColorStr, "coral") ) | |
1073 | aResult = Draw_corail; | |
1074 | ||
1075 | return aResult; | |
1076 | } | |
1077 | ||
7fd59977 | 1078 | //======================================================================= |
1079 | //function : setcurvcolor | |
1080 | //purpose : | |
1081 | //======================================================================= | |
445f3267 S |
1082 | |
1083 | static Standard_Integer setcurvcolor(Draw_Interpretor& di, | |
1084 | Standard_Integer n, const char** a) | |
7fd59977 | 1085 | { |
445f3267 | 1086 | Draw_Color col, savecol; |
7fd59977 | 1087 | |
1088 | savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune)); | |
1089 | DrawTrSurf_CurveColor(savecol); | |
1090 | ||
445f3267 S |
1091 | if (n < 2) |
1092 | { | |
1093 | printColor(di, savecol); | |
1094 | } | |
1095 | else { | |
1096 | col = recognizeColor(a[1], savecol); | |
7fd59977 | 1097 | DrawTrSurf_CurveColor(col); |
7fd59977 | 1098 | } |
1099 | return 0; | |
1100 | } | |
1101 | ||
1102 | //======================================================================= | |
1103 | //function : changecurvcolor | |
1104 | //purpose : | |
1105 | //======================================================================= | |
1106 | ||
445f3267 S |
1107 | static Standard_Integer changecurvcolor(Draw_Interpretor&, |
1108 | Standard_Integer n, const char** a) | |
7fd59977 | 1109 | { |
445f3267 | 1110 | Draw_Color col, savecol; |
7fd59977 | 1111 | |
1112 | savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune)); | |
1113 | DrawTrSurf_CurveColor(savecol); | |
1114 | ||
445f3267 S |
1115 | if ( n < 3 ) |
1116 | return 1; | |
1117 | ||
1118 | col = recognizeColor(a[1], savecol); | |
7fd59977 | 1119 | |
445f3267 S |
1120 | Handle(DrawTrSurf_Curve) D = Handle(DrawTrSurf_Curve)::DownCast( Draw::Get(a[2]) ); |
1121 | if ( !D.IsNull() ) | |
1122 | { | |
7fd59977 | 1123 | D->SetColor(col); |
445f3267 S |
1124 | Draw::Repaint(); |
1125 | } | |
1126 | ||
1127 | return 0; | |
1128 | } | |
1129 | ||
1130 | //======================================================================= | |
1131 | //function : setpointcolor | |
1132 | //purpose : | |
1133 | //======================================================================= | |
1134 | ||
1135 | static Standard_Integer setpointcolor(Draw_Interpretor& di, | |
1136 | Standard_Integer n, const char** a) | |
1137 | { | |
1138 | Draw_Color col, savecol; | |
1139 | ||
1140 | savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune)); | |
1141 | DrawTrSurf_PointColor(savecol); | |
1142 | ||
1143 | if (n < 2) | |
1144 | { | |
1145 | printColor(di, savecol); | |
1146 | } | |
1147 | else { | |
1148 | col = recognizeColor(a[1], savecol); | |
1149 | DrawTrSurf_PointColor(col); | |
1150 | } | |
1151 | return 0; | |
1152 | } | |
1153 | ||
1154 | //======================================================================= | |
1155 | //function : changepointcolor | |
1156 | //purpose : | |
1157 | //======================================================================= | |
1158 | ||
1159 | static Standard_Integer changepointcolor(Draw_Interpretor&, | |
1160 | Standard_Integer n, const char** a) | |
1161 | { | |
1162 | Draw_Color col, savecol; | |
1163 | ||
1164 | savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune)); | |
1165 | DrawTrSurf_PointColor(savecol); | |
1166 | ||
1167 | if ( n < 3 ) | |
1168 | return 1; | |
1169 | ||
1170 | col = recognizeColor(a[1], savecol); | |
1171 | ||
1172 | Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) ); | |
1173 | if ( !D.IsNull() ) | |
1174 | { | |
1175 | D->Color(col); | |
1176 | Draw::Repaint(); | |
7fd59977 | 1177 | } |
1178 | ||
1179 | return 0; | |
1180 | } | |
1181 | ||
445f3267 S |
1182 | //======================================================================= |
1183 | //function : printMarker | |
1184 | //purpose : | |
1185 | //======================================================================= | |
1186 | ||
1187 | static void printMarker(Draw_Interpretor& di, const Draw_MarkerShape& theMarker) | |
1188 | { | |
1189 | switch ( theMarker ) | |
1190 | { | |
1191 | case Draw_Square: di << "square " << "\n"; break; | |
1192 | case Draw_Losange: di << "diamond " << "\n"; break; | |
1193 | case Draw_X: di << "x " << "\n"; break; | |
1194 | case Draw_Plus: di << "plus " << "\n"; break; | |
1195 | case Draw_Circle: di << "circle " << "\n"; break; | |
1196 | case Draw_CircleZoom: di << "circle_zoom " << "\n"; break; | |
1197 | } | |
1198 | } | |
1199 | ||
1200 | //======================================================================= | |
1201 | //function : recognizeMarker | |
1202 | //purpose : | |
1203 | //======================================================================= | |
1204 | ||
1205 | static Draw_MarkerShape recognizeMarker(const char* theMarkerStr, | |
1206 | const Draw_MarkerShape& theDefaultMarker) | |
1207 | { | |
1208 | Draw_MarkerShape aResult = theDefaultMarker; | |
1209 | ||
1210 | if ( !strcasecmp(theMarkerStr, "square") ) | |
1211 | aResult = Draw_Square; | |
1212 | if ( !strcasecmp(theMarkerStr, "diamond") ) | |
1213 | aResult = Draw_Losange; | |
1214 | if ( !strcasecmp(theMarkerStr, "x") ) | |
1215 | aResult = Draw_X; | |
1216 | if ( !strcasecmp(theMarkerStr, "plus") ) | |
1217 | aResult = Draw_Plus; | |
1218 | if ( !strcasecmp(theMarkerStr, "circle") ) | |
1219 | aResult = Draw_Circle; | |
1220 | if ( !strcasecmp(theMarkerStr, "circle_zoom") ) | |
1221 | aResult = Draw_CircleZoom; | |
1222 | ||
1223 | return aResult; | |
1224 | } | |
1225 | ||
1226 | //======================================================================= | |
1227 | //function : setpointmarker | |
1228 | //purpose : | |
1229 | //======================================================================= | |
1230 | ||
1231 | static Standard_Integer setpointmarker(Draw_Interpretor& di, | |
1232 | Standard_Integer n, const char** a) | |
1233 | { | |
1234 | Draw_MarkerShape mark, savemark; | |
1235 | ||
1236 | savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus)); | |
1237 | DrawTrSurf_PointMarker(savemark); | |
1238 | ||
1239 | if ( n < 2 ) | |
1240 | { | |
1241 | printMarker(di, savemark); | |
1242 | } | |
1243 | else { | |
1244 | mark = recognizeMarker(a[1], savemark); | |
1245 | DrawTrSurf_PointMarker(mark); | |
1246 | } | |
1247 | return 0; | |
1248 | } | |
1249 | ||
1250 | //======================================================================= | |
1251 | //function : changepointmarker | |
1252 | //purpose : | |
1253 | //======================================================================= | |
1254 | ||
1255 | static Standard_Integer changepointmarker(Draw_Interpretor&, | |
1256 | Standard_Integer n, const char** a) | |
1257 | { | |
1258 | Draw_MarkerShape mark, savemark; | |
1259 | ||
1260 | savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus)); | |
1261 | DrawTrSurf_PointMarker(savemark); | |
1262 | ||
1263 | if ( n < 3 ) | |
1264 | return 1; | |
1265 | ||
1266 | mark = recognizeMarker(a[1], savemark); | |
1267 | ||
1268 | Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) ); | |
1269 | if ( !D.IsNull() ) | |
1270 | { | |
1271 | D->Shape(mark); | |
1272 | Draw::Repaint(); | |
1273 | } | |
1274 | ||
1275 | return 0; | |
1276 | } | |
7fd59977 | 1277 | |
1278 | //======================================================================= | |
1279 | //function : BasicCommands | |
1280 | //purpose : | |
1281 | //======================================================================= | |
1282 | ||
1283 | static Standard_Boolean done = Standard_False; | |
1284 | void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands) | |
1285 | { | |
1286 | if (done) return; | |
1287 | done = Standard_True; | |
1288 | ||
1289 | const char* g; | |
1290 | g = "geometric display commands"; | |
1291 | ||
1292 | theCommands.Add("nbiso", | |
1293 | "nbiso name [names...] nuiso nviso", | |
1294 | __FILE__, | |
1295 | nbiso,g); | |
1296 | ||
1297 | theCommands.Add("clpoles", | |
1298 | "clpoles [name], no args : modal ", | |
1299 | __FILE__, | |
1300 | drawpoles,g); | |
1301 | ||
1302 | theCommands.Add("shpoles", | |
1303 | "shpoles [name], no args : modal ", | |
1304 | __FILE__, | |
1305 | drawpoles,g); | |
1306 | ||
1307 | theCommands.Add("clknots", | |
1308 | "clknots [name], no args : modal ", | |
1309 | __FILE__, | |
1310 | drawpoles,g); | |
1311 | ||
1312 | theCommands.Add("shknots", | |
1313 | "shknots [name], no args : modal ", | |
1314 | __FILE__, | |
1315 | drawpoles,g); | |
1316 | ||
1317 | theCommands.Add("dmode", | |
1318 | "dmode [names...] Uniform/Discret", | |
1319 | __FILE__, | |
1320 | draw,g); | |
1321 | ||
1322 | theCommands.Add("discr", | |
1323 | "discr [names...] nbintervals", | |
1324 | __FILE__, | |
1325 | draw,g); | |
1326 | ||
1327 | theCommands.Add("defle", | |
1328 | "defle [names...] defle", | |
1329 | __FILE__, | |
1330 | draw,g); | |
445f3267 S |
1331 | |
1332 | theCommands.Add("setcurvcolor", | |
1333 | TCollection_AsciiString("setcurvcolor [color] : set curve color\ | |
1334 | by default, or print the current curve color if no argument (this does not modify\ | |
1335 | the color of the curve)\n\n").Cat(ColorsHint).ToCString(), | |
7fd59977 | 1336 | __FILE__,setcurvcolor,g); |
1337 | ||
445f3267 S |
1338 | theCommands.Add("changecurvcolor", |
1339 | TCollection_AsciiString("changecurvcolor color curve: change\ | |
1340 | color of the curve\n\n").Cat(ColorsHint).ToCString(), | |
7fd59977 | 1341 | __FILE__,changecurvcolor,g); |
1342 | ||
445f3267 S |
1343 | theCommands.Add("setpointcolor", |
1344 | TCollection_AsciiString("setpointcolor [color] : set point color\ | |
1345 | by default, or print the current point color if no argument (this does not modify\ | |
1346 | the color of the point)\n\n").Cat(ColorsHint).ToCString(), | |
1347 | __FILE__,setpointcolor,g); | |
1348 | ||
1349 | theCommands.Add("changepointcolor", | |
1350 | TCollection_AsciiString("changepointcolor color point: change\ | |
1351 | color of the point\n\n").Cat(ColorsHint).ToCString(), | |
1352 | __FILE__,changepointcolor,g); | |
1353 | ||
1354 | theCommands.Add("setpointmarker", | |
1355 | TCollection_AsciiString("setpointmarker [marker] : set point marker\ | |
1356 | by default, or print the current point marker if no argument (this does not modify\ | |
1357 | the marker of the point)\n\n").Cat(MarkersHint).ToCString(), | |
1358 | __FILE__,setpointmarker,g); | |
1359 | ||
1360 | theCommands.Add("changepointmarker", | |
1361 | TCollection_AsciiString("changepointmarker marker point: change\ | |
1362 | marker of the point\n\n").Cat(MarkersHint).ToCString(), | |
1363 | __FILE__,changepointmarker,g); | |
1364 | ||
7fd59977 | 1365 | g = "Geometric tranformations"; |
1366 | ||
1367 | theCommands.Add("translate", | |
1368 | "translate name [names...] dx dy dz", | |
1369 | __FILE__, | |
1370 | transform,g); | |
1371 | ||
1372 | theCommands.Add("rotate", | |
1373 | "rotate name [names...] x y z dx dy dz angle", | |
1374 | __FILE__, | |
1375 | transform,g); | |
1376 | ||
1377 | theCommands.Add("pmirror", | |
1378 | "pmirror name [names...] x y z", | |
1379 | __FILE__, | |
1380 | transform,g); | |
1381 | ||
1382 | theCommands.Add("lmirror", | |
1383 | "lmirror name [names...] x y z dx dy dz", | |
1384 | __FILE__, | |
1385 | transform,g); | |
1386 | ||
1387 | theCommands.Add("smirror", | |
1388 | "smirror name [names...] x y z dx dy dz", | |
1389 | __FILE__, | |
1390 | transform,g); | |
1391 | ||
1392 | theCommands.Add("pscale", | |
1393 | "pscale name [names...] x y z s", | |
1394 | __FILE__, | |
1395 | transform,g); | |
1396 | ||
1397 | theCommands.Add("2dtranslate", | |
1398 | "translate name [names...] dx dy", | |
1399 | __FILE__, | |
1400 | d2transform,g); | |
1401 | ||
1402 | theCommands.Add("2drotate", | |
1403 | "rotate name [names...] x y dx dy angle", | |
1404 | __FILE__, | |
1405 | d2transform,g); | |
1406 | ||
1407 | theCommands.Add("2dpmirror", | |
1408 | "pmirror name [names...] x y", | |
1409 | __FILE__, | |
1410 | d2transform,g); | |
1411 | ||
1412 | theCommands.Add("2dlmirror", | |
1413 | "lmirror name [names...] x y dx dy", | |
1414 | __FILE__, | |
1415 | d2transform,g); | |
1416 | ||
1417 | theCommands.Add("2dpscale", | |
1418 | "pscale name [names...] x y s", | |
1419 | __FILE__, | |
1420 | d2transform,g); | |
1421 | } | |
1422 | ||
1423 | ||
1424 | //================================================================= | |
1425 | // save and restore curves | |
1426 | //================================================================= | |
1427 | ||
1428 | static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d) | |
1429 | { | |
1430 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve)); | |
1431 | } | |
1432 | ||
1433 | static void csave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1434 | { | |
1435 | Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d); | |
1436 | GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True); | |
1437 | } | |
1438 | ||
1439 | static Handle(Draw_Drawable3D) crestore (istream& is) | |
1440 | { | |
1441 | Handle(Geom_Curve) G; | |
1442 | GeomTools_CurveSet::ReadCurve(is,G); | |
1443 | Handle(DrawTrSurf_Curve) N = | |
1444 | new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode); | |
1445 | return N; | |
1446 | } | |
1447 | ||
1448 | ||
1449 | static Draw_SaveAndRestore csr("DrawTrSurf_Curve", | |
1450 | ctest,csave,crestore); | |
1451 | ||
1452 | ||
1453 | ||
1454 | ||
1455 | //================================================================= | |
1456 | // save and restore bezier curves | |
1457 | //================================================================= | |
1458 | ||
1459 | static Standard_Boolean bzctest(const Handle(Draw_Drawable3D)& d) | |
1460 | { | |
1461 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve)); | |
1462 | } | |
1463 | ||
1464 | static void bzcsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1465 | { | |
1466 | Handle(DrawTrSurf_BezierCurve) | |
1467 | N = Handle(DrawTrSurf_BezierCurve)::DownCast(d); | |
1468 | GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True); | |
1469 | } | |
1470 | ||
1471 | static Handle(Draw_Drawable3D) bzcrestore (istream& is) | |
1472 | { | |
1473 | Handle(Geom_BezierCurve) G; | |
1474 | GeomTools_CurveSet::ReadCurve(is,G); | |
1475 | Handle(DrawTrSurf_BezierCurve) N = | |
1476 | new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles, | |
1477 | Discret,Deflection,DrawMode); | |
1478 | return N; | |
1479 | } | |
1480 | ||
1481 | ||
1482 | static Draw_SaveAndRestore bzcsr("DrawTrSurf_BezierCurve", | |
1483 | bzctest,bzcsave,bzcrestore); | |
1484 | ||
1485 | ||
1486 | ||
1487 | ||
1488 | //================================================================= | |
1489 | // save and restore bspline curves | |
1490 | //================================================================= | |
1491 | ||
1492 | static Standard_Boolean bsctest(const Handle(Draw_Drawable3D)& d) | |
1493 | { | |
1494 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve)); | |
1495 | } | |
1496 | ||
1497 | static void bscsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1498 | { | |
1499 | Handle(DrawTrSurf_BSplineCurve) | |
1500 | N = Handle(DrawTrSurf_BSplineCurve)::DownCast(d); | |
1501 | GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True); | |
1502 | } | |
1503 | ||
1504 | static Handle(Draw_Drawable3D) bscrestore (istream& is) | |
1505 | { | |
1506 | Handle(Geom_BSplineCurve) G; | |
1507 | GeomTools_CurveSet::ReadCurve(is,G); | |
1508 | Handle(DrawTrSurf_BSplineCurve) N = | |
1509 | new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor, | |
1510 | KnotsColor, | |
1511 | KnotsShape,KnotsSize, | |
1512 | ShowPoles,ShowKnots, | |
1513 | Discret,Deflection,DrawMode); | |
1514 | return N; | |
1515 | } | |
1516 | ||
1517 | ||
1518 | static Draw_SaveAndRestore bscsr("DrawTrSurf_BSplineCurve", | |
1519 | bsctest,bscsave,bscrestore); | |
1520 | ||
1521 | ||
1522 | //================================================================= | |
1523 | // save and restore curves 2d | |
1524 | //================================================================= | |
1525 | ||
1526 | static Standard_Boolean c2dtest(const Handle(Draw_Drawable3D)& d) | |
1527 | { | |
1528 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve2d)); | |
1529 | } | |
1530 | ||
1531 | static void c2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1532 | { | |
1533 | Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d)::DownCast(d); | |
1534 | GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True); | |
1535 | } | |
1536 | ||
1537 | static Handle(Draw_Drawable3D) c2drestore (istream& is) | |
1538 | { | |
1539 | Handle(Geom2d_Curve) G; | |
1540 | GeomTools_Curve2dSet::ReadCurve2d(is,G); | |
1541 | Handle(DrawTrSurf_Curve2d) N = | |
1542 | new DrawTrSurf_Curve2d(G,CurvColor,Discret); | |
1543 | return N; | |
1544 | } | |
1545 | ||
1546 | ||
1547 | static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d", | |
1548 | c2dtest,c2dsave,c2drestore); | |
1549 | ||
1550 | ||
1551 | ||
1552 | ||
1553 | //================================================================= | |
1554 | // save and restore bezier curves 2d | |
1555 | //================================================================= | |
1556 | ||
1557 | static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d) | |
1558 | { | |
1559 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d)); | |
1560 | } | |
1561 | ||
1562 | static void bzc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1563 | { | |
1564 | Handle(DrawTrSurf_BezierCurve2d) | |
1565 | N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d); | |
1566 | GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True); | |
1567 | } | |
1568 | ||
1569 | static Handle(Draw_Drawable3D) bzc2drestore (istream& is) | |
1570 | { | |
1571 | Handle(Geom2d_BezierCurve) G; | |
1572 | GeomTools_Curve2dSet::ReadCurve2d(is,G); | |
1573 | Handle(DrawTrSurf_BezierCurve2d) N = | |
1574 | new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles, | |
1575 | Discret); | |
1576 | return N; | |
1577 | } | |
1578 | ||
1579 | ||
1580 | static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d", | |
1581 | bzc2dtest,bzc2dsave,bzc2drestore); | |
1582 | ||
1583 | ||
1584 | ||
1585 | ||
1586 | //================================================================= | |
1587 | // save and restore bspline curves 2d | |
1588 | //================================================================= | |
1589 | ||
1590 | static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d) | |
1591 | { | |
1592 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d)); | |
1593 | } | |
1594 | ||
1595 | static void bsc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1596 | { | |
1597 | Handle(DrawTrSurf_BSplineCurve2d) | |
1598 | N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d); | |
1599 | GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True); | |
1600 | } | |
1601 | ||
1602 | static Handle(Draw_Drawable3D) bsc2drestore (istream& is) | |
1603 | { | |
1604 | Handle(Geom2d_BSplineCurve) G; | |
1605 | GeomTools_Curve2dSet::ReadCurve2d(is,G); | |
1606 | Handle(DrawTrSurf_BSplineCurve2d) N = | |
1607 | new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor, | |
1608 | KnotsColor, | |
1609 | KnotsShape,KnotsSize, | |
1610 | ShowPoles,ShowKnots, | |
1611 | Discret); | |
1612 | return N; | |
1613 | } | |
1614 | ||
1615 | ||
1616 | static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d", | |
1617 | bsc2dtest,bsc2dsave,bsc2drestore); | |
1618 | ||
1619 | ||
1620 | //================================================================= | |
1621 | // save and restore surfaces | |
1622 | //================================================================= | |
1623 | ||
1624 | static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d) | |
1625 | { | |
1626 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface)); | |
1627 | } | |
1628 | ||
1629 | static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1630 | { | |
1631 | Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d); | |
1632 | GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True); | |
1633 | } | |
1634 | ||
1635 | static Handle(Draw_Drawable3D) srestore (istream& is) | |
1636 | { | |
1637 | Handle(Geom_Surface) G; | |
1638 | GeomTools_SurfaceSet::ReadSurface(is,G); | |
1639 | Handle(DrawTrSurf_Surface) N = | |
1640 | new DrawTrSurf_Surface(G, | |
1641 | NbUIsos,NbVIsos, | |
1642 | BoundsColor,IsosColor, | |
1643 | Discret,Deflection,DrawMode); | |
1644 | return N; | |
1645 | } | |
1646 | ||
1647 | ||
1648 | static Draw_SaveAndRestore ssr("DrawTrSurf_Surface", | |
1649 | stest,ssave,srestore); | |
1650 | ||
1651 | ||
1652 | ||
1653 | ||
1654 | //================================================================= | |
1655 | // save and restore bezier surfaces | |
1656 | //================================================================= | |
1657 | ||
1658 | static Standard_Boolean bzstest(const Handle(Draw_Drawable3D)& d) | |
1659 | { | |
1660 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierSurface)); | |
1661 | } | |
1662 | ||
1663 | static void bzssave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1664 | { | |
1665 | Handle(DrawTrSurf_BezierSurface) | |
1666 | N = Handle(DrawTrSurf_BezierSurface)::DownCast(d); | |
1667 | GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True); | |
1668 | } | |
1669 | ||
1670 | static Handle(Draw_Drawable3D) bzsrestore (istream& is) | |
1671 | { | |
1672 | Handle(Geom_BezierSurface) G; | |
1673 | GeomTools_SurfaceSet::ReadSurface(is,G); | |
1674 | Handle(DrawTrSurf_BezierSurface) N = | |
1675 | new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos, | |
1676 | BoundsColor,IsosColor,PolesColor, | |
1677 | ShowPoles, | |
1678 | Discret,Deflection,DrawMode); | |
1679 | return N; | |
1680 | } | |
1681 | ||
1682 | ||
1683 | static Draw_SaveAndRestore bzssr("DrawTrSurf_BezierSurface", | |
1684 | bzstest,bzssave,bzsrestore); | |
1685 | ||
1686 | ||
1687 | ||
1688 | ||
1689 | //================================================================= | |
1690 | // save and restore bspline surfaces | |
1691 | //================================================================= | |
1692 | ||
1693 | static Standard_Boolean bsstest(const Handle(Draw_Drawable3D)& d) | |
1694 | { | |
1695 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineSurface)); | |
1696 | } | |
1697 | ||
1698 | static void bsssave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1699 | { | |
1700 | Handle(DrawTrSurf_BSplineSurface) | |
1701 | N = Handle(DrawTrSurf_BSplineSurface)::DownCast(d); | |
1702 | GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True); | |
1703 | } | |
1704 | ||
1705 | static Handle(Draw_Drawable3D) bssrestore (istream& is) | |
1706 | { | |
1707 | Handle(Geom_BSplineSurface) G; | |
1708 | GeomTools_SurfaceSet::ReadSurface(is,G); | |
1709 | Handle(DrawTrSurf_BSplineSurface) N; | |
1710 | if (!knotsIsos) | |
1711 | N = new DrawTrSurf_BSplineSurface(G, | |
1712 | NbUIsos,NbVIsos, | |
1713 | BoundsColor,IsosColor, | |
1714 | PolesColor,KnotsColor, | |
1715 | KnotsShape,KnotsSize, | |
1716 | ShowPoles,ShowKnots, | |
1717 | Discret,Deflection,DrawMode); | |
1718 | else | |
1719 | N = new DrawTrSurf_BSplineSurface(G, | |
1720 | BoundsColor,IsosColor, | |
1721 | PolesColor,KnotsColor, | |
1722 | KnotsShape,KnotsSize, | |
1723 | ShowPoles,ShowKnots, | |
1724 | Discret,Deflection,DrawMode); | |
1725 | ||
1726 | return N; | |
1727 | } | |
1728 | ||
1729 | ||
1730 | static Draw_SaveAndRestore bsssr("DrawTrSurf_BSplineSurface", | |
1731 | bsstest,bsssave,bssrestore); | |
1732 | ||
1733 | ||
1734 | //================================================================= | |
1735 | // save and restore points | |
1736 | //================================================================= | |
1737 | ||
1738 | static Standard_Boolean pnttest(const Handle(Draw_Drawable3D)& d) | |
1739 | { | |
1740 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Point)); | |
1741 | } | |
1742 | ||
1743 | static void pntsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1744 | { | |
1745 | Handle(DrawTrSurf_Point) | |
1746 | N = Handle(DrawTrSurf_Point)::DownCast(d); | |
03155c18 | 1747 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1748 | ios::fmtflags F = OS.flags(); |
1749 | OS.setf(ios::scientific,ios::floatfield); | |
1750 | OS.precision(15); | |
1751 | #else | |
1752 | long form = OS.setf(ios::scientific); | |
60be1f9b | 1753 | std::streamsize prec = OS.precision(15); |
7fd59977 | 1754 | #endif |
1755 | gp_Pnt P = N->Point(); | |
1756 | if (N->Is3D()) { | |
1757 | OS << "1 "; | |
1758 | OS << P.X() << " " << P.Y() << " " << P.Z() << "\n"; | |
1759 | } | |
1760 | else { | |
1761 | OS << "0 "; | |
1762 | OS << P.X() << " " << P.Y() << "\n"; | |
1763 | } | |
03155c18 | 1764 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1765 | OS.setf(F); |
1766 | #else | |
1767 | OS.setf(form); | |
1768 | OS.precision(prec); | |
1769 | #endif | |
1770 | } | |
1771 | ||
1772 | static Handle(Draw_Drawable3D) pntrestore (istream& is) | |
1773 | { | |
1774 | Standard_Integer is3d; | |
1775 | is >> is3d; | |
1d47d8d0 | 1776 | Standard_Real x,y,z = 0.; |
7fd59977 | 1777 | if (is3d) |
1778 | is >> x >> y >> z; | |
1779 | else | |
1780 | is >> x >> y; | |
1781 | Handle(DrawTrSurf_Point) N; | |
1782 | if (is3d) | |
1783 | N = new DrawTrSurf_Point(gp_Pnt(x,y,z),PntShape,PntColor); | |
1784 | else | |
1785 | N = new DrawTrSurf_Point(gp_Pnt2d(x,y),PntShape,PntColor); | |
1786 | ||
1787 | return N; | |
1788 | } | |
1789 | ||
1790 | ||
1791 | static Draw_SaveAndRestore pntsr("DrawTrSurf_Point", | |
1792 | pnttest,pntsave,pntrestore); | |
1793 | ||
1794 | ||
1795 | ||
1796 | //================================================================= | |
1797 | // save and restore triangulation | |
1798 | //================================================================= | |
1799 | ||
1800 | static Standard_Boolean triatest(const Handle(Draw_Drawable3D)& d) | |
1801 | { | |
1802 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Triangulation)); | |
1803 | } | |
1804 | ||
1805 | static void triasave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1806 | { | |
1807 | Handle(DrawTrSurf_Triangulation) | |
1808 | T = Handle(DrawTrSurf_Triangulation)::DownCast(d); | |
03155c18 | 1809 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1810 | ios::fmtflags F = OS.flags(); |
1811 | OS.setf(ios::scientific,ios::floatfield); | |
1812 | OS.precision(15); | |
1813 | #else | |
1814 | long form = OS.setf(ios::scientific); | |
60be1f9b | 1815 | std::streamsize prec = OS.precision(15); |
7fd59977 | 1816 | #endif |
1817 | Poly::Write(T->Triangulation(),OS); | |
03155c18 | 1818 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1819 | OS.setf(F); |
1820 | #else | |
1821 | OS.setf(form); | |
1822 | OS.precision(prec); | |
1823 | #endif | |
1824 | } | |
1825 | ||
1826 | static Handle(Draw_Drawable3D) triarestore (istream& is) | |
1827 | { | |
1828 | return new DrawTrSurf_Triangulation(Poly::ReadTriangulation(is)); | |
1829 | } | |
1830 | ||
1831 | ||
1832 | static Draw_SaveAndRestore triasr("DrawTrSurf_Triangulation", | |
1833 | triatest,triasave,triarestore); | |
1834 | ||
1835 | ||
1836 | ||
1837 | //================================================================= | |
1838 | // save and restore polygon3d | |
1839 | //================================================================= | |
1840 | ||
1841 | static Standard_Boolean poly3dtest(const Handle(Draw_Drawable3D)& d) | |
1842 | { | |
1843 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon3D)); | |
1844 | } | |
1845 | ||
1846 | static void poly3dsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1847 | { | |
1848 | Handle(DrawTrSurf_Polygon3D) | |
1849 | T = Handle(DrawTrSurf_Polygon3D)::DownCast(d); | |
03155c18 | 1850 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1851 | ios::fmtflags F = OS.flags(); |
1852 | OS.setf(ios::scientific,ios::floatfield); | |
1853 | OS.precision(15); | |
1854 | #else | |
1855 | long form = OS.setf(ios::scientific); | |
60be1f9b | 1856 | std::streamsize prec = OS.precision(15); |
7fd59977 | 1857 | #endif |
1858 | Poly::Write(T->Polygon3D(),OS); | |
03155c18 | 1859 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1860 | OS.setf(F); |
1861 | #else | |
1862 | OS.setf(form); | |
1863 | OS.precision(prec); | |
1864 | #endif | |
1865 | } | |
1866 | ||
1867 | static Handle(Draw_Drawable3D) poly3drestore (istream& is) | |
1868 | { | |
1869 | return new DrawTrSurf_Polygon3D(Poly::ReadPolygon3D(is)); | |
1870 | } | |
1871 | ||
1872 | ||
1873 | static Draw_SaveAndRestore poly3dsr("DrawTrSurf_Polygon3D", | |
1874 | poly3dtest,poly3dsave,poly3drestore); | |
1875 | ||
1876 | ||
1877 | //================================================================= | |
1878 | // save and restore polygon2d | |
1879 | //================================================================= | |
1880 | ||
1881 | static Standard_Boolean poly2dtest(const Handle(Draw_Drawable3D)& d) | |
1882 | { | |
1883 | return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon2D)); | |
1884 | } | |
1885 | ||
1886 | static void poly2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS) | |
1887 | { | |
1888 | Handle(DrawTrSurf_Polygon2D) | |
1889 | T = Handle(DrawTrSurf_Polygon2D)::DownCast(d); | |
03155c18 | 1890 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1891 | ios::fmtflags F = OS.flags(); |
1892 | OS.setf(ios::scientific, ios::floatfield); | |
1893 | OS.precision(15); | |
1894 | #else | |
1895 | long form = OS.setf(ios::scientific); | |
60be1f9b | 1896 | std::streamsize prec = OS.precision(15); |
7fd59977 | 1897 | #endif |
1898 | Poly::Write(T->Polygon2D(),OS); | |
03155c18 | 1899 | #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX) |
7fd59977 | 1900 | OS.setf(F); |
1901 | #else | |
1902 | OS.setf(form); | |
1903 | OS.precision(prec); | |
1904 | #endif | |
1905 | } | |
1906 | ||
1907 | static Handle(Draw_Drawable3D) poly2drestore (istream& is) | |
1908 | { | |
1909 | return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is)); | |
1910 | } | |
1911 | ||
1912 | ||
1913 | static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D", | |
1914 | poly2dtest,poly2dsave,poly2drestore); | |
1915 |