Salome HOME
0021275: EDF 1681 SMESH: Find the number of nodes of any group
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i_1.cxx
index 2b216fe268d77330f4480a45880151cf4f2ecf69..1fd5f54150aee1b9d616deaae8175d1d567d6a25 100644 (file)
@@ -1,31 +1,30 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
-// File      : SMESH_Gen_i_1.cxx
-// Created   : Thu Oct 21 17:24:06 2004
-// Author    : Edward AGAPOV (eap)
-// Module    : SMESH
-// $Header: 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  File      : SMESH_Gen_i_1.cxx
+//  Created   : Thu Oct 21 17:24:06 2004
+//  Author    : Edward AGAPOV (eap)
+//  Module    : SMESH
+//  $Header   : $
+
 #include "SMESH_Gen_i.hxx"
 
 #include "SMESH_Mesh_i.hxx"
@@ -137,6 +136,11 @@ long SMESH_Gen_i::GetVolumeGroupsTag()
   return SMESH::Tag_VolumeGroups;
 }
 
+long SMESH_Gen_i::Get0DElementsGroupsTag()
+{
+  return SMESH::Tag_0DElementsGroups;
+}
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::CanPublishInStudy
@@ -628,7 +632,10 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
     SetName( aRootSO, aRootName );
 
     // Add new submesh to corresponding sub-tree
-    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, "ICON_SMESH_TREE_MESH_WARN");
+    SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
+    const int isEmpty = ( elemTypes->length() == 0 );
+    const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
+    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, pm[isEmpty] );
     if ( aSubMeshSO->_is_nil() )
       return aSubMeshSO._retn();
   }
@@ -690,7 +697,12 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr    theStudy
         SetName( aRootSO, aRootNames[aType] );
 
       // Add new group to corresponding sub-tree
-      aGroupSO = publish (theStudy, theGroup, aRootSO, 0, "ICON_SMESH_TREE_GROUP" );
+      SMESH::array_of_ElementType_var elemTypes = theGroup->GetTypes();
+      const int isEmpty = ( elemTypes->length() == 0 );
+      std::string pm[2] = { "ICON_SMESH_TREE_GROUP", "ICON_SMESH_TREE_MESH_WARN" };
+      if ( SMESH::DownCast< SMESH_GroupOnFilter_i* > ( theGroup ))
+        pm[0] = "ICON_SMESH_TREE_GROUP_ON_FILTER";
+      aGroupSO = publish (theStudy, theGroup, aRootSO, 0, pm[isEmpty].c_str() );
     }
     if ( aGroupSO->_is_nil() )
       return aGroupSO._retn();
@@ -922,7 +934,30 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
   if(!hasAttr)
     aNewParams = anInputParams;
   else 
-    aNewParams = aOldParameters+"|"+anInputParams;
+    {
+      int pos = aOldParameters.SearchFromEnd("|");
+      if(pos==-1) pos = 0;
+      TCollection_AsciiString previousParamFull(aOldParameters.Split(pos));
+      TCollection_AsciiString previousParam(previousParamFull);
+      TCollection_AsciiString theRepet("1");
+      pos = previousParam.SearchFromEnd(";*=");
+      if(pos >= 0)
+        {
+          theRepet = previousParam.Split(pos+2);
+          pos = pos-1;
+          if(pos==-1) pos = 0;
+          previousParam.Split(pos);
+        }
+      if(previousParam == anInputParams)
+        {
+          theRepet = theRepet.IntegerValue()+1;
+          aNewParams = aOldParameters + previousParam + ";*=" + theRepet;
+        }
+      else
+        {
+          aNewParams = aOldParameters + previousParamFull + "|" + anInputParams;
+        }
+    }
 
   if(VARIABLE_DEBUG)
   {