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:
+23
-9
@@ -20,6 +20,10 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const string RESERVED_NAME = "$$" ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GdbMaterialMgr::GdbMaterialMgr( void)
|
||||
{
|
||||
@@ -58,7 +62,7 @@ GdbMaterialMgr::Save( NgeWriter& ngeOut) const
|
||||
// scrittura dei materiali custom
|
||||
for ( int i = m_nStdNum ; i < int( m_GdbMats.size()) ; ++ i) {
|
||||
// Nome, Id, Tipo (1=materiale senza texture)
|
||||
string sMatName = ( m_GdbMats[i].sName.empty() ? "$$" : m_GdbMats[i].sName) ;
|
||||
string sMatName = ( m_GdbMats[i].sName.empty() ? RESERVED_NAME : m_GdbMats[i].sName) ;
|
||||
if ( ! ngeOut.WriteString( sMatName, ","))
|
||||
return false ;
|
||||
if ( ! ngeOut.WriteInt( i + 1, ","))
|
||||
@@ -81,7 +85,7 @@ GdbMaterialMgr::Save( NgeWriter& ngeOut) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbMaterialMgr::Load( NgeReader& ngeIn)
|
||||
GdbMaterialMgr::Load( NgeReader& ngeIn, INTVECTOR& vBaseMatId)
|
||||
{
|
||||
// lettura eventuale intestazione libreria
|
||||
int nKey ;
|
||||
@@ -91,6 +95,10 @@ GdbMaterialMgr::Load( NgeReader& ngeIn)
|
||||
ngeIn.UngetKey() ;
|
||||
return true ;
|
||||
}
|
||||
// aggiorno indice rilocazione per materiali standard (1 based)
|
||||
vBaseMatId.resize( m_nStdNum + 1, 0) ;
|
||||
for ( int i = 0 ; i <= m_nStdNum ; ++ i)
|
||||
vBaseMatId[i] = i ;
|
||||
// lettura numero di materiali custom
|
||||
int nCustNum ;
|
||||
if ( ! ngeIn.ReadInt( nCustNum, ";", true))
|
||||
@@ -107,6 +115,9 @@ GdbMaterialMgr::Load( NgeReader& ngeIn)
|
||||
int nType ;
|
||||
if ( ! ngeIn.ReadInt( nType, ";", true))
|
||||
return false ;
|
||||
// verifico correttezza indice
|
||||
if ( nInd != m_nStdNum + i + 1)
|
||||
return false ;
|
||||
// dati del materiale
|
||||
Color colAmb ;
|
||||
if ( ! ngeIn.ReadCol( colAmb, ";"))
|
||||
@@ -120,14 +131,17 @@ GdbMaterialMgr::Load( NgeReader& ngeIn)
|
||||
double dShin ;
|
||||
if ( ! ngeIn.ReadDouble( dShin, ";", true))
|
||||
return false ;
|
||||
// inserisco il materiale
|
||||
int nNew = AddMaterial( sMatName, Material( colAmb, colDiff, colSpec, dShin)) ;
|
||||
if ( nNew == GDB_MT_NULL || nNew != nInd)
|
||||
// inserisco il materiale, verificando non sia già presente (escludo nome riservato)
|
||||
int nNew = (( sMatName != RESERVED_NAME) ? FindMaterial( sMatName) : GDB_MT_NULL) ;
|
||||
if ( nNew == GDB_MT_NULL)
|
||||
nNew = AddMaterial( sMatName, Material( colAmb, colDiff, colSpec, dShin), true) ;
|
||||
if ( nNew == GDB_MT_NULL)
|
||||
return false ;
|
||||
vBaseMatId.push_back( nNew) ;
|
||||
}
|
||||
// sistemazione dei materiali cancellati
|
||||
for ( int i = m_nStdNum ; i < int( m_GdbMats.size()) ; ++ i) {
|
||||
if ( m_GdbMats[i].sName == "$$")
|
||||
if ( m_GdbMats[i].sName == RESERVED_NAME)
|
||||
EraseMaterial( i + 1) ;
|
||||
}
|
||||
|
||||
@@ -136,13 +150,13 @@ GdbMaterialMgr::Load( NgeReader& ngeIn)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GdbMaterialMgr::AddMaterial( const string& sName, const Material& matM)
|
||||
GdbMaterialMgr::AddMaterial( const string& sName, const Material& matM, bool bLoad)
|
||||
{
|
||||
// verifico validità nome
|
||||
if ( ! IsValidName( sName))
|
||||
if ( ! IsValidName( sName) || ( ! bLoad && sName == RESERVED_NAME))
|
||||
return GDB_MT_NULL ;
|
||||
// se il materiale già esiste ritorno errore
|
||||
if ( FindMaterial( sName) > 0)
|
||||
if ( sName != RESERVED_NAME && FindMaterial( sName) > 0)
|
||||
return GDB_MT_NULL ;
|
||||
// provo ad inserire al posto del primo cancellato
|
||||
int nId = FindFirstErased() ;
|
||||
|
||||
Reference in New Issue
Block a user