0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / Vrml / Vrml_SpotLight.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 #include <Vrml_SpotLight.ixx>
15
16 Vrml_SpotLight::Vrml_SpotLight():
17   myOnOff(Standard_True),
18   myIntensity(1),
19   myDropOffRate(0), 
20   myCutOffAngle(0.785398) 
21 {
22   gp_Vec tmpVec(0,0,1);
23   myLocation = tmpVec;
24
25   tmpVec.SetCoord(0,0,-1);
26   myDirection = tmpVec;
27
28   Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
29   myColor = tmpColor;
30 }
31
32  Vrml_SpotLight::Vrml_SpotLight( const Standard_Boolean aOnOff, 
33                                  const Standard_Real aIntensity, 
34                                  const Quantity_Color& aColor, 
35                                  const gp_Vec& aLocation,
36                                  const gp_Vec& aDirection,
37                                  const Standard_Real aDropOffRate, 
38                                  const Standard_Real aCutOffAngle) 
39 {
40   myOnOff = aOnOff;
41   if (aIntensity < 0. || aIntensity > 1.)
42     {
43       Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
44     }
45   myIntensity = aIntensity;
46   myColor = aColor;
47   myLocation = aLocation;
48   myDirection = aDirection;
49   myDropOffRate = aDropOffRate;
50   myCutOffAngle = aCutOffAngle;
51 }
52
53 void Vrml_SpotLight::SetOnOff(const Standard_Boolean aOnOff)
54 {
55   myOnOff = aOnOff;
56 }
57
58 Standard_Boolean Vrml_SpotLight::OnOff() const 
59 {
60   return myOnOff;
61 }
62
63 void Vrml_SpotLight::SetIntensity(const Standard_Real aIntensity)
64 {
65   if (aIntensity < 0. || aIntensity > 1.)
66     {
67       Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
68     }
69   myIntensity = aIntensity;
70 }
71
72 Standard_Real Vrml_SpotLight::Intensity() const 
73 {
74   return myIntensity;
75 }
76
77 void Vrml_SpotLight::SetColor(const Quantity_Color& aColor)
78 {
79   myColor = aColor;
80 }
81
82 Quantity_Color Vrml_SpotLight::Color() const 
83 {
84   return  myColor;
85 }
86
87 void Vrml_SpotLight::SetLocation(const gp_Vec& aLocation)
88 {
89   myLocation = aLocation;
90 }
91
92 gp_Vec Vrml_SpotLight::Location() const 
93 {
94   return myLocation;
95 }
96
97 void Vrml_SpotLight::SetDirection(const gp_Vec& aDirection)
98 {
99   myDirection = aDirection;
100 }
101
102 gp_Vec Vrml_SpotLight::Direction() const 
103 {
104   return myDirection;
105 }
106
107 void Vrml_SpotLight::SetDropOffRate(const Standard_Real aDropOffRate)
108 {
109   myDropOffRate = aDropOffRate;
110 }
111
112 Standard_Real Vrml_SpotLight::DropOffRate() const 
113 {
114   return myDropOffRate;
115 }
116
117 void Vrml_SpotLight::SetCutOffAngle(const Standard_Real aCutOffAngle)
118 {
119   myCutOffAngle = aCutOffAngle;
120 }
121
122 Standard_Real Vrml_SpotLight::CutOffAngle() const 
123 {
124   return myCutOffAngle;
125 }
126
127 Standard_OStream& Vrml_SpotLight::Print(Standard_OStream& anOStream) const 
128 {
129  anOStream  << "SpotLight {" << endl;
130
131  if ( myOnOff != Standard_True )
132    {
133     anOStream  << "    on" << "\t\t" << "FALSE" << endl;
134 //    anOStream << myOnOff << endl;
135    }
136
137  if ( Abs(myIntensity - 1) > 0.0001 )
138    {
139     anOStream  << "    intensity" << '\t';
140     anOStream << myIntensity << endl;
141    }
142
143  if ( Abs(myColor.Red() - 1) > 0.0001 || 
144      Abs(myColor.Green() - 1) > 0.0001 || 
145      Abs(myColor.Blue() - 1) > 0.0001 )
146    {
147     anOStream  << "    color" << '\t';
148     anOStream << myColor.Red() << ' ' << myColor.Green() << ' ' << myColor.Blue() << endl;
149    }
150
151  if ( Abs(myLocation.X() - 0) > 0.0001 || 
152      Abs(myLocation.Y() - 0) > 0.0001 || 
153      Abs(myLocation.Z() - 1) > 0.0001 ) 
154    {
155     anOStream  << "    location" << '\t';
156     anOStream << myLocation.X() << ' ' << myLocation.Y() << ' ' << myLocation.Z() << endl;
157    }
158
159  if ( Abs(myDirection.X() - 0) > 0.0001 || 
160      Abs(myDirection.Y() - 0) > 0.0001 || 
161      Abs(myDirection.Z() + 1) > 0.0001 ) 
162    {
163     anOStream  << "    direction" << '\t';
164     anOStream << myDirection.X() << ' ' << myDirection.Y() << ' ' << myDirection.Z() << endl;
165    }
166
167  if ( Abs(myDropOffRate - 0) > 0.0001 )
168    {
169     anOStream  << "    dropOffRate" << '\t';
170     anOStream << myDropOffRate << endl;
171    }
172
173  if ( Abs(myCutOffAngle - 0.785398) > 0.0000001 )
174    {
175     anOStream  << "    cutOffAngle" << '\t';
176     anOStream << myCutOffAngle << endl;
177    }
178
179  anOStream  << '}' << endl;
180  return anOStream;
181 }