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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <AIS_Shape.hxx>
19 #include <AIS_GraphicTool.hxx>
20 #include <AIS_InteractiveContext.hxx>
21 #include <BRepBndLib.hxx>
22 #include <BRepTools.hxx>
23 #include <BRepTools_ShapeSet.hxx>
24 #include <Graphic3d_AspectFillArea3d.hxx>
25 #include <Graphic3d_AspectLine3d.hxx>
26 #include <Graphic3d_Group.hxx>
27 #include <Graphic3d_MaterialAspect.hxx>
28 #include <Graphic3d_Structure.hxx>
29 #include <Message.hxx>
30 #include <Message_Messenger.hxx>
31 #include <HLRBRep.hxx>
32 #include <OSD_Timer.hxx>
33 #include <Prs3d_Drawer.hxx>
34 #include <Prs3d_Presentation.hxx>
35 #include <Prs3d_ShadingAspect.hxx>
36 #include <Prs3d_BndBox.hxx>
37 #include <StdPrs_ToolTriangulatedShape.hxx>
38 #include <Quantity_Color.hxx>
39 #include <Select3D_SensitiveBox.hxx>
40 #include <Standard_ErrorHandler.hxx>
41 #include <Standard_Failure.hxx>
42 #include <Standard_Type.hxx>
43 #include <StdPrs_HLRPolyShape.hxx>
44 #include <StdPrs_HLRShape.hxx>
45 #include <StdPrs_ShadedShape.hxx>
46 #include <StdPrs_WFShape.hxx>
47 #include <StdSelect.hxx>
48 #include <StdSelect_BRepSelectionTool.hxx>
50 IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
53 #define replaceAspectWithDef(theMap, theAspect) \
54 if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
56 theMap.Bind (myDrawer->theAspect()->Aspect(), myDrawer->Link()->theAspect()->Aspect()); \
59 // Auxiliary macros for replaceWithNewOwnAspects()
60 #define replaceAspectWithOwn(theMap, theAspect) \
61 if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
63 theMap.Bind (myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
66 //=======================================================================
67 //function : replaceWithNewOwnAspects
69 //=======================================================================
70 void AIS_Shape::replaceWithNewOwnAspects()
72 Graphic3d_MapOfAspectsToAspects aReplaceMap;
74 replaceAspectWithOwn (aReplaceMap, ShadingAspect);
75 replaceAspectWithOwn (aReplaceMap, LineAspect);
76 replaceAspectWithOwn (aReplaceMap, WireAspect);
77 replaceAspectWithOwn (aReplaceMap, FreeBoundaryAspect);
78 replaceAspectWithOwn (aReplaceMap, UnFreeBoundaryAspect);
79 replaceAspectWithOwn (aReplaceMap, SeenLineAspect);
80 replaceAspectWithOwn (aReplaceMap, FaceBoundaryAspect);
81 replaceAspectWithOwn (aReplaceMap, PointAspect);
83 replaceAspects (aReplaceMap);
86 //==================================================
87 // Function: AIS_Shape
89 //==================================================
90 AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
91 : AIS_InteractiveObject (PrsMgr_TOP_ProjectorDependent),
97 myCompBB (Standard_True)
102 //=======================================================================
105 //=======================================================================
106 void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
107 const Handle(Prs3d_Presentation)& thePrs,
108 const Standard_Integer theMode)
111 || (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
116 // wire,edge,vertex -> pas de HLR + priorite display superieure
117 if (myshape.ShapeType() >= TopAbs_WIRE
118 && myshape.ShapeType() <= TopAbs_VERTEX)
120 // TopAbs_WIRE -> 7, TopAbs_EDGE -> 8, TopAbs_VERTEX -> 9 (Graphic3d_DisplayPriority_Highlight)
121 const Standard_Integer aPrior = (Standard_Integer )Graphic3d_DisplayPriority_Above1
122 + (Standard_Integer )myshape.ShapeType() - TopAbs_WIRE;
123 thePrs->SetVisual (Graphic3d_TOS_ALL);
124 thePrs->SetDisplayPriority ((Graphic3d_DisplayPriority )aPrior);
129 thePrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
136 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
140 StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
142 catch (Standard_Failure const& anException)
144 Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() wireframe presentation builder has failed (")
145 + anException.GetMessageString() + ")");
151 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
152 if ((Standard_Integer) myshape.ShapeType() > 4)
154 StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
160 StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
167 StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
168 myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
169 && !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
170 myUVOrigin, myUVRepeat, myUVScale);
172 catch (Standard_Failure const& anException)
174 Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() shaded presentation builder has failed (")
175 + anException.GetMessageString() + ")");
176 StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
180 Standard_Real aTransparency = Transparency() ;
181 if (aTransparency > 0.0)
183 SetTransparency (aTransparency);
193 StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
197 Prs3d_BndBox::Add (thePrs, BoundingBox(), myDrawer);
202 // Recompute hidden line presentation (if necessary).
206 //=======================================================================
207 //function : computeHlrPresentation
209 //=======================================================================
210 void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProjector,
211 const Handle(Prs3d_Presentation)& thePrs,
212 const TopoDS_Shape& theShape,
213 const Handle(Prs3d_Drawer)& theDrawer)
215 if (theShape.IsNull())
220 switch (theShape.ShapeType())
226 thePrs->SetDisplayPriority (Graphic3d_DisplayPriority_Below);
227 StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
230 case TopAbs_COMPOUND:
232 if (theShape.NbChildren() == 0)
244 const Handle(Prs3d_Drawer)& aDefDrawer = theDrawer->Link();
245 if (aDefDrawer->DrawHiddenLine())
247 theDrawer->EnableDrawHiddenLine();
251 theDrawer->DisableDrawHiddenLine();
254 const Aspect_TypeOfDeflection aPrevDef = aDefDrawer->TypeOfDeflection();
255 aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
256 if (theDrawer->IsAutoTriangulation())
258 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (theShape, theDrawer, Standard_True);
265 switch (theDrawer->TypeOfHLR())
269 StdPrs_HLRShape aBuilder;
270 aBuilder.ComputeHLR (thePrs, theShape, theDrawer, theProjector);
273 case Prs3d_TOH_PolyAlgo:
274 case Prs3d_TOH_NotSet:
276 StdPrs_HLRPolyShape aBuilder;
277 aBuilder.ComputeHLR (thePrs, theShape, theDrawer, theProjector);
282 catch (Standard_Failure const& anException)
284 Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() HLR Algorithm has failed (")
285 + anException.GetMessageString() + ")");
286 StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
290 aDefDrawer->SetTypeOfDeflection (aPrevDef);
293 //=======================================================================
294 //function : ComputeSelection
296 //=======================================================================
298 void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
299 const Standard_Integer aMode)
301 if(myshape.IsNull()) return;
302 if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
304 // empty Shape -> empty Assembly.
308 TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode);
309 TopoDS_Shape shape = myshape;
311 // POP protection against crash in low layers
313 Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(shape, myDrawer);
317 StdSelect_BRepSelectionTool::Load(aSelection,
322 myDrawer->DeviationAngle(),
323 myDrawer->IsAutoTriangulation());
325 catch (Standard_Failure const& anException)
327 Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::ComputeSelection(") + aMode + ") has failed ("
328 + anException.GetMessageString() + ")");
332 Bnd_Box B = BoundingBox();
333 Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
334 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
335 aSelection->Add(aSensitiveBox);
339 // insert the drawer in the BrepOwners for hilight...
340 StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
343 void AIS_Shape::Color (Quantity_Color& theColor) const
345 if (const Handle(Prs3d_ShadingAspect)& aShading = myDrawer->ShadingAspect())
347 theColor = aShading->Color(myCurrentFacingModel);
351 Graphic3d_NameOfMaterial AIS_Shape::Material() const
353 const Handle(Prs3d_ShadingAspect)& aShading = myDrawer->ShadingAspect();
354 return !aShading.IsNull()
355 ? aShading->Material(myCurrentFacingModel).Name()
356 : Graphic3d_NameOfMaterial_DEFAULT;
359 Standard_Real AIS_Shape::Transparency() const
361 const Handle(Prs3d_ShadingAspect)& aShading = myDrawer->ShadingAspect();
362 return !aShading.IsNull()
363 ? aShading->Transparency(myCurrentFacingModel)
367 //=======================================================================
368 //function : setColor
370 //=======================================================================
372 bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
373 const Quantity_Color& theColor) const
375 bool toRecompute = false;
376 toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
377 toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
378 toRecompute = theDrawer->SetupOwnPointAspect() || toRecompute;
381 theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
382 theDrawer->LineAspect()->SetColor (theColor);
383 theDrawer->WireAspect()->SetColor (theColor);
384 theDrawer->PointAspect()->SetColor (theColor);
385 theDrawer->FreeBoundaryAspect()->SetColor (theColor);
386 theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
387 theDrawer->SeenLineAspect()->SetColor (theColor);
388 theDrawer->FaceBoundaryAspect()->SetColor (theColor);
392 //=======================================================================
393 //function : SetColor
395 //=======================================================================
397 void AIS_Shape::SetColor (const Quantity_Color& theColor)
399 const bool toRecompute = setColor (myDrawer, theColor);
400 myDrawer->SetColor (theColor);
401 hasOwnColor = Standard_True;
404 || !myDrawer->HasLink())
406 SynchronizeAspects();
410 replaceWithNewOwnAspects();
415 //=======================================================================
416 //function : UnsetColor
418 //=======================================================================
420 void AIS_Shape::UnsetColor()
427 hasOwnColor = Standard_False;
428 myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
430 Graphic3d_MapOfAspectsToAspects aReplaceMap;
433 replaceAspectWithDef (aReplaceMap, LineAspect);
434 replaceAspectWithDef (aReplaceMap, WireAspect);
435 replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
436 replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
437 replaceAspectWithDef (aReplaceMap, SeenLineAspect);
438 replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
439 myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
440 myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
441 myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
442 myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
443 myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
444 myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
448 Quantity_Color aColor = Quantity_NOC_YELLOW;
449 if (myDrawer->HasLink())
451 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
453 myDrawer->LineAspect()->SetColor (aColor);
454 aColor = Quantity_NOC_RED;
455 if (myDrawer->HasLink())
457 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
459 myDrawer->WireAspect()->SetColor (aColor);
460 aColor = Quantity_NOC_GREEN;
461 if (myDrawer->HasLink())
463 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
465 myDrawer->FreeBoundaryAspect()->SetColor (aColor);
466 aColor = Quantity_NOC_YELLOW;
467 if (myDrawer->HasLink())
469 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
471 myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
472 if (myDrawer->HasLink())
474 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
476 myDrawer->SeenLineAspect()->SetColor (aColor);
477 aColor = Quantity_NOC_BLACK;
478 if (myDrawer->HasLink())
480 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_FaceBoundary, aColor);
482 myDrawer->FaceBoundaryAspect()->SetColor (aColor);
485 if (!myDrawer->HasOwnShadingAspect())
489 else if (HasMaterial()
491 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
493 const Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NameOfMaterial_Brass);
494 Graphic3d_MaterialAspect mat = aDefaultMat;
495 Quantity_Color anInteriorColors[2] = {Quantity_NOC_CYAN1, Quantity_NOC_CYAN1};
496 if (myDrawer->HasLink())
498 anInteriorColors[0] = myDrawer->Link()->ShadingAspect()->Aspect()->InteriorColor();
499 anInteriorColors[1] = myDrawer->Link()->ShadingAspect()->Aspect()->BackInteriorColor();
501 if (HasMaterial() || myDrawer->HasLink())
503 const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect = (HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
504 mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE
505 ? aSrcAspect->FrontMaterial()
506 : aSrcAspect->BackMaterial();
510 const Quantity_Color aColor = myDrawer->HasLink()
511 ? myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel)
512 : aDefaultMat.AmbientColor();
513 mat.SetColor (aColor);
517 Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
518 mat.SetTransparency (Standard_ShortReal(aTransp));
520 myDrawer->ShadingAspect()->SetMaterial (mat, myCurrentFacingModel);
521 myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (anInteriorColors[0]);
522 myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor(anInteriorColors[1]);
526 replaceAspectWithDef (aReplaceMap, ShadingAspect);
527 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
529 if (myDrawer->HasOwnPointAspect())
531 replaceAspectWithDef (aReplaceMap, PointAspect);
532 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
534 replaceAspects (aReplaceMap);
535 SynchronizeAspects();
539 //=======================================================================
540 //function : setWidth
542 //=======================================================================
544 bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
545 const Standard_Real theLineWidth) const
547 bool toRecompute = theDrawer->SetOwnLineAspects();
550 theDrawer->LineAspect()->SetWidth (theLineWidth);
551 theDrawer->WireAspect()->SetWidth (theLineWidth);
552 theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
553 theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
554 theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
555 theDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
559 //=======================================================================
560 //function : SetWidth
562 //=======================================================================
564 void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
566 myOwnWidth = (Standard_ShortReal )theLineWidth;
568 if (!setWidth (myDrawer, theLineWidth)
569 || !myDrawer->HasLink())
571 SynchronizeAspects();
575 replaceWithNewOwnAspects();
580 //=======================================================================
581 //function : UnsetWidth
583 //=======================================================================
585 void AIS_Shape::UnsetWidth()
587 if (myOwnWidth == 0.0f)
595 Graphic3d_MapOfAspectsToAspects aReplaceMap;
596 replaceAspectWithDef (aReplaceMap, LineAspect);
597 replaceAspectWithDef (aReplaceMap, WireAspect);
598 replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
599 replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
600 replaceAspectWithDef (aReplaceMap, SeenLineAspect);
601 replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
602 myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
603 myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
604 myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
605 myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
606 myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
607 myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
608 replaceAspects (aReplaceMap);
612 myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
613 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
614 myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
615 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
616 myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
617 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
618 myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
619 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
620 myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
621 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
622 myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
623 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
624 SynchronizeAspects();
629 //=======================================================================
630 //function : setMaterial
632 //=======================================================================
634 void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
635 const Graphic3d_MaterialAspect& theMaterial,
636 const Standard_Boolean theToKeepColor,
637 const Standard_Boolean theToKeepTransp) const
639 theDrawer->SetupOwnShadingAspect();
641 const Quantity_Color aColor = theDrawer->ShadingAspect()->Color (myCurrentFacingModel);
642 const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
643 theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
647 theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
651 theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
655 //=======================================================================
656 //function : SetMaterial
658 //=======================================================================
660 void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
662 const bool toRecompute = !myDrawer->HasOwnShadingAspect();
663 setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
664 hasOwnMaterial = Standard_True;
667 || !myDrawer->HasLink())
669 SynchronizeAspects();
673 replaceWithNewOwnAspects();
677 //=======================================================================
678 //function : UnsetMaterial
680 //=======================================================================
682 void AIS_Shape::UnsetMaterial()
689 if (!myDrawer->HasOwnShadingAspect())
695 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
697 if(myDrawer->HasLink())
699 myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
700 myCurrentFacingModel);
704 myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
705 myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
707 SynchronizeAspects();
711 Graphic3d_MapOfAspectsToAspects aReplaceMap;
712 replaceAspectWithDef (aReplaceMap, ShadingAspect);
713 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
714 replaceAspects (aReplaceMap);
718 //=======================================================================
719 //function : setTransparency
721 //=======================================================================
723 void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
724 const Standard_Real theValue) const
726 theDrawer->SetupOwnShadingAspect();
727 // override transparency
728 theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
731 //=======================================================================
732 //function : SetTransparency
734 //=======================================================================
736 void AIS_Shape::SetTransparency (const Standard_Real theValue)
738 const bool toRecompute = !myDrawer->HasOwnShadingAspect();
739 setTransparency (myDrawer, theValue);
740 myDrawer->SetTransparency ((Standard_ShortReal )theValue);
743 || !myDrawer->HasLink())
745 SynchronizeAspects();
749 replaceWithNewOwnAspects();
753 //=======================================================================
754 //function : UnsetTransparency
756 //=======================================================================
758 void AIS_Shape::UnsetTransparency()
760 myDrawer->SetTransparency (0.0f);
761 if (!myDrawer->HasOwnShadingAspect())
767 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
769 myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
770 SynchronizeAspects();
774 Graphic3d_MapOfAspectsToAspects aReplaceMap;
775 replaceAspectWithDef (aReplaceMap, ShadingAspect);
776 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
777 replaceAspects (aReplaceMap);
781 //=======================================================================
782 //function : BoundingBox
784 //=======================================================================
786 const Bnd_Box& AIS_Shape::BoundingBox()
788 if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
790 // empty Shape -> empty Assembly.
796 BRepBndLib::Add (myshape, myBB, false);
797 myCompBB = Standard_False;
804 //=======================================================================
805 //function : SetOwnDeviationCoefficient
806 //purpose : resets myhasOwnDeviationCoefficient to Standard_False and
807 // returns Standard_True if it change
808 //=======================================================================
810 Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
812 Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
813 if(itSet) myDrawer->SetDeviationCoefficient();
817 //=======================================================================
818 //function : SetOwnDeviationAngle
819 //purpose : resets myhasOwnDeviationAngle to Standard_False and
820 // returns Standard_True if it change
821 //=======================================================================
823 Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
825 Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
826 if(itSet) myDrawer->SetDeviationAngle();
831 //=======================================================================
832 //function : SetOwnDeviationCoefficient
834 //=======================================================================
836 void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
838 myDrawer->SetDeviationCoefficient( aCoefficient );
842 //=======================================================================
843 //function : SetOwnDeviationAngle
845 //=======================================================================
847 void AIS_Shape::SetOwnDeviationAngle (const Standard_Real theAngle)
849 myDrawer->SetDeviationAngle (theAngle);
850 SetToUpdate (AIS_WireFrame);
852 //=======================================================================
853 //function : SetOwnDeviationAngle
855 //=======================================================================
857 void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
859 Standard_Real OutAngl,OutDefl;
860 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
861 SetOwnDeviationAngle(anAngle) ;
862 SetOwnDeviationCoefficient(OutDefl) ;
867 //=======================================================================
868 //function : UserAngle
870 //=======================================================================
872 Standard_Real AIS_Shape::UserAngle() const
874 return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng;
877 //=======================================================================
878 //function : OwnDeviationCoefficient
880 //=======================================================================
882 Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
883 Standard_Real & aPreviousCoefficient ) const
885 aCoefficient = myDrawer->DeviationCoefficient();
886 aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
887 return myDrawer->HasOwnDeviationCoefficient() ;
890 //=======================================================================
891 //function : OwnDeviationAngle
893 //=======================================================================
895 Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
896 Standard_Real & aPreviousAngle ) const
898 anAngle = myDrawer->DeviationAngle();
899 aPreviousAngle = myDrawer->PreviousDeviationAngle ();
900 return myDrawer->HasOwnDeviationAngle();
903 //=======================================================================
904 //function : DumpJson
906 //=======================================================================
907 void AIS_Shape::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
909 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
910 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject)
912 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myshape)
913 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBB)
915 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myInitAng)
916 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCompBB)