1 // Created on: 1993-08-12
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Standard_Stream.hxx>
19 #include <Draw_Color.hxx>
20 #include <DrawTrSurf.ixx>
21 #include <DrawTrSurf_Point.hxx>
22 #include <DrawTrSurf_BezierSurface.hxx>
23 #include <DrawTrSurf_BSplineSurface.hxx>
24 #include <DrawTrSurf_BezierCurve.hxx>
25 #include <DrawTrSurf_BSplineCurve.hxx>
26 #include <DrawTrSurf_BezierCurve2d.hxx>
27 #include <DrawTrSurf_BSplineCurve2d.hxx>
28 #include <DrawTrSurf_Triangulation.hxx>
29 #include <DrawTrSurf_Polygon3D.hxx>
30 #include <DrawTrSurf_Polygon2D.hxx>
31 #include <Draw_Appli.hxx>
34 #include <GeomTools_CurveSet.hxx>
35 #include <GeomTools_Curve2dSet.hxx>
36 #include <GeomTools_SurfaceSet.hxx>
39 #include <gp_Ax2d.hxx>
41 #include <gp_Trsf2d.hxx>
43 #include <TCollection_AsciiString.hxx>
45 static Draw_Color PntColor(Draw_rouge);
46 static Draw_Color CurvColor(Draw_jaune);
47 static Draw_Color BoundsColor(Draw_vert);
48 static Draw_Color IsosColor(Draw_bleu);
49 static Draw_Color PolesColor(Draw_rouge);
50 static Draw_Color KnotsColor(Draw_violet);
52 static Draw_MarkerShape PntShape = Draw_Plus;
53 static Draw_MarkerShape KnotsShape = Draw_Losange;
54 static Standard_Boolean ShowPoles = Standard_True;
55 static Standard_Boolean ShowKnots = Standard_True;
56 static Standard_Boolean knotsIsos =Standard_True;
57 static Standard_Real Deflection = 0.01;
58 static Standard_Integer KnotsSize = 5;
59 static Standard_Integer Discret = 30;
60 static Standard_Integer DrawMode = 0;
61 static Standard_Integer NbUIsos = 10;
62 static Standard_Integer NbVIsos = 10;
64 static TCollection_AsciiString ColorsHint(
65 "The possible colors are: \n\
66 white, red, green, blue, cyan,\n\
67 golden, magenta, brown, orange, pink,\n\
68 salmon, violet, yellow, darkgreen, coral");
70 static TCollection_AsciiString MarkersHint(
71 "The possible markers are: \n\
72 square, diamond, x, plus, circle, circle_zoom");
74 //=======================================================================
75 //function : DrawTrSurf_CurveColor
76 //purpose : Sets new color for rendering of curves. Returns the
77 // previous one to keep possibility to restore the initial
79 //=======================================================================
81 Standard_EXPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col)
83 Draw_Color c = CurvColor;
88 //=======================================================================
89 //function : DrawTrSurf_PointColor
90 //purpose : Sets new color for rendering of points. Returns the
91 // previous one to keep possibility to restore the initial
93 //=======================================================================
95 Standard_EXPORT Draw_Color DrawTrSurf_PointColor(const Draw_Color col)
97 Draw_Color c = PntColor;
102 //=======================================================================
103 //function : DrawTrSurf_PointMarker
104 //purpose : Sets new marker for rendering of points. Returns the
105 // previous one to keep possibility to restore the initial
107 //=======================================================================
109 Standard_EXPORT Draw_MarkerShape DrawTrSurf_PointMarker(const Draw_MarkerShape marker)
111 Draw_MarkerShape prev = PntShape;
116 //=======================================================================
117 //function : GetDrawable
119 //=======================================================================
120 static Handle(DrawTrSurf_Drawable) GetDrawable(Standard_CString& Name)
122 Handle(Draw_Drawable3D) D = Draw::Get(Name);
123 Handle(DrawTrSurf_Drawable) Dr;
125 Dr = Handle(DrawTrSurf_Drawable)::DownCast(D);
129 //=======================================================================
130 //function : GetSurface
132 //=======================================================================
133 static Handle(DrawTrSurf_Surface) GetSurface(Standard_CString& Name)
135 Handle(Draw_Drawable3D) D = Draw::Get(Name);
136 Handle(DrawTrSurf_Surface) Dr;
138 Dr = Handle(DrawTrSurf_Surface)::DownCast(D);
142 //=======================================================================
143 //function : GetBezierSurface
145 //=======================================================================
146 static Handle(DrawTrSurf_BezierSurface) GetBezierSurface(Standard_CString& Name)
148 Handle(Draw_Drawable3D) D = Draw::Get(Name);
149 Handle(DrawTrSurf_BezierSurface) Dr;
151 Dr = Handle(DrawTrSurf_BezierSurface)::DownCast(D);
155 //=======================================================================
156 //function : GetBSplineSurface
158 //=======================================================================
159 static Handle(DrawTrSurf_BSplineSurface) GetBSplineSurface(Standard_CString& Name)
161 Handle(Draw_Drawable3D) D = Draw::Get(Name);
162 Handle(DrawTrSurf_BSplineSurface) Dr;
164 Dr = Handle(DrawTrSurf_BSplineSurface)::DownCast(D);
168 //=======================================================================
169 //function : GetBezierCurve
171 //=======================================================================
172 static Handle(DrawTrSurf_BezierCurve) GetBezierCurve(Standard_CString& Name)
174 Handle(Draw_Drawable3D) D = Draw::Get(Name);
175 Handle(DrawTrSurf_BezierCurve) Dr;
177 Dr = Handle(DrawTrSurf_BezierCurve)::DownCast(D);
181 //=======================================================================
182 //function : GetBSplineCurve
184 //=======================================================================
185 static Handle(DrawTrSurf_BSplineCurve) GetBSplineCurve(Standard_CString& Name)
187 Handle(Draw_Drawable3D) D = Draw::Get(Name);
188 Handle(DrawTrSurf_BSplineCurve) Dr;
190 Dr = Handle(DrawTrSurf_BSplineCurve)::DownCast(D);
194 //=======================================================================
195 //function : GetBezierCurve2d
197 //=======================================================================
198 static Handle(DrawTrSurf_BezierCurve2d) GetBezierCurve2d(Standard_CString& Name)
200 Handle(Draw_Drawable3D) D = Draw::Get(Name);
201 Handle(DrawTrSurf_BezierCurve2d) Dr;
203 Dr = Handle(DrawTrSurf_BezierCurve2d)::DownCast(D);
207 //=======================================================================
208 //function : GetBSplineCurve2d
210 //=======================================================================
211 static Handle(DrawTrSurf_BSplineCurve2d) GetBSplineCurve2d(Standard_CString& Name)
213 Handle(Draw_Drawable3D) D = Draw::Get(Name);
214 Handle(DrawTrSurf_BSplineCurve2d) Dr;
216 Dr = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(D);
221 //=======================================================================
224 //=======================================================================
225 static Standard_Integer nbiso (Draw_Interpretor& di, Standard_Integer n, const char** a)
229 NbUIsos = Draw::Atoi(a[1]);
230 NbVIsos = Draw::Atoi(a[2]);
232 di << NbUIsos << " " << NbVIsos;
235 for (Standard_Integer i = 1; i < n - 2; i++) {
236 Handle(DrawTrSurf_Surface) DS = GetSurface(a[i]);
238 DS->ShowIsos(Draw::Atoi(a[n-2]),Draw::Atoi(a[n-1]));
246 //=======================================================================
247 //function : drawpoles
249 //=======================================================================
251 static Standard_Integer drawpoles(Draw_Interpretor&,
256 if ( !strcmp(a[0],"shpoles")) {
257 ShowPoles = Standard_True;
259 else if ( !strcmp(a[0],"clpoles")) {
260 ShowPoles = Standard_False;
262 else if ( !strcmp(a[0],"shknots")) {
263 ShowKnots = Standard_True;
265 else if ( !strcmp(a[0],"clknots")) {
266 ShowKnots = Standard_False;
272 Handle(DrawTrSurf_BezierSurface) BZS;
273 BZS = GetBezierSurface(a[1]);
274 if ( !BZS.IsNull()) {
275 if ( !strcmp(a[0],"shpoles")) {
278 else if ( !strcmp(a[0],"clpoles")) {
286 Handle(DrawTrSurf_BSplineSurface) BSS = GetBSplineSurface(a[1]);
287 if ( !BSS.IsNull()) {
288 if ( !strcmp(a[0],"shpoles")) {
291 else if ( !strcmp(a[0],"clpoles")) {
294 else if ( !strcmp(a[0],"shknots")) {
297 else if ( !strcmp(a[0],"clknots")) {
302 Handle(DrawTrSurf_BezierCurve) BZC = GetBezierCurve(a[1]);
303 if ( !BZC.IsNull()) {
304 if ( !strcmp(a[0],"shpoles")) {
307 else if ( !strcmp(a[0],"clpoles")) {
315 Handle(DrawTrSurf_BSplineCurve) BSC = GetBSplineCurve(a[1]);
316 if ( !BSC.IsNull()) {
317 if ( !strcmp(a[0],"shpoles")) {
320 else if ( !strcmp(a[0],"clpoles")) {
323 else if ( !strcmp(a[0],"shknots")) {
326 else if ( !strcmp(a[0],"clknots")) {
331 Handle(DrawTrSurf_BezierCurve2d) BZ2 = GetBezierCurve2d(a[1]);
332 if ( !BZ2.IsNull()) {
333 if ( !strcmp(a[0],"shpoles")) {
336 else if ( !strcmp(a[0],"clpoles")) {
344 Handle(DrawTrSurf_BSplineCurve2d) BS2 = GetBSplineCurve2d(a[1]);
345 if ( !BS2.IsNull()) {
346 if ( !strcmp(a[0],"shpoles")) {
349 else if ( !strcmp(a[0],"clpoles")) {
352 else if ( !strcmp(a[0],"shknots")) {
355 else if ( !strcmp(a[0],"clknots")) {
371 //=======================================================================
374 //=======================================================================
376 static Standard_Integer draw (Draw_Interpretor& di, Standard_Integer n, const char** a)
379 if (!strcmp(a[0],"dmode")) {
389 else if (!strcmp(a[0],"discr")) {
391 Discret = Draw::Atoi(a[n-1]);
395 else if (!strcmp(a[0],"defle")) {
397 Deflection = Draw::Atof(a[n-1]);
402 for (Standard_Integer i = 1; i < n - 1; i++) {
403 Handle(DrawTrSurf_Drawable) D = GetDrawable(a[1]);
405 if (!strcmp(a[0],"dmode")) {
406 Standard_Integer mod = 0;
407 if ((*a[n-1] == 'U')||(*a[n-1] == 'u')) mod = 1;
411 else if (!strcmp(a[0],"discr")) {
412 D->SetDiscretisation(Draw::Atoi(a[n-1]));
415 else if (!strcmp(a[0],"defle")) {
416 D->SetDeflection(Draw::Atof(a[n-1]));
426 //=======================================================================
427 //function : transform
429 //=======================================================================
431 static Standard_Integer transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
435 Standard_Integer i,last = n-1;
436 if (!strcmp(a[0],"pscale")) {
437 Standard_Real s = Draw::Atof(a[last]);
439 if (last < 4) return 1;
440 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
443 else if (!strcmp(a[0]+1,"mirror")) {
444 if (last < 4) return 1;
445 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
451 if (last < 4) return 1;
452 gp_Pnt O(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
454 gp_Dir D(P.X(),P.Y(),P.Z());
456 T.SetMirror(gp_Ax1(O,D));
458 else if (*a[0] == 's') {
460 T.SetMirror(Pl.Position().Ax2());
465 else if (!strcmp(a[0],"translate")) {
466 if (last < 4) return 1;
467 gp_Vec V(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
472 else if (!strcmp(a[0],"rotate")) {
473 if (last < 8) return 1;
474 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
476 gp_Dir D(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
478 gp_Pnt P(Draw::Atof(a[last-2]),Draw::Atof(a[last-1]),Draw::Atof(a[last]));
480 T.SetRotation(gp_Ax1(P,D),ang);
483 for (i = 1; i <= last; i++) {
484 Handle(Geom_Geometry) G = DrawTrSurf::Get(a[i]);
491 if (DrawTrSurf::GetPoint(a[i],P)) {
493 DrawTrSurf::Set(a[i],P);
501 //=======================================================================
502 //function : d2transform
504 //=======================================================================
506 static Standard_Integer d2transform (Draw_Interpretor& di, Standard_Integer n, const char** a)
510 Standard_Integer i,last = n-1;
511 if (!strcmp(a[0],"2dpscale")) {
512 Standard_Real s = Draw::Atof(a[last]);
514 if (last < 3) return 1;
515 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
518 else if ( (!strcmp(a[0],"2dpmirror")) ||
519 (!strcmp(a[0],"2dlmirror")) ) {
520 if (last < 3) return 1;
521 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
522 if (!strcmp(a[0],"2dpmirror")) {
527 if (last < 3) return 1;
528 gp_Pnt2d O(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
530 gp_Dir2d D(P.X(),P.Y());
531 T.SetMirror(gp_Ax2d(O,D));
535 else if (!strcmp(a[0],"2dtranslate")) {
536 if (last < 3) return 1;
537 gp_Vec2d V(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
542 else if (!strcmp(a[0],"2drotate")) {
543 if (last < 4) return 1;
544 Standard_Real ang = Draw::Atof(a[last]) * (M_PI / 180.0);
546 gp_Pnt2d P(Draw::Atof(a[last-1]),Draw::Atof(a[last]));
548 T.SetRotation(P,ang);
551 for (i = 1; i <= last; i++) {
552 Handle(Geom2d_Curve) G = DrawTrSurf::GetCurve2d(a[i]);
559 if (DrawTrSurf::GetPoint2d(a[i],P)) {
561 DrawTrSurf::Set(a[i],P);
569 //=======================================================================
572 //=======================================================================
573 void DrawTrSurf::Set(const Standard_CString Name,
576 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
580 //=======================================================================
583 //=======================================================================
584 void DrawTrSurf::Set(const Standard_CString Name,
587 Handle(DrawTrSurf_Point) DP = new DrawTrSurf_Point(P,PntShape,PntColor);
591 //=======================================================================
593 //purpose : Geometry from Geom
594 //=======================================================================
595 void DrawTrSurf::Set(const Standard_CString Name,
596 const Handle(Geom_Geometry)& G,
597 const Standard_Boolean isSenseMarker)
599 Handle(DrawTrSurf_Drawable) D;
602 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(G);
605 Handle(Geom_BezierCurve) Bez =
606 Handle(Geom_BezierCurve)::DownCast(C);
608 Handle(DrawTrSurf_BezierCurve) DBez =
609 new DrawTrSurf_BezierCurve(Bez,CurvColor,PolesColor,ShowPoles,
610 Discret,Deflection,DrawMode);
615 Handle(Geom_BSplineCurve) BS =
616 Handle(Geom_BSplineCurve)::DownCast(C);
618 Handle(DrawTrSurf_BSplineCurve) DBS =
619 new DrawTrSurf_BSplineCurve(BS,
620 CurvColor,PolesColor,
622 KnotsShape,KnotsSize,
624 Discret,Deflection,DrawMode);
628 if (Bez.IsNull() && BS.IsNull()) {
629 Handle(DrawTrSurf_Curve) DC =
630 new DrawTrSurf_Curve(C,CurvColor,Discret,Deflection,DrawMode,isSenseMarker);
636 Handle(Geom_Surface) S = Handle(Geom_Surface)::DownCast(G);
639 Handle(Geom_BezierSurface) Bez =
640 Handle(Geom_BezierSurface)::DownCast(S);
642 Handle(DrawTrSurf_BezierSurface) DBez =
643 new DrawTrSurf_BezierSurface(Bez,NbUIsos,NbVIsos,
644 BoundsColor,IsosColor,PolesColor,
646 Discret,Deflection,DrawMode);
651 Handle(Geom_BSplineSurface) BS =
652 Handle(Geom_BSplineSurface)::DownCast(S);
654 Handle(DrawTrSurf_BSplineSurface) DBS ;
656 DBS = new DrawTrSurf_BSplineSurface(BS,
658 BoundsColor,IsosColor,
659 PolesColor,KnotsColor,
660 KnotsShape,KnotsSize,
662 Discret,Deflection,DrawMode);
664 DBS = new DrawTrSurf_BSplineSurface(BS,
665 BoundsColor,IsosColor,
666 PolesColor,KnotsColor,
667 KnotsShape,KnotsSize,
669 Discret,Deflection,DrawMode);
674 if (Bez.IsNull() && BS.IsNull()) {
675 Handle(DrawTrSurf_Surface) DS =
676 new DrawTrSurf_Surface(S,
678 BoundsColor,IsosColor,
679 Discret,Deflection,DrawMode);
689 //=======================================================================
691 //purpose : Curve from Geom2d
692 //=======================================================================
693 void DrawTrSurf::Set(const Standard_CString Name,
694 const Handle(Geom2d_Curve)& C,
695 const Standard_Boolean isSenseMarker)
697 Handle(DrawTrSurf_Drawable) D;
700 Handle(Geom2d_BezierCurve) Bez =
701 Handle(Geom2d_BezierCurve)::DownCast(C);
703 Handle(DrawTrSurf_BezierCurve2d) DBez =
704 new DrawTrSurf_BezierCurve2d(Bez,CurvColor,PolesColor,ShowPoles,
710 Handle(Geom2d_BSplineCurve) BS =
711 Handle(Geom2d_BSplineCurve)::DownCast(C);
713 Handle(DrawTrSurf_BSplineCurve2d) DBS =
714 new DrawTrSurf_BSplineCurve2d(BS,
715 CurvColor,PolesColor,
717 KnotsShape,KnotsSize,
723 if (Bez.IsNull() && BS.IsNull()) {
724 Handle(DrawTrSurf_Curve2d) DC =
725 new DrawTrSurf_Curve2d(C,CurvColor,Discret,isSenseMarker);
733 //=======================================================================
736 //=======================================================================
737 void DrawTrSurf::Set(const Standard_CString Name,
738 const Handle(Poly_Triangulation)& T)
740 Handle(DrawTrSurf_Triangulation) D = new DrawTrSurf_Triangulation(T);
743 //=======================================================================
746 //=======================================================================
747 void DrawTrSurf::Set(const Standard_CString Name,
748 const Handle(Poly_Polygon3D)& P)
750 Handle(DrawTrSurf_Polygon3D) D = new DrawTrSurf_Polygon3D(P);
754 //=======================================================================
757 //=======================================================================
758 void DrawTrSurf::Set(const Standard_CString Name,
759 const Handle(Poly_Polygon2D)& P)
761 Handle(DrawTrSurf_Polygon2D) D = new DrawTrSurf_Polygon2D(P);
765 //=======================================================================
768 //=======================================================================
769 Handle(Geom_Geometry) DrawTrSurf::Get(Standard_CString& Name)
771 Handle(Draw_Drawable3D) D = Draw::Get(Name);
773 Handle(DrawTrSurf_Curve) DC =
774 Handle(DrawTrSurf_Curve)::DownCast(D);
776 return DC->GetCurve();
778 Handle(DrawTrSurf_Surface) DS =
779 Handle(DrawTrSurf_Surface)::DownCast(D);
781 return DS->GetSurface();
783 return Handle(Geom_Geometry) ();
787 //=======================================================================
788 //function : GetPoint
790 //=======================================================================
791 Standard_Boolean DrawTrSurf::GetPoint(Standard_CString& Name,
794 Handle(DrawTrSurf_Point) D =
795 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
797 return Standard_False;
799 return Standard_False;
802 return Standard_True;
806 //=======================================================================
807 //function : GetPoint2d
809 //=======================================================================
810 Standard_Boolean DrawTrSurf::GetPoint2d(Standard_CString& Name,
813 Handle(DrawTrSurf_Point) D =
814 Handle(DrawTrSurf_Point)::DownCast(Draw::Get(Name));
816 return Standard_False;
818 return Standard_False;
821 return Standard_True;
825 //=======================================================================
826 //function : GetCurve
828 //=======================================================================
829 Handle(Geom_Curve) DrawTrSurf::GetCurve(Standard_CString& Name)
831 Handle(DrawTrSurf_Curve) D =
832 Handle(DrawTrSurf_Curve)::DownCast(Draw::Get(Name));
834 return Handle(Geom_Curve)();
836 return D->GetCurve();
840 //=======================================================================
841 //function : GetBezierCurve
843 //=======================================================================
844 Handle(Geom_BezierCurve) DrawTrSurf::GetBezierCurve(Standard_CString& Name)
846 Handle(DrawTrSurf_BezierCurve) D =
847 Handle(DrawTrSurf_BezierCurve)::DownCast(Draw::Get(Name));
849 return Handle(Geom_BezierCurve)();
851 return Handle(Geom_BezierCurve)::DownCast(D->GetCurve());
855 //=======================================================================
856 //function : GetBSplineCurve
858 //=======================================================================
859 Handle(Geom_BSplineCurve) DrawTrSurf::GetBSplineCurve(Standard_CString& Name)
861 Handle(DrawTrSurf_BSplineCurve) D =
862 Handle(DrawTrSurf_BSplineCurve)::DownCast(Draw::Get(Name));
864 return Handle(Geom_BSplineCurve)();
866 return Handle(Geom_BSplineCurve)::DownCast(D->GetCurve());
868 //=======================================================================
869 //function : GetCurve2d
871 //=======================================================================
872 Handle(Geom2d_Curve) DrawTrSurf::GetCurve2d(Standard_CString& Name)
874 Handle(DrawTrSurf_Curve2d) D =
875 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
877 return Handle(Geom2d_Curve)();
879 return D->GetCurve();
881 //=======================================================================
882 //function : GetBezierCurve2d
884 //=======================================================================
885 Handle(Geom2d_BezierCurve) DrawTrSurf::GetBezierCurve2d(Standard_CString& Name)
887 Handle(DrawTrSurf_Curve2d) D =
888 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
890 return Handle(Geom2d_BezierCurve)();
892 return Handle(Geom2d_BezierCurve)::DownCast(D->GetCurve());
894 //=======================================================================
895 //function : GetBSplineCurve2d
897 //=======================================================================
898 Handle(Geom2d_BSplineCurve) DrawTrSurf::GetBSplineCurve2d
899 (Standard_CString& Name)
901 Handle(DrawTrSurf_Curve2d) D =
902 Handle(DrawTrSurf_Curve2d)::DownCast(Draw::Get(Name));
904 return Handle(Geom2d_BSplineCurve)();
906 return Handle(Geom2d_BSplineCurve)::DownCast(D->GetCurve());
908 //=======================================================================
909 //function : GetSurface
911 //=======================================================================
912 Handle(Geom_Surface) DrawTrSurf::GetSurface
913 (Standard_CString& Name)
915 Handle(DrawTrSurf_Surface) D =
916 Handle(DrawTrSurf_Surface)::DownCast(Draw::Get(Name));
918 return Handle(Geom_Surface)();
920 return D->GetSurface();
922 //=======================================================================
923 //function : GetBezierSurface
925 //=======================================================================
926 Handle(Geom_BezierSurface) DrawTrSurf::GetBezierSurface
927 (Standard_CString& Name)
929 Handle(DrawTrSurf_BezierSurface) D =
930 Handle(DrawTrSurf_BezierSurface)::DownCast(Draw::Get(Name));
932 return Handle(Geom_BezierSurface)();
934 return Handle(Geom_BezierSurface)::DownCast(D->GetSurface());
936 //=======================================================================
937 //function : GetBSplineSurface
939 //=======================================================================
940 Handle(Geom_BSplineSurface) DrawTrSurf::GetBSplineSurface
941 (Standard_CString& Name)
943 Handle(DrawTrSurf_BSplineSurface) D =
944 Handle(DrawTrSurf_BSplineSurface)::DownCast(Draw::Get(Name));
946 return Handle(Geom_BSplineSurface)();
948 return Handle(Geom_BSplineSurface)::DownCast(D->GetSurface());
950 //=======================================================================
951 //function : GetTriangulation
953 //=======================================================================
954 Handle(Poly_Triangulation) DrawTrSurf::GetTriangulation(Standard_CString& Name)
956 Handle(DrawTrSurf_Triangulation) D =
957 Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(Name));
959 return Handle(Poly_Triangulation)();
961 return D->Triangulation();
963 //=======================================================================
964 //function : GetPolygon3D
966 //=======================================================================
967 Handle(Poly_Polygon3D) DrawTrSurf::GetPolygon3D(Standard_CString& Name)
969 Handle(DrawTrSurf_Polygon3D) D =
970 Handle(DrawTrSurf_Polygon3D)::DownCast(Draw::Get(Name));
972 return Handle(Poly_Polygon3D)();
974 return D->Polygon3D();
976 //=======================================================================
977 //function : GetPolygon2D
979 //=======================================================================
980 Handle(Poly_Polygon2D) DrawTrSurf::GetPolygon2D(Standard_CString& Name)
982 Handle(DrawTrSurf_Polygon2D) D =
983 Handle(DrawTrSurf_Polygon2D)::DownCast(Draw::Get(Name));
985 return Handle(Poly_Polygon2D)();
987 return D->Polygon2D();
990 //=======================================================================
991 //function : printColor
993 //=======================================================================
995 static void printColor(Draw_Interpretor& di, const Draw_Color& theColor)
997 switch ( theColor.ID() )
999 case Draw_blanc: di << "white " << "\n"; break;
1000 case Draw_rouge: di << "red " << "\n"; break;
1001 case Draw_vert: di << "green " << "\n"; break;
1002 case Draw_bleu: di << "blue " << "\n"; break;
1003 case Draw_cyan: di << "cyan " << "\n"; break;
1004 case Draw_or: di << "golden " << "\n"; break;
1005 case Draw_magenta: di << "magenta " << "\n"; break;
1006 case Draw_marron: di << "brown " << "\n"; break;
1007 case Draw_orange: di << "orange " << "\n"; break;
1008 case Draw_rose: di << "pink " << "\n"; break;
1009 case Draw_saumon: di << "salmon " << "\n"; break;
1010 case Draw_violet: di << "violet " << "\n"; break;
1011 case Draw_jaune: di << "yellow " << "\n"; break;
1012 case Draw_kaki: di << "dark-olive green " << "\n"; break;
1013 case Draw_corail: di << "coral " << "\n"; break;
1017 //=======================================================================
1018 //function : recognizeColor
1020 //=======================================================================
1022 static Draw_Color recognizeColor(const char* theColorStr,
1023 const Draw_Color& theDefaultColor)
1025 Draw_Color aResult = theDefaultColor;
1027 if ( !strcasecmp(theColorStr,"white") )
1028 aResult = Draw_blanc;
1029 if ( !strcasecmp(theColorStr, "red") )
1030 aResult = Draw_rouge;
1031 if ( !strcasecmp(theColorStr, "green") )
1032 aResult = Draw_vert;
1033 if ( !strcasecmp(theColorStr, "blue") )
1034 aResult = Draw_bleu;
1035 if ( !strcasecmp(theColorStr, "cyan") )
1036 aResult = Draw_cyan;
1037 if ( !strcasecmp(theColorStr, "golden") )
1039 if ( !strcasecmp(theColorStr, "magenta") )
1040 aResult = Draw_magenta;
1041 if ( !strcasecmp(theColorStr, "brown") )
1042 aResult = Draw_marron;
1043 if ( !strcasecmp(theColorStr, "orange") )
1044 aResult = Draw_orange;
1045 if ( !strcasecmp(theColorStr, "pink") )
1046 aResult = Draw_rose;
1047 if ( !strcasecmp(theColorStr, "salmon") )
1048 aResult = Draw_saumon;
1049 if ( !strcasecmp(theColorStr, "violet") )
1050 aResult = Draw_violet;
1051 if ( !strcasecmp(theColorStr, "yellow") )
1052 aResult = Draw_jaune;
1053 if ( !strcasecmp(theColorStr, "darkgreen") )
1054 aResult = Draw_kaki;
1055 if ( !strcasecmp(theColorStr, "coral") )
1056 aResult = Draw_corail;
1061 //=======================================================================
1062 //function : setcurvcolor
1064 //=======================================================================
1066 static Standard_Integer setcurvcolor(Draw_Interpretor& di,
1067 Standard_Integer n, const char** a)
1069 Draw_Color col, savecol;
1071 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1072 DrawTrSurf_CurveColor(savecol);
1076 printColor(di, savecol);
1079 col = recognizeColor(a[1], savecol);
1080 DrawTrSurf_CurveColor(col);
1085 //=======================================================================
1086 //function : changecurvcolor
1088 //=======================================================================
1090 static Standard_Integer changecurvcolor(Draw_Interpretor&,
1091 Standard_Integer n, const char** a)
1093 Draw_Color col, savecol;
1095 savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_jaune));
1096 DrawTrSurf_CurveColor(savecol);
1101 col = recognizeColor(a[1], savecol);
1103 Handle(DrawTrSurf_Curve) D = Handle(DrawTrSurf_Curve)::DownCast( Draw::Get(a[2]) );
1113 //=======================================================================
1114 //function : setpointcolor
1116 //=======================================================================
1118 static Standard_Integer setpointcolor(Draw_Interpretor& di,
1119 Standard_Integer n, const char** a)
1121 Draw_Color col, savecol;
1123 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1124 DrawTrSurf_PointColor(savecol);
1128 printColor(di, savecol);
1131 col = recognizeColor(a[1], savecol);
1132 DrawTrSurf_PointColor(col);
1137 //=======================================================================
1138 //function : changepointcolor
1140 //=======================================================================
1142 static Standard_Integer changepointcolor(Draw_Interpretor&,
1143 Standard_Integer n, const char** a)
1145 Draw_Color col, savecol;
1147 savecol = DrawTrSurf_PointColor(Draw_Color(Draw_jaune));
1148 DrawTrSurf_PointColor(savecol);
1153 col = recognizeColor(a[1], savecol);
1155 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1165 //=======================================================================
1166 //function : printMarker
1168 //=======================================================================
1170 static void printMarker(Draw_Interpretor& di, const Draw_MarkerShape& theMarker)
1172 switch ( theMarker )
1174 case Draw_Square: di << "square " << "\n"; break;
1175 case Draw_Losange: di << "diamond " << "\n"; break;
1176 case Draw_X: di << "x " << "\n"; break;
1177 case Draw_Plus: di << "plus " << "\n"; break;
1178 case Draw_Circle: di << "circle " << "\n"; break;
1179 case Draw_CircleZoom: di << "circle_zoom " << "\n"; break;
1183 //=======================================================================
1184 //function : recognizeMarker
1186 //=======================================================================
1188 static Draw_MarkerShape recognizeMarker(const char* theMarkerStr,
1189 const Draw_MarkerShape& theDefaultMarker)
1191 Draw_MarkerShape aResult = theDefaultMarker;
1193 if ( !strcasecmp(theMarkerStr, "square") )
1194 aResult = Draw_Square;
1195 if ( !strcasecmp(theMarkerStr, "diamond") )
1196 aResult = Draw_Losange;
1197 if ( !strcasecmp(theMarkerStr, "x") )
1199 if ( !strcasecmp(theMarkerStr, "plus") )
1200 aResult = Draw_Plus;
1201 if ( !strcasecmp(theMarkerStr, "circle") )
1202 aResult = Draw_Circle;
1203 if ( !strcasecmp(theMarkerStr, "circle_zoom") )
1204 aResult = Draw_CircleZoom;
1209 //=======================================================================
1210 //function : setpointmarker
1212 //=======================================================================
1214 static Standard_Integer setpointmarker(Draw_Interpretor& di,
1215 Standard_Integer n, const char** a)
1217 Draw_MarkerShape mark, savemark;
1219 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1220 DrawTrSurf_PointMarker(savemark);
1224 printMarker(di, savemark);
1227 mark = recognizeMarker(a[1], savemark);
1228 DrawTrSurf_PointMarker(mark);
1233 //=======================================================================
1234 //function : changepointmarker
1236 //=======================================================================
1238 static Standard_Integer changepointmarker(Draw_Interpretor&,
1239 Standard_Integer n, const char** a)
1241 Draw_MarkerShape mark, savemark;
1243 savemark = DrawTrSurf_PointMarker(Draw_MarkerShape(Draw_Plus));
1244 DrawTrSurf_PointMarker(savemark);
1249 mark = recognizeMarker(a[1], savemark);
1251 Handle(DrawTrSurf_Point) D = Handle(DrawTrSurf_Point)::DownCast( Draw::Get(a[2]) );
1261 //=======================================================================
1262 //function : BasicCommands
1264 //=======================================================================
1266 static Standard_Boolean done = Standard_False;
1267 void DrawTrSurf::BasicCommands(Draw_Interpretor& theCommands)
1270 done = Standard_True;
1273 g = "geometric display commands";
1275 theCommands.Add("nbiso",
1276 "nbiso name [names...] nuiso nviso",
1280 theCommands.Add("clpoles",
1281 "clpoles [name], no args : modal ",
1285 theCommands.Add("shpoles",
1286 "shpoles [name], no args : modal ",
1290 theCommands.Add("clknots",
1291 "clknots [name], no args : modal ",
1295 theCommands.Add("shknots",
1296 "shknots [name], no args : modal ",
1300 theCommands.Add("dmode",
1301 "dmode [names...] Uniform/Discret",
1305 theCommands.Add("discr",
1306 "discr [names...] nbintervals",
1310 theCommands.Add("defle",
1311 "defle [names...] defle",
1315 theCommands.Add("setcurvcolor",
1316 TCollection_AsciiString("setcurvcolor [color] : set curve color\
1317 by default, or print the current curve color if no argument (this does not modify\
1318 the color of the curve)\n\n").Cat(ColorsHint).ToCString(),
1319 __FILE__,setcurvcolor,g);
1321 theCommands.Add("changecurvcolor",
1322 TCollection_AsciiString("changecurvcolor color curve: change\
1323 color of the curve\n\n").Cat(ColorsHint).ToCString(),
1324 __FILE__,changecurvcolor,g);
1326 theCommands.Add("setpointcolor",
1327 TCollection_AsciiString("setpointcolor [color] : set point color\
1328 by default, or print the current point color if no argument (this does not modify\
1329 the color of the point)\n\n").Cat(ColorsHint).ToCString(),
1330 __FILE__,setpointcolor,g);
1332 theCommands.Add("changepointcolor",
1333 TCollection_AsciiString("changepointcolor color point: change\
1334 color of the point\n\n").Cat(ColorsHint).ToCString(),
1335 __FILE__,changepointcolor,g);
1337 theCommands.Add("setpointmarker",
1338 TCollection_AsciiString("setpointmarker [marker] : set point marker\
1339 by default, or print the current point marker if no argument (this does not modify\
1340 the marker of the point)\n\n").Cat(MarkersHint).ToCString(),
1341 __FILE__,setpointmarker,g);
1343 theCommands.Add("changepointmarker",
1344 TCollection_AsciiString("changepointmarker marker point: change\
1345 marker of the point\n\n").Cat(MarkersHint).ToCString(),
1346 __FILE__,changepointmarker,g);
1348 g = "Geometric tranformations";
1350 theCommands.Add("translate",
1351 "translate name [names...] dx dy dz",
1355 theCommands.Add("rotate",
1356 "rotate name [names...] x y z dx dy dz angle",
1360 theCommands.Add("pmirror",
1361 "pmirror name [names...] x y z",
1365 theCommands.Add("lmirror",
1366 "lmirror name [names...] x y z dx dy dz",
1370 theCommands.Add("smirror",
1371 "smirror name [names...] x y z dx dy dz",
1375 theCommands.Add("pscale",
1376 "pscale name [names...] x y z s",
1380 theCommands.Add("2dtranslate",
1381 "translate name [names...] dx dy",
1385 theCommands.Add("2drotate",
1386 "rotate name [names...] x y dx dy angle",
1390 theCommands.Add("2dpmirror",
1391 "pmirror name [names...] x y",
1395 theCommands.Add("2dlmirror",
1396 "lmirror name [names...] x y dx dy",
1400 theCommands.Add("2dpscale",
1401 "pscale name [names...] x y s",
1407 //=================================================================
1408 // save and restore curves
1409 //=================================================================
1411 static Standard_Boolean ctest(const Handle(Draw_Drawable3D)& d)
1413 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve));
1416 static void csave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1418 Handle(DrawTrSurf_Curve) N = Handle(DrawTrSurf_Curve)::DownCast(d);
1419 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1422 static Handle(Draw_Drawable3D) crestore (istream& is)
1424 Handle(Geom_Curve) G;
1425 GeomTools_CurveSet::ReadCurve(is,G);
1426 Handle(DrawTrSurf_Curve) N =
1427 new DrawTrSurf_Curve(G,CurvColor,Discret,Deflection,DrawMode);
1432 static Draw_SaveAndRestore csr("DrawTrSurf_Curve",
1433 ctest,csave,crestore);
1438 //=================================================================
1439 // save and restore bezier curves
1440 //=================================================================
1442 static Standard_Boolean bzctest(const Handle(Draw_Drawable3D)& d)
1444 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve));
1447 static void bzcsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1449 Handle(DrawTrSurf_BezierCurve)
1450 N = Handle(DrawTrSurf_BezierCurve)::DownCast(d);
1451 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1454 static Handle(Draw_Drawable3D) bzcrestore (istream& is)
1456 Handle(Geom_BezierCurve) G;
1457 GeomTools_CurveSet::ReadCurve(is,G);
1458 Handle(DrawTrSurf_BezierCurve) N =
1459 new DrawTrSurf_BezierCurve(G,CurvColor,PolesColor,ShowPoles,
1460 Discret,Deflection,DrawMode);
1465 static Draw_SaveAndRestore bzcsr("DrawTrSurf_BezierCurve",
1466 bzctest,bzcsave,bzcrestore);
1471 //=================================================================
1472 // save and restore bspline curves
1473 //=================================================================
1475 static Standard_Boolean bsctest(const Handle(Draw_Drawable3D)& d)
1477 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve));
1480 static void bscsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1482 Handle(DrawTrSurf_BSplineCurve)
1483 N = Handle(DrawTrSurf_BSplineCurve)::DownCast(d);
1484 GeomTools_CurveSet::PrintCurve(N->GetCurve(),OS,Standard_True);
1487 static Handle(Draw_Drawable3D) bscrestore (istream& is)
1489 Handle(Geom_BSplineCurve) G;
1490 GeomTools_CurveSet::ReadCurve(is,G);
1491 Handle(DrawTrSurf_BSplineCurve) N =
1492 new DrawTrSurf_BSplineCurve(G, CurvColor,PolesColor,
1494 KnotsShape,KnotsSize,
1495 ShowPoles,ShowKnots,
1496 Discret,Deflection,DrawMode);
1501 static Draw_SaveAndRestore bscsr("DrawTrSurf_BSplineCurve",
1502 bsctest,bscsave,bscrestore);
1505 //=================================================================
1506 // save and restore curves 2d
1507 //=================================================================
1509 static Standard_Boolean c2dtest(const Handle(Draw_Drawable3D)& d)
1511 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Curve2d));
1514 static void c2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1516 Handle(DrawTrSurf_Curve2d) N = Handle(DrawTrSurf_Curve2d)::DownCast(d);
1517 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1520 static Handle(Draw_Drawable3D) c2drestore (istream& is)
1522 Handle(Geom2d_Curve) G;
1523 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1524 Handle(DrawTrSurf_Curve2d) N =
1525 new DrawTrSurf_Curve2d(G,CurvColor,Discret);
1530 static Draw_SaveAndRestore c2dsr("DrawTrSurf_Curve2d",
1531 c2dtest,c2dsave,c2drestore);
1536 //=================================================================
1537 // save and restore bezier curves 2d
1538 //=================================================================
1540 static Standard_Boolean bzc2dtest(const Handle(Draw_Drawable3D)& d)
1542 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierCurve2d));
1545 static void bzc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1547 Handle(DrawTrSurf_BezierCurve2d)
1548 N = Handle(DrawTrSurf_BezierCurve2d)::DownCast(d);
1549 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1552 static Handle(Draw_Drawable3D) bzc2drestore (istream& is)
1554 Handle(Geom2d_BezierCurve) G;
1555 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1556 Handle(DrawTrSurf_BezierCurve2d) N =
1557 new DrawTrSurf_BezierCurve2d(G,CurvColor,PolesColor,ShowPoles,
1563 static Draw_SaveAndRestore bzc2dsr("DrawTrSurf_BezierCurve2d",
1564 bzc2dtest,bzc2dsave,bzc2drestore);
1569 //=================================================================
1570 // save and restore bspline curves 2d
1571 //=================================================================
1573 static Standard_Boolean bsc2dtest(const Handle(Draw_Drawable3D)& d)
1575 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineCurve2d));
1578 static void bsc2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1580 Handle(DrawTrSurf_BSplineCurve2d)
1581 N = Handle(DrawTrSurf_BSplineCurve2d)::DownCast(d);
1582 GeomTools_Curve2dSet::PrintCurve2d(N->GetCurve(),OS,Standard_True);
1585 static Handle(Draw_Drawable3D) bsc2drestore (istream& is)
1587 Handle(Geom2d_BSplineCurve) G;
1588 GeomTools_Curve2dSet::ReadCurve2d(is,G);
1589 Handle(DrawTrSurf_BSplineCurve2d) N =
1590 new DrawTrSurf_BSplineCurve2d(G, CurvColor,PolesColor,
1592 KnotsShape,KnotsSize,
1593 ShowPoles,ShowKnots,
1599 static Draw_SaveAndRestore bsc2dsr("DrawTrSurf_BSplineCurve2d",
1600 bsc2dtest,bsc2dsave,bsc2drestore);
1603 //=================================================================
1604 // save and restore surfaces
1605 //=================================================================
1607 static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d)
1609 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Surface));
1612 static void ssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1614 Handle(DrawTrSurf_Surface) N = Handle(DrawTrSurf_Surface)::DownCast(d);
1615 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1618 static Handle(Draw_Drawable3D) srestore (istream& is)
1620 Handle(Geom_Surface) G;
1621 GeomTools_SurfaceSet::ReadSurface(is,G);
1622 Handle(DrawTrSurf_Surface) N =
1623 new DrawTrSurf_Surface(G,
1625 BoundsColor,IsosColor,
1626 Discret,Deflection,DrawMode);
1631 static Draw_SaveAndRestore ssr("DrawTrSurf_Surface",
1632 stest,ssave,srestore);
1637 //=================================================================
1638 // save and restore bezier surfaces
1639 //=================================================================
1641 static Standard_Boolean bzstest(const Handle(Draw_Drawable3D)& d)
1643 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BezierSurface));
1646 static void bzssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1648 Handle(DrawTrSurf_BezierSurface)
1649 N = Handle(DrawTrSurf_BezierSurface)::DownCast(d);
1650 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1653 static Handle(Draw_Drawable3D) bzsrestore (istream& is)
1655 Handle(Geom_BezierSurface) G;
1656 GeomTools_SurfaceSet::ReadSurface(is,G);
1657 Handle(DrawTrSurf_BezierSurface) N =
1658 new DrawTrSurf_BezierSurface(G,NbUIsos,NbVIsos,
1659 BoundsColor,IsosColor,PolesColor,
1661 Discret,Deflection,DrawMode);
1666 static Draw_SaveAndRestore bzssr("DrawTrSurf_BezierSurface",
1667 bzstest,bzssave,bzsrestore);
1672 //=================================================================
1673 // save and restore bspline surfaces
1674 //=================================================================
1676 static Standard_Boolean bsstest(const Handle(Draw_Drawable3D)& d)
1678 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_BSplineSurface));
1681 static void bsssave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1683 Handle(DrawTrSurf_BSplineSurface)
1684 N = Handle(DrawTrSurf_BSplineSurface)::DownCast(d);
1685 GeomTools_SurfaceSet::PrintSurface(N->GetSurface(),OS,Standard_True);
1688 static Handle(Draw_Drawable3D) bssrestore (istream& is)
1690 Handle(Geom_BSplineSurface) G;
1691 GeomTools_SurfaceSet::ReadSurface(is,G);
1692 Handle(DrawTrSurf_BSplineSurface) N;
1694 N = new DrawTrSurf_BSplineSurface(G,
1696 BoundsColor,IsosColor,
1697 PolesColor,KnotsColor,
1698 KnotsShape,KnotsSize,
1699 ShowPoles,ShowKnots,
1700 Discret,Deflection,DrawMode);
1702 N = new DrawTrSurf_BSplineSurface(G,
1703 BoundsColor,IsosColor,
1704 PolesColor,KnotsColor,
1705 KnotsShape,KnotsSize,
1706 ShowPoles,ShowKnots,
1707 Discret,Deflection,DrawMode);
1713 static Draw_SaveAndRestore bsssr("DrawTrSurf_BSplineSurface",
1714 bsstest,bsssave,bssrestore);
1717 //=================================================================
1718 // save and restore points
1719 //=================================================================
1721 static Standard_Boolean pnttest(const Handle(Draw_Drawable3D)& d)
1723 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Point));
1726 static void pntsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1728 Handle(DrawTrSurf_Point)
1729 N = Handle(DrawTrSurf_Point)::DownCast(d);
1730 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1731 ios::fmtflags F = OS.flags();
1732 OS.setf(ios::scientific,ios::floatfield);
1735 long form = OS.setf(ios::scientific);
1736 std::streamsize prec = OS.precision(15);
1738 gp_Pnt P = N->Point();
1741 OS << P.X() << " " << P.Y() << " " << P.Z() << "\n";
1745 OS << P.X() << " " << P.Y() << "\n";
1747 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1755 static Handle(Draw_Drawable3D) pntrestore (istream& is)
1757 Standard_Integer is3d;
1759 Standard_Real x,y,z = 0.;
1764 Handle(DrawTrSurf_Point) N;
1766 N = new DrawTrSurf_Point(gp_Pnt(x,y,z),PntShape,PntColor);
1768 N = new DrawTrSurf_Point(gp_Pnt2d(x,y),PntShape,PntColor);
1774 static Draw_SaveAndRestore pntsr("DrawTrSurf_Point",
1775 pnttest,pntsave,pntrestore);
1779 //=================================================================
1780 // save and restore triangulation
1781 //=================================================================
1783 static Standard_Boolean triatest(const Handle(Draw_Drawable3D)& d)
1785 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Triangulation));
1788 static void triasave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1790 Handle(DrawTrSurf_Triangulation)
1791 T = Handle(DrawTrSurf_Triangulation)::DownCast(d);
1792 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1793 ios::fmtflags F = OS.flags();
1794 OS.setf(ios::scientific,ios::floatfield);
1797 long form = OS.setf(ios::scientific);
1798 std::streamsize prec = OS.precision(15);
1800 Poly::Write(T->Triangulation(),OS);
1801 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1809 static Handle(Draw_Drawable3D) triarestore (istream& is)
1811 return new DrawTrSurf_Triangulation(Poly::ReadTriangulation(is));
1815 static Draw_SaveAndRestore triasr("DrawTrSurf_Triangulation",
1816 triatest,triasave,triarestore);
1820 //=================================================================
1821 // save and restore polygon3d
1822 //=================================================================
1824 static Standard_Boolean poly3dtest(const Handle(Draw_Drawable3D)& d)
1826 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon3D));
1829 static void poly3dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1831 Handle(DrawTrSurf_Polygon3D)
1832 T = Handle(DrawTrSurf_Polygon3D)::DownCast(d);
1833 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1834 ios::fmtflags F = OS.flags();
1835 OS.setf(ios::scientific,ios::floatfield);
1838 long form = OS.setf(ios::scientific);
1839 std::streamsize prec = OS.precision(15);
1841 Poly::Write(T->Polygon3D(),OS);
1842 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1850 static Handle(Draw_Drawable3D) poly3drestore (istream& is)
1852 return new DrawTrSurf_Polygon3D(Poly::ReadPolygon3D(is));
1856 static Draw_SaveAndRestore poly3dsr("DrawTrSurf_Polygon3D",
1857 poly3dtest,poly3dsave,poly3drestore);
1860 //=================================================================
1861 // save and restore polygon2d
1862 //=================================================================
1864 static Standard_Boolean poly2dtest(const Handle(Draw_Drawable3D)& d)
1866 return d->IsInstance(STANDARD_TYPE(DrawTrSurf_Polygon2D));
1869 static void poly2dsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
1871 Handle(DrawTrSurf_Polygon2D)
1872 T = Handle(DrawTrSurf_Polygon2D)::DownCast(d);
1873 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1874 ios::fmtflags F = OS.flags();
1875 OS.setf(ios::scientific, ios::floatfield);
1878 long form = OS.setf(ios::scientific);
1879 std::streamsize prec = OS.precision(15);
1881 Poly::Write(T->Polygon2D(),OS);
1882 #if !defined(_WIN32) && !defined(__sgi) && !defined(IRIX)
1890 static Handle(Draw_Drawable3D) poly2drestore (istream& is)
1892 return new DrawTrSurf_Polygon2D(Poly::ReadPolygon2D(is));
1896 static Draw_SaveAndRestore poly2dsr("DrawTrSurf_Polygon2D",
1897 poly2dtest,poly2dsave,poly2drestore);