1655127475
- aggiunte costanti - piccola miglioria in funzione inline.
159 lines
10 KiB
C++
159 lines
10 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2013
|
|
//----------------------------------------------------------------------------
|
|
// File : EGkPolyLine.h Data : 22.12.13 Versione : 1.4l3
|
|
// Contenuto : Dichiarazione della classe PolyLine.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 22.12.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "/EgtDev/Include/EGkPoint3d.h"
|
|
#include "/EgtDev/Include/EGkBBox3d.h"
|
|
#include "/EgtDev/Include/EGkPlane3d.h"
|
|
#include "/EgtDev/Include/EGkGeoCollection.h"
|
|
|
|
//----------------------- Macro per import/export ----------------------------
|
|
#undef EGK_EXPORT
|
|
#if defined( I_AM_EGK) // da definirsi solo nella DLL
|
|
#define EGK_EXPORT __declspec( dllexport)
|
|
#else
|
|
#define EGK_EXPORT __declspec( dllimport)
|
|
#endif
|
|
|
|
//-----------------------------------------------------------------------------
|
|
class PolyLine
|
|
{
|
|
public :
|
|
EGK_EXPORT PolyLine( void) ;
|
|
EGK_EXPORT ~PolyLine( void) ;
|
|
EGK_EXPORT bool Clear( void) ;
|
|
EGK_EXPORT bool AddUPoint( double dPar, const Point3d& ptP, bool bEndOrStart = true) ;
|
|
EGK_EXPORT bool Close( void) ;
|
|
EGK_EXPORT bool ModifyLastParam( double dPar) ;
|
|
EGK_EXPORT bool EraseFirstUPoint( void) ;
|
|
EGK_EXPORT bool EraseLastUPoint( void) ;
|
|
EGK_EXPORT bool AddOffsetToU( double dOffset) ;
|
|
EGK_EXPORT bool Translate( const Vector3d& vtMove) ;
|
|
EGK_EXPORT bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
|
{ double dAngRad = dAngDeg * DEGTORAD ;
|
|
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
|
EGK_EXPORT bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
|
EGK_EXPORT bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
|
EGK_EXPORT bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
|
EGK_EXPORT bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
|
EGK_EXPORT bool ToGlob( const Frame3d& frRef) ;
|
|
EGK_EXPORT bool ToLoc( const Frame3d& frRef) ;
|
|
EGK_EXPORT bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
|
EGK_EXPORT bool Join( PolyLine& PL, double dOffsetPar = 0) ;
|
|
EGK_EXPORT bool Split( double dU, PolyLine& PL) ;
|
|
EGK_EXPORT bool GetLocalBBox( BBox3d& b3Loc) const ;
|
|
EGK_EXPORT bool IsClosed( void) const ;
|
|
EGK_EXPORT int GetRejectedNbr( void) const
|
|
{ return m_nRejected ; }
|
|
EGK_EXPORT int GetPointNbr( void) const
|
|
{ return int( m_lUPoints.size()) ; }
|
|
EGK_EXPORT bool GetFirstUPoint( double* pdPar, Point3d* pptP, bool bNotLast = false) const ;
|
|
EGK_EXPORT bool GetNextUPoint( double* pdPar, Point3d* pptP, bool bNotLast = false) const ;
|
|
EGK_EXPORT bool GetFirstU( double& dPar, bool bNotLast = false) const
|
|
{ return GetFirstUPoint( &dPar, nullptr, bNotLast) ; }
|
|
EGK_EXPORT bool GetNextU( double& dPar, bool bNotLast = false) const
|
|
{ return GetNextUPoint( &dPar, nullptr, bNotLast) ; }
|
|
EGK_EXPORT bool GetFirstPoint( Point3d& ptP, bool bNotLast = false) const
|
|
{ return GetFirstUPoint( nullptr, &ptP, bNotLast) ; }
|
|
EGK_EXPORT bool GetNextPoint( Point3d& ptP, bool bNotLast = false) const
|
|
{ return GetNextUPoint( nullptr, &ptP, bNotLast) ; }
|
|
EGK_EXPORT bool GetLastUPoint( double* pdPar, Point3d* pptP, bool bNotFirst = false) const ;
|
|
EGK_EXPORT bool GetPrevUPoint( double* pdPar, Point3d* pptP, bool bNotFirst = false) const ;
|
|
EGK_EXPORT bool GetLastU( double& dPar, bool bNotFirst = false) const
|
|
{ return GetLastUPoint( &dPar, nullptr, bNotFirst) ; }
|
|
EGK_EXPORT bool GetPrevU( double& dPar, bool bNotFirst = false) const
|
|
{ return GetPrevUPoint( &dPar, nullptr, bNotFirst) ; }
|
|
EGK_EXPORT bool GetLastPoint( Point3d& ptP, bool bNotFirst = false) const
|
|
{ return GetLastUPoint( nullptr, &ptP, bNotFirst) ; }
|
|
EGK_EXPORT bool GetPrevPoint( Point3d& ptP, bool bNotFirst = false) const
|
|
{ return GetPrevUPoint( nullptr, &ptP, bNotFirst) ; }
|
|
EGK_EXPORT bool GetCurrUPoint( double* pdPar, Point3d* pptP) const ;
|
|
EGK_EXPORT bool GetCurrU( double& dPar) const
|
|
{ return GetCurrUPoint( &dPar, nullptr) ; }
|
|
EGK_EXPORT bool GetCurrPoint( Point3d& ptP) const
|
|
{ return GetCurrUPoint( nullptr, &ptP) ; }
|
|
EGK_EXPORT int GetLineNbr( void) const
|
|
{ return int( m_lUPoints.size() > 1 ? ( m_lUPoints.size() - 1) : 0) ; }
|
|
EGK_EXPORT bool GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const ;
|
|
EGK_EXPORT bool GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const ;
|
|
EGK_EXPORT bool GetFirstLine( Point3d& ptIni, Point3d& ptFin) const
|
|
{ return GetFirstULine( nullptr, &ptIni, nullptr, &ptFin) ; }
|
|
EGK_EXPORT bool GetNextLine( Point3d& ptIni, Point3d& ptFin) const
|
|
{ return GetNextULine( nullptr, &ptIni, nullptr, &ptFin) ; }
|
|
EGK_EXPORT bool GetLastULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const ;
|
|
EGK_EXPORT bool GetPrevULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const ;
|
|
EGK_EXPORT bool GetLastLine( Point3d& ptIni, Point3d& ptFin) const
|
|
{ return GetLastULine( nullptr, &ptIni, nullptr, &ptFin) ; }
|
|
EGK_EXPORT bool GetPrevLine( Point3d& ptIni, Point3d& ptFin) const
|
|
{ return GetPrevULine( nullptr, &ptIni, nullptr, &ptFin) ; }
|
|
EGK_EXPORT PNTULIST& GetUPointList( void)
|
|
{ return m_lUPoints ; }
|
|
EGK_EXPORT bool IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler = EPS_SMALL) const ;
|
|
EGK_EXPORT bool IsFlat( Plane3d& plPlane, double dToler = EPS_SMALL) const ;
|
|
EGK_EXPORT bool IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler = EPS_SMALL) const ;
|
|
EGK_EXPORT bool GetApproxLength( double& dLen) const ;
|
|
EGK_EXPORT bool GetLength( double& dLen) const ;
|
|
EGK_EXPORT bool GetAreaXY( double& dArea) const ;
|
|
EGK_EXPORT bool GetMaxDistanceFromLine( const Point3d& ptLine, const Vector3d& vtLine, double dLen,
|
|
double& dMaxDist, bool bIsSegment = true) const ;
|
|
EGK_EXPORT bool AdjustForMaxSegmentLen( double dMaxLen) ;
|
|
EGK_EXPORT bool RemoveAlignedPoints( double dToler = EPS_SMALL) ;
|
|
EGK_EXPORT bool ApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler = EPS_SMALL) ;
|
|
EGK_EXPORT bool MakeConvex( const Vector3d& vtN, bool bLeftSide) ;
|
|
EGK_EXPORT bool Invert( bool bInvertU = true) ;
|
|
EGK_EXPORT bool Flatten( double dZ = 0) ;
|
|
EGK_EXPORT bool FlattenInAutoPlane( double dToler = 10 * EPS_SMALL) ;
|
|
EGK_EXPORT bool GetConvexHullXY( PNTVECTOR& vConvHull) const ;
|
|
EGK_EXPORT bool GetMinAreaRectangleXY( Point3d& ptCen, Vector3d& vtAx, double& dLen, double& dHeight) const ;
|
|
EGK_EXPORT bool Trim( const Plane3d& plPlane, bool bInVsOut = true) ;
|
|
EGK_EXPORT void SetTempProp( int nProp, int nPropInd = 0)
|
|
{ if ( nPropInd >= 0 && nPropInd < 2)
|
|
m_nTempProp[nPropInd] = nProp ; }
|
|
EGK_EXPORT int GetTempProp( int nPropInd = 0) const
|
|
{ return (( nPropInd >= 0 && nPropInd < 2) ? m_nTempProp[nPropInd] : 0) ; }
|
|
EGK_EXPORT bool FromPointVector( const PNTVECTOR& vPnt)
|
|
{ Clear() ;
|
|
for ( int i = 0 ; i < std::ssize( vPnt) ; ++i)
|
|
AddUPoint( i, vPnt[i]) ;
|
|
return GetPointNbr() > 0 ; }
|
|
|
|
private :
|
|
bool MyChangeStart( int nPos) ;
|
|
bool MyApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler = EPS_SMALL) ;
|
|
bool MyMakeConvex( const Vector3d& vtN, bool bLeftSide) ;
|
|
bool MyRemoveSamePoints( double dToler = EPS_SMALL) ;
|
|
|
|
private :
|
|
int m_nRejected ; // numero punti rifiutati perchè coincidenti
|
|
int m_nTempProp[2] ; // vettore proprietà temporanee
|
|
PNTULIST m_lUPoints ; // lista dei punti
|
|
mutable PNTULIST::const_iterator m_iter ; // iteratore corrente
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Raccolte di PolyLine
|
|
typedef std::vector<PolyLine> POLYLINEVECTOR ; // vettore di PolyLine
|
|
typedef std::list<PolyLine> POLYLINELIST ; // lista di PolyLine
|
|
typedef std::vector<POLYLINEVECTOR> POLYLINEMATRIX ; // matrice di PolyLine
|
|
|
|
//----------------------------------------------------------------------------
|
|
EGK_EXPORT bool DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dDist) ;
|
|
EGK_EXPORT bool DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dDist, double& dMinDistPar) ;
|
|
EGK_EXPORT bool IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler) ;
|
|
EGK_EXPORT bool GetPointParamOnPolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler, double& dPar) ;
|
|
EGK_EXPORT bool ChangePolyLineStart( PolyLine& plPoly, const Point3d& ptNewStart, double dToler) ;
|
|
EGK_EXPORT bool SplitPolyLineAtPoint( const PolyLine& plPoly, const Point3d& ptP, double dToler, PolyLine& plPoly1, PolyLine& plPoly2) ;
|
|
EGK_EXPORT bool AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIVECTOR& vPnt1, PNTIVECTOR& vPnt2, bool& bCommonInternalPoints) ;
|
|
EGK_EXPORT bool MatchPolyLinesAddingPoints( const PolyLine& PL1, const PolyLine& PL2, int nType, PNTIVECTOR& vPnt1, PNTIVECTOR& vPnt2) ;
|