Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:32

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