//---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- // File : DistPointCurve.cpp Data : 02.01.14 Versione : 1.5a1 // Contenuto : Implementazione della classe distanza punto da Curva. // // // // Modifiche : 02.01.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DistPointLine.h" #include "DistPointArc.h" #include "DistPointCrvBezier.h" #include "/EgtDev/Include/EGkDistPointCurve.h" //---------------------------------------------------------------------------- DistPointCurve::DistPointCurve( const Point3d& ptP, const ICurve& Curve) { // distanza non calcolata m_dDist = - 1 ; // curva non valida if ( ! Curve.IsValid()) return ; // chiamo calcolatore opportuno switch ( Curve.GetType()) { case CRV_LINE : LineCalculate( ptP, Curve) ; break ; case CRV_ARC : ArcCalculate( ptP, Curve) ; break ; case CRV_BEZ : CrvBezierCalculate( ptP, Curve) ; break ; case CRV_COMPO : CrvCompositeCalculate( ptP, Curve) ; break ; } } //---------------------------------------------------------------------------- void DistPointCurve::LineCalculate( const Point3d& ptP, const ICurve& Curve) { DistPointLine dstPtLn( ptP, *GetCurveLine( &Curve)) ; m_bDet = true ; m_dDist = (( dstPtLn.m_dSqDist > 0) ? sqrt( dstPtLn.m_dSqDist) : dstPtLn.m_dSqDist) ; m_dParam = dstPtLn.m_dParam ; m_ptMinDist = dstPtLn.m_ptMinDist ; } //---------------------------------------------------------------------------- void DistPointCurve::ArcCalculate( const Point3d& ptP, const ICurve& Curve) { DistPointArc dstPtArc( ptP, *GetCurveArc( &Curve)) ; m_bDet = dstPtArc.m_bDet ; m_dDist = dstPtArc.m_dDist ; m_dParam = dstPtArc.m_dParam ; m_ptMinDist = dstPtArc.m_ptMinDist ; } //---------------------------------------------------------------------------- void DistPointCurve::CrvBezierCalculate( const Point3d& ptP, const ICurve& Curve) { DistPointCrvBezier dstPtCBez( ptP, *GetCurveBezier( &Curve)) ; m_bDet = dstPtCBez.m_bDet ; m_dDist = dstPtCBez.m_dDist ; m_dParam = dstPtCBez.m_dParam ; m_ptMinDist = dstPtCBez.m_ptMinDist ; } //---------------------------------------------------------------------------- void DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve) { //DistPointCrvComposite dstPtLn( ptP, *GetCurveComposite( &Curve)) ; } //---------------------------------------------------------------------------- bool DistPointCurve::GetSqDist( double& dSqDist) { if ( m_dDist < 0) return false ; dSqDist = m_dDist * m_dDist ; return true ; } //---------------------------------------------------------------------------- bool DistPointCurve::GetDist( double& dDist) { if ( m_dDist < 0) return false ; dDist = m_dDist ; return true ; } //---------------------------------------------------------------------------- bool DistPointCurve::GetPointMinDist( Point3d& ptMinDist, bool* pbDet) { if ( m_dDist < 0) return false ; ptMinDist = m_ptMinDist ; if ( pbDet != nullptr) *pbDet = m_bDet ; return true ; } //---------------------------------------------------------------------------- bool DistPointCurve::GetParamAtPointMinDist( double& dParam, bool* pbDet) { if ( m_dDist < 0) return false ; dParam = m_dParam ; if ( pbDet != nullptr) *pbDet = m_bDet ; return true ; }