0033041: Coding - get rid of unused headers [TopTools to Xw]
[occt.git] / src / Vrml / Vrml_DirectionalLight.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Vrml_DirectionalLight.hxx>
16
17 Vrml_DirectionalLight::Vrml_DirectionalLight():
18   myOnOff(Standard_True),
19   myIntensity(1),
20   myColor (Quantity_NOC_WHITE),
21   myDirection (0, 0, -1)
22 {
23   //
24 }
25
26  Vrml_DirectionalLight::Vrml_DirectionalLight(const Standard_Boolean aOnOff, 
27                                               const Standard_Real aIntensity, 
28                                               const Quantity_Color& aColor, 
29                                               const gp_Vec& aDirection)
30 {
31   myOnOff = aOnOff;
32   if (aIntensity < 0. || aIntensity > 1.)
33     {
34       throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
35     }
36   myIntensity = aIntensity;
37   myColor = aColor;
38   myDirection = aDirection;
39 }
40
41 void Vrml_DirectionalLight::SetOnOff(const Standard_Boolean aOnOff)
42 {
43   myOnOff = aOnOff;
44 }
45
46 Standard_Boolean Vrml_DirectionalLight::OnOff() const 
47 {
48   return myOnOff;
49 }
50
51 void Vrml_DirectionalLight::SetIntensity(const Standard_Real aIntensity)
52 {
53   if (aIntensity < 0. || aIntensity > 1.)
54     {
55       throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
56     }
57   myIntensity = aIntensity;
58 }
59
60 Standard_Real Vrml_DirectionalLight::Intensity() const 
61 {
62   return myIntensity;
63 }
64
65 void Vrml_DirectionalLight::SetColor(const Quantity_Color& aColor)
66 {
67   myColor = aColor;
68 }
69
70 Quantity_Color Vrml_DirectionalLight::Color() const 
71 {
72   return  myColor;
73 }
74
75 void Vrml_DirectionalLight::SetDirection(const gp_Vec& aDirection)
76 {
77   myDirection = aDirection;
78 }
79
80 gp_Vec Vrml_DirectionalLight::Direction() const 
81 {
82   return myDirection;
83 }
84
85 Standard_OStream& Vrml_DirectionalLight::Print(Standard_OStream& anOStream) const 
86 {
87  anOStream  << "DirectionalLight {\n";
88
89  if ( myOnOff != Standard_True )
90    {
91     anOStream  << "    on\t\tFALSE\n";
92 //    anOStream << myOnOff << "\n";
93    }
94
95  if ( Abs(myIntensity - 1) > 0.0001 )
96    {
97     anOStream  << "    intensity\t";
98     anOStream << myIntensity << "\n";
99    }
100
101  if ( Abs(myColor.Red() - 1) > 0.0001 || 
102       Abs(myColor.Green() - 1) > 0.0001 || 
103       Abs(myColor.Blue() - 1) > 0.0001 )
104    {
105     NCollection_Vec3<Standard_Real> aColor_sRGB;
106     myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
107     anOStream  << "    color\t";
108     anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
109    }
110
111  if ( Abs(myDirection.X() - 0) > 0.0001 || 
112      Abs(myDirection.Y() - 0) > 0.0001 || 
113      Abs(myDirection.Z() + 1) > 0.0001 ) 
114    {
115     anOStream  << "    direction" << '\t';
116     anOStream << myDirection.X() << " " << myDirection.Y() << " " << myDirection.Z() << "\n";
117    }
118
119  anOStream  << "}\n";
120  return anOStream;
121 }