1 // File: AIS_MultipleConnectedShape.cxx
2 // Created: Tue Apr 22 17:43:42 1997
3 // Author: Guest Design
7 #include <Standard_NotImplemented.hxx>
9 #include <AIS_MultipleConnectedShape.ixx>
13 #include <AIS_InteractiveContext.hxx>
14 #include <AIS_Drawer.hxx>
15 #include <TopAbs_ShapeEnum.hxx>
16 #include <StdPrs_WFDeflectionShape.hxx>
17 #include <StdPrs_HLRPolyShape.hxx>
18 #include <Prs3d_Drawer.hxx>
19 #include <Aspect_TypeOfDeflection.hxx>
20 #include <Bnd_Box.hxx>
21 #include <BRepTools.hxx>
22 #include <BRepBndLib.hxx>
23 #include <OSD_Timer.hxx>
24 #include <StdSelect_BRepSelectionTool.hxx>
25 #include <StdSelect.hxx>
26 #include <Precision.hxx>
28 //=======================================================================
29 //function : AIS_ConnectedShape
31 //=======================================================================
33 AIS_MultipleConnectedShape::AIS_MultipleConnectedShape (const TopoDS_Shape& aShape):
34 AIS_MultipleConnectedInteractive(PrsMgr_TOP_ProjectorDependant),
39 //=======================================================================
42 //=======================================================================
43 AIS_KindOfInteractive AIS_MultipleConnectedShape::Type() const
44 {return AIS_KOI_Shape;}
47 //=======================================================================
48 //function : Signature
50 //=======================================================================
51 Standard_Integer AIS_MultipleConnectedShape::Signature() const
55 //=======================================================================
56 //function : AcceptShapeDecomposition
58 //=======================================================================
60 Standard_Boolean AIS_MultipleConnectedShape::AcceptShapeDecomposition() const
61 {return Standard_True;}
66 //=======================================================================
67 //function : Compute Hidden Lines
69 //=======================================================================
71 void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
72 const Handle(Prs3d_Presentation)& aPresentation)
74 Compute(aProjector,aPresentation,myShape);
78 //=======================================================================
81 //=======================================================================
83 void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
84 const Handle(Geom_Transformation)& aTrsf,
85 const Handle(Prs3d_Presentation)& aPresentation)
87 aPresentation->Clear();
89 const TopLoc_Location& loc = myShape.Location();
90 TopoDS_Shape shbis = myShape.Located(TopLoc_Location(aTrsf->Trsf())*loc);
91 Compute(aProjector,aPresentation,shbis);
97 void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
98 const Handle(Prs3d_Presentation)& aPresentation,
99 const TopoDS_Shape& SH)
101 //Standard_Boolean recompute = Standard_False;
102 //Standard_Boolean myFirstCompute = Standard_True;
103 switch (SH.ShapeType()){
108 aPresentation->SetDisplayPriority(4);
109 StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer);
115 Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
116 if (defdrawer->DrawHiddenLine())
117 {myDrawer->EnableDrawHiddenLine();}
118 else {myDrawer->DisableDrawHiddenLine();}
120 Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
121 defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
123 // traitement HLRAngle et HLRDeviationCoefficient()
124 Standard_Real prevangl = myDrawer->HLRAngle();
125 Standard_Real newangl = defdrawer->HLRAngle();
126 if (Abs(newangl- prevangl) > Precision::Angular()) {
128 cout << "AIS_MultipleConnectedShape : compute"<<endl;
129 cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
131 BRepTools::Clean(SH);
133 myDrawer->SetHLRAngle(newangl);
134 myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient());
136 StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
139 defdrawer->SetTypeOfDeflection (prevdef);
145 //=======================================================================
148 //=======================================================================
150 void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d& /*aPresentationManager3d*/,
151 const Handle_Prs3d_Presentation& /*aPresentation*/,
154 Standard_NotImplemented::Raise("AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d&, const Handle_Prs3d_Presentation&, const int)");
155 // AIS_MultipleConnectedInteractive::Compute( aPresentationManager3d , aPresentation , anint ) ; Not accessible
158 //=======================================================================
161 //=======================================================================
163 void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d,
164 const Handle_Graphic2d_GraphicObject& aGraphicObject,
167 // Standard_NotImplemented::Raise("AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
168 PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
171 //=======================================================================
172 //function : ComputeSelection
174 //=======================================================================
176 void AIS_MultipleConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
177 const Standard_Integer aMode)
179 //cout<<"AIS_MultipleConnectedShape::ComputeSelection"<<endl;
181 Standard_Real aDeviationAngle = myDrawer->DeviationAngle();
182 Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
183 if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
185 // On calcule la fleche en fonction des min max globaux de la piece:
186 Bnd_Box aBndBox; //= BoundingBox(); ?
187 BRepBndLib::Add (myShape, aBndBox);
188 if (!aBndBox.IsVoid())
190 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
191 aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
192 aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
198 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_VERTEX, aDeflection, aDeviationAngle);
201 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_EDGE, aDeflection, aDeviationAngle);
204 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_WIRE, aDeflection, aDeviationAngle);
207 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_FACE, aDeflection, aDeviationAngle);
210 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHELL, aDeflection, aDeviationAngle);
213 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SOLID, aDeflection, aDeviationAngle);
216 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPOUND, aDeflection, aDeviationAngle);
219 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPSOLID, aDeflection, aDeviationAngle);
222 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHAPE, aDeflection, aDeviationAngle);
225 // insert the drawer in the BrepOwners for hilight...
226 StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);