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