b311480e |
1 | // Created on: 2007-08-01 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #ifndef VrmlData_IndexedLineSet_HeaderFile |
17 | #define VrmlData_IndexedLineSet_HeaderFile |
18 | |
19 | #include <VrmlData_Geometry.hxx> |
20 | #include <VrmlData_Coordinate.hxx> |
21 | #include <VrmlData_Color.hxx> |
22 | //#include <Quantity_Color.hxx> |
23 | |
24 | /** |
25 | * Data type to store a set of polygons. |
26 | */ |
27 | |
28 | class VrmlData_IndexedLineSet : public VrmlData_Geometry |
29 | { |
30 | public: |
31 | // ---------- PUBLIC METHODS ---------- |
32 | |
33 | |
34 | /** |
35 | * Empty constructor. |
36 | */ |
37 | inline VrmlData_IndexedLineSet () |
38 | : myArrPolygons (0L), |
39 | myArrColorInd (0L), |
40 | myNbPolygons (0), |
41 | myNbColors (0), |
42 | myColorPerVertex (Standard_True) |
43 | {} |
44 | |
45 | /** |
46 | * Constructor. |
47 | */ |
48 | inline VrmlData_IndexedLineSet (const VrmlData_Scene& theScene, |
49 | const char * theName, |
50 | const Standard_Boolean isColorPerVertex |
51 | = Standard_True) |
52 | : VrmlData_Geometry (theScene, theName), |
53 | myArrPolygons (0L), |
54 | myArrColorInd (0L), |
55 | myNbPolygons (0), |
56 | myNbColors (0), |
57 | myColorPerVertex (isColorPerVertex) |
58 | {} |
59 | |
60 | /** |
61 | * Query the Coordinates. |
62 | */ |
63 | inline const Handle(VrmlData_Coordinate)& |
64 | Coordinates () const { return myCoords; } |
65 | |
66 | /** |
67 | * Set the nodes |
68 | */ |
69 | inline void SetCoordinates (const Handle(VrmlData_Coordinate)& theCoord) |
70 | { myCoords = theCoord; } |
71 | |
72 | /** |
73 | * Query the Colors. |
74 | */ |
75 | inline const Handle(VrmlData_Color)& |
76 | Colors () const { return myColors; } |
77 | |
78 | /** |
79 | * Set the Color node |
80 | */ |
81 | inline void SetColors (const Handle(VrmlData_Color)& theColors) |
82 | { myColors = theColors; } |
83 | |
84 | // ======================================================================== |
85 | // =========================== POLYLINES ================================= |
86 | /** |
87 | * Query the array of polygons |
88 | */ |
89 | inline size_t Polygons (const Standard_Integer**& arrPolygons) const |
90 | { arrPolygons = myArrPolygons; return myNbPolygons; } |
91 | |
92 | /** |
93 | * Query one polygon. |
94 | * @param iPolygon |
95 | * rank of the polygon [0 .. N-1] |
96 | * @param outIndice |
97 | * <tt>[out]</tt> array of vertex indice |
98 | * @return |
99 | * number of vertice in the polygon - the dimension of outIndice array |
100 | */ |
101 | inline Standard_Integer |
102 | Polygon (const Standard_Integer iPolygon, |
103 | const Standard_Integer *& outIndice) |
104 | { return * (outIndice = myArrPolygons[iPolygon])++; } |
105 | |
106 | /** |
107 | * Set the polygons |
108 | */ |
7dc9e047 |
109 | inline void SetPolygons (const Standard_Size nPolygons, |
7fd59977 |
110 | const Standard_Integer ** thePolygons) |
111 | { myNbPolygons = nPolygons; myArrPolygons = thePolygons; } |
112 | |
113 | // ======================================================================== |
114 | // ================================ COLORS ================================ |
115 | /** |
116 | * Query the array of color indice |
117 | * @param arrColorInd |
118 | * <tt>[out]</tt> array of colorIndex as it is described in VRML2.0 spec |
119 | * @return |
120 | * Number of integers in the array arrColorInd. |
121 | */ |
122 | inline size_t ArrayColorInd (const Standard_Integer**& arrColorInd) const |
123 | { arrColorInd = myArrColorInd; return myNbColors; } |
124 | |
125 | /** |
126 | * Query a color for one node in the given element. The color is |
127 | * interpreted according to fields myColors, myArrColorInd, |
128 | * myColorPerVertex, as defined in VRML 2.0. |
129 | * @param iFace |
130 | * rank of the polygon [0 .. N-1] |
131 | * @param iVertex |
132 | * rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored |
133 | * if (myColorPerVertex == False) |
134 | * @return |
135 | * Color value (RGB); if the color is indefinite then returns (0., 0., 0.) |
136 | */ |
137 | Standard_EXPORT Quantity_Color |
138 | GetColor (const Standard_Integer iFace, |
139 | const Standard_Integer iVertex); |
140 | |
141 | /** |
142 | * Set the colors array of indice |
143 | */ |
7dc9e047 |
144 | inline void SetColorInd (const Standard_Size nIndice, |
7fd59977 |
145 | const Standard_Integer ** theIndice) |
146 | { myNbColors = nIndice; myArrColorInd = theIndice; } |
147 | |
148 | /** |
149 | * Set the boolean value "colorPerVertex" |
150 | */ |
151 | inline void SetColorPerVertex (const Standard_Boolean isColorPerVertex) |
152 | { myColorPerVertex = isColorPerVertex; } |
153 | |
154 | /** |
155 | * Query the shape. This method checks the flag myIsModified; if True it |
156 | * should rebuild the shape presentation. |
157 | */ |
158 | Standard_EXPORT virtual const Handle(TopoDS_TShape)& |
159 | TShape (); |
160 | |
161 | /** |
162 | * Create a copy of this node. |
163 | * If the parameter is null, a new copied node is created. Otherwise new node |
164 | * is not created, but rather the given one is modified. |
165 | */ |
166 | Standard_EXPORT virtual Handle(VrmlData_Node) |
167 | Clone (const Handle(VrmlData_Node)& theOther)const; |
168 | |
169 | /** |
170 | * Read the Node from input stream. |
171 | */ |
172 | Standard_EXPORT virtual VrmlData_ErrorStatus |
173 | Read (VrmlData_InBuffer& theBuffer); |
174 | |
175 | /** |
176 | * Write the Node to output stream. |
177 | */ |
178 | Standard_EXPORT virtual VrmlData_ErrorStatus |
179 | Write (const char * thePrefix) const; |
180 | |
181 | /** |
182 | * Returns True if the node is default, so that it should not be written. |
183 | */ |
184 | Standard_EXPORT virtual Standard_Boolean |
185 | IsDefault () const; |
186 | |
187 | |
188 | private: |
189 | // ---------- PRIVATE FIELDS ---------- |
190 | Handle(VrmlData_Coordinate) myCoords; |
191 | Handle(VrmlData_Color) myColors; |
192 | const Standard_Integer ** myArrPolygons; |
193 | const Standard_Integer ** myArrColorInd; |
194 | Standard_Size myNbPolygons; |
195 | Standard_Size myNbColors; |
196 | Standard_Boolean myColorPerVertex; |
197 | |
198 | public: |
199 | // Declaration of CASCADE RTTI |
ec357c5c |
200 | DEFINE_STANDARD_RTTI (VrmlData_IndexedLineSet, VrmlData_Geometry) |
7fd59977 |
201 | }; |
202 | |
203 | // Definition of HANDLE object using Standard_DefineHandle.hxx |
204 | DEFINE_STANDARD_HANDLE (VrmlData_IndexedLineSet, VrmlData_Geometry) |
205 | |
206 | |
207 | #endif |