8a416970a3
- correzione a PolyLine (Splice) - impostazione Reset grafica sulle diverse entità geometriche.
179 lines
4.4 KiB
C++
179 lines
4.4 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : PolyLine.cpp Data : 22.12.13 Versione : 1.4l3
|
|
// Contenuto : Implementazione della classe PolyLine.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 22.12.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "\EgtDev\Include\EGkPolyLine.h"
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
PolyLine::PolyLine( void)
|
|
{
|
|
m_nCount = 0 ;
|
|
m_iter = m_lUPoints.end() ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
PolyLine::~PolyLine( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::AddUPoint( double dPar, const Point3d& ptP)
|
|
{
|
|
try {
|
|
m_lUPoints.push_back( UPOINT( dPar, ptP)) ;
|
|
}
|
|
catch (...) {
|
|
return false ;
|
|
}
|
|
|
|
m_nCount ++ ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::EraseFirstUPoint( void)
|
|
{
|
|
if ( m_lUPoints.begin() == m_lUPoints.end())
|
|
return false ;
|
|
|
|
m_lUPoints.pop_front() ;
|
|
m_nCount -- ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::AddOffsetToU( double dOffset)
|
|
{
|
|
UPNTLIST::iterator iter ;
|
|
|
|
|
|
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
|
iter->first += dOffset ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::Splice( PolyLine& PL)
|
|
{
|
|
m_lUPoints.splice( m_lUPoints.end(), PL.m_lUPoints) ;
|
|
m_nCount += PL.GetPointNbr() ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP) const
|
|
{
|
|
m_iter = m_lUPoints.begin() ;
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
|
|
if ( pdPar != nullptr)
|
|
*pdPar = m_iter->first ;
|
|
if ( pptP != nullptr)
|
|
*pptP = m_iter->second ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP) const
|
|
{
|
|
++ m_iter ;
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
|
|
if ( pdPar != nullptr)
|
|
*pdPar = m_iter->first ;
|
|
if ( pptP != nullptr)
|
|
*pptP = m_iter->second ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP) const
|
|
{
|
|
if ( m_lUPoints.begin() == m_lUPoints.end())
|
|
return false ;
|
|
|
|
if ( pdPar != nullptr)
|
|
*pdPar = m_lUPoints.back().first ;
|
|
if ( pptP != nullptr)
|
|
*pptP = m_lUPoints.back().second ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
|
|
{
|
|
// parametro e punto iniziali
|
|
m_iter = m_lUPoints.begin() ;
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
if ( pdIni != nullptr)
|
|
*pdIni = m_iter->first ;
|
|
if ( pptIni != nullptr)
|
|
*pptIni = m_iter->second ;
|
|
|
|
// parametro e punto finali
|
|
++ m_iter ;
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
if ( pdFin != nullptr)
|
|
*pdFin = m_iter->first ;
|
|
if ( pptFin != nullptr)
|
|
*pptFin = m_iter->second ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
|
|
{
|
|
// parametro e punto iniziali (è il precedente finale)
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
if ( pdIni != nullptr)
|
|
*pdIni = m_iter->first ;
|
|
if ( pptIni != nullptr)
|
|
*pptIni = m_iter->second ;
|
|
|
|
// parametro e punto finali
|
|
++ m_iter ;
|
|
if ( m_iter == m_lUPoints.end())
|
|
return false ;
|
|
if ( pdFin != nullptr)
|
|
*pdFin = m_iter->first ;
|
|
if ( pptFin != nullptr)
|
|
*pptFin = m_iter->second ;
|
|
|
|
return true ;
|
|
}
|
|
|