0030510: Application Framework - add missing NULL check within TDataStd_RealArray...
[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
7604a153 349bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
6262338c 350 const Quantity_Color& theColor) const
7fd59977 351{
7604a153 352 bool toRecompute = false;
6262338c 353 if (!theDrawer->HasOwnShadingAspect())
ad3217cd 354 {
7604a153 355 toRecompute = true;
ad3217cd 356 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 357 if (theDrawer->HasLink())
358 {
359 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
360 }
7fd59977 361 }
6262338c 362 if (!theDrawer->HasOwnLineAspect())
ad3217cd 363 {
7604a153 364 toRecompute = true;
ad3217cd 365 theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 366 if (theDrawer->HasLink())
367 {
368 *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
369 }
ad3217cd 370 }
6262338c 371 if (!theDrawer->HasOwnWireAspect())
ad3217cd 372 {
7604a153 373 toRecompute = true;
ad3217cd 374 theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 375 if (theDrawer->HasLink())
376 {
377 *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
378 }
ad3217cd 379 }
6262338c 380 if (!theDrawer->HasOwnPointAspect())
ad3217cd 381 {
7604a153 382 toRecompute = true;
7d835040 383 theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
6262338c 384 if (theDrawer->HasLink())
385 {
386 *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
387 }
ad3217cd 388 }
8a5dfb38 389 if (!theDrawer->HasOwnFreeBoundaryAspect())
390 {
7604a153 391 toRecompute = true;
8a5dfb38 392 theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
393 if (theDrawer->HasLink())
394 {
395 *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
396 }
397 }
398 if (!theDrawer->HasOwnUnFreeBoundaryAspect())
399 {
7604a153 400 toRecompute = true;
8a5dfb38 401 theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
402 if (theDrawer->HasLink())
403 {
404 *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
405 }
406 }
407 if (!theDrawer->HasOwnSeenLineAspect())
408 {
7604a153 409 toRecompute = true;
8a5dfb38 410 theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
411 if (theDrawer->HasLink())
412 {
413 *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
414 }
415 }
7604a153 416 if (!theDrawer->HasOwnFaceBoundaryAspect())
417 {
418 toRecompute = true;
419 theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
420 if (theDrawer->HasLink())
421 {
422 *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
423 }
424 }
ad3217cd 425
426 // override color
427 theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
ad3217cd 428 theDrawer->LineAspect()->SetColor (theColor);
429 theDrawer->WireAspect()->SetColor (theColor);
430 theDrawer->PointAspect()->SetColor (theColor);
8a5dfb38 431 theDrawer->FreeBoundaryAspect()->SetColor (theColor);
432 theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
433 theDrawer->SeenLineAspect()->SetColor (theColor);
7604a153 434 theDrawer->FaceBoundaryAspect()->SetColor (theColor);
435 return toRecompute;
ad3217cd 436}
a10fa819 437
ad3217cd 438//=======================================================================
439//function : SetColor
440//purpose :
441//=======================================================================
7fd59977 442
ad3217cd 443void AIS_Shape::SetColor (const Quantity_Color& theColor)
444{
7604a153 445 const bool toRecompute = setColor (myDrawer, theColor);
f838dac4 446 myDrawer->SetColor (theColor);
ad3217cd 447 hasOwnColor = Standard_True;
7604a153 448 if (!toRecompute)
449 {
450 myToRecomputeModes.Clear();
451 myRecomputeEveryPrs = false;
452 SynchronizeAspects();
453 return;
454 }
7fd59977 455
48cc825e 456 // modify shading presentation without re-computation
457 const PrsMgr_Presentations& aPrsList = Presentations();
458 Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
459 Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
460 Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
461 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 462 {
48cc825e 463 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
464 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 465 {
48cc825e 466 continue;
467 }
468
469 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
48cc825e 470 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
471 {
472 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
473
a10fa819
A
474 // Check if aspect of given type is set for the group,
475 // because setting aspect for group with no already set aspect
476 // can lead to loss of presentation data
48cc825e 477 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
ad3217cd 478 {
48cc825e 479 aGroup->SetGroupPrimitivesAspect (anAreaAspect);
ad3217cd 480 }
48cc825e 481 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
ad3217cd 482 {
48cc825e 483 aGroup->SetGroupPrimitivesAspect (aLineAspect);
ad3217cd 484 }
48cc825e 485 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
ad3217cd 486 {
48cc825e 487 aGroup->SetGroupPrimitivesAspect (aPointAspect);
ad3217cd 488 }
a10fa819 489 }
7fd59977 490 }
491
ad3217cd 492 LoadRecomputable (AIS_WireFrame);
493 LoadRecomputable (2);
7fd59977 494}
5cbef0fe 495
7fd59977 496//=======================================================================
497//function : UnsetColor
ad3217cd 498//purpose :
7fd59977 499//=======================================================================
500
501void AIS_Shape::UnsetColor()
502{
ad3217cd 503 if (!HasColor())
5cbef0fe
S
504 {
505 myToRecomputeModes.Clear();
7604a153 506 myRecomputeEveryPrs = false;
5cbef0fe
S
507 return;
508 }
7604a153 509
7fd59977 510 hasOwnColor = Standard_False;
a6dee93d 511 myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
7fd59977 512
ad3217cd 513 if (!HasWidth())
514 {
515 Handle(Prs3d_LineAspect) anEmptyAsp;
516 myDrawer->SetLineAspect (anEmptyAsp);
517 myDrawer->SetWireAspect (anEmptyAsp);
518 myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
519 myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
520 myDrawer->SetSeenLineAspect (anEmptyAsp);
7604a153 521 myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
ad3217cd 522 }
523 else
524 {
6262338c 525 Quantity_Color aColor = Quantity_NOC_YELLOW;
526 if (myDrawer->HasLink())
527 {
528 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
529 }
ad3217cd 530 myDrawer->LineAspect()->SetColor (aColor);
6262338c 531 aColor = Quantity_NOC_RED;
532 if (myDrawer->HasLink())
533 {
534 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
535 }
ad3217cd 536 myDrawer->WireAspect()->SetColor (aColor);
6262338c 537 aColor = Quantity_NOC_GREEN;
538 if (myDrawer->HasLink())
539 {
540 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
541 }
ad3217cd 542 myDrawer->FreeBoundaryAspect()->SetColor (aColor);
6262338c 543 aColor = Quantity_NOC_YELLOW;
544 if (myDrawer->HasLink())
545 {
546 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
547 }
ad3217cd 548 myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
6262338c 549 if (myDrawer->HasLink())
550 {
551 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
552 }
ad3217cd 553 myDrawer->SeenLineAspect()->SetColor (aColor);
7604a153 554 aColor = Quantity_NOC_BLACK;
555 if (myDrawer->HasLink())
556 {
557 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_FaceBoundary, aColor);
558 }
559 myDrawer->FaceBoundaryAspect()->SetColor (aColor);
ad3217cd 560 }
561
a6dee93d 562 if (!myDrawer->HasOwnShadingAspect())
563 {
564 //
565 }
566 else if (HasMaterial()
567 || IsTransparent()
568 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
ad3217cd 569 {
a6dee93d 570 const Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
6262338c 571 Graphic3d_MaterialAspect mat = aDefaultMat;
a6dee93d 572 Quantity_Color anInteriorColors[2] = {Quantity_NOC_CYAN1, Quantity_NOC_CYAN1};
573 if (myDrawer->HasLink())
574 {
575 anInteriorColors[0] = myDrawer->Link()->ShadingAspect()->Aspect()->InteriorColor();
576 anInteriorColors[1] = myDrawer->Link()->ShadingAspect()->Aspect()->BackInteriorColor();
577 }
6262338c 578 if (HasMaterial() || myDrawer->HasLink())
579 {
a6dee93d 580 const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect = (HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
581 mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE
582 ? aSrcAspect->FrontMaterial()
583 : aSrcAspect->BackMaterial();
6262338c 584 }
ad3217cd 585 if (HasMaterial())
586 {
a6dee93d 587 const Quantity_Color aColor = myDrawer->HasLink()
588 ? myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel)
589 : aDefaultMat.AmbientColor();
ad3217cd 590 mat.SetColor (aColor);
5cbef0fe 591 }
ad3217cd 592 if (IsTransparent())
593 {
594 Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
4e1bc39a 595 mat.SetTransparency (Standard_ShortReal(aTransp));
5cbef0fe 596 }
a6dee93d 597 myDrawer->ShadingAspect()->SetMaterial (mat, myCurrentFacingModel);
598 myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (anInteriorColors[0]);
599 myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor(anInteriorColors[1]);
5cbef0fe 600 }
ad3217cd 601 else
602 {
603 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
5cbef0fe 604 }
ad3217cd 605 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7604a153 606 myRecomputeEveryPrs = true;
ad3217cd 607}
608
609//=======================================================================
610//function : setWidth
611//purpose :
612//=======================================================================
613
7604a153 614bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
6262338c 615 const Standard_Real theLineWidth) const
ad3217cd 616{
7604a153 617 bool toRecompute = false;
6262338c 618 if (!theDrawer->HasOwnLineAspect())
ad3217cd 619 {
7604a153 620 toRecompute = true;
ad3217cd 621 theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 622 if (theDrawer->HasLink())
623 {
624 *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
625 }
ad3217cd 626 }
6262338c 627 if (!theDrawer->HasOwnWireAspect())
ad3217cd 628 {
7604a153 629 toRecompute = true;
ad3217cd 630 theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 631 if (theDrawer->HasLink())
632 {
633 *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
634 }
ad3217cd 635 }
8a5dfb38 636 if (!theDrawer->HasOwnFreeBoundaryAspect())
637 {
7604a153 638 toRecompute = true;
8a5dfb38 639 theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
640 if (theDrawer->HasLink())
641 {
642 *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
643 }
644 }
645 if (!theDrawer->HasOwnUnFreeBoundaryAspect())
646 {
7604a153 647 toRecompute = true;
8a5dfb38 648 theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
649 if (theDrawer->HasLink())
650 {
651 *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
652 }
653 }
654 if (!theDrawer->HasOwnSeenLineAspect())
655 {
7604a153 656 toRecompute = true;
8a5dfb38 657 theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
658 if (theDrawer->HasLink())
659 {
660 *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
661 }
662 }
7604a153 663 if (!theDrawer->HasOwnFaceBoundaryAspect())
664 {
665 toRecompute = true;
666 theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
667 if (theDrawer->HasLink())
668 {
669 *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
670 }
671 }
ad3217cd 672
673 // override width
674 theDrawer->LineAspect()->SetWidth (theLineWidth);
675 theDrawer->WireAspect()->SetWidth (theLineWidth);
8a5dfb38 676 theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
677 theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
678 theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
7604a153 679 theDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
680 return toRecompute;
7fd59977 681}
682
7fd59977 683//=======================================================================
684//function : SetWidth
685//purpose :
686//=======================================================================
687
ad3217cd 688void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
7fd59977 689{
ad3217cd 690 myOwnWidth = theLineWidth;
7604a153 691 if (setWidth (myDrawer, theLineWidth))
692 {
693 myRecomputeEveryPrs = true;
694 }
695 else
696 {
697 myRecomputeEveryPrs = false;
698 myToRecomputeModes.Clear();
699 SynchronizeAspects();
700 }
7fd59977 701}
702
703//=======================================================================
704//function : UnsetWidth
ad3217cd 705//purpose :
7fd59977 706//=======================================================================
707
708void AIS_Shape::UnsetWidth()
709{
ad3217cd 710 if (myOwnWidth == 0.0)
5cbef0fe
S
711 {
712 myToRecomputeModes.Clear();
7604a153 713 myRecomputeEveryPrs = false;
5cbef0fe
S
714 return;
715 }
5cbef0fe 716
ad3217cd 717 myOwnWidth = 0.0;
ad3217cd 718 if (!HasColor())
719 {
7604a153 720 const Handle(Prs3d_LineAspect) anEmptyAsp;
ad3217cd 721 myDrawer->SetLineAspect (anEmptyAsp);
722 myDrawer->SetWireAspect (anEmptyAsp);
723 myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
724 myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
725 myDrawer->SetSeenLineAspect (anEmptyAsp);
7604a153 726 myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
727 myRecomputeEveryPrs = true;
7fd59977 728 }
ad3217cd 729 else
730 {
6262338c 731 myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
732 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
733 myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
734 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
735 myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
736 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
737 myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
738 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
739 myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
740 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
7604a153 741 myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
742 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
743 SynchronizeAspects();
744 myToRecomputeModes.Clear();
745 myRecomputeEveryPrs = false;
7fd59977 746 }
7fd59977 747}
748
e0608a8d 749//=======================================================================
750//function : setMaterial
751//purpose :
752//=======================================================================
753
6262338c 754void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
e0608a8d 755 const Graphic3d_MaterialAspect& theMaterial,
756 const Standard_Boolean theToKeepColor,
757 const Standard_Boolean theToKeepTransp) const
758{
759 const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
760 const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
6262338c 761 if (!theDrawer->HasOwnShadingAspect())
e0608a8d 762 {
763 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 764 if (theDrawer->HasLink())
765 {
766 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
767 }
e0608a8d 768 }
769 theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
770
771 if (theToKeepColor)
772 {
773 theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
774 }
775 if (theToKeepTransp)
776 {
777 theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
778 }
779}
780
7fd59977 781//=======================================================================
782//function : SetMaterial
ad3217cd 783//purpose :
7fd59977 784//=======================================================================
5cbef0fe 785
ad3217cd 786void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
7fd59977 787{
e0608a8d 788 setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
7fd59977 789 hasOwnMaterial = Standard_True;
5cbef0fe 790
48cc825e 791 // modify shading presentation without re-computation
792 const PrsMgr_Presentations& aPrsList = Presentations();
793 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
794 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 795 {
48cc825e 796 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
797 if (aPrsModed.Mode() != AIS_Shaded)
af324faa 798 {
48cc825e 799 continue;
800 }
801
802 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
48cc825e 803 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
804 {
805 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
806
a10fa819
A
807 // Check if aspect of given type is set for the group,
808 // because setting aspect for group with no already set aspect
809 // can lead to loss of presentation data
ad3217cd 810 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
811 {
812 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
813 }
5cbef0fe 814 }
7fd59977 815 }
48cc825e 816
817 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
818 myToRecomputeModes.Clear();
7fd59977 819}
ad3217cd 820
7fd59977 821//=======================================================================
822//function : UnsetMaterial
ad3217cd 823//purpose :
7fd59977 824//=======================================================================
5cbef0fe 825
7fd59977 826void AIS_Shape::UnsetMaterial()
827{
ad3217cd 828 if (!HasMaterial())
829 {
830 return;
831 }
5cbef0fe 832
a6dee93d 833 if (!myDrawer->HasOwnShadingAspect())
834 {
835 //
836 }
837 else if (HasColor()
838 || IsTransparent()
839 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
ad3217cd 840 {
6262338c 841 if(myDrawer->HasLink())
842 {
843 myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
844 myCurrentFacingModel);
845 }
ad3217cd 846 if (HasColor())
847 {
f838dac4 848 myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
849 myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
7fd59977 850 }
ad3217cd 851 }
852 else
853 {
854 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
7fd59977 855 }
856 hasOwnMaterial = Standard_False;
ad3217cd 857
48cc825e 858 // modify shading presentation without re-computation
859 const PrsMgr_Presentations& aPrsList = Presentations();
860 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
861 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 862 {
48cc825e 863 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
864 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 865 {
48cc825e 866 continue;
867 }
868
869 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
48cc825e 870 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
871 {
872 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 873 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
874 {
875 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
876 }
7fd59977 877 }
878 }
48cc825e 879
ad3217cd 880 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
7fd59977 881 myToRecomputeModes.Clear();
7fd59977 882}
5cbef0fe 883
7fd59977 884//=======================================================================
ad3217cd 885//function : setTransparency
886//purpose :
7fd59977 887//=======================================================================
888
6262338c 889void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
890 const Standard_Real theValue) const
7fd59977 891{
6262338c 892 if (!theDrawer->HasOwnShadingAspect())
ad3217cd 893 {
894 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 895 if (theDrawer->HasLink())
896 {
897 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
898 }
7fd59977 899 }
5cbef0fe 900
ad3217cd 901 // override transparency
902 theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
903}
904
905//=======================================================================
906//function : SetTransparency
907//purpose :
908//=======================================================================
909
910void AIS_Shape::SetTransparency (const Standard_Real theValue)
911{
912 setTransparency (myDrawer, theValue);
f838dac4 913 myDrawer->SetTransparency ((Standard_ShortReal )theValue);
ad3217cd 914
48cc825e 915 // modify shading presentation without re-computation
916 const PrsMgr_Presentations& aPrsList = Presentations();
917 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
918 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 919 {
48cc825e 920 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
921 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 922 {
48cc825e 923 continue;
924 }
925
926 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
48cc825e 927 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
928 {
929 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 930 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
931 {
932 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
933 }
7fd59977 934 }
935 }
48cc825e 936
ad3217cd 937 myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
5cbef0fe 938 myToRecomputeModes.Clear();
7fd59977 939}
940
941//=======================================================================
942//function : UnsetTransparency
ad3217cd 943//purpose :
7fd59977 944//=======================================================================
5cbef0fe 945
7fd59977 946void AIS_Shape::UnsetTransparency()
947{
f838dac4 948 myDrawer->SetTransparency (0.0f);
6262338c 949 if (!myDrawer->HasOwnShadingAspect())
ad3217cd 950 {
951 return;
952 }
a6dee93d 953 else if (HasColor()
954 || HasMaterial()
955 || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
ad3217cd 956 {
957 myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
958 }
959 else
960 {
961 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
962 }
5cbef0fe 963
48cc825e 964 // modify shading presentation without re-computation
965 const PrsMgr_Presentations& aPrsList = Presentations();
966 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
967 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 968 {
48cc825e 969 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
970 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 971 {
48cc825e 972 continue;
973 }
974
975 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
48cc825e 976 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
977 {
978 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 979 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
980 {
981 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
982 }
7fd59977 983 }
984 }
48cc825e 985
ad3217cd 986 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
5cbef0fe 987 myToRecomputeModes.Clear();
7fd59977 988}
989
5cbef0fe
S
990//=======================================================================
991//function : LoadRecomputable
992//purpose :
993//=======================================================================
7fd59977 994
995void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
996{
5cbef0fe 997 myRecomputeEveryPrs = Standard_False;
7fd59977 998 if(!IsInList(myToRecomputeModes,TheMode))
999 myToRecomputeModes.Append(TheMode);
1000}
1001
7fd59977 1002//=======================================================================
1003//function : BoundingBox
1004//purpose :
1005//=======================================================================
1006
1007const Bnd_Box& AIS_Shape::BoundingBox()
1008{
b2d1851c 1009 if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
1010 {
1011 // empty Shape -> empty Assembly.
1012 myBB.SetVoid ();
1013 return myBB;
7fd59977 1014 }
1015
1016 if(myCompBB) {
1017 BRepBndLib::AddClose(myshape, myBB);
a10fa819 1018 myCompBB = Standard_False;
7fd59977 1019 }
1020 return myBB;
1021}
1022
1023//*****
1024//***** Reset
1025//=======================================================================
1026//function : SetOwnDeviationCoefficient
1027//purpose : resets myhasOwnDeviationCoefficient to Standard_False and
1028// returns Standard_True if it change
1029//=======================================================================
1030
1031Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
1032{
6262338c 1033 Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
7fd59977 1034 if(itSet) myDrawer->SetDeviationCoefficient();
1035 return itSet;
7fd59977 1036}
1037
7fd59977 1038//=======================================================================
1039//function : SetHLROwnDeviationCoefficient
1040//purpose : resets myhasOwnHLRDeviationCoefficient to Standard_False and
1041// returns Standard_True if it change
1042//=======================================================================
1043
1044Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
1045{
6262338c 1046 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
7fd59977 1047 if(itSet) myDrawer->SetHLRDeviationCoefficient();
1048 return itSet;
1049
1050}
1051
1052//=======================================================================
1053//function : SetOwnDeviationAngle
1054//purpose : resets myhasOwnDeviationAngle to Standard_False and
1055// returns Standard_True if it change
1056//=======================================================================
1057
1058Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
1059{
6262338c 1060 Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
7fd59977 1061 if(itSet) myDrawer->SetDeviationAngle();
1062 return itSet;
1063
1064}
1065
1066//=======================================================================
1067//function : SetOwnHLRDeviationAngle
1068//purpose : resets myhasOwnHLRDeviationAngle to Standard_False and
1069// returns Standard_True if it change
1070//=======================================================================
1071
1072Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
1073{
6262338c 1074 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
7fd59977 1075 if(itSet) myDrawer->SetHLRAngle();
1076 return itSet;
1077
1078}
1079//***** SetOwn
1080//=======================================================================
1081//function : SetOwnDeviationCoefficient
1082//purpose :
1083//=======================================================================
1084
1085void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
1086{
1087 myDrawer->SetDeviationCoefficient( aCoefficient );
1088 SetToUpdate(0) ; // WireFrame
1089 SetToUpdate(1) ; // Shadding
1090}
1091
1092//=======================================================================
1093//function : SetOwnHLRDeviationCoefficient
1094//purpose :
1095//=======================================================================
1096
1097void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficient )
1098{
1099 myDrawer->SetHLRDeviationCoefficient( aCoefficient );
1100
1101}
1102
1103//=======================================================================
1104//function : SetOwnDeviationAngle
1105//purpose :
1106//=======================================================================
1107
1108void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle )
1109{
1110
1111 myDrawer->SetDeviationAngle(anAngle );
1112 SetToUpdate(0) ; // WireFrame
1113}
1114//=======================================================================
1115//function : SetOwnDeviationAngle
1116//purpose :
1117//=======================================================================
1118
1119void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
1120{
1121 Standard_Real OutAngl,OutDefl;
1122 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1123 SetOwnDeviationAngle(anAngle) ;
7fd59977 1124 SetOwnDeviationCoefficient(OutDefl) ;
1125 myInitAng = anAngle;
1126 SetToUpdate(0);
1127 SetToUpdate(1);
1128}
1129
1130//=======================================================================
1131//function : UserAngle
1132//purpose :
1133//=======================================================================
1134
1135Standard_Real AIS_Shape::UserAngle() const
1136{
1137 return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng;
1138}
1139
1140
1141//=======================================================================
1142//function : SetHLRAngleAndDeviation
1143//purpose :
1144//=======================================================================
1145
1146void AIS_Shape::SetHLRAngleAndDeviation ( const Standard_Real anAngle )
1147{
1148 Standard_Real OutAngl,OutDefl;
1149 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1150 SetOwnHLRDeviationAngle( OutAngl );
1151 SetOwnHLRDeviationCoefficient(OutDefl);
1152
1153}
1154//=======================================================================
1155//function : SetOwnHLRDeviationAngle
1156//purpose :
1157//=======================================================================
1158
1159void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real anAngle )
1160{
1161 myDrawer->SetHLRAngle( anAngle );
1162}
1163
1164//***** GetOwn
1165//=======================================================================
1166//function : OwnDeviationCoefficient
1167//purpose :
1168//=======================================================================
1169
1170Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
3c34883c 1171 Standard_Real & aPreviousCoefficient ) const
7fd59977 1172{
1173 aCoefficient = myDrawer->DeviationCoefficient();
1174 aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
6262338c 1175 return myDrawer->HasOwnDeviationCoefficient() ;
7fd59977 1176}
1177
1178//=======================================================================
1179//function : OwnHLRDeviationCoefficient
1180//purpose :
1181//=======================================================================
1182
1183Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
3c34883c 1184 Standard_Real & aPreviousCoefficient ) const
7fd59977 1185{
1186 aCoefficient = myDrawer->HLRDeviationCoefficient();
1187 aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
6262338c 1188 return myDrawer->HasOwnHLRDeviationCoefficient();
7fd59977 1189
1190}
1191
1192//=======================================================================
1193//function : OwnDeviationAngle
1194//purpose :
1195//=======================================================================
1196
1197Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
3c34883c 1198 Standard_Real & aPreviousAngle ) const
7fd59977 1199{
1200 anAngle = myDrawer->DeviationAngle();
1201 aPreviousAngle = myDrawer->PreviousDeviationAngle ();
6262338c 1202 return myDrawer->HasOwnDeviationAngle();
7fd59977 1203}
1204
1205//=======================================================================
1206//function : OwnHLRDeviationAngle
1207//purpose :
1208//=======================================================================
1209
1210Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
3c34883c 1211 Standard_Real & aPreviousAngle ) const
7fd59977 1212{
1213 anAngle = myDrawer->HLRAngle();
1214 aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
6262338c 1215 return myDrawer->HasOwnHLRDeviationAngle();
7fd59977 1216}