EgtGeomKernel 1.5a4 : Implementazione BoundingBox.
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DistPointCrvCompo.cpp Data : 15.01.14 Versione : 1.5a4
|
||||
// Contenuto : Implementazione della classe distanza punto da curva Composita.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 15.01.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DistPointCrvComposite.h"
|
||||
#include "DistPointCrvAux.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo)
|
||||
{
|
||||
// distanza non calcolata
|
||||
m_dDist = - 1 ;
|
||||
|
||||
if ( ! CrvCompo.IsValid())
|
||||
return ;
|
||||
#if 0
|
||||
// creo una polilinea di approssimazione
|
||||
PolyLine PL ;
|
||||
if ( ! CrvBez.ApproxWithLines( LIN_TOL_APPROX, ANG_TOL_APPROX_DEG, PL))
|
||||
return ;
|
||||
|
||||
// cerco la minima distanza per la polilinea
|
||||
MDCVECTOR vApproxMin ;
|
||||
MDCVECTOR::iterator Iter ;
|
||||
if ( ! CalcMinDistPointPolyLine( ptP, PL, vApproxMin))
|
||||
return ;
|
||||
|
||||
// verifico presenza singolarità agli estremi degli intervalli trovati
|
||||
double dSingP ;
|
||||
if ( CrvBez.GetSingularParam( dSingP) == 0)
|
||||
dSingP = - 1 ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// imposto flag per singolarità agli estremi
|
||||
(*Iter).bParMinSing = fabs( (*Iter).dParMin - dSingP) < EPS_SMALL ;
|
||||
(*Iter).bParMaxSing = fabs( (*Iter).dParMax - dSingP) < EPS_SMALL ;
|
||||
}
|
||||
|
||||
// raffino i punti trovati
|
||||
double dPolishedPar ;
|
||||
Point3d ptPolishedQ ;
|
||||
for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) {
|
||||
// eseguo raffinamento
|
||||
if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) {
|
||||
(*Iter).dDist = Dist( ptP, ptPolishedQ) ;
|
||||
(*Iter).dPar = dPolishedPar ;
|
||||
(*Iter).ptQ = ptPolishedQ ;
|
||||
}
|
||||
else
|
||||
(*Iter).dDist = INFINITO ;
|
||||
}
|
||||
|
||||
// determino i minimi raffinati da tenere
|
||||
double dMinDist ;
|
||||
if ( FilterMinDistPointCurve( ptP, CrvBez, vApproxMin, dMinDist, m_Info))
|
||||
m_dDist = dMinDist ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetSqDist( double& dSqDist)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
dSqDist = m_dDist * m_dDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetDist( double& dDist)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
dDist = m_dDist ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
if ( nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
|
||||
ptMinDist = m_Info[nInd].ptQ ;
|
||||
nFlag = m_Info[nInd].nFlag ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
if ( nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
|
||||
dParam = m_Info[nInd].dPar ;
|
||||
nFlag = m_Info[nInd].nFlag ;
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user