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 | |
42cf5bc1 |
17 | |
18 | #include <Graphic3d_Texture1D.hxx> |
19 | #include <Standard_OutOfRange.hxx> |
20 | #include <Standard_Type.hxx> |
7fd59977 |
21 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
22 | |
92efcf78 |
23 | IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture1D,Graphic3d_TextureMap) |
24 | |
bf75be98 |
25 | static const char *NameOfTexture_to_FileName[] = |
7fd59977 |
26 | { |
27 | "1d_elevation.rgb" |
28 | }; |
29 | |
bf75be98 |
30 | // ======================================================================= |
31 | // function : Graphic3d_Texture1D |
32 | // purpose : |
33 | // ======================================================================= |
34 | Graphic3d_Texture1D::Graphic3d_Texture1D (const TCollection_AsciiString& theFileName, |
35 | const Graphic3d_TypeOfTexture theType) |
36 | : Graphic3d_TextureMap (theFileName, theType), |
37 | myName (Graphic3d_NOT_1D_UNKNOWN) |
7fd59977 |
38 | { |
39 | } |
40 | |
bf75be98 |
41 | // ======================================================================= |
42 | // function : Graphic3d_Texture1D |
43 | // purpose : |
44 | // ======================================================================= |
45 | Graphic3d_Texture1D::Graphic3d_Texture1D (const Graphic3d_NameOfTexture1D theNOT, |
46 | const Graphic3d_TypeOfTexture theType) |
47 | : Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType), |
48 | myName (theNOT) |
7fd59977 |
49 | { |
bf75be98 |
50 | myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder()); |
51 | myTexId = TCollection_AsciiString ("Graphic3d_Texture1D_") |
52 | + NameOfTexture_to_FileName[theNOT]; |
7fd59977 |
53 | } |
54 | |
f376ac72 |
55 | // ======================================================================= |
56 | // function : Graphic3d_Texture1D |
57 | // purpose : |
58 | // ======================================================================= |
59 | Graphic3d_Texture1D::Graphic3d_Texture1D (const Handle(Image_PixMap)& thePixMap, |
60 | const Graphic3d_TypeOfTexture theType) |
61 | : Graphic3d_TextureMap (thePixMap, theType), |
62 | myName (Graphic3d_NOT_1D_UNKNOWN) |
63 | { |
64 | } |
65 | |
bf75be98 |
66 | // ======================================================================= |
67 | // function : Name |
68 | // purpose : |
69 | // ======================================================================= |
70 | Graphic3d_NameOfTexture1D Graphic3d_Texture1D::Name() const |
71 | { |
7fd59977 |
72 | return myName; |
73 | } |
74 | |
bf75be98 |
75 | // ======================================================================= |
76 | // function : NumberOfTextures |
77 | // purpose : |
78 | // ======================================================================= |
79 | Standard_Integer Graphic3d_Texture1D::NumberOfTextures() |
80 | { |
7fd59977 |
81 | return sizeof(NameOfTexture_to_FileName)/sizeof(char*); |
82 | } |
83 | |
bf75be98 |
84 | // ======================================================================= |
85 | // function : TextureName |
86 | // purpose : |
87 | // ======================================================================= |
88 | TCollection_AsciiString Graphic3d_Texture1D::TextureName (const Standard_Integer theRank) |
89 | { |
90 | if (theRank < 1 || theRank > NumberOfTextures()) |
91 | { |
92 | Standard_OutOfRange::Raise ("BAD index of texture"); |
93 | } |
7fd59977 |
94 | |
bf75be98 |
95 | TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]); |
96 | Standard_Integer i = aFileName.SearchFromEnd ("."); |
97 | return aFileName.SubString (4, i - 1); |
7fd59977 |
98 | } |