mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
fix SWP12968
Implementation of methods SMESH_Gen_i::LoadASCII and SMESH_Gen_i::SaveASCII.
This commit is contained in:
parent
7a3868cfc4
commit
961309c8a4
@ -1214,7 +1214,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
||||
{
|
||||
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,
|
||||
// use that of the component
|
||||
if ( myCurrentStudy->_is_nil() ||
|
||||
@ -1305,9 +1305,9 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
||||
if ( myImpl ) {
|
||||
string hypname = string( myHyp->GetName() );
|
||||
string libname = string( myHyp->GetLibName() );
|
||||
// BUG SWP13062
|
||||
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
|
||||
// WNT and ".so" for X-system) must be deleted
|
||||
// BUG SWP13062
|
||||
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
|
||||
// WNT and ".so" for X-system) must be deleted
|
||||
int libname_len = libname.length();
|
||||
#ifdef WNT
|
||||
if( libname_len > 4 )
|
||||
@ -1370,9 +1370,9 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
||||
if ( myImpl ) {
|
||||
string hypname = string( myHyp->GetName() );
|
||||
string libname = string( myHyp->GetLibName() );
|
||||
// BUG SWP13062
|
||||
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
|
||||
// WNT and ".so" for X-system) must be deleted
|
||||
// BUG SWP13062
|
||||
// Needs for save crossplatform libname, i.e. parth of name ( ".dll" for
|
||||
// WNT and ".so" for X-system) must be deleted
|
||||
int libname_len = libname.length();
|
||||
#ifdef WNT
|
||||
if( libname_len > 4 )
|
||||
@ -1996,7 +1996,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
|
||||
/*!
|
||||
* 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 ) {
|
||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SaveASCII" );
|
||||
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
|
||||
*
|
||||
* 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,
|
||||
bool isMultiFile ) {
|
||||
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 );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user