//---------------------------------------------------------------------------- // EgalTech 2013-2023 //---------------------------------------------------------------------------- // File : GeomDB.h Data : 09.07.23 Versione : 2.5g1 // 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" #include //---------------------------------------------------------------------------- class GeomDB : public IGeomDB { friend class GdbIterator ; friend class GdbObj ; friend class GdbGroup ; friend class GdbGeo ; friend int CopyGeoObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob) ; friend int CopyGroupObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob) ; friend int DuplicateGeoObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId) ; friend int DuplicateGroupObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, bool bSkipTemp) ; public : ~GeomDB( void) override ; bool Init( void) override ; bool Clear( void) override ; bool Load( const std::string& sFileIn, int nGroupId = GDB_ID_ROOT) override ; bool Save( int nId, const std::string& sFileOut, int nFlag = GDB_SV_BIN) const override ; bool Save( const INTVECTOR& vId, const std::string& sFileOut, int nFlag = GDB_SV_BIN) const override ; bool ExistsObj( int nId) const override ; int AddGroup( int nId, int nParentId, const Frame3d& frFrame) override ; int InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& frFrame) override ; int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) override ; int InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj) override ; bool ReplaceGeoObj( int nId, IGeoObj* pGeoObj) override ; int GetFirstInGroup( int nGroupId) const override ; int GetNext( int nId) const override ; int GetLastInGroup( int nGroupId) const override ; int GetPrev( int nId) const override ; int GetFirstNameInGroup( int nGroupId, const std::string& sName) const override ; int GetNextName( int nId, const std::string& sName) const override ; int GetLastNameInGroup( int nGroupId, const std::string& sName) const override ; int GetPrevName( int nId, const std::string& sName) const override ; int GetFirstGroupInGroup( int nGroupId) const override ; int GetNextGroup( int nId) const override ; int GetLastGroupInGroup( int nGroupId) const override ; int GetPrevGroup( int nId) const override ; int GetGdbType( int nId) const override ; int GetGeoType( int nId) const override ; IGeoObj* GetGeoObj( int nId) override ; const IGeoObj* GetGeoObj( int nId) const override ; Frame3d* GetGroupFrame( int nId) override ; const Frame3d* GetGroupFrame( int nId) const override ; bool GetGroupFrame( int nId, Frame3d& frGrp) const override ; bool GetGroupGlobFrame( int nId, Frame3d& frGlob) const override ; int GetGroupObjs( int nId) const override ; int GetParentId( int nId) const override ; bool GetGlobFrame( int nId, Frame3d& frGlob) const override { return GetGroupGlobFrame( GetParentId( nId), frGlob) ; } bool GetLocalBBox( int nId, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ; bool GetGlobalBBox( int nId, BBox3d& b3Glob, int nFlag = BBF_STANDARD) const override ; bool GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ; int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) override { return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, false) ; } int CopyGlob( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) override { return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, true) ; } bool Relocate( int nId, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) override { return Relocate( nId, nRefId, nSonBeforeAfter, false) ; } bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) override { return Relocate( nId, nRefId, nSonBeforeAfter, true) ; } bool GroupSwap( int nId1, int nId2, bool bSwapRef, bool bMark = false) override ; int GetNewId( void) const override ; bool ChangeId( int nId, int nNewId) override ; bool Erase( int nId) override ; IGeoObj* RemoveGeoObjAndErase( int nId) override ; bool EmptyGroup( int nId) override ; // Transformations bool Translate( int nId, const Vector3d& vtMove) override ; bool TranslateGlob( int nId, const Vector3d& vtMove) override ; bool TranslateGroup( int nId, const Vector3d& vtMove) override ; bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) override { double dAngRad = dAngDeg * DEGTORAD ; return Rotate( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) override ; bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) override { double dAngRad = dAngDeg * DEGTORAD ; return RotateGlob( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) override ; bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) override { double dAngRad = dAngDeg * DEGTORAD ; return RotateGroup( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) override ; bool Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) override ; bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) override ; bool ScaleGroup( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) override ; bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) override ; bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) override ; bool MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm) override ; bool Shear( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) override ; bool ShearGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) override ; bool ShearGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) override ; // Selection bool SelectObj( int nId, bool bOnlyIfVisible = false) override ; bool DeselectObj( int nId) override ; bool SelectGroupObjs( int nId, int nFilter = 0, bool bOnlyIfVisible = false) override ; bool DeselectGroupObjs( int nId) override ; bool IsSelectedObj( int nId) const override ; int GetSelectedObjNbr( void) const override ; int GetFirstSelectedObj( void) const override ; int GetNextSelectedObj( void) const override ; int GetLastSelectedObj( void) const override ; int GetPrevSelectedObj( void) const override ; bool ClearSelection( void) override ; // Attributes bool DumpAttributes( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool CopyAttributes( int nIdSou, int nIdDest) override ; bool SetLevel( int nId, int nLevel) override ; bool RevertLevel( int nId) override ; bool GetLevel( int nId, int& nLevel) const override ; bool GetCalcLevel( int nId, int& nLevel) const override ; bool SetMode( int nId, int nMode) override ; bool RevertMode( int nId) override ; bool GetMode( int nId, int& nMode) const override ; bool GetCalcMode( int nId, int& nMode) const override ; bool SetStatus( int nId, int nStat) override ; bool RevertStatus( int nId) override ; bool GetStatus( int nId, int& nStat) const override ; bool GetCalcStatus( int nId, int& nStat) const override ; bool SetMark( int nId, int nMark = GDB_MK_ON) override ; bool ResetMark( int nId) override ; bool GetMark( int nId, int& nMark) const override ; bool GetCalcMark( int nId, int& nMark) const override ; bool CopyMaterial( int nIdSou, int nIdDest) override ; bool SetDefaultMaterial( Color cCol) override ; bool GetDefaultMaterial( Color& cCol) const override ; bool SetMaterial( int nId, int nMat) override ; bool SetMaterial( int nId, const std::string& sMatName) override ; bool SetMaterial( int nId, Color cCol) override ; bool GetMaterial( int nId, int& nMat) const override ; bool GetMaterial( int nId, Material& mMat) const override ; bool GetMaterial( int nId, Color& cCol) const override ; bool GetCalcMaterial( int nId, int& nMat) const override ; bool GetCalcMaterial( int nId, Material& mMat) const override ; bool GetCalcMaterial( int nId, Color& cCol) const override ; bool SetName( int nId, const std::string& sName) override ; bool GetName( int nId, std::string& sName) const override ; bool ExistsName( int nId) const override ; bool RemoveName( int nId) override ; bool SetInfo( int nId, const std::string& sKey, const std::string& sInfo) override ; bool SetInfo( int nId, const std::string& sKey, bool bInfo) override ; bool SetInfo( int nId, const std::string& sKey, int nInfo) override ; bool SetInfo( int nId, const std::string& sKey, double dInfo) override ; bool SetInfo( int nId, const std::string& sKey, const Point3d& ptInfo) override ; bool SetInfo( int nId, const std::string& sKey, const Vector3d& vtInfo) override ; bool SetInfo( int nId, const std::string& sKey, const BBox3d& b3Info) override ; bool SetInfo( int nId, const std::string& sKey, const Frame3d& frInfo) override ; bool SetInfo( int nId, const std::string& sKey, const INTVECTOR& vnInfo) override ; bool SetInfo( int nId, const std::string& sKey, const DBLVECTOR& vdInfo) override ; bool SetInfo( int nId, const std::string& sKey, const STRVECTOR& vsInfo) override ; bool GetInfo( int nId, const std::string& sKey, std::string& sInfo) const override ; bool GetInfo( int nId, const std::string& sKey, bool& bInfo) const override ; bool GetInfo( int nId, const std::string& sKey, int& nInfo) const override ; bool GetInfo( int nId, const std::string& sKey, double& dInfo) const override ; bool GetInfo( int nId, const std::string& sKey, Point3d& ptInfo) const override ; bool GetInfo( int nId, const std::string& sKey, Vector3d& vtInfo) const override ; bool GetInfo( int nId, const std::string& sKey, BBox3d& b3Info) const override ; bool GetInfo( int nId, const std::string& sKey, Frame3d& frInfo) const override ; bool GetInfo( int nId, const std::string& sKey, INTVECTOR& vnInfo) const override ; bool GetInfo( int nId, const std::string& sKey, DBLVECTOR& vdInfo) const override ; bool GetInfo( int nId, const std::string& sKey, STRVECTOR& vsInfo) const override ; bool ExistsInfo( int nId, const std::string& sKey) const override ; bool RemoveInfo( int nId, const std::string& sKey) override ; bool GetAllInfo( int nId, STRVECTOR& vsInfo) const override ; bool CopyAllInfoFrom( int nId, int nSouId) override ; // Stipple (significativo solo per curve) bool DumpStipple( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool SetStipple( int nId, int nFactor, int nPattern) override ; bool GetStipple( int nId, int& nFactor, int& nPattern) const override ; // TextureData bool DumpTextureData( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool SetTextureName( int nId, const std::string& sTxrName) override ; bool SetTextureFrame( int nId, const Frame3d& frTxrRef) override ; bool RemoveTextureData( int nId) override ; bool GetTextureName( int nId, std::string& sTxrName) const override ; bool GetTextureFrame( int nId, Frame3d& frTxrRef) const override ; // UserObj bool SetUserObj( int nId, IUserObj* pUserObj) override ; IUserObj* GetUserObj( int nId) override ; const IUserObj* GetUserObj( int nId) const override ; bool DumpUserObj( int nId, std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool CopyUserObj( int nIdSou, int nIdDest) override ; bool RemoveUserObj( int nId) override ; // Material library int AddMaterial( const std::string& sName, const Material& matM) override ; int FindMaterial( const std::string& sName) const override ; bool EraseMaterial( int nMat, bool& bInUse) override ; bool GetMaterialData( int nMat, Material& matM) const override ; bool GetMaterialName( int nMat, std::string& sName) const override ; int GetMaxMaterialId( void) const override ; bool ExistsMaterial( int nMat) const override ; bool IsCustomMaterial( int nMat, bool& bCustom) const override ; bool ModifyMaterialData( int nMat, const Material& matM) override ; bool ModifyMaterialName( int nMat, const std::string& sName) override ; // Grid bool SetGridFrame( const Frame3d& frFrame) override { if ( ! frFrame.IsValid()) return false ; m_GridFrame = frFrame ; return true ; } const Frame3d& GetGridFrame( void) override { return m_GridFrame ; } public : GeomDB( void) ; private : GdbObj* GetGdbObj( int nId) ; const GdbObj* GetGdbObj( int nId) const ; GdbGeo* GetGdbGeo( int nId) { return ::GetGdbGeo( GetGdbObj( nId)) ; } const GdbGeo* GetGdbGeo( int nId) const { return ::GetGdbGeo( GetGdbObj( nId)) ; } GdbGroup* GetGdbGroup( int nId) { return ::GetGdbGroup( GetGdbObj( nId)) ; } const GdbGroup* GetGdbGroup( int nId) const { return ::GetGdbGroup( GetGdbObj( nId)) ; } bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bLockAddErase = true, 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 EmptyGroup( GdbObj* pGdbObj) ; bool LoadHeader( NgeReader& ngeIn, bool bSave) ; bool LoadOneObj( NgeReader& ngeIn, int nGroupId, int nBaseGdbId, const INTVECTOR& vBaseMatId, bool& bEnd) ; bool SaveGroupHierarchy( const GdbGroup* pGdbGroup, int nBaseId, NgeWriter& ngeOut, INTUNORDSET* pSavedIds = nullptr) const ; bool SaveHeader( NgeWriter& ngeOut) const ; bool SaveFooter( NgeWriter& ngeOut) const ; bool SetStatus( GdbObj* pGdbObj, int nStat) ; bool RevertStatus( GdbObj* pGdbObj, bool bOkSel = true) ; 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 Frame3d m_GridFrame ; // riferimento della griglia std::atomic_flag m_bAddEraseOn ; // flag esecuzione inserimento o cancellazione in corso (per multi thread) } ;