Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Graphic3d_TextureSet.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (c) 2017 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_TextureSet_HeaderFile
0015 #define _Graphic3d_TextureSet_HeaderFile
0016 
0017 #include <Graphic3d_TextureMap.hxx>
0018 #include <NCollection_Array1.hxx>
0019 
0020 //! Class holding array of textures to be mapped as a set.
0021 //! Textures should be defined in ascending order of texture units within the set.
0022 class Graphic3d_TextureSet : public Standard_Transient
0023 {
0024   DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureSet, Standard_Transient)
0025 public:
0026   //! Class for iterating texture set.
0027   class Iterator : public NCollection_Array1<occ::handle<Graphic3d_TextureMap>>::Iterator
0028   {
0029   public:
0030     //! Empty constructor.
0031     Iterator() = default;
0032 
0033     //! Constructor.
0034     Iterator(const occ::handle<Graphic3d_TextureSet>& theSet)
0035     {
0036       if (!theSet.IsNull())
0037       {
0038         NCollection_Array1<occ::handle<Graphic3d_TextureMap>>::Iterator::Init(theSet->myTextures);
0039       }
0040     }
0041   };
0042 
0043 public:
0044   //! Empty constructor.
0045   Graphic3d_TextureSet() = default;
0046 
0047   //! Constructor.
0048   Graphic3d_TextureSet(int theNbTextures)
0049       : myTextures(0, theNbTextures - 1)
0050   {
0051   }
0052 
0053   //! Constructor for a single texture.
0054   Graphic3d_TextureSet(const occ::handle<Graphic3d_TextureMap>& theTexture)
0055       : myTextures(0, 0)
0056   {
0057     myTextures.ChangeFirst() = theTexture;
0058   }
0059 
0060   //! Return TRUE if texture array is empty.
0061   bool IsEmpty() const { return myTextures.IsEmpty(); }
0062 
0063   //! Return number of textures.
0064   int Size() const { return myTextures.Length(); }
0065 
0066   //! Return the lower index in texture set.
0067   int Lower() const { return myTextures.Lower(); }
0068 
0069   //! Return the upper index in texture set.
0070   int Upper() const { return myTextures.Upper(); }
0071 
0072   //! Return the first texture.
0073   const occ::handle<Graphic3d_TextureMap>& First() const { return myTextures.First(); }
0074 
0075   //! Return the first texture.
0076   void SetFirst(const occ::handle<Graphic3d_TextureMap>& theTexture)
0077   {
0078     myTextures.ChangeFirst() = theTexture;
0079   }
0080 
0081   //! Return the texture at specified position within [0, Size()) range.
0082   const occ::handle<Graphic3d_TextureMap>& Value(int theIndex) const
0083   {
0084     return myTextures.Value(theIndex);
0085   }
0086 
0087   //! Return the texture at specified position within [0, Size()) range.
0088   void SetValue(int theIndex, const occ::handle<Graphic3d_TextureMap>& theTexture)
0089   {
0090     myTextures.SetValue(theIndex, theTexture);
0091   }
0092 
0093 protected:
0094   NCollection_Array1<occ::handle<Graphic3d_TextureMap>> myTextures;
0095 };
0096 
0097 #endif // _Graphic3d_TextureSet_HeaderFile