Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / SMESHDS / SMESHDS_GroupBase.cxx
index 52b21e168e21262a413d0dc3fb1b07dfd90f2e2c..1fc450002d7551063469835050a91c7bd45c1495 100644 (file)
@@ -43,6 +43,7 @@ SMESHDS_GroupBase::SMESHDS_GroupBase (const int                 theID,
        myID(theID), myMesh(theMesh), myType(theType), myStoreName(""),
        myCurIndex(0), myCurID(-1)
 {
+  myColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB );
 }
 
 //=============================================================================
@@ -131,12 +132,24 @@ bool SMESHDS_GroupBase::IsEmpty()
 
 bool SMESHDS_GroupBase::Contains (const int theID)
 {
-  SMDS_ElemIteratorPtr it = GetElements();
-  bool contains = false;
-  if ( it )
-    while ( !contains && it->more() )
-      contains = ( it->next()->GetID() == theID );
-  return contains;
+  if ( SMDS_ElemIteratorPtr it = GetElements() ) {
+    while ( it->more() )
+      if ( it->next()->GetID() == theID )
+        return true;
+  }
+  return false;
+}
+
+//=======================================================================
+//function : Contains
+//purpose  : 
+//=======================================================================
+
+bool SMESHDS_GroupBase::Contains (const SMDS_MeshElement* elem)
+{
+  if ( elem )
+    return Contains( elem->GetID() );
+  return false;
 }
 
 //=======================================================================
@@ -148,3 +161,35 @@ void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType)
 {
   myType = theType;
 }
+
+//=======================================================================
+//function : SetType
+//purpose  : 
+//=======================================================================
+
+void SMESHDS_GroupBase::SetColorGroup(int theColorGroup)
+{
+  if( theColorGroup < 0 || theColorGroup > 360 )
+  {
+    MESSAGE("SMESHDS_GroupBase::SetColorGroup : Value must be in range [0,360]");
+    return;
+  }
+
+  Quantity_Color aColor( (double)theColorGroup, 1.0, 1.0, Quantity_TOC_HLS );
+  SetColor( aColor );
+}
+  
+//=======================================================================
+//function : SetType
+//purpose  : 
+//=======================================================================
+
+int SMESHDS_GroupBase::GetColorGroup() const
+{
+  Quantity_Color aColor = GetColor();
+  double aHue = aColor.Hue();
+  if( aHue < 0 )
+    return 0;
+  return (int)( aHue );
+}
+