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