1 // Created on: 1995-03-10
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <DrawTrSurf_Polygon3D.hxx>
18
19 #include <Draw_Color.hxx>
20 #include <Draw_Display.hxx>
21 #include <Draw_MarkerShape.hxx>
22 #include <Poly.hxx>
23 #include <Poly_Polygon3D.hxx>
24
IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D,Draw_Drawable3D)25 IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
26
27 //=======================================================================
28 //function : DrawTrSurf_Polygon3D
29 //purpose :
30 //=======================================================================
31 DrawTrSurf_Polygon3D::DrawTrSurf_Polygon3D (const Handle(Poly_Polygon3D)& P)
32 : myPolygon3D(P),
33 myNodes(Standard_False)
34 {
35 //
36 }
37
38 //=======================================================================
39 //function : DrawOn
40 //purpose :
41 //=======================================================================
DrawOn(Draw_Display & dis) const42 void DrawTrSurf_Polygon3D::DrawOn(Draw_Display& dis) const
43 {
44 dis.SetColor(Draw_jaune);
45
46 const TColgp_Array1OfPnt& Points = myPolygon3D->Nodes();
47 for (Standard_Integer i = Points.Lower(); i <= Points.Upper()-1; i++)
48 {
49 dis.Draw(Points(i), Points(i+1));
50 }
51
52 if (myNodes)
53 {
54 for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++)
55 {
56 dis.DrawMarker(Points(i), Draw_X);
57 }
58 }
59 }
60
61 //=======================================================================
62 //function : Copy
63 //purpose :
64 //=======================================================================
Handle(Draw_Drawable3D)65 Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Copy() const
66 {
67 return new DrawTrSurf_Polygon3D(myPolygon3D);
68 }
69
70 //=======================================================================
71 //function : Dump
72 //purpose :
73 //=======================================================================
Dump(Standard_OStream & S) const74 void DrawTrSurf_Polygon3D::Dump (Standard_OStream& S) const
75 {
76 Poly::Dump(myPolygon3D, S);
77 }
78
79 //=======================================================================
80 //function : Save
81 //purpose :
82 //=======================================================================
Save(Standard_OStream & theStream) const83 void DrawTrSurf_Polygon3D::Save (Standard_OStream& theStream) const
84 {
85 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
86 std::ios::fmtflags aFlags = theStream.flags();
87 theStream.setf (std::ios::scientific,std::ios::floatfield);
88 theStream.precision (15);
89 #else
90 long aForm = theStream.setf (std::ios::scientific);
91 std::streamsize aPrec = theStream.precision (15);
92 #endif
93 Poly::Write (myPolygon3D, theStream);
94 #if !defined(_MSC_VER) && !defined(__sgi) && !defined(IRIX)
95 theStream.setf (aFlags);
96 #else
97 theStream.setf (aForm);
98 theStream.precision (aPrec);
99 #endif
100 }
101
102 //=======================================================================
103 //function : Restore
104 //purpose :
105 //=======================================================================
Handle(Draw_Drawable3D)106 Handle(Draw_Drawable3D) DrawTrSurf_Polygon3D::Restore (Standard_IStream& theStream)
107 {
108 return new DrawTrSurf_Polygon3D (Poly::ReadPolygon3D (theStream));
109 }
110
111 //=======================================================================
112 //function : Whatis
113 //purpose :
114 //=======================================================================
Whatis(Draw_Interpretor & I) const115 void DrawTrSurf_Polygon3D::Whatis (Draw_Interpretor& I) const
116 {
117 I << "polygon3D";
118 }
119