Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:20: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(nullptr),
0039         myArrColorInd(nullptr),
0040         myNbPolygons(0),
0041         myNbColors(0),
0042         myColorPerVertex(true)
0043   {
0044   }
0045 
0046   /**
0047    * Constructor.
0048    */
0049   inline VrmlData_IndexedLineSet(const VrmlData_Scene& theScene,
0050                                  const char*           theName,
0051                                  const bool            isColorPerVertex = true)
0052       : VrmlData_Geometry(theScene, theName),
0053         myArrPolygons(nullptr),
0054         myArrColorInd(nullptr),
0055         myNbPolygons(0),
0056         myNbColors(0),
0057         myColorPerVertex(isColorPerVertex)
0058   {
0059   }
0060 
0061   /**
0062    * Query the Coordinates.
0063    */
0064   inline const occ::handle<VrmlData_Coordinate>& Coordinates() const { return myCoords; }
0065 
0066   /**
0067    * Set the nodes
0068    */
0069   inline void SetCoordinates(const occ::handle<VrmlData_Coordinate>& theCoord)
0070   {
0071     myCoords = theCoord;
0072   }
0073 
0074   /**
0075    * Query the Colors.
0076    */
0077   inline const occ::handle<VrmlData_Color>& Colors() const { return myColors; }
0078 
0079   /**
0080    * Set the Color node
0081    */
0082   inline void SetColors(const occ::handle<VrmlData_Color>& theColors) { myColors = theColors; }
0083 
0084   // ========================================================================
0085   // =========================== POLYLINES  =================================
0086   /**
0087    * Query the array of polygons
0088    */
0089   inline size_t Polygons(const int**& arrPolygons) const
0090   {
0091     arrPolygons = myArrPolygons;
0092     return myNbPolygons;
0093   }
0094 
0095   /**
0096    * Query one polygon.
0097    * @param iPolygon
0098    *   rank of the polygon [0 .. N-1]
0099    * @param outIndice
0100    *   <tt>[out]</tt> array of vertex indice
0101    * @return
0102    *   number of vertice in the polygon - the dimension of outIndice array
0103    */
0104   inline int Polygon(const int iPolygon, const int*& outIndice)
0105   {
0106     return *(outIndice = myArrPolygons[iPolygon])++;
0107   }
0108 
0109   /**
0110    * Set the polygons
0111    */
0112   inline void SetPolygons(const size_t nPolygons, const int** thePolygons)
0113   {
0114     myNbPolygons  = nPolygons;
0115     myArrPolygons = thePolygons;
0116   }
0117 
0118   // ========================================================================
0119   // ================================ COLORS ================================
0120   /**
0121    * Query the array of color indice
0122    * @param arrColorInd
0123    *   <tt>[out]</tt> array of colorIndex as it is described in VRML2.0 spec
0124    * @return
0125    *   Number of integers in the array arrColorInd.
0126    */
0127   inline size_t ArrayColorInd(const int**& arrColorInd) const
0128   {
0129     arrColorInd = myArrColorInd;
0130     return myNbColors;
0131   }
0132 
0133   /**
0134    * Query a color for one node in the given element. The color is
0135    * interpreted according to fields myColors, myArrColorInd,
0136    * myColorPerVertex, as defined in VRML 2.0.
0137    * @param iFace
0138    *   rank of the polygon [0 .. N-1]
0139    * @param iVertex
0140    *   rank of the vertex in the polygon [0 .. M-1]. This parameter is ignored
0141    *   if (myColorPerVertex == False)
0142    * @return
0143    *   Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
0144    */
0145   Standard_EXPORT Quantity_Color GetColor(const int iFace, const int iVertex);
0146 
0147   /**
0148    * Set the colors array of indice
0149    */
0150   inline void SetColorInd(const size_t nIndice, const int** theIndice)
0151   {
0152     myNbColors    = nIndice;
0153     myArrColorInd = theIndice;
0154   }
0155 
0156   /**
0157    * Set the boolean value "colorPerVertex"
0158    */
0159   inline void SetColorPerVertex(const bool isColorPerVertex)
0160   {
0161     myColorPerVertex = isColorPerVertex;
0162   }
0163 
0164   /**
0165    * Query the shape. This method checks the flag myIsModified; if True it
0166    * should rebuild the shape presentation.
0167    */
0168   Standard_EXPORT const occ::handle<TopoDS_TShape>& TShape() override;
0169 
0170   /**
0171    * Create a copy of this node.
0172    * If the parameter is null, a new copied node is created. Otherwise new node
0173    * is not created, but rather the given one is modified.
0174    */
0175   Standard_EXPORT occ::handle<VrmlData_Node> Clone(
0176     const occ::handle<VrmlData_Node>& theOther) const override;
0177 
0178   /**
0179    * Read the Node from input stream.
0180    */
0181   Standard_EXPORT VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) override;
0182 
0183   /**
0184    * Write the Node to output stream.
0185    */
0186   Standard_EXPORT VrmlData_ErrorStatus Write(const char* thePrefix) const override;
0187 
0188   /**
0189    * Returns True if the node is default, so that it should not be written.
0190    */
0191   Standard_EXPORT bool IsDefault() const override;
0192 
0193 private:
0194   // ---------- PRIVATE FIELDS ----------
0195   occ::handle<VrmlData_Coordinate> myCoords;
0196   occ::handle<VrmlData_Color>      myColors;
0197   const int**                      myArrPolygons;
0198   const int**                      myArrColorInd;
0199   size_t                           myNbPolygons;
0200   size_t                           myNbColors;
0201   bool                             myColorPerVertex;
0202 
0203 public:
0204   // Declaration of CASCADE RTTI
0205   DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedLineSet, VrmlData_Geometry)
0206 };
0207 
0208 // Definition of HANDLE object using Standard_DefineHandle.hxx
0209 #endif