EgtGeomKernel 1.5d5 :

- aggiunta scrittura binaria
- tolte GetKey, Load e Save da interfaccia IGeoObj.
This commit is contained in:
Dario Sassi
2014-04-14 15:57:58 +00:00
parent 39db15e41e
commit f956fd20cc
37 changed files with 829 additions and 198 deletions
+33 -18
View File
@@ -17,7 +17,9 @@
#include "GdbGeo.h"
#include "DllMain.h"
#include "Attribs.h"
#include "NgeWriter.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <new>
@@ -182,7 +184,7 @@ GeomDB::LoadOneObj( Scanner& TheScanner, bool& bEnd)
return true ;
}
// se gruppo
else if ( sType == GdbGroup::GetKey()) {
else if ( sType == "A_GRP") {
pGdbObj = new( nothrow) GdbGroup ;
}
// se copia TODO ("X_CPY")..
@@ -210,16 +212,15 @@ GeomDB::LoadOneObj( Scanner& TheScanner, bool& bEnd)
//----------------------------------------------------------------------------
bool
GeomDB::Save( const std::string& sFileOut) const
GeomDB::Save( const std::string& sFileOut, bool bBinary) const
{
// apertura file
ofstream ofSave ;
ofSave.open( stringtoW( sFileOut)) ;
if ( ! ofSave.good())
NgeWriter ngeOut ;
if ( ! ngeOut.Init( sFileOut, bBinary))
return false ;
// intestazione
bool bOk = SaveHeader( ofSave) ;
bool bOk = SaveHeader( ngeOut) ;
// ciclo di scrittura degli oggetti
const GdbObj* pGdbObj = m_GrpRadix.GetFirstObj() ;
@@ -230,36 +231,50 @@ GeomDB::Save( const std::string& sFileOut) const
// se non temporaneo
if ( nLevel != GDB_LV_TEMP) {
// salvo l'oggetto
if ( ! pGdbObj->Save( ofSave))
if ( ! pGdbObj->Save( ngeOut))
bOk = false ;
}
// passo al successivo
pGdbObj = pGdbObj->GetNext() ;
}
ofSave << "END" << endl ;
// terminazione
if ( ! SaveFooter( ngeOut))
bOk = false ;
// chiusura file
ofSave.close() ;
if ( ! ngeOut.Close())
bOk = false ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SaveHeader( ostream& osOut) const
GeomDB::SaveHeader( NgeWriter& ngeOut) const
{
// intestazione
osOut << "START" << endl ;
osOut << "GeomDB,1.5.3.9;" << endl ;
ngeOut.WriteKey( NGE_START, true) ;
ngeOut.WriteString( NGE_GEOMDB, ",") ;
ngeOut.WriteInt( NGE_MAJOR_VER, ".") ;
ngeOut.WriteInt( NGE_MINOR_VER, ".") ;
ngeOut.WriteInt( NGE_PATCH_VER, ";", true) ;
// materiale di default come colore
osOut << "MAT_DEF" << endl ;
Color colDef( 0, 0, 0, 0) ;
GetDefaultMaterial( colDef) ;
osOut << ToString( colDef.GetIntRed()) << "," ;
osOut << ToString( colDef.GetIntGreen()) << "," ;
osOut << ToString( colDef.GetIntBlue()) << "," ;
osOut << ToString( colDef.GetIntAlpha()) << ";" << endl ;
GetDefaultMaterial( colDef) ;
ngeOut.WriteKey( NGE_MAT_DEF, true) ;
ngeOut.WriteCol( colDef, ";", true) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SaveFooter( NgeWriter& ngeOut) const
{
// terminazione
ngeOut.WriteKey( NGE_END, true) ;
return true ;
}