0030520: VIS - IVtkTools_ShapePicker::GetPickPosition() returns incorrect point
[occt.git] / src / VrmlConverter / VrmlConverter_Drawer.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 <Standard_Type.hxx>
16 #include <Vrml_Material.hxx>
17 #include <VrmlConverter_Drawer.hxx>
18 #include <VrmlConverter_IsoAspect.hxx>
19 #include <VrmlConverter_LineAspect.hxx>
20 #include <VrmlConverter_PointAspect.hxx>
21 #include <VrmlConverter_ShadingAspect.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(VrmlConverter_Drawer,Standard_Transient)
24
25 VrmlConverter_Drawer::VrmlConverter_Drawer():
26   myNbPoints(17),
27   myIsoOnPlane(Standard_False),
28   myFreeBoundaryDraw(Standard_True),
29   myUnFreeBoundaryDraw(Standard_True),
30   myWireDraw(Standard_True),
31   myChordialDeviation(0.1),
32   myTypeOfDeflection(Aspect_TOD_RELATIVE),
33   myMaximalParameterValue(500.), 
34   myDeviationCoefficient(0.001),
35   myDrawHiddenLine(Standard_False)
36 {
37 }
38
39 void VrmlConverter_Drawer::SetTypeOfDeflection(const Aspect_TypeOfDeflection aTypeOfDeflection)
40 {
41  myTypeOfDeflection = aTypeOfDeflection;
42 }
43
44 Aspect_TypeOfDeflection VrmlConverter_Drawer::TypeOfDeflection() const 
45 {
46  return myTypeOfDeflection;
47 }
48
49 void VrmlConverter_Drawer::SetMaximalChordialDeviation(const Standard_Real aChordialDeviation)
50 {
51  myChordialDeviation = aChordialDeviation;
52 }
53
54 Standard_Real VrmlConverter_Drawer::MaximalChordialDeviation() const 
55 {
56  return myChordialDeviation;
57 }
58
59 void VrmlConverter_Drawer::SetDeviationCoefficient(const Standard_Real aCoefficient)
60 {
61  myDeviationCoefficient = aCoefficient;
62 }
63
64 Standard_Real VrmlConverter_Drawer::DeviationCoefficient() const 
65 {
66  return myDeviationCoefficient;
67 }
68
69 void VrmlConverter_Drawer::SetDiscretisation(const Standard_Integer d)
70 {
71  myNbPoints = d;
72 }
73
74 Standard_Integer VrmlConverter_Drawer::Discretisation() const 
75 {
76  return myNbPoints;
77 }
78
79 void VrmlConverter_Drawer::SetMaximalParameterValue(const Standard_Real Value)
80 {
81  myMaximalParameterValue = Value;
82 }
83
84 Standard_Real VrmlConverter_Drawer::MaximalParameterValue() const 
85 {
86  return myMaximalParameterValue;
87 }
88
89 void VrmlConverter_Drawer::SetIsoOnPlane(const Standard_Boolean OnOff)
90 {
91  myIsoOnPlane = OnOff;
92 }
93
94 Standard_Boolean VrmlConverter_Drawer::IsoOnPlane()const
95 {
96  return myIsoOnPlane;
97 }
98
99 Handle (VrmlConverter_IsoAspect) VrmlConverter_Drawer::UIsoAspect()
100 {
101   if (myUIsoAspect.IsNull()) 
102     {
103       Handle(Vrml_Material) m = new Vrml_Material;
104       myUIsoAspect = new VrmlConverter_IsoAspect (m, Standard_False, 1);
105     }
106   return myUIsoAspect;
107 }
108
109 void VrmlConverter_Drawer::SetUIsoAspect ( const Handle(VrmlConverter_IsoAspect)& anAspect) 
110 {
111  myUIsoAspect = anAspect;
112 }
113
114 Handle (VrmlConverter_IsoAspect) VrmlConverter_Drawer::VIsoAspect ()
115 {
116   if (myVIsoAspect.IsNull()) 
117     {
118       Handle(Vrml_Material) m = new Vrml_Material;
119       myVIsoAspect = new VrmlConverter_IsoAspect (m, Standard_False, 1);
120     }
121  return myVIsoAspect;
122 }
123
124 void VrmlConverter_Drawer::SetVIsoAspect ( const Handle(VrmlConverter_IsoAspect)& anAspect) 
125 {
126  myVIsoAspect = anAspect;
127 }
128
129 Handle(VrmlConverter_LineAspect) VrmlConverter_Drawer::FreeBoundaryAspect() 
130 {
131   if (myFreeBoundaryAspect.IsNull())
132     {
133       Handle(Vrml_Material) m = new Vrml_Material;
134       myFreeBoundaryAspect = new VrmlConverter_LineAspect(m, Standard_False);
135     }
136   return myFreeBoundaryAspect;
137 }
138
139 void VrmlConverter_Drawer::SetFreeBoundaryAspect(const Handle(VrmlConverter_LineAspect)& anAspect)
140 {
141  myFreeBoundaryAspect = anAspect;
142 }
143
144 void VrmlConverter_Drawer::SetFreeBoundaryDraw(const Standard_Boolean OnOff)
145 {
146  myFreeBoundaryDraw = OnOff;
147 }
148
149 Standard_Boolean VrmlConverter_Drawer::FreeBoundaryDraw() const 
150 {
151  return myFreeBoundaryDraw;
152 }
153
154 Handle(VrmlConverter_LineAspect) VrmlConverter_Drawer::WireAspect() 
155 {
156   if (myWireAspect.IsNull())
157     {
158       Handle(Vrml_Material) m = new Vrml_Material;
159       myWireAspect = new VrmlConverter_LineAspect(m, Standard_False);
160     }
161   return myWireAspect;
162 }
163
164 void VrmlConverter_Drawer::SetWireAspect(const Handle(VrmlConverter_LineAspect)& anAspect)
165 {
166  myWireAspect = anAspect;
167 }
168
169 void VrmlConverter_Drawer::SetWireDraw(const Standard_Boolean OnOff)
170 {
171  myWireDraw = OnOff;
172 }
173
174 Standard_Boolean VrmlConverter_Drawer::WireDraw() const 
175 {
176  return myWireDraw;
177 }
178
179 Handle(VrmlConverter_LineAspect) VrmlConverter_Drawer::UnFreeBoundaryAspect() 
180 {
181   if (myUnFreeBoundaryAspect.IsNull())
182     {
183       Handle(Vrml_Material) m = new Vrml_Material;
184       myUnFreeBoundaryAspect = new VrmlConverter_LineAspect(m, Standard_False);
185     }
186   return myUnFreeBoundaryAspect;
187 }
188
189 void VrmlConverter_Drawer::SetUnFreeBoundaryAspect(const Handle(VrmlConverter_LineAspect)& anAspect)
190 {
191  myUnFreeBoundaryAspect = anAspect;
192 }
193
194 void VrmlConverter_Drawer::SetUnFreeBoundaryDraw(const Standard_Boolean OnOff)
195 {
196  myUnFreeBoundaryDraw = OnOff;
197 }
198
199 Standard_Boolean VrmlConverter_Drawer::UnFreeBoundaryDraw() const 
200 {
201  return myUnFreeBoundaryDraw;
202 }
203
204 Handle(VrmlConverter_LineAspect) VrmlConverter_Drawer::LineAspect() 
205 {
206   if (myLineAspect.IsNull())
207     {
208       Handle(Vrml_Material) m = new Vrml_Material;
209       myLineAspect = new VrmlConverter_LineAspect(m, Standard_False);
210     }
211   return myLineAspect;
212 }
213
214 void VrmlConverter_Drawer::SetLineAspect(const Handle(VrmlConverter_LineAspect)& anAspect)
215 {
216  myLineAspect = anAspect;
217 }
218
219 Handle(VrmlConverter_PointAspect) VrmlConverter_Drawer::PointAspect() 
220 {
221   if (myPointAspect.IsNull())
222     {
223       Handle(Vrml_Material) m = new Vrml_Material;
224       myPointAspect = new VrmlConverter_PointAspect(m, Standard_False);
225     }
226  return myPointAspect;
227 }
228
229 void VrmlConverter_Drawer::SetPointAspect(const Handle(VrmlConverter_PointAspect)& anAspect)
230 {
231  myPointAspect = anAspect;
232 }
233
234 Handle(VrmlConverter_ShadingAspect) VrmlConverter_Drawer::ShadingAspect() 
235 {
236   if (myShadingAspect.IsNull())
237     {
238       myShadingAspect = new VrmlConverter_ShadingAspect;
239     }
240  return myShadingAspect;
241 }
242
243 void VrmlConverter_Drawer::SetShadingAspect(const Handle(VrmlConverter_ShadingAspect)& anAspect)
244 {
245  myShadingAspect = anAspect;
246 }
247
248 Standard_Boolean VrmlConverter_Drawer::DrawHiddenLine () const {return myDrawHiddenLine;}
249
250 void VrmlConverter_Drawer::EnableDrawHiddenLine () {myDrawHiddenLine=Standard_True;}
251
252 void VrmlConverter_Drawer::DisableDrawHiddenLine () {myDrawHiddenLine=Standard_False;}
253
254 Handle (VrmlConverter_LineAspect) VrmlConverter_Drawer::HiddenLineAspect () 
255 {
256   if (myHiddenLineAspect.IsNull())
257     {
258       Handle(Vrml_Material) m = new Vrml_Material;
259       myHiddenLineAspect = new VrmlConverter_LineAspect(m, Standard_False);
260     }
261   return myHiddenLineAspect;
262 }
263
264 void VrmlConverter_Drawer::SetHiddenLineAspect ( const Handle(VrmlConverter_LineAspect)& anAspect) 
265 {
266  myHiddenLineAspect = anAspect;
267 }
268
269 Handle (VrmlConverter_LineAspect) VrmlConverter_Drawer::SeenLineAspect ()  
270 {
271   if (mySeenLineAspect.IsNull())
272     {
273       Handle(Vrml_Material) m = new Vrml_Material;
274       mySeenLineAspect = new VrmlConverter_LineAspect(m, Standard_False);
275     }
276   return mySeenLineAspect;
277 }
278
279 void VrmlConverter_Drawer::SetSeenLineAspect ( const Handle(VrmlConverter_LineAspect)& anAspect) 
280 {
281  mySeenLineAspect = anAspect;
282 }