//---------------------------------------------------------------------------- // EgalTech 2015-2023 //---------------------------------------------------------------------------- // File : EGkPolygon3d.h Data : 17.12.23 Versione : 2.5l3 // Contenuto : Dichiarazione della classe Polygon3d (poligono nello spazio). // // // // Modifiche : 30.08.15 DS Creazione modulo. // 19.06.19 DS Aggiunta GetVertices. // 23.07.19 DS Aggiunte Offset e Invert. // 02.10.20 DS A FromPlaneTrimmedWithBox aggiunto parametro dToler. // //---------------------------------------------------------------------------- #pragma once #include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGkTriangle3d.h" #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkGeoCollection.h" //----------------------- Macro per import/export ---------------------------- #undef EGK_EXPORT #if defined( I_AM_EGK) // da definirsi solo nella DLL #define EGK_EXPORT __declspec( dllexport) #else #define EGK_EXPORT __declspec( dllimport) #endif //---------------------------------------------------------------------------- class Polygon3d { public : EGK_EXPORT bool Clear( void) ; EGK_EXPORT bool ClearSides( void) ; EGK_EXPORT bool FromTriangle( const Triangle3d& trTria) ; EGK_EXPORT bool FromRectangle( double dDimX, double dDimY) ; EGK_EXPORT bool FromPolyLine( const PolyLine& PL) ; EGK_EXPORT bool FromPlaneTrimmedWithBox( const Plane3d& plPlane, const Point3d& ptMin, const Point3d& ptMax, bool bOnEq = false, bool bOnCt = false, double dToler = EPS_SMALL) ; EGK_EXPORT bool FromPlaneTrimmedWithBox( const Point3d& ptOn, const Vector3d& vtN, const Point3d& ptMin, const Point3d& ptMax, bool bOnEq = false, bool bOnCt = false, double dToler = EPS_SMALL) ; EGK_EXPORT bool Trim( const Plane3d& plPlane, bool bInVsOut, bool bOnEq = false, bool bOnCt = false) ; EGK_EXPORT bool Trim( const Polygon3d& plyOther, bool bInVsOut, bool bOnEq = false, bool bOnCt = false) ; EGK_EXPORT bool Add( const Polygon3d& plyOther) ; EGK_EXPORT void Offset( double dDist) { Translate( dDist * m_Plane.GetVersN()) ; } EGK_EXPORT void Invert( void) ; EGK_EXPORT void Translate( const Vector3d& vtMove) ; EGK_EXPORT bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) { double dAngRad = dAngDeg * DEGTORAD ; return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } EGK_EXPORT bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; EGK_EXPORT bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; EGK_EXPORT bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; EGK_EXPORT bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ; EGK_EXPORT bool ToGlob( const Frame3d& frRef) ; EGK_EXPORT bool ToLoc( const Frame3d& frRef) ; EGK_EXPORT bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ; EGK_EXPORT bool GetLocalBBox( BBox3d& b3Loc) const ; EGK_EXPORT bool IsValid( void) const { return ! m_Plane.GetVersN().IsSmall() ; } EGK_EXPORT const Plane3d& GetPlane( void) const { return m_Plane ; } EGK_EXPORT const Vector3d& GetVersN( void) const { return m_Plane.GetVersN() ; } EGK_EXPORT double GetPlaneDist( void) const { return m_Plane.GetDist() ; } EGK_EXPORT int GetSideCount( void) const { return ( IsValid() ? int( m_vVert.size()) : 0) ; } EGK_EXPORT const PNTVECTOR& GetVertices( void) const { return m_vVert ; } EGK_EXPORT PolyLine GetPolyLine( void) const ; EGK_EXPORT Point3d GetCentroid( void) const ; EGK_EXPORT double GetPerimeter( void) const ; EGK_EXPORT double GetArea( void) const ; private : Plane3d m_Plane ; // piano in cui giace il poligono PNTVECTOR m_vVert ; // elenco ordinato dei vertici del poligono (CCW da Z+ piano) } ; //---------------------------------------------------------------------------- // Raccolte di Polygon3d typedef std::vector POLYGVECTOR ; // vettore di poligoni typedef std::list POLYGLIST ; // lista di poligoni