+//=============================================================================
+/*
+ * Return number of mesh elements of each \a SMESH::EntityType
+ * Result array of number of elements per \a SMESH::EntityType
+ * Inherited from SMESH_IDSource
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_GroupBase_i::GetMeshInfo()
+{
+ if ( myPreMeshInfo )
+ return myPreMeshInfo->GetMeshInfo();
+
+ SMESH::long_array_var aRes = new SMESH::long_array();
+ aRes->length(SMESH::Entity_Last);
+ for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
+ aRes[i] = 0;
+
+ if ( SMESHDS_GroupBase* g = GetGroupDS())
+ {
+ if ( g->GetType() == SMDSAbs_Node /*|| ( myNbNodes > -1 && g->GetTic() == myGroupDSTic)*/)
+ aRes[ SMDSEntity_Node ] = GetNumberOfNodes();
+
+ if ( g->GetType() != SMDSAbs_Node )
+ SMESH_Mesh_i::CollectMeshInfo( g->GetElements(), aRes);
+ }
+
+ return aRes._retn();
+}
+
+//=============================================================================
+/*
+ * Return number of mesh elements of each \a ElementType
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_GroupBase_i::GetNbElementsByType()
+{
+ SMESH::long_array_var aRes = new SMESH::long_array();
+ aRes->length(SMESH::NB_ELEMENT_TYPES);
+ for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++)
+ aRes[ i ] = 0;
+
+ if ( myPreMeshInfo )
+ aRes[ GetType() ] = myPreMeshInfo->NbElements( SMDSAbs_ElementType( GetType() ));
+ else
+ aRes[ GetType() ] = Size();
+
+ return aRes._retn();
+}
+
+//=======================================================================
+//function : GetIDs
+//purpose : Return ids of members
+//=======================================================================
+
+SMESH::long_array* SMESH_GroupBase_i::GetIDs()
+{
+ return GetListOfID();
+}
+
+//=======================================================================
+//function : GetTypes
+//purpose : Return types of elements it contains
+//=======================================================================
+
+SMESH::array_of_ElementType* SMESH_GroupBase_i::GetTypes()
+{
+ SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
+ if ( !IsEmpty() )
+ {
+ types->length( 1 );
+ types[0] = GetType();
+ }
+ return types._retn();
+}
+
+//=======================================================================
+//function : IsMeshInfoCorrect
+//purpose : * Return false if GetMeshInfo() returns incorrect information that may
+// * happen if mesh data is not yet fully loaded from the file of study.
+//=======================================================================
+
+bool SMESH_GroupBase_i::IsMeshInfoCorrect()
+{
+ return myPreMeshInfo ? myPreMeshInfo->IsMeshInfoCorrect() : true;
+}
+
+//=======================================================================
+//function : GetVtkUgStream
+//purpose : Return data vtk unstructured grid (not implemented)
+//=======================================================================
+
+SALOMEDS::TMPFile* SMESH_GroupBase_i::GetVtkUgStream()
+{
+ SALOMEDS::TMPFile_var SeqFile;
+ return SeqFile._retn();
+}
+
+//================================================================================
+/*!
+ * \brief Retrieves the predicate from the filter
+ */
+//================================================================================
+
+SMESH_PredicatePtr SMESH_GroupOnFilter_i::GetPredicate( SMESH::Filter_ptr filter )
+{
+ SMESH_PredicatePtr predicate;
+
+ if ( SMESH::Filter_i* filt_i = SMESH::DownCast< SMESH::Filter_i* >( filter ))
+ if ( SMESH::Predicate_i* predic_i= filt_i->GetPredicate_i() )
+ predicate = predic_i->GetPredicate();
+
+ return predicate;
+}
+
+//================================================================================
+/*!
+ * \brief Sets the filter defining group contents
+ */
+//================================================================================
+
+void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
+ throw (SALOME::SALOME_Exception)
+{
+ if ( myFilter->_is_equivalent( theFilter ))
+ return;
+
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
+ if ( ! myFilter->_is_nil() )
+ myFilter->UnRegister();
+
+ myFilter = SMESH::Filter::_duplicate( theFilter );
+
+ if ( !myFilter->_is_nil() )
+ {
+ myFilter->Register();
+
+ if ( SMESH::Filter_i* f = SMESH::DownCast< SMESH::Filter_i* >( myFilter ))
+ {
+ // make filter notify me about change of either a predicate or a base group
+ f->FindBaseObjects();
+
+ if ( f->ContainModifWaiter( this ) ||
+ this->ContainModifWaiter( f ))
+ {
+ SetFilter( SMESH::Filter::_nil() );
+ THROW_SALOME_CORBA_EXCEPTION( "Cyclic dependency between Groups on Filter",
+ SALOME::BAD_PARAM );
+ }
+ f->AddModifWaiter( this );
+ }
+ myFilter->SetMesh( SMESH::SMESH_Mesh::_nil() ); // to UnRegister() the mesh
+ }
+
+ if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
+ {
+ grDS->SetPredicate( GetPredicate( myFilter ));
+ Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
+ }
+
+ SMESH::SMESH_GroupOnFilter_var me = _this();
+
+ // mark the group valid after edition
+ GetMeshServant()->GetGen()->HighLightInvalid( me, false );
+
+
+ TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )";
+}
+
+//================================================================================
+/*!
+ * \brief Return the filter defining group contents
+ */
+//================================================================================
+
+SMESH::Filter_ptr SMESH_GroupOnFilter_i::GetFilter()
+{
+ SMESH::Filter_var f = myFilter;
+ TPythonDump() << f << " = " << SMESH::SMESH_GroupOnFilter_var(_this()) << ".GetFilter()";
+ return f._retn();
+}
+
+//================================================================================
+/*!
+ * @return true if group contents is computed
+ */
+//================================================================================
+
+CORBA::Boolean SMESH_GroupOnFilter_i::IsUpToDate()
+{
+ if ( myPreMeshInfo )
+ return false;
+
+ if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
+ return grDS->IsUpToDate();
+
+ return false;
+}
+
+//=======================================================================
+//function : IsMeshInfoCorrect
+//purpose : Return false in two cases: 1) if mesh not loaded and GetMeshInfo() returns
+// incorrect information 2) mesh loaded but group contents is not computed
+//=======================================================================
+
+bool SMESH_GroupOnFilter_i::IsMeshInfoCorrect()
+{
+ return myPreMeshInfo ? myPreMeshInfo->IsMeshInfoCorrect() : IsUpToDate();
+}
+
+//=======================================================================
+//function : GetIDs
+//purpose : Return ids of members
+//=======================================================================
+
+SMESH::long_array* SMESH_GroupOnFilter_i::GetListOfID()
+{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
+ SMESH::long_array_var aRes = new SMESH::long_array();
+ SMESHDS_GroupBase* aGroupDS = GetGroupDS();
+ if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
+ {
+ const SMDS_MeshInfo& meshInfo = aGroupDS->GetMesh()->GetMeshInfo();
+ aRes->length( meshInfo.NbElements( aGroupDS->GetType() ));
+ if ( aRes->length() ) // else aRes[0] -> SIGSEGV
+ aRes->length( grDS->GetElementIds( &aRes[0] ));
+
+ if ( 0 < aRes->length() && aRes->length() < 100 ) // for comfortable testing ;)
+ std::sort( &aRes[0], &aRes[0] + aRes->length() );
+ }
+ return aRes._retn();
+}
+
+//=============================================================================
+/*!
+ * Return statistic of mesh elements
+ * Result array of number enityties
+ * Inherited from SMESH_IDSource
+ */
+//=============================================================================