1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #define BUC60488 //GG_10/10/99 Set correctly all fields
21 #include <Prs3d_Drawer.ixx>
23 Prs3d_Drawer::Prs3d_Drawer(): myNbPoints(30),myIsoOnPlane(Standard_False),
24 myFreeBoundaryDraw(Standard_True),
25 myUnFreeBoundaryDraw(Standard_True),
26 myWireDraw(Standard_True),
28 myShadingAspect( new Prs3d_ShadingAspect()),
30 myShadingAspectGlobal(Standard_True),
31 myChordialDeviation(0.0001),
32 myTypeOfDeflection(Aspect_TOD_RELATIVE),
33 myMaximalParameterValue(500000.),
34 myDeviationCoefficient(0.001),
35 myHLRDeviationCoefficient(0.02),
36 myDeviationAngle(12*M_PI/180),
37 myHLRAngle(20*M_PI/180),
38 myLineDrawArrow(Standard_False),
39 myDrawHiddenLine(Standard_False),
40 myFaceBoundaryDraw(Standard_False),
41 myTypeOfHLR(Prs3d_TOH_PolyAlgo)
45 void Prs3d_Drawer::SetTypeOfDeflection(const Aspect_TypeOfDeflection aTypeOfDeflection){
47 myTypeOfDeflection = aTypeOfDeflection;}
49 Aspect_TypeOfDeflection Prs3d_Drawer::TypeOfDeflection() const {
51 return myTypeOfDeflection;
56 void Prs3d_Drawer::SetIsoOnPlane(const Standard_Boolean OnOff)
62 Standard_Boolean Prs3d_Drawer::IsoOnPlane()const
68 Standard_Integer Prs3d_Drawer::Discretisation() const
74 void Prs3d_Drawer::SetDiscretisation(const Standard_Integer d)
80 void Prs3d_Drawer::SetMaximalChordialDeviation(
81 const Quantity_Length aChordialDeviation) {
82 myChordialDeviation = aChordialDeviation;
85 Quantity_Length Prs3d_Drawer::MaximalChordialDeviation() const {
86 return myChordialDeviation;
90 //=======================================================================
91 //function : SetDeviationCoefficient
93 //=======================================================================
95 void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real aCoefficient) {
97 myDeviationCoefficient = aCoefficient;
100 //=======================================================================
101 //function : DeviationCoefficient
103 //=======================================================================
105 Standard_Real Prs3d_Drawer::DeviationCoefficient () const {
107 return myDeviationCoefficient;
110 //=======================================================================
111 //function : SetHLRDeviationCoefficient
113 //=======================================================================
115 void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real aCoefficient) {
117 myHLRDeviationCoefficient = aCoefficient;
120 //=======================================================================
121 //function : HLRDeviationCoefficient
123 //=======================================================================
125 Standard_Real Prs3d_Drawer::HLRDeviationCoefficient () const {
127 return myHLRDeviationCoefficient;
130 //=======================================================================
131 //function : SetHLRAngle
133 //=======================================================================
135 void Prs3d_Drawer::SetHLRAngle (const Standard_Real anAngle) {
137 myHLRAngle = anAngle;
140 //=======================================================================
141 //function : HLRAngle
143 //=======================================================================
145 Standard_Real Prs3d_Drawer::HLRAngle () const {
150 //=======================================================================
151 //function : SetDeviationAngle
153 //=======================================================================
155 void Prs3d_Drawer::SetDeviationAngle (const Standard_Real anAngle)
157 myDeviationAngle = anAngle;
160 //=======================================================================
161 //function : DeviationAngle
163 //=======================================================================
165 Standard_Real Prs3d_Drawer::DeviationAngle () const
167 return myDeviationAngle;
171 void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real Value) {
172 myMaximalParameterValue = Value;
175 Standard_Real Prs3d_Drawer::MaximalParameterValue () const {
176 return myMaximalParameterValue;
179 Handle (Prs3d_IsoAspect) Prs3d_Drawer::UIsoAspect (){
181 if (myUIsoAspect.IsNull())
182 myUIsoAspect = new Prs3d_IsoAspect
183 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
188 void Prs3d_Drawer::SetUIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
189 myUIsoAspect = anAspect;
192 Handle (Prs3d_IsoAspect) Prs3d_Drawer::VIsoAspect () {
193 if (myVIsoAspect.IsNull())
194 myVIsoAspect = new Prs3d_IsoAspect
195 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
200 void Prs3d_Drawer::SetVIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
201 myVIsoAspect = anAspect;
204 Handle (Prs3d_LineAspect) Prs3d_Drawer::FreeBoundaryAspect () {
205 if (myFreeBoundaryAspect.IsNull())
206 myFreeBoundaryAspect = new Prs3d_LineAspect
207 (Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.);
209 return myFreeBoundaryAspect;
212 void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& anAspect) {
213 myFreeBoundaryAspect = anAspect;
216 void Prs3d_Drawer::SetFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
217 myFreeBoundaryDraw = OnOff;
220 Standard_Boolean Prs3d_Drawer::FreeBoundaryDraw () const {
221 return myFreeBoundaryDraw;
224 Handle (Prs3d_LineAspect) Prs3d_Drawer::UnFreeBoundaryAspect (){
225 if (myUnFreeBoundaryAspect.IsNull())
226 myUnFreeBoundaryAspect = new Prs3d_LineAspect
227 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
228 return myUnFreeBoundaryAspect;
231 void Prs3d_Drawer::SetUnFreeBoundaryAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
232 myUnFreeBoundaryAspect = anAspect;
235 void Prs3d_Drawer::SetUnFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
236 myUnFreeBoundaryDraw = OnOff;
239 Standard_Boolean Prs3d_Drawer::UnFreeBoundaryDraw () const {
240 return myUnFreeBoundaryDraw;
243 Handle (Prs3d_LineAspect) Prs3d_Drawer::WireAspect () {
244 if (myWireAspect.IsNull())
245 myWireAspect = new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_SOLID,1.);
250 void Prs3d_Drawer::SetWireAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
251 myWireAspect = anAspect;
253 void Prs3d_Drawer::SetWireDraw ( const Standard_Boolean OnOff ) {
257 Standard_Boolean Prs3d_Drawer::WireDraw () const {
262 Handle (Prs3d_LineAspect) Prs3d_Drawer::LineAspect () {
263 if (myLineAspect.IsNull())
264 myLineAspect = new Prs3d_LineAspect
265 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
269 void Prs3d_Drawer::SetLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
270 myLineAspect = anAspect;
273 Handle (Prs3d_TextAspect) Prs3d_Drawer::TextAspect () {
274 if (myTextAspect.IsNull())
275 myTextAspect = new Prs3d_TextAspect();
280 void Prs3d_Drawer::SetTextAspect ( const Handle(Prs3d_TextAspect)& anAspect) {
281 myTextAspect = anAspect;
284 Handle (Prs3d_ShadingAspect) Prs3d_Drawer::ShadingAspect () {
285 if (myShadingAspect.IsNull())
286 myShadingAspect = new Prs3d_ShadingAspect();
288 return myShadingAspect;
291 void Prs3d_Drawer::SetShadingAspect ( const Handle(Prs3d_ShadingAspect)& anAspect) {
292 myShadingAspect = anAspect;
295 void Prs3d_Drawer::SetShadingAspectGlobal(const Standard_Boolean aValue) {
296 myShadingAspectGlobal = aValue;
299 Standard_Boolean Prs3d_Drawer::ShadingAspectGlobal() const {
301 return myShadingAspectGlobal;
305 void Prs3d_Drawer::SetLineArrowDraw ( const Standard_Boolean OnOff ) {
306 myLineDrawArrow = OnOff;
309 Standard_Boolean Prs3d_Drawer::LineArrowDraw () const {
310 return myLineDrawArrow;
313 Handle (Prs3d_ArrowAspect) Prs3d_Drawer::ArrowAspect() {
314 if (myArrowAspect.IsNull())
315 myArrowAspect = new Prs3d_ArrowAspect;
317 return myArrowAspect;
320 void Prs3d_Drawer::SetArrowAspect ( const Handle(Prs3d_ArrowAspect)& anAspect) {
321 myArrowAspect = anAspect;
324 Handle (Prs3d_PointAspect) Prs3d_Drawer::PointAspect() {
325 if (myPointAspect.IsNull())
326 myPointAspect = new Prs3d_PointAspect
327 (Aspect_TOM_PLUS,Quantity_NOC_YELLOW,1.);
329 return myPointAspect;
332 void Prs3d_Drawer::SetPointAspect ( const Handle(Prs3d_PointAspect)& anAspect) {
333 myPointAspect = anAspect;
336 Standard_Boolean Prs3d_Drawer::DrawHiddenLine () const {return myDrawHiddenLine;}
338 void Prs3d_Drawer::EnableDrawHiddenLine () {myDrawHiddenLine=Standard_True;}
340 void Prs3d_Drawer::DisableDrawHiddenLine () {myDrawHiddenLine=Standard_False;}
342 Handle (Prs3d_LineAspect) Prs3d_Drawer::HiddenLineAspect () {
343 if (myHiddenLineAspect.IsNull())
344 myHiddenLineAspect = new Prs3d_LineAspect
345 (Quantity_NOC_YELLOW,Aspect_TOL_DASH,0.5);
347 return myHiddenLineAspect;
350 void Prs3d_Drawer::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
351 myHiddenLineAspect = anAspect;
354 Handle (Prs3d_LineAspect) Prs3d_Drawer::SeenLineAspect () {
355 if (mySeenLineAspect.IsNull())
356 mySeenLineAspect = new Prs3d_LineAspect
357 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
359 return mySeenLineAspect;
362 void Prs3d_Drawer::SetSeenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
363 mySeenLineAspect = anAspect;
366 Handle (Prs3d_LineAspect) Prs3d_Drawer::VectorAspect () {
367 if (myVectorAspect.IsNull())
368 myVectorAspect = new Prs3d_LineAspect
369 (Quantity_NOC_SKYBLUE,Aspect_TOL_SOLID,1.);
371 return myVectorAspect;
374 void Prs3d_Drawer::SetVectorAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
375 myVectorAspect = anAspect;
378 Handle (Prs3d_DatumAspect) Prs3d_Drawer::DatumAspect () {
379 if (myDatumAspect.IsNull())
380 myDatumAspect = new Prs3d_DatumAspect;
382 return myDatumAspect;
385 void Prs3d_Drawer::SetDatumAspect ( const Handle(Prs3d_DatumAspect)& anAspect) {
386 myDatumAspect = anAspect;
389 Handle (Prs3d_PlaneAspect) Prs3d_Drawer::PlaneAspect () {
390 if (myPlaneAspect.IsNull())
391 myPlaneAspect = new Prs3d_PlaneAspect;
393 return myPlaneAspect;
396 void Prs3d_Drawer::SetPlaneAspect ( const Handle(Prs3d_PlaneAspect)& anAspect) {
397 myPlaneAspect = anAspect;
400 Handle (Prs3d_DimensionAspect) Prs3d_Drawer::DimensionAspect ()
402 if (myDimensionAspect.IsNull())
403 myDimensionAspect = new Prs3d_DimensionAspect;
405 return myDimensionAspect;
408 void Prs3d_Drawer::SetDimensionAspect ( const Handle(Prs3d_DimensionAspect)& theAspect)
410 myDimensionAspect = theAspect;
414 Handle (Prs3d_LineAspect) Prs3d_Drawer::SectionAspect () {
415 if (mySectionAspect.IsNull())
416 mySectionAspect = new Prs3d_LineAspect
417 (Quantity_NOC_ORANGE,Aspect_TOL_SOLID,1.);
419 return mySectionAspect;
422 void Prs3d_Drawer::SetSectionAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
423 mySectionAspect = anAspect;
426 // =======================================================================
427 // function : SetFaceBoundaryDraw
429 // =======================================================================
430 void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
432 myFaceBoundaryDraw = theIsEnabled;
435 // =======================================================================
436 // function : IsFaceBoundaryDraw
438 // =======================================================================
439 Standard_Boolean Prs3d_Drawer::IsFaceBoundaryDraw () const
441 return myFaceBoundaryDraw;
444 // =======================================================================
445 // function : SetFaceBoundaryAspect
447 // =======================================================================
448 void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
450 myFaceBoundaryAspect = theAspect;
453 // =======================================================================
454 // function : FaceBoundaryAspect
456 // =======================================================================
457 Handle_Prs3d_LineAspect Prs3d_Drawer::FaceBoundaryAspect ()
459 if (myFaceBoundaryAspect.IsNull ())
461 myFaceBoundaryAspect =
462 new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
465 return myFaceBoundaryAspect;
468 // =======================================================================
469 // function : SetTypeOfHLR
470 // purpose : set type of HLR algorithm
471 // =======================================================================
473 void Prs3d_Drawer::SetTypeOfHLR ( const Prs3d_TypeOfHLR theTypeOfHLR)
475 myTypeOfHLR = theTypeOfHLR;
478 // =======================================================================
479 // function : TypeOfHLR
480 // purpose : gets type of HLR algorithm
481 // =======================================================================
483 Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR ( ) const