1 // Created on: 1993-08-12
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Draw_Appli.hxx>
20 #include <Draw_Color.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <DrawTrSurf_BezierCurve.hxx>
23 #include <DrawTrSurf_BezierCurve2d.hxx>
24 #include <DrawTrSurf_BezierSurface.hxx>
25 #include <DrawTrSurf_BSplineCurve.hxx>
26 #include <DrawTrSurf_BSplineCurve2d.hxx>
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>
32 #include <DrawTrSurf_Polygon2D.hxx>
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>
46 #include <GeomTools_Curve2dSet.hxx>
47 #include <GeomTools_CurveSet.hxx>
48 #include <GeomTools_SurfaceSet.hxx>
50 #include <gp_Ax2d.hxx>
53 #include <gp_Pnt2d.hxx>
54 #include <gp_Trsf2d.hxx>
56 #include <Poly_Polygon2D.hxx>
57 #include <Poly_Polygon3D.hxx>
58 #include <Poly_Triangulation.hxx>
59 #include <Standard_Stream.hxx>
60 #include <TCollection_AsciiString.hxx>
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);
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;
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");
87 static TCollection_AsciiString MarkersHint(
88 "The possible markers are: \n\
89 square, diamond, x, plus, circle, circle_zoom");
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
96 //=======================================================================
98 Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col)
100 Draw_Color c = CurvColor;
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
110 //=======================================================================
112 Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color col)
114 Draw_Color c = PntColor;
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
124 //=======================================================================
126 Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape marker)
128 Draw_MarkerShape prev = PntShape;
133 //=======================================================================
134 //function : GetDrawable
136 //=======================================================================
137 static Handle(DrawTrSurf_Drawable) GetDrawable(Standard_CString& Name)
139 Handle(Draw_Drawable3D) D = Draw::Get(Name);
140 Handle(DrawTrSurf_Drawable) Dr;
142 Dr = Handle(DrawTrSurf_Drawable)::DownCast(D);
146 //=======================================================================
147 //function : GetSurface
149 //=======================================================================
150 static Handle(DrawTrSurf_Surface) GetSurface(Standard_CString& Name)
152 Handle(Draw_Drawable3D) D = Draw::Get(Name);
153 Handle(DrawTrSurf_Surface) Dr;
155 Dr = Handle(DrawTrSurf_Surface)::DownCast(D);
159 //=======================================================================
160 //function : GetBezierSurface
162 //=======================================================================
163 static Handle(DrawTrSurf_BezierSurface) GetBezierSurface(Standard_CString& Name)
165 Handle(Draw_Drawable3D) D = Draw::Get(Name);
166 Handle(DrawTrSurf_BezierSurface) Dr;
168 Dr = Handle(DrawTrSurf_BezierSurface)::DownCast(D);
172 //=======================================================================
173 //function : GetBSplineSurface
175 //=======================================================================
176 static Handle(DrawTrSurf_BSplineSurface) GetBSplineSurface(Standard_CString& Name)
178 Handle(Draw_Drawable3D) D = Draw::Get(Name);
179 Handle(DrawTrSurf_BSplineSurface) Dr;
181 Dr = Handle(DrawTrSurf_BSplineSurface)::DownCast(D);
185 //=======================================================================
186 //function : GetBezierCurve
188 //=======================================================================
189 static Handle(DrawTrSurf_BezierCurve) GetBezierCurve(Standard_CString& Name)
191 Handle(Draw_Drawable3D) D = Draw::Get(Name);
192 Handle(DrawTrSurf_BezierCurve) Dr;
194 Dr = Handle(DrawTrSurf_BezierCurve)::DownCast(D);
198 //=======================================================================
199 //function : GetBSplineCurve
201 //=======================================================================
202 static Handle(DrawTrSurf_BSplineCurve) GetBSplineCurve(Standard_CString& Name)
204 Handle(Draw_Drawable3D) D = Draw::Get(Name);
205 Handle(DrawTrSurf_BSplineCurve) Dr;
207 Dr = Handle(DrawTrSurf_BSplineCurve)::DownCast(D);
211 //=======================================================================
212 //function : GetBezierCurve2d
214 //=======================================================================
215 static Handle(DrawTrSurf_BezierCurve2d) GetBezierCurve2d(Standard_CString& Name)
217 Handle(Draw_Drawable3D) D = Draw::Get(Name);
218 Handle(DrawTrSurf_BezierCurve2d) Dr;
220 Dr = Handle(DrawTrSurf_BezierCurve2d)::DownCast(D);
224 //=======================================================================
225 //function : GetBSplineCurve2d
227 //=======================================================================
228 static Handle(DrawTrSurf_BSplineCurve2d) GetBSplineCurve2d(Standard_CString& Name)
230 Handle(Draw_Drawable3D) D = Draw::Get(Name);
231 Handle(DrawTrSurf_BSplineCurve2d) Dr;
233 Dr = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(D);
238 //=======================================================================
241 //=======================================================================
242 static Standard_Integer nbiso (Draw_Interpretor& di, Standard_Integer n, const char** a)
246 NbUIsos = Draw::Atoi(a[1]);
247 NbVIsos = Draw::Atoi(a[2]);
249 di << NbUIsos << " " << NbVIsos;
252 for (Standard_Integer i = 1; i < n - 2; i++) {
253 Handle(DrawTrSurf_Surface) DS = GetSurface(a[i]);
255 DS->ShowIsos(Draw::Atoi(a[n-2]),Draw::Atoi(a[n-1]));
263 //=======================================================================
264 //function : drawpoles
266 //=======================================================================
268 static Standard_Integer drawpoles(Draw_Interpretor&,
273 if ( !strcmp(a[0],"shpoles")) {
274 ShowPoles = Standard_True;
276 else if ( !strcmp(a[0],"clpoles")) {
277 ShowPoles = Standard_False;
279 else if ( !strcmp(a[0],"shknots")) {
280 ShowKnots = Standard_True;
282 else if ( !strcmp(a[0],"clknots")) {
283 ShowKnots = Standard_False;
289 Handle(DrawTrSurf_BezierSurface) BZS;
290 BZS = GetBezierSurface(a[1]);
291 if ( !BZS.IsNull()) {
292 if ( !strcmp(a[0],"shpoles")) {
295 else if ( !strcmp(a[0],"clpoles")) {
303 Handle(DrawTrSurf_BSplineSurface) BSS = GetBSplineSurface(a[1]);
304 if ( !BSS.IsNull()) {
305 if ( !strcmp(a[0],"shpoles")) {
308 else if ( !strcmp(a[0],"clpoles")) {
311 else if ( !strcmp(a[0],"shknots")) {
314 else if ( !strcmp(a[0],"clknots")) {
319 Handle(DrawTrSurf_BezierCurve) BZC = GetBezierCurve(a[1]);
320 if ( !BZC.IsNull()) {
321 if ( !strcmp(a[0],"shpoles")) {
324 else if ( !strcmp(a[0],"clpoles")) {
332 Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]);
333 if ( !BSC.IsNull()) {
334 if ( !strcmp(a[0],"shpoles")) {
337 else if ( !strcmp(a[0],"clpoles")) {
340 else if ( !strcmp(a[0],"shknots")) {
343 else if ( !strcmp(a[0],"clknots")) {
348 Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]);
349 if ( !BZ2.IsNull()) {
350 if ( !strcmp(a[0],"shpoles")) {
353 else if ( !strcmp(a[0],"clpoles")) {
361 Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]);
362 if ( !BS2.IsNull()) {
363 if ( !strcmp(a[0],"shpoles")) {
366 else if ( !strcmp(a[0],"clpoles")) {
369 else if ( !strcmp(a[0],"shknots")) {
372 else if ( !strcmp(a[0],"clknots")) {
388 //=======================================================================
391 //=======================================================================
393 static Standard_Integer draw (Draw_Interpretor& di, Standard_Integer n, const char** a)
396 if (!strcmp(a[0],"dmode")) {
406 else if (!strcmp(a[0],"discr")) {
408 Discret = Draw::Atoi(a[n-1]);
412 else if (!strcmp(a[0],"defle")) {
414 Deflection = Draw::Atof(a[n-1]);
419 for (Standard_Integer i = 1; i < n - 1; i++) {
420 Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]);
422 if (!strcmp(a[0],"dmode")) {
423 Standard_Integer mod = 0;
424 if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
428 else if (!strcmp(a[0],"discr")) {
429 D->SetDiscretisation(Draw::Atoi(a[n-1]));
432 else if (!strcmp(a[0],"defle")) {
433 D->SetDeflection(Draw::Atof(a[n-1]));
443 //=======================================================================
444 //function : transform
446 //=======================================================================
448 static Standard_Integer transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
452 Standard_Integer i,last = n-1;
453 if (!strcmp(a[0],"pscale")) {
454 Standard_Real s = Draw::Atof(a[last]);
456 if (last < 4) return 1;
457 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
460 else if (!strcmp(a[0]+1,"mirror")) {
461 if (last < 4) return 1;
462 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
468 if (last < 4) return 1;
469 gp_Pnt O(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
471 gp_Dir D(P.X(),P.Y(),P.Z());
473 T.SetMirror(gp_Ax1(O,D));
475 else if (*a[0] == 's') {
477 T.SetMirror(Pl.Position().Ax2());
482 else if (!strcmp(a[0],"translate")) {
483 if (last < 4) return 1;
484 gp_Vec V(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
489 else if (!strcmp(a[0],"rotate")) {
490 if (last < 8) return 1;
491 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
493 gp_Dir D(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
495 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
497 T.SetRotation(gp_Ax1(P,D),ang);
500 for (i = 1; i <= last; i++) {
501 Handle(Geom_Geometry) G = DrawTrSurf::Get(a[i]);
508 if (DrawTrSurf::GetPoint(a[i],P)) {
510 DrawTrSurf::Set(a[i],P);
518 //=======================================================================
519 //function : d2transform
521 //=======================================================================
523 static Standard_Integer d2transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
527 Standard_Integer i,last = n-1;
528 if (!strcmp(a[0],"2dpscale")) {
529 Standard_Real s = Draw::Atof(a[last]);
531 if (last < 3) return 1;
532 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
535 else if ( (!strcmp(a[0],"2dpmirror")) ||
536 (!strcmp(a[0],"2dlmirror")) ) {
537 if (last < 3) return 1;
538 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
539 if (!strcmp(a[0],"2dpmirror")) {
544 if (last < 3) return 1;
545 gp_Pnt2d O(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
547 gp_Dir2d D(P.X(),P.Y());
548 T.SetMirror(gp_Ax2d(O,D));
552 else if (!strcmp(a[0],"2dtranslate")) {
553 if (last < 3) return 1;
554 gp_Vec2d V(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
559 else if (!strcmp(a[0],"2drotate")) {
560 if (last < 4) return 1;
561 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
563 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
565 T.SetRotation(P,ang);
568 for (i = 1; i <= last; i++) {
569 Handle(Geom2d_Curve) G = DrawTrSurf::GetCurve2d(a[i]);
576 if (DrawTrSurf::GetPoint2d(a[i],P)) {
578 DrawTrSurf::Set(a[i],P);
586 //=======================================================================
589 //=======================================================================
590 void DrawTrSurf::Set(const Standard_CString Name,
593 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
597 //=======================================================================
600 //=======================================================================
601 void DrawTrSurf::Set(const Standard_CString Name,
604 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
608 //=======================================================================
610 //purpose : Geometry from Geom
611 //=======================================================================
612 void DrawTrSurf::Set(const Standard_CString Name,
613 const Handle(Geom_Geometry)& G,
614 const Standard_Boolean isSenseMarker)
616 Handle(DrawTrSurf_Drawable) D;
619 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G);
622 Handle(Geom_BezierCurve) Bez =
623 Handle(Geom_BezierCurve)::DownCast(C);
625 Handle(DrawTrSurf_BezierCurve) DBez =
626 new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles,
627 Discret,Deflection,DrawMode);
632 Handle(Geom_BSplineCurve) BS =
633 Handle(Geom_BSplineCurve)::DownCast(C);
635 Handle(DrawTrSurf_BSplineCurve) DBS =
636 new DrawTrSurf_BSplineCurve(BS,
637 CurvColor,PolesColor,
639 KnotsShape,KnotsSize,
641 Discret,Deflection,DrawMode);
645 if (Bez.IsNull() && BS.IsNull()) {
646 Handle(DrawTrSurf_Curve) DC =
647 new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker);
653 Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G);
656 Handle(Geom_BezierSurface) Bez =
657 Handle(Geom_BezierSurface)::DownCast(S);
659 Handle(DrawTrSurf_BezierSurface) DBez =
660 new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos,
661 BoundsColor,IsosColor,PolesColor,
663 Discret,Deflection,DrawMode);
668 Handle(Geom_BSplineSurface) BS =
669 Handle(Geom_BSplineSurface)::DownCast(S);
671 Handle(DrawTrSurf_BSplineSurface) DBS ;
673 DBS = new DrawTrSurf_BSplineSurface(BS,
675 BoundsColor,IsosColor,
676 PolesColor,KnotsColor,
677 KnotsShape,KnotsSize,
679 Discret,Deflection,DrawMode);
681 DBS = new DrawTrSurf_BSplineSurface(BS,
682 BoundsColor,IsosColor,
683 PolesColor,KnotsColor,
684 KnotsShape,KnotsSize,
686 Discret,Deflection,DrawMode);
691 if (Bez.IsNull() && BS.IsNull()) {
692 Handle(DrawTrSurf_Surface) DS =
693 new DrawTrSurf_Surface(S,
695 BoundsColor,IsosColor,
696 Discret,Deflection,DrawMode);
706 //=======================================================================
708 //purpose : Curve from Geom2d
709 //=======================================================================
710 void DrawTrSurf::Set(const Standard_CString Name,
711 const Handle(Geom2d_Curve)& C,
712 const Standard_Boolean isSenseMarker)
714 Handle(DrawTrSurf_Drawable) D;
717 Handle(Geom2d_BezierCurve) Bez =
718 Handle(Geom2d_BezierCurve)::DownCast(C);
720 Handle(DrawTrSurf_BezierCurve2d) DBez =
721 new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles,
727 Handle(Geom2d_BSplineCurve) BS =
728 Handle(Geom2d_BSplineCurve)::DownCast(C);
730 Handle(DrawTrSurf_BSplineCurve2d) DBS =
731 new DrawTrSurf_BSplineCurve2d(BS,
732 CurvColor,PolesColor,
734 KnotsShape,KnotsSize,
740 if (Bez.IsNull() && BS.IsNull()) {
741 Handle(DrawTrSurf_Curve2d) DC =
742 new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker);
750 //=======================================================================
753 //=======================================================================
754 void DrawTrSurf::Set(const Standard_CString Name,
755 const Handle(Poly_Triangulation)& T)
757 Handle(DrawTrSurf_Triangulation) D = new DrawTrSurf_Triangulation(T);
760 //=======================================================================
763 //=======================================================================
764 void DrawTrSurf::Set(const Standard_CString Name,
765 const Handle(Poly_Polygon3D)& P)
767 Handle(DrawTrSurf_Polygon3D) D = new DrawTrSurf_Polygon3D(P);
771 //=======================================================================
774 //=======================================================================
775 void DrawTrSurf::Set(const Standard_CString Name,
776 const Handle(Poly_Polygon2D)& P)
778 Handle(DrawTrSurf_Polygon2D) D = new DrawTrSurf_Polygon2D(P);
782 //=======================================================================
785 //=======================================================================
786 Handle(Geom_Geometry) DrawTrSurf::Get(Standard_CString& Name)
788 Handle(Draw_Drawable3D) D = Draw::Get(Name);
790 Handle(DrawTrSurf_Curve) DC =
791 Handle(DrawTrSurf_Curve)::DownCast(D);
793 return DC->GetCurve();
795 Handle(DrawTrSurf_Surface) DS =
796 Handle(DrawTrSurf_Surface)::DownCast(D);
798 return DS->GetSurface();
800 return Handle(Geom_Geometry) ();
804 //=======================================================================
805 //function : GetPoint
807 //=======================================================================
808 Standard_Boolean DrawTrSurf::GetPoint(Standard_CString& Name,
811 Handle(DrawTrSurf_Point) D =
812 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
814 return Standard_False;
816 return Standard_False;
819 return Standard_True;
823 //=======================================================================
824 //function : GetPoint2d
826 //=======================================================================
827 Standard_Boolean DrawTrSurf::GetPoint2d(Standard_CString& Name,
830 Handle(DrawTrSurf_Point) D =
831 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
833 return Standard_False;
835 return Standard_False;
838 return Standard_True;
842 //=======================================================================
843 //function : GetCurve
845 //=======================================================================
846 Handle(Geom_Curve) DrawTrSurf::GetCurve(Standard_CString& Name)
848 Handle(DrawTrSurf_Curve) D =
849 Handle(DrawTrSurf_Curve)::DownCast(Draw::Get(Name));
851 return Handle(Geom_Curve)();
853 return D->GetCurve();
857 //=======================================================================
858 //function : GetBezierCurve
860 //=======================================================================
861 Handle(Geom_BezierCurve) DrawTrSurf::GetBezierCurve(Standard_CString& Name)
863 Handle(DrawTrSurf_BezierCurve) D =
864 Handle(DrawTrSurf_BezierCurve)::DownCast(Draw::Get(Name));
866 return Handle(Geom_BezierCurve)();
868 return Handle(Geom_BezierCurve)::DownCast(D->GetCurve());
872 //=======================================================================
873 //function : GetBSplineCurve
875 //=======================================================================
876 Handle(Geom_BSplineCurve) DrawTrSurf::GetBSplineCurve(Standard_CString& Name)
878 Handle(DrawTrSurf_BSplineCurve) D =
879 Handle(DrawTrSurf_BSplineCurve)::DownCast(Draw::Get(Name));
881 return Handle(Geom_BSplineCurve)();
883 return Handle(Geom_BSplineCurve)::DownCast(D->GetCurve());
885 //=======================================================================
886 //function : GetCurve2d
888 //=======================================================================
889 Handle(Geom2d_Curve) DrawTrSurf::GetCurve2d(Standard_CString& Name)
891 Handle(DrawTrSurf_Curve2d) D =
892 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
894 return Handle(Geom2d_Curve)();
896 return D->GetCurve();
898 //=======================================================================
899 //function : GetBezierCurve2d
901 //=======================================================================
902 Handle(Geom2d_BezierCurve) DrawTrSurf::GetBezierCurve2d(Standard_CString& Name)
904 Handle(DrawTrSurf_Curve2d) D =
905 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
907 return Handle(Geom2d_BezierCurve)();
909 return Handle(Geom2d_BezierCurve)::DownCast(D->GetCurve());
911 //=======================================================================
912 //function : GetBSplineCurve2d
914 //=======================================================================
915 Handle(Geom2d_BSplineCurve) DrawTrSurf::GetBSplineCurve2d
916 (Standard_CString& Name)
918 Handle(DrawTrSurf_Curve2d) D =
919 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
921 return Handle(Geom2d_BSplineCurve)();
923 return Handle(Geom2d_BSplineCurve)::DownCast(D->GetCurve());
925 //=======================================================================
926 //function : GetSurface
928 //=======================================================================
929 Handle(Geom_Surface) DrawTrSurf::GetSurface
930 (Standard_CString& Name)
932 Handle(DrawTrSurf_Surface) D =
933 Handle(DrawTrSurf_Surface)::DownCast(Draw::Get(Name));
935 return Handle(Geom_Surface)();
937 return D->GetSurface();
939 //=======================================================================
940 //function : GetBezierSurface
942 //=======================================================================
943 Handle(Geom_BezierSurface) DrawTrSurf::GetBezierSurface
944 (Standard_CString& Name)
946 Handle(DrawTrSurf_BezierSurface) D =
947 Handle(DrawTrSurf_BezierSurface)::DownCast(Draw::Get(Name));
949 return Handle(Geom_BezierSurface)();
951 return Handle(Geom_BezierSurface)::DownCast(D->GetSurface());
953 //=======================================================================
954 //function : GetBSplineSurface
956 //=======================================================================
957 Handle(Geom_BSplineSurface) DrawTrSurf::GetBSplineSurface
958 (Standard_CString& Name)
960 Handle(DrawTrSurf_BSplineSurface) D =
961 Handle(DrawTrSurf_BSplineSurface)::DownCast(Draw::Get(Name));
963 return Handle(Geom_BSplineSurface)();
965 return Handle(Geom_BSplineSurface)::DownCast(D->GetSurface());
967 //=======================================================================
968 //function : GetTriangulation
970 //=======================================================================
971 Handle(Poly_Triangulation) DrawTrSurf::GetTriangulation(Standard_CString& Name)
973 Handle(DrawTrSurf_Triangulation) D =
974 Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(Name));
976 return Handle(Poly_Triangulation)();
978 return D->Triangulation();
980 //=======================================================================
981 //function : GetPolygon3D
983 //=======================================================================
984 Handle(Poly_Polygon3D) DrawTrSurf::GetPolygon3D(Standard_CString& Name)
986 Handle(DrawTrSurf_Polygon3D) D =
987 Handle(DrawTrSurf_Polygon3D)::DownCast(Draw::Get(Name));
989 return Handle(Poly_Polygon3D)();
991 return D->Polygon3D();
993 //=======================================================================
994 //function : GetPolygon2D
996 //=======================================================================
997 Handle(Poly_Polygon2D) DrawTrSurf::GetPolygon2D(Standard_CString& Name)
999 Handle(DrawTrSurf_Polygon2D) D =
1000 Handle(DrawTrSurf_Polygon2D)::DownCast(Draw::Get(Name));
1002 return Handle(Poly_Polygon2D)();
1004 return D->Polygon2D();
1007 //=======================================================================
1008 //function : printColor
1010 //=======================================================================
1012 static void printColor(Draw_Interpretor& di, const Draw_Color& theColor)
1014 switch ( theColor.ID() )
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;
1034 //=======================================================================
1035 //function : recognizeColor
1037 //=======================================================================
1039 static Draw_Color recognizeColor(const char* theColorStr,
1040 const Draw_Color& theDefaultColor)
1042 Draw_Color aResult = theDefaultColor;
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") )
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;
1078 //=======================================================================
1079 //function : setcurvcolor
1081 //=======================================================================
1083 static Standard_Integer setcurvcolor(Draw_Interpretor& di,
1084 Standard_Integer n, const char** a)
1086 Draw_Color col, savecol;
1088 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1089 DrawTrSurf_CurveColor(savecol);
1093 printColor(di, savecol);
1096 col = recognizeColor(a[1], savecol);
1097 DrawTrSurf_CurveColor(col);
1102 //=======================================================================
1103 //function : changecurvcolor
1105 //=======================================================================
1107 static Standard_Integer changecurvcolor(Draw_Interpretor&,
1108 Standard_Integer n, const char** a)
1110 Draw_Color col, savecol;
1112 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1113 DrawTrSurf_CurveColor(savecol);
1118 col = recognizeColor(a[1], savecol);
1120 Handle(DrawTrSurf_Curve) D = Handle(DrawTrSurf_Curve)::DownCast( Draw::Get(a[2]) );
1130 //=======================================================================
1131 //function : setpointcolor
1133 //=======================================================================
1135 static Standard_Integer setpointcolor(Draw_Interpretor& di,
1136 Standard_Integer n, const char** a)
1138 Draw_Color col, savecol;
1140 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1141 DrawTrSurf_PointColor(savecol);
1145 printColor(di, savecol);
1148 col = recognizeColor(a[1], savecol);
1149 DrawTrSurf_PointColor(col);
1154 //=======================================================================
1155 //function : changepointcolor
1157 //=======================================================================
1159 static Standard_Integer changepointcolor(Draw_Interpretor&,
1160 Standard_Integer n, const char** a)
1162 Draw_Color col, savecol;
1164 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1165 DrawTrSurf_PointColor(savecol);
1170 col = recognizeColor(a[1], savecol);
1172 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1182 //=======================================================================
1183 //function : printMarker
1185 //=======================================================================
1187 static void printMarker(Draw_Interpretor& di, const Draw_MarkerShape& theMarker)
1189 switch ( theMarker )
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;
1200 //=======================================================================
1201 //function : recognizeMarker
1203 //=======================================================================
1205 static Draw_MarkerShape recognizeMarker(const char* theMarkerStr,
1206 const Draw_MarkerShape& theDefaultMarker)
1208 Draw_MarkerShape aResult = theDefaultMarker;
1210 if ( !strcasecmp(theMarkerStr, "square") )
1211 aResult = Draw_Square;
1212 if ( !strcasecmp(theMarkerStr, "diamond") )
1213 aResult = Draw_Losange;
1214 if ( !strcasecmp(theMarkerStr, "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;
1226 //=======================================================================
1227 //function : setpointmarker
1229 //=======================================================================
1231 static Standard_Integer setpointmarker(Draw_Interpretor& di,
1232 Standard_Integer n, const char** a)
1234 Draw_MarkerShape mark, savemark;
1236 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1237 DrawTrSurf_PointMarker(savemark);
1241 printMarker(di, savemark);
1244 mark = recognizeMarker(a[1], savemark);
1245 DrawTrSurf_PointMarker(mark);
1250 //=======================================================================
1251 //function : changepointmarker
1253 //=======================================================================
1255 static Standard_Integer changepointmarker(Draw_Interpretor&,
1256 Standard_Integer n, const char** a)
1258 Draw_MarkerShape mark, savemark;
1260 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1261 DrawTrSurf_PointMarker(savemark);
1266 mark = recognizeMarker(a[1], savemark);
1268 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1278 //=======================================================================
1279 //function : BasicCommands
1281 //=======================================================================
1283 static Standard_Boolean done = Standard_False;
1284 void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands)
1287 done = Standard_True;
1290 g = "geometric display commands";
1292 theCommands.Add("nbiso",
1293 "nbiso name [names...] nuiso nviso",
1297 theCommands.Add("clpoles",
1298 "clpoles [name], no args : modal ",
1302 theCommands.Add("shpoles",
1303 "shpoles [name], no args : modal ",
1307 theCommands.Add("clknots",
1308 "clknots [name], no args : modal ",
1312 theCommands.Add("shknots",
1313 "shknots [name], no args : modal ",
1317 theCommands.Add("dmode",
1318 "dmode [names...] Uniform/Discret",
1322 theCommands.Add("discr",
1323 "discr [names...] nbintervals",
1327 theCommands.Add("defle",
1328 "defle [names...] defle",
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(),
1336 __FILE__,setcurvcolor,g);
1338 theCommands.Add("changecurvcolor",
1339 TCollection_AsciiString("changecurvcolor color curve: change\
1340 color of the curve\n\n").Cat(ColorsHint).ToCString(),
1341 __FILE__,changecurvcolor,g);
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);
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);
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);
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);
1365 g = "Geometric tranformations";
1367 theCommands.Add("translate",
1368 "translate name [names...] dx dy dz",
1372 theCommands.Add("rotate",
1373 "rotate name [names...] x y z dx dy dz angle",
1377 theCommands.Add("pmirror",
1378 "pmirror name [names...] x y z",
1382 theCommands.Add("lmirror",
1383 "lmirror name [names...] x y z dx dy dz",
1387 theCommands.Add("smirror",
1388 "smirror name [names...] x y z dx dy dz",
1392 theCommands.Add("pscale",
1393 "pscale name [names...] x y z s",
1397 theCommands.Add("2dtranslate",
1398 "translate name [names...] dx dy",
1402 theCommands.Add("2drotate",
1403 "rotate name [names...] x y dx dy angle",
1407 theCommands.Add("2dpmirror",
1408 "pmirror name [names...] x y",
1412 theCommands.Add("2dlmirror",
1413 "lmirror name [names...] x y dx dy",
1417 theCommands.Add("2dpscale",
1418 "pscale name [names...] x y s",
1424 //=================================================================
1425 // save and restore curves
1426 //=================================================================
1428 static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d)
1430 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve));
1433 static void csave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1435 Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d);
1436 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1439 static Handle(Draw_Drawable3D) crestore (std::istream& is)
1441 Handle(Geom_Curve) G = GeomTools_CurveSet::ReadCurve(is);
1442 Handle(DrawTrSurf_Curve) N =
1443 new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
1448 static Draw_SaveAndRestore csr("DrawTrSurf_Curve",
1449 ctest,csave,crestore);
1454 //=================================================================
1455 // save and restore bezier curves
1456 //=================================================================
1458 static Standard_Boolean bzctest(const Handle(Draw_Drawable3D)& d)
1460 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve));
1463 static void bzcsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1465 Handle(DrawTrSurf_BezierCurve)
1466 N = Handle(DrawTrSurf_BezierCurve)::DownCast(d);
1467 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1470 static Handle(Draw_Drawable3D) bzcrestore (std::istream& is)
1472 Handle(Geom_BezierCurve) G =
1473 Handle(Geom_BezierCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
1474 Handle(DrawTrSurf_BezierCurve) N =
1475 new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
1476 Discret,Deflection,DrawMode);
1481 static Draw_SaveAndRestore bzcsr("DrawTrSurf_BezierCurve",
1482 bzctest,bzcsave,bzcrestore);
1487 //=================================================================
1488 // save and restore bspline curves
1489 //=================================================================
1491 static Standard_Boolean bsctest(const Handle(Draw_Drawable3D)& d)
1493 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve));
1496 static void bscsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1498 Handle(DrawTrSurf_BSplineCurve)
1499 N = Handle(DrawTrSurf_BSplineCurve)::DownCast(d);
1500 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1503 static Handle(Draw_Drawable3D) bscrestore (std::istream& is)
1505 Handle(Geom_BSplineCurve) G =
1506 Handle(Geom_BSplineCurve)::DownCast (GeomTools_CurveSet::ReadCurve(is));
1507 Handle(DrawTrSurf_BSplineCurve) N =
1508 new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
1510 KnotsShape,KnotsSize,
1511 ShowPoles,ShowKnots,
1512 Discret,Deflection,DrawMode);
1517 static Draw_SaveAndRestore bscsr("DrawTrSurf_BSplineCurve",
1518 bsctest,bscsave,bscrestore);
1521 //=================================================================
1522 // save and restore curves 2d
1523 //=================================================================
1525 static Standard_Boolean c2dtest(const Handle(Draw_Drawable3D)& d)
1527 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve2d));
1530 static void c2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1532 Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d)::DownCast(d);
1533 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1536 static Handle(Draw_Drawable3D) c2drestore (std::istream& is)
1538 Handle(Geom2d_Curve) G = GeomTools_Curve2dSet::ReadCurve2d(is);
1539 Handle(DrawTrSurf_Curve2d) N =
1540 new DrawTrSurf_Curve2d(G,CurvColor,Discret);
1545 static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d",
1546 c2dtest,c2dsave,c2drestore);
1551 //=================================================================
1552 // save and restore bezier curves 2d
1553 //=================================================================
1555 static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d)
1557 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d));
1560 static void bzc2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1562 Handle(DrawTrSurf_BezierCurve2d)
1563 N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d);
1564 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1567 static Handle(Draw_Drawable3D) bzc2drestore (std::istream& is)
1569 Handle(Geom2d_BezierCurve) G =
1570 Handle(Geom2d_BezierCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
1571 Handle(DrawTrSurf_BezierCurve2d) N =
1572 new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
1578 static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d",
1579 bzc2dtest,bzc2dsave,bzc2drestore);
1584 //=================================================================
1585 // save and restore bspline curves 2d
1586 //=================================================================
1588 static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d)
1590 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d));
1593 static void bsc2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1595 Handle(DrawTrSurf_BSplineCurve2d)
1596 N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d);
1597 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1600 static Handle(Draw_Drawable3D) bsc2drestore (std::istream& is)
1602 Handle(Geom2d_BSplineCurve) G =
1603 Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d(is));
1604 Handle(DrawTrSurf_BSplineCurve2d) N =
1605 new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
1607 KnotsShape,KnotsSize,
1608 ShowPoles,ShowKnots,
1614 static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d",
1615 bsc2dtest,bsc2dsave,bsc2drestore);
1618 //=================================================================
1619 // save and restore surfaces
1620 //=================================================================
1622 static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
1624 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface));
1627 static void ssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1629 Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d);
1630 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1633 static Handle(Draw_Drawable3D) srestore (std::istream& is)
1635 Handle(Geom_Surface) G = GeomTools_SurfaceSet::ReadSurface(is);
1636 Handle(DrawTrSurf_Surface) N =
1637 new DrawTrSurf_Surface(G,
1639 BoundsColor,IsosColor,
1640 Discret,Deflection,DrawMode);
1645 static Draw_SaveAndRestore ssr("DrawTrSurf_Surface",
1646 stest,ssave,srestore);
1651 //=================================================================
1652 // save and restore bezier surfaces
1653 //=================================================================
1655 static Standard_Boolean bzstest(const Handle(Draw_Drawable3D)& d)
1657 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierSurface));
1660 static void bzssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1662 Handle(DrawTrSurf_BezierSurface)
1663 N = Handle(DrawTrSurf_BezierSurface)::DownCast(d);
1664 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1667 static Handle(Draw_Drawable3D) bzsrestore (std::istream& is)
1669 Handle(Geom_BezierSurface) G =
1670 Handle(Geom_BezierSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
1671 Handle(DrawTrSurf_BezierSurface) N =
1672 new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
1673 BoundsColor,IsosColor,PolesColor,
1675 Discret,Deflection,DrawMode);
1680 static Draw_SaveAndRestore bzssr("DrawTrSurf_BezierSurface",
1681 bzstest,bzssave,bzsrestore);
1686 //=================================================================
1687 // save and restore bspline surfaces
1688 //=================================================================
1690 static Standard_Boolean bsstest(const Handle(Draw_Drawable3D)& d)
1692 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineSurface));
1695 static void bsssave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1697 Handle(DrawTrSurf_BSplineSurface)
1698 N = Handle(DrawTrSurf_BSplineSurface)::DownCast(d);
1699 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1702 static Handle(Draw_Drawable3D) bssrestore (std::istream& is)
1704 Handle(Geom_BSplineSurface) G =
1705 Handle(Geom_BSplineSurface)::DownCast (GeomTools_SurfaceSet::ReadSurface(is));
1706 Handle(DrawTrSurf_BSplineSurface) N;
1708 N = new DrawTrSurf_BSplineSurface(G,
1710 BoundsColor,IsosColor,
1711 PolesColor,KnotsColor,
1712 KnotsShape,KnotsSize,
1713 ShowPoles,ShowKnots,
1714 Discret,Deflection,DrawMode);
1716 N = new DrawTrSurf_BSplineSurface(G,
1717 BoundsColor,IsosColor,
1718 PolesColor,KnotsColor,
1719 KnotsShape,KnotsSize,
1720 ShowPoles,ShowKnots,
1721 Discret,Deflection,DrawMode);
1727 static Draw_SaveAndRestore bsssr("DrawTrSurf_BSplineSurface",
1728 bsstest,bsssave,bssrestore);
1731 //=================================================================
1732 // save and restore points
1733 //=================================================================
1735 static Standard_Boolean pnttest(const Handle(Draw_Drawable3D)& d)
1737 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Point));
1740 static void pntsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1742 Handle(DrawTrSurf_Point)
1743 N = Handle(DrawTrSurf_Point)::DownCast(d);
1744 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1745 std::ios::fmtflags F = OS.flags();
1746 OS.setf(std::ios::scientific,std::ios::floatfield);
1749 long form = OS.setf(std::ios::scientific);
1750 std::streamsize prec = OS.precision(15);
1752 gp_Pnt P = N->Point();
1755 OS << P.X() << " " << P.Y() << " " << P.Z() << "\n";
1759 OS << P.X() << " " << P.Y() << "\n";
1761 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1769 static Handle(Draw_Drawable3D) pntrestore (std::istream& is)
1771 Standard_Integer is3d;
1773 Standard_Real x,y,z = 0.;
1778 Handle(DrawTrSurf_Point) N;
1780 N = new DrawTrSurf_Point(gp_Pnt(x,y,z),PntShape,PntColor);
1782 N = new DrawTrSurf_Point(gp_Pnt2d(x,y),PntShape,PntColor);
1788 static Draw_SaveAndRestore pntsr("DrawTrSurf_Point",
1789 pnttest,pntsave,pntrestore);
1793 //=================================================================
1794 // save and restore triangulation
1795 //=================================================================
1797 static Standard_Boolean triatest(const Handle(Draw_Drawable3D)& d)
1799 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Triangulation));
1802 static void triasave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1804 Handle(DrawTrSurf_Triangulation)
1805 T = Handle(DrawTrSurf_Triangulation)::DownCast(d);
1806 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1807 std::ios::fmtflags F = OS.flags();
1808 OS.setf(std::ios::scientific,std::ios::floatfield);
1811 long form = OS.setf(std::ios::scientific);
1812 std::streamsize prec = OS.precision(15);
1814 Poly::Write(T->Triangulation(),OS);
1815 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1823 static Handle(Draw_Drawable3D) triarestore (std::istream& is)
1825 return new DrawTrSurf_Triangulation(Poly::ReadTriangulation(is));
1829 static Draw_SaveAndRestore triasr("DrawTrSurf_Triangulation",
1830 triatest,triasave,triarestore);
1834 //=================================================================
1835 // save and restore polygon3d
1836 //=================================================================
1838 static Standard_Boolean poly3dtest(const Handle(Draw_Drawable3D)& d)
1840 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon3D));
1843 static void poly3dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1845 Handle(DrawTrSurf_Polygon3D)
1846 T = Handle(DrawTrSurf_Polygon3D)::DownCast(d);
1847 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1848 std::ios::fmtflags F = OS.flags();
1849 OS.setf(std::ios::scientific,std::ios::floatfield);
1852 long form = OS.setf(std::ios::scientific);
1853 std::streamsize prec = OS.precision(15);
1855 Poly::Write(T->Polygon3D(),OS);
1856 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1864 static Handle(Draw_Drawable3D) poly3drestore (std::istream& is)
1866 return new DrawTrSurf_Polygon3D(Poly::ReadPolygon3D(is));
1870 static Draw_SaveAndRestore poly3dsr("DrawTrSurf_Polygon3D",
1871 poly3dtest,poly3dsave,poly3drestore);
1874 //=================================================================
1875 // save and restore polygon2d
1876 //=================================================================
1878 static Standard_Boolean poly2dtest(const Handle(Draw_Drawable3D)& d)
1880 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon2D));
1883 static void poly2dsave(const Handle(Draw_Drawable3D)&d, std::ostream& OS)
1885 Handle(DrawTrSurf_Polygon2D)
1886 T = Handle(DrawTrSurf_Polygon2D)::DownCast(d);
1887 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1888 std::ios::fmtflags F = OS.flags();
1889 OS.setf(std::ios::scientific, std::ios::floatfield);
1892 long form = OS.setf(std::ios::scientific);
1893 std::streamsize prec = OS.precision(15);
1895 Poly::Write(T->Polygon2D(),OS);
1896 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
1904 static Handle(Draw_Drawable3D) poly2drestore (std::istream& is)
1906 return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is));
1910 static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D",
1911 poly2dtest,poly2dsave,poly2drestore);