EgtGeomKernel 1.4a3 : Migliorata gestione gruppi, aggiunti GdbIterator, GeoFrame3d e IdManager.
This commit is contained in:
+79
-5
@@ -15,6 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "\EgtDev\Include\EGnStringUtils.h"
|
||||
#include "GdbGroup.h"
|
||||
#include "IdManager.h"
|
||||
|
||||
|
||||
using namespace std ;
|
||||
@@ -56,7 +57,7 @@ GdbGroup::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GdbGroup*
|
||||
GdbGroup::Clone( int nId) const
|
||||
GdbGroup::Clone( int nId, IdManager& IdMgr) const
|
||||
{
|
||||
GdbGroup* pGdbGroup ;
|
||||
const GdbNode* pNode ;
|
||||
@@ -70,13 +71,14 @@ GdbGroup::Clone( int nId) const
|
||||
|
||||
// copio dati oggetto Gdb
|
||||
pGdbGroup->m_nId = nId ;
|
||||
IdMgr.UpdateMaxId( nId) ;
|
||||
// ...
|
||||
|
||||
// clono i nodi figli
|
||||
pNode = GetFirstNode() ;
|
||||
while ( pNode != nullptr) {
|
||||
// eseguo copia
|
||||
pNewNode = pNode->Clone( ++ nId) ;
|
||||
pNewNode = pNode->Clone( IdMgr.GetNewId(), IdMgr) ;
|
||||
if ( pNewNode == nullptr) {
|
||||
delete pGdbGroup ;
|
||||
return nullptr ;
|
||||
@@ -104,13 +106,12 @@ GdbGroup::Save( std::ostream& osOut) const
|
||||
osOut << GetKey() << endl ;
|
||||
// identificativi
|
||||
osOut << m_nId << "@" << GetParentId() << endl ;
|
||||
// altri parametri
|
||||
// TODO ...
|
||||
// dati del riferimento
|
||||
m_gfrFrame.Save( osOut) ;
|
||||
|
||||
// lancio il salvataggio dei figli
|
||||
const GdbNode* pGdbNode = GetFirstNode() ;
|
||||
while ( pGdbNode != nullptr) {
|
||||
// oggetto geometrico
|
||||
if ( ! pGdbNode->Save( osOut))
|
||||
bOk = false ;
|
||||
pGdbNode = pGdbNode->GetNext() ;
|
||||
@@ -141,8 +142,81 @@ GdbGroup::Load( const string& sType, CScan& TheScanner, int& nParentId)
|
||||
// assegno l'Id del padre
|
||||
if ( ! FromString( vsParams[1], nParentId))
|
||||
return false ;
|
||||
// leggo i dati del riferimento
|
||||
m_gfrFrame.Load( TheScanner) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
return m_gfrFrame.Translate( vtMove) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
return m_gfrFrame.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::Scale( const Point3d& ptCen, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
bool bOk ;
|
||||
bool bUniform ;
|
||||
Point3d ptCenLoc ;
|
||||
GdbNode* pGdbNode ;
|
||||
|
||||
|
||||
// non è possibile scalare il riferimento, devo agire sui nodi sottostanti
|
||||
|
||||
// determino se la scalatura è uniforme
|
||||
bUniform = fabs( dCoeffX - dCoeffY) < EPS_SMALL && fabs( dCoeffX - dCoeffZ) < EPS_SMALL ;
|
||||
|
||||
// se la scalatura è uniforme, basta portare il centro nel riferimento del gruppo
|
||||
if ( bUniform) {
|
||||
ptCenLoc = ptCen ;
|
||||
ptCenLoc.ToLoc( m_gfrFrame.m_frF) ;
|
||||
}
|
||||
// altrimenti si deve propagare il riferimento rispetto al centro
|
||||
else
|
||||
return false ; // !!!!! TODO !!!!!
|
||||
|
||||
// ciclo sui nodi
|
||||
bOk = true ;
|
||||
pGdbNode = GetFirstNode() ;
|
||||
while ( pGdbNode != nullptr) {
|
||||
if ( ! pGdbNode->Scale( ptCenLoc, dCoeffX, dCoeffY, dCoeffZ))
|
||||
bOk = false ;
|
||||
pGdbNode = pGdbNode->GetNext() ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::GetGlobFrame( Frame3d& frGlob)
|
||||
{
|
||||
GdbGroup* pParent ;
|
||||
|
||||
|
||||
// assegno il proprio frame
|
||||
frGlob = m_gfrFrame.m_frF ;
|
||||
|
||||
// mentre ci sono padri
|
||||
pParent = GetParent() ;
|
||||
while ( pParent != nullptr) {
|
||||
// porto il riferimento corrente sopra il padre
|
||||
frGlob.ToGlob( pParent->m_gfrFrame.m_frF) ;
|
||||
// passo al successivo
|
||||
pParent = pParent->GetParent() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user