fix SWP12968

Implementation of methods SMESH_Gen_i::LoadASCII and SMESH_Gen_i::SaveASCII.
This commit is contained in:
abd 2006-08-29 05:41:25 +00:00
parent 7a3868cfc4
commit 961309c8a4

View File

@ -1214,21 +1214,21 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
{ {
INFOS( "SMESH_Gen_i::Save" ); INFOS( "SMESH_Gen_i::Save" );
// ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() ) // ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
// san -- in case <myCurrentStudy> differs from theComponent's study, // san -- in case <myCurrentStudy> differs from theComponent's study,
// use that of the component // use that of the component
if ( myCurrentStudy->_is_nil() || if ( myCurrentStudy->_is_nil() ||
theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() ) theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() )
SetCurrentStudy( theComponent->GetStudy() ); SetCurrentStudy( theComponent->GetStudy() );
// Store study contents as a set of python commands // Store study contents as a set of python commands
SavePython(myCurrentStudy); SavePython(myCurrentStudy);
StudyContext* myStudyContext = GetCurrentStudyContext(); StudyContext* myStudyContext = GetCurrentStudyContext();
// Declare a byte stream // Declare a byte stream
SALOMEDS::TMPFile_var aStreamFile; SALOMEDS::TMPFile_var aStreamFile;
// Obtain a temporary dir // Obtain a temporary dir
TCollection_AsciiString tmpDir = TCollection_AsciiString tmpDir =
( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str(); ( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str();
@ -1297,57 +1297,57 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySObject = it->Value(); SALOMEDS::SObject_var mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject ); CORBA::Object_var anObject = SObjectToObject( mySObject );
if ( !CORBA::is_nil( anObject ) ) { if ( !CORBA::is_nil( anObject ) ) {
SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
if ( !myHyp->_is_nil() ) { if ( !myHyp->_is_nil() ) {
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() ); SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
if ( myImpl ) { if ( myImpl ) {
string hypname = string( myHyp->GetName() ); string hypname = string( myHyp->GetName() );
string libname = string( myHyp->GetLibName() ); string libname = string( myHyp->GetLibName() );
// BUG SWP13062 // BUG SWP13062
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for // Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
// WNT and ".so" for X-system) must be deleted // WNT and ".so" for X-system) must be deleted
int libname_len = libname.length(); int libname_len = libname.length();
#ifdef WNT #ifdef WNT
if( libname_len > 4 ) if( libname_len > 4 )
libname.resize( libname_len - 4 ); libname.resize( libname_len - 4 );
#else #else
if( libname_len > 3 ) if( libname_len > 3 )
libname.resize( libname_len - 3 ); libname.resize( libname_len - 3 );
#endif #endif
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
string hypdata = string( myImpl->SaveTo() ); string hypdata = string( myImpl->SaveTo() );
// for each hypothesis create HDF group basing on its id // for each hypothesis create HDF group basing on its id
char hypGrpName[30]; char hypGrpName[30];
sprintf( hypGrpName, "Hypothesis %d", id ); sprintf( hypGrpName, "Hypothesis %d", id );
aGroup = new HDFgroup( hypGrpName, aTopGroup ); aGroup = new HDFgroup( hypGrpName, aTopGroup );
aGroup->CreateOnDisk(); aGroup->CreateOnDisk();
// --> type name of hypothesis // --> type name of hypothesis
aSize[ 0 ] = hypname.length() + 1; aSize[ 0 ] = hypname.length() + 1;
aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) ); aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// --> server plugin library name of hypothesis // --> server plugin library name of hypothesis
aSize[ 0 ] = libname.length() + 1; aSize[ 0 ] = libname.length() + 1;
aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( libname.c_str() ) ); aDataset->WriteOnDisk( ( char* )( libname.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// --> persistent data of hypothesis // --> persistent data of hypothesis
aSize[ 0 ] = hypdata.length() + 1; aSize[ 0 ] = hypdata.length() + 1;
aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) ); aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// close hypothesis HDF group // close hypothesis HDF group
aGroup->CloseOnDisk(); aGroup->CloseOnDisk();
} }
} }
} }
} }
// close hypotheses root HDF group // close hypotheses root HDF group
aTopGroup->CloseOnDisk(); aTopGroup->CloseOnDisk();
@ -1362,57 +1362,57 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySObject = it->Value(); SALOMEDS::SObject_var mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject ); CORBA::Object_var anObject = SObjectToObject( mySObject );
if ( !CORBA::is_nil( anObject ) ) { if ( !CORBA::is_nil( anObject ) ) {
SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
if ( !myHyp->_is_nil() ) { if ( !myHyp->_is_nil() ) {
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() ); SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
if ( myImpl ) { if ( myImpl ) {
string hypname = string( myHyp->GetName() ); string hypname = string( myHyp->GetName() );
string libname = string( myHyp->GetLibName() ); string libname = string( myHyp->GetLibName() );
// BUG SWP13062 // BUG SWP13062
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for // Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
// WNT and ".so" for X-system) must be deleted // WNT and ".so" for X-system) must be deleted
int libname_len = libname.length(); int libname_len = libname.length();
#ifdef WNT #ifdef WNT
if( libname_len > 4 ) if( libname_len > 4 )
libname.resize( libname_len - 4 ); libname.resize( libname_len - 4 );
#else #else
if( libname_len > 3 ) if( libname_len > 3 )
libname.resize( libname_len - 3 ); libname.resize( libname_len - 3 );
#endif #endif
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
string hypdata = string( myImpl->SaveTo() ); string hypdata = string( myImpl->SaveTo() );
// for each algorithm create HDF group basing on its id // for each algorithm create HDF group basing on its id
char hypGrpName[30]; char hypGrpName[30];
sprintf( hypGrpName, "Algorithm %d", id ); sprintf( hypGrpName, "Algorithm %d", id );
aGroup = new HDFgroup( hypGrpName, aTopGroup ); aGroup = new HDFgroup( hypGrpName, aTopGroup );
aGroup->CreateOnDisk(); aGroup->CreateOnDisk();
// --> type name of algorithm // --> type name of algorithm
aSize[0] = hypname.length() + 1; aSize[0] = hypname.length() + 1;
aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Name", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) ); aDataset->WriteOnDisk( ( char* )( hypname.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// --> server plugin library name of hypothesis // --> server plugin library name of hypothesis
aSize[0] = libname.length() + 1; aSize[0] = libname.length() + 1;
aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "LibName", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( libname.c_str() ) ); aDataset->WriteOnDisk( ( char* )( libname.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// --> persistent data of algorithm // --> persistent data of algorithm
aSize[0] = hypdata.length() + 1; aSize[0] = hypdata.length() + 1;
aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Data", aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) ); aDataset->WriteOnDisk( ( char* )( hypdata.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// close algorithm HDF group // close algorithm HDF group
aGroup->CloseOnDisk(); aGroup->CloseOnDisk();
} }
} }
} }
} }
// close algorithms root HDF group // close algorithms root HDF group
aTopGroup->CloseOnDisk(); aTopGroup->CloseOnDisk();
@ -1421,155 +1421,155 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
else if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) { else if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
CORBA::Object_var anObject = SObjectToObject( gotBranch ); CORBA::Object_var anObject = SObjectToObject( gotBranch );
if ( !CORBA::is_nil( anObject ) ) { if ( !CORBA::is_nil( anObject ) ) {
SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ; SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ;
if ( !myMesh->_is_nil() ) { if ( !myMesh->_is_nil() ) {
SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myMesh ).in() ); SMESH_Mesh_i* myImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myMesh ).in() );
if ( myImpl ) { if ( myImpl ) {
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
::SMESH_Mesh& myLocMesh = myImpl->GetImpl(); ::SMESH_Mesh& myLocMesh = myImpl->GetImpl();
SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS(); SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
// for each mesh open the HDF group basing on its id // for each mesh open the HDF group basing on its id
char meshGrpName[ 30 ]; char meshGrpName[ 30 ];
sprintf( meshGrpName, "Mesh %d", id ); sprintf( meshGrpName, "Mesh %d", id );
aTopGroup = new HDFgroup( meshGrpName, aFile ); aTopGroup = new HDFgroup( meshGrpName, aFile );
aTopGroup->CreateOnDisk(); aTopGroup->CreateOnDisk();
// --> put dataset to hdf file which is a flag that mesh has data // --> put dataset to hdf file which is a flag that mesh has data
string strHasData = "0"; string strHasData = "0";
// check if the mesh is not empty // check if the mesh is not empty
if ( mySMESHDSMesh->NbNodes() > 0 ) { if ( mySMESHDSMesh->NbNodes() > 0 ) {
// write mesh data to med file // write mesh data to med file
myWriter.SetMesh( mySMESHDSMesh ); myWriter.SetMesh( mySMESHDSMesh );
myWriter.SetMeshId( id ); myWriter.SetMeshId( id );
strHasData = "1"; strHasData = "1";
} }
aSize[ 0 ] = strHasData.length() + 1; aSize[ 0 ] = strHasData.length() + 1;
aDataset = new HDFdataset( "Has data", aTopGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Has data", aTopGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( strHasData.c_str() ) ); aDataset->WriteOnDisk( ( char* )( strHasData.c_str() ) );
aDataset->CloseOnDisk(); 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;
bool found = gotBranch->FindSubObject( GetRefOnShapeTag(), myRef ); bool found = gotBranch->FindSubObject( GetRefOnShapeTag(), myRef );
if ( found ) { if ( found ) {
SALOMEDS::SObject_var myShape; SALOMEDS::SObject_var myShape;
bool ok = myRef->ReferencedObject( myShape ); bool ok = myRef->ReferencedObject( myShape );
if ( ok ) { if ( ok ) {
shapeRefFound = (! CORBA::is_nil( myShape->GetObject() )); shapeRefFound = (! CORBA::is_nil( myShape->GetObject() ));
string myRefOnObject = myShape->GetID(); string myRefOnObject = myShape->GetID();
if ( shapeRefFound && myRefOnObject.length() > 0 ) { if ( shapeRefFound && myRefOnObject.length() > 0 ) {
aSize[ 0 ] = myRefOnObject.length() + 1; aSize[ 0 ] = myRefOnObject.length() + 1;
aDataset = new HDFdataset( "Ref on shape", aTopGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( "Ref on shape", aTopGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
} }
} }
} }
// write applied hypotheses if exist // write applied hypotheses if exist
SALOMEDS::SObject_var myHypBranch; SALOMEDS::SObject_var myHypBranch;
found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch ); found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch );
if ( found && !shapeRefFound ) { // remove applied hyps if ( found && !shapeRefFound ) { // remove applied hyps
myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch ); myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
} }
if ( found && shapeRefFound ) { if ( found && shapeRefFound ) {
aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup ); aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
aGroup->CreateOnDisk(); aGroup->CreateOnDisk();
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myHypBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myHypBranch );
int hypNb = 0; int hypNb = 0;
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySObject = it->Value(); SALOMEDS::SObject_var mySObject = it->Value();
SALOMEDS::SObject_var myRefOnHyp; SALOMEDS::SObject_var myRefOnHyp;
bool ok = mySObject->ReferencedObject( myRefOnHyp ); bool ok = mySObject->ReferencedObject( myRefOnHyp );
if ( ok ) { if ( ok ) {
// san - it is impossible to recover applied hypotheses // san - it is impossible to recover applied hypotheses
// using their entries within Load() method, // using their entries within Load() method,
// for there are no AttributeIORs in the study when Load() is working. // for there are no AttributeIORs in the study when Load() is working.
// Hence, it is better to store persistent IDs of hypotheses as references to them // Hence, it is better to store persistent IDs of hypotheses as references to them
//string myRefOnObject = myRefOnHyp->GetID(); //string myRefOnObject = myRefOnHyp->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnHyp ); CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) { //if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1; //aSize[ 0 ] = myRefOnObject.length() + 1;
char hypName[ 30 ], hypId[ 30 ]; char hypName[ 30 ], hypId[ 30 ];
sprintf( hypName, "Hyp %d", ++hypNb ); sprintf( hypName, "Hyp %d", ++hypNb );
sprintf( hypId, "%d", id ); sprintf( hypId, "%d", id );
aSize[ 0 ] = strlen( hypId ) + 1; aSize[ 0 ] = strlen( hypId ) + 1;
aDataset = new HDFdataset( hypName, aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( hypName, aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
//aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
aDataset->WriteOnDisk( hypId ); aDataset->WriteOnDisk( hypId );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
//} //}
} }
} }
aGroup->CloseOnDisk(); aGroup->CloseOnDisk();
} }
// write applied algorithms if exist // write applied algorithms if exist
SALOMEDS::SObject_var myAlgoBranch; SALOMEDS::SObject_var myAlgoBranch;
found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch ); found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch );
if ( found && !shapeRefFound ) { // remove applied algos if ( found && !shapeRefFound ) { // remove applied algos
myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch ); myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
} }
if ( found && shapeRefFound ) { if ( found && shapeRefFound ) {
aGroup = new HDFgroup( "Applied Algorithms", aTopGroup ); aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
aGroup->CreateOnDisk(); aGroup->CreateOnDisk();
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myAlgoBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myAlgoBranch );
int algoNb = 0; int algoNb = 0;
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySObject = it->Value(); SALOMEDS::SObject_var mySObject = it->Value();
SALOMEDS::SObject_var myRefOnAlgo; SALOMEDS::SObject_var myRefOnAlgo;
bool ok = mySObject->ReferencedObject( myRefOnAlgo ); bool ok = mySObject->ReferencedObject( myRefOnAlgo );
if ( ok ) { if ( ok ) {
// san - it is impossible to recover applied algorithms // san - it is impossible to recover applied algorithms
// using their entries within Load() method, // using their entries within Load() method,
// for there are no AttributeIORs in the study when Load() is working. // for there are no AttributeIORs in the study when Load() is working.
// Hence, it is better to store persistent IDs of algorithms as references to them // Hence, it is better to store persistent IDs of algorithms as references to them
//string myRefOnObject = myRefOnAlgo->GetID(); //string myRefOnObject = myRefOnAlgo->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo ); CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) { //if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1; //aSize[ 0 ] = myRefOnObject.length() + 1;
char algoName[ 30 ], algoId[ 30 ]; char algoName[ 30 ], algoId[ 30 ];
sprintf( algoName, "Algo %d", ++algoNb ); sprintf( algoName, "Algo %d", ++algoNb );
sprintf( algoId, "%d", id ); sprintf( algoId, "%d", id );
aSize[ 0 ] = strlen( algoId ) + 1; aSize[ 0 ] = strlen( algoId ) + 1;
aDataset = new HDFdataset( algoName, aGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( algoName, aGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
//aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
aDataset->WriteOnDisk( algoId ); aDataset->WriteOnDisk( algoId );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
//} //}
} }
} }
aGroup->CloseOnDisk(); aGroup->CloseOnDisk();
} }
// --> submesh objects sub-branches // --> submesh objects sub-branches
for ( int i = GetSubMeshOnVertexTag(); i <= GetSubMeshOnCompoundTag(); i++ ) { for ( int i = GetSubMeshOnVertexTag(); i <= GetSubMeshOnCompoundTag(); i++ ) {
SALOMEDS::SObject_var mySubmeshBranch; SALOMEDS::SObject_var mySubmeshBranch;
found = gotBranch->FindSubObject( i, mySubmeshBranch ); found = gotBranch->FindSubObject( i, mySubmeshBranch );
if ( found ) // check if there is shape reference in submeshes if ( found ) // check if there is shape reference in submeshes
{ {
bool hasShapeRef = false; bool hasShapeRef = false;
SALOMEDS::ChildIterator_var itSM = SALOMEDS::ChildIterator_var itSM =
myCurrentStudy->NewChildIterator( mySubmeshBranch ); myCurrentStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) { for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_var mySubRef, myShape, mySObject = itSM->Value(); SALOMEDS::SObject_var mySubRef, myShape, mySObject = itSM->Value();
if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef )) if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ))
mySubRef->ReferencedObject( myShape ); mySubRef->ReferencedObject( myShape );
if ( !CORBA::is_nil( myShape ) && !CORBA::is_nil( myShape->GetObject() )) if ( !CORBA::is_nil( myShape ) && !CORBA::is_nil( myShape->GetObject() ))
@ -1600,45 +1600,45 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
found = false; found = false;
} }
} // end check if there is shape reference in submeshes } // end check if there is shape reference in submeshes
if ( found ) { if ( found ) {
char name_meshgroup[ 30 ]; char name_meshgroup[ 30 ];
if ( i == GetSubMeshOnVertexTag() ) if ( i == GetSubMeshOnVertexTag() )
strcpy( name_meshgroup, "SubMeshes On Vertex" ); strcpy( name_meshgroup, "SubMeshes On Vertex" );
else if ( i == GetSubMeshOnEdgeTag() ) else if ( i == GetSubMeshOnEdgeTag() )
strcpy( name_meshgroup, "SubMeshes On Edge" ); strcpy( name_meshgroup, "SubMeshes On Edge" );
else if ( i == GetSubMeshOnWireTag() ) else if ( i == GetSubMeshOnWireTag() )
strcpy( name_meshgroup, "SubMeshes On Wire" ); strcpy( name_meshgroup, "SubMeshes On Wire" );
else if ( i == GetSubMeshOnFaceTag() ) else if ( i == GetSubMeshOnFaceTag() )
strcpy( name_meshgroup, "SubMeshes On Face" ); strcpy( name_meshgroup, "SubMeshes On Face" );
else if ( i == GetSubMeshOnShellTag() ) else if ( i == GetSubMeshOnShellTag() )
strcpy( name_meshgroup, "SubMeshes On Shell" ); strcpy( name_meshgroup, "SubMeshes On Shell" );
else if ( i == GetSubMeshOnSolidTag() ) else if ( i == GetSubMeshOnSolidTag() )
strcpy( name_meshgroup, "SubMeshes On Solid" ); strcpy( name_meshgroup, "SubMeshes On Solid" );
else if ( i == GetSubMeshOnCompoundTag() ) else if ( i == GetSubMeshOnCompoundTag() )
strcpy( name_meshgroup, "SubMeshes On Compound" ); strcpy( name_meshgroup, "SubMeshes On Compound" );
// for each type of submeshes create container HDF group
aGroup = new HDFgroup( name_meshgroup, aTopGroup );
aGroup->CreateOnDisk();
// iterator for all submeshes of given type
SALOMEDS::ChildIterator_var itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_var mySObject = itSM->Value();
CORBA::Object_var anSubObject = SObjectToObject( mySObject );
if ( !CORBA::is_nil( anSubObject ))
{
SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow( anSubObject ) ;
CORBA::String_var objStr = GetORB()->object_to_string( anSubObject );
int subid = myStudyContext->findId( string( objStr.in() ) );
// for each mesh open the HDF group basing on its id
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", subid );
aSubGroup = new HDFgroup( submeshGrpName, aGroup );
aSubGroup->CreateOnDisk();
// write reference on a shape, already checked if it exists // for each type of submeshes create container HDF group
aGroup = new HDFgroup( name_meshgroup, aTopGroup );
aGroup->CreateOnDisk();
// iterator for all submeshes of given type
SALOMEDS::ChildIterator_var itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_var mySObject = itSM->Value();
CORBA::Object_var anSubObject = SObjectToObject( mySObject );
if ( !CORBA::is_nil( anSubObject ))
{
SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow( anSubObject ) ;
CORBA::String_var objStr = GetORB()->object_to_string( anSubObject );
int subid = myStudyContext->findId( string( objStr.in() ) );
// for each mesh open the HDF group basing on its id
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", subid );
aSubGroup = new HDFgroup( submeshGrpName, aGroup );
aSubGroup->CreateOnDisk();
// write reference on a shape, already checked if it exists
SALOMEDS::SObject_var mySubRef, myShape; SALOMEDS::SObject_var mySubRef, myShape;
if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef )) if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ))
mySubRef->ReferencedObject( myShape ); mySubRef->ReferencedObject( myShape );
@ -1651,141 +1651,141 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
} }
// write applied hypotheses if exist // write applied hypotheses if exist
SALOMEDS::SObject_var mySubHypBranch; SALOMEDS::SObject_var mySubHypBranch;
found = mySObject->FindSubObject( GetRefOnAppliedHypothesisTag(), mySubHypBranch ); found = mySObject->FindSubObject( GetRefOnAppliedHypothesisTag(), mySubHypBranch );
if ( found ) { if ( found ) {
aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup ); aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
aSubSubGroup->CreateOnDisk(); aSubSubGroup->CreateOnDisk();
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubHypBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubHypBranch );
int hypNb = 0; int hypNb = 0;
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySubSObject = it->Value(); SALOMEDS::SObject_var mySubSObject = it->Value();
SALOMEDS::SObject_var myRefOnHyp; SALOMEDS::SObject_var myRefOnHyp;
bool ok = mySubSObject->ReferencedObject( myRefOnHyp ); bool ok = mySubSObject->ReferencedObject( myRefOnHyp );
if ( ok ) { if ( ok ) {
//string myRefOnObject = myRefOnHyp->GetID(); //string myRefOnObject = myRefOnHyp->GetID();
CORBA::Object_var anObject = SObjectToObject( myRefOnHyp ); CORBA::Object_var anObject = SObjectToObject( myRefOnHyp );
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); CORBA::String_var objStr = GetORB()->object_to_string( anObject );
int id = myStudyContext->findId( string( objStr.in() ) ); int id = myStudyContext->findId( string( objStr.in() ) );
//if ( myRefOnObject.length() > 0 ) { //if ( myRefOnObject.length() > 0 ) {
//aSize[ 0 ] = myRefOnObject.length() + 1; //aSize[ 0 ] = myRefOnObject.length() + 1;
char hypName[ 30 ], hypId[ 30 ]; char hypName[ 30 ], hypId[ 30 ];
sprintf( hypName, "Hyp %d", ++hypNb ); sprintf( hypName, "Hyp %d", ++hypNb );
sprintf( hypId, "%d", id ); sprintf( hypId, "%d", id );
aSize[ 0 ] = strlen( hypId ) + 1; aSize[ 0 ] = strlen( hypId ) + 1;
aDataset = new HDFdataset( hypName, aSubSubGroup, HDF_STRING, aSize, 1 ); aDataset = new HDFdataset( hypName, aSubSubGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk(); aDataset->CreateOnDisk();
//aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
aDataset->WriteOnDisk( hypId ); aDataset->WriteOnDisk( hypId );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
//} //}
} }
} }
aSubSubGroup->CloseOnDisk(); aSubSubGroup->CloseOnDisk();
} }
// write applied algorithms if exist
SALOMEDS::SObject_var mySubAlgoBranch;
found = mySObject->FindSubObject( GetRefOnAppliedAlgorithmsTag(), mySubAlgoBranch );
if ( found ) {
aSubSubGroup = new HDFgroup( "Applied Algorithms", aSubGroup );
aSubSubGroup->CreateOnDisk();
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubAlgoBranch ); // write applied algorithms if exist
int algoNb = 0; SALOMEDS::SObject_var mySubAlgoBranch;
for ( ; it->More(); it->Next() ) { found = mySObject->FindSubObject( GetRefOnAppliedAlgorithmsTag(), mySubAlgoBranch );
SALOMEDS::SObject_var mySubSObject = it->Value(); if ( found ) {
SALOMEDS::SObject_var myRefOnAlgo; aSubSubGroup = new HDFgroup( "Applied Algorithms", aSubGroup );
bool ok = mySubSObject->ReferencedObject( myRefOnAlgo ); aSubSubGroup->CreateOnDisk();
if ( ok ) {
//string myRefOnObject = myRefOnAlgo->GetID(); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( mySubAlgoBranch );
CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo ); int algoNb = 0;
CORBA::String_var objStr = GetORB()->object_to_string( anObject ); for ( ; it->More(); it->Next() ) {
int id = myStudyContext->findId( string( objStr.in() ) ); SALOMEDS::SObject_var mySubSObject = it->Value();
//if ( myRefOnObject.length() > 0 ) { SALOMEDS::SObject_var myRefOnAlgo;
//aSize[ 0 ] = myRefOnObject.length() + 1; bool ok = mySubSObject->ReferencedObject( myRefOnAlgo );
char algoName[ 30 ], algoId[ 30 ]; if ( ok ) {
sprintf( algoName, "Algo %d", ++algoNb ); //string myRefOnObject = myRefOnAlgo->GetID();
sprintf( algoId, "%d", id ); CORBA::Object_var anObject = SObjectToObject( myRefOnAlgo );
aSize[ 0 ] = strlen( algoId ) + 1; CORBA::String_var objStr = GetORB()->object_to_string( anObject );
aDataset = new HDFdataset( algoName, aSubSubGroup, HDF_STRING, aSize, 1 ); int id = myStudyContext->findId( string( objStr.in() ) );
aDataset->CreateOnDisk(); //if ( myRefOnObject.length() > 0 ) {
//aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); //aSize[ 0 ] = myRefOnObject.length() + 1;
aDataset->WriteOnDisk( algoId ); char algoName[ 30 ], algoId[ 30 ];
aDataset->CloseOnDisk(); sprintf( algoName, "Algo %d", ++algoNb );
//} sprintf( algoId, "%d", id );
} aSize[ 0 ] = strlen( algoId ) + 1;
} aDataset = new HDFdataset( algoName, aSubSubGroup, HDF_STRING, aSize, 1 );
aSubSubGroup->CloseOnDisk(); aDataset->CreateOnDisk();
} //aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) );
// close submesh HDF group aDataset->WriteOnDisk( algoId );
aSubGroup->CloseOnDisk(); aDataset->CloseOnDisk();
} //}
} }
// close container of submeshes by type HDF group }
aGroup->CloseOnDisk(); aSubSubGroup->CloseOnDisk();
} }
} // close submesh HDF group
aSubGroup->CloseOnDisk();
}
}
// close container of submeshes by type HDF group
aGroup->CloseOnDisk();
}
}
// All sub-meshes will be stored in MED file // All sub-meshes will be stored in MED file
if ( shapeRefFound ) if ( shapeRefFound )
myWriter.AddAllSubMeshes(); myWriter.AddAllSubMeshes();
// groups root sub-branch // groups root sub-branch
SALOMEDS::SObject_var myGroupsBranch; SALOMEDS::SObject_var myGroupsBranch;
for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) { for ( int i = GetNodeGroupsTag(); i <= GetVolumeGroupsTag(); i++ ) {
found = gotBranch->FindSubObject( i, myGroupsBranch ); found = gotBranch->FindSubObject( i, myGroupsBranch );
if ( found ) { if ( found ) {
char name_group[ 30 ]; char name_group[ 30 ];
if ( i == GetNodeGroupsTag() ) if ( i == GetNodeGroupsTag() )
strcpy( name_group, "Groups of Nodes" ); strcpy( name_group, "Groups of Nodes" );
else if ( i == GetEdgeGroupsTag() ) else if ( i == GetEdgeGroupsTag() )
strcpy( name_group, "Groups of Edges" ); strcpy( name_group, "Groups of Edges" );
else if ( i == GetFaceGroupsTag() ) else if ( i == GetFaceGroupsTag() )
strcpy( name_group, "Groups of Faces" ); strcpy( name_group, "Groups of Faces" );
else if ( i == GetVolumeGroupsTag() ) else if ( i == GetVolumeGroupsTag() )
strcpy( name_group, "Groups of Volumes" ); strcpy( name_group, "Groups of Volumes" );
aGroup = new HDFgroup( name_group, aTopGroup ); aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->CreateOnDisk(); aGroup->CreateOnDisk();
SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch ); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch );
for ( ; it->More(); it->Next() ) { for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_var mySObject = it->Value(); SALOMEDS::SObject_var mySObject = it->Value();
CORBA::Object_var aSubObject = SObjectToObject( mySObject ); CORBA::Object_var aSubObject = SObjectToObject( mySObject );
if ( !CORBA::is_nil( aSubObject ) ) { if ( !CORBA::is_nil( aSubObject ) ) {
SMESH_GroupBase_i* myGroupImpl = SMESH_GroupBase_i* myGroupImpl =
dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() ); dynamic_cast<SMESH_GroupBase_i*>( GetServant( aSubObject ).in() );
if ( !myGroupImpl ) if ( !myGroupImpl )
continue; 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 ]; char grpName[ 30 ];
sprintf( grpName, "Group %d", anId ); 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 );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// Store the group contents into MED file // Store the group contents into MED file
if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) { if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) {
if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = " if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = "
<< grpName << " to MED file" ); << grpName << " to MED file" );
SMESHDS_GroupBase* aGrpBaseDS = SMESHDS_GroupBase* aGrpBaseDS =
myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS(); myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS();
aGrpBaseDS->SetStoreName( grpName ); aGrpBaseDS->SetStoreName( grpName );
// Pass SMESHDS_Group to MED writer // Pass SMESHDS_Group to MED writer
SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS ); SMESHDS_Group* aGrpDS = dynamic_cast<SMESHDS_Group*>( aGrpBaseDS );
if ( aGrpDS ) if ( aGrpDS )
myWriter.AddGroup( aGrpDS ); myWriter.AddGroup( aGrpDS );
@ -1795,8 +1795,8 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
if ( aGeomGrp ) { if ( aGeomGrp ) {
SALOMEDS::SObject_var mySubRef, myShape; SALOMEDS::SObject_var mySubRef, myShape;
if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) && if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) &&
mySubRef->ReferencedObject( myShape ) && mySubRef->ReferencedObject( myShape ) &&
!CORBA::is_nil( myShape->GetObject() )) !CORBA::is_nil( myShape->GetObject() ))
{ {
string myRefOnObject = myShape->GetID(); string myRefOnObject = myShape->GetID();
if ( myRefOnObject.length() > 0 ) { if ( myRefOnObject.length() > 0 ) {
@ -1815,17 +1815,17 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
myWriter.AddGroup( aGeomGrp ); myWriter.AddGroup( aGeomGrp );
} }
} }
} }
} }
} }
aGroup->CloseOnDisk(); aGroup->CloseOnDisk();
} }
} // loop on groups } // loop on groups
if ( strcmp( strHasData.c_str(), "1" ) == 0 ) if ( strcmp( strHasData.c_str(), "1" ) == 0 )
{ {
// Flush current mesh information into MED file // Flush current mesh information into MED file
myWriter.Perform(); myWriter.Perform();
// maybe a shape was deleted in the study // maybe a shape was deleted in the study
if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) { if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) {
@ -1969,10 +1969,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
} // if ( there are submeshes in SMESHDS_Mesh ) } // if ( there are submeshes in SMESHDS_Mesh )
} // if ( hasData ) } // if ( hasData )
// close mesh HDF group // close mesh HDF group
aTopGroup->CloseOnDisk(); aTopGroup->CloseOnDisk();
} }
} }
} }
} }
} }
@ -1996,7 +1996,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
/*! /*!
* SMESH_Gen_i::SaveASCII * SMESH_Gen_i::SaveASCII
* *
* Save SMESH module's data in ASCII format (not implemented yet) * Save SMESH module's data in ASCII format
*/ */
//============================================================================= //=============================================================================
@ -2005,7 +2005,19 @@ SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII( SALOMEDS::SComponent_ptr theComponent
bool isMultiFile ) { bool isMultiFile ) {
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SaveASCII" ); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SaveASCII" );
SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile ); SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile );
return aStreamFile._retn();
//after usual saving needs to encipher binary to text string
//Any binary symbol will be represent as "|xx" () hexadecimal format number
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]) );
buffer[size * 3] = '\0';
SALOMEDS::TMPFile_var anAsciiStreamFile = new SALOMEDS::TMPFile(size*3, size*3, buffer, 1);
return anAsciiStreamFile._retn();
} }
//============================================================================= //=============================================================================
@ -2851,7 +2863,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
/*! /*!
* SMESH_Gen_i::LoadASCII * SMESH_Gen_i::LoadASCII
* *
* Load SMESH module's data in ASCII format (not implemented yet) * Load SMESH module's data in ASCII format
*/ */
//============================================================================= //=============================================================================
@ -2860,7 +2872,29 @@ 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 );
//before call main ::Load method it's need for decipher text format to
//binary ( "|xx" => x' )
int size = theStream.length();
if ( int((size / 3 )*3) != size ) //error size of buffer
return false;
int real_size = int(size / 3);
_CORBA_Octet* buffer = new _CORBA_Octet[real_size];
char tmp[3];
tmp[2]='\0';
int c = -1;
for ( int i = 0; i < real_size; i++ )
{
memcpy( &(tmp[0]), &(theStream[i*3+1]), 2 );
sscanf( tmp, "%x", &c );
sprintf( (char*)&(buffer[i]), "%c", (char)c );
}
SALOMEDS::TMPFile_var aRealStreamFile = new SALOMEDS::TMPFile(real_size, real_size, buffer, 1);
return Load( theComponent, *(aRealStreamFile._retn()), theURL, isMultiFile );
} }
//============================================================================= //=============================================================================