//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : SurfTriMesh.h Data : 26.03.14 Versione : 1.5c9 // Contenuto : Dichiarazione della classe Superfici TriMesh. // // // // Modifiche : 26.03.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include "ObjGraphicsMgr.h" #include "DllMain.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include //---------------------------------------------------------------------------- const int VT_NULL = - 1 ; // vertice o triangolo nullo const int VT_DEL = - 2 ; // vertice o triangolo cancellato //---------------------------------------------------------------------------- class StmVert { public : StmVert( void) : ptP(), nIdTria( VT_NULL), nFlag( 0) {} StmVert( const Point3d& ptQ) : ptP( ptQ), nIdTria( VT_NULL), nFlag( 0) {} StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), nIdTria( nIdT), nFlag( nF) {} public : Point3d ptP ; int nIdTria ; int nFlag ; } ; //---------------------------------------------------------------------------- class StmTria { public : StmTria( void) : vtN(), nTFlag( 0), nEFlag( 0) { nIdVert[0] = VT_NULL ; nIdVert[1] = VT_NULL ; nIdVert[2] = VT_NULL ; nIdAdjac[0] = VT_NULL ; nIdAdjac[1] = VT_NULL ; nIdAdjac[2] = VT_NULL ; } StmTria( const int nIdV[3]) : vtN(), nTFlag( 0), nEFlag( 0) { nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ; nIdAdjac[0] = VT_NULL ; nIdAdjac[1] = VT_NULL ; nIdAdjac[2] = VT_NULL ; } StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF) : vtN( vtV), nTFlag( nTF), nEFlag( nEF) { nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ; nIdAdjac[0] = nIdA[0] ; nIdAdjac[1] = nIdA[1] ; nIdAdjac[2] = nIdA[2] ; } public : int nIdVert[3] ; int nIdAdjac[3] ; Vector3d vtN ; int nTFlag ; int nEFlag ; } ; //---------------------------------------------------------------------------- class SurfTriMesh : public ISurfTriMesh { public : // IGeoObj virtual ~SurfTriMesh( void) ; virtual SurfTriMesh* Clone( void) const ; virtual GeoObjType GetType( void) const { return SRF_TRIMESH ; } virtual bool IsValid( void) const { return ( m_nStatus == OK) ; } virtual const std::string& GetTitle( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; virtual const std::string& GetKey( void) const ; virtual bool Save( std::ostream& osOut) const ; virtual bool Load( Scanner& TheScanner) ; 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 dAngRad) { 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 void SetObjGraphics( IObjGraphics* pOGr) { m_OGrMgr.SetObjGraphics( pOGr) ; } virtual IObjGraphics* GetObjGraphics( void) { return m_OGrMgr.GetObjGraphics() ; } virtual const IObjGraphics* GetObjGraphics( void) const { return m_OGrMgr.GetObjGraphics() ; } public : // ISurf virtual bool IsSimple( void) const { return true ; } virtual bool IsClosed( void) const { return m_bClosed ; } public : // ISurfTriMesh virtual bool Copy( const IGeoObj* pGObjSrc) ; virtual bool Init( int nNumVert, int nNumTria) ; virtual int AddVertex( const Point3d& ptVert) ; virtual int AddTriangle( const int nIdVert[3]) ; virtual int GetFirstTriangle( Point3d& ptP0, Point3d& ptP1, Point3d& ptP2) const ; virtual int GetNextTriangle( int nId, Point3d& ptP0, Point3d& ptP1, Point3d& ptP2) const ; public : SurfTriMesh( void) ; const SurfTriMesh& operator =( const SurfTriMesh& stSrc) { if ( ! Copy( stSrc)) LOG_ERROR( GetEGkLogger(), "SurfTriMesh : copy error") return *this ; } private : bool Copy( const SurfTriMesh& clSrc) ; bool Validate( void) ; bool SetVertex( int nInd, const StmVert& vV) ; bool SetTriangle( int nInd, const StmTria& tT) ; int GetVertexNum( void) const { return int( m_vVert.size()) ; } int GetTriangleNum( void) const { return int( m_vTria.size()) ; } bool CalcTriangleNormal( int nT) ; bool InvertTriangle( int nT) ; private : enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; private : typedef std::vector VERTVECTOR ; typedef std::vector TRIAVECTOR ; private : ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto Status m_nStatus ; // stato bool m_bClosed ; // la superficie racchiude un volume VERTVECTOR m_vVert ; // vettore dei vertici TRIAVECTOR m_vTria ; // vettore dei triangoli } ;