//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : EGkIntervals.h Data : 03.08.15 Versione : 1.6h1 // Contenuto : Dichiarazione della classe insieme di intervalli Intervals. // // // // Modifiche : 03.08.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include #include //----------------------- 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 Intervals { public : EGK_EXPORT Intervals( void) : m_dToler( EPS_SMALL), m_Iter( m_vInts.end()) { m_vInts.reserve( 4) ; } EGK_EXPORT Intervals( double dToler) : m_dToler( std::max( dToler, EPS_ZERO)), m_Iter( m_vInts.end()) { m_vInts.reserve( 4) ; } public : EGK_EXPORT void Reset( void) ; EGK_EXPORT void Set( double dMin, double dMax) ; EGK_EXPORT void Add( double dMin, double dMax) ; EGK_EXPORT void Subtract( double dMin, double dMax) ; EGK_EXPORT void Intersect( double dMin, double dMax) ; EGK_EXPORT void Add( const Intervals& Other) ; EGK_EXPORT void Subtract( const Intervals& Other) ; EGK_EXPORT void Intersect( const Intervals& Other) ; EGK_EXPORT bool IsEmpty( void) const { return m_vInts.empty() ; } EGK_EXPORT int GetCount( void) const { return int( m_vInts.size()) ; } EGK_EXPORT bool GetMinMax( double& dMin, double& dMax) const ; EGK_EXPORT bool GetFirst( double& dMin, double& dMax) const ; EGK_EXPORT bool GetNext( double& dMin, double& dMax) const ; EGK_EXPORT bool GetLast( double& dMin, double& dMax) const ; EGK_EXPORT bool GetPrev( double& dMin, double& dMax) const ; EGK_EXPORT bool IsInside( double dP) const ; EGK_EXPORT bool GetPrevNearest( double dP, double& dPrev) const ; EGK_EXPORT bool GetNextNearest( double dP, double& dNext) const ; private : typedef std::pair INTERV ; // intervallo, definito come insieme di minimo e massimo typedef std::vector INTERVVECTOR ; // lista di intervalli typedef INTERVVECTOR::const_iterator INTV_CINT ; // iteratore costante a lista di intervalli private : double m_dToler ; INTERVVECTOR m_vInts ; mutable INTV_CINT m_Iter ; } ;