EgtGeomKernel 1.4a3 : Migliorata gestione gruppi, aggiunti GdbIterator, GeoFrame3d e IdManager.
This commit is contained in:
+150
-50
@@ -19,11 +19,13 @@
|
||||
#include "/EgtDev/Include/EgnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoFrame3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgtReleasePointer.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "GdbExecutor.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -118,6 +120,8 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
return ExecutePoint( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "V" || sCmd1 == "VECTOR")
|
||||
return ExecuteVector( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "FR" || sCmd1 == "FRAME")
|
||||
return ExecuteFrame( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "CL" || sCmd1 == "CURVELINE")
|
||||
return ExecuteCurveLine( sCmd2, vsParams) ;
|
||||
else if ( sCmd1 == "CA" || sCmd1 == "CURVEARC")
|
||||
@@ -172,16 +176,52 @@ GdbExecutor::ExecuteAlias( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
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])) ;
|
||||
}
|
||||
Frame3d frFrame ;
|
||||
|
||||
return false ;
|
||||
|
||||
// gruppo generico
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d ptOrig ;
|
||||
Vector3d vtDirX ;
|
||||
Vector3d vtDirY ;
|
||||
Vector3d vtDirZ ;
|
||||
// 6 parametri : Id, Id del padre, Orig, VersX, VersY, VersZ
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero i componenti
|
||||
if ( ! GetPointParam( vsParams[2], ptOrig) ||
|
||||
! GetVectorParam( vsParams[3], vtDirX) ||
|
||||
! GetVectorParam( vsParams[4], vtDirY) ||
|
||||
! GetVectorParam( vsParams[5], vtDirZ))
|
||||
return false ;
|
||||
// costruisco il riferimento
|
||||
if ( ! frFrame.Set( ptOrig, vtDirX, vtDirY, vtDirZ))
|
||||
return false ;
|
||||
}
|
||||
// gruppo orientato come il padre
|
||||
else if ( sCmd2 == "PLANEXY" || sCmd2 == "XY") {
|
||||
Point3d ptOrig ;
|
||||
// 3 parametri : Id, Id del padre, Orig
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero i componenti
|
||||
if ( ! GetPointParam( vsParams[2], ptOrig))
|
||||
return false ;
|
||||
// costruisco il riferimento
|
||||
if ( ! frFrame.Set( ptOrig, Frame3d::TOP))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
|
||||
// creo il gruppo
|
||||
int nIdDest = GetIdParam( vsParams[0]) ;
|
||||
int nIdNew = m_pGDB->AddGroup( nIdDest, GetIdParam( vsParams[1]), frFrame) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nIdDest == GDB_ID_NULL && m_AliasMap.find( vsParams[0]) != m_AliasMap.end())
|
||||
m_AliasMap[vsParams[0]] = nIdNew ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -204,7 +244,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGPnt == nullptr)
|
||||
return false ;
|
||||
pGPnt->Set( Pnt) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]),pGPnt) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]),pGPnt) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -230,7 +270,37 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGVect == nullptr)
|
||||
return false ;
|
||||
pGVect->Set( Vect) ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGVect) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGVect) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// analisi ed esecuzione dei comandi
|
||||
if ( sCmd2 == "MAKE" || sCmd2 == "") {
|
||||
Point3d ptOrig ;
|
||||
Vector3d vtDirX ;
|
||||
Vector3d vtDirY ;
|
||||
Vector3d vtDirZ ;
|
||||
// 6 parametri
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero i componenti
|
||||
if ( ! GetPointParam( vsParams[2], ptOrig) ||
|
||||
! GetVectorParam( vsParams[3], vtDirX) ||
|
||||
! GetVectorParam( vsParams[4], vtDirY) ||
|
||||
! GetVectorParam( vsParams[5], vtDirZ))
|
||||
return false ;
|
||||
// creo il riferimento
|
||||
IGeoFrame3d* pGFrame = CreateGeoFrame3d() ;
|
||||
if ( pGFrame == nullptr)
|
||||
return false ;
|
||||
pGFrame->Set( ptOrig, vtDirX, vtDirY, vtDirZ) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGFrame) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -252,10 +322,10 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
! GetPointParam( vsParams[3], ptEnd))
|
||||
return false ;
|
||||
// creo la linea
|
||||
ReleasePtr<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( ! IsValid( pCrvLine) || ! pCrvLine->Set( ptStart, ptEnd))
|
||||
return false ;
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvLine)) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvLine)) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -266,7 +336,7 @@ bool
|
||||
GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// creo l'arco
|
||||
ReleasePtr<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( ! IsValid( pCrvArc))
|
||||
return false ;
|
||||
|
||||
@@ -337,7 +407,7 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco l'arco nel DB
|
||||
return m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvArc)) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvArc)) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -345,7 +415,7 @@ bool
|
||||
GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// creo la curva di Bezier
|
||||
ReleasePtr<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
if ( ! IsValid( pCrvBez))
|
||||
return false ;
|
||||
|
||||
@@ -387,7 +457,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// recupero e setto punti di controllo
|
||||
for ( i = 0 ; i <= nDeg ; ++ i) {
|
||||
if ( ! GetPointWeParam( vsParams[i+3], ptP, dW) ||
|
||||
if ( ! GetPointWParam( vsParams[i+3], ptP, dW) ||
|
||||
! pCrvBez->SetControlPoint( i, ptP, dW))
|
||||
return false ;
|
||||
}
|
||||
@@ -397,7 +467,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]), GetIdParam( vsParams[1]), Release( pCrvBez)) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvBez)) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -410,7 +480,7 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
STRVECTOR vsNames ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
const ICurve* pCrv ;
|
||||
ReleasePtr<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( ! IsValid( pCrvCompo))
|
||||
return false ;
|
||||
// 3 o 4 parametri
|
||||
@@ -467,7 +537,7 @@ GdbExecutor::GetIdParam( const std::string& sParam)
|
||||
return nVal ;
|
||||
// altrimenti errore
|
||||
else
|
||||
return 0 ;
|
||||
return - 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -545,7 +615,7 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::GetPointWeParam( const std::string& sParam, Point3d& ptP, double& dW)
|
||||
GdbExecutor::GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW)
|
||||
{
|
||||
STRVECTOR vsParams ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
@@ -590,7 +660,13 @@ GdbExecutor::ExecuteCopy( const STRVECTOR& vsParams)
|
||||
if ( vsParams.size() != 3)
|
||||
return false ;
|
||||
// esecuzione copia
|
||||
return m_pGDB->Copy( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), GetIdParam( vsParams[2])) ;
|
||||
int nIdDest = GetIdParam( vsParams[1]) ;
|
||||
int nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nIdDest == GDB_ID_NULL && m_AliasMap.find( vsParams[1]) != m_AliasMap.end())
|
||||
m_AliasMap[vsParams[1]] = nIdNew ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -811,7 +887,17 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// eseguo
|
||||
return m_OutScl.SetPartLay( vsParams[0], vsParams[1]) ;
|
||||
}
|
||||
// emetto entità
|
||||
// emetto gruppo
|
||||
else if ( sCmd2 == "PUTGR") {
|
||||
int nId ;
|
||||
// un parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
nId = GetIdParam( vsParams[0]) ;
|
||||
// emetto gruppo e suoi sottoposti
|
||||
return OutGroupScl( nId) ;
|
||||
}
|
||||
// emetto oggetto geometrico
|
||||
else if ( sCmd2 == "PUT") {
|
||||
bool bCrvVsPolyg ;
|
||||
int nId ;
|
||||
@@ -832,35 +918,49 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
nId = GetIdParam( *Iter) ;
|
||||
switch ( m_pGDB->GetObjType( nId)) {
|
||||
case CRV_LINE :
|
||||
if ( ! m_OutScl.PutCurveLine( *GetCurveLine( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
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( nId))))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! m_OutScl.PutPolygBez( *GetCurveBezier( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
}
|
||||
break ;
|
||||
case CRV_COMPO :
|
||||
if ( ! m_OutScl.PutCurveCompo( *GetCurveComposite( m_pGDB->GetGeoObj( nId))))
|
||||
return false ;
|
||||
break ;
|
||||
default :
|
||||
if ( ! m_OutScl.PutCurve( m_pGDB->GetGeoObj( nId), bCrvVsPolyg))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::OutGroupScl( int nId)
|
||||
{
|
||||
bool bNext ;
|
||||
int nParentId ;
|
||||
int nGdbType ;
|
||||
Frame3d frFrame ;
|
||||
GdbIterator Iter ;
|
||||
|
||||
|
||||
// emetto dati gruppo
|
||||
if ( m_pGDB->GetGroupGlobFrame( nId, frFrame)) {
|
||||
nParentId = m_pGDB->GetParentId( nId) ;
|
||||
if ( nParentId > GDB_ID_ROOT) {
|
||||
if ( ! m_OutScl.SetPartLayRef( ToString( nParentId), ToString( nId), frFrame))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// emetto entità gruppo
|
||||
Iter.SetGDB( m_pGDB) ;
|
||||
bNext = Iter.GoToFirstInGroup( nId) ;
|
||||
while ( bNext) {
|
||||
nGdbType = Iter.GetGdbType() ;
|
||||
if ( nGdbType == GDB_GEO) {
|
||||
if ( ! m_OutScl.PutCurve( Iter.GetGeoObj(), true))
|
||||
return false ;
|
||||
}
|
||||
else if ( nGdbType == GDB_GROUP) {
|
||||
if ( ! OutGroupScl( Iter.GetId()))
|
||||
return false ;
|
||||
}
|
||||
bNext = Iter.GoToNext() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user