0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / VrmlData / VrmlData_IndexedFaceSet.hxx
CommitLineData
7fd59977 1// File: VrmlData_IndexedFaceSet.hxx
2// Created: 26.05.06 08:48:31
3// Author: Alexander GRIGORIEV
4// Copyright: Open Cascade 2006
5
6
7#ifndef VrmlData_IndexedFaceSet_HeaderFile
8#define VrmlData_IndexedFaceSet_HeaderFile
9
10#include <VrmlData_Faceted.hxx>
11#include <VrmlData_Coordinate.hxx>
12#include <VrmlData_Normal.hxx>
13#include <VrmlData_Color.hxx>
14#include <VrmlData_TextureCoordinate.hxx>
15#include <gp_XYZ.hxx>
16#include <Quantity_Color.hxx>
17
18/**
19 * Implementation of IndexedFaceSet node
20 */
21class VrmlData_IndexedFaceSet : public VrmlData_Faceted
22{
23 public:
24 // ---------- PUBLIC METHODS ----------
25
26 /**
27 * Empty constructor
28 */
29 inline VrmlData_IndexedFaceSet ()
30 : myArrPolygons (0L),
31 myArrNormalInd (0L),
32 myArrColorInd (0L),
33 myArrTextureInd (0L),
34 myNbPolygons (0),
35 myNbNormals (0),
36 myNbColors (0),
37 myNbTextures (0),
38 myNormalPerVertex (Standard_True),
39 myColorPerVertex (Standard_True)
40 {}
41
42 /**
43 * Constructor
44 */
45 inline VrmlData_IndexedFaceSet (const VrmlData_Scene& theScene,
46 const char * theName,
47 const Standard_Boolean isCCW =Standard_True,
48 const Standard_Boolean isSolid =Standard_True,
49 const Standard_Boolean isConvex=Standard_True,
50 const Standard_Real theCreaseAngle = 0.)
51 : VrmlData_Faceted (theScene, theName, isCCW, isSolid, isConvex,
52 theCreaseAngle),
53 myArrPolygons (0L),
54 myArrNormalInd (0L),
55 myArrColorInd (0L),
56 myArrTextureInd (0L),
57 myNbPolygons (0),
58 myNbNormals (0),
59 myNbColors (0),
60 myNbTextures (0),
61 myNormalPerVertex (Standard_True),
62 myColorPerVertex (Standard_True)
63 {}
64
65 /**
66 * Query the Normals.
67 */
68 inline const Handle(VrmlData_Normal)&
69 Normals () const { return myNormals; }
70
71 /**
72 * Query the Colors.
73 */
74 inline const Handle(VrmlData_Color)&
75 Colors () const { return myColors; }
76
77 /**
78 * Query the Texture Coordinates.
79 */
80 inline const Handle(VrmlData_TextureCoordinate)&
81 TextureCoords () const { return myTxCoords; }
82
83 // ========================================================================
84 // =========================== TRIANGULATION GRID =========================
85 /**
86 * Query the Coordinates.
87 */
88 inline const Handle(VrmlData_Coordinate)&
89 Coordinates () const { return myCoords; }
90
91 /**
92 * Query the array of polygons
93 */
94 inline size_t Polygons (const Standard_Integer**& arrPolygons) const
95 { arrPolygons = myArrPolygons; return myNbPolygons; }
96
97 /**
98 * Query one polygon.
99 * @param iFace
100 * rank of the polygon [0 .. N-1]
101 * @param outIndice
102 * <tt>[out]</tt> array of vertex indice
103 * @return
104 * number of vertice in the polygon - the dimension of outIndice array
105 */
106 inline Standard_Integer
107 Polygon (const Standard_Integer iFace,
108 const Standard_Integer *& outIndice)
109 { return * (outIndice = myArrPolygons[iFace])++; }
110
111 /**
112 * Set the nodes
113 */
114 inline void SetCoordinates (const Handle(VrmlData_Coordinate)& theCoord)
115 { myCoords = theCoord; }
116
117 /**
118 * Set the polygons
119 */
120 inline void SetPolygons (const Standard_Integer nPolygons,
121 const Standard_Integer ** thePolygons)
122 { myNbPolygons = nPolygons; myArrPolygons = thePolygons; }
123
124 // ========================================================================
125 // ================================ NORMALS ===============================
126
127 /**
128 * Query the array of normal indice
129 * @param arrNormalInd
130 * <tt>[out]</tt> array of normalIndex as it is described in VRML2.0 spec
131 * @return
132 * Number of integers in the array arrNormalInd.
133 */
134 inline size_t ArrayNormalInd (const Standard_Integer**& arrNormalInd) const
135 { arrNormalInd = myArrNormalInd; return myNbNormals; }
136
137 /**
138 * Query normals indice for one face. This method should be called after
139 * checking myArrNormalInd != NULL, otherwise exception will be thrown.
140 * @param iFace
141 * rank of the face [0 .. N-1]
142 * @param outIndice
143 * <tt>[out]</tt> array of normals indice
144 * @return
145 * number of indice in the array - the dimension of outIndice array
146 */
147 inline Standard_Integer
148 IndiceNormals (const Standard_Integer iFace,
149 const Standard_Integer *& outIndice)
150 { return * (outIndice = myArrNormalInd[iFace])++; }
151
152 /**
153 * Query a normal for one node in the given element. The normal is
154 * interpreted according to fields myNormals, myArrNormalInd,
155 * myNormalPerVertex, as defined in VRML 2.0.
156 * @param iFace
157 * rank of the polygon [0 .. N-1]
158 * @param iVertex
159 * rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored
160 * if (myNormalPerVertex == False)
161 * @return
162 * Normal vector; if the normal is indefinite then returns (0., 0., 0.)
163 */
164 Standard_EXPORT gp_XYZ
165 GetNormal (const Standard_Integer iFace,
166 const Standard_Integer iVertex);
167
168 /**
169 * Set the normals array of indice
170 */
171 inline void SetNormalInd (const Standard_Integer nIndice,
172 const Standard_Integer ** theIndice)
173 { myNbNormals = nIndice; myArrNormalInd = theIndice; }
174
175 /**
176 * Set the normals node
177 */
178 inline void SetNormals (const Handle(VrmlData_Normal)& theNormals)
179 { myNormals = theNormals; }
180
181 /**
182 * Set the boolean value "normalPerVertex"
183 */
184 inline void SetNormalPerVertex (const Standard_Boolean isNormalPerVertex)
185 { myNormalPerVertex = isNormalPerVertex; }
186
187 // ========================================================================
188 // ================================ COLORS ================================
189
190 /**
191 * Query the array of color indice
192 * @param arrColorInd
193 * <tt>[out]</tt> array of colorIndex as it is described in VRML2.0 spec
194 * @return
195 * Number of integers in the array arrColorInd.
196 */
197 inline size_t ArrayColorInd (const Standard_Integer**& arrColorInd) const
198 { arrColorInd = myArrColorInd; return myNbColors; }
199
200 /**
201 * Query a color for one node in the given element. The color is
202 * interpreted according to fields myColors, myArrColorInd,
203 * myColorPerVertex, as defined in VRML 2.0.
204 * @param iFace
205 * rank of the polygon [0 .. N-1]
206 * @param iVertex
207 * rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored
208 * if (myColorPerVertex == False)
209 * @return
210 * Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
211 */
212 Standard_EXPORT Quantity_Color
213 GetColor (const Standard_Integer iFace,
214 const Standard_Integer iVertex);
215
216 /**
217 * Set the colors array of indice
218 */
219 inline void SetColorInd (const Standard_Integer nIndice,
220 const Standard_Integer ** theIndice)
221 { myNbColors = nIndice; myArrColorInd = theIndice; }
222
223 /**
224 * Set the Color node
225 */
226 inline void SetColors (const Handle(VrmlData_Color)& theColors)
227 { myColors = theColors; }
228
229 /**
230 * Set the boolean value "colorPerVertex"
231 */
232 inline void SetColorPerVertex (const Standard_Boolean isColorPerVertex)
233 { myColorPerVertex = isColorPerVertex; }
234
235 // ========================================================================
236 // ========================== TEXTURE COIRDINATES =========================
237
238 /**
239 * Query the array of texture coordinate indice
240 * @param arrTextureCoordInd
241 * <tt>[out]</tt> array of texCoordIndex as it is described in VRML2.0 spec
242 * @return
243 * Number of integers in the array texCoordIndex.
244 */
245 inline size_t ArrayTextureCoordInd
246 (const Standard_Integer**& arrTextureCoordInd) const
247 { arrTextureCoordInd = myArrTextureInd; return myNbTextures; }
248
249 /**
250 * Set the TexCoordiante array of indice
251 */
252 inline void SetTextureCoordInd (const Standard_Integer nIndice,
253 const Standard_Integer ** theIndice)
254 { myNbTextures = nIndice; myArrTextureInd = theIndice; }
255
256 /**
257 * Set the Texture Coordinate node
258 */
259 inline void SetTextureCoords(const Handle(VrmlData_TextureCoordinate)& tc)
260 { myTxCoords = tc; }
261
262 /**
263 * Query the shape. This method checks the flag myIsModified; if True it
264 * should rebuild the shape presentation.
265 */
266 Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape ();
267
268 /**
269 * Create a copy of this node.
270 * If the parameter is null, a new copied node is created. Otherwise new node
271 * is not created, but rather the given one is modified.
272 */
273 Standard_EXPORT virtual Handle(VrmlData_Node)
274 Clone (const Handle(VrmlData_Node)& theOther)const;
275
276 /**
277 * Read the Node from input stream.
278 */
279 Standard_EXPORT virtual VrmlData_ErrorStatus
280 Read (VrmlData_InBuffer& theBuffer);
281
282 /**
283 * Write the Node to output stream.
284 */
285 Standard_EXPORT virtual VrmlData_ErrorStatus
286 Write (const char * thePrefix) const;
287
288 /**
289 * Returns True if the node is default, so that it should not be written.
290 */
291 Standard_EXPORT virtual Standard_Boolean
292 IsDefault () const;
293
294 protected:
295 // ---------- PROTECTED METHODS ----------
296
297// /**
298// * If the normals are not defined, here we compute them from the polygons.
299// * @param theArray
300// * Array of float values having length:<ul>
301// * <li>if myNormalPerVertex==TRUE : 3 * myCoords->Length()</li>
302// * <li>if myNormalPerVertex==FALSE: 9 * number_of_triangles </li>
303// * </ul>
304// */
305// Standard_EXPORT void
306// computeNormals (Standard_ShortReal * theArray);
307
308 private:
309 // ---------- PRIVATE FIELDS ----------
310 Handle(VrmlData_Coordinate) myCoords;
311 Handle(VrmlData_Normal) myNormals;
312 Handle(VrmlData_Color) myColors;
313 Handle(VrmlData_TextureCoordinate) myTxCoords;
314 const Standard_Integer ** myArrPolygons;
315 const Standard_Integer ** myArrNormalInd;
316 const Standard_Integer ** myArrColorInd;
317 const Standard_Integer ** myArrTextureInd;
318 Standard_Size myNbPolygons;
319 Standard_Size myNbNormals;
320 Standard_Size myNbColors;
321 Standard_Size myNbTextures;
322 Standard_Boolean myNormalPerVertex;
323 Standard_Boolean myColorPerVertex;
324
325 public:
326// Declaration of CASCADE RTTI
327DEFINE_STANDARD_RTTI (VrmlData_IndexedFaceSet)
328};
329
330// Definition of HANDLE object using Standard_DefineHandle.hxx
331DEFINE_STANDARD_HANDLE (VrmlData_IndexedFaceSet, VrmlData_Faceted)
332
333
334#endif