b311480e |
1 | // Created on: 1997-07-28 |
2 | // Created by: Pierre CHALAMET |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | #include <Graphic3d_Texture2D.ixx> |
7fd59977 |
18 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
19 | |
20 | static const char *NameOfTexture_to_FileName[] = |
21 | { |
22 | "2d_MatraDatavision.rgb", |
23 | "2d_alienskin.rgb", |
24 | "2d_blue_rock.rgb", |
25 | "2d_bluewhite_paper.rgb", |
26 | "2d_brushed.rgb", |
27 | "2d_bubbles.rgb", |
28 | "2d_bumps.rgb", |
29 | "2d_cast.rgb", |
30 | "2d_chipbd.rgb", |
31 | "2d_clouds.rgb", |
32 | "2d_flesh.rgb", |
33 | "2d_floor.rgb", |
34 | "2d_galvnisd.rgb", |
35 | "2d_grass.rgb", |
36 | "2d_aluminum.rgb", |
37 | "2d_rock.rgb", |
38 | "2d_knurl.rgb", |
39 | "2d_maple.rgb", |
40 | "2d_marble.rgb", |
41 | "2d_mottled.rgb", |
42 | "2d_rain.rgb" |
43 | }; |
44 | |
bf75be98 |
45 | // ======================================================================= |
46 | // function : Graphic3d_Texture2D |
47 | // purpose : |
48 | // ======================================================================= |
49 | Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName, |
50 | const Graphic3d_TypeOfTexture theType) |
51 | : Graphic3d_TextureMap (theFileName, theType), |
52 | myName (Graphic3d_NOT_2D_UNKNOWN) |
7fd59977 |
53 | { |
54 | } |
55 | |
bf75be98 |
56 | // ======================================================================= |
57 | // function : Graphic3d_Texture2D |
58 | // purpose : |
59 | // ======================================================================= |
60 | Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT, |
61 | const Graphic3d_TypeOfTexture theType) |
62 | : Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType), |
63 | myName (theNOT) |
7fd59977 |
64 | { |
bf75be98 |
65 | myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder()); |
66 | myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_") |
67 | + NameOfTexture_to_FileName[theNOT]; |
7fd59977 |
68 | } |
69 | |
f376ac72 |
70 | // ======================================================================= |
71 | // function : Graphic3d_Texture2D |
72 | // purpose : |
73 | // ======================================================================= |
74 | Graphic3d_Texture2D::Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixMap, |
75 | const Graphic3d_TypeOfTexture theType) |
76 | : Graphic3d_TextureMap (thePixMap, theType), |
77 | myName (Graphic3d_NOT_2D_UNKNOWN) |
78 | { |
79 | } |
80 | |
bf75be98 |
81 | // ======================================================================= |
82 | // function : NumberOfTextures |
83 | // purpose : |
84 | // ======================================================================= |
85 | Standard_Integer Graphic3d_Texture2D::NumberOfTextures() |
86 | { |
7fd59977 |
87 | return sizeof(NameOfTexture_to_FileName)/sizeof(char*); |
88 | } |
89 | |
bf75be98 |
90 | // ======================================================================= |
91 | // function : Name |
92 | // purpose : |
93 | // ======================================================================= |
94 | Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const |
95 | { |
7fd59977 |
96 | return myName; |
97 | } |
98 | |
bf75be98 |
99 | // ======================================================================= |
100 | // function : TextureName |
101 | // purpose : |
102 | // ======================================================================= |
103 | TCollection_AsciiString Graphic3d_Texture2D::TextureName (const Standard_Integer theRank) |
104 | { |
105 | if (theRank < 1 || theRank > NumberOfTextures()) |
106 | { |
107 | Standard_OutOfRange::Raise ("BAD index of texture"); |
108 | } |
109 | |
110 | TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]); |
111 | Standard_Integer i = aFileName.SearchFromEnd ("."); |
112 | return aFileName.SubString (4, i - 1); |
7fd59977 |
113 | } |