EgtGeomKernel 1.5d7 :

- aggiunti materiali e loro gestione
- aggiunta gestione libreria materiali.
This commit is contained in:
Dario Sassi
2014-04-27 20:09:56 +00:00
parent 7e680c311f
commit 5fe590f627
21 changed files with 1020 additions and 181 deletions
+125 -23
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : GdbExecutor.cpp Data : 19.01.14 Versione : 1.5a6
// File : GdbExecutor.cpp Data : 24.04.14 Versione : 1.5a6
// Contenuto : Implementazione della classe GdbExecutor.
//
//
@@ -87,6 +87,8 @@ GdbExecutor::GdbExecutor( void)
m_ExecMgr.Insert( "NAME", &GdbExecutor::ExecuteName) ;
m_ExecMgr.Insert( "INF", &GdbExecutor::ExecuteInfo) ;
m_ExecMgr.Insert( "INFO", &GdbExecutor::ExecuteInfo) ;
m_ExecMgr.Insert( "MATLIBRARY", &GdbExecutor::ExecuteMatLibrary) ;
m_ExecMgr.Insert( "MATLIB", &GdbExecutor::ExecuteMatLibrary) ;
m_ExecMgr.Insert( "COPY", &GdbExecutor::ExecuteCopy) ;
m_ExecMgr.Insert( "REL", &GdbExecutor::ExecuteRelocate) ;
m_ExecMgr.Insert( "RELOCATE", &GdbExecutor::ExecuteRelocate) ;
@@ -898,14 +900,14 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
//----------------------------------------------------------------------------
int
GdbExecutor::GetIdParam( const std::string& sParam, bool bNewAllowed)
GdbExecutor::GetIdParam( const string& sParam, bool bNewAllowed)
{
return m_pParser->GetIdParam( sParam, bNewAllowed) ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::GetNamesParam( const std::string& sParam, INTVECTOR& vnNames)
GdbExecutor::GetNamesParam( const string& sParam, INTVECTOR& vnNames)
{
// divido in parti
STRVECTOR vsNames ;
@@ -934,7 +936,7 @@ GdbExecutor::GetNamesParam( const std::string& sParam, INTVECTOR& vnNames)
//----------------------------------------------------------------------------
bool
GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV)
GdbExecutor::GetVectorParam( const string& sParam, Vector3d& vtV)
{
// se insieme di tre componenti
if ( sParam[0] == '(') {
@@ -993,7 +995,7 @@ GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV)
//----------------------------------------------------------------------------
bool
GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
GdbExecutor::GetPointParam( const string& sParam, Point3d& ptP)
{
// se insieme di tre coordinate
if ( sParam[0] == '(') {
@@ -1027,7 +1029,7 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
//----------------------------------------------------------------------------
bool
GdbExecutor::GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW)
GdbExecutor::GetPointWParam( const string& sParam, Point3d& ptP, double& dW)
{
// deve essere insieme di dati
if ( sParam[0] != '(')
@@ -1069,7 +1071,7 @@ GdbExecutor::GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW
//----------------------------------------------------------------------------
bool
GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF)
GdbExecutor::GetFrameParam( const string& sParam, Frame3d& frF)
{
// se insieme di punto origine e tre versori
if ( sParam[0] == '(') {
@@ -1112,7 +1114,7 @@ GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF)
//----------------------------------------------------------------------------
bool
GdbExecutor::GetColorParam( const std::string& sParam, bool& bByParent, Color& cCol)
GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol)
{
// se insieme di tre o quattro valori
if ( sParam[0] == '(') {
@@ -1352,8 +1354,8 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams)
bool
GdbExecutor::ExecuteMaterial( const string& sCmd2, const STRVECTOR& vsParams)
{
// assegnazione colore di oggetto
if ( sCmd2.empty()) {
// assegnazione materiale di oggetto tramite colore
if ( sCmd2.empty() || sCmd2 == "COLOR") {
// devono essere 2 parametri ( Id, Colore)
if ( vsParams.size() != 2)
return false ;
@@ -1380,6 +1382,32 @@ GdbExecutor::ExecuteMaterial( const string& sCmd2, const STRVECTOR& vsParams)
}
return true ;
}
// assegnazione materiale di oggetto
else if ( sCmd2 == "MAT" || sCmd2 == "MATERIAL") {
// devono essere 2 parametri ( Id, Materiale)
if ( vsParams.size() != 2)
return false ;
// recupero lista Id
INTVECTOR vnNames ;
if ( ! GetNamesParam( vsParams[0], vnNames))
return false ;
// verifico se da padre
string sMat = vsParams[1] ;
bool bByParent = ( sMat == "BYPARENT") ;
// esecuzione impostazione colore
INTVECTOR::iterator Iter ;
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
if ( bByParent) {
if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT))
return false ;
}
else {
if ( ! m_pGDB->SetMaterial( *Iter, vsParams[1]))
return false ;
}
}
return true ;
}
// impostazione colore di default
else if ( sCmd2 == "DEF" || sCmd2 == "DEFAULT") {
// 1 parametro ( Colore)
@@ -1483,7 +1511,81 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteMatLibrary( const string& sCmd2, const STRVECTOR& vsParams)
{
if ( sCmd2 == "ADD") {
// 5 parametri ( Nome, colAmb, colDiff, colSpec, Shininess)
if ( vsParams.size() != 5)
return false ;
// colore ambiente
bool bByParent ;
Color colAmb ;
if ( ! GetColorParam( vsParams[1], bByParent, colAmb) || bByParent)
return false ;
// colore diffuso
Color colDiff ;
if ( ! GetColorParam( vsParams[2], bByParent, colDiff) || bByParent)
return false ;
// colore speculare
Color colSpec ;
if ( ! GetColorParam( vsParams[3], bByParent, colSpec) || bByParent)
return false ;
// lucentezza
double dShin ;
if ( ! FromString( vsParams[4], dShin))
return false ;
// creo il materiale
Material matM( colAmb, colDiff, colSpec, dShin) ;
// inserisco il materiale in libreria
return ( m_pGDB->AddMaterial( vsParams[0], matM) != GDB_MT_NULL) ;
}
else if ( sCmd2 == "REMOVE") {
// 1 parametro ( Nome)
if ( vsParams.size() != 1)
return false ;
// elimino il materiale
int nMat ;
if ( ( nMat = m_pGDB->FindMaterial( vsParams[0])) == GDB_MT_NULL)
return false ;
bool bInUse ;
return m_pGDB->EraseMaterial( nMat, bInUse) ;
}
else if ( sCmd2 == "MODIFY") {
// 5 parametri ( Nome, colAmb, colDiff, colSpec, Shininess)
if ( vsParams.size() != 5)
return false ;
// colore ambiente
bool bByParent ;
Color colAmb ;
if ( ! GetColorParam( vsParams[1], bByParent, colAmb) || bByParent)
return false ;
// colore diffuso
Color colDiff ;
if ( ! GetColorParam( vsParams[2], bByParent, colDiff) || bByParent)
return false ;
// colore speculare
Color colSpec ;
if ( ! GetColorParam( vsParams[3], bByParent, colSpec) || bByParent)
return false ;
// lucentezza
double dShin ;
if ( ! FromString( vsParams[4], dShin))
return false ;
// creo il materiale
Material matM( colAmb, colDiff, colSpec, dShin) ;
// modifico i dati del materiale in libreria
int nMat ;
if ( ( nMat = m_pGDB->FindMaterial( vsParams[0])) == GDB_MT_NULL)
return false ;
return m_pGDB->ModifyMaterialData( nMat, matM) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
{
// 3 parametri ( IdSou, IdDest, ParentIdDest)
if ( vsParams.size() != 3)
@@ -1506,7 +1608,7 @@ GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteRelocate( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 parametri ( Id, NewParentId)
if ( vsParams.size() != 2)
@@ -1534,7 +1636,7 @@ GdbExecutor::ExecuteRelocate( const std::string& sCmd2, const STRVECTOR& vsParam
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteErase( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteErase( const string& sCmd2, const STRVECTOR& vsParams)
{
// 1 parametro ( Nome/i)
if ( vsParams.size() != 1)
@@ -1555,7 +1657,7 @@ GdbExecutor::ExecuteErase( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteTranslate( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteTranslate( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 parametri ( Nome/i, Vettore)
if ( vsParams.size() != 2)
@@ -1599,7 +1701,7 @@ GdbExecutor::ExecuteTranslate( const std::string& sCmd2, const STRVECTOR& vsPara
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteRotate( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteRotate( const string& sCmd2, const STRVECTOR& vsParams)
{
// 4 parametri ( Nome, PtoAsse, VtAsse, AngDeg)
if ( vsParams.size() != 4)
@@ -1651,7 +1753,7 @@ GdbExecutor::ExecuteRotate( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteScale( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteScale( const string& sCmd2, const STRVECTOR& vsParams)
{
// 5 parametri ( Nome, Punto o Frame, CoeffX, CoeffY, CoeffZ)
if ( vsParams.size() != 5)
@@ -1708,7 +1810,7 @@ GdbExecutor::ExecuteScale( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteMirror( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteMirror( const string& sCmd2, const STRVECTOR& vsParams)
{
// 3 parametri ( Nome, Punto, Vettore)
if ( vsParams.size() != 3)
@@ -1756,7 +1858,7 @@ GdbExecutor::ExecuteMirror( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteInvertCurve( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
{
// 1 parametro ( Nome/i)
if ( vsParams.size() != 1)
@@ -1778,7 +1880,7 @@ GdbExecutor::ExecuteInvertCurve( const std::string& sCmd2, const STRVECTOR& vsPa
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteInvertSurf( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteInvertSurf( const string& sCmd2, const STRVECTOR& vsParams)
{
// 1 parametro ( Nome/i)
if ( vsParams.size() != 1)
@@ -1800,7 +1902,7 @@ GdbExecutor::ExecuteInvertSurf( const std::string& sCmd2, const STRVECTOR& vsPar
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteTrimCurve( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteTrimCurve( const string& sCmd2, const STRVECTOR& vsParams)
{
enum SeLp { SL, EL, SP, EP} ;
@@ -1861,7 +1963,7 @@ GdbExecutor::ExecuteTrimCurve( const std::string& sCmd2, const STRVECTOR& vsPara
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteNew( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteNew( const string& sCmd2, const STRVECTOR& vsParams)
{
// nessun parametro
if ( vsParams.size() != 0)
@@ -1874,7 +1976,7 @@ GdbExecutor::ExecuteNew( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteLoad( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteLoad( const string& sCmd2, const STRVECTOR& vsParams)
{
// 1 parametro ( NomeFile)
if ( vsParams.size() != 1)
@@ -1888,7 +1990,7 @@ GdbExecutor::ExecuteLoad( const std::string& sCmd2, const STRVECTOR& vsParams)
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteSave( const std::string& sCmd2, const STRVECTOR& vsParams)
GdbExecutor::ExecuteSave( const string& sCmd2, const STRVECTOR& vsParams)
{
// almeno 1 parametro ( NomeFile)
if ( vsParams.size() < 1)