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