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 <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>
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>
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 <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>
68 IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
71 #define replaceAspectWithDef(theMap, theAspect) \
72 if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
74 theMap.Bind (myDrawer->theAspect()->Aspect(), myDrawer->Link()->theAspect()->Aspect()); \
77 // Auxiliary macros for replaceWithNewOwnAspects()
78 #define replaceAspectWithOwn(theMap, theAspect) \
79 if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
81 theMap.Bind (myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
84 //=======================================================================
85 //function : replaceWithNewOwnAspects
87 //=======================================================================
88 void AIS_Shape::replaceWithNewOwnAspects()
90 Graphic3d_MapOfAspectsToAspects aReplaceMap;
92 replaceAspectWithOwn (aReplaceMap, ShadingAspect);
93 replaceAspectWithOwn (aReplaceMap, LineAspect);
94 replaceAspectWithOwn (aReplaceMap, WireAspect);
95 replaceAspectWithOwn (aReplaceMap, FreeBoundaryAspect);
96 replaceAspectWithOwn (aReplaceMap, UnFreeBoundaryAspect);
97 replaceAspectWithOwn (aReplaceMap, SeenLineAspect);
98 replaceAspectWithOwn (aReplaceMap, FaceBoundaryAspect);
99 replaceAspectWithOwn (aReplaceMap, PointAspect);
101 replaceAspects (aReplaceMap);
104 //==================================================
105 // Function: AIS_Shape
107 //==================================================
108 AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
109 : AIS_InteractiveObject (PrsMgr_TOP_ProjectorDependant),
111 myUVOrigin(0.0, 0.0),
112 myUVRepeat(1.0, 1.0),
113 myUVScale (1.0, 1.0),
115 myCompBB (Standard_True)
120 //=======================================================================
123 //=======================================================================
124 void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
125 const Handle(Prs3d_Presentation)& aPrs,
126 const Standard_Integer theMode)
128 if(myshape.IsNull()) return;
130 // wire,edge,vertex -> pas de HLR + priorite display superieure
131 Standard_Integer TheType = (Standard_Integer) myshape.ShapeType();
132 if(TheType>4 && TheType<8) {
133 aPrs->SetVisual(Graphic3d_TOS_ALL);
134 aPrs->SetDisplayPriority(TheType+2);
136 // Shape vide -> Assemblage vide.
137 if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
144 aPrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
151 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
155 StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
157 catch (Standard_Failure const& anException)
159 Message::DefaultMessenger()->Send (TCollection_AsciiString()
160 + "Error: AIS_Shape::Compute() wireframe presentation builder has failed ("
161 + anException.GetMessageString() + ")", Message_Fail);
167 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
168 if ((Standard_Integer) myshape.ShapeType() > 4)
170 StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
176 StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
183 StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
184 myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
185 && !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
186 myUVOrigin, myUVRepeat, myUVScale);
188 catch (Standard_Failure const& anException)
190 Message::DefaultMessenger()->Send (TCollection_AsciiString()
191 + "Error: AIS_Shape::Compute() shaded presentation builder has failed ("
192 + anException.GetMessageString() + ")", Message_Fail);
193 StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
197 Standard_Real aTransparency = Transparency() ;
198 if (aTransparency > 0.0)
200 SetTransparency (aTransparency);
210 StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
214 StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
219 // Recompute hidden line presentation (if necessary).
223 //=======================================================================
224 //function : computeHlrPresentation
226 //=======================================================================
227 void AIS_Shape::computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector,
228 const Handle(Prs3d_Presentation)& thePrs,
229 const TopoDS_Shape& theShape,
230 const Handle(Prs3d_Drawer)& theDrawer)
232 if (theShape.IsNull())
237 switch (theShape.ShapeType())
243 thePrs->SetDisplayPriority (4);
244 StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
247 case TopAbs_COMPOUND:
249 if (theShape.NbChildren() == 0)
261 const Handle(Prs3d_Drawer)& aDefDrawer = theDrawer->Link();
262 if (aDefDrawer->DrawHiddenLine())
264 theDrawer->EnableDrawHiddenLine();
268 theDrawer->DisableDrawHiddenLine();
271 const Aspect_TypeOfDeflection aPrevDef = aDefDrawer->TypeOfDeflection();
272 aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
273 if (theDrawer->IsAutoTriangulation())
275 StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (theShape, theDrawer, Standard_True);
282 switch (theDrawer->TypeOfHLR())
285 StdPrs_HLRShape::Add (thePrs, theShape, theDrawer, theProjector);
287 case Prs3d_TOH_PolyAlgo:
289 StdPrs_HLRPolyShape::Add (thePrs, theShape, theDrawer, theProjector);
293 catch (Standard_Failure const& anException)
295 Message::DefaultMessenger()->Send (TCollection_AsciiString()
296 + "Error: AIS_Shape::Compute() HLR Algorithm has failed ("
297 + anException.GetMessageString() + ")", Message_Fail);
298 StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
302 aDefDrawer->SetTypeOfDeflection (aPrevDef);
305 //=======================================================================
306 //function : ComputeSelection
308 //=======================================================================
310 void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
311 const Standard_Integer aMode)
313 if(myshape.IsNull()) return;
314 if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
316 // empty Shape -> empty Assembly.
320 TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode);
321 TopoDS_Shape shape = myshape;
323 // POP protection against crash in low layers
325 Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
329 StdSelect_BRepSelectionTool::Load(aSelection,
334 myDrawer->HLRAngle(),
335 myDrawer->IsAutoTriangulation());
337 catch (Standard_Failure const& anException)
339 Message::DefaultMessenger()->Send (TCollection_AsciiString()
340 + "Error: AIS_Shape::ComputeSelection(" + aMode + ") has failed ("
341 + anException.GetMessageString() + ")", Message_Fail);
345 Bnd_Box B = BoundingBox();
346 Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
347 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
348 aSelection->Add(aSensitiveBox);
352 // insert the drawer in the BrepOwners for hilight...
353 StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
356 void AIS_Shape::Color( Quantity_Color& aColor ) const {
357 aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
360 Graphic3d_NameOfMaterial AIS_Shape::Material() const {
361 return (myDrawer->ShadingAspect()->Material(myCurrentFacingModel)).Name();
364 Standard_Real AIS_Shape::Transparency() const {
365 return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
368 //=======================================================================
369 //function : setColor
371 //=======================================================================
373 bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
374 const Quantity_Color& theColor) const
376 bool toRecompute = false;
377 toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
378 toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
379 toRecompute = theDrawer->SetupOwnPointAspect() || toRecompute;
382 theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
383 theDrawer->LineAspect()->SetColor (theColor);
384 theDrawer->WireAspect()->SetColor (theColor);
385 theDrawer->PointAspect()->SetColor (theColor);
386 theDrawer->FreeBoundaryAspect()->SetColor (theColor);
387 theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
388 theDrawer->SeenLineAspect()->SetColor (theColor);
389 theDrawer->FaceBoundaryAspect()->SetColor (theColor);
393 //=======================================================================
394 //function : SetColor
396 //=======================================================================
398 void AIS_Shape::SetColor (const Quantity_Color& theColor)
400 const bool toRecompute = setColor (myDrawer, theColor);
401 myDrawer->SetColor (theColor);
402 hasOwnColor = Standard_True;
405 || !myDrawer->HasLink())
407 SynchronizeAspects();
411 replaceWithNewOwnAspects();
416 //=======================================================================
417 //function : UnsetColor
419 //=======================================================================
421 void AIS_Shape::UnsetColor()
428 hasOwnColor = Standard_False;
429 myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
431 Graphic3d_MapOfAspectsToAspects aReplaceMap;
434 replaceAspectWithDef (aReplaceMap, LineAspect);
435 replaceAspectWithDef (aReplaceMap, WireAspect);
436 replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
437 replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
438 replaceAspectWithDef (aReplaceMap, SeenLineAspect);
439 replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
440 myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
441 myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
442 myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
443 myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
444 myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
445 myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
449 Quantity_Color aColor = Quantity_NOC_YELLOW;
450 if (myDrawer->HasLink())
452 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
454 myDrawer->LineAspect()->SetColor (aColor);
455 aColor = Quantity_NOC_RED;
456 if (myDrawer->HasLink())
458 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
460 myDrawer->WireAspect()->SetColor (aColor);
461 aColor = Quantity_NOC_GREEN;
462 if (myDrawer->HasLink())
464 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
466 myDrawer->FreeBoundaryAspect()->SetColor (aColor);
467 aColor = Quantity_NOC_YELLOW;
468 if (myDrawer->HasLink())
470 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
472 myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
473 if (myDrawer->HasLink())
475 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
477 myDrawer->SeenLineAspect()->SetColor (aColor);
478 aColor = Quantity_NOC_BLACK;
479 if (myDrawer->HasLink())
481 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_FaceBoundary, aColor);
483 myDrawer->FaceBoundaryAspect()->SetColor (aColor);
486 if (!myDrawer->HasOwnShadingAspect())
490 else if (HasMaterial()
492 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
494 const Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
495 Graphic3d_MaterialAspect mat = aDefaultMat;
496 Quantity_Color anInteriorColors[2] = {Quantity_NOC_CYAN1, Quantity_NOC_CYAN1};
497 if (myDrawer->HasLink())
499 anInteriorColors[0] = myDrawer->Link()->ShadingAspect()->Aspect()->InteriorColor();
500 anInteriorColors[1] = myDrawer->Link()->ShadingAspect()->Aspect()->BackInteriorColor();
502 if (HasMaterial() || myDrawer->HasLink())
504 const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect = (HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
505 mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE
506 ? aSrcAspect->FrontMaterial()
507 : aSrcAspect->BackMaterial();
511 const Quantity_Color aColor = myDrawer->HasLink()
512 ? myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel)
513 : aDefaultMat.AmbientColor();
514 mat.SetColor (aColor);
518 Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
519 mat.SetTransparency (Standard_ShortReal(aTransp));
521 myDrawer->ShadingAspect()->SetMaterial (mat, myCurrentFacingModel);
522 myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (anInteriorColors[0]);
523 myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor(anInteriorColors[1]);
527 replaceAspectWithDef (aReplaceMap, ShadingAspect);
528 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
530 if (myDrawer->HasOwnPointAspect())
532 replaceAspectWithDef (aReplaceMap, PointAspect);
533 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
535 replaceAspects (aReplaceMap);
536 SynchronizeAspects();
540 //=======================================================================
541 //function : setWidth
543 //=======================================================================
545 bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
546 const Standard_Real theLineWidth) const
548 bool toRecompute = theDrawer->SetOwnLineAspects();
551 theDrawer->LineAspect()->SetWidth (theLineWidth);
552 theDrawer->WireAspect()->SetWidth (theLineWidth);
553 theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
554 theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
555 theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
556 theDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
560 //=======================================================================
561 //function : SetWidth
563 //=======================================================================
565 void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
567 myOwnWidth = (Standard_ShortReal )theLineWidth;
569 if (!setWidth (myDrawer, theLineWidth)
570 || !myDrawer->HasLink())
572 SynchronizeAspects();
576 replaceWithNewOwnAspects();
581 //=======================================================================
582 //function : UnsetWidth
584 //=======================================================================
586 void AIS_Shape::UnsetWidth()
588 if (myOwnWidth == 0.0f)
596 Graphic3d_MapOfAspectsToAspects aReplaceMap;
597 replaceAspectWithDef (aReplaceMap, LineAspect);
598 replaceAspectWithDef (aReplaceMap, WireAspect);
599 replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
600 replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
601 replaceAspectWithDef (aReplaceMap, SeenLineAspect);
602 replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
603 myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
604 myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
605 myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
606 myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
607 myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
608 myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
609 replaceAspects (aReplaceMap);
613 myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
614 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
615 myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
616 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
617 myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
618 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
619 myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
620 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
621 myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
622 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
623 myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
624 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
625 SynchronizeAspects();
630 //=======================================================================
631 //function : setMaterial
633 //=======================================================================
635 void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
636 const Graphic3d_MaterialAspect& theMaterial,
637 const Standard_Boolean theToKeepColor,
638 const Standard_Boolean theToKeepTransp) const
640 const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
641 const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
642 theDrawer->SetupOwnShadingAspect();
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 : SetHLROwnDeviationCoefficient
819 //purpose : resets myhasOwnHLRDeviationCoefficient to Standard_False and
820 // returns Standard_True if it change
821 //=======================================================================
823 Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
825 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
826 if(itSet) myDrawer->SetHLRDeviationCoefficient();
831 //=======================================================================
832 //function : SetOwnDeviationAngle
833 //purpose : resets myhasOwnDeviationAngle to Standard_False and
834 // returns Standard_True if it change
835 //=======================================================================
837 Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
839 Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
840 if(itSet) myDrawer->SetDeviationAngle();
845 //=======================================================================
846 //function : SetOwnHLRDeviationAngle
847 //purpose : resets myhasOwnHLRDeviationAngle to Standard_False and
848 // returns Standard_True if it change
849 //=======================================================================
851 Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
853 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
854 if(itSet) myDrawer->SetHLRAngle();
859 //=======================================================================
860 //function : SetOwnDeviationCoefficient
862 //=======================================================================
864 void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
866 myDrawer->SetDeviationCoefficient( aCoefficient );
870 //=======================================================================
871 //function : SetOwnHLRDeviationCoefficient
873 //=======================================================================
875 void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficient )
877 myDrawer->SetHLRDeviationCoefficient( aCoefficient );
881 //=======================================================================
882 //function : SetOwnDeviationAngle
884 //=======================================================================
886 void AIS_Shape::SetOwnDeviationAngle (const Standard_Real theAngle)
888 myDrawer->SetDeviationAngle (theAngle);
889 SetToUpdate (AIS_WireFrame);
891 //=======================================================================
892 //function : SetOwnDeviationAngle
894 //=======================================================================
896 void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
898 Standard_Real OutAngl,OutDefl;
899 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
900 SetOwnDeviationAngle(anAngle) ;
901 SetOwnDeviationCoefficient(OutDefl) ;
906 //=======================================================================
907 //function : UserAngle
909 //=======================================================================
911 Standard_Real AIS_Shape::UserAngle() const
913 return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng;
917 //=======================================================================
918 //function : SetHLRAngleAndDeviation
920 //=======================================================================
922 void AIS_Shape::SetHLRAngleAndDeviation ( const Standard_Real anAngle )
924 Standard_Real OutAngl,OutDefl;
925 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
926 SetOwnHLRDeviationAngle( OutAngl );
927 SetOwnHLRDeviationCoefficient(OutDefl);
930 //=======================================================================
931 //function : SetOwnHLRDeviationAngle
933 //=======================================================================
935 void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real anAngle )
937 myDrawer->SetHLRAngle( anAngle );
941 //=======================================================================
942 //function : OwnDeviationCoefficient
944 //=======================================================================
946 Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
947 Standard_Real & aPreviousCoefficient ) const
949 aCoefficient = myDrawer->DeviationCoefficient();
950 aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
951 return myDrawer->HasOwnDeviationCoefficient() ;
954 //=======================================================================
955 //function : OwnHLRDeviationCoefficient
957 //=======================================================================
959 Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
960 Standard_Real & aPreviousCoefficient ) const
962 aCoefficient = myDrawer->HLRDeviationCoefficient();
963 aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
964 return myDrawer->HasOwnHLRDeviationCoefficient();
968 //=======================================================================
969 //function : OwnDeviationAngle
971 //=======================================================================
973 Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
974 Standard_Real & aPreviousAngle ) const
976 anAngle = myDrawer->DeviationAngle();
977 aPreviousAngle = myDrawer->PreviousDeviationAngle ();
978 return myDrawer->HasOwnDeviationAngle();
981 //=======================================================================
982 //function : OwnHLRDeviationAngle
984 //=======================================================================
986 Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
987 Standard_Real & aPreviousAngle ) const
989 anAngle = myDrawer->HLRAngle();
990 aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
991 return myDrawer->HasOwnHLRDeviationAngle();