EgtGeomKernel 1.5c1 :

- aggiunta prima gestione attributi.
This commit is contained in:
Dario Sassi
2014-03-06 08:17:26 +00:00
parent 76f1c1ceac
commit 2a2c0065ed
21 changed files with 1284 additions and 714 deletions
+150
View File
@@ -0,0 +1,150 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : Attribs.cpp Data : 05.03.14 Versione : 1.5c1
// Contenuto : Implementazione della classe Attribs.
//
//
//
// Modifiche : 05.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Attribs.h"
#include "/EgtDev/Include/EgnStringUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
Attribs::Dump( string& sOut, const char* szNewLine) const
{
sOut += "Lev=" ;
switch ( m_Data[LEVEL]) {
default : /* LEV_USER */ sOut += "user" ; break ;
case LEV_SYSTEM : sOut += "system" ; break ;
case LEV_TEMP : sOut += "temp" ; break ;
}
sOut += " Mod=" ;
switch ( m_Data[MODE]) {
default : /* MOD_STD */ sOut += "std" ; break ;
case MOD_LOCKED : sOut += "locked" ; break ;
case MOD_HIDDEN : sOut += "hidden" ; break ;
}
sOut += " Sta=" ;
switch ( m_Data[STATUS]) {
default : /* STS_ON */ sOut += "on" ; break ;
case STS_SEL : sOut += "sel" ; break ;
case STS_OFF : sOut += "off" ; break ;
}
sOut += szNewLine ;
sOut += "Mat=" ;
switch ( m_Material) {
case MAT_PARENT : sOut += "by parent" ; break ;
case MAT_COLOR : sOut += "color" ; break ;
case MAT_NULL : sOut += "null" ; break ;
default : sOut += ToString( m_Material) ; break ;
}
if ( m_Material != MAT_PARENT && m_Material != MAT_NULL) {
sOut += " Col=" ;
sOut += ToString( m_Color.GetIntRed()) + "," ;
sOut += ToString( m_Color.GetIntGreen()) + "," ;
sOut += ToString( m_Color.GetIntBlue()) + "," ;
sOut += ToString( m_Color.GetIntAlpha()) ;
}
sOut += szNewLine ;
return true ;
}
//----------------------------------------------------------------------------
bool
Attribs::Save( ostream& osOut) const
{
// flag presenza attributi
osOut << "A" << endl ;
// livello
osOut << ToString( m_Data[LEVEL]) ;
// modo
osOut << "," << ToString( m_Data[MODE]) ;
// stato
osOut << "," << ToString( m_Data[STATUS]) ;
// altro
osOut << "," << ToString( m_Data[OTHER]) ;
// materiale
osOut << ";" << ToString( m_Material) ;
// colore
osOut << ";" << ToString( m_Color.GetIntRed()) ;
osOut << "," << ToString( m_Color.GetIntGreen()) ;
osOut << "," << ToString( m_Color.GetIntBlue()) ;
osOut << "," << ToString( m_Color.GetIntAlpha()) ;
// numero di stringhe (nelle linee successive)
osOut << ";" << ToString( 0) << ";" << endl ;
return true ;
}
//----------------------------------------------------------------------------
bool
Attribs::Load( Scanner& TheScanner)
{
// leggo la prossima linea
string sLine ;
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
STRVECTOR vsParams ;
Tokenize( sLine, ",;", vsParams) ;
// 10 parametri
if ( vsParams.size() != 10)
return false ;
// livello
int nLev ;
if ( ! FromString( vsParams[0], nLev))
return false ;
m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ;
// modo
int nMode ;
if ( ! FromString( vsParams[1], nMode))
return false ;
m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ;
// stato
int nStat ;
if ( ! FromString( vsParams[2], nStat))
return false ;
m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ;
// altro
int nOther ;
if ( ! FromString( vsParams[3], nOther))
return false ;
m_Data[OTHER] = CLIP( nOther, 0, 255) ;
// materiale
int nMat ;
if ( ! FromString( vsParams[4], nMat))
return false ;
m_Material = __max( nMat, MAT_PARENT) ;
// colore
int nRed ;
if ( ! FromString( vsParams[5], nRed))
return false ;
int nGreen ;
if ( ! FromString( vsParams[6], nGreen))
return false ;
int nBlue ;
if ( ! FromString( vsParams[7], nBlue))
return false ;
int nAlpha ;
if ( ! FromString( vsParams[8], nAlpha))
return false ;
m_Color.Set( nRed, nGreen, nBlue, nAlpha) ;
// numero di stringhe (nelle linee successive)
int nNext ;
if ( ! FromString( vsParams[9], nNext))
return false ;
return true ;
}
+79
View File
@@ -0,0 +1,79 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : Attribs.h Data : 03.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GeoAttributes.
//
//
//
// Modifiche : 03.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScan.h"
#include <string>
//----------------------------------------------------------------------------
#define CLIP( nV, nMIN, nMAX) (( nV < nMIN) ? nMIN : (( nV > nMAX) ? nMAX : nV))
//----------------------------------------------------------------------------
class Attribs
{
public :
Attribs( void)
{ m_Data[LEVEL] = LEV_USER ; m_Data[MODE] = MOD_STD ;
m_Data[STATUS] = STS_ON ; m_Data[OTHER] = 0 ;
m_Material = MAT_PARENT ; m_Color.Set( 0, 0, 0) ;}
Attribs* Clone( void) const
{ Attribs* pAttribs ;
// alloco oggetto
pAttribs = new(std::nothrow) Attribs ;
if ( pAttribs != nullptr)
*pAttribs = *(const_cast<Attribs*>(this)) ;
return pAttribs ; }
bool Dump( std::string& sOut, const char* szNewLine) const ;
bool Save( std::ostream& osOut) const ;
bool Load( Scanner& TheScanner) ;
void SetLevel( int nLev)
{ m_Data[LEVEL] = CLIP( nLev, LEV_USER, LEV_TEMP) ; }
int GetLevel( void) const
{ return m_Data[LEVEL] ; }
void SetMode( int nMode)
{ m_Data[MODE] = CLIP( nMode, MOD_STD, MOD_HIDDEN) ; }
int GetMode( void) const
{ return m_Data[MODE] ; }
void SetStatus( int nStat)
{ m_Data[STATUS] = CLIP( nStat, STS_ON, STS_OFF) ; }
int GetStatus( void) const
{ return m_Data[STATUS] ; }
void SetMaterial( int nMat)
{ if ( nMat != MAT_COLOR)
m_Material = nMat ; }
int GetMaterial( void) const
{ return m_Material ; }
void SetColor( Color cCol)
{ m_Material = MAT_COLOR ; m_Color = cCol ; }
Color GetColor( void) const
{ return m_Color ; }
public :
enum Level { LEV_USER = 0, LEV_SYSTEM = 1, LEV_TEMP = 2} ;
enum Mode { MOD_STD = 0, MOD_LOCKED = 1, MOD_HIDDEN = 2} ;
enum Status { STS_ON = 0, STS_SEL = 1, STS_OFF = 2} ;
enum { MAT_PARENT = -2, MAT_COLOR = -1, MAT_NULL = 0} ;
private :
enum { LEVEL = 0, MODE = 1, STATUS = 2, OTHER = 3, DIM = 4} ;
private :
unsigned char m_Data[DIM] ;
int m_Material ;
Color m_Color ;
std::string m_sName ;
std::string m_sNotes ;
} ;
BIN
View File
Binary file not shown.
+4 -2
View File
@@ -225,6 +225,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Attribs.cpp" />
<ClCompile Include="BBox3d.cpp" />
<ClCompile Include="DistPointArc.cpp" />
<ClCompile Include="DistPointCrvAux.cpp" />
@@ -242,8 +243,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="Frame3d.cpp" />
<ClCompile Include="GdbGroup.cpp" />
<ClCompile Include="GdbIterator.cpp" />
<ClCompile Include="GdbNode.cpp" />
<ClCompile Include="GdbObj.cpp" />
<ClCompile Include="GdbGeo.cpp" />
<ClCompile Include="GeoFrame3d.cpp" />
<ClCompile Include="GeomDB.cpp" />
<ClCompile Include="GeoObj.cpp" />
@@ -312,8 +313,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="CurveLine.h" />
<ClInclude Include="GdbGroup.h" />
<ClInclude Include="GdbIterator.h" />
<ClInclude Include="GdbGeo.h" />
<ClInclude Include="GdbObj.h" />
<ClInclude Include="GdbNode.h" />
<ClInclude Include="Attribs.h" />
<ClInclude Include="GeoConst.h" />
<ClInclude Include="GeoFrame3d.h" />
<ClInclude Include="GeomDB.h" />
+21 -15
View File
@@ -75,18 +75,12 @@
<ClCompile Include="GeomDB.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbObj.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="OutScl.cpp">
<Filter>File di origine\Script</Filter>
</ClCompile>
<ClCompile Include="GdbExecutor.cpp">
<Filter>File di origine\Script</Filter>
</ClCompile>
<ClCompile Include="GdbNode.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbGroup.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
@@ -108,9 +102,6 @@
<ClCompile Include="DistPointCrvBezier.cpp">
<Filter>File di origine\Distanze</Filter>
</ClCompile>
<ClCompile Include="GdbIterator.cpp">
<Filter>File di origine\Distanze</Filter>
</ClCompile>
<ClCompile Include="PolynomialPoint3d.cpp">
<Filter>File di origine\Base</Filter>
</ClCompile>
@@ -126,6 +117,18 @@
<ClCompile Include="StringUtils3d.cpp">
<Filter>File di origine\Base</Filter>
</ClCompile>
<ClCompile Include="GdbIterator.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbGeo.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="GdbObj.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
<ClCompile Include="Attribs.cpp">
<Filter>File di origine\Gdb</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -203,9 +206,6 @@
<ClInclude Include="..\Include\EgkCurveComposite.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GeomDB.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@@ -218,9 +218,6 @@
<ClInclude Include="GdbExecutor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbNode.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbGroup.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@@ -317,6 +314,15 @@
<ClInclude Include="ObjGraphicsMgr.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Attribs.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbGeo.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="GdbObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGeomKernel.rc">
+44
View File
@@ -128,6 +128,8 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
return ExecuteCurveBez( sCmd2, vsParams) ;
else if ( sCmd1 == "CC" || sCmd1 == "CURVECOMPO")
return ExecuteCurveCompo( sCmd2, vsParams) ;
else if ( sCmd1 == "COL" || sCmd1 == "COLOR")
return ExecuteColor( sCmd2, vsParams) ;
else if ( sCmd1 == "COPY")
return ExecuteCopy( sCmd2, vsParams) ;
else if ( sCmd1 == "ERASE")
@@ -882,6 +884,48 @@ GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF)
}
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteColor( const string& sCmd2, const STRVECTOR& vsParams)
{
// impostazione colore di default
if ( sCmd2 == "DEF" || sCmd2 == "DEFAULT") {
// 3 parametri ( Red, Green, Blue)
if ( vsParams.size() != 3)
return false ;
// recupero i colori
int nRed ;
int nGreen ;
int nBlue ;
if ( ! FromString( vsParams[0], nRed) ||
! FromString( vsParams[1], nGreen) ||
! FromString( vsParams[2], nBlue))
return false ;
Color cCol( nRed, nGreen, nBlue) ;
return m_pGDB->SetDefaultColor( cCol) ;
}
// impostazione colore su oggetto
else {
// 4 o 5 parametri ( Id, Red, Green, Blue, Alpha)
if ( vsParams.size() != 4 && vsParams.size() != 5)
return false ;
// recupero i colori
int nRed ;
int nGreen ;
int nBlue ;
if ( ! FromString( vsParams[1], nRed) ||
! FromString( vsParams[2], nGreen) ||
! FromString( vsParams[3], nBlue))
return false ;
int nAlpha = 100 ;
if ( vsParams.size() == 5 &&
! FromString( vsParams[4], nAlpha))
return false ;
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
return m_pGDB->SetColor( GetIdParam( vsParams[0]), cCol) ;
}
}
//----------------------------------------------------------------------------
bool
GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams)
+1
View File
@@ -46,6 +46,7 @@ class GdbExecutor : public IGdbExecutor
bool ExecuteCurveArc( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveBez( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCurveCompo( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteColor( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteErase( const STRVECTOR& vsParams) ;
bool ExecuteTranslate( const std::string& sCmd2, const STRVECTOR& vsParams) ;
+246
View File
@@ -0,0 +1,246 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbGeo.cpp Data : 24.11.13 Versione : 1.3a1
// Contenuto : Implementazione della classe GdbGeo oggetto del DB geometrico.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GdbGeo.h"
#include "GeoObjFactory.h"
#include "CurveAux.h"
#include "Attribs.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <new>
using namespace std ;
//----------------------------------------------------------------------------
GdbGeo::GdbGeo( void)
{
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbGeo::~GdbGeo( void)
{
if ( m_pGeoObj != nullptr)
delete m_pGeoObj ;
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbGeo*
GdbGeo::Clone( int nId, IdManager& IdMgr) const
{
GdbGeo* pGdbGeo ;
// alloco oggetto Gdb
pGdbGeo = new(nothrow) GdbGeo ;
if ( pGdbGeo == nullptr)
return nullptr ;
// copio dati oggetto Gdb
pGdbGeo->GdbObj::Copy( this) ;
// assegno nuovo Id
pGdbGeo->m_nId = nId ;
// l'aggiornamento del manager di Id viene fatto all'inserimento nel DB
// copio oggetto Geo
if ( m_pGeoObj != nullptr) {
pGdbGeo->m_pGeoObj = m_pGeoObj->Clone() ;
if ( pGdbGeo->m_pGeoObj == nullptr) {
delete pGdbGeo ;
return nullptr ;
}
}
return pGdbGeo ;
}
//----------------------------------------------------------------------------
GeoObjType
GdbGeo::GetType( void) const
{
// non esiste l'oggetto geometrico
if ( m_pGeoObj == nullptr)
return GEO_NONE ;
return m_pGeoObj->GetType() ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Save( std::ostream& osOut) const
{
bool bOk = true ;
// tipo entità
osOut << m_pGeoObj->GetKey() << endl ;
// nome
osOut << m_nId << "@" << GetParentId() << endl ;
// attributi
if ( ! GdbObj::SaveAttribs( osOut))
bOk = false ;
// parametri geometrici
osOut << "G" << endl ;
if ( ! m_pGeoObj->Save( osOut))
bOk = false ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Load( const std::string& sType, Scanner& TheScanner, int& nParentId)
{
int nType ;
string sLine ;
STRVECTOR vsParams ;
// creo l'oggetto geometrico corrispondente
nType = GEOOBJ_KEYTOTYPE( sType) ;
m_pGeoObj = GEOOBJ_CREATE( nType) ;
if ( m_pGeoObj == nullptr)
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
Tokenize( sLine, "@", vsParams) ;
// 2 parametri : Id e ParentId
if ( vsParams.size() != 2)
return false ;
// assegno l'identificativo
if ( ! FromString( vsParams[0], m_nId))
return false ;
// assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// eventuali attributi
if ( sLine == "A") {
if ( ! GdbObj::LoadAttribs( TheScanner))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
}
// verifico inizio dati geometrici
if ( sLine != "G")
return false ;
// parametri geometrici
return m_pGeoObj->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::GetLocalBBox( BBox3d& b3Loc) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetLocalBBox( b3Loc) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetBBox( frRef, b3Ref) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Translate( const Vector3d& vtMove)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Translate( vtMove) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
if ( m_pGeoObj == nullptr)
return false ;
// se arco e scalatura non omogenea
if ( m_pGeoObj->GetType() == CRV_ARC &&
(fabs( dCoeffX - dCoeffY) > EPS_SMALL || fabs( dCoeffX - dCoeffZ) > EPS_SMALL)) {
// trasformo in curva di Bezier (semplice o composta)
ICurve* pCrvNew ;
if ( ! ArcToBezierCurve( GetCurve( m_pGeoObj), pCrvNew))
return false ;
// elimino l'arco e lo sostituisco con la curva di Bezier
delete m_pGeoObj ;
m_pGeoObj = pCrvNew ;
}
// eseguo scalatura
return m_pGeoObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Mirror( ptOn, vtNorm) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::ToGlob( const Frame3d& frRef)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->ToGlob( frRef) ;
}
//----------------------------------------------------------------------------
bool
GdbGeo::ToLoc( const Frame3d& frRef)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->ToLoc( frRef) ;
}
+48
View File
@@ -0,0 +1,48 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbGeo.h Data : 05.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GdbGeo.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "GdbObj.h"
#include "/EgtDev/Include/EGkGeoObjType.h"
#include <string>
class IGeoObj ;
//----------------------------------------------------------------------------
class GdbGeo : public GdbObj
{
public :
virtual ~GdbGeo( void) ;
virtual GdbGeo* Clone( int nId, IdManager& IdMgr) const ;
virtual bool Save( std::ostream& osOut) const ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
virtual bool Translate( const Vector3d& vtMove) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool ToGlob( const Frame3d& frRef) ;
virtual bool ToLoc( const Frame3d& frRef) ;
public :
GdbGeo( void) ;
GeoObjType GetType( void) const ;
public :
IGeoObj* m_pGeoObj ;
} ;
+88 -65
View File
@@ -13,22 +13,22 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "\EgtDev\Include\EGnStringUtils.h"
#include "GdbGroup.h"
#include "IdManager.h"
#include "\EgtDev\Include\EGnStringUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
GdbGroup::GdbGroup( void)
: m_nNodeCount( 0), m_pFirstNode( nullptr), m_pLastNode( nullptr)
: m_nObjCount( 0), m_pFirstObj( nullptr), m_pLastObj( nullptr)
{
}
//----------------------------------------------------------------------------
GdbGroup::~GdbGroup( void)
{
// elimino i figli
Clear() ;
}
@@ -36,18 +36,16 @@ GdbGroup::~GdbGroup( void)
bool
GdbGroup::Clear( void)
{
GdbNode* pNode ;
// disalloco gli oggetti
pNode = GetFirstNode() ;
while ( pNode != nullptr) {
GdbObj* pObj ;
pObj = GetFirstObj() ;
while ( pObj != nullptr) {
// lo rimuovo dalla lista
pNode->Remove() ;
pObj->Remove() ;
// lo disalloco
delete pNode ;
delete pObj ;
// passo al nuovo primo
pNode = GetFirstNode() ;
pObj = GetFirstObj() ;
}
return true ;
@@ -57,41 +55,44 @@ GdbGroup::Clear( void)
GdbGroup*
GdbGroup::Clone( int nId, IdManager& IdMgr) const
{
GdbGroup* pGdbGroup ;
const GdbNode* pNode ;
GdbNode* pNewNode ;
// alloco gruppo Gdb
GdbGroup* pGdbGroup ;
pGdbGroup = new(nothrow) GdbGroup ;
if ( pGdbGroup == nullptr)
return nullptr ;
// copio dati oggetto Gdb
pGdbGroup->GdbObj::Copy( this) ;
// assegno nuovo Id
pGdbGroup->m_nId = nId ;
IdMgr.UpdateMaxId( nId) ;
// copio dati gruppo
pGdbGroup->m_gfrFrame = m_gfrFrame ;
// clono i nodi figli
pNode = GetFirstNode() ;
while ( pNode != nullptr) {
// clono gli oggetti figli
const GdbObj* pObj = GetFirstObj() ;
while ( pObj != nullptr) {
// eseguo copia
pNewNode = pNode->Clone( IdMgr.GetNewId(), IdMgr) ;
if ( pNewNode == nullptr) {
GdbObj* pNewObj = pObj->Clone( IdMgr.GetNewId(), IdMgr) ;
if ( pNewObj == nullptr) {
delete pGdbGroup ;
return nullptr ;
}
// lo inserisco nella lista dei figli
if ( ! pNewNode->AddTail( pGdbGroup)) {
delete pNewNode ;
if ( ! pNewObj->AddTail( pGdbGroup)) {
delete pNewObj ;
delete pGdbGroup ;
return nullptr ;
}
// lo inserisco nella mappa dei nomi
if ( ! IdMgr.AddNode( pNewNode->m_nId, pNewNode))
// lo inserisco nella mappa degli Id
if ( ! IdMgr.AddObj( pNewObj->m_nId, pNewObj)) {
delete pGdbGroup ;
return nullptr ;
// passo al prossimo nodo
pNode = pNode->GetNext() ;
}
// passo al prossimo oggetto
pObj = pObj->GetNext() ;
}
return pGdbGroup ;
@@ -107,15 +108,22 @@ GdbGroup::Save( std::ostream& osOut) const
osOut << GetKey() << endl ;
// identificativi
osOut << m_nId << "@" << GetParentId() << endl ;
// dati del riferimento
m_gfrFrame.Save( osOut) ;
// lancio il salvataggio dei figli
const GdbNode* pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
if ( ! pGdbNode->Save( osOut))
// attributi
if ( ! GdbObj::SaveAttribs( osOut))
bOk = false ;
pGdbNode = pGdbNode->GetNext() ;
// dati del riferimento
osOut << "G" << endl ;
if ( ! m_gfrFrame.Save( osOut))
bOk = false ;
// salvataggio dei figli
const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
if ( ! pGdbObj->Save( osOut))
bOk = false ;
pGdbObj = pGdbObj->GetNext() ;
}
return bOk ;
@@ -143,6 +151,24 @@ GdbGroup::Load( const string& sType, Scanner& TheScanner, int& nParentId)
// assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// eventuali attributi
if ( sLine == "A") {
if ( ! GdbObj::LoadAttribs( TheScanner))
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
}
// verifico inizio dati geometrici
if ( sLine != "G")
return false ;
// leggo i dati del riferimento
m_gfrFrame.Load( TheScanner) ;
@@ -154,13 +180,13 @@ bool
GdbGroup::GetLocalBBox( BBox3d& b3Loc) const
{
b3Loc.Reset() ;
const GdbNode* pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
BBox3d b3B ;
// voglio il box come appare nel frame del gruppo, quindi passo frame identità
if ( pGdbNode->GetBBox( GLOB_FRM, b3B))
if ( pGdbObj->GetBBox( GLOB_FRM, b3B))
b3Loc.Add( b3B) ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = pGdbObj->GetNext() ;
}
return true ;
}
@@ -171,12 +197,12 @@ GdbGroup::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{
Frame3d frCurr = m_gfrFrame.m_frF * frRef ;
b3Ref.Reset() ;
const GdbNode* pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
const GdbObj* pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
BBox3d b3B ;
if ( pGdbNode->GetBBox( frCurr, b3B))
if ( pGdbObj->GetBBox( frCurr, b3B))
b3Ref.Add( b3B) ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = pGdbObj->GetNext() ;
}
return true ;
}
@@ -199,20 +225,20 @@ GdbGroup::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
bool
GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
GdbNode* pGdbNode ;
GdbObj* pGdbObj ;
// parziale scalatura del riferimento (non può essere completa)
Frame3d frFrameS = m_gfrFrame.m_frF ;
frFrameS.PseudoScale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
// porto i nodi nel nuovo riferimento, senza modificarne la geometria in globale
// porto gli oggetti nel nuovo riferimento, senza modificarne la geometria in globale
Frame3d frTrasf = m_gfrFrame.m_frF ;
frTrasf.ToLoc( frFrameS) ;
pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
pGdbNode->ToGlob( frTrasf) ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
pGdbObj->ToGlob( frTrasf) ;
pGdbObj = pGdbObj->GetNext() ;
}
// assegno il nuovo riferimento
@@ -224,11 +250,11 @@ GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
// ciclo sui nodi
bool bOk = true ;
pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
if ( ! pGdbNode->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ))
pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
if ( ! pGdbObj->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ))
bOk = false ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = pGdbObj->GetNext() ;
}
return bOk ;
@@ -238,7 +264,7 @@ GdbGroup::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
bool
GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
{
GdbNode* pGdbNode ;
GdbObj* pGdbObj ;
// parziale mirror del riferimento (non può essere completa)
@@ -248,10 +274,10 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// porto i nodi nel nuovo riferimento, senza modificarne la geometria in globale
Frame3d frTrasf = m_gfrFrame.m_frF ;
frTrasf.ToLoc( frFrameS) ;
pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
pGdbNode->ToGlob( frTrasf) ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
pGdbObj->ToGlob( frTrasf) ;
pGdbObj = pGdbObj->GetNext() ;
}
// assegno il nuovo riferimento
@@ -265,11 +291,11 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
// ciclo sui nodi
bool bOk = true ;
pGdbNode = GetFirstNode() ;
while ( pGdbNode != nullptr) {
if ( ! pGdbNode->Mirror( ptOnLoc, vtNormLoc))
pGdbObj = GetFirstObj() ;
while ( pGdbObj != nullptr) {
if ( ! pGdbObj->Mirror( ptOnLoc, vtNormLoc))
bOk = false ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = pGdbObj->GetNext() ;
}
return bOk ;
@@ -279,13 +305,11 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
bool
GdbGroup::GetGlobFrame( Frame3d& frGlob) const
{
const GdbGroup* pParent ;
// assegno il proprio frame
frGlob = m_gfrFrame.m_frF ;
// mentre ci sono padri
const GdbGroup* pParent ;
pParent = GetParent() ;
while ( pParent != nullptr) {
// porto il riferimento corrente sopra il padre
@@ -296,4 +320,3 @@ GdbGroup::GetGlobFrame( Frame3d& frGlob) const
return true ;
}
+24 -17
View File
@@ -13,16 +13,15 @@
#pragma once
#include <string>
#include "/EgtDev/Include/EGkGeoObj.h"
#include "GeoFrame3d.h"
#include "GdbNode.h"
#include "GdbObj.h"
#include "/EgtDev/Include/EGkGeoObj.h"
#include <string>
//----------------------------------------------------------------------------
class GdbGroup : public GdbNode
class GdbGroup : public GdbObj
{
friend class GdbNode ;
friend class GdbObj ;
public :
virtual ~GdbGroup( void) ;
@@ -46,16 +45,24 @@ class GdbGroup : public GdbNode
public :
GdbGroup( void) ;
bool Clear( void) ;
void NodeCountInc( void) { ++ m_nNodeCount ; }
void NodeCountDec( void) { -- m_nNodeCount ; }
int GetNodeCount( void) const { return m_nNodeCount ; }
GdbNode* GetFirstNode( void) { return m_pFirstNode ; }
const GdbNode* GetFirstNode( void) const { return m_pFirstNode ; }
GdbNode* GetLastNode( void) { return m_pLastNode ; }
const GdbNode* GetLastNode( void) const { return m_pLastNode ; }
void ObjCountInc( void)
{ ++ m_nObjCount ; }
void ObjCountDec( void)
{ -- m_nObjCount ; }
int GetObjCount( void) const
{ return m_nObjCount ; }
GdbObj* GetFirstObj( void)
{ return m_pFirstObj ; }
const GdbObj* GetFirstObj( void) const
{ return m_pFirstObj ; }
GdbObj* GetLastObj( void)
{ return m_pLastObj ; }
const GdbObj* GetLastObj( void) const
{ return m_pLastObj ; }
public :
static const std::string& GetKey( void) { static std::string s_sKey = "A_GRP" ; return s_sKey ; }
static const std::string& GetKey( void)
{ static std::string s_sKey = "A_GRP" ; return s_sKey ; }
public :
bool GetGlobFrame( Frame3d& frGlob) const ;
@@ -64,7 +71,7 @@ class GdbGroup : public GdbNode
GeoFrame3d m_gfrFrame ;
private :
int m_nNodeCount ;
GdbNode* m_pFirstNode ;
GdbNode* m_pLastNode ;
int m_nObjCount ;
GdbObj* m_pFirstObj ;
GdbObj* m_pLastObj ;
} ;
+70 -55
View File
@@ -13,8 +13,9 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include <new>
#include "GdbIterator.h"
#include "Attribs.h"
#include <new>
using namespace std ;
@@ -31,7 +32,7 @@ CreateGdbIterator( void)
GdbIterator::GdbIterator( void)
{
m_pGDB = nullptr ;
m_pCurrNode = nullptr ;
m_pCurrObj = nullptr ;
}
//----------------------------------------------------------------------------
@@ -56,9 +57,9 @@ GdbIterator::GoTo( int nId)
if ( m_pGDB == nullptr)
return false ;
m_pCurrNode = m_pGDB->GetGdbNode( nId) ;
m_pCurrObj = m_pGDB->GetGdbObj( nId) ;
return ( m_pCurrNode != nullptr) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
@@ -74,75 +75,73 @@ GdbIterator::GoToFirstInGroup( int nIdGroup)
// recupero il gruppo
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
if ( pGdbGroup == nullptr) {
m_pCurrNode = nullptr ;
m_pCurrObj = nullptr ;
return false ;
}
// recupero il nodo
m_pCurrNode = pGdbGroup->GetFirstNode() ;
// recupero l'oggetto
m_pCurrObj = pGdbGroup->GetFirstObj() ;
return ( m_pCurrNode != nullptr) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GoToNext( void)
{
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
m_pCurrNode = m_pCurrNode->GetNext() ;
m_pCurrObj = m_pCurrObj->GetNext() ;
return ( m_pCurrNode != nullptr) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GoToLastInGroup( int nIdGroup)
{
GdbGroup* pGdbGroup ;
if ( m_pGDB == nullptr)
return false ;
// recupero il gruppo
GdbGroup* pGdbGroup ;
pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ;
if ( pGdbGroup == nullptr) {
m_pCurrNode = nullptr ;
m_pCurrObj = nullptr ;
return false ;
}
// recupero il nodo
m_pCurrNode = pGdbGroup->GetLastNode() ;
// recupero l'oggetto
m_pCurrObj = pGdbGroup->GetLastObj() ;
return ( m_pCurrNode != nullptr) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GoToPrev( void)
{
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
m_pCurrNode = m_pCurrNode->GetPrev() ;
m_pCurrObj = m_pCurrObj->GetPrev() ;
return ( m_pCurrNode != nullptr) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
GdbType
GdbIterator::GetGdbType( void) const
{
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return GDB_NONE ;
// se oggetto geometrico
if ( GetGdbObj( m_pCurrNode) != nullptr)
if ( GetGdbGeo( m_pCurrObj) != nullptr)
return GDB_GEO ;
// se gruppo
else if ( GetGdbGroup( m_pCurrNode) != nullptr)
else if ( GetGdbGroup( m_pCurrObj) != nullptr)
return GDB_GROUP ;
// altro
else
@@ -153,31 +152,27 @@ GdbIterator::GetGdbType( void) const
IGeoObj*
GdbIterator::GetGeoObj( void)
{
const GdbObj* pGdbObj ;
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero l'oggetto Gdb
if ( ( pGdbObj = GetGdbObj( m_pCurrNode)) == nullptr)
const GdbGeo* pGdbGeo ;
if ( ( pGdbGeo = GetGdbGeo( m_pCurrObj)) == nullptr)
return nullptr ;
// restituisco il suo contenuto geometrico
return pGdbObj->m_pGeoObj ;
return pGdbGeo->m_pGeoObj ;
}
//----------------------------------------------------------------------------
IGeoFrame3d*
GdbIterator::GetGeoFrame( void)
{
GdbGroup* pGdbGroup ;
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return nullptr ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr)
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return nullptr ;
return &( pGdbGroup->m_gfrFrame) ;
@@ -185,15 +180,13 @@ GdbIterator::GetGeoFrame( void)
//----------------------------------------------------------------------------
bool
GdbIterator::GetGroupFrame( Frame3d& frGlob)
GdbIterator::GetGroupFrame( Frame3d& frGlob) const
{
GdbGroup* pGdbGroup ;
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr)
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return false ;
// copio il riferimento
@@ -203,15 +196,13 @@ GdbIterator::GetGroupFrame( Frame3d& frGlob)
//----------------------------------------------------------------------------
bool
GdbIterator::GetGroupGlobFrame( Frame3d& frGlob)
GdbIterator::GetGroupGlobFrame( Frame3d& frGlob) const
{
GdbGroup* pGdbGroup ;
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrNode)) == nullptr)
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( m_pCurrObj)) == nullptr)
return false ;
return pGdbGroup->GetGlobFrame( frGlob) ;
@@ -219,20 +210,44 @@ GdbIterator::GetGroupGlobFrame( Frame3d& frGlob)
//----------------------------------------------------------------------------
int
GdbIterator::GetId( void)
GdbIterator::GetId( void) const
{
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return - 1 ;
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return GDB_ID_NULL ;
return m_pCurrNode->m_nId ;
return m_pCurrObj->m_nId ;
}
//----------------------------------------------------------------------------
int
GdbIterator::GetParentId( void)
GdbIterator::GetParentId( void) const
{
if ( m_pGDB == nullptr || m_pCurrNode == nullptr)
return - 1 ;
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return GDB_ID_NULL ;
return m_pCurrNode->GetParentId() ;
return m_pCurrObj->GetParentId() ;
}
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
bool
GdbIterator::SetColor( Color cCol)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// assegno il colore
return m_pCurrObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::GetColor( Color& cCol) const
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// recupero il colore
return m_pCurrObj->GetColor( cCol) ;
}
+8 -6
View File
@@ -32,14 +32,16 @@ class GdbIterator : public IGdbIterator
virtual GdbType GetGdbType( void) const ;
virtual IGeoObj* GetGeoObj( void) ;
virtual IGeoFrame3d* GetGeoFrame( void) ;
virtual bool GetGroupFrame( Frame3d& frGlob) ;
virtual bool GetGroupGlobFrame( Frame3d& frGlob) ;
virtual int GetId( void) ;
virtual int GetParentId( void) ;
virtual bool GetGlobFrame( Frame3d& frGlob)
virtual bool GetGroupFrame( Frame3d& frGlob) const ;
virtual bool GetGroupGlobFrame( Frame3d& frGlob) const ;
virtual int GetId( void) const ;
virtual int GetParentId( void) const ;
virtual bool GetGlobFrame( Frame3d& frGlob) const
{ return m_pGDB->GetGroupGlobFrame( GetParentId(), frGlob) ; }
virtual bool SetColor( Color cCol) ;
virtual bool GetColor( Color& cCol) const ;
private :
GeomDB* m_pGDB ;
GdbNode* m_pCurrNode ;
GdbObj* m_pCurrObj ;
} ;
-159
View File
@@ -1,159 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbNode.cpp Data : 28.11.13 Versione : 1.4a2
// Contenuto : Implementazione della classe GdbNode.
//
//
//
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GdbNode.h"
#include "GdbGroup.h"
//----------------------------------------------------------------------------
GdbNode::GdbNode( void)
: m_nId( GDB_ID_NULL), m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
{
}
//----------------------------------------------------------------------------
int
GdbNode::GetParentId( void) const
{
if ( m_pParent != nullptr)
return m_pParent->m_nId ;
else
return 0 ;
}
//----------------------------------------------------------------------------
bool
GdbNode::AddTail( GdbGroup* pParent)
{
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
// se non ci sono figli
if ( pParent->m_pLastNode == nullptr) {
pParent->m_pLastNode = this ;
pParent->m_pFirstNode = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->NodeCountInc() ;
return true ;
}
// caso standard
return InsertAfter( pParent->m_pLastNode) ;
}
//----------------------------------------------------------------------------
bool
GdbNode::AddHead( GdbGroup* pParent)
{
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
// se non ci sono figli
if ( pParent->m_pFirstNode == nullptr) {
pParent->m_pFirstNode = this ;
pParent->m_pLastNode = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->NodeCountInc() ;
return true ;
}
// caso standard
return InsertBefore( pParent->m_pFirstNode) ;
}
//----------------------------------------------------------------------------
bool
GdbNode::InsertAfter( GdbNode* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef->m_pNext ;
m_pPrev = pRef ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento di riferimento
pRef->m_pNext = this ;
// sistemazione puntatori di eventuale elemento successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo ultimo nodo
if ( m_pParent->m_pLastNode == pRef)
m_pParent->m_pLastNode = this ;
m_pParent->NodeCountInc() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbNode::InsertBefore( GdbNode* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef ;
m_pPrev = pRef->m_pPrev ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento corrente
pRef->m_pPrev = this ;
// sistemazione puntatori di eventuale elemento precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo primo nodo
if ( m_pParent->m_pFirstNode == pRef)
m_pParent->m_pFirstNode = this ;
m_pParent->NodeCountInc() ;
}
return true ;
}
/*-------------------------------------------------------------------------*/
bool
GdbNode::Remove( void)
{
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
if ( m_pParent->m_pFirstNode == this)
m_pParent->m_pFirstNode = m_pNext ;
if ( m_pParent->m_pLastNode == this)
m_pParent->m_pLastNode = m_pPrev ;
m_pParent->NodeCountDec() ;
}
// sistemazione di eventuale precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = m_pNext ;
// sistemazione di eventuale successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = m_pPrev ;
return true ;
}
-65
View File
@@ -1,65 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbNode.h Data : 28.11.13 Versione : 1.4a2
// Contenuto : Dichiarazione della classe GdbNode.
//
//
//
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <string>
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGkBBox3d.h"
class GdbGroup ;
class IdManager ;
//----------------------------------------------------------------------------
class GdbNode
{
public :
virtual ~GdbNode( void) {}
virtual GdbNode* Clone( int nId, IdManager& IdMgr) const = 0 ;
virtual bool Save( std::ostream& osOut) const = 0 ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) = 0 ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual bool Translate( const Vector3d& vtMove) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
virtual bool ToGlob( const Frame3d& frRef) = 0 ;
virtual bool ToLoc( const Frame3d& frRef) = 0 ;
public :
GdbNode( void) ;
GdbNode* GetNext( void) { return m_pNext ; }
const GdbNode* GetNext( void) const { return m_pNext ; }
GdbNode* GetPrev( void) { return m_pPrev ; }
const GdbNode* GetPrev( void) const { return m_pPrev ; }
GdbGroup* GetParent( void) { return m_pParent ; }
const GdbGroup* GetParent( void) const { return m_pParent ; }
int GetParentId( void) const ;
bool AddTail( GdbGroup* pParent) ;
bool AddHead( GdbGroup* pParent) ;
bool InsertAfter( GdbNode* pRef) ;
bool InsertBefore( GdbNode* pRef) ;
bool Remove( void) ;
public :
int m_nId ;
private :
GdbNode* m_pNext ;
GdbNode* m_pPrev ;
GdbGroup* m_pParent ;
} ;
+214 -153
View File
@@ -1,12 +1,12 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbObj.cpp Data : 24.11.13 Versione : 1.3a1
// Contenuto : Implementazione della classe CGdbObj oggetto del DB geometrico.
// File : GdbObj.cpp Data : 05.03.14 Versione : 1.5c1
// Contenuto : Implementazione della classe GdbObj.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
@@ -14,8 +14,8 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GdbObj.h"
#include "GeoObjFactory.h"
#include "CurveAux.h"
#include "GdbGroup.h"
#include "Attribs.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <new>
@@ -23,190 +23,251 @@ using namespace std ;
//----------------------------------------------------------------------------
GdbObj::GdbObj( void)
: m_nId( GDB_ID_NULL), m_pAttribs( nullptr),
m_pNext( nullptr), m_pPrev( nullptr), m_pParent( nullptr)
{
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbObj::~GdbObj( void)
{
if ( m_pGeoObj != nullptr)
delete m_pGeoObj ;
m_pGeoObj = nullptr ;
if ( m_pAttribs != nullptr)
delete m_pAttribs ;
m_pAttribs = nullptr ;
}
//----------------------------------------------------------------------------
GdbObj*
GdbObj::Clone( int nId, IdManager& IdMgr) const
bool
GdbObj::Copy( const GdbObj* pSou)
{
GdbObj* pGdbObj ;
// elimino eventuali attributi pre-esistenti
if ( m_pAttribs != nullptr)
delete m_pAttribs ;
m_pAttribs = nullptr ;
// alloco oggetto Gdb
pGdbObj = new(nothrow) GdbObj ;
if ( pGdbObj == nullptr)
return nullptr ;
// copio dati oggetto Gdb
pGdbObj->m_nId = nId ;
// ...
// copio oggetto Geo
pGdbObj->m_pGeoObj = m_pGeoObj->Clone() ;
if ( pGdbObj->m_pGeoObj == nullptr) {
delete pGdbObj ;
return nullptr ;
// se l'oggetto sorgente non esiste
if ( pSou == nullptr) {
m_nId = GDB_ID_NULL ;
return false ;
}
return pGdbObj ;
}
// copio Id
m_nId = pSou->m_nId ;
//----------------------------------------------------------------------------
GeoObjType
GdbObj::GetType( void) const
{
// non esiste l'oggetto geometrico
if ( m_pGeoObj == nullptr)
return GEO_NONE ;
return m_pGeoObj->GetType() ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Save( std::ostream& osOut) const
{
// tipo entità
osOut << m_pGeoObj->GetKey() << endl ;
// nome
osOut << m_nId << "@" << GetParentId() << endl ;
// parametri geometrici
return m_pGeoObj->Save( osOut) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Load( const std::string& sType, Scanner& TheScanner, int& nParentId)
{
int nType ;
string sLine ;
STRVECTOR vsParams ;
// creo l'oggetto geometrico corrispondente
nType = GEOOBJ_KEYTOTYPE( sType) ;
m_pGeoObj = GEOOBJ_CREATE( nType) ;
if ( m_pGeoObj == nullptr)
// copio gli attributi
if ( pSou->m_pAttribs != nullptr) {
m_pAttribs = pSou->m_pAttribs->Clone() ;
if ( m_pAttribs == nullptr)
return false ;
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
Tokenize( sLine, "@", vsParams) ;
// 2 parametri : Id e ParentId
if ( vsParams.size() != 2)
return false ;
// assegno l'identificativo
if ( ! FromString( vsParams[0], m_nId))
return false ;
// assegno l'Id del padre
if ( ! FromString( vsParams[1], nParentId))
return false ;
// parametri geometrici
return m_pGeoObj->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetLocalBBox( BBox3d& b3Loc) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetLocalBBox( b3Loc) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->GetBBox( frRef, b3Ref) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Translate( const Vector3d& vtMove)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Translate( vtMove) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
if ( m_pGeoObj == nullptr)
return false ;
return m_pGeoObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
if ( m_pGeoObj == nullptr)
return false ;
// se arco e scalatura non omogenea
if ( m_pGeoObj->GetType() == CRV_ARC &&
(fabs( dCoeffX - dCoeffY) > EPS_SMALL || fabs( dCoeffX - dCoeffZ) > EPS_SMALL)) {
// trasformo in curva di Bezier (semplice o composta)
ICurve* pCrvNew ;
if ( ! ArcToBezierCurve( GetCurve( m_pGeoObj), pCrvNew))
return false ;
// elimino l'arco e lo sostituisco con la curva di Bezier
delete m_pGeoObj ;
m_pGeoObj = pCrvNew ;
}
// eseguo scalatura
return m_pGeoObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
return true ;
}
//----------------------------------------------------------------------------
// Node
//----------------------------------------------------------------------------
int
GdbObj::GetParentId( void) const
{
if ( m_pParent != nullptr)
return m_pParent->m_nId ;
else
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
GdbObj::AddTail( GdbGroup* pParent)
{
if ( m_pGeoObj == nullptr)
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
return m_pGeoObj->Mirror( ptOn, vtNorm) ;
// se non ci sono figli
if ( pParent->m_pLastObj == nullptr) {
pParent->m_pLastObj = this ;
pParent->m_pFirstObj = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->ObjCountInc() ;
return true ;
}
// caso standard
return InsertAfter( pParent->m_pLastObj) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::ToGlob( const Frame3d& frRef)
GdbObj::AddHead( GdbGroup* pParent)
{
if ( m_pGeoObj == nullptr)
// se il padre non è definito, errore
if ( pParent == nullptr)
return false ;
return m_pGeoObj->ToGlob( frRef) ;
// se non ci sono figli
if ( pParent->m_pFirstObj == nullptr) {
pParent->m_pFirstObj = this ;
pParent->m_pLastObj = this ;
m_pParent = pParent ;
m_pNext = nullptr ;
m_pPrev = nullptr ;
m_pParent->ObjCountInc() ;
return true ;
}
// caso standard
return InsertBefore( pParent->m_pFirstObj) ;
}
//----------------------------------------------------------------------------
bool
GdbObj::ToLoc( const Frame3d& frRef)
GdbObj::InsertAfter( GdbObj* pRef)
{
if ( m_pGeoObj == nullptr)
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
return m_pGeoObj->ToLoc( frRef) ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef->m_pNext ;
m_pPrev = pRef ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento di riferimento
pRef->m_pNext = this ;
// sistemazione puntatori di eventuale elemento successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo ultimo nodo
if ( m_pParent->m_pLastObj == pRef)
m_pParent->m_pLastObj = this ;
m_pParent->ObjCountInc() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::InsertBefore( GdbObj* pRef)
{
// se riferimento non definito, errore
if ( pRef == nullptr)
return false ;
// sistemazione puntatori di elemento inserito
m_pNext = pRef ;
m_pPrev = pRef->m_pPrev ;
m_pParent = pRef->m_pParent ;
// sistemazione puntatori di elemento corrente
pRef->m_pPrev = this ;
// sistemazione puntatori di eventuale elemento precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = this ;
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
// se nuovo primo nodo
if ( m_pParent->m_pFirstObj == pRef)
m_pParent->m_pFirstObj = this ;
m_pParent->ObjCountInc() ;
}
return true ;
}
/*-------------------------------------------------------------------------*/
bool
GdbObj::Remove( void)
{
// sistemazione dell'eventuale padre
if ( m_pParent != nullptr) {
if ( m_pParent->m_pFirstObj == this)
m_pParent->m_pFirstObj = m_pNext ;
if ( m_pParent->m_pLastObj == this)
m_pParent->m_pLastObj = m_pPrev ;
m_pParent->ObjCountDec() ;
}
// sistemazione di eventuale precedente
if ( m_pPrev != nullptr)
m_pPrev->m_pNext = m_pNext ;
// sistemazione di eventuale successivo
if ( m_pNext != nullptr)
m_pNext->m_pPrev = m_pPrev ;
return true ;
}
//----------------------------------------------------------------------------
// Attribs
//----------------------------------------------------------------------------
bool
GdbObj::SaveAttribs( std::ostream& osOut) const
{
if ( m_pAttribs != nullptr)
return m_pAttribs->Save( osOut) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::LoadAttribs( Scanner& TheScanner)
{
if ( GetSafeAttribs() == nullptr)
return false ;
return m_pAttribs->Load( TheScanner) ;
}
//----------------------------------------------------------------------------
Attribs*
GdbObj::GetSafeAttribs( void)
{
if ( m_pAttribs == nullptr) {
Attribs* pAttribs = new (nothrow) Attribs ;
if ( pAttribs == nullptr)
return nullptr ;
m_pAttribs = pAttribs ;
}
return m_pAttribs ;
}
//----------------------------------------------------------------------------
bool
GdbObj::SetColor( Color cCol)
{
// recupero gli attributi (se non ci sono, vengono creati)
Attribs* pAttribs = GetSafeAttribs() ;
if ( pAttribs == nullptr)
return false ;
// assegno il colore
pAttribs->SetColor( cCol) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::GetColor( Color& cCol) const
{
// se non ci sono attributi o ci si deve riferire al padre
if ( m_pAttribs == nullptr ||
m_pAttribs->GetMaterial() == Attribs::MAT_PARENT) {
if ( GetParent() != nullptr)
return GetParent()->GetColor( cCol) ;
else
return false ;
}
// se il colore è definito
if ( m_pAttribs->GetMaterial() != Attribs::MAT_NULL) {
cCol = m_pAttribs->GetColor() ;
return true ;
}
return false ;
}
+61 -22
View File
@@ -1,47 +1,86 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : GdbObj.h Data : 08.04.13 Versione : 1.1c1
// File : GdbObj.h Data : 05.03.14 Versione : 1.5c1
// Contenuto : Dichiarazione della classe GdbObj.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
// Modifiche : 28.11.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScan.h"
#include "/EgtDev/Include/EGkBBox3d.h"
#include <string>
#include "/EgtDev/Include/EGkGeoObj.h"
#include "GdbNode.h"
class GdbGroup ;
class IdManager ;
class Attribs ;
//----------------------------------------------------------------------------
class GdbObj : public GdbNode
class GdbObj
{
public :
virtual ~GdbObj( void) ;
virtual GdbObj* Clone( int nId, IdManager& IdMgr) const ;
virtual bool Save( std::ostream& osOut) const ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
virtual bool Translate( const Vector3d& vtMove) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool ToGlob( const Frame3d& frRef) ;
virtual bool ToLoc( const Frame3d& frRef) ;
virtual GdbObj* Clone( int nId, IdManager& IdMgr) const = 0 ;
virtual bool Save( std::ostream& osOut) const = 0 ;
virtual bool Load( const std::string& sType, Scanner& TheScanner, int& nParentId) = 0 ;
virtual bool GetLocalBBox( BBox3d& b3Loc) const = 0 ;
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const = 0 ;
virtual bool Translate( const Vector3d& vtMove) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
virtual bool ToGlob( const Frame3d& frRef) = 0 ;
virtual bool ToLoc( const Frame3d& frRef) = 0 ;
public :
GdbObj( void) ;
GeoObjType GetType( void) const ;
bool Copy( const GdbObj* pSou) ;
public :
IGeoObj* m_pGeoObj ;
bool SaveAttribs( std::ostream& osOut) const ;
bool LoadAttribs( Scanner& TheScanner) ;
Attribs* GetAttribs( void)
{ return m_pAttribs ; }
Attribs* GetSafeAttribs( void) ;
bool SetColor( Color cCol) ;
bool GetColor( Color& cCol) const ;
public :
GdbObj* GetNext( void)
{ return m_pNext ; }
const GdbObj* GetNext( void) const
{ return m_pNext ; }
GdbObj* GetPrev( void)
{ return m_pPrev ; }
const GdbObj* GetPrev( void) const
{ return m_pPrev ; }
GdbGroup* GetParent( void)
{ return m_pParent ; }
const GdbGroup* GetParent( void) const
{ return m_pParent ; }
int GetParentId( void) const ;
bool AddTail( GdbGroup* pParent) ;
bool AddHead( GdbGroup* pParent) ;
bool InsertAfter( GdbObj* pRef) ;
bool InsertBefore( GdbObj* pRef) ;
bool Remove( void) ;
public :
int m_nId ;
Attribs* m_pAttribs ;
private :
GdbObj* m_pNext ;
GdbObj* m_pPrev ;
GdbGroup* m_pParent ;
} ;
+173 -115
View File
@@ -14,8 +14,9 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "GeomDB.h"
#include "GdbObj.h"
#include "GdbGeo.h"
#include "DllMain.h"
#include "Attribs.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -36,6 +37,7 @@ CreateGeomDB( void)
GeomDB::GeomDB( void)
{
m_GrpRadix.m_nId = GDB_ID_ROOT ;
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
}
//----------------------------------------------------------------------------
@@ -48,9 +50,10 @@ GeomDB::~GeomDB( void)
bool
GeomDB::Init( void)
{
// imposto numero minimo buckets del map degli Id
m_IdManager.Init( 1024) ;
// imposto colore di default
m_GrpRadix.SetColor( Color( 0, 0, 0)) ;
return true ;
}
@@ -93,7 +96,7 @@ GeomDB::Load( const std::string& sFileIn)
// ciclo di lettura dei nodi
bOk = true ;
do {
if ( ! LoadOneNode( TheScanner, bEnd)) {
if ( ! LoadOneObj( TheScanner, bEnd)) {
bOk = false ;
string sOut = "GeomDbLoad : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEGkLogger(), sOut.c_str())
@@ -130,11 +133,11 @@ GeomDB::LoadStart( Scanner& TheScanner)
//----------------------------------------------------------------------------
bool
GeomDB::LoadOneNode( Scanner& TheScanner, bool& bEnd)
GeomDB::LoadOneObj( Scanner& TheScanner, bool& bEnd)
{
int nParentId ;
string sType ;
GdbNode* pGdbNode ;
GdbObj* pGdbObj ;
// in generale non è fine file
@@ -151,27 +154,27 @@ GeomDB::LoadOneNode( Scanner& TheScanner, bool& bEnd)
}
// se gruppo
else if ( sType == GdbGroup::GetKey()) {
pGdbNode = new( nothrow) GdbGroup ;
pGdbObj = new( nothrow) GdbGroup ;
}
// se copia TODO ("X_CPY")..
//else if ( sType == GdbCopy::GetKey) {
// pGdbNode = new( nothrow) GdbCopy ;
// pGdbObj = new( nothrow) GdbCopy ;
//}
// altrimenti oggetto geometrico
else
pGdbNode = new( nothrow) GdbObj ;
pGdbObj = new( nothrow) GdbGeo ;
// verifico il nodo GDB
if ( pGdbNode == nullptr)
// verifico l'oggetto GDB
if ( pGdbObj == nullptr)
return false ;
// se lettura dati e inserimento nel DB vanno bene
if ( pGdbNode->Load( sType, TheScanner, nParentId) &&
AddToGeomDB( pGdbNode, nParentId))
if ( pGdbObj->Load( sType, TheScanner, nParentId) &&
AddToGeomDB( pGdbObj, nParentId))
return true ;
// altrimenti errore
else {
delete pGdbNode ;
delete pGdbObj ;
return false ;
}
}
@@ -190,15 +193,15 @@ GeomDB::Save( const std::string& sFileOut) const
// intestazione
ofSave << "START" << endl ;
ofSave << "GeomDB,1.4a4" << endl ;
ofSave << "GeomDB,1.5c1" << endl ;
// ciclo di scrittura degli oggetti
bool bOk = true ;
const GdbNode* pGdbNode = m_GrpRadix.GetFirstNode() ;
while ( pGdbNode != nullptr) {
const GdbObj* pGdbObj = m_GrpRadix.GetFirstObj() ;
while ( pGdbObj != nullptr) {
// oggetto geometrico
if ( ! pGdbNode->Save( ofSave))
if ( ! pGdbObj->Save( ofSave))
bOk = false ;
pGdbNode = pGdbNode->GetNext() ;
pGdbObj = pGdbObj->GetNext() ;
}
ofSave << "END" << endl ;
@@ -210,14 +213,14 @@ GeomDB::Save( const std::string& sFileOut) const
//----------------------------------------------------------------------------
bool
GeomDB::ExistsNode( int nId) const
GeomDB::ExistsObj( int nId) const
{
return ( (const_cast<GeomDB*>(this))->GetGdbNode(nId) != nullptr) ;
return ( (const_cast<GeomDB*>(this))->GetGdbObj( nId) != nullptr) ;
}
//----------------------------------------------------------------------------
GdbNode*
GeomDB::GetGdbNode( int nId)
GdbObj*
GeomDB::GetGdbObj( int nId)
{
// impossibile
if ( nId < GDB_ID_ROOT)
@@ -227,19 +230,19 @@ GeomDB::GetGdbNode( int nId)
return &m_GrpRadix ;
// un nodo qualubque
else
return m_IdManager.FindNode( nId) ;
return m_IdManager.FindObj( nId) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::AddToGeomDB( GdbNode* pGNode, int nParentId)
GeomDB::AddToGeomDB( GdbObj* pGObj, int nParentId)
{
// verifico validità oggetto puntato
if ( pGNode == nullptr)
if ( pGObj == nullptr)
return false ;
// verifica validità e unicità del nome
if ( pGNode->m_nId <= GDB_ID_ROOT || ExistsNode( pGNode->m_nId))
if ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId))
return false ;
// cerco il padre
@@ -247,14 +250,14 @@ GeomDB::AddToGeomDB( GdbNode* pGNode, int nParentId)
if ( pGroup == nullptr)
return false ;
// inserisco in coda alla lista del padre
if ( ! pGNode->AddTail( pGroup))
if ( ! pGObj->AddTail( pGroup))
return false ;
// aggiorno gestore Id
m_IdManager.UpdateMaxId( pGNode->m_nId) ;
m_IdManager.UpdateMaxId( pGObj->m_nId) ;
// inserisco in mappa nomi
return m_IdManager.AddNode( pGNode->m_nId, pGNode) ;
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
}
//----------------------------------------------------------------------------
@@ -270,7 +273,7 @@ GeomDB::AddGroup( int nId, int nParentId, const Frame3d& frFrame)
// verifico validità Id
if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ;
if ( ExistsNode( nId))
if ( ExistsObj( nId))
return GDB_ID_NULL ;
// alloco gruppo Gdb
pGdbGroup = new(nothrow) GdbGroup ;
@@ -293,7 +296,7 @@ GeomDB::AddGroup( int nId, int nParentId, const Frame3d& frFrame)
int
GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
{
GdbObj* pGdbObj ;
GdbGeo* pGdbGeo ;
// assegno GeoObj a gestore puntatore con rilascio automatico
@@ -301,22 +304,22 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
// verifico validità identificativo
if ( nId <= GDB_ID_ROOT)
nId = m_IdManager.GetNewId() ;
if ( ExistsNode( nId))
if ( ExistsObj( nId))
return GDB_ID_NULL ;
// verifico validità oggetto Geo
if ( ! IsValid( pRPGeoObj) || ! pRPGeoObj->IsValid())
return GDB_ID_NULL ;
// alloco oggetto Gdb
pGdbObj = new(nothrow) GdbObj ;
if ( pGdbObj == nullptr)
pGdbGeo = new(nothrow) GdbGeo ;
if ( pGdbGeo == nullptr)
return GDB_ID_NULL ;
// assegno identificativo
pGdbObj->m_nId = nId ;
pGdbGeo->m_nId = nId ;
// assegno dati
pGdbObj->m_pGeoObj = Release( pRPGeoObj) ;
pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ;
// inserisco nel DB
if ( ! AddToGeomDB( pGdbObj, nParentId)) {
delete pGdbObj ;
if ( ! AddToGeomDB( pGdbGeo, nParentId)) {
delete pGdbGeo ;
return GDB_ID_NULL ;
}
@@ -327,18 +330,18 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
GdbType
GeomDB::GetGdbType( int nId) const
{
const GdbNode* pGdbNode ;
const GdbObj* pGdbObj ;
// recupero il nodo
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr)
// recupero l'oggetto
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return GDB_NONE ;
// se oggetto geometrico
if ( ::GetGdbObj( pGdbNode) != nullptr)
if ( ::GetGdbGeo( pGdbObj) != nullptr)
return GDB_GEO ;
// se gruppo
else if ( ::GetGdbGroup( pGdbNode) != nullptr)
else if ( ::GetGdbGroup( pGdbObj) != nullptr)
return GDB_GROUP ;
// altro
else
@@ -349,25 +352,21 @@ GeomDB::GetGdbType( int nId) const
IGeoObj*
GeomDB::GetGeoObj( int nId)
{
const GdbObj* pGdbObj ;
// recupero l'oggetto Gdb
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
const GdbGeo* pGdbGeo ;
if ( ( pGdbGeo = GetGdbGeo( nId)) == nullptr)
return nullptr ;
// restituisco il suo contenuto geometrico
return pGdbObj->m_pGeoObj ;
return pGdbGeo->m_pGeoObj ;
}
//----------------------------------------------------------------------------
IGeoFrame3d*
GeomDB::GetGeoFrame( int nId)
{
GdbGroup* pGdbGroup ;
// recupero il gruppo Gdb
GdbGroup* pGdbGroup ;
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
return nullptr ;
@@ -404,7 +403,7 @@ GeomDB::GetGroupGlobFrame( int nId, Frame3d& frGlob) const
//----------------------------------------------------------------------------
int
GeomDB::GetGroupNodes( int nId) const
GeomDB::GetGroupObjs( int nId) const
{
// recupero il gruppo Gdb
const GdbGroup* pGdbGroup ;
@@ -412,35 +411,35 @@ GeomDB::GetGroupNodes( int nId) const
return 0 ;
// restituisco il numero di nodi (figli)
return pGdbGroup->GetNodeCount() ;
return pGdbGroup->GetObjCount() ;
}
//----------------------------------------------------------------------------
int
GeomDB::GetParentId( int nId) const
{
// recupero il nodo Gdb
const GdbNode* pGdbNode ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr)
// recupero l'oggetto Gdb
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return GDB_ID_NULL ;
// restituisco l'Id del padre
return pGdbNode->GetParentId() ;
return pGdbObj->GetParentId() ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetLocalBBox( int nId, BBox3d& b3Loc) const
{
const GdbNode* pGdbNode ;
const GdbObj* pGdbObj ;
// recupero l'oggetto
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr)
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ;
// eseguo l'operazione
return pGdbNode->GetLocalBBox( b3Loc) ;
return pGdbObj->GetLocalBBox( b3Loc) ;
}
//----------------------------------------------------------------------------
@@ -448,17 +447,17 @@ bool
GeomDB::GetGlobalBBox( int nId, BBox3d& b3Glob) const
{
// recupero l'oggetto
const GdbNode* pGdbNode ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr)
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ;
if ( ! GetGroupGlobFrame( pGdbNode->GetParentId(), frGlob))
if ( ! GetGroupGlobFrame( pGdbObj->GetParentId(), frGlob))
return false ;
// eseguo l'operazione
return pGdbNode->GetBBox( frGlob, b3Glob) ;
return pGdbObj->GetBBox( frGlob, b3Glob) ;
}
//----------------------------------------------------------------------------
@@ -466,20 +465,20 @@ bool
GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref) const
{
// recupero l'oggetto
const GdbNode* pGdbNode ;
if ( ( pGdbNode = (const_cast<GeomDB*> (this))->GetGdbNode( nId)) == nullptr)
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*> (this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ;
if ( ! GetGroupGlobFrame( pGdbNode->GetParentId(), frGlob))
if ( ! GetGroupGlobFrame( pGdbObj->GetParentId(), frGlob))
return false ;
// lo porto nel riferimento passato
frGlob.ToLoc( frRef) ;
// eseguo l'operazione
return pGdbNode->GetBBox( frGlob, b3Ref) ;
return pGdbObj->GetBBox( frGlob, b3Ref) ;
}
//----------------------------------------------------------------------------
@@ -489,22 +488,22 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nParentIdDest)
// verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ;
if ( ExistsNode( nIdDest))
if ( ExistsObj( nIdDest))
return GDB_ID_NULL ;
// verifico esistenza del sorgente
GdbNode* pGdNSou ;
if ( ( pGdNSou = GetGdbNode( nIdSou)) == nullptr)
GdbObj* pGdOSou ;
if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
return GDB_ID_NULL ;
// eseguo la copia
GdbNode* pGdNDest ;
if ( ( pGdNDest = pGdNSou->Clone( nIdDest, m_IdManager)) == nullptr)
GdbObj* pGdODest ;
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
return GDB_ID_NULL ;
// inserisco nel DB
if ( ! AddToGeomDB( pGdNDest, nParentIdDest)) {
delete pGdNDest ;
if ( ! AddToGeomDB( pGdODest, nParentIdDest)) {
delete pGdODest ;
return GDB_ID_NULL ;
}
@@ -518,12 +517,12 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
// verifico Id destinazione
if ( nIdDest <= GDB_ID_ROOT)
nIdDest = m_IdManager.GetNewId() ;
if ( ExistsNode( nIdDest))
if ( ExistsObj( nIdDest))
return GDB_ID_NULL ;
// verifico esistenza del sorgente
GdbNode* pGdNSou ;
if ( ( pGdNSou = GetGdbNode( nIdSou)) == nullptr)
GdbObj* pGdOSou ;
if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento del sorgente
@@ -537,19 +536,19 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
return false ;
// eseguo la copia
GdbNode* pGdNDest ;
if ( ( pGdNDest = pGdNSou->Clone( nIdDest, m_IdManager)) == nullptr)
GdbObj* pGdODest ;
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
return GDB_ID_NULL ;
// porto la copia da riferimento sorgente a quello destinazione
if ( ! AreSameFrame( frSou, frDest)) {
pGdNDest->ToGlob( frSou) ;
pGdNDest->ToLoc( frDest) ;
pGdODest->ToGlob( frSou) ;
pGdODest->ToLoc( frDest) ;
}
// inserisco nel DB
if ( ! AddToGeomDB( pGdNDest, nParentIdDest)) {
delete pGdNDest ;
if ( ! AddToGeomDB( pGdODest, nParentIdDest)) {
delete pGdODest ;
return GDB_ID_NULL ;
}
@@ -560,8 +559,8 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
bool
GeomDB::Erase( int nId)
{
INTPGDBN_UMAP::const_iterator Iter ;
GdbNode* pGdbNode ;
INTPGDBO_UMAP::const_iterator Iter ;
GdbObj* pGdbObj ;
// non si può cancellare il gruppo radice (escludo anche Id non validi)
@@ -569,18 +568,18 @@ GeomDB::Erase( int nId)
return false ;
// recupero l'oggetto
pGdbNode = m_IdManager.FindNode( nId) ;
if ( pGdbNode == nullptr)
pGdbObj = m_IdManager.FindObj( nId) ;
if ( pGdbObj == nullptr)
return false ;
// elimino da mappa dei nomi
m_IdManager.RemoveNode( nId) ;
m_IdManager.RemoveObj( nId) ;
// lo tolgo dalla lista
pGdbNode->Remove() ;
pGdbObj->Remove() ;
// lo disalloco (distruttore virtuale)
delete pGdbNode ;
delete pGdbObj ;
return true ;
}
@@ -590,11 +589,11 @@ bool
GeomDB::Translate( int nId, const Vector3d& vtMove)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// eseguo la traslazione
return pGdbNode->Translate( vtMove) ;
return pGdbObj->Translate( vtMove) ;
}
//----------------------------------------------------------------------------
@@ -602,8 +601,8 @@ bool
GeomDB::TranslateGlob( int nId, const Vector3d& vtMove)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frObj ;
@@ -614,7 +613,7 @@ GeomDB::TranslateGlob( int nId, const Vector3d& vtMove)
if ( ! vtMoveLoc.ToLoc( frObj))
return false ;
// eseguo la traslazione
return pGdbNode->Translate( vtMoveLoc) ;
return pGdbObj->Translate( vtMoveLoc) ;
}
//----------------------------------------------------------------------------
@@ -622,11 +621,11 @@ bool
GeomDB::Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// eseguo la rotazione
return pGdbNode->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
return pGdbObj->Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
@@ -634,8 +633,8 @@ bool
GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frObj ;
@@ -649,7 +648,7 @@ GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double d
if ( ! vtAxLoc.ToLoc( frObj))
return false ;
// eseguo la rotazione
return pGdbNode->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ;
return pGdbObj->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ;
}
//----------------------------------------------------------------------------
@@ -657,11 +656,11 @@ bool
GeomDB::Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// eseguo la scalatura
return pGdbNode->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
return pGdbObj->Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
}
//----------------------------------------------------------------------------
@@ -669,8 +668,8 @@ bool
GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frObj ;
@@ -681,7 +680,7 @@ GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY
if ( ! frRefLoc.ToLoc( frObj))
return false ;
// eseguo la scalatura
return pGdbNode->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ;
return pGdbObj->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ;
}
//----------------------------------------------------------------------------
@@ -689,11 +688,11 @@ bool
GeomDB::Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// eseguo l'operazione
return pGdbNode->Mirror( ptOn, vtNorm) ;
return pGdbObj->Mirror( ptOn, vtNorm) ;
}
//----------------------------------------------------------------------------
@@ -701,8 +700,8 @@ bool
GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
{
// recupero l'oggetto
GdbNode* pGdbNode ;
if ( ( pGdbNode = GetGdbNode( nId)) == nullptr)
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// recupero il riferimento in cui è immerso
Frame3d frObj ;
@@ -716,5 +715,64 @@ GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
if ( ! vtNormLoc.ToLoc( frObj))
return false ;
// eseguo l'operazione
return pGdbNode->Mirror( ptOnLoc, vtNormLoc) ;
return pGdbObj->Mirror( ptOnLoc, vtNormLoc) ;
}
//----------------------------------------------------------------------------
// Attributes
//----------------------------------------------------------------------------
bool
GeomDB::DumpAttributes( int nId, string& sOut, const char* szNewLine) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// eseguo il dump
if ( pGdbObj->m_pAttribs != nullptr)
return pGdbObj->m_pAttribs->Dump( sOut, szNewLine) ;
else {
Attribs attr ;
return attr.Dump( sOut, szNewLine) ;
}
}
//----------------------------------------------------------------------------
bool
GeomDB::SetDefaultColor( Color cCol)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( GDB_ID_ROOT)) == nullptr)
return false ;
// assegno il colore
return pGdbObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::SetColor( int nId, Color cCol)
{
// recupero l'oggetto
GdbObj* pGdbObj ;
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
return false ;
// assegno il colore
return pGdbObj->SetColor( cCol) ;
}
//----------------------------------------------------------------------------
bool
GeomDB::GetColor( int nId, Color& cCol) const
{
// recupero l'oggetto
const GdbObj* pGdbObj ;
if ( ( pGdbObj = (const_cast<GeomDB*>(this))->GetGdbObj( nId)) == nullptr)
return false ;
// recupero il colore
return pGdbObj->GetColor( cCol) ;
}
+22 -16
View File
@@ -13,7 +13,7 @@
#pragma once
#include "GdbObj.h"
#include "GdbGeo.h"
#include "GdbGroup.h"
#include "IdManager.h"
#include "/EgtDev/Include/EGkGeomDB.h"
@@ -34,7 +34,7 @@ class GeomDB : public IGeomDB
virtual bool Clear( void) ;
virtual bool Load( const std::string& sFileIn) ;
virtual bool Save( const std::string& sFileOut) const ;
virtual bool ExistsNode( int nId) const ;
virtual bool ExistsObj( int nId) const ;
virtual int AddGroup( int nId, int nParentId, const Frame3d& frFrame) ;
virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ;
virtual GdbType GetGdbType( int nId) const ;
@@ -42,7 +42,7 @@ class GeomDB : public IGeomDB
virtual IGeoFrame3d* GetGeoFrame( int nId) ;
virtual bool GetGroupFrame( int nId, Frame3d& frGrp) const ;
virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) const ;
virtual int GetGroupNodes( int nId) const ;
virtual int GetGroupObjs( int nId) const ;
virtual int GetParentId( int nId) const ;
virtual bool GetGlobFrame( int nId, Frame3d& frGlob) const
{ return GetGroupGlobFrame( GetParentId( nId), frGlob) ; }
@@ -66,17 +66,23 @@ class GeomDB : public IGeomDB
virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool DumpAttributes( int nId, std::string& sOut, const char* szNewLine) const ;
virtual bool SetDefaultColor( Color cCol) ;
virtual bool SetColor( int nId, Color cCol) ;
virtual bool GetColor( int nId, Color& cCol) const ;
public :
GeomDB( void) ;
private :
GdbNode* GetGdbNode( int nId) ;
GdbObj* GetGdbObj( int nId) { return dynamic_cast<GdbObj*>( GetGdbNode( nId)) ; }
GdbGroup* GetGdbGroup( int nId) { return dynamic_cast<GdbGroup*>( GetGdbNode( nId)) ; }
bool AddToGeomDB( GdbNode* pGNode, int nParentId) ;
GdbObj* GetGdbObj( int nId) ;
GdbGeo* GetGdbGeo( int nId)
{ return dynamic_cast<GdbGeo*>( GetGdbObj( nId)) ; }
GdbGroup* GetGdbGroup( int nId)
{ return dynamic_cast<GdbGroup*>( GetGdbObj( nId)) ; }
bool AddToGeomDB( GdbObj* pGObj, int nParentId) ;
bool LoadStart( Scanner& TheScanner) ;
bool LoadOneNode( Scanner& TheScanner, bool& bEnd) ;
bool LoadOneObj( Scanner& TheScanner, bool& bEnd) ;
private :
GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB
@@ -84,11 +90,11 @@ class GeomDB : public IGeomDB
} ;
//----------------------------------------------------------------------------
inline const GdbObj* GetGdbObj( const GdbNode* pGNode)
{ return dynamic_cast<const GdbObj*>(pGNode) ; }
inline GdbObj* GetGdbObj( GdbNode* pGNode)
{ return dynamic_cast<GdbObj*>(pGNode) ; }
inline const GdbGroup* GetGdbGroup( const GdbNode* pGNode)
{ return dynamic_cast<const GdbGroup*>(pGNode) ; }
inline GdbGroup* GetGdbGroup( GdbNode* pGNode)
{ return dynamic_cast<GdbGroup*>(pGNode) ; }
inline const GdbGeo* GetGdbGeo( const GdbObj* pGObj)
{ return dynamic_cast<const GdbGeo*>(pGObj) ; }
inline GdbGeo* GetGdbGeo( GdbObj* pGObj)
{ return dynamic_cast<GdbGeo*>(pGObj) ; }
inline const GdbGroup* GetGdbGroup( const GdbObj* pGObj)
{ return dynamic_cast<const GdbGroup*>(pGObj) ; }
inline GdbGroup* GetGdbGroup( GdbObj* pGObj)
{ return dynamic_cast<GdbGroup*>(pGObj) ; }
+20 -13
View File
@@ -17,30 +17,37 @@
//----------------------------------------------------------------------------
typedef std::unordered_map< int, GdbNode*> INTPGDBN_UMAP ;
typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;
//----------------------------------------------------------------------------
class IdManager
{
public :
IdManager( void) { m_nMaxId = 0 ; }
bool Init( int nBuckets) { m_GdbIdMap.rehash( nBuckets) ; return true ; }
bool Clear( void) { m_GdbIdMap.clear() ; m_nMaxId = 0 ; return true ; }
GdbNode* FindNode( int nId)
{ INTPGDBN_UMAP::const_iterator Iter = m_GdbIdMap.find( nId) ;
IdManager( void)
{ m_nMaxId = 0 ; }
bool Init( int nBuckets)
{ m_GdbIdMap.rehash( nBuckets) ; return true ; }
bool Clear( void)
{ m_GdbIdMap.clear() ; m_nMaxId = 0 ; return true ; }
GdbObj* FindObj( int nId)
{ INTPGDBO_UMAP::const_iterator Iter = m_GdbIdMap.find( nId) ;
if ( Iter != m_GdbIdMap.end())
return Iter->second ;
else
return nullptr ; }
bool AddNode( int nId, GdbNode* pGNode)
{ return m_GdbIdMap.insert( std::pair< int, GdbNode*>( nId, pGNode)).second ; }
bool RemoveNode( int nId)
bool AddObj( int nId, GdbObj* pGObj)
{ if ( nId > m_nMaxId) m_nMaxId = nId ;
return m_GdbIdMap.insert( std::pair< int, GdbObj*>( nId, pGObj)).second ; }
bool RemoveObj( int nId)
{ m_GdbIdMap.erase( nId) ; return true ; }
int GetNewId( void) { return ++ m_nMaxId ; }
int GetMaxId( void) const { return m_nMaxId ; }
void UpdateMaxId( int nId) { if ( nId > m_nMaxId) m_nMaxId = nId ; }
int GetNewId( void)
{ return ( ++ m_nMaxId) ; }
int GetMaxId( void) const
{ return m_nMaxId ; }
void UpdateMaxId( int nId)
{ if ( nId > m_nMaxId) m_nMaxId = nId ; }
private :
int m_nMaxId ;
INTPGDBN_UMAP m_GdbIdMap ; // map basato sugli identificatori
INTPGDBO_UMAP m_GdbIdMap ; // map basato sugli identificatori
} ;
BIN
View File
Binary file not shown.