Files
EgtGeomKernel/GeomDB.h
T
Dario Sassi dd0496d5eb EgtGeomKernel 1.5j6 :
- corretta e migliorata gestione ID delle entità.
2014-10-30 08:48:08 +00:00

212 lines
12 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GeomDB.h Data : 08.04.13 Versione : 1.1c1
// Contenuto : Dichiarazione della classe GeomDB.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "GdbGeo.h"
#include "GdbGroup.h"
#include "IdManager.h"
#include "IterManager.h"
#include "SelManager.h"
#include "GdbMaterialMgr.h"
#include "/EgtDev/Include/EGkGeomDB.h"
//----------------------------------------------------------------------------
class GeomDB : public IGeomDB
{
friend class GdbIterator ;
friend class GdbObj ;
friend class GdbGroup ;
friend class GdbGeo ;
public :
virtual ~GeomDB( void) ;
virtual bool Init( void) ;
virtual bool Clear( void) ;
virtual bool Load( const std::string& sFileIn) ;
virtual bool Save( const std::string& sFileOut, int nFlag = GDB_SV_BIN) const ;
virtual bool ExistsObj( int nId) const ;
virtual int AddGroup( int nId, int nParentId, const Frame3d& frFrame) ;
virtual int InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& frFrame) ;
virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ;
virtual int InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj) ;
virtual int GetFirstInGroup( int nIdGroup) const ;
virtual int GetNext( int nId) const ;
virtual int GetLastInGroup( int nIdGroup) const ;
virtual int GetPrev( int nId) const ;
virtual int GetFirstGroupInGroup( int nIdGroup) const ;
virtual int GetNextGroup( int nId) const ;
virtual int GetLastGroupInGroup( int nIdGroup) const ;
virtual int GetPrevGroup( int nId) const ;
virtual int GetGdbType( int nId) const ;
virtual IGeoObj* GetGeoObj( int nId) ;
virtual const IGeoObj* GetGeoObj( int nId) const ;
virtual Frame3d* GetGroupFrame( int nId) ;
virtual const Frame3d* GetGroupFrame( int nId) const ;
virtual bool GetGroupFrame( int nId, Frame3d& frGrp) const ;
virtual bool GetGroupGlobFrame( int nId, Frame3d& frGlob) 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) ; }
virtual bool GetLocalBBox( int nId, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const ;
virtual bool GetGlobalBBox( int nId, BBox3d& b3Glob, int nFlag = BBF_STANDARD) const ;
virtual bool GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const ;
virtual int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON)
{ return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, false) ; }
virtual int CopyGlob( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON)
{ return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, true) ; }
virtual bool Relocate( int nId, int nRefId, int nSonBeforeAfter = GDB_SON)
{ return Relocate( nId, nRefId, nSonBeforeAfter, false) ; }
virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_SON)
{ return Relocate( nId, nRefId, nSonBeforeAfter, true) ; }
virtual bool Erase( int nId) ;
virtual bool Translate( int nId, const Vector3d& vtMove) ;
virtual bool TranslateGlob( int nId, const Vector3d& vtMove) ;
virtual bool TranslateGroup( int nId, const Vector3d& vtMove) ;
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return Rotate( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return RotateGlob( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
{ double dAngRad = dAngDeg * DEGTORAD ;
return RotateGroup( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
virtual bool Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
virtual bool ScaleGroup( 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 MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
virtual bool Shear( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
virtual bool ShearGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
virtual bool ShearGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
// selection
virtual bool SelectObj( int nId) ;
virtual bool DeselectObj( int nId) ;
virtual bool SelectGroupObjs( int nId, int nFilter = 0) ;
virtual bool DeselectGroupObjs( int nId) ;
virtual bool IsSelectedObj( int nId) const ;
virtual int GetSelectedObjNbr( void) const ;
virtual int GetFirstSelectedObj( void) const ;
virtual int GetNextSelectedObj( void) const ;
virtual bool ClearSelection( void) ;
// attributes
virtual bool DumpAttributes( int nId, std::string& sOut, const char* szNewLine) const ;
virtual bool SetLevel( int nId, int nLevel) ;
virtual bool RevertLevel( int nId) ;
virtual bool GetLevel( int nId, int& nLevel) const ;
virtual bool GetCalcLevel( int nId, int& nLevel) const ;
virtual bool SetMode( int nId, int nMode) ;
virtual bool RevertMode( int nId) ;
virtual bool GetMode( int nId, int& nMode) const ;
virtual bool GetCalcMode( int nId, int& nMode) const ;
virtual bool SetStatus( int nId, int nStat) ;
virtual bool RevertStatus( int nId) ;
virtual bool GetStatus( int nId, int& nStat) const ;
virtual bool GetCalcStatus( int nId, int& nStat) const ;
virtual bool SetMark( int nId) ;
virtual bool ResetMark( int nId) ;
virtual bool GetMark( int nId, int& nMark) const ;
virtual bool GetCalcMark( int nId, int& nMark) const ;
virtual bool SetDefaultMaterial( Color cCol) ;
virtual bool GetDefaultMaterial( Color& cCol) const ;
virtual bool SetMaterial( int nId, int nMat) ;
virtual bool SetMaterial( int nId, const std::string& sMatName) ;
virtual bool SetMaterial( int nId, Color cCol) ;
virtual bool GetMaterial( int nId, int& nMat) const ;
virtual bool GetMaterial( int nId, Material& mMat) const ;
virtual bool GetMaterial( int nId, Color& cCol) const ;
virtual bool GetCalcMaterial( int nId, int& nMat) const ;
virtual bool GetCalcMaterial( int nId, Material& mMat) const ;
virtual bool GetCalcMaterial( int nId, Color& cCol) const ;
virtual bool SetName( int nId, const std::string& sName) ;
virtual bool GetName( int nId, std::string& sName) const ;
virtual bool ExistsName( int nId) const ;
virtual bool RemoveName( int nId) ;
virtual bool SetInfo( int nId, const std::string& sKey, const std::string& sInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, bool bInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, int nInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, double dInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, const Point3d& ptInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, const Vector3d& vtInfo) ;
virtual bool SetInfo( int nId, const std::string& sKey, const Frame3d& frInfo) ;
virtual bool GetInfo( int nId, const std::string& sKey, std::string& sInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, bool& bInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, int& nInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, double& dInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, Point3d& ptInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, Vector3d& vtInfo) const ;
virtual bool GetInfo( int nId, const std::string& sKey, Frame3d& frInfo) const ;
virtual bool ExistsInfo( int nId, const std::string& sKey) const ;
virtual bool RemoveInfo( int nId, const std::string& sKey) ;
// material library
virtual int AddMaterial( const std::string& sName, const Material& matM) ;
virtual int FindMaterial( const std::string& sName) const ;
virtual bool EraseMaterial( int nMat, bool& bInUse) ;
virtual bool GetMaterialData( int nMat, Material& matM) const ;
virtual bool GetMaterialName( int nMat, std::string& sName) const ;
virtual int GetMaxMaterialId( void) const ;
virtual bool ExistsMaterial( int nMat) const ;
virtual bool IsCustomMaterial( int nMat, bool& bCustom) const ;
virtual bool ModifyMaterialData( int nMat, const Material& matM) ;
virtual bool ModifyMaterialName( int nMat, const std::string& sName) ;
public :
GeomDB( void) ;
private :
GdbObj* GetGdbObj( int nId) ;
const GdbObj* GetGdbObj( int nId) const ;
GdbGeo* GetGdbGeo( int nId)
{ return dynamic_cast<GdbGeo*>( GetGdbObj( nId)) ; }
const GdbGeo* GetGdbGeo( int nId) const
{ return dynamic_cast<const GdbGeo*>( GetGdbObj( nId)) ; }
GdbGroup* GetGdbGroup( int nId)
{ return dynamic_cast<GdbGroup*>( GetGdbObj( nId)) ; }
const GdbGroup* GetGdbGroup( int nId) const
{ return dynamic_cast<const GdbGroup*>( GetGdbObj( nId)) ; }
bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId = true) ;
int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob) ;
bool Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) ;
bool Erase( GdbObj* pGObj) ;
bool LoadHeader( NgeReader& ngeIn) ;
bool LoadOneObj( NgeReader& ngeIn, bool& bEnd) ;
bool SaveHeader( NgeWriter& ngeOut) const ;
bool SaveFooter( NgeWriter& ngeOut) const ;
bool SetStatus( GdbObj* pGdbObj, int nStat) ;
bool RevertStatus( GdbObj* pGdbObj) ;
bool SetMaterial( GdbObj* pGdbObj, int nMat) ;
bool SetMaterial( GdbObj* pGdbObj, const std::string& sMatName) ;
bool GetMaterial( const GdbObj* pGdbObj, Material& mMat) const ;
bool GetCalcMaterial( const GdbObj* pGdbObj, Material& mMat) const ;
bool UsedMaterialInGroup( int nMat, const GdbGroup* pGdbGroup) const ;
bool NotifyObjectsWithMaterialInGroup( int nMat, Color cCol, bool bByParent, GdbGroup* pGdbGroup) ;
bool AddGdbIteratorToList( GdbIterator* pIter)
{ return m_IterManager.AddGdbIterator( pIter) ; }
bool RemoveGdbIteratorFromList( GdbIterator* pIter)
{ return m_IterManager.RemoveGdbIterator( pIter) ; }
private :
IdManager m_IdManager ; // gestore del nuovo Id
IterManager m_IterManager ; // gestore lista iteratori attivi
SelManager m_SelManager ; // gestore lista oggetti selezionati
GdbMaterialMgr m_MatManager ; // gestore lista materiali
GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB
} ;