//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : SurfFlatRegion.h Data : 05.08.15 Versione : 1.6h2 // Contenuto : Dichiarazione della classe Surface FlatRegion. // // // // Modifiche : 05.08.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include "ObjGraphicsMgr.h" #include "DllMain.h" #include "GeoObjRW.h" #include "SurfTriMesh.h" #include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include //---------------------------------------------------------------------------- class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW { public : // IGeoObj ~SurfFlatRegion( void) override ; SurfFlatRegion* Clone( void) const override ; GeoObjType GetType( void) const override ; bool IsValid( void) const override { return ( m_nStatus == OK) ; } const std::string& GetTitle( void) const override ; bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; bool GetLocalBBox( BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ; bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ; bool Translate( const Vector3d& vtMove) override ; bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) override { double dAngRad = dAngDeg * DEGTORAD ; return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) override ; bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) override ; bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) override ; bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) override ; bool ToGlob( const Frame3d& frRef) override ; bool ToLoc( const Frame3d& frRef) override ; bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) override ; void SetObjGraphics( IObjGraphics* pOGr) override { m_OGrMgr.SetObjGraphics( pOGr) ; } IObjGraphics* GetObjGraphics( void) override { return m_OGrMgr.GetObjGraphics() ; } const IObjGraphics* GetObjGraphics( void) const override { return m_OGrMgr.GetObjGraphics() ; } void SetTempProp( int nProp) override { m_nTempProp = nProp ; } int GetTempProp( void) override { return m_nTempProp ; } public : // ISurf bool IsSimple( void) const override { return true ; } bool IsClosed( void) const override { return false ; } bool GetArea( double& dArea) const override ; bool GetVolume( double& dVolume) const override { dVolume = 0 ; return ( m_nStatus == OK) ; } bool GetCentroid( Point3d& ptCen) const override ; bool Invert( void) override ; public : // ISurfFlatRegion bool CopyFrom( const IGeoObj* pGObjSrc) override ; bool Clear( void) override ; bool AddExtLoop( const ICurve& cCrv) override ; bool AddExtLoop( ICurve* pCrv) override ; bool AddIntLoop( const ICurve& cCrv) override ; bool AddIntLoop( ICurve* pCrv) override ; bool Add( const ISurfFlatRegion& Other) override ; bool Subtract( const ISurfFlatRegion& Other) override ; bool Intersect( const ISurfFlatRegion& Other) override ; bool Offset( double dDist, int nType) override ; const Vector3d& GetNormVersor( void) const override { return m_frF.VersZ() ; } int GetChunkCount( void) const override ; int GetLoopCount( int nChunk) const override ; ICurve* GetLoop( int nChunk, int nLoop) const override ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni) bool ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ; const ISurfTriMesh* GetAuxSurf( void) const override ; SurfFlatRegion* CloneChunk( int nChunk) const override ; bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ; bool GetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const override ; int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides public : // IGeoObjRW int GetNgeId( void) const override ; bool Save( NgeWriter& ngeOut) const override ; bool Load( NgeReader& ngeIn) override ; public : SurfFlatRegion( void) ; SurfFlatRegion( const SurfFlatRegion& stSrc) { if ( ! CopyFrom( stSrc)) LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy constructor error") } SurfFlatRegion& operator =( const SurfFlatRegion& stSrc) { if ( ! CopyFrom( stSrc)) LOG_ERROR( GetEGkLogger(), "SurfFlatRegion : copy error") return *this ; } friend class MyCDSimpleSurfFrMove ; private : enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; private : typedef std::deque PCRV_DEQUE ; private : bool CopyFrom( const SurfFlatRegion& clSrc) ; bool AddSimpleExtLoop( ICurve* pCrv) ; bool MyAddExtLoop( ICurve* pCrv) ; bool AddSimpleIntLoop( ICurve* pCrv) ; bool MyAddIntLoop( ICurve* pCrv) ; int GetIndFromChunkLoop( int nChunk, int nLoop) const ; bool GetChunkLoopFromInd( int nInd, int& nChunk, int& nLoop) const ; ICurve* GetMyLoop( int nInd) const ; // indice nel vettore di tutti i loop ICurve* GetMyLoop( int nChunk, int nLoop) const ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni) void ResetAuxSurf( void) const ; bool ConvertArcsToBezierCurves( void) ; bool MyGetCurveClassification( const ICurve& Crv, CRVCVECTOR& ccClass) const ; static bool MySelectCurves( const PCRV_DEQUE& vpLoop, const SurfFlatRegion& Other, int nType1, bool bInvert1, int nType2, bool bInvert2, PCRV_DEQUE& vpCurve) ; static bool MyChainCurves( PCRV_DEQUE& vpCurve, PCRV_DEQUE& vpLoop) ; static SurfFlatRegion* MyNewSurfFromLoops( PCRV_DEQUE& vpLoop) ; static bool MyTestAndDelete( PCRV_DEQUE& vpCrv) ; private : ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria Status m_nStatus ; // stato Frame3d m_frF ; // riferimento intrinseco PCRV_DEQUE m_vpLoop ; // deque delle curve che formano i loop INTVECTOR m_vExtInd ; // indice dei loop esterni nel precedente vettore int m_nTempProp ; // proprietà temporanea } ; //----------------------------------------------------------------------------- inline SurfFlatRegion* CreateBasicSurfFlatRegion( void) { return (static_cast( CreateGeoObj( SRF_FLATRGN))) ; } inline SurfFlatRegion* CloneBasicSurfFlatRegion( const IGeoObj* pGObj) { if ( pGObj == nullptr || pGObj->GetType() != SRF_FLATRGN) return nullptr ; return (static_cast(pGObj->Clone())) ; } inline const SurfFlatRegion* GetBasicSurfFlatRegion( const IGeoObj* pGObj) { return (dynamic_cast( pGObj)) ; } inline SurfFlatRegion* GetBasicSurfFlatRegion( IGeoObj* pGObj) { return (dynamic_cast( pGObj)) ; }