EgtGeomKernel 1.4a2 : Aggiunti gruppi per avere struttura DB ad albero.
This commit is contained in:
+83
-65
@@ -102,7 +102,7 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
// output di debug
|
||||
cout << "Cmd = [" << sCmd1 << "/" << sCmd2 << "]" ;
|
||||
cout << " Par = [" ;
|
||||
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; theConstIter ++) {
|
||||
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) {
|
||||
if ( theConstIter != vsParams.begin())
|
||||
cout << "/" ;
|
||||
cout << *theConstIter ;
|
||||
@@ -112,6 +112,8 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
// esecuzione comando
|
||||
if ( sCmd1 == "ALIAS")
|
||||
return ExecuteAlias( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "GR" || sCmd1 == "GROUP")
|
||||
return ExecuteGroup( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "P" || sCmd1 == "POINT")
|
||||
return ExecutePoint( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "V" || sCmd1 == "VECTOR")
|
||||
@@ -166,6 +168,22 @@ GdbExecutor::ExecuteAlias( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
// 2 parametri : Id e Id del padre
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// creo il gruppo
|
||||
return m_pGDB->AddGroup( GetIdParam( vsParams[0]), GetIdParam( vsParams[1])) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
@@ -173,20 +191,20 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d Pnt ;
|
||||
// 4 parametri : un nome e 3 coordinate
|
||||
if ( vsParams.size() != 4)
|
||||
// 5 parametri : Id, IdParent e 3 coordinate
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero le tre coordinate
|
||||
if ( ! FromString( vsParams[1], Pnt.x) ||
|
||||
! FromString( vsParams[2], Pnt.y) ||
|
||||
! FromString( vsParams[3], Pnt.z))
|
||||
if ( ! FromString( vsParams[2], Pnt.x) ||
|
||||
! FromString( vsParams[3], Pnt.y) ||
|
||||
! FromString( vsParams[4], Pnt.z))
|
||||
return false ;
|
||||
// creo il punto
|
||||
IGeoPoint3d* pGPnt = CreateGeoPoint3d() ;
|
||||
if ( pGPnt == nullptr)
|
||||
return false ;
|
||||
pGPnt->Set( Pnt) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), pGPnt) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]),pGPnt) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -199,20 +217,20 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Vector3d Vect ;
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
// 5 parametri
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero i tre componenti
|
||||
if ( ! FromString( vsParams[1], Vect.x) ||
|
||||
! FromString( vsParams[2], Vect.y) ||
|
||||
! FromString( vsParams[3], Vect.z))
|
||||
if ( ! FromString( vsParams[2], Vect.x) ||
|
||||
! FromString( vsParams[3], Vect.y) ||
|
||||
! FromString( vsParams[4], Vect.z))
|
||||
return false ;
|
||||
// creo il vettore
|
||||
IGeoVector3d* pGVect = CreateGeoVector3d() ;
|
||||
if ( pGVect == nullptr)
|
||||
return false ;
|
||||
pGVect->Set( Vect) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), pGVect) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGVect) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -226,18 +244,18 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d ptStart ;
|
||||
Point3d ptEnd ;
|
||||
// 3 parametri
|
||||
if ( vsParams.size() != 3)
|
||||
// 4 parametri
|
||||
if ( vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero e setto punti iniziale e finale
|
||||
if ( ! GetPointParam( vsParams[1], ptStart) ||
|
||||
! GetPointParam( vsParams[2], ptEnd))
|
||||
if ( ! GetPointParam( vsParams[2], ptStart) ||
|
||||
! GetPointParam( vsParams[3], ptEnd))
|
||||
return false ;
|
||||
// creo la linea
|
||||
ReleasePtr<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( ! IsValid( pCrvLine) || ! pCrvLine->Set( ptStart, ptEnd))
|
||||
return false ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvLine)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvLine)) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -260,26 +278,26 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
Vector3d vtS ;
|
||||
double dAngCenDeg ;
|
||||
double dDeltaZ ;
|
||||
// 7 parametri
|
||||
if ( vsParams.size() != 7)
|
||||
// 8 parametri
|
||||
if ( vsParams.size() != 8)
|
||||
return false ;
|
||||
// centro
|
||||
if ( ! GetPointParam( vsParams[1], ptCen))
|
||||
if ( ! GetPointParam( vsParams[2], ptCen))
|
||||
return false ;
|
||||
// versore ortogonale al piano della circonferenza
|
||||
if ( ! GetVectorParam( vsParams[2], vtN))
|
||||
if ( ! GetVectorParam( vsParams[3], vtN))
|
||||
return false ;
|
||||
// raggio
|
||||
if ( ! FromString( vsParams[3], dRad))
|
||||
if ( ! FromString( vsParams[4], dRad))
|
||||
return false ;
|
||||
// versore iniziale
|
||||
if ( ! GetVectorParam( vsParams[4], vtS))
|
||||
if ( ! GetVectorParam( vsParams[5], vtS))
|
||||
return false ;
|
||||
// angolo al centro
|
||||
if ( ! FromString( vsParams[5], dAngCenDeg))
|
||||
if ( ! FromString( vsParams[6], dAngCenDeg))
|
||||
return false ;
|
||||
// deltaZ
|
||||
if ( ! FromString( vsParams[6], dDeltaZ))
|
||||
if ( ! FromString( vsParams[7], dDeltaZ))
|
||||
return false ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->Set( ptCen, vtN, dRad, vtS, dAngCenDeg, dDeltaZ))
|
||||
@@ -292,23 +310,23 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
double dAngIniDeg ;
|
||||
double dAngCenDeg ;
|
||||
double dDeltaZ ;
|
||||
// 6 parametri
|
||||
if ( vsParams.size() != 6)
|
||||
// 7 parametri
|
||||
if ( vsParams.size() != 7)
|
||||
return false ;
|
||||
// centro
|
||||
if ( ! GetPointParam( vsParams[1], ptCen))
|
||||
if ( ! GetPointParam( vsParams[2], ptCen))
|
||||
return false ;
|
||||
// raggio
|
||||
if ( ! FromString( vsParams[2], dRad))
|
||||
if ( ! FromString( vsParams[3], dRad))
|
||||
return false ;
|
||||
// angolo iniziale
|
||||
if ( ! FromString( vsParams[3], dAngIniDeg))
|
||||
if ( ! FromString( vsParams[4], dAngIniDeg))
|
||||
return false ;
|
||||
// angolo al centro
|
||||
if ( ! FromString( vsParams[4], dAngCenDeg))
|
||||
if ( ! FromString( vsParams[5], dAngCenDeg))
|
||||
return false ;
|
||||
// deltaZ
|
||||
if ( ! FromString( vsParams[5], dDeltaZ))
|
||||
if ( ! FromString( vsParams[6], dDeltaZ))
|
||||
return false ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->Set( ptCen, dRad, dAngIniDeg, dAngCenDeg, dDeltaZ))
|
||||
@@ -319,7 +337,7 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco l'arco nel DB
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvArc)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -336,18 +354,18 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
int i ;
|
||||
int nDeg ;
|
||||
Point3d ptP ;
|
||||
// almeno 2 parametri
|
||||
if ( vsParams.size() < 2)
|
||||
// almeno 3 parametri
|
||||
if ( vsParams.size() < 3)
|
||||
return false ;
|
||||
// recupero il grado
|
||||
if ( ! FromString( vsParams[1], nDeg))
|
||||
if ( ! FromString( vsParams[2], nDeg))
|
||||
return false ;
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, false))
|
||||
return false ;
|
||||
// recupero e setto punti di controllo
|
||||
for ( i = 0 ; i <= nDeg ; i ++) {
|
||||
if ( ! GetPointParam( vsParams[i+2], ptP) ||
|
||||
for ( i = 0 ; i <= nDeg ; ++ i) {
|
||||
if ( ! GetPointParam( vsParams[i+3], ptP) ||
|
||||
! pCrvBez->SetControlPoint( i, ptP))
|
||||
return false ;
|
||||
}
|
||||
@@ -358,18 +376,18 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
int nDeg ;
|
||||
double dW ;
|
||||
Point3d ptP ;
|
||||
// almeno 2 parametri
|
||||
if ( vsParams.size() < 2)
|
||||
// almeno 3 parametri
|
||||
if ( vsParams.size() < 3)
|
||||
return false ;
|
||||
// recupero il grado
|
||||
if ( ! FromString( vsParams[1], nDeg))
|
||||
if ( ! FromString( vsParams[2], nDeg))
|
||||
return false ;
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDeg, true))
|
||||
return false ;
|
||||
// recupero e setto punti di controllo
|
||||
for ( i = 0 ; i <= nDeg ; i ++) {
|
||||
if ( ! GetPointWeParam( vsParams[i+2], ptP, dW) ||
|
||||
for ( i = 0 ; i <= nDeg ; ++ i) {
|
||||
if ( ! GetPointWeParam( vsParams[i+3], ptP, dW) ||
|
||||
! pCrvBez->SetControlPoint( i, ptP, dW))
|
||||
return false ;
|
||||
}
|
||||
@@ -379,7 +397,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco la curva di Bezier nel DB
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvBez)) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvBez)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -395,17 +413,17 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
ReleasePtr<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( ! IsValid( pCrvCompo))
|
||||
return false ;
|
||||
// 2 o 3 parametri
|
||||
// 3 o 4 parametri
|
||||
switch ( vsParams.size()) {
|
||||
case 2 : bErase = false ; break ;
|
||||
case 3 : bErase = ( vsParams[2] != "0") ; break ;
|
||||
case 3 : bErase = false ; break ;
|
||||
case 4 : bErase = ( vsParams[3] != "0") ; break ;
|
||||
default : return false ; break ;
|
||||
}
|
||||
// recupero lista nomi
|
||||
if ( ! GetNamesParam( vsParams[1], vsNames))
|
||||
if ( ! GetNamesParam( vsParams[2], vsNames))
|
||||
return false ;
|
||||
// esecuzione
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
// recupero la curva
|
||||
pCrv = GetCurve( m_pGDB->GetGeoObj( GetIdParam( *Iter))) ;
|
||||
if ( pCrv == nullptr)
|
||||
@@ -415,10 +433,10 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
// inserisco la curva composita nel DB
|
||||
if ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), Release( pCrvCompo))) {
|
||||
if ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvCompo))) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Erase( GetIdParam(*Iter)))
|
||||
return false ;
|
||||
}
|
||||
@@ -461,7 +479,7 @@ GdbExecutor::GetNamesParam( const std::string& sParam, STRVECTOR& vsNames)
|
||||
|
||||
// divido in parti
|
||||
Tokenize( sParam, ",", vsNames) ;
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++)
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
|
||||
return true ;
|
||||
@@ -477,7 +495,7 @@ GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV)
|
||||
STRVECTOR::iterator Iter ;
|
||||
// divido in parti
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; Iter++)
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
if ( vsParams.size() != 3)
|
||||
@@ -506,7 +524,7 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
|
||||
STRVECTOR::iterator Iter ;
|
||||
// divido in parti
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; Iter++)
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
// verifico siano 3 parti e le converto
|
||||
if ( vsParams.size() != 3)
|
||||
@@ -539,7 +557,7 @@ GdbExecutor::GetPointWeParam( const std::string& sParam, Point3d& ptP, double& d
|
||||
|
||||
// divido in parti
|
||||
Tokenize( sParam, ",", vsParams) ;
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; Iter++)
|
||||
for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter)
|
||||
Trim( (*Iter), " \t\r\n()") ;
|
||||
|
||||
// se 4 parti, sono 3 coordinate e un peso
|
||||
@@ -568,11 +586,11 @@ GdbExecutor::GetPointWeParam( const std::string& sParam, Point3d& ptP, double& d
|
||||
bool
|
||||
GdbExecutor::ExecuteCopy( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 2 parametri ( NomeSou, NomeDest)
|
||||
if ( vsParams.size() != 2)
|
||||
// 3 parametri ( IdSou, IdDest, ParentIdDest)
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// esecuzione copia
|
||||
return m_pGDB->Copy( GetIdParam( vsParams[0]), GetIdParam( vsParams[1])) ;
|
||||
return m_pGDB->Copy( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), GetIdParam( vsParams[2])) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -590,7 +608,7 @@ GdbExecutor::ExecuteErase( const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vsNames))
|
||||
return false ;
|
||||
// esecuzione cancellazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Erase( GetIdParam( *Iter)))
|
||||
return false ;
|
||||
}
|
||||
@@ -617,7 +635,7 @@ GdbExecutor::ExecuteTranslate( const STRVECTOR& vsParams)
|
||||
if ( ! GetVectorParam( vsParams[1], vtVN))
|
||||
return false ;
|
||||
// esecuzione traslazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Translate( GetIdParam( *Iter), vtVN))
|
||||
return false ;
|
||||
}
|
||||
@@ -652,7 +670,7 @@ GdbExecutor::ExecuteRotate( const STRVECTOR& vsParams)
|
||||
if ( ! FromString( vsParams[3], dAngDeg))
|
||||
return false ;
|
||||
// esecuzione rotazioni
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Rotate( GetIdParam( *Iter), ptPC, vtVN, dAngDeg))
|
||||
return false ;
|
||||
}
|
||||
@@ -687,7 +705,7 @@ GdbExecutor::ExecuteScale( const STRVECTOR& vsParams)
|
||||
! FromString( vsParams[4], dCoeffZ))
|
||||
return false ;
|
||||
// esecuzione scalature
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Scale( GetIdParam( *Iter), ptPC, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
}
|
||||
@@ -718,7 +736,7 @@ GdbExecutor::ExecuteMirror( const STRVECTOR& vsParams)
|
||||
if ( ! GetVectorParam( vsParams[2], vtVN))
|
||||
return false ;
|
||||
// esecuzione specchiature
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
if ( ! m_pGDB->Mirror( GetIdParam( *Iter), ptPC, vtVN))
|
||||
return false ;
|
||||
}
|
||||
@@ -811,7 +829,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( ! GetNamesParam( vsParams[0], vsNames))
|
||||
return false ;
|
||||
// esecuzione
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; Iter++) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
nId = GetIdParam( *Iter) ;
|
||||
switch ( m_pGDB->GetObjType( nId)) {
|
||||
|
||||
Reference in New Issue
Block a user