mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-01 14:30:33 +05:00
0020918: EDF 1447 SMESH: Mesh common borders
1) publish groups created by Compute() 2) SetStoreName() to groups before storing hypotheses 3) Store Persistent Id of SMESHDS_Mesh 4) Let hypotheses update their data after Load() copletion via UpdateAsMeshesRestored()
This commit is contained in:
parent
6386585f46
commit
77adab5aab
@ -932,7 +932,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
|||||||
// Python Dump
|
// Python Dump
|
||||||
TPythonDump aPythonDump;
|
TPythonDump aPythonDump;
|
||||||
aPythonDump << "([";
|
aPythonDump << "([";
|
||||||
//TCollection_AsciiString aStr ("([");
|
|
||||||
|
|
||||||
if (theStatus == SMESH::DRS_OK) {
|
if (theStatus == SMESH::DRS_OK) {
|
||||||
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
|
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
|
||||||
@ -943,7 +942,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
|||||||
// Iterate through all meshes and create mesh objects
|
// Iterate through all meshes and create mesh objects
|
||||||
for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
|
for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
|
||||||
// Python Dump
|
// Python Dump
|
||||||
//if (i > 0) aStr += ", ";
|
|
||||||
if (i > 0) aPythonDump << ", ";
|
if (i > 0) aPythonDump << ", ";
|
||||||
|
|
||||||
// create mesh
|
// create mesh
|
||||||
@ -956,12 +954,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
|||||||
if ( !aSO->_is_nil() ) {
|
if ( !aSO->_is_nil() ) {
|
||||||
// Python Dump
|
// Python Dump
|
||||||
aPythonDump << aSO;
|
aPythonDump << aSO;
|
||||||
//aStr += aSO->GetID();
|
|
||||||
} else {
|
} else {
|
||||||
// Python Dump
|
// Python Dump
|
||||||
aPythonDump << "mesh_" << i;
|
aPythonDump << "mesh_" << i;
|
||||||
// aStr += "mesh_";
|
|
||||||
// aStr += TCollection_AsciiString(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read mesh data (groups are published automatically by ImportMEDFile())
|
// Read mesh data (groups are published automatically by ImportMEDFile())
|
||||||
@ -1431,7 +1426,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
|
|||||||
myLocShape = SMESH_Mesh::PseudoShape();
|
myLocShape = SMESH_Mesh::PseudoShape();
|
||||||
// call implementation compute
|
// call implementation compute
|
||||||
::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
|
::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
|
||||||
return myGen.Compute( myLocMesh, myLocShape);
|
bool ok = myGen.Compute( myLocMesh, myLocShape);
|
||||||
|
meshServant->CreateGroupServants(); // algos can create groups (issue 0020918)
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( std::bad_alloc ) {
|
catch ( std::bad_alloc ) {
|
||||||
@ -2323,6 +2320,38 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
DriverMED_W_SMESHDS_Mesh myWriter;
|
DriverMED_W_SMESHDS_Mesh myWriter;
|
||||||
myWriter.SetFile( meshfile.ToCString() );
|
myWriter.SetFile( meshfile.ToCString() );
|
||||||
|
|
||||||
|
// IMP issue 20918
|
||||||
|
// SetStoreName() to groups before storing hypotheses to let them refer to
|
||||||
|
// groups using "store name", which is "Group <group_persistent_id>"
|
||||||
|
{
|
||||||
|
SALOMEDS::ChildIterator_var itBig = myCurrentStudy->NewChildIterator( theComponent );
|
||||||
|
for ( ; itBig->More(); itBig->Next() ) {
|
||||||
|
SALOMEDS::SObject_var gotBranch = itBig->Value();
|
||||||
|
if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
|
||||||
|
CORBA::Object_var anObject = SObjectToObject( gotBranch );
|
||||||
|
if ( !CORBA::is_nil( anObject ) ) {
|
||||||
|
SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
|
||||||
|
if ( !myMesh->_is_nil() ) {
|
||||||
|
SMESH::ListOfGroups_var groups = myMesh->GetGroups();
|
||||||
|
for ( int i = 0; i < groups->length(); ++i )
|
||||||
|
{
|
||||||
|
SMESH_GroupBase_i* grImpl = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i]);
|
||||||
|
if ( grImpl )
|
||||||
|
{
|
||||||
|
CORBA::String_var objStr = GetORB()->object_to_string( grImpl->_this() );
|
||||||
|
int anId = myStudyContext->findId( string( objStr.in() ) );
|
||||||
|
char grpName[ 30 ];
|
||||||
|
sprintf( grpName, "Group %d", anId );
|
||||||
|
SMESHDS_GroupBase* aGrpBaseDS = grImpl->GetGroupDS();
|
||||||
|
aGrpBaseDS->SetStoreName( grpName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write data
|
// Write data
|
||||||
// ---> create HDF file
|
// ---> create HDF file
|
||||||
aFile = new HDFfile( (char*) filename.ToCString() );
|
aFile = new HDFfile( (char*) filename.ToCString() );
|
||||||
@ -2519,13 +2548,21 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
aDataset->CloseOnDisk();
|
aDataset->CloseOnDisk();
|
||||||
|
|
||||||
// issue 0020693. Store _isModified flag
|
// issue 0020693. Store _isModified flag
|
||||||
int isModified = myImpl->GetImpl().GetIsModified();
|
int isModified = myLocMesh.GetIsModified();
|
||||||
aSize[ 0 ] = 1;
|
aSize[ 0 ] = 1;
|
||||||
aDataset = new HDFdataset( "_isModified", aTopGroup, HDF_INT32, aSize, 1 );
|
aDataset = new HDFdataset( "_isModified", aTopGroup, HDF_INT32, aSize, 1 );
|
||||||
aDataset->CreateOnDisk();
|
aDataset->CreateOnDisk();
|
||||||
aDataset->WriteOnDisk( &isModified );
|
aDataset->WriteOnDisk( &isModified );
|
||||||
aDataset->CloseOnDisk();
|
aDataset->CloseOnDisk();
|
||||||
|
|
||||||
|
// issue 20918. Store Persistent Id of SMESHDS_Mesh
|
||||||
|
int meshPersistentId = mySMESHDSMesh->GetPersistentId();
|
||||||
|
aSize[ 0 ] = 1;
|
||||||
|
aDataset = new HDFdataset( "meshPersistentId", aTopGroup, HDF_INT32, aSize, 1 );
|
||||||
|
aDataset->CreateOnDisk();
|
||||||
|
aDataset->WriteOnDisk( &meshPersistentId );
|
||||||
|
aDataset->CloseOnDisk();
|
||||||
|
|
||||||
// write reference on a shape if exists
|
// write reference on a shape if exists
|
||||||
SALOMEDS::SObject_var myRef;
|
SALOMEDS::SObject_var myRef;
|
||||||
bool shapeRefFound = false;
|
bool shapeRefFound = false;
|
||||||
@ -2869,17 +2906,19 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() );
|
dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() );
|
||||||
if ( !myGroupImpl )
|
if ( !myGroupImpl )
|
||||||
continue;
|
continue;
|
||||||
|
SMESHDS_GroupBase* aGrpBaseDS = myGroupImpl->GetGroupDS();
|
||||||
|
if ( !aGrpBaseDS )
|
||||||
|
continue;
|
||||||
|
|
||||||
CORBA::String_var objStr = GetORB()->object_to_string( aSubObject );
|
CORBA::String_var objStr = GetORB()->object_to_string( aSubObject );
|
||||||
int anId = myStudyContext->findId( string( objStr.in() ) );
|
int anId = myStudyContext->findId( string( objStr.in() ) );
|
||||||
|
|
||||||
// For each group, create a dataset named "Group <group_persistent_id>"
|
// For each group, create a dataset named "Group <group_persistent_id>"
|
||||||
// and store the group's user name into it
|
// and store the group's user name into it
|
||||||
char grpName[ 30 ];
|
const char* grpName = aGrpBaseDS->GetStoreName();
|
||||||
sprintf( grpName, "Group %d", anId );
|
|
||||||
char* aUserName = myGroupImpl->GetName();
|
char* aUserName = myGroupImpl->GetName();
|
||||||
aSize[ 0 ] = strlen( aUserName ) + 1;
|
aSize[ 0 ] = strlen( aUserName ) + 1;
|
||||||
|
|
||||||
aDataset = new HDFdataset( grpName, aGroup, HDF_STRING, aSize, 1 );
|
aDataset = new HDFdataset( grpName, aGroup, HDF_STRING, aSize, 1 );
|
||||||
aDataset->CreateOnDisk();
|
aDataset->CreateOnDisk();
|
||||||
aDataset->WriteOnDisk( aUserName );
|
aDataset->WriteOnDisk( aUserName );
|
||||||
@ -2901,46 +2940,36 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
aDataset->WriteOnDisk( anRGB );
|
aDataset->WriteOnDisk( anRGB );
|
||||||
aDataset->CloseOnDisk();
|
aDataset->CloseOnDisk();
|
||||||
|
|
||||||
// Store the group contents into MED file
|
// Pass SMESHDS_Group to MED writer
|
||||||
if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) {
|
SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
|
||||||
|
if ( aGrpDS )
|
||||||
if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = "
|
myWriter.AddGroup( aGrpDS );
|
||||||
<< grpName << " to MED file" );
|
|
||||||
SMESHDS_GroupBase* aGrpBaseDS =
|
|
||||||
myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS();
|
|
||||||
aGrpBaseDS->SetStoreName( grpName );
|
|
||||||
|
|
||||||
// Pass SMESHDS_Group to MED writer
|
// write reference on a shape if exists
|
||||||
SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
|
SMESHDS_GroupOnGeom* aGeomGrp =
|
||||||
if ( aGrpDS )
|
dynamic_cast<SMESHDS_GroupOnGeom*>( aGrpBaseDS );
|
||||||
myWriter.AddGroup( aGrpDS );
|
if ( aGeomGrp ) {
|
||||||
|
SALOMEDS::SObject_var mySubRef, myShape;
|
||||||
// write reference on a shape if exists
|
if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) &&
|
||||||
SMESHDS_GroupOnGeom* aGeomGrp =
|
mySubRef->ReferencedObject( myShape ) &&
|
||||||
dynamic_cast<SMESHDS_GroupOnGeom*>( aGrpBaseDS );
|
!CORBA::is_nil( myShape->GetObject() ))
|
||||||
if ( aGeomGrp ) {
|
{
|
||||||
SALOMEDS::SObject_var mySubRef, myShape;
|
string myRefOnObject = myShape->GetID();
|
||||||
if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) &&
|
if ( myRefOnObject.length() > 0 ) {
|
||||||
mySubRef->ReferencedObject( myShape ) &&
|
char aRefName[ 30 ];
|
||||||
!CORBA::is_nil( myShape->GetObject() ))
|
sprintf( aRefName, "Ref on shape %d", anId);
|
||||||
{
|
aSize[ 0 ] = myRefOnObject.length() + 1;
|
||||||
string myRefOnObject = myShape->GetID();
|
aDataset = new HDFdataset(aRefName, aGroup, HDF_STRING, aSize, 1);
|
||||||
if ( myRefOnObject.length() > 0 ) {
|
aDataset->CreateOnDisk();
|
||||||
char aRefName[ 30 ];
|
aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
|
||||||
sprintf( aRefName, "Ref on shape %d", anId);
|
aDataset->CloseOnDisk();
|
||||||
aSize[ 0 ] = myRefOnObject.length() + 1;
|
|
||||||
aDataset = new HDFdataset(aRefName, aGroup, HDF_STRING, aSize, 1);
|
|
||||||
aDataset->CreateOnDisk();
|
|
||||||
aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
|
|
||||||
aDataset->CloseOnDisk();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // shape ref is invalid:
|
|
||||||
{
|
|
||||||
// save a group on geometry as ordinary group
|
|
||||||
myWriter.AddGroup( aGeomGrp );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // shape ref is invalid:
|
||||||
|
{
|
||||||
|
// save a group on geometry as ordinary group
|
||||||
|
myWriter.AddGroup( aGeomGrp );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3630,6 +3659,18 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
aDataset->CloseOnDisk();
|
aDataset->CloseOnDisk();
|
||||||
myNewMeshImpl->GetImpl().SetIsModified( bool(*isModified));
|
myNewMeshImpl->GetImpl().SetIsModified( bool(*isModified));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue 20918. Restore Persistent Id of SMESHDS_Mesh
|
||||||
|
if( aTopGroup->ExistInternalObject( "meshPersistentId" ) )
|
||||||
|
{
|
||||||
|
aDataset = new HDFdataset( "meshPersistentId", aTopGroup );
|
||||||
|
aDataset->OpenOnDisk();
|
||||||
|
size = aDataset->GetSize();
|
||||||
|
int* meshPersistentId = new int[ size ];
|
||||||
|
aDataset->ReadFromDisk( meshPersistentId );
|
||||||
|
aDataset->CloseOnDisk();
|
||||||
|
myNewMeshImpl->GetImpl().GetMeshDS()->SetPersistentId( *meshPersistentId );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3944,7 +3985,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
aGroup = new HDFgroup( "Submeshes", aTopGroup );
|
aGroup = new HDFgroup( "Submeshes", aTopGroup );
|
||||||
aGroup->OpenOnDisk();
|
aGroup->OpenOnDisk();
|
||||||
|
|
||||||
int maxID = mySMESHDSMesh->MaxShapeIndex();
|
int maxID = Max( mySMESHDSMesh->MaxSubMeshIndex(), mySMESHDSMesh->MaxShapeIndex() );
|
||||||
vector< SMESHDS_SubMesh * > subMeshes( maxID + 1, (SMESHDS_SubMesh*) 0 );
|
vector< SMESHDS_SubMesh * > subMeshes( maxID + 1, (SMESHDS_SubMesh*) 0 );
|
||||||
vector< TopAbs_ShapeEnum > smType ( maxID + 1, TopAbs_SHAPE );
|
vector< TopAbs_ShapeEnum > smType ( maxID + 1, TopAbs_SHAPE );
|
||||||
|
|
||||||
@ -4132,20 +4173,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
} // if ( aTopGroup->ExistInternalObject( "Node Positions" ) )
|
} // if ( aTopGroup->ExistInternalObject( "Node Positions" ) )
|
||||||
} // if ( hasData )
|
} // if ( hasData )
|
||||||
|
|
||||||
// Recompute State (as computed sub-meshes are restored from MED)
|
|
||||||
if ( !aShapeObject->_is_nil() || !myNewMeshImpl->HasShapeToMesh()) {
|
|
||||||
MESSAGE("Compute State Engine ...");
|
|
||||||
TopoDS_Shape myLocShape;
|
|
||||||
if(myNewMeshImpl->HasShapeToMesh())
|
|
||||||
myLocShape = GeomObjectToShape( aShapeObject );
|
|
||||||
else
|
|
||||||
myLocShape = SMESH_Mesh::PseudoShape();
|
|
||||||
|
|
||||||
myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine
|
|
||||||
(SMESH_subMesh::SUBMESH_RESTORED);
|
|
||||||
MESSAGE("Compute State Engine finished");
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to get groups
|
// try to get groups
|
||||||
for ( int ii = GetNodeGroupsTag(); ii <= GetVolumeGroupsTag(); ii++ ) {
|
for ( int ii = GetNodeGroupsTag(); ii <= GetVolumeGroupsTag(); ii++ ) {
|
||||||
char name_group[ 30 ];
|
char name_group[ 30 ];
|
||||||
@ -4252,6 +4279,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
aGroup->CloseOnDisk();
|
aGroup->CloseOnDisk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read submeh order if any
|
// read submeh order if any
|
||||||
if( aTopGroup->ExistInternalObject( "Mesh Order" ) ) {
|
if( aTopGroup->ExistInternalObject( "Mesh Order" ) ) {
|
||||||
aDataset = new HDFdataset( "Mesh Order", aTopGroup );
|
aDataset = new HDFdataset( "Mesh Order", aTopGroup );
|
||||||
@ -4270,7 +4298,30 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
|
|
||||||
myNewMeshImpl->GetImpl().SetMeshOrder( anOrderIds );
|
myNewMeshImpl->GetImpl().SetMeshOrder( anOrderIds );
|
||||||
}
|
}
|
||||||
|
} // loop on meshes
|
||||||
|
|
||||||
|
// notify algos on completed restoration
|
||||||
|
for ( meshi_group = meshGroupList.begin(); meshi_group != meshGroupList.end(); ++meshi_group )
|
||||||
|
{
|
||||||
|
SMESH_Mesh_i* myNewMeshImpl = meshi_group->first;
|
||||||
|
::SMESH_Mesh& myLocMesh = myNewMeshImpl->GetImpl();
|
||||||
|
|
||||||
|
TopoDS_Shape myLocShape;
|
||||||
|
if(myLocMesh.HasShapeToMesh())
|
||||||
|
myLocShape = myLocMesh.GetShapeToMesh();
|
||||||
|
else
|
||||||
|
myLocShape = SMESH_Mesh::PseudoShape();
|
||||||
|
|
||||||
|
myLocMesh.GetSubMesh(myLocShape)->
|
||||||
|
ComputeStateEngine (SMESH_subMesh::SUBMESH_RESTORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( hyp_data = hypDataList.begin(); hyp_data != hypDataList.end(); ++hyp_data )
|
||||||
|
{
|
||||||
|
SMESH_Hypothesis_i* hyp = hyp_data->first;
|
||||||
|
hyp->UpdateAsMeshesRestored(); // for hyps needing full mesh data restored (issue 20918)
|
||||||
|
}
|
||||||
|
|
||||||
// close mesh group
|
// close mesh group
|
||||||
if(aTopGroup)
|
if(aTopGroup)
|
||||||
aTopGroup->CloseOnDisk();
|
aTopGroup->CloseOnDisk();
|
||||||
@ -4300,7 +4351,7 @@ bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent,
|
|||||||
const char* theURL,
|
const char* theURL,
|
||||||
bool isMultiFile ) {
|
bool isMultiFile ) {
|
||||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LoadASCII" );
|
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LoadASCII" );
|
||||||
//return Load( theComponent, theStream, theURL, isMultiFile );
|
return Load( theComponent, theStream, theURL, isMultiFile );
|
||||||
|
|
||||||
//before call main ::Load method it's need for decipher text format to
|
//before call main ::Load method it's need for decipher text format to
|
||||||
//binary ( "|xx" => x' )
|
//binary ( "|xx" => x' )
|
||||||
|
Loading…
Reference in New Issue
Block a user