1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 #include <Graphic3d_Texture2D.ixx>
22 #include <TCollection_AsciiString.hxx>
24 static const char *NameOfTexture_to_FileName[] =
26 "2d_MatraDatavision.rgb",
29 "2d_bluewhite_paper.rgb",
49 // =======================================================================
50 // function : Graphic3d_Texture2D
52 // =======================================================================
53 Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName,
54 const Graphic3d_TypeOfTexture theType)
55 : Graphic3d_TextureMap (theFileName, theType),
56 myName (Graphic3d_NOT_2D_UNKNOWN)
60 // =======================================================================
61 // function : Graphic3d_Texture2D
63 // =======================================================================
64 Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT,
65 const Graphic3d_TypeOfTexture theType)
66 : Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
69 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
70 myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_")
71 + NameOfTexture_to_FileName[theNOT];
74 // =======================================================================
75 // function : NumberOfTextures
77 // =======================================================================
78 Standard_Integer Graphic3d_Texture2D::NumberOfTextures()
80 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
83 // =======================================================================
86 // =======================================================================
87 Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const
92 // =======================================================================
93 // function : TextureName
95 // =======================================================================
96 TCollection_AsciiString Graphic3d_Texture2D::TextureName (const Standard_Integer theRank)
98 if (theRank < 1 || theRank > NumberOfTextures())
100 Standard_OutOfRange::Raise ("BAD index of texture");
103 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
104 Standard_Integer i = aFileName.SearchFromEnd (".");
105 return aFileName.SubString (4, i - 1);