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")) {
403 else if (!strcmp(a[0],"discr")) {
405 Discret = Draw::Atoi(a[n-1]);
409 else if (!strcmp(a[0],"defle")) {
411 Deflection = Draw::Atof(a[n-1]);
416 for (Standard_Integer i = 1; i < n - 1; i++) {
417 Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]);
419 if (!strcmp(a[0],"dmode")) {
420 Standard_Integer mod = 0;
421 if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
425 else if (!strcmp(a[0],"discr")) {
426 D->SetDiscretisation(Draw::Atoi(a[n-1]));
429 else if (!strcmp(a[0],"defle")) {
430 D->SetDeflection(Draw::Atof(a[n-1]));
440 //=======================================================================
441 //function : transform
443 //=======================================================================
445 static Standard_Integer transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
449 Standard_Integer i,last = n-1;
450 if (!strcmp(a[0],"pscale")) {
451 Standard_Real s = Draw::Atof(a[last]);
453 if (last < 4) return 1;
454 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
457 else if (!strcmp(a[0]+1,"mirror")) {
458 if (last < 4) return 1;
459 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
465 if (last < 4) return 1;
466 gp_Pnt O(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
468 gp_Dir D(P.X(),P.Y(),P.Z());
470 T.SetMirror(gp_Ax1(O,D));
472 else if (*a[0] == 's') {
474 T.SetMirror(Pl.Position().Ax2());
479 else if (!strcmp(a[0],"translate")) {
480 if (last < 4) return 1;
481 gp_Vec V(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
486 else if (!strcmp(a[0],"rotate")) {
487 if (last < 8) return 1;
488 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
490 gp_Dir D(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
492 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
494 T.SetRotation(gp_Ax1(P,D),ang);
497 for (i = 1; i <= last; i++) {
498 Handle(Geom_Geometry) G = DrawTrSurf::Get(a[i]);
505 if (DrawTrSurf::GetPoint(a[i],P)) {
507 DrawTrSurf::Set(a[i],P);
515 //=======================================================================
516 //function : d2transform
518 //=======================================================================
520 static Standard_Integer d2transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
524 Standard_Integer i,last = n-1;
525 if (!strcmp(a[0],"2dpscale")) {
526 Standard_Real s = Draw::Atof(a[last]);
528 if (last < 3) return 1;
529 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
532 else if ( (!strcmp(a[0],"2dpmirror")) ||
533 (!strcmp(a[0],"2dlmirror")) ) {
534 if (last < 3) return 1;
535 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
536 if (!strcmp(a[0],"2dpmirror")) {
541 if (last < 3) return 1;
542 gp_Pnt2d O(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
544 gp_Dir2d D(P.X(),P.Y());
545 T.SetMirror(gp_Ax2d(O,D));
549 else if (!strcmp(a[0],"2dtranslate")) {
550 if (last < 3) return 1;
551 gp_Vec2d V(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
556 else if (!strcmp(a[0],"2drotate")) {
557 if (last < 4) return 1;
558 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
560 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
562 T.SetRotation(P,ang);
565 for (i = 1; i <= last; i++) {
566 Handle(Geom2d_Curve) G = DrawTrSurf::GetCurve2d(a[i]);
573 if (DrawTrSurf::GetPoint2d(a[i],P)) {
575 DrawTrSurf::Set(a[i],P);
583 //=======================================================================
586 //=======================================================================
587 void DrawTrSurf::Set(const Standard_CString Name,
590 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
594 //=======================================================================
597 //=======================================================================
598 void DrawTrSurf::Set(const Standard_CString Name,
601 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
605 //=======================================================================
607 //purpose : Geometry from Geom
608 //=======================================================================
609 void DrawTrSurf::Set(const Standard_CString Name,
610 const Handle(Geom_Geometry)& G,
611 const Standard_Boolean isSenseMarker)
613 Handle(DrawTrSurf_Drawable) D;
616 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G);
619 Handle(Geom_BezierCurve) Bez =
620 Handle(Geom_BezierCurve)::DownCast(C);
622 Handle(DrawTrSurf_BezierCurve) DBez =
623 new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles,
624 Discret,Deflection,DrawMode);
629 Handle(Geom_BSplineCurve) BS =
630 Handle(Geom_BSplineCurve)::DownCast(C);
632 Handle(DrawTrSurf_BSplineCurve) DBS =
633 new DrawTrSurf_BSplineCurve(BS,
634 CurvColor,PolesColor,
636 KnotsShape,KnotsSize,
638 Discret,Deflection,DrawMode);
642 if (Bez.IsNull() && BS.IsNull()) {
643 Handle(DrawTrSurf_Curve) DC =
644 new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker);
650 Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G);
653 Handle(Geom_BezierSurface) Bez =
654 Handle(Geom_BezierSurface)::DownCast(S);
656 Handle(DrawTrSurf_BezierSurface) DBez =
657 new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos,
658 BoundsColor,IsosColor,PolesColor,
660 Discret,Deflection,DrawMode);
665 Handle(Geom_BSplineSurface) BS =
666 Handle(Geom_BSplineSurface)::DownCast(S);
668 Handle(DrawTrSurf_BSplineSurface) DBS ;
670 DBS = new DrawTrSurf_BSplineSurface(BS,
672 BoundsColor,IsosColor,
673 PolesColor,KnotsColor,
674 KnotsShape,KnotsSize,
676 Discret,Deflection,DrawMode);
678 DBS = new DrawTrSurf_BSplineSurface(BS,
679 BoundsColor,IsosColor,
680 PolesColor,KnotsColor,
681 KnotsShape,KnotsSize,
683 Discret,Deflection,DrawMode);
688 if (Bez.IsNull() && BS.IsNull()) {
689 Handle(DrawTrSurf_Surface) DS =
690 new DrawTrSurf_Surface(S,
692 BoundsColor,IsosColor,
693 Discret,Deflection,DrawMode);
703 //=======================================================================
705 //purpose : Curve from Geom2d
706 //=======================================================================
707 void DrawTrSurf::Set(const Standard_CString Name,
708 const Handle(Geom2d_Curve)& C,
709 const Standard_Boolean isSenseMarker)
711 Handle(DrawTrSurf_Drawable) D;
714 Handle(Geom2d_BezierCurve) Bez =
715 Handle(Geom2d_BezierCurve)::DownCast(C);
717 Handle(DrawTrSurf_BezierCurve2d) DBez =
718 new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles,
724 Handle(Geom2d_BSplineCurve) BS =
725 Handle(Geom2d_BSplineCurve)::DownCast(C);
727 Handle(DrawTrSurf_BSplineCurve2d) DBS =
728 new DrawTrSurf_BSplineCurve2d(BS,
729 CurvColor,PolesColor,
731 KnotsShape,KnotsSize,
737 if (Bez.IsNull() && BS.IsNull()) {
738 Handle(DrawTrSurf_Curve2d) DC =
739 new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker);
747 //=======================================================================
750 //=======================================================================
751 void DrawTrSurf::Set(const Standard_CString Name,
752 const Handle(Poly_Triangulation)& T)
754 Handle(DrawTrSurf_Triangulation) D = new DrawTrSurf_Triangulation(T);
757 //=======================================================================
760 //=======================================================================
761 void DrawTrSurf::Set(const Standard_CString Name,
762 const Handle(Poly_Polygon3D)& P)
764 Handle(DrawTrSurf_Polygon3D) D = new DrawTrSurf_Polygon3D(P);
768 //=======================================================================
771 //=======================================================================
772 void DrawTrSurf::Set(const Standard_CString Name,
773 const Handle(Poly_Polygon2D)& P)
775 Handle(DrawTrSurf_Polygon2D) D = new DrawTrSurf_Polygon2D(P);
779 //=======================================================================
782 //=======================================================================
783 Handle(Geom_Geometry) DrawTrSurf::Get(Standard_CString& Name)
785 Handle(Draw_Drawable3D) D = Draw::Get(Name);
787 Handle(DrawTrSurf_Curve) DC =
788 Handle(DrawTrSurf_Curve)::DownCast(D);
790 return DC->GetCurve();
792 Handle(DrawTrSurf_Surface) DS =
793 Handle(DrawTrSurf_Surface)::DownCast(D);
795 return DS->GetSurface();
797 return Handle(Geom_Geometry) ();
801 //=======================================================================
802 //function : GetPoint
804 //=======================================================================
805 Standard_Boolean DrawTrSurf::GetPoint(Standard_CString& Name,
808 Handle(DrawTrSurf_Point) D =
809 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
811 return Standard_False;
813 return Standard_False;
816 return Standard_True;
820 //=======================================================================
821 //function : GetPoint2d
823 //=======================================================================
824 Standard_Boolean DrawTrSurf::GetPoint2d(Standard_CString& Name,
827 Handle(DrawTrSurf_Point) D =
828 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
830 return Standard_False;
832 return Standard_False;
835 return Standard_True;
839 //=======================================================================
840 //function : GetCurve
842 //=======================================================================
843 Handle(Geom_Curve) DrawTrSurf::GetCurve(Standard_CString& Name)
845 Handle(DrawTrSurf_Curve) D =
846 Handle(DrawTrSurf_Curve)::DownCast(Draw::Get(Name));
848 return Handle(Geom_Curve)();
850 return D->GetCurve();
854 //=======================================================================
855 //function : GetBezierCurve
857 //=======================================================================
858 Handle(Geom_BezierCurve) DrawTrSurf::GetBezierCurve(Standard_CString& Name)
860 Handle(DrawTrSurf_BezierCurve) D =
861 Handle(DrawTrSurf_BezierCurve)::DownCast(Draw::Get(Name));
863 return Handle(Geom_BezierCurve)();
865 return Handle(Geom_BezierCurve)::DownCast(D->GetCurve());
869 //=======================================================================
870 //function : GetBSplineCurve
872 //=======================================================================
873 Handle(Geom_BSplineCurve) DrawTrSurf::GetBSplineCurve(Standard_CString& Name)
875 Handle(DrawTrSurf_BSplineCurve) D =
876 Handle(DrawTrSurf_BSplineCurve)::DownCast(Draw::Get(Name));
878 return Handle(Geom_BSplineCurve)();
880 return Handle(Geom_BSplineCurve)::DownCast(D->GetCurve());
882 //=======================================================================
883 //function : GetCurve2d
885 //=======================================================================
886 Handle(Geom2d_Curve) DrawTrSurf::GetCurve2d(Standard_CString& Name)
888 Handle(DrawTrSurf_Curve2d) D =
889 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
891 return Handle(Geom2d_Curve)();
893 return D->GetCurve();
895 //=======================================================================
896 //function : GetBezierCurve2d
898 //=======================================================================
899 Handle(Geom2d_BezierCurve) DrawTrSurf::GetBezierCurve2d(Standard_CString& Name)
901 Handle(DrawTrSurf_Curve2d) D =
902 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
904 return Handle(Geom2d_BezierCurve)();
906 return Handle(Geom2d_BezierCurve)::DownCast(D->GetCurve());
908 //=======================================================================
909 //function : GetBSplineCurve2d
911 //=======================================================================
912 Handle(Geom2d_BSplineCurve) DrawTrSurf::GetBSplineCurve2d
913 (Standard_CString& Name)
915 Handle(DrawTrSurf_Curve2d) D =
916 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
918 return Handle(Geom2d_BSplineCurve)();
920 return Handle(Geom2d_BSplineCurve)::DownCast(D->GetCurve());
922 //=======================================================================
923 //function : GetSurface
925 //=======================================================================
926 Handle(Geom_Surface) DrawTrSurf::GetSurface
927 (Standard_CString& Name)
929 Handle(DrawTrSurf_Surface) D =
930 Handle(DrawTrSurf_Surface)::DownCast(Draw::Get(Name));
932 return Handle(Geom_Surface)();
934 return D->GetSurface();
936 //=======================================================================
937 //function : GetBezierSurface
939 //=======================================================================
940 Handle(Geom_BezierSurface) DrawTrSurf::GetBezierSurface
941 (Standard_CString& Name)
943 Handle(DrawTrSurf_BezierSurface) D =
944 Handle(DrawTrSurf_BezierSurface)::DownCast(Draw::Get(Name));
946 return Handle(Geom_BezierSurface)();
948 return Handle(Geom_BezierSurface)::DownCast(D->GetSurface());
950 //=======================================================================
951 //function : GetBSplineSurface
953 //=======================================================================
954 Handle(Geom_BSplineSurface) DrawTrSurf::GetBSplineSurface
955 (Standard_CString& Name)
957 Handle(DrawTrSurf_BSplineSurface) D =
958 Handle(DrawTrSurf_BSplineSurface)::DownCast(Draw::Get(Name));
960 return Handle(Geom_BSplineSurface)();
962 return Handle(Geom_BSplineSurface)::DownCast(D->GetSurface());
964 //=======================================================================
965 //function : GetTriangulation
967 //=======================================================================
968 Handle(Poly_Triangulation) DrawTrSurf::GetTriangulation(Standard_CString& Name)
970 Handle(DrawTrSurf_Triangulation) D =
971 Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(Name));
973 return Handle(Poly_Triangulation)();
975 return D->Triangulation();
977 //=======================================================================
978 //function : GetPolygon3D
980 //=======================================================================
981 Handle(Poly_Polygon3D) DrawTrSurf::GetPolygon3D(Standard_CString& Name)
983 Handle(DrawTrSurf_Polygon3D) D =
984 Handle(DrawTrSurf_Polygon3D)::DownCast(Draw::Get(Name));
986 return Handle(Poly_Polygon3D)();
988 return D->Polygon3D();
990 //=======================================================================
991 //function : GetPolygon2D
993 //=======================================================================
994 Handle(Poly_Polygon2D) DrawTrSurf::GetPolygon2D(Standard_CString& Name)
996 Handle(DrawTrSurf_Polygon2D) D =
997 Handle(DrawTrSurf_Polygon2D)::DownCast(Draw::Get(Name));
999 return Handle(Poly_Polygon2D)();
1001 return D->Polygon2D();
1004 //=======================================================================
1005 //function : printColor
1007 //=======================================================================
1009 static void printColor(Draw_Interpretor& di, const Draw_Color& theColor)
1011 switch ( theColor.ID() )
1013 case Draw_blanc: di << "white " << "\n"; break;
1014 case Draw_rouge: di << "red " << "\n"; break;
1015 case Draw_vert: di << "green " << "\n"; break;
1016 case Draw_bleu: di << "blue " << "\n"; break;
1017 case Draw_cyan: di << "cyan " << "\n"; break;
1018 case Draw_or: di << "golden " << "\n"; break;
1019 case Draw_magenta: di << "magenta " << "\n"; break;
1020 case Draw_marron: di << "brown " << "\n"; break;
1021 case Draw_orange: di << "orange " << "\n"; break;
1022 case Draw_rose: di << "pink " << "\n"; break;
1023 case Draw_saumon: di << "salmon " << "\n"; break;
1024 case Draw_violet: di << "violet " << "\n"; break;
1025 case Draw_jaune: di << "yellow " << "\n"; break;
1026 case Draw_kaki: di << "dark-olive green " << "\n"; break;
1027 case Draw_corail: di << "coral " << "\n"; break;
1031 //=======================================================================
1032 //function : recognizeColor
1034 //=======================================================================
1036 static Draw_Color recognizeColor(const char* theColorStr,
1037 const Draw_Color& theDefaultColor)
1039 Draw_Color aResult = theDefaultColor;
1041 if ( !strcasecmp(theColorStr,"white") )
1042 aResult = Draw_blanc;
1043 if ( !strcasecmp(theColorStr, "red") )
1044 aResult = Draw_rouge;
1045 if ( !strcasecmp(theColorStr, "green") )
1046 aResult = Draw_vert;
1047 if ( !strcasecmp(theColorStr, "blue") )
1048 aResult = Draw_bleu;
1049 if ( !strcasecmp(theColorStr, "cyan") )
1050 aResult = Draw_cyan;
1051 if ( !strcasecmp(theColorStr, "golden") )
1053 if ( !strcasecmp(theColorStr, "magenta") )
1054 aResult = Draw_magenta;
1055 if ( !strcasecmp(theColorStr, "brown") )
1056 aResult = Draw_marron;
1057 if ( !strcasecmp(theColorStr, "orange") )
1058 aResult = Draw_orange;
1059 if ( !strcasecmp(theColorStr, "pink") )
1060 aResult = Draw_rose;
1061 if ( !strcasecmp(theColorStr, "salmon") )
1062 aResult = Draw_saumon;
1063 if ( !strcasecmp(theColorStr, "violet") )
1064 aResult = Draw_violet;
1065 if ( !strcasecmp(theColorStr, "yellow") )
1066 aResult = Draw_jaune;
1067 if ( !strcasecmp(theColorStr, "darkgreen") )
1068 aResult = Draw_kaki;
1069 if ( !strcasecmp(theColorStr, "coral") )
1070 aResult = Draw_corail;
1075 //=======================================================================
1076 //function : setcurvcolor
1078 //=======================================================================
1080 static Standard_Integer setcurvcolor(Draw_Interpretor& di,
1081 Standard_Integer n, const char** a)
1083 Draw_Color col, savecol;
1085 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1086 DrawTrSurf_CurveColor(savecol);
1090 printColor(di, savecol);
1093 col = recognizeColor(a[1], savecol);
1094 DrawTrSurf_CurveColor(col);
1099 //=======================================================================
1100 //function : changecurvcolor
1102 //=======================================================================
1104 static Standard_Integer changecurvcolor(Draw_Interpretor&,
1105 Standard_Integer n, const char** a)
1107 Draw_Color col, savecol;
1109 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1110 DrawTrSurf_CurveColor(savecol);
1115 col = recognizeColor(a[1], savecol);
1117 Handle(DrawTrSurf_Curve) D = Handle(DrawTrSurf_Curve)::DownCast( Draw::Get(a[2]) );
1127 //=======================================================================
1128 //function : setpointcolor
1130 //=======================================================================
1132 static Standard_Integer setpointcolor(Draw_Interpretor& di,
1133 Standard_Integer n, const char** a)
1135 Draw_Color col, savecol;
1137 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1138 DrawTrSurf_PointColor(savecol);
1142 printColor(di, savecol);
1145 col = recognizeColor(a[1], savecol);
1146 DrawTrSurf_PointColor(col);
1151 //=======================================================================
1152 //function : changepointcolor
1154 //=======================================================================
1156 static Standard_Integer changepointcolor(Draw_Interpretor&,
1157 Standard_Integer n, const char** a)
1159 Draw_Color col, savecol;
1161 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1162 DrawTrSurf_PointColor(savecol);
1167 col = recognizeColor(a[1], savecol);
1169 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1179 //=======================================================================
1180 //function : printMarker
1182 //=======================================================================
1184 static void printMarker(Draw_Interpretor& di, const Draw_MarkerShape& theMarker)
1186 switch ( theMarker )
1188 case Draw_Square: di << "square " << "\n"; break;
1189 case Draw_Losange: di << "diamond " << "\n"; break;
1190 case Draw_X: di << "x " << "\n"; break;
1191 case Draw_Plus: di << "plus " << "\n"; break;
1192 case Draw_Circle: di << "circle " << "\n"; break;
1193 case Draw_CircleZoom: di << "circle_zoom " << "\n"; break;
1197 //=======================================================================
1198 //function : recognizeMarker
1200 //=======================================================================
1202 static Draw_MarkerShape recognizeMarker(const char* theMarkerStr,
1203 const Draw_MarkerShape& theDefaultMarker)
1205 Draw_MarkerShape aResult = theDefaultMarker;
1207 if ( !strcasecmp(theMarkerStr, "square") )
1208 aResult = Draw_Square;
1209 if ( !strcasecmp(theMarkerStr, "diamond") )
1210 aResult = Draw_Losange;
1211 if ( !strcasecmp(theMarkerStr, "x") )
1213 if ( !strcasecmp(theMarkerStr, "plus") )
1214 aResult = Draw_Plus;
1215 if ( !strcasecmp(theMarkerStr, "circle") )
1216 aResult = Draw_Circle;
1217 if ( !strcasecmp(theMarkerStr, "circle_zoom") )
1218 aResult = Draw_CircleZoom;
1223 //=======================================================================
1224 //function : setpointmarker
1226 //=======================================================================
1228 static Standard_Integer setpointmarker(Draw_Interpretor& di,
1229 Standard_Integer n, const char** a)
1231 Draw_MarkerShape mark, savemark;
1233 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1234 DrawTrSurf_PointMarker(savemark);
1238 printMarker(di, savemark);
1241 mark = recognizeMarker(a[1], savemark);
1242 DrawTrSurf_PointMarker(mark);
1247 //=======================================================================
1248 //function : changepointmarker
1250 //=======================================================================
1252 static Standard_Integer changepointmarker(Draw_Interpretor&,
1253 Standard_Integer n, const char** a)
1255 Draw_MarkerShape mark, savemark;
1257 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1258 DrawTrSurf_PointMarker(savemark);
1263 mark = recognizeMarker(a[1], savemark);
1265 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1275 //=======================================================================
1276 //function : BasicCommands
1278 //=======================================================================
1280 static Standard_Boolean done = Standard_False;
1281 void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands)
1284 done = Standard_True;
1287 g = "geometric display commands";
1289 theCommands.Add("nbiso",
1290 "nbiso name [names...] nuiso nviso",
1294 theCommands.Add("clpoles",
1295 "clpoles [name], no args : modal ",
1299 theCommands.Add("shpoles",
1300 "shpoles [name], no args : modal ",
1304 theCommands.Add("clknots",
1305 "clknots [name], no args : modal ",
1309 theCommands.Add("shknots",
1310 "shknots [name], no args : modal ",
1314 theCommands.Add("dmode",
1315 "dmode [names...] Uniform/Discret",
1319 theCommands.Add("discr",
1320 "discr [names...] nbintervals",
1324 theCommands.Add("defle",
1325 "defle [names...] defle",
1329 theCommands.Add("setcurvcolor",
1330 TCollection_AsciiString("setcurvcolor [color] : set curve color\
1331 by default, or print the current curve color if no argument (this does not modify\
1332 the color of the curve)\n\n").Cat(ColorsHint).ToCString(),
1333 __FILE__,setcurvcolor,g);
1335 theCommands.Add("changecurvcolor",
1336 TCollection_AsciiString("changecurvcolor color curve: change\
1337 color of the curve\n\n").Cat(ColorsHint).ToCString(),
1338 __FILE__,changecurvcolor,g);
1340 theCommands.Add("setpointcolor",
1341 TCollection_AsciiString("setpointcolor [color] : set point color\
1342 by default, or print the current point color if no argument (this does not modify\
1343 the color of the point)\n\n").Cat(ColorsHint).ToCString(),
1344 __FILE__,setpointcolor,g);
1346 theCommands.Add("changepointcolor",
1347 TCollection_AsciiString("changepointcolor color point: change\
1348 color of the point\n\n").Cat(ColorsHint).ToCString(),
1349 __FILE__,changepointcolor,g);
1351 theCommands.Add("setpointmarker",
1352 TCollection_AsciiString("setpointmarker [marker] : set point marker\
1353 by default, or print the current point marker if no argument (this does not modify\
1354 the marker of the point)\n\n").Cat(MarkersHint).ToCString(),
1355 __FILE__,setpointmarker,g);
1357 theCommands.Add("changepointmarker",
1358 TCollection_AsciiString("changepointmarker marker point: change\
1359 marker of the point\n\n").Cat(MarkersHint).ToCString(),
1360 __FILE__,changepointmarker,g);
1362 g = "Geometric tranformations";
1364 theCommands.Add("translate",
1365 "translate name [names...] dx dy dz",
1369 theCommands.Add("rotate",
1370 "rotate name [names...] x y z dx dy dz angle",
1374 theCommands.Add("pmirror",
1375 "pmirror name [names...] x y z",
1379 theCommands.Add("lmirror",
1380 "lmirror name [names...] x y z dx dy dz",
1384 theCommands.Add("smirror",
1385 "smirror name [names...] x y z dx dy dz",
1389 theCommands.Add("pscale",
1390 "pscale name [names...] x y z s",
1394 theCommands.Add("2dtranslate",
1395 "translate name [names...] dx dy",
1399 theCommands.Add("2drotate",
1400 "rotate name [names...] x y dx dy angle",
1404 theCommands.Add("2dpmirror",
1405 "pmirror name [names...] x y",
1409 theCommands.Add("2dlmirror",
1410 "lmirror name [names...] x y dx dy",
1414 theCommands.Add("2dpscale",
1415 "pscale name [names...] x y s",
1421 //=================================================================
1422 // save and restore curves
1423 //=================================================================
1425 static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d)
1427 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve));
1430 static void csave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1432 Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d);
1433 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1436 static Handle(Draw_Drawable3D) crestore (istream& is)
1438 Handle(Geom_Curve) G;
1439 GeomTools_CurveSet::ReadCurve(is,G);
1440 Handle(DrawTrSurf_Curve) N =
1441 new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
1446 static Draw_SaveAndRestore csr("DrawTrSurf_Curve",
1447 ctest,csave,crestore);
1452 //=================================================================
1453 // save and restore bezier curves
1454 //=================================================================
1456 static Standard_Boolean bzctest(const Handle(Draw_Drawable3D)& d)
1458 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve));
1461 static void bzcsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1463 Handle(DrawTrSurf_BezierCurve)
1464 N = Handle(DrawTrSurf_BezierCurve)::DownCast(d);
1465 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1468 static Handle(Draw_Drawable3D) bzcrestore (istream& is)
1470 Handle(Geom_BezierCurve) G;
1471 GeomTools_CurveSet::ReadCurve(is,G);
1472 Handle(DrawTrSurf_BezierCurve) N =
1473 new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
1474 Discret,Deflection,DrawMode);
1479 static Draw_SaveAndRestore bzcsr("DrawTrSurf_BezierCurve",
1480 bzctest,bzcsave,bzcrestore);
1485 //=================================================================
1486 // save and restore bspline curves
1487 //=================================================================
1489 static Standard_Boolean bsctest(const Handle(Draw_Drawable3D)& d)
1491 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve));
1494 static void bscsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1496 Handle(DrawTrSurf_BSplineCurve)
1497 N = Handle(DrawTrSurf_BSplineCurve)::DownCast(d);
1498 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1501 static Handle(Draw_Drawable3D) bscrestore (istream& is)
1503 Handle(Geom_BSplineCurve) G;
1504 GeomTools_CurveSet::ReadCurve(is,G);
1505 Handle(DrawTrSurf_BSplineCurve) N =
1506 new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
1508 KnotsShape,KnotsSize,
1509 ShowPoles,ShowKnots,
1510 Discret,Deflection,DrawMode);
1515 static Draw_SaveAndRestore bscsr("DrawTrSurf_BSplineCurve",
1516 bsctest,bscsave,bscrestore);
1519 //=================================================================
1520 // save and restore curves 2d
1521 //=================================================================
1523 static Standard_Boolean c2dtest(const Handle(Draw_Drawable3D)& d)
1525 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve2d));
1528 static void c2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1530 Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d)::DownCast(d);
1531 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1534 static Handle(Draw_Drawable3D) c2drestore (istream& is)
1536 Handle(Geom2d_Curve) G;
1537 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1538 Handle(DrawTrSurf_Curve2d) N =
1539 new DrawTrSurf_Curve2d(G,CurvColor,Discret);
1544 static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d",
1545 c2dtest,c2dsave,c2drestore);
1550 //=================================================================
1551 // save and restore bezier curves 2d
1552 //=================================================================
1554 static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d)
1556 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d));
1559 static void bzc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1561 Handle(DrawTrSurf_BezierCurve2d)
1562 N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d);
1563 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1566 static Handle(Draw_Drawable3D) bzc2drestore (istream& is)
1568 Handle(Geom2d_BezierCurve) G;
1569 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1570 Handle(DrawTrSurf_BezierCurve2d) N =
1571 new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
1577 static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d",
1578 bzc2dtest,bzc2dsave,bzc2drestore);
1583 //=================================================================
1584 // save and restore bspline curves 2d
1585 //=================================================================
1587 static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d)
1589 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d));
1592 static void bsc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1594 Handle(DrawTrSurf_BSplineCurve2d)
1595 N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d);
1596 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1599 static Handle(Draw_Drawable3D) bsc2drestore (istream& is)
1601 Handle(Geom2d_BSplineCurve) G;
1602 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1603 Handle(DrawTrSurf_BSplineCurve2d) N =
1604 new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
1606 KnotsShape,KnotsSize,
1607 ShowPoles,ShowKnots,
1613 static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d",
1614 bsc2dtest,bsc2dsave,bsc2drestore);
1617 //=================================================================
1618 // save and restore surfaces
1619 //=================================================================
1621 static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
1623 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface));
1626 static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1628 Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d);
1629 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1632 static Handle(Draw_Drawable3D) srestore (istream& is)
1634 Handle(Geom_Surface) G;
1635 GeomTools_SurfaceSet::ReadSurface(is,G);
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, 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 (istream& is)
1669 Handle(Geom_BezierSurface) G;
1670 GeomTools_SurfaceSet::ReadSurface(is,G);
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, 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 (istream& is)
1704 Handle(Geom_BSplineSurface) G;
1705 GeomTools_SurfaceSet::ReadSurface(is,G);
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, ostream& OS)
1742 Handle(DrawTrSurf_Point)
1743 N = Handle(DrawTrSurf_Point)::DownCast(d);
1744 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1745 ios::fmtflags F = OS.flags();
1746 OS.setf(ios::scientific,ios::floatfield);
1749 long form = OS.setf(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(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1769 static Handle(Draw_Drawable3D) pntrestore (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, ostream& OS)
1804 Handle(DrawTrSurf_Triangulation)
1805 T = Handle(DrawTrSurf_Triangulation)::DownCast(d);
1806 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1807 ios::fmtflags F = OS.flags();
1808 OS.setf(ios::scientific,ios::floatfield);
1811 long form = OS.setf(ios::scientific);
1812 std::streamsize prec = OS.precision(15);
1814 Poly::Write(T->Triangulation(),OS);
1815 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1823 static Handle(Draw_Drawable3D) triarestore (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, ostream& OS)
1845 Handle(DrawTrSurf_Polygon3D)
1846 T = Handle(DrawTrSurf_Polygon3D)::DownCast(d);
1847 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1848 ios::fmtflags F = OS.flags();
1849 OS.setf(ios::scientific,ios::floatfield);
1852 long form = OS.setf(ios::scientific);
1853 std::streamsize prec = OS.precision(15);
1855 Poly::Write(T->Polygon3D(),OS);
1856 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1864 static Handle(Draw_Drawable3D) poly3drestore (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, ostream& OS)
1885 Handle(DrawTrSurf_Polygon2D)
1886 T = Handle(DrawTrSurf_Polygon2D)::DownCast(d);
1887 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1888 ios::fmtflags F = OS.flags();
1889 OS.setf(ios::scientific, ios::floatfield);
1892 long form = OS.setf(ios::scientific);
1893 std::streamsize prec = OS.precision(15);
1895 Poly::Write(T->Polygon2D(),OS);
1896 #if defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)
1904 static Handle(Draw_Drawable3D) poly2drestore (istream& is)
1906 return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is));
1910 static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D",
1911 poly2dtest,poly2dsave,poly2drestore);