Files
Include/EGkDistPointCurve.h
Daniele Bariletti b6a535a3b7 Include :
- aggiunto parametro alla GetSide della DistPointCurve.
2026-03-16 17:00:20 +01:00

83 lines
3.5 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2024
//----------------------------------------------------------------------------
// File : EGkDistPointCurve.h Data : 20.05.24 Versione : 2.6e5
// 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<MinDistPCInfo> 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, double dTol = EPS_SMALL) const ;
EGK_EXPORT bool GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide, double dTol = EPS_SMALL) const ;
EGK_EXPORT bool GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const ;
private :
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 ;
} ;