1 // Created on: 2007-08-01
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef VrmlData_IndexedLineSet_HeaderFile
17 #define VrmlData_IndexedLineSet_HeaderFile
19 #include <VrmlData_Geometry.hxx>
20 #include <VrmlData_Coordinate.hxx>
21 #include <VrmlData_Color.hxx>
22 //#include <Quantity_Color.hxx>
25 * Data type to store a set of polygons.
28 class VrmlData_IndexedLineSet : public VrmlData_Geometry
31 // ---------- PUBLIC METHODS ----------
37 inline VrmlData_IndexedLineSet ()
42 myColorPerVertex (Standard_True)
48 inline VrmlData_IndexedLineSet (const VrmlData_Scene& theScene,
50 const Standard_Boolean isColorPerVertex
52 : VrmlData_Geometry (theScene, theName),
57 myColorPerVertex (isColorPerVertex)
61 * Query the Coordinates.
63 inline const Handle(VrmlData_Coordinate)&
64 Coordinates () const { return myCoords; }
69 inline void SetCoordinates (const Handle(VrmlData_Coordinate)& theCoord)
70 { myCoords = theCoord; }
75 inline const Handle(VrmlData_Color)&
76 Colors () const { return myColors; }
81 inline void SetColors (const Handle(VrmlData_Color)& theColors)
82 { myColors = theColors; }
84 // ========================================================================
85 // =========================== POLYLINES =================================
87 * Query the array of polygons
89 inline size_t Polygons (const Standard_Integer**& arrPolygons) const
90 { arrPolygons = myArrPolygons; return myNbPolygons; }
95 * rank of the polygon [0 .. N-1]
97 * <tt>[out]</tt> array of vertex indice
99 * number of vertice in the polygon - the dimension of outIndice array
101 inline Standard_Integer
102 Polygon (const Standard_Integer iPolygon,
103 const Standard_Integer *& outIndice)
104 { return * (outIndice = myArrPolygons[iPolygon])++; }
109 inline void SetPolygons (const Standard_Size nPolygons,
110 const Standard_Integer ** thePolygons)
111 { myNbPolygons = nPolygons; myArrPolygons = thePolygons; }
113 // ========================================================================
114 // ================================ COLORS ================================
116 * Query the array of color indice
118 * <tt>[out]</tt> array of colorIndex as it is described in VRML2.0 spec
120 * Number of integers in the array arrColorInd.
122 inline size_t ArrayColorInd (const Standard_Integer**& arrColorInd) const
123 { arrColorInd = myArrColorInd; return myNbColors; }
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.
130 * rank of the polygon [0 .. N-1]
132 * rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored
133 * if (myColorPerVertex == False)
135 * Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
137 Standard_EXPORT Quantity_Color
138 GetColor (const Standard_Integer iFace,
139 const Standard_Integer iVertex);
142 * Set the colors array of indice
144 inline void SetColorInd (const Standard_Size nIndice,
145 const Standard_Integer ** theIndice)
146 { myNbColors = nIndice; myArrColorInd = theIndice; }
149 * Set the boolean value "colorPerVertex"
151 inline void SetColorPerVertex (const Standard_Boolean isColorPerVertex)
152 { myColorPerVertex = isColorPerVertex; }
155 * Query the shape. This method checks the flag myIsModified; if True it
156 * should rebuild the shape presentation.
158 Standard_EXPORT virtual const Handle(TopoDS_TShape)&
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.
166 Standard_EXPORT virtual Handle(VrmlData_Node)
167 Clone (const Handle(VrmlData_Node)& theOther)const;
170 * Read the Node from input stream.
172 Standard_EXPORT virtual VrmlData_ErrorStatus
173 Read (VrmlData_InBuffer& theBuffer);
176 * Write the Node to output stream.
178 Standard_EXPORT virtual VrmlData_ErrorStatus
179 Write (const char * thePrefix) const;
182 * Returns True if the node is default, so that it should not be written.
184 Standard_EXPORT virtual Standard_Boolean
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;
199 // Declaration of CASCADE RTTI
200 DEFINE_STANDARD_RTTI (VrmlData_IndexedLineSet)
203 // Definition of HANDLE object using Standard_DefineHandle.hxx
204 DEFINE_STANDARD_HANDLE (VrmlData_IndexedLineSet, VrmlData_Geometry)