//---------------------------------------------------------------------------- // EgalTech 2013-2014 //---------------------------------------------------------------------------- // File : EGkDistPointCurve.h Data : 02.01.14 Versione : 1.5a1 // Contenuto : Dichiarazione della classe distanza punto da Curva. // // // // Modifiche : 02.01.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include "/EgtDev/Include/EGkPoint3d.h" #include "/EgtDev/Include/EGkCurve.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 //---------------------------------------------------------------------------- enum MdPCiType { MDPCI_NORMAL, MDPCI_START_CONT, MDPCI_END_CONT} ; struct MinDistPCInfo { MdPCiType nFlag ; double dPar ; Point3d ptQ ; MinDistPCInfo( void) : nFlag( MDPCI_NORMAL), dPar( 0), ptQ( 0, 0, 0) {} MinDistPCInfo( MdPCiType nF, double dP, Point3d pT) : nFlag( nF), dPar( dP), ptQ( pT) {} } ; typedef std::vector MDPCIVECTOR ; // vettore di MinDistPCInfo //---------------------------------------------------------------------------- enum MdSide { MDS_LEFT = -1, MDS_ON = 0, MDS_RIGHT = +1} ; //----------------------------------------------------------------------------- class DistPointCurve { public : EGK_EXPORT DistPointCurve( const Point3d& ptP, const ICurve& Curve, bool bIsSegment = true) ; // Il flag bIsSegment vale solo per linee. public : EGK_EXPORT bool GetSqDist( double& dSqDist) const ; EGK_EXPORT bool GetDist( double& dDist) const ; EGK_EXPORT bool IsEpsilon( double dTol) const { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } EGK_EXPORT bool IsSmall( void) const { return IsEpsilon( EPS_SMALL) ; } EGK_EXPORT bool IsZero( void) const { return IsEpsilon( EPS_ZERO) ; } EGK_EXPORT int GetNbrMinDist( void) const { return (int) m_Info.size() ; } EGK_EXPORT bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ; EGK_EXPORT bool GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) const ; EGK_EXPORT bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ; EGK_EXPORT bool GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) const ; EGK_EXPORT bool GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const ; EGK_EXPORT bool GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const ; EGK_EXPORT bool GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const ; private : DistPointCurve( void) ; void LineCalculate( const Point3d& ptP, const ICurve& Curve, bool bIsSegment) ; void ArcCalculate( const Point3d& ptP, const ICurve& Curve) ; void CrvBezierCalculate( const Point3d& ptP, const ICurve& Curve) ; void CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve) ; private : double m_dDist ; MDPCIVECTOR m_Info ; Point3d m_ptP ; const ICurve* m_pCurve ; } ;