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