Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 08:23:54

0001 // Created on: 2007-08-01
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2007-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef VrmlData_IndexedLineSet_HeaderFile
0017 #define VrmlData_IndexedLineSet_HeaderFile
0018 
0019 #include <VrmlData_Geometry.hxx>
0020 #include <VrmlData_Coordinate.hxx>
0021 #include <VrmlData_Color.hxx>
0022 
0023 // #include <Quantity_Color.hxx>
0024 
0025 /**
0026  * Data type to store a set of polygons.
0027  */
0028 
0029 class VrmlData_IndexedLineSet : public VrmlData_Geometry
0030 {
0031 public:
0032   // ---------- PUBLIC METHODS ----------
0033 
0034   /**
0035    * Empty constructor.
0036    */
0037   inline VrmlData_IndexedLineSet()
0038       : myArrPolygons(0L),
0039         myArrColorInd(0L),
0040         myNbPolygons(0),
0041         myNbColors(0),
0042         myColorPerVertex(Standard_True)
0043   {
0044   }
0045 
0046   /**
0047    * Constructor.
0048    */
0049   inline VrmlData_IndexedLineSet(const VrmlData_Scene&  theScene,
0050                                  const char*            theName,
0051                                  const Standard_Boolean isColorPerVertex = Standard_True)
0052       : VrmlData_Geometry(theScene, theName),
0053         myArrPolygons(0L),
0054         myArrColorInd(0L),
0055         myNbPolygons(0),
0056         myNbColors(0),
0057         myColorPerVertex(isColorPerVertex)
0058   {
0059   }
0060 
0061   /**
0062    * Query the Coordinates.
0063    */
0064   inline const Handle(VrmlData_Coordinate)& Coordinates() const { return myCoords; }
0065 
0066   /**
0067    * Set the nodes
0068    */
0069   inline void SetCoordinates(const Handle(VrmlData_Coordinate)& theCoord) { myCoords = theCoord; }
0070 
0071   /**
0072    * Query the Colors.
0073    */
0074   inline const Handle(VrmlData_Color)& Colors() const { return myColors; }
0075 
0076   /**
0077    * Set the Color node
0078    */
0079   inline void SetColors(const Handle(VrmlData_Color)& theColors) { myColors = theColors; }
0080 
0081   // ========================================================================
0082   // =========================== POLYLINES  =================================
0083   /**
0084    * Query the array of polygons
0085    */
0086   inline size_t Polygons(const Standard_Integer**& arrPolygons) const
0087   {
0088     arrPolygons = myArrPolygons;
0089     return myNbPolygons;
0090   }
0091 
0092   /**
0093    * Query one polygon.
0094    * @param iPolygon
0095    *   rank of the polygon [0 .. N-1]
0096    * @param outIndice
0097    *   <tt>[out]</tt> array of vertex indice
0098    * @return
0099    *   number of vertice in the polygon - the dimension of outIndice array
0100    */
0101   inline Standard_Integer Polygon(const Standard_Integer   iPolygon,
0102                                   const Standard_Integer*& outIndice)
0103   {
0104     return *(outIndice = myArrPolygons[iPolygon])++;
0105   }
0106 
0107   /**
0108    * Set the polygons
0109    */
0110   inline void SetPolygons(const Standard_Size nPolygons, const Standard_Integer** thePolygons)
0111   {
0112     myNbPolygons  = nPolygons;
0113     myArrPolygons = thePolygons;
0114   }
0115 
0116   // ========================================================================
0117   // ================================ COLORS ================================
0118   /**
0119    * Query the array of color indice
0120    * @param arrColorInd
0121    *   <tt>[out]</tt> array of colorIndex as it is described in VRML2.0 spec
0122    * @return
0123    *   Number of integers in the array arrColorInd.
0124    */
0125   inline size_t ArrayColorInd(const Standard_Integer**& arrColorInd) const
0126   {
0127     arrColorInd = myArrColorInd;
0128     return myNbColors;
0129   }
0130 
0131   /**
0132    * Query a color for one node in the given element. The color is
0133    * interpreted according to fields myColors, myArrColorInd,
0134    * myColorPerVertex, as defined in VRML 2.0.
0135    * @param iFace
0136    *   rank of the polygon [0 .. N-1]
0137    * @param iVertex
0138    *   rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored
0139    *   if (myColorPerVertex == False)
0140    * @return
0141    *   Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
0142    */
0143   Standard_EXPORT Quantity_Color GetColor(const Standard_Integer iFace,
0144                                           const Standard_Integer iVertex);
0145 
0146   /**
0147    * Set the colors array of indice
0148    */
0149   inline void SetColorInd(const Standard_Size nIndice, const Standard_Integer** theIndice)
0150   {
0151     myNbColors    = nIndice;
0152     myArrColorInd = theIndice;
0153   }
0154 
0155   /**
0156    * Set the boolean value "colorPerVertex"
0157    */
0158   inline void SetColorPerVertex(const Standard_Boolean isColorPerVertex)
0159   {
0160     myColorPerVertex = isColorPerVertex;
0161   }
0162 
0163   /**
0164    * Query the shape. This method checks the flag myIsModified; if True it
0165    * should rebuild the shape presentation.
0166    */
0167   Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
0168 
0169   /**
0170    * Create a copy of this node.
0171    * If the parameter is null, a new copied node is created. Otherwise new node
0172    * is not created, but rather the given one is modified.
0173    */
0174   Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
0175     Standard_OVERRIDE;
0176 
0177   /**
0178    * Read the Node from input stream.
0179    */
0180   Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
0181 
0182   /**
0183    * Write the Node to output stream.
0184    */
0185   Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
0186 
0187   /**
0188    * Returns True if the node is default, so that it should not be written.
0189    */
0190   Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
0191 
0192 private:
0193   // ---------- PRIVATE FIELDS ----------
0194   Handle(VrmlData_Coordinate) myCoords;
0195   Handle(VrmlData_Color)      myColors;
0196   const Standard_Integer**    myArrPolygons;
0197   const Standard_Integer**    myArrColorInd;
0198   Standard_Size               myNbPolygons;
0199   Standard_Size               myNbColors;
0200   Standard_Boolean            myColorPerVertex;
0201 
0202 public:
0203   // Declaration of CASCADE RTTI
0204   DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedLineSet, VrmlData_Geometry)
0205 };
0206 
0207 // Definition of HANDLE object using Standard_DefineHandle.hxx
0208 DEFINE_STANDARD_HANDLE(VrmlData_IndexedLineSet, VrmlData_Geometry)
0209 
0210 #endif