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
9 // under the terms of the GNU Lesser General Public 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.
23 #elif defined(HAVE_IOS_H)
31 #include <Standard_Stream.hxx>
33 #include <Draw_Color.hxx>
34 #include <DrawTrSurf.ixx>
35 #include <DrawTrSurf_Point.hxx>
36 #include <DrawTrSurf_BezierSurface.hxx>
37 #include <DrawTrSurf_BSplineSurface.hxx>
38 #include <DrawTrSurf_BezierCurve.hxx>
39 #include <DrawTrSurf_BSplineCurve.hxx>
40 #include <DrawTrSurf_BezierCurve2d.hxx>
41 #include <DrawTrSurf_BSplineCurve2d.hxx>
42 #include <DrawTrSurf_Triangulation.hxx>
43 #include <DrawTrSurf_Polygon3D.hxx>
44 #include <DrawTrSurf_Polygon2D.hxx>
45 #include <Draw_Appli.hxx>
48 #include <GeomTools_CurveSet.hxx>
49 #include <GeomTools_Curve2dSet.hxx>
50 #include <GeomTools_SurfaceSet.hxx>
53 #include <gp_Ax2d.hxx>
55 #include <gp_Trsf2d.hxx>
57 #include <TCollection_AsciiString.hxx>
59 static Draw_Color PntColor(Draw_rouge);
60 static Draw_Color CurvColor(Draw_jaune);
61 static Draw_Color BoundsColor(Draw_vert);
62 static Draw_Color IsosColor(Draw_bleu);
63 static Draw_Color PolesColor(Draw_rouge);
64 static Draw_Color KnotsColor(Draw_violet);
66 static Draw_MarkerShape PntShape = Draw_Plus;
67 static Draw_MarkerShape KnotsShape = Draw_Losange;
68 static Standard_Boolean ShowPoles = Standard_True;
69 static Standard_Boolean ShowKnots = Standard_True;
70 static Standard_Boolean knotsIsos =Standard_True;
71 static Standard_Real Deflection = 0.01;
72 static Standard_Integer KnotsSize = 5;
73 static Standard_Integer Discret = 30;
74 static Standard_Integer DrawMode = 0;
75 static Standard_Integer NbUIsos = 10;
76 static Standard_Integer NbVIsos = 10;
78 static TCollection_AsciiString ColorsHint(
79 "The possible colors are: \n\
80 white, red, green, blue, cyan,\n\
81 golden, magenta, brown, orange, pink,\n\
82 salmon, violet, yellow, darkgreen, coral");
84 static TCollection_AsciiString MarkersHint(
85 "The possible markers are: \n\
86 square, diamond, x, plus, circle, circle_zoom");
88 //=======================================================================
89 //function : DrawTrSurf_CurveColor
90 //purpose : Sets new color for rendering of curves. Returns the
91 // previous one to keep possibility to restore the initial
93 //=======================================================================
95 Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col)
97 Draw_Color c = CurvColor;
102 //=======================================================================
103 //function : DrawTrSurf_PointColor
104 //purpose : Sets new color for rendering of points. Returns the
105 // previous one to keep possibility to restore the initial
107 //=======================================================================
109 Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color col)
111 Draw_Color c = PntColor;
116 //=======================================================================
117 //function : DrawTrSurf_PointMarker
118 //purpose : Sets new marker for rendering of points. Returns the
119 // previous one to keep possibility to restore the initial
121 //=======================================================================
123 Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape marker)
125 Draw_MarkerShape prev = PntShape;
130 //=======================================================================
131 //function : GetDrawable
133 //=======================================================================
134 static Handle(DrawTrSurf_Drawable) GetDrawable(Standard_CString& Name)
136 Handle(Draw_Drawable3D) D = Draw::Get(Name);
137 Handle(DrawTrSurf_Drawable) Dr;
139 Dr = Handle(DrawTrSurf_Drawable)::DownCast(D);
143 //=======================================================================
144 //function : GetSurface
146 //=======================================================================
147 static Handle(DrawTrSurf_Surface) GetSurface(Standard_CString& Name)
149 Handle(Draw_Drawable3D) D = Draw::Get(Name);
150 Handle(DrawTrSurf_Surface) Dr;
152 Dr = Handle(DrawTrSurf_Surface)::DownCast(D);
156 //=======================================================================
157 //function : GetBezierSurface
159 //=======================================================================
160 static Handle(DrawTrSurf_BezierSurface) GetBezierSurface(Standard_CString& Name)
162 Handle(Draw_Drawable3D) D = Draw::Get(Name);
163 Handle(DrawTrSurf_BezierSurface) Dr;
165 Dr = Handle(DrawTrSurf_BezierSurface)::DownCast(D);
169 //=======================================================================
170 //function : GetBSplineSurface
172 //=======================================================================
173 static Handle(DrawTrSurf_BSplineSurface) GetBSplineSurface(Standard_CString& Name)
175 Handle(Draw_Drawable3D) D = Draw::Get(Name);
176 Handle(DrawTrSurf_BSplineSurface) Dr;
178 Dr = Handle(DrawTrSurf_BSplineSurface)::DownCast(D);
182 //=======================================================================
183 //function : GetBezierCurve
185 //=======================================================================
186 static Handle(DrawTrSurf_BezierCurve) GetBezierCurve(Standard_CString& Name)
188 Handle(Draw_Drawable3D) D = Draw::Get(Name);
189 Handle(DrawTrSurf_BezierCurve) Dr;
191 Dr = Handle(DrawTrSurf_BezierCurve)::DownCast(D);
195 //=======================================================================
196 //function : GetBSplineCurve
198 //=======================================================================
199 static Handle(DrawTrSurf_BSplineCurve) GetBSplineCurve(Standard_CString& Name)
201 Handle(Draw_Drawable3D) D = Draw::Get(Name);
202 Handle(DrawTrSurf_BSplineCurve) Dr;
204 Dr = Handle(DrawTrSurf_BSplineCurve)::DownCast(D);
208 //=======================================================================
209 //function : GetBezierCurve2d
211 //=======================================================================
212 static Handle(DrawTrSurf_BezierCurve2d) GetBezierCurve2d(Standard_CString& Name)
214 Handle(Draw_Drawable3D) D = Draw::Get(Name);
215 Handle(DrawTrSurf_BezierCurve2d) Dr;
217 Dr = Handle(DrawTrSurf_BezierCurve2d)::DownCast(D);
221 //=======================================================================
222 //function : GetBSplineCurve2d
224 //=======================================================================
225 static Handle(DrawTrSurf_BSplineCurve2d) GetBSplineCurve2d(Standard_CString& Name)
227 Handle(Draw_Drawable3D) D = Draw::Get(Name);
228 Handle(DrawTrSurf_BSplineCurve2d) Dr;
230 Dr = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(D);
235 //=======================================================================
238 //=======================================================================
239 static Standard_Integer nbiso (Draw_Interpretor& di, Standard_Integer n, const char** a)
243 NbUIsos = Draw::Atoi(a[1]);
244 NbVIsos = Draw::Atoi(a[2]);
246 di << NbUIsos << " " << NbVIsos;
249 for (Standard_Integer i = 1; i < n - 2; i++) {
250 Handle(DrawTrSurf_Surface) DS = GetSurface(a[i]);
252 DS->ShowIsos(Draw::Atoi(a[n-2]),Draw::Atoi(a[n-1]));
260 //=======================================================================
261 //function : drawpoles
263 //=======================================================================
265 static Standard_Integer drawpoles(Draw_Interpretor&,
270 if ( !strcmp(a[0],"shpoles")) {
271 ShowPoles = Standard_True;
273 else if ( !strcmp(a[0],"clpoles")) {
274 ShowPoles = Standard_False;
276 else if ( !strcmp(a[0],"shknots")) {
277 ShowKnots = Standard_True;
279 else if ( !strcmp(a[0],"clknots")) {
280 ShowKnots = Standard_False;
286 Handle(DrawTrSurf_BezierSurface) BZS;
287 BZS = GetBezierSurface(a[1]);
288 if ( !BZS.IsNull()) {
289 if ( !strcmp(a[0],"shpoles")) {
292 else if ( !strcmp(a[0],"clpoles")) {
300 Handle(DrawTrSurf_BSplineSurface) BSS = GetBSplineSurface(a[1]);
301 if ( !BSS.IsNull()) {
302 if ( !strcmp(a[0],"shpoles")) {
305 else if ( !strcmp(a[0],"clpoles")) {
308 else if ( !strcmp(a[0],"shknots")) {
311 else if ( !strcmp(a[0],"clknots")) {
316 Handle(DrawTrSurf_BezierCurve) BZC = GetBezierCurve(a[1]);
317 if ( !BZC.IsNull()) {
318 if ( !strcmp(a[0],"shpoles")) {
321 else if ( !strcmp(a[0],"clpoles")) {
329 Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]);
330 if ( !BSC.IsNull()) {
331 if ( !strcmp(a[0],"shpoles")) {
334 else if ( !strcmp(a[0],"clpoles")) {
337 else if ( !strcmp(a[0],"shknots")) {
340 else if ( !strcmp(a[0],"clknots")) {
345 Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]);
346 if ( !BZ2.IsNull()) {
347 if ( !strcmp(a[0],"shpoles")) {
350 else if ( !strcmp(a[0],"clpoles")) {
358 Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]);
359 if ( !BS2.IsNull()) {
360 if ( !strcmp(a[0],"shpoles")) {
363 else if ( !strcmp(a[0],"clpoles")) {
366 else if ( !strcmp(a[0],"shknots")) {
369 else if ( !strcmp(a[0],"clknots")) {
385 //=======================================================================
388 //=======================================================================
390 static Standard_Integer draw (Draw_Interpretor& di, Standard_Integer n, const char** a)
393 if (!strcmp(a[0],"dmode")) {
395 Standard_Integer mod = 0;
396 if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
405 else if (!strcmp(a[0],"discr")) {
407 Discret = Draw::Atoi(a[n-1]);
411 else if (!strcmp(a[0],"defle")) {
413 Deflection = Draw::Atof(a[n-1]);
418 for (Standard_Integer i = 1; i < n - 1; i++) {
419 Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]);
421 if (!strcmp(a[0],"dmode")) {
422 Standard_Integer mod = 0;
423 if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
427 else if (!strcmp(a[0],"discr")) {
428 D->SetDiscretisation(Draw::Atoi(a[n-1]));
431 else if (!strcmp(a[0],"defle")) {
432 D->SetDeflection(Draw::Atof(a[n-1]));
442 //=======================================================================
443 //function : transform
445 //=======================================================================
447 static Standard_Integer transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
451 Standard_Integer i,last = n-1;
452 if (!strcmp(a[0],"pscale")) {
453 Standard_Real s = Draw::Atof(a[last]);
455 if (last < 4) return 1;
456 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
459 else if (!strcmp(a[0]+1,"mirror")) {
460 if (last < 4) return 1;
461 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
467 if (last < 4) return 1;
468 gp_Pnt O(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
470 gp_Dir D(P.X(),P.Y(),P.Z());
472 T.SetMirror(gp_Ax1(O,D));
474 else if (*a[0] == 's') {
476 T.SetMirror(Pl.Position().Ax2());
481 else if (!strcmp(a[0],"translate")) {
482 if (last < 4) return 1;
483 gp_Vec V(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
488 else if (!strcmp(a[0],"rotate")) {
489 if (last < 8) return 1;
490 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
492 gp_Dir D(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
494 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
496 T.SetRotation(gp_Ax1(P,D),ang);
499 for (i = 1; i <= last; i++) {
500 Handle(Geom_Geometry) G = DrawTrSurf::Get(a[i]);
507 if (DrawTrSurf::GetPoint(a[i],P)) {
509 DrawTrSurf::Set(a[i],P);
517 //=======================================================================
518 //function : d2transform
520 //=======================================================================
522 static Standard_Integer d2transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
526 Standard_Integer i,last = n-1;
527 if (!strcmp(a[0],"2dpscale")) {
528 Standard_Real s = Draw::Atof(a[last]);
530 if (last < 3) return 1;
531 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
534 else if ( (!strcmp(a[0],"2dpmirror")) ||
535 (!strcmp(a[0],"2dlmirror")) ) {
536 if (last < 3) return 1;
537 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
538 if (!strcmp(a[0],"2dpmirror")) {
543 if (last < 3) return 1;
544 gp_Pnt2d O(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
546 gp_Dir2d D(P.X(),P.Y());
547 T.SetMirror(gp_Ax2d(O,D));
551 else if (!strcmp(a[0],"2dtranslate")) {
552 if (last < 3) return 1;
553 gp_Vec2d V(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
558 else if (!strcmp(a[0],"2drotate")) {
559 if (last < 4) return 1;
560 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
562 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
564 T.SetRotation(P,ang);
567 for (i = 1; i <= last; i++) {
568 Handle(Geom2d_Curve) G = DrawTrSurf::GetCurve2d(a[i]);
575 if (DrawTrSurf::GetPoint2d(a[i],P)) {
577 DrawTrSurf::Set(a[i],P);
585 //=======================================================================
588 //=======================================================================
589 void DrawTrSurf::Set(const Standard_CString Name,
592 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
596 //=======================================================================
599 //=======================================================================
600 void DrawTrSurf::Set(const Standard_CString Name,
603 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
607 //=======================================================================
609 //purpose : Geometry from Geom
610 //=======================================================================
611 void DrawTrSurf::Set(const Standard_CString Name,
612 const Handle(Geom_Geometry)& G,
613 const Standard_Boolean isSenseMarker)
615 Handle(DrawTrSurf_Drawable) D;
618 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G);
621 Handle(Geom_BezierCurve) Bez =
622 Handle(Geom_BezierCurve)::DownCast(C);
624 Handle(DrawTrSurf_BezierCurve) DBez =
625 new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles,
626 Discret,Deflection,DrawMode);
631 Handle(Geom_BSplineCurve) BS =
632 Handle(Geom_BSplineCurve)::DownCast(C);
634 Handle(DrawTrSurf_BSplineCurve) DBS =
635 new DrawTrSurf_BSplineCurve(BS,
636 CurvColor,PolesColor,
638 KnotsShape,KnotsSize,
640 Discret,Deflection,DrawMode);
644 if (Bez.IsNull() && BS.IsNull()) {
645 Handle(DrawTrSurf_Curve) DC =
646 new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker);
652 Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G);
655 Handle(Geom_BezierSurface) Bez =
656 Handle(Geom_BezierSurface)::DownCast(S);
658 Handle(DrawTrSurf_BezierSurface) DBez =
659 new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos,
660 BoundsColor,IsosColor,PolesColor,
662 Discret,Deflection,DrawMode);
667 Handle(Geom_BSplineSurface) BS =
668 Handle(Geom_BSplineSurface)::DownCast(S);
670 Handle(DrawTrSurf_BSplineSurface) DBS ;
672 DBS = new DrawTrSurf_BSplineSurface(BS,
674 BoundsColor,IsosColor,
675 PolesColor,KnotsColor,
676 KnotsShape,KnotsSize,
678 Discret,Deflection,DrawMode);
680 DBS = new DrawTrSurf_BSplineSurface(BS,
681 BoundsColor,IsosColor,
682 PolesColor,KnotsColor,
683 KnotsShape,KnotsSize,
685 Discret,Deflection,DrawMode);
690 if (Bez.IsNull() && BS.IsNull()) {
691 Handle(DrawTrSurf_Surface) DS =
692 new DrawTrSurf_Surface(S,
694 BoundsColor,IsosColor,
695 Discret,Deflection,DrawMode);
705 //=======================================================================
707 //purpose : Curve from Geom2d
708 //=======================================================================
709 void DrawTrSurf::Set(const Standard_CString Name,
710 const Handle(Geom2d_Curve)& C,
711 const Standard_Boolean isSenseMarker)
713 Handle(DrawTrSurf_Drawable) D;
716 Handle(Geom2d_BezierCurve) Bez =
717 Handle(Geom2d_BezierCurve)::DownCast(C);
719 Handle(DrawTrSurf_BezierCurve2d) DBez =
720 new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles,
726 Handle(Geom2d_BSplineCurve) BS =
727 Handle(Geom2d_BSplineCurve)::DownCast(C);
729 Handle(DrawTrSurf_BSplineCurve2d) DBS =
730 new DrawTrSurf_BSplineCurve2d(BS,
731 CurvColor,PolesColor,
733 KnotsShape,KnotsSize,
739 if (Bez.IsNull() && BS.IsNull()) {
740 Handle(DrawTrSurf_Curve2d) DC =
741 new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker);
749 //=======================================================================
752 //=======================================================================
753 void DrawTrSurf::Set(const Standard_CString Name,
754 const Handle(Poly_Triangulation)& T)
756 Handle(DrawTrSurf_Triangulation) D = new DrawTrSurf_Triangulation(T);
759 //=======================================================================
762 //=======================================================================
763 void DrawTrSurf::Set(const Standard_CString Name,
764 const Handle(Poly_Polygon3D)& P)
766 Handle(DrawTrSurf_Polygon3D) D = new DrawTrSurf_Polygon3D(P);
770 //=======================================================================
773 //=======================================================================
774 void DrawTrSurf::Set(const Standard_CString Name,
775 const Handle(Poly_Polygon2D)& P)
777 Handle(DrawTrSurf_Polygon2D) D = new DrawTrSurf_Polygon2D(P);
781 //=======================================================================
784 //=======================================================================
785 Handle(Geom_Geometry) DrawTrSurf::Get(Standard_CString& Name)
787 Handle(Draw_Drawable3D) D = Draw::Get(Name);
789 Handle(DrawTrSurf_Curve) DC =
790 Handle(DrawTrSurf_Curve)::DownCast(D);
792 return DC->GetCurve();
794 Handle(DrawTrSurf_Surface) DS =
795 Handle(DrawTrSurf_Surface)::DownCast(D);
797 return DS->GetSurface();
799 return Handle(Geom_Geometry) ();
803 //=======================================================================
804 //function : GetPoint
806 //=======================================================================
807 Standard_Boolean DrawTrSurf::GetPoint(Standard_CString& Name,
810 Handle(DrawTrSurf_Point) D =
811 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
813 return Standard_False;
815 return Standard_False;
818 return Standard_True;
822 //=======================================================================
823 //function : GetPoint2d
825 //=======================================================================
826 Standard_Boolean DrawTrSurf::GetPoint2d(Standard_CString& Name,
829 Handle(DrawTrSurf_Point) D =
830 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
832 return Standard_False;
834 return Standard_False;
837 return Standard_True;
841 //=======================================================================
842 //function : GetCurve
844 //=======================================================================
845 Handle(Geom_Curve) DrawTrSurf::GetCurve(Standard_CString& Name)
847 Handle(DrawTrSurf_Curve) D =
848 Handle(DrawTrSurf_Curve)::DownCast(Draw::Get(Name));
850 return Handle(Geom_Curve)();
852 return D->GetCurve();
856 //=======================================================================
857 //function : GetBezierCurve
859 //=======================================================================
860 Handle(Geom_BezierCurve) DrawTrSurf::GetBezierCurve(Standard_CString& Name)
862 Handle(DrawTrSurf_BezierCurve) D =
863 Handle(DrawTrSurf_BezierCurve)::DownCast(Draw::Get(Name));
865 return Handle(Geom_BezierCurve)();
867 return Handle(Geom_BezierCurve)::DownCast(D->GetCurve());
871 //=======================================================================
872 //function : GetBSplineCurve
874 //=======================================================================
875 Handle(Geom_BSplineCurve) DrawTrSurf::GetBSplineCurve(Standard_CString& Name)
877 Handle(DrawTrSurf_BSplineCurve) D =
878 Handle(DrawTrSurf_BSplineCurve)::DownCast(Draw::Get(Name));
880 return Handle(Geom_BSplineCurve)();
882 return Handle(Geom_BSplineCurve)::DownCast(D->GetCurve());
884 //=======================================================================
885 //function : GetCurve2d
887 //=======================================================================
888 Handle(Geom2d_Curve) DrawTrSurf::GetCurve2d(Standard_CString& Name)
890 Handle(DrawTrSurf_Curve2d) D =
891 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
893 return Handle(Geom2d_Curve)();
895 return D->GetCurve();
897 //=======================================================================
898 //function : GetBezierCurve2d
900 //=======================================================================
901 Handle(Geom2d_BezierCurve) DrawTrSurf::GetBezierCurve2d(Standard_CString& Name)
903 Handle(DrawTrSurf_Curve2d) D =
904 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
906 return Handle(Geom2d_BezierCurve)();
908 return Handle(Geom2d_BezierCurve)::DownCast(D->GetCurve());
910 //=======================================================================
911 //function : GetBSplineCurve2d
913 //=======================================================================
914 Handle(Geom2d_BSplineCurve) DrawTrSurf::GetBSplineCurve2d
915 (Standard_CString& Name)
917 Handle(DrawTrSurf_Curve2d) D =
918 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
920 return Handle(Geom2d_BSplineCurve)();
922 return Handle(Geom2d_BSplineCurve)::DownCast(D->GetCurve());
924 //=======================================================================
925 //function : GetSurface
927 //=======================================================================
928 Handle(Geom_Surface) DrawTrSurf::GetSurface
929 (Standard_CString& Name)
931 Handle(DrawTrSurf_Surface) D =
932 Handle(DrawTrSurf_Surface)::DownCast(Draw::Get(Name));
934 return Handle(Geom_Surface)();
936 return D->GetSurface();
938 //=======================================================================
939 //function : GetBezierSurface
941 //=======================================================================
942 Handle(Geom_BezierSurface) DrawTrSurf::GetBezierSurface
943 (Standard_CString& Name)
945 Handle(DrawTrSurf_BezierSurface) D =
946 Handle(DrawTrSurf_BezierSurface)::DownCast(Draw::Get(Name));
948 return Handle(Geom_BezierSurface)();
950 return Handle(Geom_BezierSurface)::DownCast(D->GetSurface());
952 //=======================================================================
953 //function : GetBSplineSurface
955 //=======================================================================
956 Handle(Geom_BSplineSurface) DrawTrSurf::GetBSplineSurface
957 (Standard_CString& Name)
959 Handle(DrawTrSurf_BSplineSurface) D =
960 Handle(DrawTrSurf_BSplineSurface)::DownCast(Draw::Get(Name));
962 return Handle(Geom_BSplineSurface)();
964 return Handle(Geom_BSplineSurface)::DownCast(D->GetSurface());
966 //=======================================================================
967 //function : GetTriangulation
969 //=======================================================================
970 Handle(Poly_Triangulation) DrawTrSurf::GetTriangulation(Standard_CString& Name)
972 Handle(DrawTrSurf_Triangulation) D =
973 Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(Name));
975 return Handle(Poly_Triangulation)();
977 return D->Triangulation();
979 //=======================================================================
980 //function : GetPolygon3D
982 //=======================================================================
983 Handle(Poly_Polygon3D) DrawTrSurf::GetPolygon3D(Standard_CString& Name)
985 Handle(DrawTrSurf_Polygon3D) D =
986 Handle(DrawTrSurf_Polygon3D)::DownCast(Draw::Get(Name));
988 return Handle(Poly_Polygon3D)();
990 return D->Polygon3D();
992 //=======================================================================
993 //function : GetPolygon2D
995 //=======================================================================
996 Handle(Poly_Polygon2D) DrawTrSurf::GetPolygon2D(Standard_CString& Name)
998 Handle(DrawTrSurf_Polygon2D) D =
999 Handle(DrawTrSurf_Polygon2D)::DownCast(Draw::Get(Name));
1001 return Handle(Poly_Polygon2D)();
1003 return D->Polygon2D();
1006 //=======================================================================
1007 //function : printColor
1009 //=======================================================================
1011 static void printColor(Draw_Interpretor& di, const Draw_Color& theColor)
1013 switch ( theColor.ID() )
1015 case Draw_blanc: di << "white " << "\n"; break;
1016 case Draw_rouge: di << "red " << "\n"; break;
1017 case Draw_vert: di << "green " << "\n"; break;
1018 case Draw_bleu: di << "blue " << "\n"; break;
1019 case Draw_cyan: di << "cyan " << "\n"; break;
1020 case Draw_or: di << "golden " << "\n"; break;
1021 case Draw_magenta: di << "magenta " << "\n"; break;
1022 case Draw_marron: di << "brown " << "\n"; break;
1023 case Draw_orange: di << "orange " << "\n"; break;
1024 case Draw_rose: di << "pink " << "\n"; break;
1025 case Draw_saumon: di << "salmon " << "\n"; break;
1026 case Draw_violet: di << "violet " << "\n"; break;
1027 case Draw_jaune: di << "yellow " << "\n"; break;
1028 case Draw_kaki: di << "dark-olive green " << "\n"; break;
1029 case Draw_corail: di << "coral " << "\n"; break;
1033 //=======================================================================
1034 //function : recognizeColor
1036 //=======================================================================
1038 static Draw_Color recognizeColor(const char* theColorStr,
1039 const Draw_Color& theDefaultColor)
1041 Draw_Color aResult = theDefaultColor;
1043 if ( !strcasecmp(theColorStr,"white") )
1044 aResult = Draw_blanc;
1045 if ( !strcasecmp(theColorStr, "red") )
1046 aResult = Draw_rouge;
1047 if ( !strcasecmp(theColorStr, "green") )
1048 aResult = Draw_vert;
1049 if ( !strcasecmp(theColorStr, "blue") )
1050 aResult = Draw_bleu;
1051 if ( !strcasecmp(theColorStr, "cyan") )
1052 aResult = Draw_cyan;
1053 if ( !strcasecmp(theColorStr, "golden") )
1055 if ( !strcasecmp(theColorStr, "magenta") )
1056 aResult = Draw_magenta;
1057 if ( !strcasecmp(theColorStr, "brown") )
1058 aResult = Draw_marron;
1059 if ( !strcasecmp(theColorStr, "orange") )
1060 aResult = Draw_orange;
1061 if ( !strcasecmp(theColorStr, "pink") )
1062 aResult = Draw_rose;
1063 if ( !strcasecmp(theColorStr, "salmon") )
1064 aResult = Draw_saumon;
1065 if ( !strcasecmp(theColorStr, "violet") )
1066 aResult = Draw_violet;
1067 if ( !strcasecmp(theColorStr, "yellow") )
1068 aResult = Draw_jaune;
1069 if ( !strcasecmp(theColorStr, "darkgreen") )
1070 aResult = Draw_kaki;
1071 if ( !strcasecmp(theColorStr, "coral") )
1072 aResult = Draw_corail;
1077 //=======================================================================
1078 //function : setcurvcolor
1080 //=======================================================================
1082 static Standard_Integer setcurvcolor(Draw_Interpretor& di,
1083 Standard_Integer n, const char** a)
1085 Draw_Color col, savecol;
1087 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1088 DrawTrSurf_CurveColor(savecol);
1092 printColor(di, savecol);
1095 col = recognizeColor(a[1], savecol);
1096 DrawTrSurf_CurveColor(col);
1101 //=======================================================================
1102 //function : changecurvcolor
1104 //=======================================================================
1106 static Standard_Integer changecurvcolor(Draw_Interpretor&,
1107 Standard_Integer n, const char** a)
1109 Draw_Color col, savecol;
1111 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1112 DrawTrSurf_CurveColor(savecol);
1117 col = recognizeColor(a[1], savecol);
1119 Handle(DrawTrSurf_Curve) D = Handle(DrawTrSurf_Curve)::DownCast( Draw::Get(a[2]) );
1129 //=======================================================================
1130 //function : setpointcolor
1132 //=======================================================================
1134 static Standard_Integer setpointcolor(Draw_Interpretor& di,
1135 Standard_Integer n, const char** a)
1137 Draw_Color col, savecol;
1139 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1140 DrawTrSurf_PointColor(savecol);
1144 printColor(di, savecol);
1147 col = recognizeColor(a[1], savecol);
1148 DrawTrSurf_PointColor(col);
1153 //=======================================================================
1154 //function : changepointcolor
1156 //=======================================================================
1158 static Standard_Integer changepointcolor(Draw_Interpretor&,
1159 Standard_Integer n, const char** a)
1161 Draw_Color col, savecol;
1163 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1164 DrawTrSurf_PointColor(savecol);
1169 col = recognizeColor(a[1], savecol);
1171 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1181 //=======================================================================
1182 //function : printMarker
1184 //=======================================================================
1186 static void printMarker(Draw_Interpretor& di, const Draw_MarkerShape& theMarker)
1188 switch ( theMarker )
1190 case Draw_Square: di << "square " << "\n"; break;
1191 case Draw_Losange: di << "diamond " << "\n"; break;
1192 case Draw_X: di << "x " << "\n"; break;
1193 case Draw_Plus: di << "plus " << "\n"; break;
1194 case Draw_Circle: di << "circle " << "\n"; break;
1195 case Draw_CircleZoom: di << "circle_zoom " << "\n"; break;
1199 //=======================================================================
1200 //function : recognizeMarker
1202 //=======================================================================
1204 static Draw_MarkerShape recognizeMarker(const char* theMarkerStr,
1205 const Draw_MarkerShape& theDefaultMarker)
1207 Draw_MarkerShape aResult = theDefaultMarker;
1209 if ( !strcasecmp(theMarkerStr, "square") )
1210 aResult = Draw_Square;
1211 if ( !strcasecmp(theMarkerStr, "diamond") )
1212 aResult = Draw_Losange;
1213 if ( !strcasecmp(theMarkerStr, "x") )
1215 if ( !strcasecmp(theMarkerStr, "plus") )
1216 aResult = Draw_Plus;
1217 if ( !strcasecmp(theMarkerStr, "circle") )
1218 aResult = Draw_Circle;
1219 if ( !strcasecmp(theMarkerStr, "circle_zoom") )
1220 aResult = Draw_CircleZoom;
1225 //=======================================================================
1226 //function : setpointmarker
1228 //=======================================================================
1230 static Standard_Integer setpointmarker(Draw_Interpretor& di,
1231 Standard_Integer n, const char** a)
1233 Draw_MarkerShape mark, savemark;
1235 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1236 DrawTrSurf_PointMarker(savemark);
1240 printMarker(di, savemark);
1243 mark = recognizeMarker(a[1], savemark);
1244 DrawTrSurf_PointMarker(mark);
1249 //=======================================================================
1250 //function : changepointmarker
1252 //=======================================================================
1254 static Standard_Integer changepointmarker(Draw_Interpretor&,
1255 Standard_Integer n, const char** a)
1257 Draw_MarkerShape mark, savemark;
1259 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1260 DrawTrSurf_PointMarker(savemark);
1265 mark = recognizeMarker(a[1], savemark);
1267 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1277 //=======================================================================
1278 //function : BasicCommands
1280 //=======================================================================
1282 static Standard_Boolean done = Standard_False;
1283 void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands)
1286 done = Standard_True;
1289 g = "geometric display commands";
1291 theCommands.Add("nbiso",
1292 "nbiso name [names...] nuiso nviso",
1296 theCommands.Add("clpoles",
1297 "clpoles [name], no args : modal ",
1301 theCommands.Add("shpoles",
1302 "shpoles [name], no args : modal ",
1306 theCommands.Add("clknots",
1307 "clknots [name], no args : modal ",
1311 theCommands.Add("shknots",
1312 "shknots [name], no args : modal ",
1316 theCommands.Add("dmode",
1317 "dmode [names...] Uniform/Discret",
1321 theCommands.Add("discr",
1322 "discr [names...] nbintervals",
1326 theCommands.Add("defle",
1327 "defle [names...] defle",
1331 theCommands.Add("setcurvcolor",
1332 TCollection_AsciiString("setcurvcolor [color] : set curve color\
1333 by default, or print the current curve color if no argument (this does not modify\
1334 the color of the curve)\n\n").Cat(ColorsHint).ToCString(),
1335 __FILE__,setcurvcolor,g);
1337 theCommands.Add("changecurvcolor",
1338 TCollection_AsciiString("changecurvcolor color curve: change\
1339 color of the curve\n\n").Cat(ColorsHint).ToCString(),
1340 __FILE__,changecurvcolor,g);
1342 theCommands.Add("setpointcolor",
1343 TCollection_AsciiString("setpointcolor [color] : set point color\
1344 by default, or print the current point color if no argument (this does not modify\
1345 the color of the point)\n\n").Cat(ColorsHint).ToCString(),
1346 __FILE__,setpointcolor,g);
1348 theCommands.Add("changepointcolor",
1349 TCollection_AsciiString("changepointcolor color point: change\
1350 color of the point\n\n").Cat(ColorsHint).ToCString(),
1351 __FILE__,changepointcolor,g);
1353 theCommands.Add("setpointmarker",
1354 TCollection_AsciiString("setpointmarker [marker] : set point marker\
1355 by default, or print the current point marker if no argument (this does not modify\
1356 the marker of the point)\n\n").Cat(MarkersHint).ToCString(),
1357 __FILE__,setpointmarker,g);
1359 theCommands.Add("changepointmarker",
1360 TCollection_AsciiString("changepointmarker marker point: change\
1361 marker of the point\n\n").Cat(MarkersHint).ToCString(),
1362 __FILE__,changepointmarker,g);
1364 g = "Geometric tranformations";
1366 theCommands.Add("translate",
1367 "translate name [names...] dx dy dz",
1371 theCommands.Add("rotate",
1372 "rotate name [names...] x y z dx dy dz angle",
1376 theCommands.Add("pmirror",
1377 "pmirror name [names...] x y z",
1381 theCommands.Add("lmirror",
1382 "lmirror name [names...] x y z dx dy dz",
1386 theCommands.Add("smirror",
1387 "smirror name [names...] x y z dx dy dz",
1391 theCommands.Add("pscale",
1392 "pscale name [names...] x y z s",
1396 theCommands.Add("2dtranslate",
1397 "translate name [names...] dx dy",
1401 theCommands.Add("2drotate",
1402 "rotate name [names...] x y dx dy angle",
1406 theCommands.Add("2dpmirror",
1407 "pmirror name [names...] x y",
1411 theCommands.Add("2dlmirror",
1412 "lmirror name [names...] x y dx dy",
1416 theCommands.Add("2dpscale",
1417 "pscale name [names...] x y s",
1423 //=================================================================
1424 // save and restore curves
1425 //=================================================================
1427 static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d)
1429 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve));
1432 static void csave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1434 Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d);
1435 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1438 static Handle(Draw_Drawable3D) crestore (istream& is)
1440 Handle(Geom_Curve) G;
1441 GeomTools_CurveSet::ReadCurve(is,G);
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, 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 (istream& is)
1472 Handle(Geom_BezierCurve) G;
1473 GeomTools_CurveSet::ReadCurve(is,G);
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, 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 (istream& is)
1505 Handle(Geom_BSplineCurve) G;
1506 GeomTools_CurveSet::ReadCurve(is,G);
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, 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 (istream& is)
1538 Handle(Geom2d_Curve) G;
1539 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1540 Handle(DrawTrSurf_Curve2d) N =
1541 new DrawTrSurf_Curve2d(G,CurvColor,Discret);
1546 static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d",
1547 c2dtest,c2dsave,c2drestore);
1552 //=================================================================
1553 // save and restore bezier curves 2d
1554 //=================================================================
1556 static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d)
1558 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d));
1561 static void bzc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1563 Handle(DrawTrSurf_BezierCurve2d)
1564 N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d);
1565 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1568 static Handle(Draw_Drawable3D) bzc2drestore (istream& is)
1570 Handle(Geom2d_BezierCurve) G;
1571 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1572 Handle(DrawTrSurf_BezierCurve2d) N =
1573 new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
1579 static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d",
1580 bzc2dtest,bzc2dsave,bzc2drestore);
1585 //=================================================================
1586 // save and restore bspline curves 2d
1587 //=================================================================
1589 static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d)
1591 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d));
1594 static void bsc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1596 Handle(DrawTrSurf_BSplineCurve2d)
1597 N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d);
1598 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1601 static Handle(Draw_Drawable3D) bsc2drestore (istream& is)
1603 Handle(Geom2d_BSplineCurve) G;
1604 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1605 Handle(DrawTrSurf_BSplineCurve2d) N =
1606 new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
1608 KnotsShape,KnotsSize,
1609 ShowPoles,ShowKnots,
1615 static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d",
1616 bsc2dtest,bsc2dsave,bsc2drestore);
1619 //=================================================================
1620 // save and restore surfaces
1621 //=================================================================
1623 static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
1625 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface));
1628 static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1630 Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d);
1631 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1634 static Handle(Draw_Drawable3D) srestore (istream& is)
1636 Handle(Geom_Surface) G;
1637 GeomTools_SurfaceSet::ReadSurface(is,G);
1638 Handle(DrawTrSurf_Surface) N =
1639 new DrawTrSurf_Surface(G,
1641 BoundsColor,IsosColor,
1642 Discret,Deflection,DrawMode);
1647 static Draw_SaveAndRestore ssr("DrawTrSurf_Surface",
1648 stest,ssave,srestore);
1653 //=================================================================
1654 // save and restore bezier surfaces
1655 //=================================================================
1657 static Standard_Boolean bzstest(const Handle(Draw_Drawable3D)& d)
1659 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierSurface));
1662 static void bzssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1664 Handle(DrawTrSurf_BezierSurface)
1665 N = Handle(DrawTrSurf_BezierSurface)::DownCast(d);
1666 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1669 static Handle(Draw_Drawable3D) bzsrestore (istream& is)
1671 Handle(Geom_BezierSurface) G;
1672 GeomTools_SurfaceSet::ReadSurface(is,G);
1673 Handle(DrawTrSurf_BezierSurface) N =
1674 new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
1675 BoundsColor,IsosColor,PolesColor,
1677 Discret,Deflection,DrawMode);
1682 static Draw_SaveAndRestore bzssr("DrawTrSurf_BezierSurface",
1683 bzstest,bzssave,bzsrestore);
1688 //=================================================================
1689 // save and restore bspline surfaces
1690 //=================================================================
1692 static Standard_Boolean bsstest(const Handle(Draw_Drawable3D)& d)
1694 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineSurface));
1697 static void bsssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1699 Handle(DrawTrSurf_BSplineSurface)
1700 N = Handle(DrawTrSurf_BSplineSurface)::DownCast(d);
1701 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1704 static Handle(Draw_Drawable3D) bssrestore (istream& is)
1706 Handle(Geom_BSplineSurface) G;
1707 GeomTools_SurfaceSet::ReadSurface(is,G);
1708 Handle(DrawTrSurf_BSplineSurface) N;
1710 N = new DrawTrSurf_BSplineSurface(G,
1712 BoundsColor,IsosColor,
1713 PolesColor,KnotsColor,
1714 KnotsShape,KnotsSize,
1715 ShowPoles,ShowKnots,
1716 Discret,Deflection,DrawMode);
1718 N = new DrawTrSurf_BSplineSurface(G,
1719 BoundsColor,IsosColor,
1720 PolesColor,KnotsColor,
1721 KnotsShape,KnotsSize,
1722 ShowPoles,ShowKnots,
1723 Discret,Deflection,DrawMode);
1729 static Draw_SaveAndRestore bsssr("DrawTrSurf_BSplineSurface",
1730 bsstest,bsssave,bssrestore);
1733 //=================================================================
1734 // save and restore points
1735 //=================================================================
1737 static Standard_Boolean pnttest(const Handle(Draw_Drawable3D)& d)
1739 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Point));
1742 static void pntsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1744 Handle(DrawTrSurf_Point)
1745 N = Handle(DrawTrSurf_Point)::DownCast(d);
1746 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1747 ios::fmtflags F = OS.flags();
1748 OS.setf(ios::scientific,ios::floatfield);
1751 long form = OS.setf(ios::scientific);
1752 std::streamsize prec = OS.precision(15);
1754 gp_Pnt P = N->Point();
1757 OS << P.X() << " " << P.Y() << " " << P.Z() << "\n";
1761 OS << P.X() << " " << P.Y() << "\n";
1763 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1771 static Handle(Draw_Drawable3D) pntrestore (istream& is)
1773 Standard_Integer is3d;
1775 Standard_Real x,y,z = 0.;
1780 Handle(DrawTrSurf_Point) N;
1782 N = new DrawTrSurf_Point(gp_Pnt(x,y,z),PntShape,PntColor);
1784 N = new DrawTrSurf_Point(gp_Pnt2d(x,y),PntShape,PntColor);
1790 static Draw_SaveAndRestore pntsr("DrawTrSurf_Point",
1791 pnttest,pntsave,pntrestore);
1795 //=================================================================
1796 // save and restore triangulation
1797 //=================================================================
1799 static Standard_Boolean triatest(const Handle(Draw_Drawable3D)& d)
1801 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Triangulation));
1804 static void triasave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1806 Handle(DrawTrSurf_Triangulation)
1807 T = Handle(DrawTrSurf_Triangulation)::DownCast(d);
1808 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1809 ios::fmtflags F = OS.flags();
1810 OS.setf(ios::scientific,ios::floatfield);
1813 long form = OS.setf(ios::scientific);
1814 std::streamsize prec = OS.precision(15);
1816 Poly::Write(T->Triangulation(),OS);
1817 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1825 static Handle(Draw_Drawable3D) triarestore (istream& is)
1827 return new DrawTrSurf_Triangulation(Poly::ReadTriangulation(is));
1831 static Draw_SaveAndRestore triasr("DrawTrSurf_Triangulation",
1832 triatest,triasave,triarestore);
1836 //=================================================================
1837 // save and restore polygon3d
1838 //=================================================================
1840 static Standard_Boolean poly3dtest(const Handle(Draw_Drawable3D)& d)
1842 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon3D));
1845 static void poly3dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1847 Handle(DrawTrSurf_Polygon3D)
1848 T = Handle(DrawTrSurf_Polygon3D)::DownCast(d);
1849 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1850 ios::fmtflags F = OS.flags();
1851 OS.setf(ios::scientific,ios::floatfield);
1854 long form = OS.setf(ios::scientific);
1855 std::streamsize prec = OS.precision(15);
1857 Poly::Write(T->Polygon3D(),OS);
1858 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1866 static Handle(Draw_Drawable3D) poly3drestore (istream& is)
1868 return new DrawTrSurf_Polygon3D(Poly::ReadPolygon3D(is));
1872 static Draw_SaveAndRestore poly3dsr("DrawTrSurf_Polygon3D",
1873 poly3dtest,poly3dsave,poly3drestore);
1876 //=================================================================
1877 // save and restore polygon2d
1878 //=================================================================
1880 static Standard_Boolean poly2dtest(const Handle(Draw_Drawable3D)& d)
1882 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon2D));
1885 static void poly2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1887 Handle(DrawTrSurf_Polygon2D)
1888 T = Handle(DrawTrSurf_Polygon2D)::DownCast(d);
1889 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1890 ios::fmtflags F = OS.flags();
1891 OS.setf(ios::scientific, ios::floatfield);
1894 long form = OS.setf(ios::scientific);
1895 std::streamsize prec = OS.precision(15);
1897 Poly::Write(T->Polygon2D(),OS);
1898 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1906 static Handle(Draw_Drawable3D) poly2drestore (istream& is)
1908 return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is));
1912 static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D",
1913 poly2dtest,poly2dsave,poly2drestore);