EgtGeomKernel : Migliorata interfaccia calcolo distanza punto-curva,

inoltre sistemata gestione per punti singoli e tratti continui
This commit is contained in:
Dario Sassi
2014-01-13 21:11:19 +00:00
parent 87e3800d1a
commit 0ec9bceb16
9 changed files with 228 additions and 160 deletions
+47 -28
View File
@@ -60,25 +60,31 @@ DistPointArc::DistPointCircle( const Point3d& ptP, const ICurveArc& arArc)
if ( vtDiffPlane.Normalize()) {
bool bDet ;
double dAngDeg ;
double dParam ;
Point3d ptMinDist ;
arArc.GetStartVersor().GetRotation( vtDiffPlane, arArc.GetNormVersor(), dAngDeg, bDet) ;
if ( arArc.GetAngCenter() > 0 && dAngDeg < 0)
dAngDeg += 360 ;
else if ( arArc.GetAngCenter() < 0 && dAngDeg > 0)
dAngDeg -= 360 ;
m_dParam = dAngDeg / arArc.GetAngCenter() ;
if ( m_dParam < 0)
m_dParam = 0 ;
else if ( m_dParam > 1)
m_dParam = 1 ;
m_bDet = true ;
dParam = dAngDeg / arArc.GetAngCenter() ;
if ( dParam < 0)
dParam = 0 ;
else if ( dParam > 1)
dParam = 1 ;
// calcolo del punto di minima distanza
arArc.GetPointD1D2( dParam, ICurve::FROM_MINUS, ptMinDist) ;
// salvo i dati
m_Info.push_back( MinDistPCInfo( MDPCI_NORMAL, dParam, ptMinDist)) ;
}
else {
// tutti i punti della circonferenza sono a minima distanza, imposto il punto medio
m_dParam = 0.5 ;
m_bDet = false ;
Point3d ptMinDist ;
// tutti i punti della circonferenza sono a minima distanza salvo iniziale e finale
arArc.GetStartPoint( ptMinDist) ;
m_Info.push_back( MinDistPCInfo( MDPCI_START_CONT, 0, ptMinDist)) ;
arArc.GetEndPoint( ptMinDist) ;
m_Info.push_back( MinDistPCInfo( MDPCI_END_CONT, 1, ptMinDist)) ;
}
// calcolo del punto di minima distanza
arArc.GetPointD1D2( m_dParam, ICurve::FROM_MINUS, m_ptMinDist) ;
}
//----------------------------------------------------------------------------
@@ -88,18 +94,27 @@ DistPointArc::DistPointFlatArc( const Point3d& ptP, const ICurveArc& arArc)
// calcolo come per il cerchio (ma angolo al centro corretto)
DistPointCircle( ptP, arArc) ;
// se il parametro è sui bordi, verifico quale dei due
if ( fabs( m_dParam) < EPS_ZERO || fabs( m_dParam - 1) < EPS_ZERO) {
Point3d ptTest ;
m_dDist = INFINITO ;
// se non tutti i punti e il parametro è sui bordi, li verifico entrambi
if ( m_Info[0].nFlag != MDPCI_START_CONT &&
( fabs( m_Info[0].dPar) < EPS_ZERO || fabs( m_Info[0].dPar - 1) < EPS_ZERO)) {
for ( int i = 0 ; i <= 1 ; i ++) {
// eseguo il calcolo
double dU = i ;
Point3d ptTest ;
arArc.GetPointD1D2( dU, ICurve::FROM_MINUS, ptTest) ;
double dSqDist = SqDist( ptP, ptTest) ;
if ( dSqDist < m_dDist * m_dDist) {
m_dDist = sqrt( dSqDist) ;
m_dParam = dU ;
m_ptMinDist = ptTest ;
double dDist = Dist( ptP, ptTest) ;
// altro punto con la stessa minima distanza
if ( i == 1 && fabs( dDist - m_dDist) < EPS_SMALL) {
// lo aggiungo
m_Info.push_back( MinDistPCInfo( MDPCI_NORMAL, dU, ptTest)) ;
}
// primo punto o punto con minima distanza più bassa
else if ( i == 0 || dDist < m_dDist) {
// aggiorno i minimi
m_dDist = dDist ;
// il nuovo vettore deve contenere solo quest'ultimo minimo
m_Info.clear() ;
m_Info.push_back( MinDistPCInfo( MDPCI_NORMAL, dU, ptTest)) ;
}
}
}
@@ -136,26 +151,30 @@ DistPointArc::GetDist( double& dDist)
//----------------------------------------------------------------------------
bool
DistPointArc::GetPointMinDist( Point3d& ptMinDist, bool* pbDet)
DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag)
{
if ( m_dDist < 0)
return false ;
ptMinDist = m_ptMinDist ;
if ( pbDet != nullptr)
*pbDet = m_bDet ;
if ( nInd < 0 || nInd >= (int) m_Info.size())
return false ;
ptMinDist = m_Info[nInd].ptQ ;
nFlag = m_Info[nInd].nFlag ;
return true ;
}
//----------------------------------------------------------------------------
bool
DistPointArc::GetParamAtPointMinDist( double& dParam, bool* pbDet)
DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag)
{
if ( m_dDist < 0)
return false ;
dParam = m_dParam ;
if ( pbDet != nullptr)
*pbDet = m_bDet ;
if ( nInd < 0 || nInd >= (int) m_Info.size())
return false ;
dParam = m_Info[nInd].dPar ;
nFlag = m_Info[nInd].nFlag ;
return true ;
}