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