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