EgtGeomKernel : Migliorata interfaccia calcolo distanza punto-curva,
inoltre sistemata gestione per punti singoli e tratti continui
This commit is contained in:
+93
-19
@@ -22,8 +22,9 @@
|
||||
//----------------------------------------------------------------------------
|
||||
DistPointCurve::DistPointCurve( const Point3d& ptP, const ICurve& Curve)
|
||||
{
|
||||
// distanza non calcolata
|
||||
// distanza non calcolata e curva sconosciuta
|
||||
m_dDist = - 1 ;
|
||||
m_pCurve = nullptr ;
|
||||
|
||||
// curva non valida
|
||||
if ( ! Curve.IsValid())
|
||||
@@ -44,6 +45,8 @@ DistPointCurve::DistPointCurve( const Point3d& ptP, const ICurve& Curve)
|
||||
CrvCompositeCalculate( ptP, Curve) ;
|
||||
break ;
|
||||
}
|
||||
// salvo il puntatore alla curva
|
||||
m_pCurve = &Curve ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -52,10 +55,10 @@ 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 ;
|
||||
if ( dstPtLn.m_dSqDist > 0) {
|
||||
m_dDist = sqrt( dstPtLn.m_dSqDist) ;
|
||||
m_Info.push_back( MinDistPCInfo( MDPCI_NORMAL, dstPtLn.m_dParam, dstPtLn.m_ptMinDist)) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -64,10 +67,8 @@ 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 ;
|
||||
m_Info = dstPtArc.m_Info ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -76,10 +77,8 @@ 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 ;
|
||||
m_Info = dstPtCBez.m_Info ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -113,26 +112,101 @@ DistPointCurve::GetDist( double& dDist)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetPointMinDist( Point3d& ptMinDist, bool* pbDet)
|
||||
DistPointCurve::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
|
||||
DistPointCurve::GetParamAtPointMinDist( double& dParam, bool* pbDet)
|
||||
DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
dParam = m_dParam ;
|
||||
if ( pbDet != nullptr)
|
||||
*pbDet = m_bDet ;
|
||||
if ( m_Info.empty())
|
||||
return false ;
|
||||
|
||||
// verifico se cade in una zona continua
|
||||
for ( int i = 1 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( m_Info[i-1].nFlag == MDPCI_START_CONT &&
|
||||
m_Info[i].nFlag == MDPCI_END_CONT) {
|
||||
if ( dNearParam > m_Info[i-1].dPar && dNearParam < m_Info[i].dPar) {
|
||||
nFlag = MDPCI_START_CONT ;
|
||||
if ( m_pCurve != nullptr &&
|
||||
m_pCurve->GetPointD1D2( dNearParam, ICurve::FROM_MINUS, ptMinDist))
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
double dParam ;
|
||||
for ( int i = 0 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( i == 0 ||
|
||||
fabs( m_Info[i].dPar - dNearParam) < fabs( dParam - dNearParam)) {
|
||||
dParam = m_Info[i].dPar ;
|
||||
ptMinDist = m_Info[i].ptQ ;
|
||||
nFlag = m_Info[i].nFlag ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::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 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag)
|
||||
{
|
||||
if ( m_dDist < 0)
|
||||
return false ;
|
||||
|
||||
if ( m_Info.empty())
|
||||
return false ;
|
||||
|
||||
// verifico se cade in una zona continua
|
||||
for ( int i = 1 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( m_Info[i-1].nFlag == MDPCI_START_CONT &&
|
||||
m_Info[i].nFlag == MDPCI_END_CONT) {
|
||||
if ( dNearParam > m_Info[i-1].dPar && dNearParam < m_Info[i].dPar) {
|
||||
dParam = dNearParam ;
|
||||
nFlag = MDPCI_START_CONT ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cerco punto discreto più vicino (anche estremi di zone continue)
|
||||
for ( int i = 0 ; i < (int) m_Info.size() ; ++ i) {
|
||||
if ( i == 0 ||
|
||||
fabs( m_Info[i].dPar - dNearParam) < fabs( dParam - dNearParam)) {
|
||||
dParam = m_Info[i].dPar ;
|
||||
nFlag = m_Info[i].nFlag ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user