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 | |
42cf5bc1 |
14 | |
15 | #include <gp_Vec.hxx> |
16 | #include <Quantity_Color.hxx> |
17 | #include <Vrml_PointLight.hxx> |
7fd59977 |
18 | |
19 | Vrml_PointLight::Vrml_PointLight(): |
20 | myOnOff(Standard_True), |
ba00aab7 |
21 | myIntensity(1), |
22 | myColor (Quantity_NOC_WHITE), |
23 | myLocation (0, 0, 1) |
7fd59977 |
24 | { |
ba00aab7 |
25 | // |
7fd59977 |
26 | } |
27 | |
28 | Vrml_PointLight::Vrml_PointLight( const Standard_Boolean aOnOff, |
29 | const Standard_Real aIntensity, |
30 | const Quantity_Color& aColor, |
31 | const gp_Vec& aLocation) |
32 | { |
33 | if (aIntensity < 0. || aIntensity > 1.) |
34 | { |
9775fa61 |
35 | throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive."); |
7fd59977 |
36 | } |
37 | myOnOff = aOnOff; |
38 | myIntensity = aIntensity; |
39 | myColor = aColor; |
40 | myLocation = aLocation; |
41 | } |
42 | |
43 | void Vrml_PointLight::SetOnOff(const Standard_Boolean aOnOff) |
44 | { |
45 | myOnOff = aOnOff; |
46 | } |
47 | |
48 | Standard_Boolean Vrml_PointLight::OnOff() const |
49 | { |
50 | return myOnOff; |
51 | } |
52 | |
53 | void Vrml_PointLight::SetIntensity(const Standard_Real aIntensity) |
54 | { |
55 | if (aIntensity < 0. || aIntensity > 1.) |
56 | { |
9775fa61 |
57 | throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive."); |
7fd59977 |
58 | } |
59 | myIntensity = aIntensity; |
60 | } |
61 | |
62 | Standard_Real Vrml_PointLight::Intensity() const |
63 | { |
64 | return myIntensity; |
65 | } |
66 | |
67 | void Vrml_PointLight::SetColor(const Quantity_Color& aColor) |
68 | { |
69 | myColor = aColor; |
70 | } |
71 | |
72 | Quantity_Color Vrml_PointLight::Color() const |
73 | { |
74 | return myColor; |
75 | } |
76 | |
77 | void Vrml_PointLight::SetLocation(const gp_Vec& aLocation) |
78 | { |
79 | myLocation = aLocation; |
80 | } |
81 | |
82 | gp_Vec Vrml_PointLight::Location() const |
83 | { |
84 | return myLocation; |
85 | } |
86 | |
87 | Standard_OStream& Vrml_PointLight::Print(Standard_OStream& anOStream) const |
88 | { |
586db386 |
89 | anOStream << "PointLight {\n"; |
7fd59977 |
90 | |
91 | if ( myOnOff != Standard_True ) |
92 | { |
586db386 |
93 | anOStream << " on\t\tFALSE\n"; |
94 | // anOStream << myOnOff << "\n"; |
7fd59977 |
95 | } |
96 | |
97 | if ( Abs(myIntensity - 1) > 0.0001 ) |
98 | { |
586db386 |
99 | anOStream << " intensity\t"; |
100 | anOStream << myIntensity << "\n"; |
7fd59977 |
101 | } |
102 | |
103 | if ( Abs(myColor.Red() - 1) > 0.0001 || |
104 | Abs(myColor.Green() - 1) > 0.0001 || |
105 | Abs(myColor.Blue() - 1) > 0.0001 ) |
106 | { |
ba00aab7 |
107 | NCollection_Vec3<Standard_Real> aColor_sRGB; |
108 | myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB); |
586db386 |
109 | anOStream << " color\t"; |
ba00aab7 |
110 | anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n"; |
7fd59977 |
111 | } |
112 | |
113 | if ( Abs(myLocation.X() - 0) > 0.0001 || |
114 | Abs(myLocation.Y() - 0) > 0.0001 || |
115 | Abs(myLocation.Z() - 1) > 0.0001 ) |
116 | { |
586db386 |
117 | anOStream << " location\t"; |
118 | anOStream << myLocation.X() << " " << myLocation.Y() << " " << myLocation.Z() << "\n"; |
7fd59977 |
119 | } |
120 | |
586db386 |
121 | anOStream << "}\n"; |
7fd59977 |
122 | return anOStream; |
123 | } |