#include "SMESH_Group.hxx"
#include "SMESH_Mesh_i.hxx"
#include "SMESH_PythonDump.hxx"
+#include "SMESH_PreMeshInfo.hxx"
#include CORBA_SERVER_HEADER(SMESH_Filter)
myMeshServant( theMeshServant ),
myLocalID( theLocalID ),
myNbNodes(-1),
- myGroupDSTic(0)
+ myGroupDSTic(0),
+ myPreMeshInfo(NULL)
{
// PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i,
// servant activation is performed by SMESH_Mesh_i::createGroup()
MESSAGE("~SMESH_GroupBase_i; this = "<<this );
if ( myMeshServant )
myMeshServant->removeGroup(myLocalID);
+
+ if ( myPreMeshInfo ) delete myPreMeshInfo; myPreMeshInfo = NULL;
}
//=======================================================================
CORBA::Long SMESH_GroupBase_i::Size()
{
+ if ( myPreMeshInfo )
+ return GetType() == SMESH::NODE ? myPreMeshInfo->NbNodes() : myPreMeshInfo->NbElements();
+
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
if (aGroupDS)
return aGroupDS->Extent();
CORBA::Boolean SMESH_GroupBase_i::IsEmpty()
{
+ if ( myPreMeshInfo )
+ return Size() == 0;
+
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
if (aGroupDS)
return aGroupDS->IsEmpty();
void SMESH_Group_i::Clear()
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
// Update Python script
TPythonDump() << _this() << ".Clear()";
CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
if (aGroupDS)
return aGroupDS->Contains(theID);
CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
// Update Python script
TPythonDump() << "nbAdd = " << _this() << ".Add( " << theIDs << " )";
CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
// Update Python script
TPythonDump() << "nbDel = " << _this() << ".Remove( " << theIDs << " )";
CORBA::Long
ChangeByPredicate( SMESH::Predicate_i* thePredicate,
- SMESHDS_GroupBase* theGroupBase,
- TFunChangeGroup theFun)
+ SMESHDS_GroupBase* theGroupBase,
+ TFunChangeGroup theFun)
{
CORBA::Long aNb = 0;
if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){
SMESH_Group_i::
AddByPredicate( SMESH::Predicate_ptr thePredicate )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
TPythonDump()<<_this()<<".AddByPredicate("<<aPredicate<<")";
return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Add);
SMESH_Group_i::
RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
TPythonDump()<<_this()<<".RemoveByPredicate("<<aPredicate<<")";
return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Remove);
CORBA::Long SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
TPythonDump pd;
long nbAdd = 0;
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex )
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
if (aGroupDS)
return aGroupDS->GetID(theIndex);
SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
SMESH::long_array_var aRes = new SMESH::long_array();
SMESHDS_GroupBase* aGroupDS = GetGroupDS();
if (aGroupDS) {
if ( GetType() == SMESH::NODE )
return Size();
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
if ( SMESHDS_GroupBase* g = GetGroupDS())
{
if ( myNbNodes < 0 || g->GetTic() != myGroupDSTic )
{
if ( GetType() == SMESH::NODE/* || Size() < 100000 */)
return true;
+ if ( myPreMeshInfo )
+ return false;
if ( SMESHDS_GroupBase* g = GetGroupDS())
return ( myNbNodes > -1 && g->GetTic() == myGroupDSTic);
return false;
if ( GetType() == SMESH::NODE )
return GetListOfID();
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
SMESH::long_array_var aRes = new SMESH::long_array();
if ( SMESHDS_GroupBase* g = GetGroupDS())
{
//=============================================================================
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;
- SMESHDS_GroupBase* aGrpDS = GetGroupDS();
- if ( !aGrpDS )
- return aRes._retn();
- if ( GetType() == NODE )
- aRes[ SMESH::Entity_Node ] = aGrpDS->Extent();
- else
- SMESH_Mesh_i::CollectMeshInfo( aGrpDS->GetElements(), aRes);
-
-// SMDS_ElemIteratorPtr it = aGrpDS->GetElements();
-// if ( it->more() )
-// {
-// cout << "START" << endl;
-// set< const SMDS_MeshElement* > nodes;
-// const SMDS_MeshElement* e = it->next();
-// for ( int i = 0; i < 1000000; ++i)
-// {
-// SMDS_ElemIteratorPtr it = e->nodesIterator();
-// nodes.insert( e + i );
-// }
-// cout << "END "<< nodes.size() << endl;
-// }
-
+ 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();
}
SMESH::long_array* SMESH_GroupBase_i::GetIDs()
{
- SMESH::long_array_var aResult = GetListOfID();
- return aResult._retn();
+ return GetListOfID();
}
//=======================================================================
SMESH::array_of_ElementType* SMESH_GroupBase_i::GetTypes()
{
SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
- if ( SMESHDS_GroupBase* ds = GetGroupDS() )
- if ( !ds->IsEmpty() )
- {
- types->length( 1 );
- types[0] = GetType();
- }
+ if ( !IsEmpty() )
+ {
+ types->length( 1 );
+ types[0] = GetType();
+ }
return types._retn();
}
+//=======================================================================
+//function : IsMeshInfoCorrect
+//purpose : * Returns 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;
+}
+
//================================================================================
/*!
* \brief Retrieves the predicate from the filter
void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
if ( ! myFilter->_is_nil() )
myFilter->UnRegister();
return filter._retn();
}
+//================================================================================
+/*!
+ * \brief Destructor of SMESH_GroupOnFilter_i
+ */
+//================================================================================
+
SMESH_GroupOnFilter_i::~SMESH_GroupOnFilter_i()
{
if ( ! myFilter->_is_nil() )
}
}
+//================================================================================
+/*!
+ * \brief Method calleds when a predicate of myFilter changes
+ */
+//================================================================================
+
void SMESH_GroupOnFilter_i::PredicateChanged()
{
+ if ( myPreMeshInfo )
+ myPreMeshInfo->FullLoadFromFile();
+
if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
grDS->SetPredicate( GetPredicate( myFilter ));
}