1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Graphic3d_Texture2D.hxx>
19 #include <Standard_OutOfRange.hxx>
20 #include <Standard_Type.hxx>
21 #include <TCollection_AsciiString.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2D,Graphic3d_TextureMap)
25 static const char *NameOfTexture_to_FileName[] =
27 "2d_MatraDatavision.rgb",
30 "2d_bluewhite_paper.rgb",
50 // =======================================================================
51 // function : Graphic3d_Texture2D
53 // =======================================================================
54 Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName,
55 const Graphic3d_TypeOfTexture theType)
56 : Graphic3d_TextureMap (theFileName, theType),
57 myName (Graphic3d_NOT_2D_UNKNOWN)
61 // =======================================================================
62 // function : Graphic3d_Texture2D
64 // =======================================================================
65 Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT,
66 const Graphic3d_TypeOfTexture theType)
67 : Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
70 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
71 myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_")
72 + NameOfTexture_to_FileName[theNOT];
75 // =======================================================================
76 // function : Graphic3d_Texture2D
78 // =======================================================================
79 Graphic3d_Texture2D::Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixMap,
80 const Graphic3d_TypeOfTexture theType)
81 : Graphic3d_TextureMap (thePixMap, theType),
82 myName (Graphic3d_NOT_2D_UNKNOWN)
86 // =======================================================================
87 // function : NumberOfTextures
89 // =======================================================================
90 Standard_Integer Graphic3d_Texture2D::NumberOfTextures()
92 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
95 // =======================================================================
98 // =======================================================================
99 Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const
104 // =======================================================================
105 // function : TextureName
107 // =======================================================================
108 TCollection_AsciiString Graphic3d_Texture2D::TextureName (const Standard_Integer theRank)
110 if (theRank < 1 || theRank > NumberOfTextures())
112 Standard_OutOfRange::Raise ("BAD index of texture");
115 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
116 Standard_Integer i = aFileName.SearchFromEnd (".");
117 return aFileName.SubString (4, i - 1);