0024977: There are compilation errors in products csharp sample
[occt.git] / src / AIS / AIS_MultipleConnectedShape.cxx
CommitLineData
b311480e 1// Created on: 1997-04-22
2// Created by: Guest Design
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// <g_design>
18
19
20#include <Standard_NotImplemented.hxx>
21
22#include <AIS_MultipleConnectedShape.ixx>
23
24
25
26#include <AIS_InteractiveContext.hxx>
27#include <AIS_Drawer.hxx>
28#include <TopAbs_ShapeEnum.hxx>
29#include <StdPrs_WFDeflectionShape.hxx>
30#include <StdPrs_HLRPolyShape.hxx>
31#include <Prs3d_Drawer.hxx>
32#include <Aspect_TypeOfDeflection.hxx>
33#include <Bnd_Box.hxx>
34#include <BRepTools.hxx>
35#include <BRepBndLib.hxx>
36#include <OSD_Timer.hxx>
37#include <StdSelect_BRepSelectionTool.hxx>
38#include <StdSelect.hxx>
39#include <Precision.hxx>
40
41//=======================================================================
42//function : AIS_ConnectedShape
43//purpose :
44//=======================================================================
45
46AIS_MultipleConnectedShape::AIS_MultipleConnectedShape (const TopoDS_Shape& aShape):
47AIS_MultipleConnectedInteractive(PrsMgr_TOP_ProjectorDependant),
48myShape(aShape)
49{
50}
51
52//=======================================================================
53//function : Type
54//purpose :
55//=======================================================================
56AIS_KindOfInteractive AIS_MultipleConnectedShape::Type() const
57{return AIS_KOI_Shape;}
58
59
60//=======================================================================
61//function : Signature
62//purpose :
63//=======================================================================
64Standard_Integer AIS_MultipleConnectedShape::Signature() const
65{return 2;}
66
67
68//=======================================================================
69//function : AcceptShapeDecomposition
70//purpose :
71//=======================================================================
72
73Standard_Boolean AIS_MultipleConnectedShape::AcceptShapeDecomposition() const
74{return Standard_True;}
75
76
77
78
79//=======================================================================
80//function : Compute Hidden Lines
81//purpose :
82//=======================================================================
83
84void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
85 const Handle(Prs3d_Presentation)& aPresentation)
86{
87 Compute(aProjector,aPresentation,myShape);
88
89}
90
91//=======================================================================
92//function : Compute
93//purpose :
94//=======================================================================
95
96void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
97 const Handle(Geom_Transformation)& aTrsf,
98 const Handle(Prs3d_Presentation)& aPresentation)
99{
100 aPresentation->Clear();
101
102 const TopLoc_Location& loc = myShape.Location();
103 TopoDS_Shape shbis = myShape.Located(TopLoc_Location(aTrsf->Trsf())*loc);
104 Compute(aProjector,aPresentation,shbis);
105}
106
107
108
109
110void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
111 const Handle(Prs3d_Presentation)& aPresentation,
112 const TopoDS_Shape& SH)
113{
114 //Standard_Boolean recompute = Standard_False;
115 //Standard_Boolean myFirstCompute = Standard_True;
116 switch (SH.ShapeType()){
117 case TopAbs_VERTEX:
118 case TopAbs_EDGE:
119 case TopAbs_WIRE:
120 {
121 aPresentation->SetDisplayPriority(4);
122 StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer);
123 break;
124 }
125 default:
126 {
127
128 Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
129 if (defdrawer->DrawHiddenLine())
130 {myDrawer->EnableDrawHiddenLine();}
131 else {myDrawer->DisableDrawHiddenLine();}
132
133 Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
134 defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
135
136 // traitement HLRAngle et HLRDeviationCoefficient()
137 Standard_Real prevangl = myDrawer->HLRAngle();
138 Standard_Real newangl = defdrawer->HLRAngle();
139 if (Abs(newangl- prevangl) > Precision::Angular()) {
140#ifdef DEB
141 cout << "AIS_MultipleConnectedShape : compute"<<endl;
142 cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
143#endif
144 BRepTools::Clean(SH);
145 }
146 myDrawer->SetHLRAngle(newangl);
147 myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient());
148
149 StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
150
151
152 defdrawer->SetTypeOfDeflection (prevdef);
153
154 }
155 }
156}
157
158//=======================================================================
159//function : Compute
160//purpose :
161//=======================================================================
162
857ffd5e 163void AIS_MultipleConnectedShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager3d,
164 const Handle(Prs3d_Presentation)& aPresentation,
792c785c 165 const int anint)
7fd59977 166{
792c785c 167 AIS_MultipleConnectedInteractive::Compute( aPresentationManager3d , aPresentation , anint ) ;
7fd59977 168}
169
170//=======================================================================
7fd59977 171//function : ComputeSelection
172//purpose :
173//=======================================================================
174
175void AIS_MultipleConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
176 const Standard_Integer aMode)
177{
178 //cout<<"AIS_MultipleConnectedShape::ComputeSelection"<<endl;
179
180 Standard_Real aDeviationAngle = myDrawer->DeviationAngle();
181 Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
182 if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
183 {
184 // On calcule la fleche en fonction des min max globaux de la piece:
185 Bnd_Box aBndBox; //= BoundingBox(); ?
186 BRepBndLib::Add (myShape, aBndBox);
187 if (!aBndBox.IsVoid())
188 {
189 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
190 aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
191 aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
192 }
193 }
194
195 switch(aMode){
196 case 1:
197 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_VERTEX, aDeflection, aDeviationAngle);
198 break;
199 case 2:
200 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_EDGE, aDeflection, aDeviationAngle);
201 break;
202 case 3:
203 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_WIRE, aDeflection, aDeviationAngle);
204 break;
205 case 4:
206 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_FACE, aDeflection, aDeviationAngle);
207 break;
208 case 5:
209 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHELL, aDeflection, aDeviationAngle);
210 break;
211 case 6:
212 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SOLID, aDeflection, aDeviationAngle);
213 break;
214 case 7:
215 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPOUND, aDeflection, aDeviationAngle);
216 break;
217 case 8:
218 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPSOLID, aDeflection, aDeviationAngle);
219 break;
220 default:
221 StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHAPE, aDeflection, aDeviationAngle);
222 break;
223 }
224 // insert the drawer in the BrepOwners for hilight...
225 StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
226
227}
228
229
230
231