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