0025687: Visualization, XCAF - eliminate visual artifacts at the edges of faces
[occt.git] / src / AIS / AIS_ColoredShape.cxx
CommitLineData
ad3217cd 1// Created on: 2014-04-24
2// Created by: Kirill Gavrilov
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <AIS_ColoredShape.hxx>
17
18#include <AIS_InteractiveContext.hxx>
19#include <BRep_Builder.hxx>
20#include <BRepTools.hxx>
21#include <gp_Pnt2d.hxx>
22#include <Graphic3d_AspectFillArea3d.hxx>
23#include <Graphic3d_AspectLine3d.hxx>
24#include <Graphic3d_Group.hxx>
25#include <Graphic3d_StructureManager.hxx>
26#include <Graphic3d_Texture2Dmanual.hxx>
27#include <Precision.hxx>
28#include <Prs3d_LineAspect.hxx>
29#include <Prs3d_IsoAspect.hxx>
30#include <Prs3d_Presentation.hxx>
31#include <Prs3d_ShadingAspect.hxx>
32#include <Prs3d_Root.hxx>
33#include <PrsMgr_PresentationManager3d.hxx>
34#include <Standard_ErrorHandler.hxx>
35#include <StdPrs_ShadedShape.hxx>
36#include <StdPrs_ToolShadedShape.hxx>
37#include <StdPrs_WFDeflectionShape.hxx>
38#include <StdPrs_WFShape.hxx>
39#include <TopExp_Explorer.hxx>
40#include <TopoDS.hxx>
41#include <TopoDS_Compound.hxx>
42#include <TopoDS_Iterator.hxx>
43
44IMPLEMENT_STANDARD_HANDLE (AIS_ColoredDrawer, AIS_Drawer)
45IMPLEMENT_STANDARD_RTTIEXT(AIS_ColoredDrawer, AIS_Drawer)
46
47IMPLEMENT_STANDARD_HANDLE (AIS_ColoredShape, AIS_Shape)
48IMPLEMENT_STANDARD_RTTIEXT(AIS_ColoredShape, AIS_Shape)
49
50//=======================================================================
51//function : AIS_ColoredShape
52//purpose :
53//=======================================================================
54AIS_ColoredShape::AIS_ColoredShape (const TopoDS_Shape& theShape)
55: AIS_Shape (theShape)
56{
57 // disable dedicated line aspects
58 myDrawer->SetFreeBoundaryAspect (myDrawer->LineAspect());
59 myDrawer->SetUnFreeBoundaryAspect(myDrawer->LineAspect());
60 myDrawer->SetSeenLineAspect (myDrawer->LineAspect());
61}
62
63//=======================================================================
64//function : AIS_ColoredShape
65//purpose :
66//=======================================================================
67AIS_ColoredShape::AIS_ColoredShape (const Handle(AIS_Shape)& theShape)
68: AIS_Shape (theShape->Shape())
69{
70 // disable dedicated line aspects
71 myDrawer->SetFreeBoundaryAspect (myDrawer->LineAspect());
72 myDrawer->SetUnFreeBoundaryAspect(myDrawer->LineAspect());
73 myDrawer->SetSeenLineAspect (myDrawer->LineAspect());
74 if (theShape->HasMaterial())
75 {
76 SetMaterial (theShape->Material());
77 }
78 if (theShape->HasColor())
79 {
80 SetColor (theShape->Color());
81 }
82 if (theShape->HasWidth())
83 {
84 SetWidth (theShape->Width());
85 }
86 if (theShape->IsTransparent())
87 {
88 SetTransparency (theShape->Transparency());
89 }
90}
91
92//=======================================================================
93//function : CustomAspects
94//purpose :
95//=======================================================================
96Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects (const TopoDS_Shape& theShape)
97{
98 Handle(AIS_ColoredDrawer) aDrawer;
99 myShapeColors.Find (theShape, aDrawer);
100 if (aDrawer.IsNull())
101 {
102 aDrawer = new AIS_ColoredDrawer (myDrawer);
103 myShapeColors.Bind (theShape, aDrawer);
104 LoadRecomputable (AIS_WireFrame);
105 LoadRecomputable (AIS_Shaded);
106 }
107 return aDrawer;
108}
109
110//=======================================================================
111//function : ClearCustomAspects
112//purpose :
113//=======================================================================
114void AIS_ColoredShape::ClearCustomAspects()
115{
116 if (myShapeColors.IsEmpty())
117 {
118 return;
119 }
120 myShapeColors.Clear();
121 LoadRecomputable (AIS_WireFrame);
122 LoadRecomputable (AIS_Shaded);
123}
124
125//=======================================================================
126//function : UnsetCustomAspects
127//purpose :
128//=======================================================================
129void AIS_ColoredShape::UnsetCustomAspects (const TopoDS_Shape& theShape,
130 const Standard_Boolean theToUnregister)
131{
132 if (!myShapeColors.IsBound (theShape))
133 {
134 return;
135 }
136
137 LoadRecomputable (AIS_WireFrame);
138 LoadRecomputable (AIS_Shaded);
139 if (theToUnregister)
140 {
141 myShapeColors.UnBind (theShape);
142 return;
143 }
144
145 myShapeColors.ChangeFind (theShape) = new AIS_ColoredDrawer (myDrawer);
146}
147
148//=======================================================================
149//function : SetCustomColor
150//purpose :
151//=======================================================================
152void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
153 const Quantity_Color& theColor)
154{
155 if (theShape.IsNull())
156 {
157 return;
158 }
159
160 const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
161 setColor (aDrawer, theColor);
162 aDrawer->SetOwnColor (theColor);
163 LoadRecomputable (AIS_WireFrame);
164 LoadRecomputable (AIS_Shaded);
165}
166
167//=======================================================================
168//function : SetCustomWidth
169//purpose :
170//=======================================================================
171void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
172 const Standard_Real theLineWidth)
173{
174 if (theShape.IsNull())
175 {
176 return;
177 }
178
179 const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape);
180 setWidth (CustomAspects (theShape), theLineWidth);
181 aDrawer->SetOwnWidth (theLineWidth);
182 LoadRecomputable (AIS_WireFrame);
183 LoadRecomputable (AIS_Shaded);
184}
185
186//=======================================================================
187//function : SetColor
188//purpose :
189//=======================================================================
190
191void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
192{
193 setColor (myDrawer, theColor);
194 myOwnColor = theColor;
195 hasOwnColor = Standard_True;
196 LoadRecomputable (AIS_WireFrame);
197 LoadRecomputable (AIS_Shaded);
198 for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
199 {
200 const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
201 if (aDrawer->HasOwnColor())
202 {
203 continue;
204 }
205
206 if (aDrawer->HasShadingAspect())
207 {
208 aDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
209 }
210 if (aDrawer->HasLineAspect())
211 {
212 aDrawer->LineAspect()->SetColor (theColor);
213 }
214 if (aDrawer->HasWireAspect())
215 {
216 aDrawer->WireAspect()->SetColor (theColor);
217 }
218 }
219}
220
221//=======================================================================
222//function : SetWidth
223//purpose :
224//=======================================================================
225
226void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth)
227{
228 setWidth (myDrawer, theLineWidth);
229 myOwnWidth = theLineWidth;
230 LoadRecomputable (AIS_WireFrame);
231 LoadRecomputable (AIS_Shaded);
232 for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
233 {
234 const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
235 if (aDrawer->HasOwnWidth())
236 {
237 continue;
238 }
239
240 if (aDrawer->HasLineAspect())
241 {
242 aDrawer->LineAspect()->SetWidth (theLineWidth);
243 }
244 if (aDrawer->HasWireAspect())
245 {
246 aDrawer->WireAspect()->SetWidth (theLineWidth);
247 }
248 }
249}
250
251//=======================================================================
252//function : SetTransparency
253//purpose :
254//=======================================================================
255
256void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
257{
258 setTransparency (myDrawer, theValue);
259 myTransparency = theValue;
260 LoadRecomputable (AIS_WireFrame);
261 LoadRecomputable (AIS_Shaded);
262 for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
263 {
264 const Handle(AIS_Drawer)& aDrawer = anIter.Value();
265 if (aDrawer->HasShadingAspect())
266 {
267 aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
268 }
269 }
270}
271
272//=======================================================================
e0608a8d 273//function : SetMaterial
274//purpose :
275//=======================================================================
276
277void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
278{
279 setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
280 //myOwnMaterial = theMaterial;
281 hasOwnMaterial = Standard_True;
282 LoadRecomputable (AIS_Shaded);
283 for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
284 {
285 const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
286 //if (aDrawer->HasOwnMaterial()) continue;
287 if (aDrawer->HasShadingAspect())
288 {
289 setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), Standard_False); // aDrawer->IsTransparent()
290 }
291 }
292}
293
294//=======================================================================
ad3217cd 295//function : Compute
296//purpose :
297//=======================================================================
298void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
299 const Handle(Prs3d_Presentation)& thePrs,
300 const Standard_Integer theMode)
301{
302 thePrs->Clear();
303 if (IsInfinite())
304 {
305 thePrs->SetInfiniteState (Standard_True);
306 }
307
ad3217cd 308 if (theMode == AIS_Shaded)
309 {
310 // compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
311 Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
312 Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
313 Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
314 if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
315 || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
316 {
317 BRepTools::Clean (myshape);
318 }
319 StdPrs_ShadedShape::Tessellate (myshape, myDrawer);
320 }
321
5bffb882 322 TopoDS_Compound anOpened, aClosed;
323 BRep_Builder aBuilder;
324 aBuilder.MakeCompound (aClosed);
325 aBuilder.MakeCompound (anOpened);
326 if (theMode == AIS_Shaded && myshape.ShapeType() <= TopAbs_SOLID)
327 {
328 StdPrs_ShadedShape::ExploreSolids (myshape, aBuilder, aClosed, anOpened, Standard_False);
329 }
330 else
331 {
332 aBuilder.Add (anOpened, myshape);
333 }
334
335 // myShapeColors + anOpened --> array[TopAbs_ShapeEnum] of map of color-to-compound
336 DataMapOfShapeCompd aDispatchedOpened [(size_t)TopAbs_SHAPE];
337 dispatchColors (anOpened, myShapeColors, aDispatchedOpened);
338 addShapesWithCustomProps (thePrs, aDispatchedOpened, theMode, StdPrs_Volume_Opened);
339
340 if (theMode == AIS_Shaded)
341 {
342 if (isShapeEntirelyVisible())
343 {
344 // myShapeColors + aClosed --> array[TopAbs_ShapeEnum] of map of color-to-compound
345 DataMapOfShapeCompd aDispatchedClosed [(size_t)TopAbs_SHAPE];
346 dispatchColors (aClosed, myShapeColors, aDispatchedClosed);
347 addShapesWithCustomProps (thePrs, aDispatchedClosed, theMode, StdPrs_Volume_Closed);
348 }
349 else
350 {
351 for (TopoDS_Iterator aSolidIter (aClosed); aSolidIter.More(); aSolidIter.Next())
352 {
353 DataMapOfShapeCompd aDispatchedClosed [(size_t)TopAbs_SHAPE];
354 dispatchColors (aSolidIter.Value(), myShapeColors, aDispatchedClosed);
355 addShapesWithCustomProps (thePrs, aDispatchedClosed, theMode,
356 isShapeEntirelyVisible (aDispatchedClosed) ? StdPrs_Volume_Closed : StdPrs_Volume_Opened);
357 }
358 }
359 }
360}
ad3217cd 361
5bffb882 362//=======================================================================
363//function : addShapesWithCustomProps
364//purpose :
365//=======================================================================
366void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs,
367 DataMapOfShapeCompd* theDispatched,
368 const Standard_Integer theMode,
369 const StdPrs_Volume theVolume)
370{
ad3217cd 371 Handle(AIS_ColoredDrawer) aCustomDrawer;
372 for (size_t aShType = 0; aShType < (size_t )TopAbs_SHAPE; ++aShType)
373 {
5bffb882 374 DataMapOfShapeCompd& aKeyshapeDrawshapeMap = theDispatched[aShType];
ad3217cd 375 for (DataMapOfShapeCompd::Iterator aMapIter (aKeyshapeDrawshapeMap);
376 aMapIter.More(); aMapIter.Next())
377 {
378 const TopoDS_Shape& aShapeKey = aMapIter.Key(); // key shape with detailed color or a base shape
379 const TopoDS_Compound& aShapeDraw = aMapIter.Value(); // compound of subshapes with <aShType> type
86766b0e 380 Handle(AIS_Drawer) aDrawer;
381 if (myShapeColors.Find (aShapeKey, aCustomDrawer))
382 {
383 aDrawer = aCustomDrawer;
384 if (aCustomDrawer->IsHidden())
385 {
386 continue;
387 }
388 }
389 else
390 {
391 aDrawer = myDrawer;
392 }
ad3217cd 393
394 // Draw each kind of subshapes and personal-colored shapes in a separate group
395 // since it's necessary to set transparency/material for all subshapes
396 // without affecting their unique colors
5bffb882 397 if (theMode == AIS_Shaded
398 && aShapeDraw.ShapeType() <= TopAbs_FACE
399 && !IsInfinite())
ad3217cd 400 {
5bffb882 401 StdPrs_ShadedShape::Add (thePrs, aShapeDraw, aDrawer, theVolume);
402 }
403 else
404 {
405 StdPrs_WFDeflectionShape::Add (thePrs, aShapeDraw, aDrawer);
ad3217cd 406 }
407 }
408 }
409}
410
411//=======================================================================
412//function : dispatchColors
413//purpose :
414//=======================================================================
415Standard_Boolean AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseKey,
416 const TopoDS_Shape& theSubshapeToParse,
417 const DataMapOfShapeShape& theSubshapeKeyshapeMap,
418 const TopAbs_ShapeEnum theParentType,
419 DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray)
420{
421 TopAbs_ShapeEnum aShType = theSubshapeToParse.ShapeType();
422 if (aShType == TopAbs_SHAPE)
423 {
424 return Standard_False;
425 }
426
427 // check own setting of current shape
428 TopoDS_Shape aKeyShape = theBaseKey;
429 Standard_Boolean isOverriden = theSubshapeKeyshapeMap.Find (theSubshapeToParse, aKeyShape);
430
431 // iterate on sub-shapes
432 BRep_Builder aBBuilder;
433 TopoDS_Shape aShapeCopy = theSubshapeToParse.EmptyCopied();
ab860031 434 aShapeCopy.Closed (theSubshapeToParse.Closed());
ad3217cd 435 Standard_Boolean isSubOverride = Standard_False;
436 Standard_Integer nbDef = 0;
437 for (TopoDS_Iterator it (theSubshapeToParse); it.More(); it.Next())
438 {
439 if (dispatchColors (theBaseKey, it.Value(),
440 theSubshapeKeyshapeMap, aShType,
441 theTypeKeyshapeDrawshapeArray))
442 {
443 isSubOverride = Standard_True;
444 }
445 else
446 {
447 aBBuilder.Add (aShapeCopy, it.Value());
448 ++nbDef;
449 }
450 }
451 if (aShType == TopAbs_FACE || !isSubOverride)
452 {
453 aShapeCopy = theSubshapeToParse;
454 }
455 else if (nbDef == 0)
456 {
457 return isOverriden || isSubOverride; // empty compound
458 }
459
460 // if any of styles is overridden regarding to default one, add rest to map
461 if (isOverriden
462 || (isSubOverride && theParentType != TopAbs_WIRE // avoid drawing edges when vertex color is overridden
463 && theParentType != TopAbs_FACE) // avoid drawing edges of the same color as face
464 || (theParentType == TopAbs_SHAPE && !(isOverriden || isSubOverride))) // bind original shape to default color
465 {
466 TopoDS_Compound aCompound;
467 DataMapOfShapeCompd& aKeyshapeDrawshapeMap = theTypeKeyshapeDrawshapeArray[(size_t )aShType];
468 if (!aKeyshapeDrawshapeMap.FindFromKey (aKeyShape, aCompound))
469 {
470 aBBuilder.MakeCompound (aCompound);
471 aKeyshapeDrawshapeMap.Add (aKeyShape, aCompound);
472 }
473 aBBuilder.Add (aCompound, aShapeCopy);
474 }
475 return isOverriden || isSubOverride;
476}
477
3ea0a91b 478//! Function to check if specified compound is sub-shape of another one
5bffb882 479inline Standard_Boolean isFirstCmpContainSecondOne (const TopoDS_Shape& theFirstCmp,
480 const TopoDS_Shape& theSecondCmp)
3ea0a91b 481{
5bffb882 482 if (theFirstCmp.ShapeType() != TopAbs_COMPOUND
483 || theSecondCmp.ShapeType() != TopAbs_COMPOUND)
3ea0a91b 484 {
485 return Standard_False;
486 }
487
5bffb882 488 for (TopoDS_Iterator aFirstCmpIter (theFirstCmp); aFirstCmpIter.More(); aFirstCmpIter.Next())
3ea0a91b 489 {
5bffb882 490 if (aFirstCmpIter.Value().ShapeType() != TopAbs_COMPOUND)
3ea0a91b 491 {
492 continue;
493 }
5bffb882 494 else if (aFirstCmpIter.Value() == theSecondCmp
495 || isFirstCmpContainSecondOne (aFirstCmpIter.Value(), theSecondCmp))
3ea0a91b 496 {
497 return Standard_True;
498 }
499 }
500 return Standard_False;
501}
502
ad3217cd 503//=======================================================================
504//function : dispatchColors
505//purpose :
506//=======================================================================
507void AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseShape,
508 const DataMapOfShapeColor& theKeyshapeColorMap,
509 DataMapOfShapeCompd* theTypeKeyshapeDrawshapeArray)
510{
511 // Extract <theShapeColors> map (KeyshapeColored -> Color)
512 // to subshapes map (Subshape -> KeyshapeColored).
513 // This needed when colored shape is not part of <theBaseShape>
514 // (but subshapes are) and actually container for subshapes.
515 DataMapOfShapeShape aSubshapeKeyshapeMap;
3ea0a91b 516 for (DataMapOfShapeColor::Iterator aKeyShapeIter (theKeyshapeColorMap);
517 aKeyShapeIter.More(); aKeyShapeIter.Next())
ad3217cd 518 {
5bffb882 519 const TopoDS_Shape& aKeyShape = aKeyShapeIter.Key();
520 bindSubShapes (aSubshapeKeyshapeMap, theBaseShape, aKeyShape, aKeyShape);
521 }
522
523 // Fill the array of maps per shape type
524 dispatchColors (theBaseShape, theBaseShape,
525 aSubshapeKeyshapeMap, TopAbs_SHAPE,
526 theTypeKeyshapeDrawshapeArray);
527}
528
529//=======================================================================
530//function : isShapeEntirelyVisible
531//purpose :
532//=======================================================================
533Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible (DataMapOfShapeCompd* theDispatched) const
534{
535 Handle(AIS_ColoredDrawer) aCustomDrawer;
536 for (size_t aShType = (size_t )TopAbs_COMPOUND; aShType <= (size_t )TopAbs_FACE; ++aShType)
537 {
538 const DataMapOfShapeCompd& aKeyshapeDrawshapeMap = theDispatched[aShType];
539 for (DataMapOfShapeCompd::Iterator aMapIter (aKeyshapeDrawshapeMap); aMapIter.More(); aMapIter.Next())
ad3217cd 540 {
5bffb882 541 if (myShapeColors.Find (aMapIter.Key(), aCustomDrawer)
542 && !aCustomDrawer.IsNull()
543 && aCustomDrawer->IsHidden())
ad3217cd 544 {
5bffb882 545 return Standard_False;
ad3217cd 546 }
5bffb882 547 }
548 }
549 return Standard_True;
550}
551
552//=======================================================================
553//function : isShapeEntirelyVisible
554//purpose :
555//=======================================================================
556Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible() const
557{
558 for (DataMapOfShapeColor::Iterator aMapIter (myShapeColors); aMapIter.More(); aMapIter.Next())
559 {
560 if (aMapIter.Value()->IsHidden())
561 {
562 return Standard_False;
563 }
564 }
565 return Standard_True;
566}
567
568//=======================================================================
569//function : bindSubShapes
570//purpose :
571//=======================================================================
572void AIS_ColoredShape::bindSubShapes (DataMapOfShapeShape& theSubshapeKeyshapeMap,
573 const TopoDS_Shape& theBaseShape,
574 const TopoDS_Shape& theShapeWithColor,
575 const TopoDS_Shape& theColorKeyShape)
576{
577 TopAbs_ShapeEnum aShapeWithColorType = theShapeWithColor.ShapeType();
578 if (aShapeWithColorType == TopAbs_COMPOUND)
579 {
580 if (isFirstCmpContainSecondOne (theBaseShape, theShapeWithColor))
581 {
582 if (!theSubshapeKeyshapeMap.IsBound (theShapeWithColor))
ad3217cd 583 {
5bffb882 584 theSubshapeKeyshapeMap.Bind (theShapeWithColor, theColorKeyShape);
585 }
586 }
587 else
588 {
589 for (TopoDS_Iterator aSubShapeIter (theShapeWithColor); aSubShapeIter.More(); aSubShapeIter.Next())
590 {
591 bindSubShapes (theSubshapeKeyshapeMap, theBaseShape, aSubShapeIter.Value(), theColorKeyShape);
ad3217cd 592 }
593 }
594 }
5bffb882 595 else if (aShapeWithColorType == TopAbs_SOLID || aShapeWithColorType == TopAbs_SHELL)
596 {
597 for (TopExp_Explorer anExp (theShapeWithColor, TopAbs_FACE); anExp.More(); anExp.Next())
598 {
599 if (!theSubshapeKeyshapeMap.IsBound (anExp.Current()))
600 {
601 theSubshapeKeyshapeMap.Bind (anExp.Current(), theColorKeyShape);
602 }
603 }
604 }
605 else if (aShapeWithColorType == TopAbs_WIRE)
606 {
607 for (TopExp_Explorer anExp (theShapeWithColor, TopAbs_EDGE); anExp.More(); anExp.Next())
608 {
609 if (!theSubshapeKeyshapeMap.IsBound (anExp.Current()))
610 {
611 theSubshapeKeyshapeMap.Bind (anExp.Current(), theColorKeyShape);
612 }
613 }
614 }
615 else
616 {
617 // bind single face, edge and vertex
618 // force rebind if required due to the color of single shape has
619 // higher priority than the color of "compound" shape (wire is a
620 // compound of edges, shell is a compound of faces) that contains
621 // this single shape.
622 theSubshapeKeyshapeMap.Bind (theShapeWithColor, theColorKeyShape);
623 }
ad3217cd 624}
5bffb882 625