EgtGeomKernel 1.4a1 : gli oggetti non hanno più un nome ma un Id.
This commit is contained in:
Binary file not shown.
+71
-27
@@ -110,7 +110,9 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
cout << "]" << endl ;
|
||||
|
||||
// esecuzione comando
|
||||
if ( sCmd1 == "P" || sCmd1 == "POINT")
|
||||
if ( sCmd1 == "ALIAS")
|
||||
return ExecuteAlias( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "P" || sCmd1 == "POINT")
|
||||
return ExecutePoint( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "V" || sCmd1 == "VECTOR")
|
||||
return ExecuteVector( sCmd2, vsParams) ;
|
||||
@@ -144,11 +146,31 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteAlias( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "") {
|
||||
int nId ;
|
||||
// 2 parametri : stringa alias e Id
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// recupero Id
|
||||
if ( ! FromString( vsParams[1], nId))
|
||||
return false ;
|
||||
// inserisco le stringhe in coda alla lista
|
||||
return m_AliasMap.insert( pair< string, int>( vsParams[0], nId)).second ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d Pnt ;
|
||||
// 4 parametri : un nome e 3 coordinate
|
||||
@@ -164,7 +186,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGPnt == nullptr)
|
||||
return false ;
|
||||
pGPnt->Set( Pnt) ;
|
||||
return m_pGDB->AddGeoObj( vsParams[0], pGPnt) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), pGPnt) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -174,7 +196,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Vector3d Vect ;
|
||||
// 4 parametri
|
||||
@@ -190,7 +212,7 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGVect == nullptr)
|
||||
return false ;
|
||||
pGVect->Set( Vect) ;
|
||||
return m_pGDB->AddGeoObj( vsParams[0], pGVect) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), pGVect) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -200,7 +222,7 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d ptStart ;
|
||||
Point3d ptEnd ;
|
||||
@@ -215,7 +237,7 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
ReleasePtr<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( ! IsValid( pCrvLine) || ! pCrvLine->Set( ptStart, ptEnd))
|
||||
return false ;
|
||||
return m_pGDB->AddGeoObj( vsParams[0], Release( pCrvLine)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvLine)) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -297,7 +319,7 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco l'arco nel DB
|
||||
return m_pGDB->AddGeoObj( vsParams[0], Release( pCrvArc)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -357,7 +379,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco la curva di Bezier nel DB
|
||||
return m_pGDB->AddGeoObj( vsParams[0], Release( pCrvBez)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvBez)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -385,7 +407,7 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// esecuzione
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
// recupero la curva
|
||||
pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ;
|
||||
pCrv = GetCurve( m_pGDB->GetGeoObj( GetIdParam( *Iter))) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// aggiungo questa curva
|
||||
@@ -393,11 +415,11 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
// inserisco la curva composita nel DB
|
||||
if ( m_pGDB->AddGeoObj( vsParams[0], Release( pCrvCompo))) {
|
||||
if ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvCompo))) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Erase( (*Iter)))
|
||||
if ( ! m_pGDB->Erase( GetIdParam(*Iter)))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -410,6 +432,26 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GdbExecutor::GetIdParam( const std::string& sParam)
|
||||
{
|
||||
int nVal ;
|
||||
AliasMap::iterator Iter ;
|
||||
|
||||
|
||||
// sostituisco eventuali Alias
|
||||
Iter = m_AliasMap.find( sParam) ;
|
||||
if ( Iter != m_AliasMap.end())
|
||||
return Iter->second ;
|
||||
// converto in identificatore numerico
|
||||
else if ( FromString( sParam, nVal))
|
||||
return nVal ;
|
||||
// altrimenti errore
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetNamesParam( const std::string& sParam, STRVECTOR& vsNames)
|
||||
@@ -447,7 +489,7 @@ GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV)
|
||||
// altrimenti nome di vettore già nel DB
|
||||
else {
|
||||
const IGeoVector3d* pV ;
|
||||
if ( ( pV = GetGeoVector3d( m_pGDB->GetGeoObj( sParam))) == nullptr)
|
||||
if ( ( pV = GetGeoVector3d( m_pGDB->GetGeoObj( GetIdParam( sParam)))) == nullptr)
|
||||
return false ;
|
||||
vtV = pV->GetVector() ;
|
||||
return true ;
|
||||
@@ -476,7 +518,7 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
|
||||
// altrimenti nome di punto già nel DB
|
||||
else {
|
||||
const IGeoPoint3d* pPt ;
|
||||
if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( sParam))) == nullptr)
|
||||
if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( GetIdParam( sParam)))) == nullptr)
|
||||
return false ;
|
||||
ptP = pPt->GetPoint() ;
|
||||
return true ;
|
||||
@@ -511,7 +553,7 @@ GdbExecutor::GetPointWeParam( const std::string& sParam, Point3d& ptP, double& d
|
||||
else if ( vsParams.size() == 2) {
|
||||
const IGeoPoint3d* pPt ;
|
||||
// recupero il punto
|
||||
if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( vsParams[0]))) == nullptr)
|
||||
if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( GetIdParam( vsParams[0])))) == nullptr)
|
||||
return false ;
|
||||
ptP = pPt->GetPoint() ;
|
||||
// recupero il peso
|
||||
@@ -530,7 +572,7 @@ GdbExecutor::ExecuteCopy( const STRVECTOR& vsParams)
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// esecuzione copia
|
||||
return m_pGDB->Copy( vsParams[0], vsParams[1]) ;
|
||||
return m_pGDB->Copy( GetIdParam( vsParams[0]), GetIdParam( vsParams[1])) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -549,7 +591,7 @@ GdbExecutor::ExecuteErase( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// esecuzione cancellazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Erase( (*Iter)))
|
||||
if ( ! m_pGDB->Erase( GetIdParam( *Iter)))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -576,7 +618,7 @@ GdbExecutor::ExecuteTranslate( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// esecuzione traslazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Translate( (*Iter), vtVN))
|
||||
if ( ! m_pGDB->Translate( GetIdParam( *Iter), vtVN))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -611,7 +653,7 @@ GdbExecutor::ExecuteRotate( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// esecuzione rotazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Rotate( (*Iter), ptPC, vtVN, dAngDeg))
|
||||
if ( ! m_pGDB->Rotate( GetIdParam( *Iter), ptPC, vtVN, dAngDeg))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -646,7 +688,7 @@ GdbExecutor::ExecuteScale( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// esecuzione scalature
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Scale( (*Iter), ptPC, dCoeffX, dCoeffY, dCoeffZ))
|
||||
if ( ! m_pGDB->Scale( GetIdParam( *Iter), ptPC, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -677,7 +719,7 @@ GdbExecutor::ExecuteMirror( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// esecuzione specchiature
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
if ( ! m_pGDB->Mirror( (*Iter), ptPC, vtVN))
|
||||
if ( ! m_pGDB->Mirror( GetIdParam( *Iter), ptPC, vtVN))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -754,6 +796,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// emetto entità
|
||||
else if ( sCmd2 == "PUT") {
|
||||
bool bCrvVsPolyg ;
|
||||
int nId ;
|
||||
STRVECTOR vsNames ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
// almeno un parametro
|
||||
@@ -770,27 +813,28 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// esecuzione
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
switch ( m_pGDB->GetObjType( *Iter)) {
|
||||
nId = GetIdParam( *Iter) ;
|
||||
switch ( m_pGDB->GetObjType( nId)) {
|
||||
case CRV_LINE :
|
||||
if ( ! m_OutScl.PutCurveLine( *GetCurveLine( m_pGDB->GetGeoObj(*Iter))))
|
||||
if ( ! m_OutScl.PutCurveLine( *GetCurveLine( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
if ( ! m_OutScl.PutCurveArc( *GetCurveArc( m_pGDB->GetGeoObj(*Iter))))
|
||||
if ( ! m_OutScl.PutCurveArc( *GetCurveArc( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
break ;
|
||||
case CRV_BEZ :
|
||||
if ( bCrvVsPolyg) {
|
||||
if ( ! m_OutScl.PutCurveBez( *GetCurveBezier( m_pGDB->GetGeoObj(*Iter))))
|
||||
if ( ! m_OutScl.PutCurveBez( *GetCurveBezier( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! m_OutScl.PutPolygBez( *GetCurveBezier( m_pGDB->GetGeoObj(*Iter))))
|
||||
if ( ! m_OutScl.PutPolygBez( *GetCurveBezier( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
}
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
if ( ! m_OutScl.PutCurveCompo( *GetCurveComposite( m_pGDB->GetGeoObj(*Iter))))
|
||||
if ( ! m_OutScl.PutCurveCompo( *GetCurveComposite( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
break ;
|
||||
default :
|
||||
|
||||
+6
-2
@@ -31,10 +31,12 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool Save( const std::wstring& sFile) ;
|
||||
|
||||
private :
|
||||
int GetIdParam( const std::string& sParam) ;
|
||||
bool GetNamesParam( const std::string& sParam, STRVECTOR& vsNames) ;
|
||||
bool GetVectorParam( const std::string& sParam, Vector3d& vtV) ;
|
||||
bool GetPointParam( const std::string& sParam, Point3d& ptP) ;
|
||||
bool GetPointWeParam( const std::string& sParam, Point3d& ptP, double& dW) ;
|
||||
bool ExecuteAlias( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecutePoint( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteVector( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteCurveLine( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
@@ -52,6 +54,8 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool ExecuteOutScl( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
|
||||
private :
|
||||
IGeomDB* m_pGDB ;
|
||||
OutScl m_OutScl ;
|
||||
IGeomDB* m_pGDB ;
|
||||
OutScl m_OutScl ;
|
||||
typedef std::unordered_map<std::string, int> AliasMap ;
|
||||
AliasMap m_AliasMap ;
|
||||
} ;
|
||||
|
||||
+5
-4
@@ -71,7 +71,7 @@ GdbObj::Save( std::ostream& osOut) const
|
||||
// tipo entità
|
||||
osOut << m_pGeoObj->GetKey() << endl ;
|
||||
// nome
|
||||
osOut << m_sName << endl ;
|
||||
osOut << m_nId << endl ;
|
||||
// parametri geometrici
|
||||
return m_pGeoObj->Save( osOut) ;
|
||||
|
||||
@@ -107,11 +107,12 @@ GdbObj::Load( CScan& TheScanner, string& sErrLine)
|
||||
return false ;
|
||||
// la divido in parametri
|
||||
Tokenize( sLine, ",", vsParams) ;
|
||||
// 1 parametro : nome
|
||||
// 1 parametro : Id
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// assegno il nome
|
||||
m_sName = vsParams[0] ;
|
||||
// assegno l'identificativo
|
||||
if ( ! FromString( vsParams[0], m_nId))
|
||||
return false ;
|
||||
|
||||
// parametri geometrici
|
||||
return m_pGeoObj->Load( TheScanner) ;
|
||||
|
||||
@@ -49,6 +49,6 @@ class GdbObj
|
||||
return m_pGeoObj->Mirror( ptOn, vtNorm) ; }
|
||||
|
||||
public :
|
||||
std::string m_sName ;
|
||||
IGeoObj* m_pGeoObj ;
|
||||
int m_nId ;
|
||||
IGeoObj* m_pGeoObj ;
|
||||
} ;
|
||||
|
||||
+47
-38
@@ -15,6 +15,8 @@
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtReleasePointer.h"
|
||||
#include "GdbObj.h"
|
||||
#include "GeomDB.h"
|
||||
|
||||
@@ -44,8 +46,8 @@ GeomDB::~GeomDB( void)
|
||||
bool
|
||||
GeomDB::Init( void)
|
||||
{
|
||||
// imposto numero minimo buckets di m_GdbNameMap
|
||||
m_GdbNameMap.rehash( 128) ;
|
||||
// imposto numero minimo buckets di m_GdbIdMap
|
||||
m_GdbIdMap.rehash( 1024) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -62,7 +64,7 @@ GeomDB::Clear( void)
|
||||
delete (*Iter) ;
|
||||
|
||||
m_GeomDB.clear() ;
|
||||
m_GdbNameMap.clear() ;
|
||||
m_GdbIdMap.clear() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -193,24 +195,24 @@ GeomDB::Save( std::ofstream& osOut)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::ExistsObj( const std::string& sName)
|
||||
GeomDB::ExistsObj( int nId)
|
||||
{
|
||||
STRPGDBO_UMAP::const_iterator Iter ;
|
||||
INTPGDBO_UMAP::const_iterator Iter ;
|
||||
|
||||
|
||||
Iter = m_GdbNameMap.find( sName) ;
|
||||
return ( Iter != m_GdbNameMap.end()) ;
|
||||
Iter = m_GdbIdMap.find( nId) ;
|
||||
return ( Iter != m_GdbIdMap.end()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GdbObj*
|
||||
GeomDB::GetGdbObj( const std::string& sName)
|
||||
GeomDB::GetGdbObj( int nId)
|
||||
{
|
||||
STRPGDBO_UMAP::const_iterator Iter ;
|
||||
INTPGDBO_UMAP::const_iterator Iter ;
|
||||
|
||||
|
||||
Iter = m_GdbNameMap.find( sName) ;
|
||||
if ( Iter != m_GdbNameMap.end())
|
||||
Iter = m_GdbIdMap.find( nId) ;
|
||||
if ( Iter != m_GdbIdMap.end())
|
||||
return Iter->second ;
|
||||
else
|
||||
return nullptr ;
|
||||
@@ -225,57 +227,60 @@ GeomDB::AddToGeomDB( GdbObj* pGdbObj)
|
||||
return false ;
|
||||
|
||||
// verifica validità e unicità del nome
|
||||
if ( pGdbObj->m_sName.length() == 0 || ExistsObj( pGdbObj->m_sName))
|
||||
if ( pGdbObj->m_nId <= 0 || ExistsObj( pGdbObj->m_nId))
|
||||
return false ;
|
||||
|
||||
// inserisco in lista principale
|
||||
m_GeomDB.push_back( pGdbObj) ;
|
||||
|
||||
// inserisco in mappa nomi
|
||||
m_GdbNameMap[ pGdbObj->m_sName] = pGdbObj ;
|
||||
m_GdbIdMap[ pGdbObj->m_nId] = pGdbObj ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::AddGeoObj( const std::string& sName, IGeoObj* pGeoObj)
|
||||
GeomDB::AddGeoObj( int nId, IGeoObj* pGeoObj)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// assegno GeoObj a gestore puntatore con rilascio automatico
|
||||
ReleasePtr<IGeoObj> pRPGeoObj( pGeoObj) ;
|
||||
// verifico validità nome
|
||||
if ( sName.length() == 0)
|
||||
if ( nId <= 0)
|
||||
return false ;
|
||||
// verifico validità oggetto Geo
|
||||
if ( pGeoObj == nullptr || ! pGeoObj->IsValid())
|
||||
if ( ! IsValid( pRPGeoObj) || ! pRPGeoObj->IsValid())
|
||||
return false ;
|
||||
// alloco oggetto Gdb
|
||||
pGdbObj = new(nothrow) GdbObj ;
|
||||
if ( pGdbObj == nullptr)
|
||||
return false ;
|
||||
// assegno nome
|
||||
pGdbObj->m_sName = sName ;
|
||||
// assegno dati
|
||||
pGdbObj->m_pGeoObj = pGeoObj ;
|
||||
pGdbObj->m_nId = nId ;
|
||||
// assegno dati ( ma non ne trasferisco il possesso)
|
||||
pGdbObj->m_pGeoObj = Get( pRPGeoObj) ;
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGdbObj)) {
|
||||
delete pGdbObj ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// rilascio il possesso di GeoObj
|
||||
Release( pRPGeoObj) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoObjType
|
||||
GeomDB::GetObjType( const std::string& sName)
|
||||
GeomDB::GetObjType( int nId)
|
||||
{
|
||||
const GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return GEO_NONE ;
|
||||
// ne identifico il tipo
|
||||
return pGdbObj->GetType() ;
|
||||
@@ -283,13 +288,13 @@ GeomDB::GetObjType( const std::string& sName)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeoObj*
|
||||
GeomDB::GetGeoObj( const string& sName)
|
||||
GeomDB::GetGeoObj( int nId)
|
||||
{
|
||||
const GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto Gdb
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// restituisco il suo contenuto geometrico
|
||||
@@ -298,14 +303,18 @@ GeomDB::GetGeoObj( const string& sName)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Copy( const string& sNameSou, const string& sNameDest)
|
||||
GeomDB::Copy( int nIdSou, int nIdDest)
|
||||
{
|
||||
GdbObj* pGdoSou ;
|
||||
GdbObj* pGdoDest ;
|
||||
|
||||
|
||||
// verifico validità Id destinazione
|
||||
if ( nIdDest <= 0)
|
||||
return false ;
|
||||
|
||||
// verifico esistenza del sorgente
|
||||
if ( ( pGdoSou = GetGdbObj( sNameSou)) == nullptr)
|
||||
if ( ( pGdoSou = GetGdbObj( nIdSou)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo la copia
|
||||
@@ -313,7 +322,7 @@ GeomDB::Copy( const string& sNameSou, const string& sNameDest)
|
||||
return false ;
|
||||
|
||||
// assegno il nuovo nome
|
||||
pGdoDest->m_sName = sNameDest ;
|
||||
pGdoDest->m_nId = nIdDest ;
|
||||
|
||||
// inserisco nel DB
|
||||
if ( ! AddToGeomDB( pGdoDest)) {
|
||||
@@ -326,18 +335,18 @@ GeomDB::Copy( const string& sNameSou, const string& sNameDest)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Erase( const string& sName)
|
||||
GeomDB::Erase( int nId)
|
||||
{
|
||||
PGDBO_LIST::iterator Iter ;
|
||||
|
||||
|
||||
// elimino da mappa dei nomi
|
||||
m_GdbNameMap.erase( sName) ;
|
||||
m_GdbIdMap.erase( nId) ;
|
||||
|
||||
// elimino da lista principale
|
||||
for ( Iter = m_GeomDB.begin() ; Iter != m_GeomDB.end() ; Iter++) {
|
||||
// se oggetto cercato
|
||||
if ( (*Iter)->m_sName == sName) {
|
||||
if ( (*Iter)->m_nId == nId) {
|
||||
// lo disalloco (distruttore virtuale)
|
||||
delete( (*Iter)) ;
|
||||
// lo tolgo dalla lista
|
||||
@@ -352,13 +361,13 @@ GeomDB::Erase( const string& sName)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Translate( const string& sName, const Vector3d& vtMove)
|
||||
GeomDB::Translate( int nId, const Vector3d& vtMove)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
@@ -367,13 +376,13 @@ GeomDB::Translate( const string& sName, const Vector3d& vtMove)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Rotate( const string& sName, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
GeomDB::Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
@@ -382,13 +391,13 @@ GeomDB::Rotate( const string& sName, const Point3d& ptAx, const Vector3d& vtAx,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Scale( const string& sName, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
GeomDB::Scale( int nId, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
@@ -397,13 +406,13 @@ GeomDB::Scale( const string& sName, const Point3d& ptCen, double dCoeffX, double
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Mirror( const string& sName, const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
GeomDB::Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// recupero l'oggetto
|
||||
if ( ( pGdbObj = GetGdbObj( sName)) == nullptr)
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo l'operazione
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
typedef std::list< GdbObj*> PGDBO_LIST ;
|
||||
typedef std::unordered_map< std::string, GdbObj*> STRPGDBO_UMAP ;
|
||||
typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class CScan ;
|
||||
@@ -34,30 +34,30 @@ class GeomDB : public IGeomDB
|
||||
virtual bool Clear( void) ;
|
||||
virtual bool Load( std::ifstream& osIn) ;
|
||||
virtual bool Save( std::ofstream& osOut) ;
|
||||
virtual bool ExistsObj( const std::string& sName) ;
|
||||
virtual bool AddGeoObj( const std::string& sName, IGeoObj* pGeoObj) ;
|
||||
virtual GeoObjType GetObjType( const std::string& sName) ;
|
||||
virtual IGeoObj* GetGeoObj( const std::string& sName) ;
|
||||
virtual bool Copy( const std::string& sNameSou, const std::string& sNameDest) ;
|
||||
virtual bool Erase( const std::string& sName) ;
|
||||
virtual bool Translate( const std::string& sName, const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const std::string& sName, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const std::string& sName, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
virtual bool ExistsObj( int nId) ;
|
||||
virtual bool AddGeoObj( int nId, IGeoObj* pGeoObj) ;
|
||||
virtual GeoObjType GetObjType( int nId) ;
|
||||
virtual IGeoObj* GetGeoObj( int nId) ;
|
||||
virtual bool Copy( int nIdSou, int nIdDest) ;
|
||||
virtual bool Erase( int nId) ;
|
||||
virtual bool Translate( int nId, const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( sName, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const std::string& sName, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const std::string& sName, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
return Rotate( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( int nId, const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
|
||||
public :
|
||||
GeomDB( void) ;
|
||||
|
||||
private :
|
||||
GdbObj* GetGdbObj( const std::string& sName) ;
|
||||
GdbObj* GetGdbObj( int nId) ;
|
||||
bool AddToGeomDB( GdbObj* pGObj) ;
|
||||
bool LoadStart( CScan& TheScanner) ;
|
||||
bool LoadOneObject( CScan& TheScanner, bool& bEnd) ;
|
||||
|
||||
private :
|
||||
PGDBO_LIST m_GeomDB ; // lista principale, proprietaria degli oggetti
|
||||
STRPGDBO_UMAP m_GdbNameMap ; // map basato sui nomi
|
||||
PGDBO_LIST m_GeomDB ; // lista principale, proprietaria degli oggetti
|
||||
INTPGDBO_UMAP m_GdbIdMap ; // map basato sugli identificatori
|
||||
} ;
|
||||
|
||||
Reference in New Issue
Block a user