1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
16 #include <Quantity_Color.hxx>
17 #include <Vrml_PointLight.hxx>
19 Vrml_PointLight::Vrml_PointLight():
20 myOnOff(Standard_True),
26 Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
30 Vrml_PointLight::Vrml_PointLight( const Standard_Boolean aOnOff,
31 const Standard_Real aIntensity,
32 const Quantity_Color& aColor,
33 const gp_Vec& aLocation)
35 if (aIntensity < 0. || aIntensity > 1.)
37 throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
40 myIntensity = aIntensity;
42 myLocation = aLocation;
45 void Vrml_PointLight::SetOnOff(const Standard_Boolean aOnOff)
50 Standard_Boolean Vrml_PointLight::OnOff() const
55 void Vrml_PointLight::SetIntensity(const Standard_Real aIntensity)
57 if (aIntensity < 0. || aIntensity > 1.)
59 throw Standard_Failure("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
61 myIntensity = aIntensity;
64 Standard_Real Vrml_PointLight::Intensity() const
69 void Vrml_PointLight::SetColor(const Quantity_Color& aColor)
74 Quantity_Color Vrml_PointLight::Color() const
79 void Vrml_PointLight::SetLocation(const gp_Vec& aLocation)
81 myLocation = aLocation;
84 gp_Vec Vrml_PointLight::Location() const
89 Standard_OStream& Vrml_PointLight::Print(Standard_OStream& anOStream) const
91 anOStream << "PointLight {\n";
93 if ( myOnOff != Standard_True )
95 anOStream << " on\t\tFALSE\n";
96 // anOStream << myOnOff << "\n";
99 if ( Abs(myIntensity - 1) > 0.0001 )
101 anOStream << " intensity\t";
102 anOStream << myIntensity << "\n";
105 if ( Abs(myColor.Red() - 1) > 0.0001 ||
106 Abs(myColor.Green() - 1) > 0.0001 ||
107 Abs(myColor.Blue() - 1) > 0.0001 )
109 anOStream << " color\t";
110 anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
113 if ( Abs(myLocation.X() - 0) > 0.0001 ||
114 Abs(myLocation.Y() - 0) > 0.0001 ||
115 Abs(myLocation.Z() - 1) > 0.0001 )
117 anOStream << " location\t";
118 anOStream << myLocation.X() << " " << myLocation.Y() << " " << myLocation.Z() << "\n";