-// Copyright (C) 2007-2010 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
+// 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.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
SMESH_Gen_i::~SMESH_Gen_i()
{
- INFOS( "SMESH_Gen_i::~SMESH_Gen_i" );
+ MESSAGE( "SMESH_Gen_i::~SMESH_Gen_i" );
// delete hypothesis creators
map<string, GenericHypothesisCreator_i*>::iterator itHyp;
}
}
- // let the temporary hypothesis find out some how parameter values by mesh
+ // let the temporary hypothesis find out somehow parameter values by mesh
if ( hyp->SetParametersByMesh( mesh, shape ))
return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
}
::SMESH_Hypothesis::TDefaults dflts;
dflts._elemLength = diagonal / myGen.GetBoundaryBoxSegmentation();
dflts._nbSegments = myGen.GetDefaultNbSegments();
+ dflts._shape = &shape;
// let the temporary hypothesis initialize it's values
if ( hyp->SetParametersByDefaults( dflts, mesh ))
return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
SMESH_subMesh* sm = anIt->first;
SMESH_ComputeErrorPtr& error = sm->GetComputeError();
const SMESH_Algo* algo = myGen.GetAlgo( myLocMesh, sm->GetSubShape());
- if ( algo && !error.get() || error->IsOK() )
+ if ( (algo && !error.get()) || error->IsOK() )
error.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED,"Failed to evaluate",algo));
}
else
}
}
+ newMeshDS->Modified();
+
*pyDump << newMesh << " = " << this
<< ".CopyMesh( " << meshPart << ", "
<< "'" << meshName << "', "
if ( !CORBA::is_nil( anObject ) ) {
SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
if ( !myMesh->_is_nil() ) {
+ TPythonDump pd; // not to dump GetGroups()
SMESH::ListOfGroups_var groups = myMesh->GetGroups();
+ pd << ""; // to avoid optimizing pd out
for ( int i = 0; i < groups->length(); ++i )
{
SMESH_GroupBase_i* grImpl = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i]);
// groups root sub-branch
SALOMEDS::SObject_var myGroupsBranch;
- for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) {
+ for ( int i = GetNodeGroupsTag(); i <= Get0DElementsGroupsTag(); i++ ) {
found = gotBranch->FindSubObject( i, myGroupsBranch );
if ( found ) {
char name_group[ 30 ];
strcpy( name_group, "Groups of Faces" );
else if ( i == GetVolumeGroupsTag() )
strcpy( name_group, "Groups of Volumes" );
+ else if ( i == Get0DElementsGroupsTag() )
+ strcpy( name_group, "Groups of 0D Elements" );
aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->CreateOnDisk();
myWriter.AddGroup( aGeomGrp );
}
}
+ else if ( SMESH_GroupOnFilter_i* aFilterGrp_i =
+ dynamic_cast<SMESH_GroupOnFilter_i*>( myGroupImpl ))
+ {
+ std::string str = aFilterGrp_i->FilterToString();
+ std::string hdfGrpName = "Filter " + SMESH_Comment(anId);
+ aSize[ 0 ] = str.length() + 1;
+ aDataset = new HDFdataset( hdfGrpName.c_str(), aGroup, HDF_STRING, aSize, 1);
+ aDataset->CreateOnDisk();
+ aDataset->WriteOnDisk( ( char* )( str.c_str() ) );
+ aDataset->CloseOnDisk();
+ }
}
}
aGroup->CloseOnDisk();
int size = aStreamFile.in().length();
_CORBA_Octet* buffer = new _CORBA_Octet[size*3+1];
for ( int i = 0; i < size; i++ )
- sprintf( (char*)&(buffer[i*3]), "|%02x", (char*)(aStreamFile[i]) );
+ sprintf( (char*)&(buffer[i*3]), "|%02x", aStreamFile[i] );
buffer[size * 3] = '\0';
int* anAutoColor = new int[ size ];
aDataset->ReadFromDisk( anAutoColor );
aDataset->CloseOnDisk();
- myNewMeshImpl->SetAutoColor( (bool)anAutoColor[0] );
+ myNewMeshImpl->GetImpl().SetAutoColor( (bool)anAutoColor[0] );
}
// try to read and set reference to shape
}
}
- // try to get applied algorithms
+ // Try to get applied ALGORITHMS (mesh is not cleared by algo addition because
+ // nodes and elements are not yet put into sub-meshes)
if ( aTopGroup->ExistInternalObject( "Applied Algorithms" ) ) {
aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
aGroup->OpenOnDisk();
if ( aSubMesh->_is_nil() )
continue;
- // VSR: Get submesh data from MED convertor
- // int anInternalSubmeshId = aSubMesh->GetId(); // this is not a persistent ID, it's an internal one computed from sub-shape
- // if (myNewMeshImpl->_mapSubMesh.find(anInternalSubmeshId) != myNewMeshImpl->_mapSubMesh.end()) {
- // if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " <<
- // subid << " for subshape # " << anInternalSubmeshId);
- // SMESHDS_SubMesh* aSubMeshDS =
- // myNewMeshImpl->_mapSubMesh[anInternalSubmeshId]->CreateSubMeshDS();
- // if ( !aSubMeshDS ) {
- // if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " <<
- // anInternalSubmeshId << " in current mesh!");
- // }
- // else
- // myReader.GetSubMesh( aSubMeshDS, subid );
- // }
-
// try to get applied algorithms
if ( aSubGroup->ExistInternalObject( "Applied Algorithms" ) ) {
// open "applied algorithms" HDF group
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
- //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
- //CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
string anIOR = myStudyContext->getIORbyOldId( id );
if ( !anIOR.empty() ) {
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
- //SALOMEDS::SObject_var hypSO = myCurrentStudy->FindObjectID( refFromFile );
- //CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
string anIOR = myStudyContext->getIORbyOldId( id );
if ( !anIOR.empty() ) {
if(hasData) {
- // Read sub-meshes from MED
- // -------------------------
+ // Read sub-meshes
+ // ----------------
if(MYDEBUG) MESSAGE("Create all sub-meshes");
bool submeshesInFamilies = ( ! aTopGroup->ExistInternalObject( "Submeshes" ));
- if ( submeshesInFamilies )
+ if ( submeshesInFamilies ) // from MED
{
// old way working before fix of PAL 12992
myReader.CreateAllSubMeshes();
} // if ( hasData )
// try to get groups
- for ( int ii = GetNodeGroupsTag(); ii <= GetVolumeGroupsTag(); ii++ ) {
+ for ( int ii = GetNodeGroupsTag(); ii <= Get0DElementsGroupsTag(); ii++ ) {
char name_group[ 30 ];
if ( ii == GetNodeGroupsTag() )
strcpy( name_group, "Groups of Nodes" );
strcpy( name_group, "Groups of Faces" );
else if ( ii == GetVolumeGroupsTag() )
strcpy( name_group, "Groups of Volumes" );
+ else if ( ii == Get0DElementsGroupsTag() )
+ strcpy( name_group, "Groups of 0D Elements" );
if ( aTopGroup->ExistInternalObject( name_group ) ) {
aGroup = new HDFgroup( name_group, aTopGroup );
}
}
}
+ // Try to read a filter of SMESH_GroupOnFilter
+ SMESH::Filter_var filter;
+ SMESH_PredicatePtr predicate;
+ std::string hdfGrpName = "Filter " + SMESH_Comment(subid);
+ if ( aGroup->ExistInternalObject( hdfGrpName.c_str() ))
+ {
+ aDataset = new HDFdataset( hdfGrpName.c_str(), aGroup );
+ aDataset->OpenOnDisk();
+ size = aDataset->GetSize();
+ char* persistStr = new char[ size ];
+ aDataset->ReadFromDisk( persistStr );
+ aDataset->CloseOnDisk();
+ if ( strlen( persistStr ) > 0 ) {
+ filter = SMESH_GroupOnFilter_i::StringToFilter( persistStr );
+ predicate = SMESH_GroupOnFilter_i::GetPredicate( filter );
+ }
+ }
+
// Create group servant
SMESH::ElementType type = (SMESH::ElementType)(ii - GetNodeGroupsTag() + 1);
SMESH::SMESH_GroupBase_var aNewGroup = SMESH::SMESH_GroupBase::_duplicate
- ( myNewMeshImpl->createGroup( type, nameFromFile, aShape ) );
+ ( myNewMeshImpl->createGroup( type, nameFromFile, aShape, predicate ) );
// Obtain a SMESHDS_Group object
if ( aNewGroup->_is_nil() )
continue;
int newSubId = myStudyContext->findId( iorSubString );
myStudyContext->mapOldToNew( subid, newSubId );
- SMESH_GroupBase_i* aGroupImpl =
- dynamic_cast<SMESH_GroupBase_i*>( GetServant( aNewGroup ).in() );
+ SMESH_GroupBase_i* aGroupImpl = SMESH::DownCast< SMESH_GroupBase_i*>( aNewGroup );
if ( !aGroupImpl )
continue;
- SMESH_Group* aLocalGroup = myLocMesh.GetGroup( aGroupImpl->GetLocalID() );
- if ( !aLocalGroup )
+ if ( SMESH_GroupOnFilter_i* aFilterGroup =
+ dynamic_cast< SMESH_GroupOnFilter_i*>( aGroupImpl ))
+ aFilterGroup->SetFilter( filter );
+
+ SMESHDS_GroupBase* aGroupBaseDS = aGroupImpl->GetGroupDS();
+ if ( !aGroupBaseDS )
continue;
- SMESHDS_GroupBase* aGroupBaseDS = aLocalGroup->GetGroupDS();
aGroupBaseDS->SetStoreName( name_dataset );
// ouv : NPAL12872