0027828: Reference documentation of AIS_Trihedron contains invalid information about...
[occt.git] / src / AIS / AIS_Shape.cxx
1 // Created on: 1996-12-20
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <AIS_GraphicTool.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <AIS_Shape.hxx>
21 #include <Aspect_TypeOfLine.hxx>
22 #include <Bnd_Box.hxx>
23 #include <BRep_Builder.hxx>
24 #include <BRepBndLib.hxx>
25 #include <BRepTools.hxx>
26 #include <BRepTools_ShapeSet.hxx>
27 #include <Geom_Transformation.hxx>
28 #include <gp_Pnt.hxx>
29 #include <Graphic3d_ArrayOfPolylines.hxx>
30 #include <Graphic3d_AspectFillArea3d.hxx>
31 #include <Graphic3d_AspectLine3d.hxx>
32 #include <Graphic3d_AspectMarker3d.hxx>
33 #include <Graphic3d_AspectText3d.hxx>
34 #include <Graphic3d_Group.hxx>
35 #include <Graphic3d_MaterialAspect.hxx>
36 #include <Graphic3d_SequenceOfGroup.hxx>
37 #include <Graphic3d_Structure.hxx>
38 #include <HLRBRep.hxx>
39 #include <OSD_Timer.hxx>
40 #include <Precision.hxx>
41 #include <Prs3d.hxx>
42 #include <Prs3d_Drawer.hxx>
43 #include <Prs3d_IsoAspect.hxx>
44 #include <Prs3d_Presentation.hxx>
45 #include <Prs3d_Projector.hxx>
46 #include <Prs3d_Root.hxx>
47 #include <Prs3d_ShadingAspect.hxx>
48 #include <StdPrs_BndBox.hxx>
49 #include <StdPrs_ToolTriangulatedShape.hxx>
50 #include <PrsMgr_ModedPresentation.hxx>
51 #include <Quantity_Color.hxx>
52 #include <Select3D_SensitiveBox.hxx>
53 #include <Select3D_SensitiveEntity.hxx>
54 #include <Standard_ErrorHandler.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_Type.hxx>
57 #include <StdPrs_HLRPolyShape.hxx>
58 #include <StdPrs_HLRShape.hxx>
59 #include <StdPrs_ShadedShape.hxx>
60 #include <StdPrs_WFShape.hxx>
61 #include <StdSelect.hxx>
62 #include <StdSelect_BRepOwner.hxx>
63 #include <StdSelect_BRepSelectionTool.hxx>
64 #include <StdSelect_DisplayMode.hxx>
65 #include <TColStd_ListIteratorOfListOfInteger.hxx>
66 #include <TopExp.hxx>
67 #include <TopExp_Explorer.hxx>
68 #include <TopoDS_Iterator.hxx>
69 #include <TopoDS_Shape.hxx>
70
71 IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
72
73 static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
74 {
75   TColStd_ListIteratorOfListOfInteger It(LL);
76   for(;It.More();It.Next()){
77     if(It.Value()==aMode) 
78       return Standard_True;}
79   return Standard_False;
80 }
81
82 //==================================================
83 // Function: 
84 // Purpose :
85 //==================================================
86
87 AIS_Shape::
88 AIS_Shape(const TopoDS_Shape& shap):
89 AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant),
90 myInitAng(0.)
91 {
92   Set (shap);
93   SetHilightMode(0);
94 }
95
96 //=======================================================================
97 //function : Type
98 //purpose  : 
99 //=======================================================================
100 AIS_KindOfInteractive AIS_Shape::Type() const 
101 {return AIS_KOI_Shape;}
102
103
104 //=======================================================================
105 //function : Signature
106 //purpose  : 
107 //=======================================================================
108 Standard_Integer AIS_Shape::Signature() const 
109 {return 0;}
110
111 //=======================================================================
112 //function : AcceptShapeDecomposition
113 //purpose  : 
114 //=======================================================================
115 Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const 
116 {return Standard_True;}
117
118 //=======================================================================
119 //function : Compute
120 //purpose  : 
121 //=======================================================================
122 void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
123                         const Handle(Prs3d_Presentation)& aPrs,
124                         const Standard_Integer theMode)
125 {  
126   if(myshape.IsNull()) return;
127
128   // wire,edge,vertex -> pas de HLR + priorite display superieure
129   Standard_Integer TheType = (Standard_Integer) myshape.ShapeType();
130   if(TheType>4 && TheType<8) {
131     aPrs->SetVisual(Graphic3d_TOS_ALL);
132     aPrs->SetDisplayPriority(TheType+2);
133   }
134   // Shape vide -> Assemblage vide.
135   if (myshape.ShapeType() == TopAbs_COMPOUND) {
136     TopoDS_Iterator anExplor (myshape);
137
138     if (!anExplor.More()) {
139       return;
140     }
141   }
142
143   if (IsInfinite())
144   {
145     aPrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
146   }
147
148   switch (theMode)
149   {
150     case AIS_WireFrame:
151     {
152       StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
153       try
154       {
155         OCC_CATCH_SIGNALS
156         StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
157       }
158       catch (Standard_Failure)
159       {
160       #ifdef OCCT_DEBUG
161         cout << "AIS_Shape::Compute() failed" << endl;
162         cout << "a Shape should be incorrect : No Compute can be maked on it " << endl;
163       #endif
164         // presentation of the bounding box is calculated
165         //      Compute(aPresentationManager,aPrs,2);
166       }
167       break;
168     }
169     case AIS_Shaded:
170     {
171       StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
172       if ((Standard_Integer) myshape.ShapeType() > 4)
173       {
174         StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
175       }
176       else
177       {
178         if (IsInfinite())
179         {
180           StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
181         }
182         else
183         {
184           try
185           {
186             OCC_CATCH_SIGNALS
187             StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer);
188           }
189           catch (Standard_Failure)
190           {
191           #ifdef OCCT_DEBUG
192             cout << "AIS_Shape::Compute() in ShadingMode failed" << endl;
193           #endif
194             StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
195           }
196         }
197       }
198       Standard_Real aTransparency = Transparency() ;
199       if (aTransparency > 0.0)
200       {
201         SetTransparency (aTransparency);
202       }
203       break;
204     }
205
206     // Bounding box.
207     case 2:
208     {
209       if (IsInfinite())
210       {
211         StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
212       }
213       else
214       {
215         StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
216       }
217     }
218   }
219
220   // Recompute hidden line presentation (if necessary).
221   aPrs->ReCompute();
222 }
223
224 //=======================================================================
225 //function : Compute
226 //purpose  : Hidden Line Removal
227 //=======================================================================
228 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
229                         const Handle(Prs3d_Presentation)& aPresentation)
230 {
231   Compute(aProjector,aPresentation,myshape);
232 }
233
234 //=======================================================================
235 //function : Compute
236 //purpose  : 
237 //=======================================================================
238
239 void AIS_Shape::Compute(const Handle(Prs3d_Projector)&     aProjector,
240                         const Handle(Geom_Transformation)& TheTrsf,
241                         const Handle(Prs3d_Presentation)&  aPresentation)
242 {
243   const TopLoc_Location& loc = myshape.Location();
244   TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
245   Compute(aProjector,aPresentation,shbis);
246 }
247
248 //=======================================================================
249 //function : Compute
250 //purpose  : 
251 //=======================================================================
252
253 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
254                         const Handle(Prs3d_Presentation)& aPresentation,
255                         const TopoDS_Shape& SH)
256 {
257   if (SH.ShapeType() == TopAbs_COMPOUND) {
258     TopoDS_Iterator anExplor (SH);
259
260     if (!anExplor.More()) // Shape vide -> Assemblage vide.
261       return;
262   }
263
264   Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
265   if (defdrawer->DrawHiddenLine())
266     {myDrawer->EnableDrawHiddenLine();}
267   else {myDrawer->DisableDrawHiddenLine();}
268
269   Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
270   defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
271
272   if (myDrawer->IsAutoTriangulation())
273   {
274     // coefficients for calculation
275     Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff;
276     Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle);
277     Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff);
278     if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
279         ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient))
280     {
281       BRepTools::Clean(SH);
282     }
283   }
284   
285   {
286     try {
287       OCC_CATCH_SIGNALS
288       switch (TypeOfHLR()) {
289         case Prs3d_TOH_Algo:
290           StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
291           break;
292         case Prs3d_TOH_PolyAlgo:
293         default:
294           StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
295           break;
296       }
297     }
298     catch (Standard_Failure) {
299 #ifdef OCCT_DEBUG
300       cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
301 #endif
302       StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
303     }
304   }
305
306   defdrawer->SetTypeOfDeflection (prevdef);
307 }
308
309 //=======================================================================
310 //function : SelectionType
311 //purpose  : gives the type according to the Index of Selection Mode
312 //=======================================================================
313
314 TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode)
315 {
316   switch(aMode){
317   case 1:
318     return TopAbs_VERTEX;
319   case 2:
320     return TopAbs_EDGE;
321   case 3:
322     return TopAbs_WIRE;
323   case 4:
324     return TopAbs_FACE;
325   case 5:
326     return TopAbs_SHELL;
327   case 6:
328     return TopAbs_SOLID;
329   case 7:
330     return TopAbs_COMPSOLID;
331   case 8:
332     return TopAbs_COMPOUND;
333   case 0:
334   default:
335     return TopAbs_SHAPE;
336   }
337   
338 }
339 //=======================================================================
340 //function : SelectionType
341 //purpose  : gives the SelectionMode according to the Type od Decomposition...
342 //=======================================================================
343 Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
344 {
345   switch(aType){
346   case TopAbs_VERTEX:
347     return 1;
348   case TopAbs_EDGE:
349     return 2;
350   case TopAbs_WIRE:
351     return 3;
352   case  TopAbs_FACE:
353     return 4;
354   case TopAbs_SHELL:
355     return 5;
356   case TopAbs_SOLID:
357     return 6;
358   case TopAbs_COMPSOLID:
359     return 7;
360   case TopAbs_COMPOUND:
361     return 8;
362   case TopAbs_SHAPE:
363   default:
364     return 0;
365   }
366 }
367
368
369 //=======================================================================
370 //function : ComputeSelection
371 //purpose  : 
372 //=======================================================================
373
374 void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
375                                               const Standard_Integer aMode)
376 {
377   if(myshape.IsNull()) return;
378   if (myshape.ShapeType() == TopAbs_COMPOUND) {
379     TopoDS_Iterator anExplor (myshape);
380
381     if (!anExplor.More()) // empty Shape -> empty Assembly.
382       return;
383   }
384
385   TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode);
386   TopoDS_Shape shape = myshape;
387
388 // POP protection against crash in low layers
389
390   Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
391   try {  
392     OCC_CATCH_SIGNALS
393     StdSelect_BRepSelectionTool::Load(aSelection,
394                                       this,
395                                       shape,
396                                       TypOfSel,
397                                       aDeflection,
398                                       myDrawer->HLRAngle(),
399                                       myDrawer->IsAutoTriangulation());
400   } catch ( Standard_Failure ) {
401 //    cout << "a Shape should be incorrect : A Selection on the Bnd  is activated   "<<endl;
402     if ( aMode == 0 ) {
403       aSelection->Clear();
404       Bnd_Box B = BoundingBox();
405       Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
406       Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
407       aSelection->Add(aSensitiveBox);
408     }
409   }
410
411   // insert the drawer in the BrepOwners for hilight...
412   StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
413 }
414
415 Quantity_NameOfColor AIS_Shape::Color() const {
416 Quantity_Color aColor;
417   Color(aColor);
418   return aColor.Name();
419 }
420
421 void AIS_Shape::Color( Quantity_Color& aColor ) const {
422   aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
423 }
424
425 Graphic3d_NameOfMaterial AIS_Shape::Material() const {
426   return (myDrawer->ShadingAspect()->Material(myCurrentFacingModel)).Name();
427 }
428
429 Standard_Real AIS_Shape::Transparency() const {
430   return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
431 }
432
433 //=======================================================================
434 //function : SetColor
435 //purpose  : 
436 //=======================================================================
437
438 void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
439 {
440   SetColor(Quantity_Color(aCol));
441 }
442
443 //=======================================================================
444 //function : setColor
445 //purpose  :
446 //=======================================================================
447
448 void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
449                           const Quantity_Color&       theColor) const
450 {
451   if (!theDrawer->HasOwnShadingAspect())
452   {
453     theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
454     if (theDrawer->HasLink())
455     {
456       *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
457     }
458   }
459   if (!theDrawer->HasOwnLineAspect())
460   {
461     theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
462     if (theDrawer->HasLink())
463     {
464       *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
465     }
466   }
467   if (!theDrawer->HasOwnWireAspect())
468   {
469     theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
470     if (theDrawer->HasLink())
471     {
472       *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
473     }
474   }
475   if (!theDrawer->HasOwnPointAspect())
476   {
477     theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
478     if (theDrawer->HasLink())
479     {
480       *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
481     }
482   }
483   if (!theDrawer->HasOwnFreeBoundaryAspect())
484   {
485     theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
486     if (theDrawer->HasLink())
487     {
488       *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
489     }
490   }
491   if (!theDrawer->HasOwnUnFreeBoundaryAspect())
492   {
493     theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
494     if (theDrawer->HasLink())
495     {
496       *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
497     }
498   }
499   if (!theDrawer->HasOwnSeenLineAspect())
500   {
501     theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
502     if (theDrawer->HasLink())
503     {
504       *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
505     }
506   }
507
508   // override color
509   theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
510   theDrawer->LineAspect()->SetColor (theColor);
511   theDrawer->WireAspect()->SetColor (theColor);
512   theDrawer->PointAspect()->SetColor (theColor);
513   theDrawer->FreeBoundaryAspect()->SetColor (theColor);
514   theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
515   theDrawer->SeenLineAspect()->SetColor (theColor);
516 }
517
518 //=======================================================================
519 //function : SetColor
520 //purpose  :
521 //=======================================================================
522
523 void AIS_Shape::SetColor (const Quantity_Color& theColor)
524 {
525   setColor (myDrawer, theColor);
526   myOwnColor  = theColor;
527   hasOwnColor = Standard_True;
528
529   // modify shading presentation without re-computation
530   const PrsMgr_Presentations&        aPrsList     = Presentations();
531   Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
532   Handle(Graphic3d_AspectLine3d)     aLineAspect  = myDrawer->LineAspect()->Aspect();
533   Handle(Graphic3d_AspectMarker3d)   aPointAspect = myDrawer->PointAspect()->Aspect();
534   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
535   {
536     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
537     if (aPrsModed.Mode() != AIS_Shaded)
538     {
539       continue;
540     }
541
542     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
543     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
544     {
545       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
546
547       // Check if aspect of given type is set for the group, 
548       // because setting aspect for group with no already set aspect
549       // can lead to loss of presentation data
550       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
551       {
552         aGroup->SetGroupPrimitivesAspect (anAreaAspect);
553       }
554       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
555       {
556         aGroup->SetGroupPrimitivesAspect (aLineAspect);
557       }
558       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
559       {
560         aGroup->SetGroupPrimitivesAspect (aPointAspect);
561       }
562     }
563   }
564
565   LoadRecomputable (AIS_WireFrame);
566   LoadRecomputable (2);
567 }
568
569 //=======================================================================
570 //function : UnsetColor
571 //purpose  :
572 //=======================================================================
573
574 void AIS_Shape::UnsetColor()
575 {
576   if (!HasColor())
577   {
578     myToRecomputeModes.Clear();
579     return;
580   }
581   hasOwnColor = Standard_False;
582
583   if (!HasWidth())
584   {
585     Handle(Prs3d_LineAspect) anEmptyAsp;
586     myDrawer->SetLineAspect          (anEmptyAsp);
587     myDrawer->SetWireAspect          (anEmptyAsp);
588     myDrawer->SetFreeBoundaryAspect  (anEmptyAsp);
589     myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
590     myDrawer->SetSeenLineAspect      (anEmptyAsp);
591   }
592   else
593   {
594     Quantity_Color aColor = Quantity_NOC_YELLOW;
595     if (myDrawer->HasLink())
596     {
597       AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line,   aColor);
598     }
599     myDrawer->LineAspect()->SetColor (aColor);
600     aColor = Quantity_NOC_RED;
601     if (myDrawer->HasLink())
602     {
603       AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire,   aColor);
604     }
605     myDrawer->WireAspect()->SetColor (aColor);
606     aColor = Quantity_NOC_GREEN;
607     if (myDrawer->HasLink())
608     {
609       AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free,   aColor);
610     }
611     myDrawer->FreeBoundaryAspect()->SetColor (aColor);
612     aColor = Quantity_NOC_YELLOW;
613     if (myDrawer->HasLink())
614     {
615       AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
616     }
617     myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
618     if (myDrawer->HasLink())
619     {
620       AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen,   aColor);
621     }
622     myDrawer->SeenLineAspect()->SetColor (aColor);
623   }
624
625   if (HasMaterial()
626    || IsTransparent())
627   {
628     Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
629     Graphic3d_MaterialAspect mat = aDefaultMat;
630     if (HasMaterial() || myDrawer->HasLink())
631     {
632       mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
633     }
634     if (HasMaterial())
635     {
636       Quantity_Color aColor = aDefaultMat.AmbientColor();
637       if (myDrawer->HasLink())
638       {
639         aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
640       }
641       mat.SetColor (aColor);
642     }
643     if (IsTransparent())
644     {
645       Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
646       mat.SetTransparency (aTransp);
647     }
648     myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel);
649   }
650   else
651   {
652     myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
653   }
654   myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
655
656   // modify shading presentation without re-computation
657   const PrsMgr_Presentations&        aPrsList  = Presentations();
658   Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
659   Handle(Graphic3d_AspectLine3d)     aLineAsp  = myDrawer->Link()->LineAspect()->Aspect();
660   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
661   {
662     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
663     if (aPrsModed.Mode() != AIS_Shaded)
664     {
665       continue;
666     }
667
668     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
669     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
670     {
671       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
672
673       // Check if aspect of given type is set for the group,
674       // because setting aspect for group with no already set aspect
675       // can lead to loss of presentation data
676       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
677       {
678         aGroup->SetGroupPrimitivesAspect (anAreaAsp);
679       }
680       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
681       {
682         aGroup->SetGroupPrimitivesAspect (aLineAsp);
683       }
684     }
685   }
686
687   LoadRecomputable (AIS_WireFrame);
688   LoadRecomputable (2);
689 }
690
691 //=======================================================================
692 //function : setWidth
693 //purpose  :
694 //=======================================================================
695
696 void AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
697                           const Standard_Real         theLineWidth) const
698 {
699   if (!theDrawer->HasOwnLineAspect())
700   {
701     theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
702     if (theDrawer->HasLink())
703     {
704       *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
705     }
706   }
707   if (!theDrawer->HasOwnWireAspect())
708   {
709     theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
710     if (theDrawer->HasLink())
711     {
712       *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
713     }
714   }
715   if (!theDrawer->HasOwnFreeBoundaryAspect())
716   {
717     theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
718     if (theDrawer->HasLink())
719     {
720       *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
721     }
722   }
723   if (!theDrawer->HasOwnUnFreeBoundaryAspect())
724   {
725     theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
726     if (theDrawer->HasLink())
727     {
728       *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
729     }
730   }
731   if (!theDrawer->HasOwnSeenLineAspect())
732   {
733     theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
734     if (theDrawer->HasLink())
735     {
736       *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
737     }
738   }
739
740   // override width
741   theDrawer->LineAspect()->SetWidth (theLineWidth);
742   theDrawer->WireAspect()->SetWidth (theLineWidth);
743   theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
744   theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
745   theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
746 }
747
748 //=======================================================================
749 //function : SetWidth
750 //purpose  : 
751 //=======================================================================
752
753 void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
754 {
755   setWidth (myDrawer, theLineWidth);
756   myOwnWidth = theLineWidth;
757   LoadRecomputable (AIS_WireFrame); // means that it is necessary to recompute only the wireframe....
758   LoadRecomputable (2);             // and the bounding box...
759 }
760
761 //=======================================================================
762 //function : UnsetWidth
763 //purpose  :
764 //=======================================================================
765
766 void AIS_Shape::UnsetWidth()
767 {
768   if (myOwnWidth == 0.0)
769   {
770     myToRecomputeModes.Clear();
771     return;
772   }
773
774   myOwnWidth = 0.0;
775
776   Handle(Prs3d_LineAspect) anEmptyAsp;
777
778   if (!HasColor())
779   {
780     myDrawer->SetLineAspect          (anEmptyAsp);
781     myDrawer->SetWireAspect          (anEmptyAsp);
782     myDrawer->SetFreeBoundaryAspect  (anEmptyAsp);
783     myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
784     myDrawer->SetSeenLineAspect      (anEmptyAsp);
785   }
786   else
787   {
788     myDrawer->LineAspect()          ->SetWidth (myDrawer->HasLink() ?
789       AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
790     myDrawer->WireAspect()          ->SetWidth (myDrawer->HasLink() ?
791       AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
792     myDrawer->FreeBoundaryAspect()  ->SetWidth (myDrawer->HasLink() ?
793       AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
794     myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
795       AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
796     myDrawer->SeenLineAspect()      ->SetWidth (myDrawer->HasLink() ?
797       AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
798   }
799   LoadRecomputable (AIS_WireFrame);
800 }
801
802 //=======================================================================
803 //function : setMaterial
804 //purpose  :
805 //=======================================================================
806
807 void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)&     theDrawer,
808                              const Graphic3d_MaterialAspect& theMaterial,
809                              const Standard_Boolean          theToKeepColor,
810                              const Standard_Boolean          theToKeepTransp) const
811 {
812   const Quantity_Color aColor  = theDrawer->ShadingAspect()->Material     (myCurrentFacingModel).Color();
813   const Standard_Real  aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
814   if (!theDrawer->HasOwnShadingAspect())
815   {
816     theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
817     if (theDrawer->HasLink())
818     {
819       *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
820     }
821   }
822   theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
823
824   if (theToKeepColor)
825   {
826     theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
827   }
828   if (theToKeepTransp)
829   {
830     theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
831   }
832 }
833
834 //=======================================================================
835 //function : SetMaterial
836 //purpose  : 
837 //=======================================================================
838
839 void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
840 {
841   SetMaterial(Graphic3d_MaterialAspect(aMat));
842 }
843
844 //=======================================================================
845 //function : SetMaterial
846 //purpose  :
847 //=======================================================================
848
849 void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
850 {
851   setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
852   hasOwnMaterial = Standard_True;
853
854   // modify shading presentation without re-computation
855   const PrsMgr_Presentations&        aPrsList  = Presentations();
856   Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
857   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
858   {
859     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
860     if (aPrsModed.Mode() != AIS_Shaded)
861     {
862       continue;
863     }
864
865     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
866     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
867     {
868       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
869
870       // Check if aspect of given type is set for the group, 
871       // because setting aspect for group with no already set aspect
872       // can lead to loss of presentation data
873       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
874       {
875         aGroup->SetGroupPrimitivesAspect (anAreaAsp);
876       }
877     }
878   }
879
880   myRecomputeEveryPrs = Standard_False; // no mode to recalculate  :only viewer update
881   myToRecomputeModes.Clear();
882 }
883
884 //=======================================================================
885 //function : UnsetMaterial
886 //purpose  :
887 //=======================================================================
888
889 void AIS_Shape::UnsetMaterial()
890 {
891   if (!HasMaterial())
892   {
893     return;
894   }
895
896   if (HasColor()
897    || IsTransparent())
898   {
899     if(myDrawer->HasLink())
900     {
901       myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
902                                               myCurrentFacingModel);
903     }
904     if (HasColor())
905     {
906       myDrawer->ShadingAspect()->SetColor        (myOwnColor,     myCurrentFacingModel);
907       myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
908     }
909   }
910   else
911   {
912     myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
913   }
914   hasOwnMaterial = Standard_False;
915
916   // modify shading presentation without re-computation
917   const PrsMgr_Presentations&        aPrsList  = Presentations();
918   Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
919   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
920   {
921     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
922     if (aPrsModed.Mode() != AIS_Shaded)
923     {
924       continue;
925     }
926
927     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
928     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
929     {
930       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
931       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
932       {
933         aGroup->SetGroupPrimitivesAspect (anAreaAsp);
934       }
935     }
936   }
937
938   myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
939   myToRecomputeModes.Clear();  
940 }
941
942 //=======================================================================
943 //function : setTransparency
944 //purpose  :
945 //=======================================================================
946
947 void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
948                                  const Standard_Real         theValue) const
949 {
950   if (!theDrawer->HasOwnShadingAspect())
951   {
952     theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
953     if (theDrawer->HasLink())
954     {
955       *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
956     }
957   }
958
959   // override transparency
960   theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
961 }
962
963 //=======================================================================
964 //function : SetTransparency
965 //purpose  :
966 //=======================================================================
967
968 void AIS_Shape::SetTransparency (const Standard_Real theValue)
969 {
970   setTransparency (myDrawer, theValue);
971   myTransparency = theValue;
972
973   // modify shading presentation without re-computation
974   const PrsMgr_Presentations&        aPrsList  = Presentations();
975   Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
976   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
977   {
978     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
979     if (aPrsModed.Mode() != AIS_Shaded)
980     {
981       continue;
982     }
983
984     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
985     aPrs->SetDisplayPriority (10); // force highest priority for translucent objects
986     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
987     {
988       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
989       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
990       {
991         aGroup->SetGroupPrimitivesAspect (anAreaAsp);
992       }
993     }
994   }
995
996   myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
997   myToRecomputeModes.Clear();
998 }
999
1000 //=======================================================================
1001 //function : UnsetTransparency
1002 //purpose  :
1003 //=======================================================================
1004
1005 void AIS_Shape::UnsetTransparency()
1006 {
1007   myTransparency = 0.0;
1008   if (!myDrawer->HasOwnShadingAspect())
1009   {
1010     return;
1011   }
1012   else if (HasColor() || HasMaterial())
1013   {
1014     myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
1015   }
1016   else
1017   {
1018     myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
1019   }
1020
1021   // modify shading presentation without re-computation
1022   const PrsMgr_Presentations&        aPrsList  = Presentations();
1023   Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
1024   for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
1025   {
1026     const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
1027     if (aPrsModed.Mode() != AIS_Shaded)
1028     {
1029       continue;
1030     }
1031
1032     const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
1033     for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
1034     {
1035       const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
1036       if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
1037       {
1038         aGroup->SetGroupPrimitivesAspect (anAreaAsp);
1039       }
1040     }
1041     aPrs->ResetDisplayPriority();
1042   }
1043
1044   myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
1045   myToRecomputeModes.Clear();
1046 }
1047
1048 //=======================================================================
1049 //function : LoadRecomputable
1050 //purpose  : 
1051 //=======================================================================
1052
1053 void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
1054 {
1055   myRecomputeEveryPrs = Standard_False;
1056   if(!IsInList(myToRecomputeModes,TheMode))
1057     myToRecomputeModes.Append(TheMode);
1058 }
1059
1060 //=======================================================================
1061 //function : BoundingBox
1062 //purpose  : 
1063 //=======================================================================
1064
1065 const Bnd_Box& AIS_Shape::BoundingBox()  
1066 {
1067   if (myshape.ShapeType() == TopAbs_COMPOUND) {
1068     TopoDS_Iterator anExplor (myshape);
1069
1070     if (!anExplor.More()) { // empty Shape  -> empty Assembly.
1071       myBB.SetVoid();
1072       return myBB;
1073     }
1074   }
1075
1076   if(myCompBB) {
1077     BRepBndLib::AddClose(myshape, myBB);
1078     myCompBB = Standard_False;
1079   }
1080   return myBB;
1081 }
1082
1083 //*****
1084 //***** Reset
1085 //=======================================================================
1086 //function : SetOwnDeviationCoefficient
1087 //purpose  : resets myhasOwnDeviationCoefficient to Standard_False and
1088 //           returns Standard_True if it change
1089 //=======================================================================
1090
1091 Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
1092 {
1093   Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
1094   if(itSet)  myDrawer->SetDeviationCoefficient();
1095   return itSet;
1096 }
1097
1098 //=======================================================================
1099 //function : SetHLROwnDeviationCoefficient
1100 //purpose  : resets myhasOwnHLRDeviationCoefficient to Standard_False and
1101 //           returns Standard_True if it change
1102 //=======================================================================
1103
1104 Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
1105 {
1106   Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
1107   if(itSet)  myDrawer->SetHLRDeviationCoefficient();
1108   return itSet;
1109
1110 }
1111
1112 //=======================================================================
1113 //function : SetOwnDeviationAngle
1114 //purpose  : resets myhasOwnDeviationAngle to Standard_False and
1115 //           returns Standard_True if it change
1116 //=======================================================================
1117
1118 Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
1119 {
1120   Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
1121   if(itSet)  myDrawer->SetDeviationAngle();
1122   return itSet;
1123
1124 }
1125
1126 //=======================================================================
1127 //function : SetOwnHLRDeviationAngle
1128 //purpose  : resets myhasOwnHLRDeviationAngle to Standard_False and
1129 //           returns Standard_True if it change
1130 //=======================================================================
1131
1132 Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
1133 {
1134   Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
1135   if(itSet)  myDrawer->SetHLRAngle();
1136   return itSet;
1137
1138 }
1139 //***** SetOwn
1140 //=======================================================================
1141 //function : SetOwnDeviationCoefficient
1142 //purpose  : 
1143 //=======================================================================
1144
1145 void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real  aCoefficient )
1146 {
1147   myDrawer->SetDeviationCoefficient( aCoefficient );
1148   SetToUpdate(0) ; // WireFrame
1149   SetToUpdate(1) ; // Shadding
1150 }
1151
1152 //=======================================================================
1153 //function : SetOwnHLRDeviationCoefficient
1154 //purpose  : 
1155 //=======================================================================
1156
1157 void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real  aCoefficient )
1158 {
1159   myDrawer->SetHLRDeviationCoefficient( aCoefficient );
1160   
1161 }
1162
1163 //=======================================================================
1164 //function : SetOwnDeviationAngle
1165 //purpose  : 
1166 //=======================================================================
1167
1168 void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real  anAngle )
1169 {
1170
1171   myDrawer->SetDeviationAngle(anAngle );
1172   SetToUpdate(0) ;   // WireFrame
1173 }
1174 //=======================================================================
1175 //function : SetOwnDeviationAngle
1176 //purpose  : 
1177 //=======================================================================
1178
1179 void AIS_Shape::SetAngleAndDeviation ( const Standard_Real  anAngle )
1180 {
1181   Standard_Real OutAngl,OutDefl;
1182   HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1183   SetOwnDeviationAngle(anAngle) ;
1184   SetOwnDeviationCoefficient(OutDefl) ;
1185   myInitAng = anAngle;
1186   SetToUpdate(0);
1187   SetToUpdate(1);
1188 }
1189
1190 //=======================================================================
1191 //function : UserAngle
1192 //purpose  : 
1193 //=======================================================================
1194
1195 Standard_Real AIS_Shape::UserAngle() const
1196 {
1197   return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng;
1198 }
1199
1200
1201 //=======================================================================
1202 //function : SetHLRAngleAndDeviation
1203 //purpose  : 
1204 //=======================================================================
1205
1206 void AIS_Shape::SetHLRAngleAndDeviation ( const Standard_Real  anAngle )
1207 {
1208   Standard_Real OutAngl,OutDefl;
1209   HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1210   SetOwnHLRDeviationAngle( OutAngl );
1211   SetOwnHLRDeviationCoefficient(OutDefl);
1212
1213 }
1214 //=======================================================================
1215 //function : SetOwnHLRDeviationAngle
1216 //purpose  : 
1217 //=======================================================================
1218
1219 void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real  anAngle )
1220 {
1221   myDrawer->SetHLRAngle( anAngle );
1222 }
1223
1224 //***** GetOwn
1225 //=======================================================================
1226 //function : OwnDeviationCoefficient
1227 //purpose  : 
1228 //=======================================================================
1229
1230 Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real &  aCoefficient,
1231                                                       Standard_Real & aPreviousCoefficient ) const
1232 {
1233   aCoefficient = myDrawer->DeviationCoefficient();
1234   aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
1235   return myDrawer->HasOwnDeviationCoefficient() ;
1236 }
1237
1238 //=======================================================================
1239 //function : OwnHLRDeviationCoefficient
1240 //purpose  : 
1241 //=======================================================================
1242
1243 Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
1244                                                          Standard_Real & aPreviousCoefficient ) const
1245 {
1246   aCoefficient = myDrawer->HLRDeviationCoefficient();
1247   aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
1248   return myDrawer->HasOwnHLRDeviationCoefficient();
1249
1250 }
1251
1252 //=======================================================================
1253 //function : OwnDeviationAngle
1254 //purpose  : 
1255 //=======================================================================
1256
1257 Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real &  anAngle,
1258                                                 Standard_Real & aPreviousAngle ) const
1259 {
1260   anAngle = myDrawer->DeviationAngle();
1261   aPreviousAngle = myDrawer->PreviousDeviationAngle (); 
1262   return myDrawer->HasOwnDeviationAngle();
1263 }
1264
1265 //=======================================================================
1266 //function : OwnHLRDeviationAngle
1267 //purpose  : 
1268 //=======================================================================
1269
1270 Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real &  anAngle,
1271                                                    Standard_Real & aPreviousAngle ) const
1272 {
1273   anAngle = myDrawer->HLRAngle();
1274   aPreviousAngle = myDrawer->PreviousHLRDeviationAngle (); 
1275   return myDrawer->HasOwnHLRDeviationAngle();
1276 }