EgtGeomKernel 1.6a2 :
- aggiunte GetNfeFontDir e GetDefaultFont - modifiche a Set di ExtText - migliorata gestione materiali - GeomDB::Load ora può funzionare aggiungendo a DB già carico per Insert.
This commit is contained in:
+37
-17
@@ -19,10 +19,10 @@
|
||||
#include "Attribs.h"
|
||||
#include "NgeReader.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 "/EgtDev/Include/EgtNumCollection.h"
|
||||
#include "/EgtDev/Include/SELkMachineId.h"
|
||||
#include "/EgtDev/Include/SELkKeyProc.h"
|
||||
#include <new>
|
||||
@@ -95,8 +95,11 @@ GeomDB::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Load( const std::string& sFileIn)
|
||||
GeomDB::Load( const string& sFileIn, int nGroupId)
|
||||
{
|
||||
// recupero massimo Id (diventa Id base per entità da caricare)
|
||||
int nBaseGdbId = m_IdManager.GetMaxId() ;
|
||||
|
||||
// apertura file
|
||||
NgeReader ngeIn ;
|
||||
if ( ! ngeIn.Init( sFileIn)) {
|
||||
@@ -105,14 +108,16 @@ GeomDB::Load( const std::string& sFileIn)
|
||||
}
|
||||
|
||||
// leggo l'intestazione
|
||||
if ( ! LoadHeader( ngeIn)) {
|
||||
if ( ! LoadHeader( ngeIn, ( nBaseGdbId == 0))) {
|
||||
string sOut = "GeomDbLoad : Error on pos " + ToString( ngeIn.GetCurrPos()) ;
|
||||
LOG_ERROR( GetEGkLogger(), sOut.c_str())
|
||||
return false ;
|
||||
}
|
||||
|
||||
// leggo i materiali custom
|
||||
if ( ! m_MatManager.Load( ngeIn)) {
|
||||
INTVECTOR vBaseMatId ;
|
||||
vBaseMatId.reserve( 48) ;
|
||||
if ( ! m_MatManager.Load( ngeIn, vBaseMatId)) {
|
||||
string sOut = "GeomDbLoad : Error on pos " + ToString( ngeIn.GetCurrPos()) ;
|
||||
LOG_ERROR( GetEGkLogger(), sOut.c_str())
|
||||
return false ;
|
||||
@@ -122,7 +127,7 @@ GeomDB::Load( const std::string& sFileIn)
|
||||
bool bEnd ;
|
||||
bool bOk = true ;
|
||||
do {
|
||||
if ( ! LoadOneObj( ngeIn, bEnd)) {
|
||||
if ( ! LoadOneObj( ngeIn, nGroupId, nBaseGdbId, vBaseMatId, bEnd)) {
|
||||
bOk = false ;
|
||||
string sOut = "GeomDbLoad : Error on pos " + ToString( ngeIn.GetCurrPos()) ;
|
||||
LOG_ERROR( GetEGkLogger(), sOut.c_str())
|
||||
@@ -134,7 +139,7 @@ GeomDB::Load( const std::string& sFileIn)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::LoadHeader( NgeReader& ngeIn)
|
||||
GeomDB::LoadHeader( NgeReader& ngeIn, bool bSave)
|
||||
{
|
||||
// intestazione
|
||||
int nKey ;
|
||||
@@ -156,12 +161,15 @@ GeomDB::LoadHeader( NgeReader& ngeIn)
|
||||
Color colDef( 0, 0, 0, 0) ;
|
||||
if ( ! ngeIn.ReadCol( colDef, ";", true))
|
||||
return false ;
|
||||
return SetDefaultMaterial( colDef) ;
|
||||
if ( bSave)
|
||||
return SetDefaultMaterial(colDef) ;
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::LoadOneObj( NgeReader& ngeIn, bool& bEnd)
|
||||
GeomDB::LoadOneObj( NgeReader& ngeIn, int nGroupId, int nBaseGdbId, const INTVECTOR& vBaseMatId, bool& bEnd)
|
||||
{
|
||||
// in generale non è fine file
|
||||
bEnd = false ;
|
||||
@@ -193,21 +201,33 @@ GeomDB::LoadOneObj( NgeReader& ngeIn, bool& bEnd)
|
||||
if ( pGdbObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// se lettura dati e inserimento nel DB vanno bene
|
||||
// se lettura dati va bene
|
||||
int nParentId ;
|
||||
if ( pGdbObj->Load( nKey, ngeIn, nParentId) &&
|
||||
InsertInGeomDB( pGdbObj, nParentId, GDB_SON))
|
||||
return true ;
|
||||
// altrimenti errore
|
||||
else {
|
||||
delete pGdbObj ;
|
||||
return false ;
|
||||
if ( pGdbObj->Load( nKey, ngeIn, nParentId)) {
|
||||
// aggiusto Id
|
||||
pGdbObj->m_nId += nBaseGdbId ;
|
||||
// aggiusto Id del gruppo di appartenenza
|
||||
if ( nParentId == GDB_ID_ROOT)
|
||||
nParentId += nGroupId ;
|
||||
else
|
||||
nParentId += nBaseGdbId ;
|
||||
// aggiusto eventuale indice del materiale
|
||||
int nMat ;
|
||||
if ( pGdbObj->GetMaterial( nMat) &&
|
||||
nMat > 0 && nMat < int( vBaseMatId.size()))
|
||||
pGdbObj->SetMaterial( vBaseMatId[nMat]) ;
|
||||
// se inserimento nel DB va bene, ritorno con successo
|
||||
if ( InsertInGeomDB( pGdbObj, nParentId, GDB_SON))
|
||||
return true ;
|
||||
}
|
||||
// altrimenti errore
|
||||
delete pGdbObj ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Save( const std::string& sFileOut, int nFlag) const
|
||||
GeomDB::Save( const string& sFileOut, int nFlag) const
|
||||
{
|
||||
// apertura file
|
||||
NgeWriter ngeOut ;
|
||||
|
||||
Reference in New Issue
Block a user