973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | #include <Vrml_Texture2.ixx> |
15 | #include <TColStd_HArray1OfInteger.hxx> |
16 | |
17 | Vrml_Texture2::Vrml_Texture2() |
18 | { |
19 | myFilename = ""; |
20 | |
21 | myImage = new Vrml_SFImage; |
22 | |
23 | myImage->SetWidth(0); |
24 | myImage->SetHeight(0); |
25 | myImage->SetNumber(Vrml_NULL); |
26 | |
27 | myWrapS = Vrml_REPEAT; |
28 | myWrapT = Vrml_REPEAT; |
29 | } |
30 | |
31 | Vrml_Texture2::Vrml_Texture2(const TCollection_AsciiString& aFilename, |
32 | const Handle(Vrml_SFImage)& aImage, |
33 | const Vrml_Texture2Wrap aWrapS, |
34 | const Vrml_Texture2Wrap aWrapT) |
35 | { |
36 | myFilename = aFilename; |
37 | myImage = aImage; |
38 | myWrapS = aWrapS; |
39 | myWrapT = aWrapT; |
40 | } |
41 | |
42 | void Vrml_Texture2::SetFilename(const TCollection_AsciiString& aFilename) |
43 | { |
44 | myFilename = aFilename; |
45 | } |
46 | |
47 | TCollection_AsciiString Vrml_Texture2::Filename() const |
48 | { |
49 | return myFilename; |
50 | } |
51 | |
52 | void Vrml_Texture2::SetImage(const Handle(Vrml_SFImage)& aImage) |
53 | { |
54 | myImage = aImage; |
55 | } |
56 | |
57 | Handle(Vrml_SFImage) Vrml_Texture2::Image() const |
58 | { |
59 | return myImage; |
60 | } |
61 | |
62 | void Vrml_Texture2::SetWrapS(const Vrml_Texture2Wrap aWrapS) |
63 | { |
64 | myWrapS = aWrapS; |
65 | } |
66 | |
67 | Vrml_Texture2Wrap Vrml_Texture2::WrapS() const |
68 | { |
69 | return myWrapS; |
70 | } |
71 | |
72 | void Vrml_Texture2::SetWrapT(const Vrml_Texture2Wrap aWrapT) |
73 | { |
74 | myWrapT = aWrapT; |
75 | } |
76 | |
77 | Vrml_Texture2Wrap Vrml_Texture2::WrapT() const |
78 | { |
79 | return myWrapT; |
80 | } |
81 | |
82 | Standard_OStream& Vrml_Texture2::Print(Standard_OStream& anOStream) const |
83 | { |
84 | Standard_Integer i; |
85 | anOStream << "Texture2 {" << endl; |
86 | |
87 | if ( !(myFilename.IsEqual("") ) ) |
88 | { |
89 | anOStream << " filename" << '\t'; |
90 | anOStream << '"' << myFilename << '"' << endl; |
91 | } |
92 | |
93 | if ( myImage->Width() != 0 || myImage->Height() != 0 || myImage->Number() != Vrml_NULL ) |
94 | { |
95 | anOStream << " image" << '\t'; |
96 | anOStream << myImage->Width() << ' ' << myImage->Height() << ' '; |
97 | |
98 | switch ( myImage->Number() ) |
99 | { |
100 | case Vrml_NULL: anOStream << "0"; break; |
101 | case Vrml_ONE: anOStream << "1"; break; |
102 | case Vrml_TWO: anOStream << "2"; break; |
103 | case Vrml_THREE: anOStream << "3"; break; |
104 | case Vrml_FOUR: anOStream << "4"; break; |
105 | } |
106 | |
107 | if ( myImage->ArrayFlag() == Standard_True ) |
108 | { |
109 | for ( i = myImage->Array()->Lower(); i <= myImage->Array()->Upper(); i++ ) |
110 | { |
111 | // anOStream << ' ' << hex(myImage->Array()->Value(i),0); |
112 | anOStream << ' ' << myImage->Array()->Value(i); |
113 | } |
114 | } |
115 | anOStream << endl; |
116 | } |
117 | |
118 | switch ( myWrapS ) |
119 | { |
120 | case Vrml_REPEAT: break; // anOStream << " wrapS" << "\tREPEAT "; |
121 | case Vrml_CLAMP: anOStream << " wrapS" << "\tCLAMP" << endl; break; |
122 | } |
123 | |
124 | switch ( myWrapT ) |
125 | { |
126 | case Vrml_REPEAT: break; // anOStream << " wrapT" << "\tREPEAT "; |
127 | case Vrml_CLAMP: anOStream << " wrapT" << "\tCLAMP" << endl; break; |
128 | } |
129 | |
130 | anOStream << '}' << endl; |
131 | return anOStream; |
132 | } |