Salome HOME
[bos #40653][CEA] New mesh import export formats with meshio.
[modules/smesh.git] / src / SMESHDS / SMESHDS_GroupBase.cxx
index 383d796a29d9ac6015a3d73010cf6c9785d8796e..cc133c45599ad7a07c79558ae7f3c7fb0158fe96 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,6 +32,8 @@
 
 using namespace std;
 
+Quantity_Color SMESHDS_GroupBase::myDefaultColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB );
+
 //=============================================================================
 /*!
  *  
@@ -44,16 +46,16 @@ 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 );
+  myColor = myDefaultColor;
 }
 
 //=============================================================================
 /*!
- *  
+ *  Don't use it!
  */
 //=============================================================================
 
-int SMESHDS_GroupBase::GetID (const int theIndex)
+smIdType SMESHDS_GroupBase::GetID (const int theIndex)
 {
   if (myCurIndex < 1 || myCurIndex > theIndex) {
     myIterator = GetElements();
@@ -73,7 +75,7 @@ int SMESHDS_GroupBase::GetID (const int theIndex)
  */
 //=============================================================================
 
-const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const int theID) const
+const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const smIdType theID) const
 {
   SMDSAbs_ElementType aType = GetType();
   const SMDS_MeshElement* aElem = NULL;
@@ -105,10 +107,10 @@ void SMESHDS_GroupBase::resetIterator()
 //purpose  : 
 //=======================================================================
 
-int SMESHDS_GroupBase::Extent() const
+smIdType SMESHDS_GroupBase::Extent() const
 {
   SMDS_ElemIteratorPtr it = GetElements();
-  int nb = 0;
+  smIdType nb = 0;
   if ( it )
     for ( ; it->more(); it->next() ) 
       nb++;
@@ -122,6 +124,9 @@ int SMESHDS_GroupBase::Extent() const
 
 bool SMESHDS_GroupBase::IsEmpty()
 {
+  if ( myMesh->GetMeshInfo().NbElements( myType ) == 0 )
+    // avoid long iteration over sub-meshes of a complex sub-mesh of a group on geometry
+    return true;
   SMDS_ElemIteratorPtr it = GetElements();
   return ( !it || !it->more() );
 }
@@ -131,7 +136,7 @@ bool SMESHDS_GroupBase::IsEmpty()
 //purpose  : 
 //=======================================================================
 
-bool SMESHDS_GroupBase::Contains (const int theID)
+bool SMESHDS_GroupBase::Contains (const smIdType theID)
 {
   if ( SMDS_ElemIteratorPtr it = GetElements() ) {
     while ( it->more() )
@@ -179,9 +184,9 @@ void SMESHDS_GroupBase::SetColorGroup(int theColorGroup)
   if ( aR < 0. || aR > 1. || // PAL19395
        aG < 0. || aG > 1. ||
        aB < 0. || aB > 1. )
-// #ifdef _DEBUG_
-//     cout << "SMESHDS_GroupBase::SetColorGroup("<<theColorGroup<<"), invalid color ignored"<<endl;
-// #endif
+// if (SALOME::VerbosityActivated())
+//  cout << "SMESHDS_GroupBase::SetColorGroup("<<theColorGroup<<"), invalid color ignored"<<endl;
+
     return;
   Quantity_Color aColor( aR, aG, aB, Quantity_TOC_RGB );
   SetColor( aColor );