1 // Created on: 2003-11-12
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
22 // if define _POLYGONES_ ColorPrsBuilder use ArrayOfPolygons for drawing faces
24 #include <MeshVS_ElementalColorPrsBuilder.ixx>
26 #include <Graphic3d_AspectFillArea3d.hxx>
27 #include <Graphic3d_AspectLine3d.hxx>
28 #include <Graphic3d_ArrayOfPolygons.hxx>
29 #include <Graphic3d_ArrayOfPolylines.hxx>
30 #include <Graphic3d_Vertex.hxx>
31 #include <Graphic3d_Group.hxx>
32 #include <Graphic3d_Array1OfVertex.hxx>
34 #include <Prs3d_ShadingAspect.hxx>
35 #include <Prs3d_Root.hxx>
36 #include <Prs3d_LineAspect.hxx>
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TColStd_PackedMapOfInteger.hxx>
40 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
41 #include <TColStd_ListIteratorOfListOfInteger.hxx>
42 #include <TColStd_Array1OfReal.hxx>
43 #include <TColStd_SequenceOfInteger.hxx>
44 #include <TColStd_HArray1OfReal.hxx>
45 #include <TColStd_HPackedMapOfInteger.hxx>
47 #include <MeshVS_DisplayModeFlags.hxx>
48 #include <MeshVS_DataSource.hxx>
49 #include <MeshVS_Mesh.hxx>
50 #include <MeshVS_DataMapOfColorMapOfInteger.hxx>
51 #include <MeshVS_DataMapOfTwoColorsMapOfInteger.hxx>
52 #include <MeshVS_Drawer.hxx>
53 #include <MeshVS_DrawerAttribute.hxx>
54 #include <MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors.hxx>
55 #include <MeshVS_DataMapIteratorOfDataMapOfIntegerColor.hxx>
56 #include <MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger.hxx>
57 #include <MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger.hxx>
58 #include <MeshVS_MeshPrsBuilder.hxx>
59 #include <MeshVS_Buffer.hxx>
62 //================================================================
63 // Function : Constructor MeshVS_ElementalColorPrsBuilder
65 //================================================================
66 MeshVS_ElementalColorPrsBuilder::MeshVS_ElementalColorPrsBuilder
67 ( const Handle(MeshVS_Mesh)& Parent,
68 const MeshVS_DisplayModeFlags& Flags,
69 const Handle (MeshVS_DataSource)& DS,
70 const Standard_Integer Id,
71 const MeshVS_BuilderPriority& Priority )
72 : MeshVS_PrsBuilder ( Parent, Flags, DS, Id, Priority )
74 SetExcluding ( Standard_True );
77 //================================================================
80 //================================================================
81 void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
82 const TColStd_PackedMapOfInteger& IDs,
83 TColStd_PackedMapOfInteger& IDsToExclude,
84 const Standard_Boolean IsElement,
85 const Standard_Integer DisplayMode) const
87 Handle (MeshVS_DataSource) aSource = GetDataSource();
88 Handle (MeshVS_Drawer) aDrawer = GetDrawer();
90 if ( aSource.IsNull() || aDrawer.IsNull() )
93 Standard_Integer aMaxFaceNodes;
94 if ( !aDrawer->GetInteger ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) && aMaxFaceNodes<=0 )
97 MeshVS_DataMapOfIntegerColor* anElemColorMap = (MeshVS_DataMapOfIntegerColor*) &myElemColorMap1;
98 MeshVS_DataMapOfIntegerTwoColors* anElemTwoColorsMap = (MeshVS_DataMapOfIntegerTwoColors*)&myElemColorMap2;
100 MeshVS_DataMapOfColorMapOfInteger aColorsOfElements;
101 MeshVS_DataMapOfTwoColorsMapOfInteger aTwoColorsOfElements;
103 MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
104 TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
105 Standard_Integer NbNodes;
106 MeshVS_EntityType aType;
108 if ( !( DisplayMode & GetFlags() ) || !IsElement ||
109 ( myElemColorMap1.IsEmpty() && myElemColorMap2.IsEmpty() ) )
112 // subtract the hidden elements and ids to exclude (to minimise allocated memory)
113 TColStd_PackedMapOfInteger anIDs;
115 Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
116 if ( !aHiddenElems.IsNull() )
117 anIDs.Subtract( aHiddenElems->Map() );
118 anIDs.Subtract( IDsToExclude );
120 // STEP 0: We looking for two colored elements, who has equal two colors and move it
121 // to map of elements with one assigned color
122 TColStd_ListOfInteger aColorOne;
123 for ( MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors anIter ( *anElemTwoColorsMap ); anIter.More(); anIter.Next () )
125 Standard_Integer aKey = anIter.Key ();
126 MeshVS_TwoColors aValue = anIter.Value ();
127 Quantity_Color aCol1, aCol2;
128 ExtractColors ( aValue, aCol1, aCol2 );
129 if ( aCol1 == aCol2 )
131 aColorOne.Append ( aKey );
132 anElemColorMap->Bind ( aKey, aCol1 );
136 for ( TColStd_ListIteratorOfListOfInteger aLIter ( aColorOne ); aLIter.More(); aLIter.Next() )
137 anElemTwoColorsMap->UnBind ( aLIter.Value() );
139 // The map is to resort itself by colors.
140 // STEP 1: We start sorting elements with one assigned color
141 for ( MeshVS_DataMapIteratorOfDataMapOfIntegerColor anIterM ( *anElemColorMap ); anIterM.More(); anIterM.Next () )
143 Standard_Integer aMKey = anIterM.Key ();
144 // The ID of current element
145 Standard_Boolean IsExist = Standard_False;
146 for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger anIterC ( aColorsOfElements );
147 anIterC.More() && !IsExist; anIterC.Next () )
148 if ( anIterC.Key()==anIterM.Value() )
150 TColStd_MapOfInteger& aChangeValue = (TColStd_MapOfInteger&) anIterC.Value();
151 aChangeValue.Add ( aMKey );
152 IsExist = Standard_True;
157 TColStd_MapOfInteger aNewMap; aNewMap.Add ( aMKey );
158 aColorsOfElements.Bind ( anIterM.Value(), aNewMap );
162 // STEP 2: We start sorting elements with two assigned colors
163 for ( MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors anIterM2 ( *anElemTwoColorsMap ); anIterM2.More();
166 Standard_Integer aMKey = anIterM2.Key ();
167 // The ID of current element
168 Standard_Boolean IsExist = Standard_False;
169 for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger anIterC2 ( aTwoColorsOfElements );
170 anIterC2.More() && !IsExist; anIterC2.Next () )
171 if ( IsEqual ( anIterC2.Key(), anIterM2.Value() ) )
173 TColStd_MapOfInteger& aChangeValue = (TColStd_MapOfInteger&) anIterC2.Value();
174 aChangeValue.Add ( aMKey );
175 IsExist = Standard_True;
180 TColStd_MapOfInteger aNewMap; aNewMap.Add ( aMKey );
181 aTwoColorsOfElements.Bind ( anIterM2.Value(), aNewMap );
185 //Now we are ready to draw faces with equal colors
186 Aspect_InteriorStyle aStyle;
187 Standard_Integer aStyleInt;
188 Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
189 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
190 Standard_Integer anEdgeInt, aLineInt;
191 Standard_Real anEdgeWidth, aLineWidth;
192 Quantity_Color anInteriorColor;
193 Quantity_Color anEdgeColor, aLineColor;
194 Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False,
195 IsMeshSmoothShading = Standard_False;
197 aDrawer->GetColor ( MeshVS_DA_InteriorColor, anInteriorColor );
198 aDrawer->GetColor ( MeshVS_DA_EdgeColor, anEdgeColor );
199 aDrawer->GetColor ( MeshVS_DA_BeamColor, aLineColor );
200 aDrawer->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth );
201 aDrawer->GetDouble ( MeshVS_DA_BeamWidth, aLineWidth );
202 aDrawer->GetBoolean( MeshVS_DA_ShowEdges, anEdgeOn );
203 aDrawer->GetBoolean( MeshVS_DA_ColorReflection, IsReflect );
204 aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
206 if ( aDrawer->GetInteger ( MeshVS_DA_InteriorStyle, aStyleInt) )
207 aStyle = (Aspect_InteriorStyle) aStyleInt;
209 if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) )
210 anEdgeType = (Aspect_TypeOfLine) anEdgeInt;
212 if ( aDrawer->GetInteger ( MeshVS_DA_BeamType, aLineInt) )
213 aLineType = (Aspect_TypeOfLine) aLineInt;
215 Handle( MeshVS_HArray1OfSequenceOfInteger ) aTopo;
216 Standard_Integer PolygonVerticesFor3D = 0, PolygonBoundsFor3D = 0;
217 TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
218 for( ; it.More(); it.Next() )
220 Standard_Integer aKey = it.Key();
221 if( aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
222 MeshVS_MeshPrsBuilder::HowManyPrimitives
223 ( aTopo, Standard_True, Standard_False, NbNodes,
224 PolygonVerticesFor3D, PolygonBoundsFor3D );
227 Graphic3d_MaterialAspect aMaterial[2];
229 for ( i=0; i<2; i++ )
231 // OCC20644 "plastic" is most suitable here, as it is "non-physic"
232 // so TelUpdateMaterial() from OpenGl_attri.c uses the interior
233 // color from AspectFillArea3d to calculate all material colors
234 aMaterial[i] = Graphic3d_MaterialAspect ( Graphic3d_NOM_PLASTIC );
236 // OCC21720 For single-colored elements turning all material components off is a good idea,
237 // as anyhow the normals are not computed and the lighting will be off,
238 // the element color will be taken from Graphic3d_AspectFillArea3d's interior color,
239 // and there is no need to spend time on updating material properties
242 aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
243 aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
244 aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
245 aMaterial[i].SetReflectionModeOff(Graphic3d_TOR_EMISSION);
249 // OCC20644 This stuff is important in order for elemental and nodal colors
250 // to produce similar visual impression and also to make colors match
251 // those in the color scale most exactly (the sum of all reflection
252 // coefficients is equal to 1). See also MeshVS_NodalColorPrsBuilder
253 // class for more explanations.
254 aMaterial[i].SetAmbient( .5 );
255 aMaterial[i].SetDiffuse( .5 );
256 aMaterial[i].SetSpecular( 0. );
257 aMaterial[i].SetEmissive( 0. );
261 // Draw elements with one color
262 for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter ( aColorsOfElements ); aColIter.More();
265 Standard_Integer aSize = aColIter.Value().Extent();
269 TColStd_PackedMapOfInteger aCustomElements;
271 Prs3d_Root::NewGroup ( Prs );
272 Handle ( Graphic3d_Group ) aGGroup = Prs3d_Root::CurrentGroup ( Prs );
273 Prs3d_Root::NewGroup ( Prs );
274 Handle ( Graphic3d_Group ) aLGroup = Prs3d_Root::CurrentGroup ( Prs );
276 Handle (Graphic3d_ArrayOfPolygons) aPolyGArr = new Graphic3d_ArrayOfPolygons
277 ( aMaxFaceNodes*aSize + PolygonVerticesFor3D, aSize + PolygonBoundsFor3D, 0, IsReflect );
278 Standard_Boolean IsPolyG = Standard_False;
280 Handle (Graphic3d_ArrayOfPolylines) aPolyLArr = new Graphic3d_ArrayOfPolylines
282 Standard_Boolean IsPolyL = Standard_False;
284 // OCC20644 NOTE: aColIter.Key() color is then scaled by TelUpdateMaterial() in OpenGl_attri.c
285 // using the material reflection coefficients. This affects the visual result.
286 Handle(Graphic3d_AspectFillArea3d) anAsp =
287 new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, aColIter.Key(), anEdgeColor,
288 anEdgeType, anEdgeWidth, aMaterial[0], aMaterial[1] );
290 Handle(Graphic3d_AspectLine3d) anLAsp =
291 new Graphic3d_AspectLine3d ( aColIter.Key(), aLineType, aLineWidth );
293 anAsp->SetDistinguishOff ();
294 anAsp->SetInteriorColor ( aColIter.Key() );
300 for( it.Reset(); it.More(); it.Next() )
302 Standard_Integer aKey = it.Key();
303 if( aColIter.Value().Contains( aKey ) )
305 if ( !aSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType ) )
308 if( aType == MeshVS_ET_Face )
310 aPolyGArr->AddBound ( NbNodes );
311 if( IsExcludingOn() )
312 IDsToExclude.Add( aKey );
314 else if( aType == MeshVS_ET_Link )
316 aPolyLArr->AddBound ( NbNodes );
317 if( IsExcludingOn() )
318 IDsToExclude.Add( aKey );
320 else if( aType == MeshVS_ET_Volume )
322 if( IsExcludingOn() )
323 IDsToExclude.Add( aKey );
324 if( aSource->Get3DGeom( aKey, NbNodes, aTopo ) )
326 MeshVS_MeshPrsBuilder::AddVolumePrs( aTopo, aCoords, NbNodes, aPolyGArr, IsReflect, Standard_False, Standard_False, 1.0 );
327 IsPolyG = Standard_True;
334 aCustomElements.Add( aKey );
338 // Preparing normal(s) to show reflections if requested
339 Handle(TColStd_HArray1OfReal) aNormals;
340 Standard_Boolean hasNormals = IsReflect && aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals );
342 // Adding vertices (with normals if necessary)
343 for ( i=1; i<=NbNodes; i++ )
344 if ( aType == MeshVS_ET_Face )
348 hasNormals ? aPolyGArr->AddVertex ( aCoords(3 * i - 2),
351 aNormals->Value(3 * i - 2),
352 aNormals->Value(3 * i - 1),
353 aNormals->Value(3 * i ) ) :
354 aPolyGArr->AddVertex ( aCoords(3 * i - 2),
362 aPolyGArr->AddVertex ( aCoords(3 * i - 2),
365 IsPolyG = Standard_True;
367 else if ( aType == MeshVS_ET_Link )
369 aPolyLArr->AddVertex ( aCoords(3*i-2), aCoords(3*i-1), aCoords(3*i) );
370 IsPolyL = Standard_True;
377 aGGroup->SetPrimitivesAspect ( anAsp );
378 aGGroup->BeginPrimitives();
379 aGGroup->AddPrimitiveArray ( aPolyGArr );
380 aGGroup->EndPrimitives();
385 aLGroup->SetPrimitivesAspect ( anAsp );
386 aLGroup->SetPrimitivesAspect ( anLAsp );
387 aLGroup->BeginPrimitives();
388 aLGroup->AddPrimitiveArray ( aPolyLArr );
389 aLGroup->EndPrimitives();
396 if( !aCustomElements.IsEmpty() )
397 CustomBuild( Prs, aCustomElements, IDsToExclude, DisplayMode );
400 Graphic3d_MaterialAspect aMaterial2[2];
401 for ( i=0; i<2; i++ )
403 // OCC20644 "plastic" is most suitable here, as it is "non-physic"
404 // so TelUpdateMaterial() from OpenGl_attri.c uses the interior
405 // color from AspectFillArea3d to calculate all material colors
406 aMaterial2[i] = Graphic3d_MaterialAspect ( Graphic3d_NOM_PLASTIC );
410 // OCC21720 Cannot turn ALL material components off, as such a material
411 // would be ignored by TelUpdateMaterial(), but we need it in order
412 // to have different materials for front and back sides!
413 // Instead, trying to make material color "nondirectional" with
414 // only ambient component on.
415 aMaterial2[i].SetReflectionModeOn ( Graphic3d_TOR_AMBIENT );
416 aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
417 aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
418 aMaterial2[i].SetReflectionModeOff( Graphic3d_TOR_EMISSION );
419 aMaterial2[i].SetAmbient ( 1. );
420 aMaterial2[i].SetDiffuse ( 0. );
421 aMaterial2[i].SetSpecular( 0. );
422 aMaterial2[i].SetEmissive( 0. );
426 // OCC20644 This stuff is important in order for elemental and nodal colors
427 // to produce similar visual impression and also to make colors match
428 // those in the color scale most exactly (the sum of all reflection
429 // coefficients is equal to 1). See also MeshVS_NodalColorPrsBuilder
430 // class for more explanations.
431 aMaterial2[i].SetAmbient( .5 );
432 aMaterial2[i].SetDiffuse( .5 );
433 aMaterial2[i].SetSpecular( 0. );
434 aMaterial2[i].SetEmissive( 0. );
438 // Draw faces with two color
439 for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger aColIter2 ( aTwoColorsOfElements );
440 aColIter2.More(); aColIter2.Next() )
442 Prs3d_Root::NewGroup ( Prs );
443 Handle ( Graphic3d_Group ) aGroup2 = Prs3d_Root::CurrentGroup ( Prs );
445 Standard_Integer aSize = aColIter2.Value().Extent();
450 Handle (Graphic3d_ArrayOfPolygons) aPolyArr = new Graphic3d_ArrayOfPolygons
451 ( aMaxFaceNodes*aSize, aSize, 0, IsReflect );
454 MeshVS_TwoColors aTC = aColIter2.Key();
455 Quantity_Color aMyIntColor, aMyBackColor;
456 ExtractColors ( aTC, aMyIntColor, aMyBackColor );
458 // OCC20644 NOTE: aMyIntColor color is then scaled by TelUpdateMaterial() in OpenGl_attri.c
459 // using the material reflection coefficients. This affects the visual result.
460 Handle(Graphic3d_AspectFillArea3d) anAsp =
461 new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, aMyIntColor, anEdgeColor,
462 anEdgeType, anEdgeWidth, aMaterial2[0], aMaterial2[1] );
463 anAsp->SetDistinguishOn ();
464 anAsp->SetInteriorColor ( aMyIntColor );
465 anAsp->SetBackInteriorColor ( aMyBackColor );
471 aGroup2->SetPrimitivesAspect ( anAsp );
472 aGroup2->BeginPrimitives();
474 for( it.Reset(); it.More(); it.Next() )
476 Standard_Integer aKey = it.Key();
477 if( aColIter2.Value().Contains( aKey ) )
479 if ( !aSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType ) )
482 if( IsExcludingOn() )
483 IDsToExclude.Add( aKey );
485 if ( aType == MeshVS_ET_Face && NbNodes > 0 )
487 // Preparing normal(s) to show reflections if requested
488 Handle(TColStd_HArray1OfReal) aNormals;
489 // OCC21720 Always passing normals to OpenGL to make materials work
490 // For OpenGL: "No normals" -> "No lighting" -> "no materials taken into account"
491 Standard_Boolean hasNormals = /*IsReflect &&*/
492 aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals );
495 aPolyArr->AddBound ( NbNodes );
497 Graphic3d_Array1OfVertex aVertArr ( 1, NbNodes );
500 for ( i=1; i<=NbNodes; i++ )
505 hasNormals ? aPolyArr->AddVertex ( aCoords(3 * i - 2),
508 aNormals->Value(3 * i - 2),
509 aNormals->Value(3 * i - 1),
510 aNormals->Value(3 * i ) ) :
511 aPolyArr->AddVertex ( aCoords(3 * i - 2),
519 aPolyArr->AddVertex ( aCoords(3*i-2),
525 aVertArr (i) = hasNormals ? Graphic3d_VertexN( aCoords(3 * i - 2),
528 aNormals->Value(3 * i - 2),
529 aNormals->Value(3 * i - 1),
530 aNormals->Value(3 * i ),
532 Graphic3d_VertexN( aCoords(3 * i - 2),
542 Graphic3d_Vertex ( aCoords(3 * i - 2),
550 aGroup2->Polygon ( aVertArr );
556 aGroup2->AddPrimitiveArray ( aPolyArr );
558 aGroup2->EndPrimitives();
562 //================================================================
563 // Function : SetColors
565 //================================================================
566 void MeshVS_ElementalColorPrsBuilder::SetColors1 ( const MeshVS_DataMapOfIntegerColor& theColorMap )
568 myElemColorMap1 = theColorMap;
571 //================================================================
572 // Function : GetColors
574 //================================================================
575 const MeshVS_DataMapOfIntegerColor& MeshVS_ElementalColorPrsBuilder::GetColors1 () const
577 return myElemColorMap1;
580 //================================================================
581 // Function : HasColors1
583 //================================================================
584 Standard_Boolean MeshVS_ElementalColorPrsBuilder::HasColors1 () const
586 return ( myElemColorMap1.Extent() >0 );
589 //================================================================
590 // Function : GetColor1
592 //================================================================
593 Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor1 ( const Standard_Integer ID,
594 Quantity_Color& theColor ) const
596 Standard_Boolean aRes = myElemColorMap1.IsBound ( ID );
598 theColor = myElemColorMap1.Find ( ID );
603 //================================================================
604 // Function : SetColor1
606 //================================================================
607 void MeshVS_ElementalColorPrsBuilder::SetColor1 ( const Standard_Integer theID,
608 const Quantity_Color& theCol )
610 Standard_Boolean aRes = myElemColorMap1.IsBound ( theID );
612 myElemColorMap1.ChangeFind ( theID ) = theCol;
614 myElemColorMap1.Bind ( theID, theCol );
617 //================================================================
618 // Function : SetColors2
620 //================================================================
621 void MeshVS_ElementalColorPrsBuilder::SetColors2 ( const MeshVS_DataMapOfIntegerTwoColors& theColorMap )
623 myElemColorMap2 = theColorMap;
626 //================================================================
627 // Function : GetColors2
629 //================================================================
630 const MeshVS_DataMapOfIntegerTwoColors& MeshVS_ElementalColorPrsBuilder::GetColors2 () const
632 return myElemColorMap2;
635 //================================================================
636 // Function : HasColors2
638 //================================================================
639 Standard_Boolean MeshVS_ElementalColorPrsBuilder::HasColors2 () const
641 return (myElemColorMap2.Extent()>0);
644 //================================================================
645 // Function : GetColor2
647 //================================================================
648 Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor2 ( const Standard_Integer ID,
649 MeshVS_TwoColors& theColor ) const
651 Standard_Boolean aRes = myElemColorMap2.IsBound ( ID );
653 theColor = myElemColorMap2.Find ( ID );
658 //================================================================
659 // Function : GetColor2
661 //================================================================
662 Standard_Boolean MeshVS_ElementalColorPrsBuilder::GetColor2 ( const Standard_Integer ID,
663 Quantity_Color& theColor1,
664 Quantity_Color& theColor2 ) const
666 MeshVS_TwoColors aTC;
667 Standard_Boolean aRes = GetColor2 ( ID, aTC );
669 ExtractColors ( aTC, theColor1, theColor2 );
673 //================================================================
674 // Function : SetColor2
676 //================================================================
677 void MeshVS_ElementalColorPrsBuilder::SetColor2 ( const Standard_Integer theID,
678 const Quantity_Color& theCol1,
679 const Quantity_Color& theCol2 )
681 SetColor2 ( theID, BindTwoColors ( theCol1, theCol2 ) );
684 //================================================================
685 // Function : SetColor2
687 //================================================================
688 void MeshVS_ElementalColorPrsBuilder::SetColor2 ( const Standard_Integer theID,
689 const MeshVS_TwoColors& theCol )
691 Standard_Boolean aRes = myElemColorMap2.IsBound ( theID );
693 myElemColorMap2.ChangeFind ( theID ) = theCol;
695 myElemColorMap2.Bind ( theID, theCol );