0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / DrawTrSurf / DrawTrSurf_Polygon2D.cxx
1 // Created on: 1995-03-14
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
18 #include <Draw_Color.hxx>
19 #include <Draw_Display.hxx>
20 #include <Draw_Drawable3D.hxx>
21 #include <Draw_MarkerShape.hxx>
22 #include <DrawTrSurf_Polygon2D.hxx>
23 #include <Poly.hxx>
24 #include <Poly_Polygon2D.hxx>
25 #include <Standard_Type.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D,Draw_Drawable2D)
28
29 //=======================================================================
30 //function : DrawTrSurf_Polygon2D
31 //purpose  : 
32 //=======================================================================
33 DrawTrSurf_Polygon2D::DrawTrSurf_Polygon2D(const Handle(Poly_Polygon2D)& P):
34    myPolygon2D(P),
35    myNodes(Standard_False)
36 {
37 }
38
39 //=======================================================================
40 //function : Polygon2D
41 //purpose  : 
42 //=======================================================================
43
44 Handle(Poly_Polygon2D) DrawTrSurf_Polygon2D::Polygon2D() const 
45 {
46   return myPolygon2D;
47 }
48
49 //=======================================================================
50 //function : ShowNodes
51 //purpose  : 
52 //=======================================================================
53
54 void DrawTrSurf_Polygon2D::ShowNodes(const Standard_Boolean B)
55 {
56   myNodes = B;
57 }
58
59 //=======================================================================
60 //function : ShowNodes
61 //purpose  : 
62 //=======================================================================
63
64 Standard_Boolean DrawTrSurf_Polygon2D::ShowNodes() const 
65 {
66   return myNodes;
67 }
68
69 //=======================================================================
70 //function : DrawOn
71 //purpose  : 
72 //=======================================================================
73
74 void DrawTrSurf_Polygon2D::DrawOn(Draw_Display& dis) const 
75 {
76   dis.SetColor(Draw_jaune);
77
78   
79   const TColgp_Array1OfPnt2d& Points = myPolygon2D->Nodes();
80
81   for (Standard_Integer i = Points.Lower(); i <= Points.Upper()-1; i++) {
82     dis.Draw(Points(i), Points(i+1));
83   }
84   
85
86   if (myNodes) { 
87     for (Standard_Integer i = Points.Lower(); i <= Points.Upper(); i++) {
88       dis.DrawMarker(Points(i), Draw_X);
89     }
90   }
91
92 }
93
94 //=======================================================================
95 //function : Copy
96 //purpose  : 
97 //=======================================================================
98
99 Handle(Draw_Drawable3D) DrawTrSurf_Polygon2D::Copy() const 
100 {
101   return new DrawTrSurf_Polygon2D(myPolygon2D);
102 }
103
104 //=======================================================================
105 //function : Dump
106 //purpose  : 
107 //=======================================================================
108
109 void DrawTrSurf_Polygon2D::Dump(Standard_OStream& S) const 
110 {
111   Poly::Dump(myPolygon2D, S);
112 }
113
114 //=======================================================================
115 //function : Whatis
116 //purpose  : 
117 //=======================================================================
118
119 void DrawTrSurf_Polygon2D::Whatis(Draw_Interpretor& I) const 
120 {
121   I << "polygon2D";
122 }
123