From 4e7501ed7fb91a9b59a39e5b045fcf75c2fe93e1 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 22 Dec 2023 09:28:30 +0100 Subject: [PATCH 01/13] EgtGeomKernel : - piccola modifica a svuotatura Spiral in CalcPocketing. --- CalcPocketing.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CalcPocketing.cpp b/CalcPocketing.cpp index e485509..f0ed8d6 100644 --- a/CalcPocketing.cpp +++ b/CalcPocketing.cpp @@ -1898,7 +1898,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm if ( IsNull( pSrfAct) || pSrfAct->GetChunkCount() == 0) return false ; - double dOffsPrec = dOffs ; + double dOffsPrec = 0. ; while ( nIter < MAX_ITER) { // ricavo la regione piana da VRONI PtrOwner pSfrOffsVR( pSrfAct->CreateOffsetSurf( - dOffs, ICurve::OFF_FILLET)) ; @@ -1942,16 +1942,17 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm } // controllo se serve un raggio più piccolo di svuotatura - bool bSmallRad = ( nIter == 0 ? dOffs - dOffsPrec < dRad + EPS_ZERO : dOffs - dOffsPrec < dRad + EPS_ZERO) ; - // memorizzo il valore di Offset per l'iterazione successiva - dOffsPrec = dOffs ; + bool bSmallRad = ( nIter == 0 ? dOffs < dRad + EPS_ZERO : dOffs - dOffsPrec < dRad + EPS_ZERO) ; // se ho trovato dei chunk, allora aggiorno l'Offset per la passata successiva - if ( nChunks > 0) + if ( nChunks > 0) { + // memorizzo il valore di Offset per l'iterazione successiva + dOffsPrec = dOffs ; dOffs += dStep ; + } // se devo usare un Offset più piccolo... else if ( ! bSmallRad) - dOffs += ( nIter == 0 ? dRad : dRad) ; // superfluo, effettivamente non ho l'offset radiale + dOffs = dOffsPrec + ( nIter == 0 ? dRad : dRad) ; // superfluo, effettivamente non ho l'offset radiale // altrimenti ho finito la regione da svuotare... else break ; From 650540e5731331f541d398e321c3af11c39b381d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 29 Dec 2023 12:55:24 +0100 Subject: [PATCH 02/13] EgtGeomKernel : - semplificata e ottimizzata creazione di superficie trimesh box standard - miglioramenti sintattici vari. --- Attribs.cpp | 47 ++- CAvToolSurfTm.cpp | 4 +- CurveComposite.cpp | 12 +- CurveComposite.h | 1 - DistLineLine.cpp | 8 +- DistLineLine.h | 22 +- DistPointArc.cpp | 11 +- DistPointArc.h | 17 +- DistPointCrvAux.cpp | 5 +- DistPointCrvBezier.cpp | 13 +- DistPointCrvBezier.h | 17 +- DistPointCrvComposite.cpp | 8 +- DistPointCrvComposite.h | 17 +- DistPointCurve.cpp | 18 +- DistPointLine.cpp | 8 +- DistPointLine.h | 18 +- DistPointSurfTm.cpp | 6 +- FontOs.cpp | 13 +- GdbExecutor.cpp | 160 ++++------ GdbGroup.cpp | 2 +- IterManager.h | 6 +- PolyArc.cpp | 40 +-- PolyLine.cpp | 29 +- StmFromTriangleSoup.cpp | 10 +- StmStandard.cpp | 52 ++-- SurfBezier.cpp | 33 +-- SurfTriMesh.cpp | 2 +- SurfTriMesh.h | 2 +- SurfTriMeshFaceting.cpp | 2 +- SurfTriMeshUtilities.cpp | 8 +- Tree.cpp | 608 ++++++++++++++------------------------ Tree.h | 216 ++++++++------ 32 files changed, 589 insertions(+), 826 deletions(-) diff --git a/Attribs.cpp b/Attribs.cpp index 06a064b..4aee267 100644 --- a/Attribs.cpp +++ b/Attribs.cpp @@ -81,8 +81,7 @@ Attribs::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine) } sOut += szNewLine ; // eventuali nome e stringhe informative - STRLIST::const_iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) + for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) sOut += *iIter + szNewLine ; return true ; @@ -101,7 +100,7 @@ Attribs::Save( NgeWriter& ngeOut) const // modo if ( ! ngeOut.WriteUchar( m_Data[MODE], ",")) return false ; - // stato (se SEL � convertito in ON) + // stato (se SEL è convertito in ON) int nStat = (( m_Data[STATUS] > GDB_ST_ON) ? GDB_ST_ON : m_Data[STATUS]) ; if ( ! ngeOut.WriteUchar( nStat, ",")) return false ; @@ -118,8 +117,7 @@ Attribs::Save( NgeWriter& ngeOut) const if ( ! ngeOut.WriteInt( int( m_slInfo.size()), ";", true)) return false ; // stringhe di info - STRLIST::const_iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { + for ( auto iIter = m_slInfo.cbegin() ; iIter != m_slInfo.cend() ; ++ iIter) { if ( ! ngeOut.WriteString( *iIter, nullptr, true)) return false ; } @@ -141,7 +139,7 @@ Attribs::Load( NgeReader& ngeIn) if ( ! ngeIn.ReadUchar( ucMode, ",")) return false ; m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ; - // stato (se SEL � convertito in ON) + // stato (se SEL è convertito in ON) unsigned char ucStat ; if ( ! ngeIn.ReadUchar( ucStat, ",")) return false ; @@ -177,7 +175,7 @@ Attribs::Load( NgeReader& ngeIn) bool Attribs::DataFromString( const string& sParam) { - // il primo parametro � diviso in 4 parti + // il primo parametro è diviso in 4 parti STRVECTOR vsParams ; Tokenize( sParam, ",", vsParams) ; // 4 parti @@ -215,10 +213,9 @@ Attribs::SetName( const string& sName) if ( sName.empty() || ! IsValidVal( sName)) return false ; - // pu� essere solo la prima stringa - STRLIST::iterator iIter ; - if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && - FindKey( *iIter, NAME)) { + // può essere solo la prima stringa + auto iIter = m_slInfo.begin() ; + if ( iIter != m_slInfo.end() && FindKey( *iIter, NAME)) { *iIter = NAME + EQUAL + sName ; return true ; } @@ -237,10 +234,9 @@ Attribs::SetName( const string& sName) bool Attribs::GetName( string& sName) const { - // pu� essere solo la prima stringa - STRLIST::const_iterator iIter ; - if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && - FindKey( *iIter, NAME)) { + // può essere solo la prima stringa + const auto iIter = m_slInfo.cbegin() ; + if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) { sName = iIter->substr( NAME.length() + 1) ; return true ; } @@ -252,23 +248,18 @@ Attribs::GetName( string& sName) const bool Attribs::ExistsName( void) const { - // pu� essere solo la prima stringa - STRLIST::const_iterator iIter ; - if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && - FindKey( *iIter, NAME)) - return true ; - - return false ; + // può essere solo la prima stringa + const auto iIter = m_slInfo.cbegin() ; + return ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) ; } //---------------------------------------------------------------------------- bool Attribs::RemoveName( void) { - // pu� essere solo la prima stringa - STRLIST::const_iterator iIter ; - if ( ( iIter = m_slInfo.begin()) != m_slInfo.end() && - FindKey( *iIter, NAME)) { + // può essere solo la prima stringa + const auto iIter = m_slInfo.cbegin() ; + if ( iIter != m_slInfo.cend() && FindKey( *iIter, NAME)) { m_slInfo.pop_front() ; return true ; } @@ -285,11 +276,11 @@ Attribs::SetInfo( const string& sKey, const string& sVal) if ( ! IsValidKey( sKey) || sVal.empty() || ! IsValidVal( sVal)) return false ; - // se � il nome + // se è il nome if ( sKey == NAME) return SetName( sVal) ; - // se esiste gi� una stringa con quella chiave la sostituisco + // se esiste già una stringa con quella chiave la sostituisco for ( auto iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { if ( FindKey( *iIter, sKey)) { *iIter = sKey + EQUAL + sVal ; diff --git a/CAvToolSurfTm.cpp b/CAvToolSurfTm.cpp index ba73ba0..878ea15 100644 --- a/CAvToolSurfTm.cpp +++ b/CAvToolSurfTm.cpp @@ -1,8 +1,8 @@ //---------------------------------------------------------------------------- // EgalTech 2018-2018 //---------------------------------------------------------------------------- -// File : CAToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2 -// Contenuto : Implementazione della classe CAToolSurfTm. +// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2 +// Contenuto : Implementazione della classe CAvToolSurfTm. // // // diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 11ca192..1990f14 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -832,8 +832,7 @@ CurveComposite::Validate( void) Point3d ptStart ; // ciclo su tutte le curve int nCount = 0 ; - PCSD_CONST_ITER Iter ; - for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) { + for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) { // verifico validità della curva e sua semplicità if ( ! (*Iter)->IsValid() || (*Iter)->GetType() == CRV_COMPO) { m_nStatus = ERR ; @@ -1188,8 +1187,7 @@ CurveComposite::GetLength( double& dLen) const // ciclo di calcolo dLen = 0 ; - PCSD_CONST_ITER Iter ; - for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) { + for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) { double dLenCrvSmpl ; if ( (*Iter)->GetLength( dLenCrvSmpl)) dLen += dLenCrvSmpl ; @@ -1215,8 +1213,7 @@ CurveComposite::GetLengthAtParam( double dU, double& dLen) const // ciclo di calcolo dLen = 0 ; double dUToGo = dU ; - PCSD_CONST_ITER Iter ; - for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) { + for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) { // dominio parametrico della curva semplice double dParStart, dParEnd ; (*Iter)->GetDomain( dParStart, dParEnd) ; @@ -1264,8 +1261,7 @@ CurveComposite::GetParamAtLength( double dLen, double& dU) const // ciclo di calcolo dU = 0 ; double dLenToGo = dLen ; - PCSD_CONST_ITER Iter ; - for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) { + for ( auto Iter = m_CrvSmplS.cbegin() ; Iter != m_CrvSmplS.cend() ; ++Iter) { // lunghezza della curva semplice double dCrvLen ; if ( ! (*Iter)->GetLength( dCrvLen)) diff --git a/CurveComposite.h b/CurveComposite.h index 33848ac..3eb7546 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -211,7 +211,6 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW private : typedef std::deque PCRVSMPL_DEQUE ; - typedef PCRVSMPL_DEQUE::iterator PCSD_ITER ; typedef PCRVSMPL_DEQUE::const_iterator PCSD_CONST_ITER ; private : diff --git a/DistLineLine.cpp b/DistLineLine.cpp index f915d9a..a045b45 100644 --- a/DistLineLine.cpp +++ b/DistLineLine.cpp @@ -59,7 +59,7 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d //---------------------------------------------------------------------------- bool -DistLineLine::GetSqDist( double& dSqDist) +DistLineLine::GetSqDist( double& dSqDist) const { if ( m_dSqDist < 0) return false ; @@ -70,7 +70,7 @@ DistLineLine::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistLineLine::GetDist( double& dDist) +DistLineLine::GetDist( double& dDist) const { if ( m_dSqDist < 0) return false ; @@ -83,7 +83,7 @@ DistLineLine::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) +DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const { if ( m_dSqDist < 0) return false ; @@ -94,7 +94,7 @@ DistLineLine::GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) //---------------------------------------------------------------------------- bool -DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) +DistLineLine::GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const { if ( m_dSqDist < 0) return false ; diff --git a/DistLineLine.h b/DistLineLine.h index ed817fb..1315c29 100644 --- a/DistLineLine.h +++ b/DistLineLine.h @@ -28,16 +28,16 @@ class DistLineLine bool bIsSegment1 = true, bool bIsSegment2 = true) ; public : - bool GetSqDist( double& dSqDist) ; - bool GetDist( double& dDist) ; - bool IsEpsilon( double dTol) { - double dSqDist ; - return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; - } - bool IsSmall( void) { return IsEpsilon( EPS_SMALL) ; } - bool IsZero( void) { return IsEpsilon( EPS_ZERO) ; } - bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) ; - bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) ; + bool GetSqDist( double& dSqDist) const ; + bool GetDist( double& dDist) const ; + bool IsEpsilon( double dTol) const + { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } + bool IsSmall( void) const + { return IsEpsilon( EPS_SMALL) ; } + bool IsZero( void) const + { return IsEpsilon( EPS_ZERO) ; } + bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const ; + bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const ; private : void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1, @@ -45,7 +45,7 @@ class DistLineLine bool bIsSegment1, bool bIsSegment2) ; private: double m_dSqDist ; - double m_dDist ; + mutable double m_dDist ; double m_dPos1 ; double m_dPos2 ; Point3d m_ptMinDist1 ; diff --git a/DistPointArc.cpp b/DistPointArc.cpp index 0b78be8..8d266a8 100644 --- a/DistPointArc.cpp +++ b/DistPointArc.cpp @@ -122,14 +122,13 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc) // cerco la minima distanza per la polilinea MDCVECTOR vApproxMin ; - MDCVECTOR::iterator Iter ; if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin)) return ; // raffino i punti trovati double dPolishedPar ; Point3d ptPolishedQ ; - for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { + for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { // eseguo raffinamento if ( PolishMinDistPointCurve( ptP, arArc, *Iter, dPolishedPar, ptPolishedQ)) { (*Iter).dDist = Dist( ptP, ptPolishedQ) ; @@ -148,7 +147,7 @@ DistPointArc::DistPointHelix( const Point3d& ptP, const ICurveArc& arArc) //---------------------------------------------------------------------------- bool -DistPointArc::GetSqDist( double& dSqDist) +DistPointArc::GetSqDist( double& dSqDist) const { if ( m_dDist < 0) return false ; @@ -159,7 +158,7 @@ DistPointArc::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistPointArc::GetDist( double& dDist) +DistPointArc::GetDist( double& dDist) const { if ( m_dDist < 0) return false ; @@ -170,7 +169,7 @@ DistPointArc::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) +DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const { if ( m_dDist < 0) return false ; @@ -185,7 +184,7 @@ DistPointArc::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) //---------------------------------------------------------------------------- bool -DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) +DistPointArc::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const { if ( m_dDist < 0) return false ; diff --git a/DistPointArc.h b/DistPointArc.h index 8998dd6..e1369d1 100644 --- a/DistPointArc.h +++ b/DistPointArc.h @@ -27,17 +27,18 @@ class DistPointArc DistPointArc( const Point3d& ptP, const ICurveArc& arArc) ; public : - bool GetSqDist( double& dSqDist) ; - bool GetDist( double& dDist) ; - bool IsEpsilon( double dTol) + bool GetSqDist( double& dSqDist) const ; + bool GetDist( double& dDist) const ; + bool IsEpsilon( double dTol) const { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } - bool IsSmall( void) + bool IsSmall( void) const { return IsEpsilon( EPS_SMALL) ; } - bool IsZero( void) + bool IsZero( void) const { return IsEpsilon( EPS_ZERO) ; } - int GetNbrMinDist( void) { return (int) m_Info.size() ; } - bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; - bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; + int GetNbrMinDist( void) const + { return (int) m_Info.size() ; } + bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ; + bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ; private : DistPointArc( void) ; diff --git a/DistPointCrvAux.cpp b/DistPointCrvAux.cpp index 2839d26..773df96 100644 --- a/DistPointCrvAux.cpp +++ b/DistPointCrvAux.cpp @@ -156,13 +156,10 @@ bool FilterMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve, const MDCVECTOR& vApproxMin, double& dMinDist, MDPCIVECTOR& Info) { - MDCVECTOR::const_iterator Iter ; - - // determino i minimi raffinati da tenere bool bFound = false ; bool bLastOnEnd = false ; // flag per ultimo punto su fine del suo intervallo - for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { + for ( auto Iter = vApproxMin.cbegin() ; Iter != vApproxMin.cend() ; ++Iter) { // altro punto con la stessa minima distanza if ( bFound && abs( (*Iter).dDist - dMinDist) < EPS_SMALL) { // se abbastanza lontano e non su bordi intervallino lo aggiungo diff --git a/DistPointCrvBezier.cpp b/DistPointCrvBezier.cpp index 7fc2f70..693d405 100644 --- a/DistPointCrvBezier.cpp +++ b/DistPointCrvBezier.cpp @@ -44,7 +44,6 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& // cerco la minima distanza per la polilinea MDCVECTOR vApproxMin ; - MDCVECTOR::iterator Iter ; if ( ! CalcMinDistPointPolyLine( ptP, PL, dLinTol, vApproxMin)) return ; @@ -52,7 +51,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& double dSingP ; if ( CrvBez.GetSingularParam( dSingP) == 0) dSingP = - 1 ; - for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { + for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { // imposto flag per singolarità agli estremi (*Iter).bParMinSing = abs( (*Iter).dParMin - dSingP) < EPS_SMALL ; (*Iter).bParMaxSing = abs( (*Iter).dParMax - dSingP) < EPS_SMALL ; @@ -61,7 +60,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& // raffino i punti trovati double dPolishedPar ; Point3d ptPolishedQ ; - for ( Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { + for ( auto Iter = vApproxMin.begin() ; Iter != vApproxMin.end() ; ++Iter) { // eseguo raffinamento if ( PolishMinDistPointCurve( ptP, CrvBez, *Iter, dPolishedPar, ptPolishedQ)) { (*Iter).dDist = Dist( ptP, ptPolishedQ) ; @@ -80,7 +79,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& //---------------------------------------------------------------------------- bool -DistPointCrvBezier::GetSqDist( double& dSqDist) +DistPointCrvBezier::GetSqDist( double& dSqDist) const { if ( m_dDist < 0) return false ; @@ -91,7 +90,7 @@ DistPointCrvBezier::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistPointCrvBezier::GetDist( double& dDist) +DistPointCrvBezier::GetDist( double& dDist) const { if ( m_dDist < 0) return false ; @@ -102,7 +101,7 @@ DistPointCrvBezier::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) +DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const { if ( m_dDist < 0) return false ; @@ -117,7 +116,7 @@ DistPointCrvBezier::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) //---------------------------------------------------------------------------- bool -DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) +DistPointCrvBezier::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const { if ( m_dDist < 0) return false ; diff --git a/DistPointCrvBezier.h b/DistPointCrvBezier.h index 1cac563..3033756 100644 --- a/DistPointCrvBezier.h +++ b/DistPointCrvBezier.h @@ -27,17 +27,18 @@ class DistPointCrvBezier DistPointCrvBezier( const Point3d& ptP, const ICurveBezier& CrvBez) ; public : - bool GetSqDist( double& dSqDist) ; - bool GetDist( double& dDist) ; - bool IsEpsilon( double dTol) + bool GetSqDist( double& dSqDist) const ; + bool GetDist( double& dDist) const ; + bool IsEpsilon( double dTol) const { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } - bool IsSmall( void) + bool IsSmall( void) const { return IsEpsilon( EPS_SMALL) ; } - bool IsZero( void) + bool IsZero( void) const { return IsEpsilon( EPS_ZERO) ; } - int GetNbrMinDist( void) { return (int) m_Info.size() ; } - bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; - bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; + int GetNbrMinDist( void) const + { return (int) m_Info.size() ; } + bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ; + bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ; private : DistPointCrvBezier( void) ; diff --git a/DistPointCrvComposite.cpp b/DistPointCrvComposite.cpp index 45f57fb..42a634c 100644 --- a/DistPointCrvComposite.cpp +++ b/DistPointCrvComposite.cpp @@ -129,7 +129,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo //---------------------------------------------------------------------------- bool -DistPointCrvComposite::GetSqDist( double& dSqDist) +DistPointCrvComposite::GetSqDist( double& dSqDist) const { if ( m_dDist < 0) return false ; @@ -140,7 +140,7 @@ DistPointCrvComposite::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistPointCrvComposite::GetDist( double& dDist) +DistPointCrvComposite::GetDist( double& dDist) const { if ( m_dDist < 0) return false ; @@ -151,7 +151,7 @@ DistPointCrvComposite::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) +DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const { if ( m_dDist < 0) return false ; @@ -166,7 +166,7 @@ DistPointCrvComposite::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag //---------------------------------------------------------------------------- bool -DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) +DistPointCrvComposite::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const { if ( m_dDist < 0) return false ; diff --git a/DistPointCrvComposite.h b/DistPointCrvComposite.h index c35f489..f7d20bc 100644 --- a/DistPointCrvComposite.h +++ b/DistPointCrvComposite.h @@ -26,17 +26,18 @@ class DistPointCrvComposite DistPointCrvComposite( const Point3d& ptP, const ICurveComposite& CrvCompo) ; public : - bool GetSqDist( double& dSqDist) ; - bool GetDist( double& dDist) ; - bool IsEpsilon( double dTol) + bool GetSqDist( double& dSqDist) const ; + bool GetDist( double& dDist) const ; + bool IsEpsilon( double dTol) const { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } - bool IsSmall( void) + bool IsSmall( void) const { return IsEpsilon( EPS_SMALL) ; } - bool IsZero( void) + bool IsZero( void) const { return IsEpsilon( EPS_ZERO) ; } - int GetNbrMinDist( void) { return (int) m_Info.size() ; } - bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) ; - bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) ; + int GetNbrMinDist( void) const + { return (int) m_Info.size() ; } + bool GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const ; + bool GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const ; private : DistPointCrvComposite( void) ; diff --git a/DistPointCurve.cpp b/DistPointCurve.cpp index 5485307..01a37f9 100644 --- a/DistPointCurve.cpp +++ b/DistPointCurve.cpp @@ -98,7 +98,7 @@ DistPointCurve::CrvCompositeCalculate( const Point3d& ptP, const ICurve& Curve) //---------------------------------------------------------------------------- bool -DistPointCurve::GetSqDist( double& dSqDist) +DistPointCurve::GetSqDist( double& dSqDist) const { if ( m_dDist < 0) return false ; @@ -109,7 +109,7 @@ DistPointCurve::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistPointCurve::GetDist( double& dDist) +DistPointCurve::GetDist( double& dDist) const { if ( m_dDist < 0) return false ; @@ -120,7 +120,7 @@ DistPointCurve::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) +DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) const { if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size()) return false ; @@ -132,7 +132,7 @@ DistPointCurve::GetMinDistPoint( int nInd, Point3d& ptMinDist, int& nFlag) //---------------------------------------------------------------------------- bool -DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) +DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFlag) const { if ( m_dDist < 0 || m_Info.empty()) return false ; @@ -166,7 +166,7 @@ DistPointCurve::GetMinDistPoint( double dNearParam, Point3d& ptMinDist, int& nFl //---------------------------------------------------------------------------- bool -DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) +DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) const { if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size()) return false ; @@ -178,7 +178,7 @@ DistPointCurve::GetParamAtMinDistPoint( int nInd, double& dParam, int& nFlag) //---------------------------------------------------------------------------- bool -DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) +DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& nFlag) const { if ( m_dDist < 0 || m_Info.empty()) return false ; @@ -209,7 +209,7 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int& //---------------------------------------------------------------------------- bool -DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) +DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const { if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size()) return false ; @@ -257,7 +257,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide //---------------------------------------------------------------------------- bool -DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) +DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const { if ( m_dDist < 0 || m_Info.empty()) return false ; @@ -278,7 +278,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i //---------------------------------------------------------------------------- bool -DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) +DistPointCurve::GetMinDistInfo( int nInd, MinDistPCInfo& aInfo) const { if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size()) return false ; diff --git a/DistPointLine.cpp b/DistPointLine.cpp index f7bea33..ad97230 100644 --- a/DistPointLine.cpp +++ b/DistPointLine.cpp @@ -95,7 +95,7 @@ DistPointLine::Calculate( const Point3d& ptP, //---------------------------------------------------------------------------- bool -DistPointLine::GetSqDist( double& dSqDist) +DistPointLine::GetSqDist( double& dSqDist) const { if ( m_dSqDist < 0) return false ; @@ -106,7 +106,7 @@ DistPointLine::GetSqDist( double& dSqDist) //---------------------------------------------------------------------------- bool -DistPointLine::GetDist( double& dDist) +DistPointLine::GetDist( double& dDist) const { if ( m_dSqDist < 0) return false ; @@ -119,7 +119,7 @@ DistPointLine::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointLine::GetMinDistPoint( Point3d& ptMinDist) +DistPointLine::GetMinDistPoint( Point3d& ptMinDist) const { if ( m_dSqDist < 0) return false ; @@ -130,7 +130,7 @@ DistPointLine::GetMinDistPoint( Point3d& ptMinDist) //---------------------------------------------------------------------------- bool -DistPointLine::GetParamAtMinDistPoint( double& dParam) +DistPointLine::GetParamAtMinDistPoint( double& dParam) const { if ( m_dSqDist < 0) return false ; diff --git a/DistPointLine.h b/DistPointLine.h index e6b92be..08a3bdc 100644 --- a/DistPointLine.h +++ b/DistPointLine.h @@ -31,18 +31,18 @@ class DistPointLine const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ; public : - bool GetSqDist( double& dSqDist) ; - bool GetDist( double& dDist) ; - bool IsEpsilon( double dTol) + bool GetSqDist( double& dSqDist) const ; + bool GetDist( double& dDist) const ; + bool IsEpsilon( double dTol) const { double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; } - bool IsSmall( void) + bool IsSmall( void) const { return IsEpsilon( EPS_SMALL) ; } - bool IsZero( void) + bool IsZero( void) const { return IsEpsilon( EPS_ZERO) ; } - int GetNbrMinDist( void) + int GetNbrMinDist( void) const { return (( m_dSqDist < 0) ? 0 : 1) ; } - bool GetMinDistPoint( Point3d& ptMinDist) ; - bool GetParamAtMinDistPoint( double& dParam) ; + bool GetMinDistPoint( Point3d& ptMinDist) const ; + bool GetParamAtMinDistPoint( double& dParam) const ; private : DistPointLine( void) ; @@ -51,7 +51,7 @@ class DistPointLine private : double m_dSqDist ; - double m_dDist ; + mutable double m_dDist ; double m_dParam ; Point3d m_ptMinDist ; } ; diff --git a/DistPointSurfTm.cpp b/DistPointSurfTm.cpp index 44b340f..6ba054d 100644 --- a/DistPointSurfTm.cpp +++ b/DistPointSurfTm.cpp @@ -176,7 +176,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf) //---------------------------------------------------------------------------- bool -DistPointSurfTm::GetDist( double& dDist) +DistPointSurfTm::GetDist( double& dDist) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) @@ -188,7 +188,7 @@ DistPointSurfTm::GetDist( double& dDist) //---------------------------------------------------------------------------- bool -DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) +DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) @@ -200,7 +200,7 @@ DistPointSurfTm::GetMinDistPoint( Point3d& ptMinDistPoint) //---------------------------------------------------------------------------- bool -DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) +DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) diff --git a/FontOs.cpp b/FontOs.cpp index 1006509..08ae540 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -298,8 +298,7 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC)) return false ; // lo trasformo opportunamente - ICURVEPLIST::iterator iIter ; - for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) { + for ( auto iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) { // trasformazioni (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Translate( vtMove) ; @@ -464,8 +463,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl if ( ! GetCharOutline( vCode[i], dAdvance, lstPC)) return false ; // lo approssimo con segmenti di retta - ICURVEPLIST::iterator iIter ; - for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) { + for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) { // trasformazioni (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Translate( vtMove) ; @@ -478,7 +476,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl if ( vtMove.x > dMaxW) dMaxW = vtMove.x ; // ciclo di pulizia - for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) + for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) delete (*iIter) ; lstPC.clear() ; } @@ -549,8 +547,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double if ( ! GetCharOutline( vCode[i], dAdvance, lstPC)) return false ; // lo approssimo con segmenti di arco e retta - ICURVEPLIST::iterator iIter ; - for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) { + for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) { // trasformazioni (*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ; (*iIter)->Translate( vtMove) ; @@ -563,7 +560,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double if ( vtMove.x > dMaxW) dMaxW = vtMove.x ; // ciclo di pulizia - for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) + for ( auto iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) delete (*iIter) ; lstPC.clear() ; } diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index e73c658..43fadf4 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -1423,8 +1423,7 @@ GdbExecutor::CurveArcChangeRadius( const STRVECTOR& vsParams) if ( ! GetLengthParam( vsParams[1], dNewRad)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero l'arco ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ; if ( pCrvArc == nullptr) @@ -1452,8 +1451,7 @@ GdbExecutor::CurveArcChangeDeltaN( const STRVECTOR& vsParams) if ( ! GetLengthParam( vsParams[1], dNewDeltaN)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero l'arco ICurveArc* pCrvArc = GetCurveArc( m_pGDB->GetGeoObj( *Iter)) ; if ( pCrvArc == nullptr) @@ -1686,8 +1684,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams) if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero la curva int nIdCrv = *Iter ; const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nIdCrv)) ; @@ -1722,7 +1719,7 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams) if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) { // se richiesto, cancello le curve originali if ( bErase) { - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->Erase( *Iter)) return false ; } @@ -2309,8 +2306,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams) if ( ! StmFts.Start()) return false ; // Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero la superficie sorgente const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; if ( pStmS == nullptr) @@ -2340,7 +2336,7 @@ GdbExecutor::SurfTriMeshByTriangleSoup( const STRVECTOR& vsParams) if ( AddGeoObj( vsParams[0], vsParams[1], pSTM)) { // se richiesto, cancello le curve originali if ( bErase) { - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->Erase( *Iter)) return false ; } @@ -2534,8 +2530,7 @@ GdbExecutor::SurfTriMeshDoCompacting( const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // opero sui diversi oggetti - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero la superficie ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; if ( pStm == nullptr) @@ -2572,8 +2567,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[1], vnNames)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero la superficie da cucire const ISurfTriMesh* pStmS = GetSurfTriMesh( m_pGDB->GetGeoObj( *Iter)) ; if ( pStmS == nullptr) @@ -2590,7 +2584,7 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams) } // se richiesto, cancello le superfici cucite alla prima if ( bErase) { - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) m_pGDB->Erase( *Iter) ; } return true ; @@ -5432,8 +5426,7 @@ GdbExecutor::TextOutline( const STRVECTOR& vsParams) pTXT->GetOutline( lstPCRV) ; // inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento bool bOk = true ; - ICURVEPLIST::iterator iIter ; - for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { + for ( auto iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { (*iIter)->LocToLoc( frTXT, frDest) ; if ( m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter)) == GDB_ID_NULL) { delete (*iIter) ; @@ -5510,8 +5503,7 @@ GdbExecutor::GetNamesParam( const string& sParam, INTVECTOR& vnNames) // converto in interi vnNames.clear() ; vnNames.reserve( vsNames.size()) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) { + for ( auto Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) { Trim( (*Iter), " \t\r\n()") ; int nId = GetIdParam( *Iter) ; if ( nId != GDB_ID_SEL) { @@ -5538,8 +5530,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector // divido in parti STRVECTOR vsParams ; Tokenize( sParam, ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // se 2 parti, allora Z = 0 if ( vsParams.size() == 2) { @@ -5594,8 +5585,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // ci deve essere almeno un parametro if ( vsParams.size() < 1) @@ -5747,8 +5737,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& // divido in parti STRVECTOR vsParams ; Tokenize( sParam, ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // se 2 parti, allora Z = 0 if ( vsParams.size() == 2) { @@ -5778,8 +5767,7 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // ci deve essere almeno un parametro if ( vsParams.size() < 1) @@ -5962,8 +5950,7 @@ GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PolyLin Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ; // converto in punti PL.Clear() ; - STRVECTOR::iterator Iter ; - for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) { + for ( auto Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) { Trim( (*Iter), " \t\r\n") ; if ( GetIdParam( *Iter) == GDB_ID_SEL) { int nId = m_pGDB->GetFirstSelectedObj() ; @@ -5997,8 +5984,7 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d // divido in parti STRVECTOR vsParams ; Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // se 4 parti, sono 3 coordinate e un peso @@ -6037,8 +6023,7 @@ GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, PolyAr Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ; // converto in punti PA.Clear() ; - STRVECTOR::iterator Iter ; - for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) { + for ( auto Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) { Trim( (*Iter), " \t\r\n") ; Point3d ptP ; double dBulge ; @@ -6059,8 +6044,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen) // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 1), ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // ci deve essere almeno un parametro if ( vsParams.size() < 1) @@ -6082,8 +6066,7 @@ GdbExecutor::GetLengthParam( const string& sParam, double& dLen) // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 1), ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // ci deve essere almeno un parametro if ( vsParams.size() < 1) @@ -6118,8 +6101,7 @@ GdbExecutor::GetDirParam( const string& sParam, const Frame3d& frDir, double& dD // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 3, sParam.length()-4), ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // ci deve essere almeno un parametro if ( vsParams.size() < 1) @@ -6263,8 +6245,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d& // divido in parti ed elimino spazi iniziali/finali STRVECTOR vsParams ; Tokenize( sTmp, ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // verifico siano 4 parti e le converto if ( vsParams.size() != 4) @@ -6291,8 +6272,7 @@ GdbExecutor::GetFrameParam( const string& sParam, const Frame3d& frRef, Frame3d& // divido in parti ed elimino spazi iniziali/finali STRVECTOR vsParams ; Tokenize( sTmp, ",", "(", ")", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n") ; // se c'è un parametro è l'origine Point3d ptOrig ; @@ -6358,8 +6338,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol) // divido in parti STRVECTOR vsParams ; Tokenize( sParam, ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // devono essere 3 o 4 parametri ( Red, Green, Blue [, Alpha]) if ( vsParams.size() != 3 && vsParams.size() != 4) @@ -6387,8 +6366,7 @@ GdbExecutor::GetColorParam( const string& sParam, bool& bByParent, Color& cCol) // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 1), ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // ci deve essere un parametro if ( vsParams.size() != 1) @@ -6421,8 +6399,7 @@ GdbExecutor::GetMaterialParam( const string& sParam, bool& bByParent, int& nMat) // recupero i parametri associati STRVECTOR vsParams ; Tokenize( sParam.substr( 1), ",", vsParams) ; - STRVECTOR::iterator Iter ; - for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) + for ( auto Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; // ci deve essere un parametro if ( vsParams.size() != 1) @@ -6479,8 +6456,7 @@ GdbExecutor::ExecuteLevel( const string& sCmd2, const STRVECTOR& vsParams) else return false ; // esecuzione impostazione livello - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SetLevel( *Iter, nLevel)) return false ; } @@ -6511,8 +6487,7 @@ GdbExecutor::ExecuteMode( const string& sCmd2, const STRVECTOR& vsParams) else return false ; // esecuzione impostazione modo - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SetMode( *Iter, nMode)) return false ; } @@ -6543,8 +6518,7 @@ GdbExecutor::ExecuteStatus( const string& sCmd2, const STRVECTOR& vsParams) else return false ; // esecuzione impostazione stato - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SetStatus( *Iter, nStat)) return false ; } @@ -6565,8 +6539,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione selezione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SelectObj( *Iter)) return false ; } @@ -6610,8 +6583,7 @@ GdbExecutor::ExecuteSelect( const string& sCmd2, const STRVECTOR& vsParams) nFilter = EXT_TEXT ; } // esecuzione selezione di tutti gli oggetti di ogni gruppo - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SelectGroupObjs( *Iter, nFilter)) return false ; } @@ -6635,8 +6607,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione deselezione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->DeselectObj( *Iter)) return false ; } @@ -6652,8 +6623,7 @@ GdbExecutor::ExecuteDeselect( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione deselezione di tutti gli oggetti di ogni gruppo - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->DeselectGroupObjs( *Iter)) return false ; } @@ -6710,8 +6680,7 @@ GdbExecutor::MaterialColor( const STRVECTOR& vsParams) if ( ! GetColorParam( vsParams[1], bByParent, cCol)) return false ; // esecuzione impostazione colore - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( bByParent) { if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT)) return false ; @@ -6741,8 +6710,7 @@ GdbExecutor::MaterialMaterial( const STRVECTOR& vsParams) if ( ! GetMaterialParam( vsParams[1], bByParent, nMat)) return false ; // esecuzione impostazione colore - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( bByParent) { if ( ! m_pGDB->SetMaterial( *Iter, GDB_MT_PARENT)) return false ; @@ -6789,8 +6757,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetStringParam( vsParams[1], sName)) return false ; // eseguo assegnazione nome - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SetName( *Iter, sName)) return false ; } @@ -6806,8 +6773,7 @@ GdbExecutor::ExecuteName( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // eseguo rimozione nome - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->RemoveName( *Iter)) return false ; } @@ -6839,8 +6805,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetStringParam( vsParams[2], sInfo)) return false ; // eseguo assegnazione Info di data Key - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->SetInfo( *Iter, sKey, sInfo)) return false ; } @@ -6860,8 +6825,7 @@ GdbExecutor::ExecuteInfo( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetStringParam( vsParams[1], sKey)) return false ; // eseguo rimozione nome Info di data Key - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->RemoveInfo( *Iter, sKey)) return false ; } @@ -7010,8 +6974,7 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams) // recupero flag per globale bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; // esecuzione rilocazioni - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( bGlob) { if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter)) return false ; @@ -7036,8 +6999,7 @@ GdbExecutor::ExecuteErase( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione cancellazioni - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { if ( ! m_pGDB->Erase( *Iter)) return false ; } @@ -7079,8 +7041,7 @@ GdbExecutor::ExecuteTranslate( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetVectorParam( vsParams[1], frRef, vtVN)) return false ; // esecuzione traslazioni - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { switch ( nTraType) { case TRA_LOC : if ( ! m_pGDB->Translate( *Iter, vtVN)) @@ -7144,8 +7105,7 @@ GdbExecutor::ExecuteRotate( const string& sCmd2, const STRVECTOR& vsParams) if ( ! FromString( vsParams[3], dAngDeg)) return false ; // esecuzione rotazioni - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { switch ( nRotType) { case ROT_LOC : if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg)) @@ -7214,8 +7174,7 @@ GdbExecutor::ExecuteScale( const string& sCmd2, const STRVECTOR& vsParams) ! FromString( vsParams[4], dCoeffZ)) return false ; // esecuzione scalature - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { switch ( nScaType) { case SCA_LOC : if ( ! m_pGDB->Scale( *Iter, frFrame, dCoeffX, dCoeffY, dCoeffZ)) @@ -7273,8 +7232,7 @@ GdbExecutor::ExecuteMirror( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetVectorParam( vsParams[2], frRef, vtVN)) return false ; // esecuzione specchiature - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { switch ( nMirType) { case MIR_LOC : if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN)) @@ -7340,8 +7298,7 @@ GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams) if ( ! FromString( vsParams[4], dCoeff)) return false ; // esecuzione scorrimenti - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { switch ( nMirType) { case MIR_LOC : if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff)) @@ -7400,8 +7357,7 @@ GdbExecutor::CurveModifyInvert( const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione inversione curve - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { ICurve* pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter)) ; if ( pCurve == nullptr || ! pCurve->Invert()) return false ; @@ -7518,8 +7474,7 @@ GdbExecutor::CurveModifyTrim( const STRVECTOR& vsParams, int nTrimType) if ( ! FromString( vsParams[1], dPar)) return false ; // esecuzione trim - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { ICurve* pCurve ; if ( ( pCurve = GetCurve( m_pGDB->GetGeoObj( *Iter))) != nullptr) { switch ( nTrimType) { @@ -7718,8 +7673,7 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams) // preparo i dati per il concatenamento ChainCurves chainC ; chainC.Init( bAllowInvert, dToler, int( vnNames.size())) ; - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero la curva e il suo riferimento ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( *Iter)) ; if ( pCrv == nullptr) @@ -7748,10 +7702,9 @@ GdbExecutor::CurveCopyByChain( const STRVECTOR& vsParams) if ( IsNull( pCrvCompo)) return false ; // recupero le curve semplici e le inserisco nella curva composita - INTVECTOR::iterator Iter2 ; - for ( Iter2 = vIds.begin() ; Iter2 != vIds.end() ; ++Iter2) { - int nId = abs( *Iter2) ; - bool bInvert = ( *Iter2 < 0) ; + for ( auto Iter = vIds.cbegin() ; Iter != vIds.cend() ; ++Iter) { + int nId = abs( *Iter) ; + bool bInvert = ( *Iter < 0) ; // recupero la curva e il suo riferimento ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ; if ( pCrv == nullptr) @@ -7806,8 +7759,7 @@ GdbExecutor::SurfModifyInvert( const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione inversione normale superficie - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { ISurf* pSurf = GetSurf( m_pGDB->GetGeoObj( *Iter)) ; if ( pSurf == nullptr || ! pSurf->Invert()) return false ; @@ -8049,8 +8001,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero l'oggetto ed eseguo l'output if ( ! OutGroupTsc( *Iter, nFlag)) return false ; @@ -8073,8 +8024,7 @@ GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // esecuzione - INTVECTOR::iterator Iter ; - for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { + for ( auto Iter = vnNames.cbegin() ; Iter != vnNames.cend() ; ++Iter) { // recupero l'oggetto ed eseguo l'output if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag)) return false ; diff --git a/GdbGroup.cpp b/GdbGroup.cpp index df1a7fd..173490f 100644 --- a/GdbGroup.cpp +++ b/GdbGroup.cpp @@ -44,7 +44,7 @@ GdbGroup::~GdbGroup( void) // nel sorgente aggiorno lista dei riferimenti INTVECTOR vnList ; pGdbObj->GetInfo( GDB_SI_LIST, vnList) ; - INTVECTOR::const_iterator iFind = find( vnList.begin(), vnList.end(), m_nId) ; + const auto iFind = find( vnList.begin(), vnList.end(), m_nId) ; if ( iFind != vnList.end()) vnList.erase( iFind) ; if ( vnList.empty()) diff --git a/IterManager.h b/IterManager.h index 2b86401..18bd1c7 100644 --- a/IterManager.h +++ b/IterManager.h @@ -26,8 +26,7 @@ class IterManager { public : bool IsGdbIteratorInList( GdbIterator* pIter) - { PGDBI_LIST::const_iterator Iter ; - for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) { + { for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) { if ( *Iter == pIter) return true ; } @@ -41,8 +40,7 @@ class IterManager catch (...) { return false ;} return true ; } bool RemoveGdbIterator( GdbIterator* pIter) - { PGDBI_LIST::iterator Iter ; - for ( Iter = m_IterList.begin() ; Iter != m_IterList.end() ; ++ Iter) { + { for ( auto Iter = m_IterList.cbegin() ; Iter != m_IterList.cend() ; ++ Iter) { if ( *Iter == pIter) { m_IterList.erase( Iter) ; return true ; diff --git a/PolyArc.cpp b/PolyArc.cpp index 7d0eeca..e2e549a 100644 --- a/PolyArc.cpp +++ b/PolyArc.cpp @@ -147,8 +147,7 @@ PolyArc::EraseLastUPoint( void) bool PolyArc::AddOffsetToU( double dOffset) { - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->dU += dOffset ; return true ; @@ -173,8 +172,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU) else return false ; // eseguo la riparametrizzazione - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->dU = dStartU + dCoeff * ( iter->dU - dOriStartU) ; return true ; } @@ -183,8 +181,7 @@ PolyArc::ParamLinearTransform( double dStartU, double dEndU) bool PolyArc::SetElevation( double dZ) { - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.z = dZ ; return true ; @@ -194,8 +191,7 @@ PolyArc::SetElevation( double dZ) bool PolyArc::AddElevation( double dZ) { - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.z += dZ ; return true ; @@ -206,8 +202,7 @@ bool PolyArc::Translate( const Vector3d& vtMove) { // il vettore estrusione non subisce modifiche - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.Translate( vtMove) ; return true ; @@ -218,8 +213,7 @@ bool PolyArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) { m_vtExtr.Rotate( vtAx, dCosAng, dSinAng) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; return true ; @@ -230,8 +224,7 @@ bool PolyArc::Scale( const Frame3d& frRef, double dCoeff) { m_vtExtr.Scale( frRef, dCoeff, dCoeff, dCoeff) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.Scale( frRef, dCoeff, dCoeff, dCoeff) ; return true ; @@ -242,8 +235,7 @@ bool PolyArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) { m_vtExtr.Mirror( vtNorm) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { iter->ptP.Mirror( ptOn, vtNorm) ; iter->dB *= - 1 ; } @@ -256,8 +248,7 @@ bool PolyArc::ToGlob( const Frame3d& frRef) { m_vtExtr.ToGlob( frRef) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.ToGlob( frRef) ; return true ; @@ -268,8 +259,7 @@ bool PolyArc::ToLoc( const Frame3d& frRef) { m_vtExtr.ToLoc( frRef) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.ToLoc( frRef) ; return true ; @@ -284,8 +274,7 @@ PolyArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) return true ; // ciclo sui punti m_vtExtr.LocToLoc( frOri, frDest) ; - UPNTBLIST::iterator iter ; - for ( iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) iter->ptP.LocToLoc( frOri, frDest) ; return true ; @@ -319,8 +308,7 @@ PolyArc::Split( double dU, PolyArc& PA) // pulisco la polilinea destinazione PA.Clear() ; // ricerca del punto in cui dividere - UPNTBLIST::const_iterator iter ; - iter = m_lUPointBs.begin() ; + auto iter = m_lUPointBs.begin() ; while ( iter != m_lUPointBs.end() && iter->dU < ( dU + EPS_PARAM)) ++ iter ; if ( iter == m_lUPointBs.end()) @@ -585,7 +573,7 @@ PolyArc::Invert( bool bInvertU) // inverto la lista m_lUPointBs.reverse() ; // sposto il bulge all'estremo iniziale di ogni tratto (l'ultimo non conta) e lo inverto - for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { if ( next( iter) != m_lUPointBs.end()) iter->dB = - next( iter)->dB ; else @@ -596,7 +584,7 @@ PolyArc::Invert( bool bInvertU) // recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione double dUfin = m_lUPointBs.front().dU ; // ciclo su tutti gli elementi - for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { + for ( auto iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { iter->dU = dUfin - iter->dU ; } } diff --git a/PolyLine.cpp b/PolyLine.cpp index 85242fc..d9fb83a 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -139,8 +139,7 @@ PolyLine::EraseLastUPoint( void) bool PolyLine::AddOffsetToU( double dOffset) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->second += dOffset ; return true ; @@ -150,8 +149,7 @@ PolyLine::AddOffsetToU( double dOffset) bool PolyLine::Translate( const Vector3d& vtMove) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.Translate( vtMove) ; return true ; @@ -161,8 +159,7 @@ PolyLine::Translate( const Vector3d& vtMove) bool PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; return true ; @@ -172,8 +169,7 @@ PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou bool PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ; return true ; @@ -183,8 +179,7 @@ PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC bool PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.Mirror( ptOn, vtNorm) ; return true ; @@ -194,8 +189,7 @@ PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) bool PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.Shear( ptOn, vtNorm, vtDir, dCoeff) ; return true ; @@ -205,8 +199,7 @@ PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vt bool PolyLine::ToGlob( const Frame3d& frRef) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.ToGlob( frRef) ; return true ; @@ -216,8 +209,7 @@ PolyLine::ToGlob( const Frame3d& frRef) bool PolyLine::ToLoc( const Frame3d& frRef) { - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.ToLoc( frRef) ; return true ; @@ -231,8 +223,7 @@ PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) if ( AreSameFrame( frOri, frDest)) return true ; // ciclo sui punti - PNTULIST::iterator iter ; - for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) + for ( auto iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter) iter->first.LocToLoc( frOri, frDest) ; return true ; @@ -683,7 +674,7 @@ PolyLine::GetMaxDistanceFromLine( const Point3d& ptLine, const Vector3d& vtLine, bool PolyLine::AdjustForMaxSegmentLen( double dMaxLen) { - PNTULIST::iterator iter = m_lUPoints.begin() ; + auto iter = m_lUPoints.begin() ; // se non ci sono punti, esco subito if ( iter == m_lUPoints.end()) return false ; diff --git a/StmFromTriangleSoup.cpp b/StmFromTriangleSoup.cpp index e83191b..0e3a7e6 100644 --- a/StmFromTriangleSoup.cpp +++ b/StmFromTriangleSoup.cpp @@ -4,7 +4,7 @@ // File : StmFromTriangleSoup.cpp Data : 07.05.23 Versione : 2.5e2 // Contenuto : Implementazione della classe StmFromTriangleSoup, per creare // una superficie trimesh da un insieme di triangoli -// (pu� essere disordinato come STL o pu� essere una superficie). +// (può essere disordinato come STL o può essere una superficie). // // Modifiche : 19.05.14 DS Creazione modulo. // @@ -53,7 +53,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria) // ciclo sui tre vertici int nIdV[3] ; for ( int i = 0 ; i < 3 ; ++ i) { - // verifico se vertice gi� presente + // verifico se vertice già presente int nId ; if ( ! m_VertGrid.Find( Tria.GetP( i), 2 * EPS_SMALL, nId)) { // aggiungo il vertice @@ -77,7 +77,7 @@ StmFromTriangleSoup::AddTriangle( const Triangle3d& Tria) //---------------------------------------------------------------------------- bool StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2, - const double dU0, const double dV0,const double dU1, const double dV1,const double dU2, const double dV2) + double dU0, double dV0, double dU1, double dV1, double dU2, double dV2) { // verifico inizializzazione if ( m_pSTM == nullptr) @@ -100,9 +100,9 @@ StmFromTriangleSoup::AddTriangle( const Point3d& ptP0, const Point3d& ptP1, cons //---------------------------------------------------------------------------- int -StmFromTriangleSoup::AddVertex( const Point3d& ptP, const double dU, const double dV) +StmFromTriangleSoup::AddVertex( const Point3d& ptP, double dU, double dV) { - // verifico se gi� presente + // verifico se già presente int nId ; if ( m_VertGrid.Find( ptP, 2 * EPS_SMALL, nId)) return nId ; diff --git a/StmStandard.cpp b/StmStandard.cpp index 3bf1bc2..e32198a 100644 --- a/StmStandard.cpp +++ b/StmStandard.cpp @@ -26,34 +26,36 @@ using namespace std ; static SurfTriMesh* GetStandardSurfTriMeshBox( double dDimX, double dDimY, double dHeight) { - // creo la polilinea del contorno della base - PolyLine PL ; - int nU = 0 ; - PL.AddUPoint( nU, Point3d( 0, 0, 0)) ; - PL.AddUPoint( ++ nU, Point3d( dDimX, 0, 0)) ; - PL.AddUPoint( ++ nU, Point3d( dDimX, dDimY, 0)) ; - PL.AddUPoint( ++ nU, Point3d( 0, dDimY, 0)) ; - PL.AddUPoint( ++ nU, Point3d( 0, 0, 0)) ; - if ( dHeight < 0) - PL.Invert() ; - // vettore altezza (estrusione) - Vector3d vtExtr( 0, 0, dHeight) ; - // creo e setto la superficie trimesh laterale + // creo oggetto vuoto PtrOwner pSTM( CreateBasicSurfTriMesh()) ; - if ( IsNull( pSTM) || ! pSTM->CreateByExtrusion( PL, vtExtr)) + if ( IsNull( pSTM)) return nullptr ; - // creo la prima superficie di estremità - SurfTriMesh STM1 ; - if ( ! STM1.CreateByFlatContour( PL)) + // assegno i vertici + double dBotZ = 0, dTopZ = dHeight ; + if ( dBotZ > dTopZ) + swap( dBotZ, dTopZ) ; + if ( pSTM->AddVertex( Point3d( 0, 0, dBotZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( 0, 0, dTopZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( dDimX, 0, dBotZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( dDimX, 0, dTopZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( dDimX, dDimY, dBotZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( dDimX, dDimY, dTopZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( 0, dDimY, dBotZ)) == SVT_NULL || + pSTM->AddVertex( Point3d( 0, dDimY, dTopZ)) == SVT_NULL) return nullptr ; - // la copio - SurfTriMesh STM2 = STM1 ; - // inverto la prima superficie - STM1.Invert() ; - // traslo la seconda - STM2.Translate( Vector3d( 0, 0, dHeight)) ; - // le unisco alla superficie del fianco - if ( ! pSTM->DoSewing( STM1) || ! pSTM->DoSewing( STM2)) + // definisco i triangoli + int aVertId[12][3]{{ 1, 0, 2}, { 1, 2, 3}, + { 3, 2, 4}, { 3, 4, 5}, + { 5, 4, 6}, { 5, 6, 7}, + { 7, 6, 0}, { 7, 0, 1}, + { 0, 4, 2}, { 6, 4, 0}, + { 1, 3, 5}, { 7, 1, 5}} ; + for ( int i = 0 ; i < 12 ; ++ i) { + if ( pSTM->AddTriangle( aVertId[i]) == SVT_NULL) + return nullptr ; + } + // sistemo la topologia + if ( ! pSTM->AdjustTopology()) return nullptr ; // restituisco la superficie return Release( pSTM) ; diff --git a/SurfBezier.cpp b/SurfBezier.cpp index b005b74..d1ee4a1 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -1501,30 +1501,27 @@ SurfBezier::GetAuxSurf( void) const if ( m_pSTM != nullptr) return m_pSTM ; - // costruttore della superficie - vector vvPL ; + // costruttore della superficie + POLYLINEMATRIX vvPL ; //POLYLINEVECTOR vPL ; // per usare i polygon basic Tree Tree( this, true) ; - std::vector> vTrees ; + BIPNTVECTOR vTrees ; Tree.GetIndependentTrees( vTrees) ; for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) { Point3d ptMin = std::get<0>( vTrees[i]) ; Point3d ptMax = std::get<1>( vTrees[i]) ; Tree.SetSurf( this, true, ptMin, ptMax) ; - //Tree.BuildTree_test() ; // per debug - //Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ; Tree.GetPolygons( vvPL) ; //Tree.GetPolygonsBasic( vPL) ; // per usare i polygon basic } - //// per usare i polygon basic////////////////////// + //// per usare i polygon basic////////////////////// //for (int k = 0 ; k < (int)vPL.size(); ++k) { // vvPL.emplace_back() ; // vvPL.back().push_back(vPL[k]) ; //} - //// per usare i polygon basic/////////////////// + //// per usare i polygon basic/////////////////// - PtrOwner pSrfTm( CreateBasicSurfTriMesh()) ; StmFromTriangleSoup stmSoup ; if ( ! stmSoup.Start()) return nullptr ; @@ -1565,24 +1562,20 @@ SurfBezier::GetAuxSurf( void) const //---------------------------------------------------------------------------- bool -SurfBezier::GetLeaves( std::vector>& vLeaves) const +SurfBezier::GetLeaves( vector>& vLeaves) const { - std::vector vCells ; Tree Tree( this, true) ; - std::vector> vTrees ; + BIPNTVECTOR vTrees ; Tree.GetIndependentTrees( vTrees) ; - for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) { - Point3d ptMin = std::get<0>( vTrees[i]) ; - Point3d ptMax = std::get<1>( vTrees[i]) ; + for ( int i = 0 ; i < int( vTrees.size()) ; ++ i) { + Point3d ptMin = get<0>( vTrees[i]) ; + Point3d ptMax = get<1>( vTrees[i]) ; Tree.SetSurf( this, true, ptMin, ptMax) ; - //Tree.BuildTree_test() ; - //Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ; Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ; + vector vCells ; Tree.GetLeaves( vCells) ; - for (int k = 0 ; k < (int)vCells.size(); ++ k ) { - std::tuple tCell ; - tCell = make_tuple( vCells[k].m_nId, vCells[k].GetBottomLeft(), vCells[k].GetTopRight()) ; - vLeaves.push_back( tCell) ; + for ( int k = 0 ; k < int( vCells.size()) ; ++ k) { + vLeaves.emplace_back( vCells[k].m_nId, vCells[k].GetBottomLeft(), vCells[k].GetTopRight()) ; } } return true ; diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index 3a48d94..8bac766 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -106,7 +106,7 @@ SurfTriMesh::Clear( void) //---------------------------------------------------------------------------- int -SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV) +SurfTriMesh::AddVertex( const Point3d& ptVert, double dU, double dV) { // imposto ricalcolo m_nStatus = TO_VERIFY ; diff --git a/SurfTriMesh.h b/SurfTriMesh.h index fd35597..e78f3f5 100644 --- a/SurfTriMesh.h +++ b/SurfTriMesh.h @@ -226,7 +226,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW { m_dSmoothAng = std::max( dSmoothAngDeg, EPS_ANG_SMALL) ; m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ; m_OGrMgr.Reset() ; } - int AddVertex( const Point3d& ptVert, const double dU = -1 , const double dV = -1) override ; + int AddVertex( const Point3d& ptVert, double dU = -1, double dV = -1) override ; bool MoveVertex( int nInd, const Point3d& ptNewVert) override ; int AddTriangle( const int nIdVert[3], int nTFlag = 0) override ; bool RemoveTriangle( int nId) override ; diff --git a/SurfTriMeshFaceting.cpp b/SurfTriMeshFaceting.cpp index 66422c1..2b9df41 100644 --- a/SurfTriMeshFaceting.cpp +++ b/SurfTriMeshFaceting.cpp @@ -731,7 +731,7 @@ SurfTriMesh::CloneFacet( int nF) const int nIdV[3] ; for ( int j = 0 ; j < 3 ; ++ j) { // verifico se vertice già presente - VVMAP::iterator it = PntMap.find( m_vTria[nT].nIdVert[j]) ; + const auto it = PntMap.find( m_vTria[nT].nIdVert[j]) ; if ( it == PntMap.end()) { // aggiungo il vertice if ( ( nIdV[j] = pSTM->AddVertex( m_vVert[m_vTria[nT].nIdVert[j]].ptP)) == SVT_NULL) diff --git a/SurfTriMeshUtilities.cpp b/SurfTriMeshUtilities.cpp index 42467a3..3d6cea2 100644 --- a/SurfTriMeshUtilities.cpp +++ b/SurfTriMeshUtilities.cpp @@ -256,14 +256,14 @@ IsVertex( PNTULIST& PointList, PNTULIST::const_iterator itCurr) { // recupero il punto precedente PNTULIST::const_iterator itPrev ; - if ( itCurr == PointList.begin()) - itPrev = prev( PointList.end(), 2) ; + if ( itCurr == PointList.cbegin()) + itPrev = prev( PointList.cend(), 2) ; else itPrev = prev( itCurr) ; // recupero il punto successivo auto itNext = next( itCurr) ; - if ( itNext == PointList.end()) - itNext = next( PointList.begin()) ; + if ( itNext == PointList.cend()) + itNext = next( PointList.cbegin()) ; // se cambia faccia adiacente tra prima e dopo, va bene if ( itPrev->second != itCurr->second) return true ; diff --git a/Tree.cpp b/Tree.cpp index a6ffae9..276448e 100644 --- a/Tree.cpp +++ b/Tree.cpp @@ -13,7 +13,6 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include #include "Tree.h" #include "SurfBezier.h" #include "GeoConst.h" @@ -24,51 +23,9 @@ #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkCurve.h" -#include "DistPointCrvComposite.h" +#include -//---------------------------------------------------------------------------- -Cell::Cell( void) - : m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0), - m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), - m_ptPbl( ORIG), m_ptPtr(), m_bProcessed( false), m_bSplitVert( true) -{ - Point3d ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ; - m_ptPtr = ptTr ; -} - - -//---------------------------------------------------------------------------- -Cell::Cell( const Point3d& ptBL, const Point3d& ptTR) - : m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0), - m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), - m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) -{} - - -//---------------------------------------------------------------------------- -Cell::~Cell( void) -{ -} - -//---------------------------------------------------------------------------- -inline bool -Cell::IsSame( const Cell& cOtherCell) const -{ - if ( m_nId == cOtherCell.m_nId) - return true ; - else - return false ; -} - -//---------------------------------------------------------------------------- -bool -Cell::IsLeaf ( void) const -{ - if( m_nChild1 == -2 && m_nChild2 == -2) - return true ; - else - return false ; -} +using namespace std ; //---------------------------------------------------------------------------- Tree::Tree( void) @@ -76,11 +33,11 @@ Tree::Tree( void) { Point3d ptBl( 0, 0), ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ; Cell cRoot( ptBl, ptTr) ; - m_mTree.insert( std::pair< int, Cell>( -1, cRoot)) ; + m_mTree.insert( pair< int, Cell>( -1, cRoot)) ; } //---------------------------------------------------------------------------- -Tree::Tree( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d ptMin, const Point3d ptMax) +Tree::Tree( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d& ptMin, const Point3d& ptMax) : m_pSrfBz( nullptr), m_bTrimmed( false), m_bBilinear( false), m_bMulti( false), m_bClosedU( false), m_bClosedV( false), m_bSplitPatches( true) { SetSurf( pSrfBz, bSplitPatches, ptMin, ptMax) ; @@ -93,9 +50,9 @@ Tree::~Tree( void) //---------------------------------------------------------------------------- void -Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d ptMin, const Point3d ptMax) +Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMin, const Point3d& ptMax) { - // pulisco i vettori membri + // pulisco i vettori membri m_vnLeaves.clear() ; m_vnParents.clear() ; m_mVert.clear() ; @@ -105,8 +62,6 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d m_vChunk.clear() ; m_vPolygons.clear() ; - - m_pSrfBz = pSrfBz ; m_bSplitPatches = bSplitPatches ; // le coordinate delle celle sono nello spazio parametrico @@ -127,7 +82,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d int nLoop = 0 ; INTVECTOR vChunk ; - // recupero la superficie di trim per avere accesso diretto ai loop e mantenendo le informazioni sui chunk + // recupero la superficie di trim per avere accesso diretto ai loop e mantenendo le informazioni sui chunk PtrOwner pTrimReg( m_pSrfBz->GetTrimRegion()->Clone()) ; double dLinTol = 0.01 ; // questo è riferito allo spazio parametrico double dAngTolDeg = 5 ; @@ -135,17 +90,17 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d PtrOwner pChunk( pTrimReg->CloneChunk( i)) ; for ( int j = 0 ; j < pChunk->GetLoopCount( 0) ; ++ j) { vChunk.push_back( nLoop) ; - // i chunk della falt region sono ancora flat region composte da 1 chunk + // i chunk della falt region sono ancora flat region composte da 1 chunk PtrOwner pLoop ( pChunk->GetLoop( 0, j)) ; PtrOwner pCrv( pLoop->Clone()) ; m_vLoop.emplace_back( Release( pLoop)) ; m_mChunk[nLoop] = i ; ++ nLoop ; - // approssimo i loop di trim con delle spezzate + // approssimo i loop di trim con delle spezzate PolyLine plApprox ; int nType = 0 ; pCrv->ApproxWithLines( dLinTol,dAngTolDeg, nType, plApprox) ; - // calcolo se il loop è CCW o CW + // calcolo se il loop è CCW o CW double dArea ; Plane3d plExtPlane ; bool bCCW ; @@ -154,21 +109,21 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d bCCW = true ; else bCCW = false ; - m_vPlApprox.push_back( std::tuple(plApprox,bCCW)) ; + m_vPlApprox.push_back( tuple(plApprox,bCCW)) ; } - // li riordino dal più grande al più piccolo - std::sort(vChunk.begin(), vChunk.end(), [this]( const int& a, const int& b) { double dArea1, dArea2 ; - m_vLoop[a]->GetAreaXY( dArea1) ; - m_vLoop[b]->GetAreaXY( dArea2) ; - return dArea1 > dArea2 ;}) ; + // li riordino dal più grande al più piccolo + sort(vChunk.begin(), vChunk.end(), [this]( const int& a, const int& b) { double dArea1, dArea2 ; + m_vLoop[a]->GetAreaXY( dArea1) ; + m_vLoop[b]->GetAreaXY( dArea2) ; + return dArea1 > dArea2 ; }) ; m_vChunk.push_back( vChunk) ; vChunk.clear() ; } - // li riordino dal più grande al più piccolo - std::sort(m_vChunk.begin(), m_vChunk.end(), [this]( const INTVECTOR& a, const INTVECTOR& b) { double dArea1, dArea2 ; - m_vLoop[a[0]]->GetAreaXY( dArea1) ; - m_vLoop[b[0]]->GetAreaXY( dArea2) ; - return dArea1 > dArea2 ;}) ; + // li riordino dal più grande al più piccolo + sort(m_vChunk.begin(), m_vChunk.end(), [this]( const INTVECTOR& a, const INTVECTOR& b) { double dArea1, dArea2 ; + m_vLoop[a[0]]->GetAreaXY( dArea1) ; + m_vLoop[b[0]]->GetAreaXY( dArea2) ; + return dArea1 > dArea2 ;}) ; } // salvo i vertici 3d della cella root Point3d ptTop( nSpanU * SBZ_TREG_COEFF, nSpanV * SBZ_TREG_COEFF) ; @@ -179,7 +134,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d } m_mTree.clear() ; Cell cRoot( ptMin, ptTop) ; - m_mTree.insert( std::pair< int, Cell>( -1, cRoot)) ; + m_mTree.insert( pair< int, Cell>( -1, cRoot)) ; Point3d ptP00, ptP10, ptP11, ptP01 ; bool bOk = false ; if ( ! bLimited) { @@ -199,18 +154,18 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d vVert.push_back( ptP10) ; vVert.push_back( ptP11) ; vVert.push_back( ptP01) ; - m_mVert.insert( std::pair( -1, vVert)) ; + m_mVert.insert( pair( -1, vVert)) ; // se richiesto divido preliminarmente le patches m_vnParents.clear() ; if ( m_bSplitPatches && ( nSpanU > 1 || nSpanV > 1)) { int nId = -1 ; - // se la superficie è chiusa lungo il parametro U, sistemo le adiacenze al bordo + // se la superficie è chiusa lungo il parametro U, sistemo le adiacenze al bordo if ( AreSamePointApprox(ptP00, ptP10) && AreSamePointApprox(ptP01, ptP11) ) { m_mTree[-1].m_nLeft = -1 ; m_mTree[-1].m_nRight = -1 ; m_bClosedU = true ; } - // se la superficie è chiusa lungo il parametro V, sistemo le adiacenze al bordo + // se la superficie è chiusa lungo il parametro V, sistemo le adiacenze al bordo if ( ( AreSamePointApprox(ptP00, ptP01) && AreSamePointApprox(ptP10, ptP11) ) ) { m_mTree[-1].m_nTop = -1 ; m_mTree[-1].m_nBottom = -1 ; @@ -242,12 +197,12 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d GetHeightLeaves( -1, vLeaves) ; m_vnParents = vLeaves ; } - // controllo se la superficie è chiusa. - // se è chiusa e non ho già fatto split preliminare, splitto sul parametro su cui è chiusa - // e sistemo le adiacenze + // controllo se la superficie è chiusa. + // se è chiusa e non ho già fatto split preliminare, splitto sul parametro su cui è chiusa + // e sistemo le adiacenze if ( ( AreSamePointApprox( ptP00, ptP01) || AreSamePointApprox( ptP10, ptP11)) || ( AreSamePointApprox( ptP00, ptP10) || AreSamePointApprox( ptP01, ptP11))) { - //m_bClosed = true ; + // m_bClosed = true ; if ( ( AreSamePointApprox( ptP00, ptP01) || AreSamePointApprox( ptP10, ptP11)) && (int) m_mTree.size() == 1) { if ( AreSamePointApprox( ptP00, ptP01) && AreSamePointApprox( ptP10, ptP11)) { m_mTree[-1].m_nTop = -1 ; @@ -256,13 +211,13 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d } m_mTree[-1].SetSplitDirVert( false) ; Split( -1) ; - // qui devo fare il controllo capped ( chiusura a semisfera) - // devo controllare se i punti ai parametri U=0 e U=1 sono tutti coincidenti - // in caso devo fare uno split nell'altra direzione + // qui devo fare il controllo capped ( chiusura a semisfera) + // devo controllare se i punti ai parametri U=0 e U=1 sono tutti coincidenti + // in caso devo fare uno split nell'altra direzione bool bOk = false ; bool bCapped0 = true, bCapped1 = true ; Point3d ptV0, ptV1 ; - // controllo se tutti i punti sull'isoparametrica sono uguali + // controllo se tutti i punti sull'isoparametrica sono uguali for ( int i = 1 ; i < nDegV * nSpanV + 1 ; ++ i) { ptV0 = m_pSrfBz->GetControlPoint( i * ( nDegU * nSpanU + 1), &bOk) ; bCapped0 = bCapped0 && AreSamePointApprox( ptP00, ptV0) ; @@ -276,9 +231,9 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d Split( 1) ; } } - // nella condizione di questo if non controllo eventuali divisioni preliminari, perché ne tengo conto dopo + // nella condizione di questo if non controllo eventuali divisioni preliminari, perché ne tengo conto dopo if ( AreSamePointApprox( ptP00, ptP10) || AreSamePointApprox( ptP01, ptP11)) { - if( (int) m_mTree.size() == 1) { + if ( m_mTree.size() == 1) { if ( AreSamePointApprox( ptP00, ptP10) && AreSamePointApprox( ptP01, ptP11)) { m_mTree[-1].m_nLeft = -1 ; m_mTree[-1].m_nRight = -1 ; @@ -286,12 +241,12 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d } m_mTree[-1].SetSplitDirVert( true) ; Split( -1) ; - // devo controllare se i punti ai parametri V=0 e V=1 sono tutti coincidenti - // in caso devo fare uno split nell'altra direzione + // devo controllare se i punti ai parametri V=0 e V=1 sono tutti coincidenti + // in caso devo fare uno split nell'altra direzione bool bOk = false ; bool bCapped0 = true, bCapped1 = true ; Point3d ptU0, ptU1 ; - // controllo se tutti i punti sull'isoparametrica sono uguali + // controllo se tutti i punti sull'isoparametrica sono uguali for ( int i = 1 ; i < nDegU * nSpanU + 1 ; ++ i) { ptU0 = m_pSrfBz->GetControlPoint( i, &bOk) ; bCapped0 = bCapped0 && AreSamePointApprox( ptP00, ptU0) ; @@ -305,7 +260,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d Split( 1) ; } } - // se ho fatto solo 1 split orizzontale e ho due celle foglie nId = 0 e nId = 1 + // se ho fatto solo 1 split orizzontale e ho due celle foglie nId = 0 e nId = 1 else if ( (int) m_mTree.size() > 1 && (int) m_mTree.size() < 4 && ! m_mTree.at(-1).IsSplitVert()) { // si può mettere anche < 5 m_mTree[0].m_nLeft = -1 ; m_mTree[0].m_nRight = -1 ; @@ -319,7 +274,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d } } - // calcolo e salvo la lunghezza reale delle curve di bezier di bordo + // calcolo e salvo la lunghezza reale delle curve di bezier di bordo PtrOwner pCrvV0( m_pSrfBz->GetCurveOnU( 0)) ; PtrOwner pCrvV1( m_pSrfBz->GetCurveOnU( double(nSpanV))) ; PtrOwner pCrvU0( m_pSrfBz->GetCurveOnV( 0)) ; @@ -353,10 +308,11 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d //---------------------------------------------------------------------------- bool -AddOrMergeBBox ( const BBox3d& bBox3dA , std::vector& vBBox, const bool& bAdd = true, const int& nInd = 0) { +AddOrMergeBBox( const BBox3d& bBox3dA, vector& vBBox, bool bAdd = true, int nInd = 0) +{ Point3d ptMin = bBox3dA.GetMin() ; Point3d ptMax = bBox3dA.GetMax() ; - if ( (int)vBBox.size() == 0) { + if ( vBBox.empty()) { vBBox.push_back( bBox3dA) ; return true ; } @@ -364,7 +320,7 @@ AddOrMergeBBox ( const BBox3d& bBox3dA , std::vector& vBBox, const bool& for ( int b = 0 ; b < (int)vBBox.size() ; ++b) { BBox3d bBox3dB = vBBox[b] ; BBox3d b3Int ; - // se sono celle diverse e ho un'intersezione faccio il merge + // se sono celle diverse e ho un'intersezione faccio il merge if ( ! ( AreSamePointExact( ptMin, bBox3dB.GetMin()) && AreSamePointExact( ptMax, bBox3dB.GetMax())) && bBox3dA.FindIntersectionXY( bBox3dB, b3Int)) { vBBox[b].Add( bBox3dA) ; @@ -372,7 +328,7 @@ AddOrMergeBBox ( const BBox3d& bBox3dA , std::vector& vBBox, const bool& vBBox.erase( vBBox.begin() + nInd) ; -- b ; } - // se ho fatto un merge devo controllare se ora la nuova bbox ha delle intersezioni + // se ho fatto un merge devo controllare se ora la nuova bbox ha delle intersezioni AddOrMergeBBox( vBBox[b], vBBox, false, b) ; bAdded = true ; break ; @@ -385,59 +341,60 @@ AddOrMergeBBox ( const BBox3d& bBox3dA , std::vector& vBBox, const bool& //---------------------------------------------------------------------------- bool -Tree::GetIndependentTrees( std::vector>& vTrees) +Tree::GetIndependentTrees( BIPNTVECTOR& vTrees) { - if ( ! m_bTrimmed ) { - vTrees.push_back( std::tuple( ORIG, ORIG)); + if ( ! m_bTrimmed) { + vTrees.emplace_back( ORIG, ORIG) ; } else { - // se ho dei loop di trim trovo le loro BBox3d per costruire l'albero solo all'interno di queste BBox - bool bIsRoot = false ; - std::vector vBBox ; - for ( int a = 0 ; a < (int)m_vPlApprox.size(); ++a ) { - PolyLine plLoop = std::get<0>( m_vPlApprox[a]) ; - // calcolo la BBox3d - BBox3d bBox3dA ; - Point3d pt ; - plLoop.GetFirstPoint( pt) ; - bBox3dA.Add( pt) ; - while ( plLoop.GetNextPoint( pt)) - bBox3dA.Add( pt) ; - // controllo se ho intersezioni con altre bbox - // se ho intersezioni unisco le bbox, altrimenti le lascio indipendenti + // se ho dei loop di trim trovo le loro BBox3d per costruire l'albero solo all'interno di queste BBox + BOXVECTOR vBBox ; + for ( int i = 0 ; i < int( m_vPlApprox.size()) ; ++ i) { + PolyLine plLoop = get<0>( m_vPlApprox[i]) ; + // calcolo la BBox3d + Point3d ptP ; + plLoop.GetFirstPoint( ptP) ; + BBox3d bBox3dA( ptP) ; + while ( plLoop.GetNextPoint( ptP)) + bBox3dA.Add( ptP) ; + // controllo se ho intersezioni con altre bbox + // se ho intersezioni unisco le bbox, altrimenti le lascio indipendenti AddOrMergeBBox( bBox3dA, vBBox) ; } - // controllo se dopo aver unito le bbox ho ottenuto Root + // controllo se dopo aver unito le bbox ho ottenuto Root + bool bIsRoot = false ; Point3d ptTR( m_nSpanU * SBZ_TREG_COEFF, m_nSpanV * SBZ_TREG_COEFF) ; - for (int c = 0 ; c < (int)vBBox.size(); ++ c) { - BBox3d bBox3d = vBBox[c] ; - if ( AreSamePointEpsilon( bBox3d.GetMin(), ORIG, 10) && AreSamePointEpsilon( bBox3d.GetMax(), ptTR, 10)){ + for ( int i = 0 ; i < int( vBBox.size()) ; ++ i) { + BBox3d bBox3d = vBBox[i] ; + if ( AreSamePointEpsilon( bBox3d.GetMin(), ORIG, 10) && AreSamePointEpsilon( bBox3d.GetMax(), ptTR, 10)) { bIsRoot = true ; break ; } } - // restituisco le celle parent di partenza a partire dalle bbox che ho ottenuto - if ( ! bIsRoot ) { - for (int i = 0 ; i < (int)vBBox.size() ; ++ i) { + // restituisco le celle parent di partenza a partire dalle bbox che ho ottenuto + if ( ! bIsRoot) { + for ( int i = 0 ; i < int( vBBox.size()) ; ++ i) { Point3d ptMin = vBBox[i].GetMin() ; Point3d ptMax = vBBox[i].GetMax() ; - vTrees.push_back( std::tuple( ptMin, ptMax)) ; + vTrees.emplace_back( ptMin, ptMax) ; } } else - vTrees.push_back( std::tuple( ORIG, ORIG)); + vTrees.emplace_back( ORIG, ORIG); } return true ; } //---------------------------------------------------------------------------- bool -Tree::Split( const int& nId, const double& dSplitValue) +Tree::Split( int nId, double dSplitValue) { // controllo che lo split non venga fatto sul lato della cella - if ( ( m_mTree[nId].IsSplitVert() && dSplitValue > m_mTree[nId].GetBottomLeft().x + EPS_SMALL && dSplitValue < m_mTree[nId].GetTopRight().x - EPS_SMALL) || - ( ! m_mTree[nId].IsSplitVert() && dSplitValue > m_mTree[nId].GetBottomLeft().y + EPS_SMALL && dSplitValue < m_mTree[nId].GetTopRight().y - EPS_SMALL)) { - // quando si implementerà lo split a parametro libero bisognerà impedire che si facciano split troppo vicini al bordo della cella!!!!!!!!!!!!!!!!!!! + if ( ( m_mTree[nId].IsSplitVert() && dSplitValue > m_mTree[nId].GetBottomLeft().x + EPS_SMALL && + dSplitValue < m_mTree[nId].GetTopRight().x - EPS_SMALL) || + ( ! m_mTree[nId].IsSplitVert() && dSplitValue > m_mTree[nId].GetBottomLeft().y + EPS_SMALL && + dSplitValue < m_mTree[nId].GetTopRight().y - EPS_SMALL)) { + // quando si implementerà lo split a parametro libero bisognerà impedire che si facciano split troppo vicini al bordo della cella!!!!!!!!!!!!!!!!!!! m_mTree[nId].m_dSplit = dSplitValue ; Cell cChild1, cChild2 ; cChild1.m_nDepth = m_mTree[nId].m_nDepth + 1 ; @@ -447,14 +404,13 @@ Tree::Split( const int& nId, const double& dSplitValue) m_mTree[nId].m_nChild1 = nNodes - 1 ; cChild2.m_nId = nNodes ; m_mTree[nId].m_nChild2 = nNodes ; - m_mTree.insert( std::pair( nNodes - 1, cChild1)) ; - m_mTree.insert( std::pair( nNodes, cChild2)) ; + m_mTree.insert( pair( nNodes - 1, cChild1)) ; + m_mTree.insert( pair( nNodes, cChild2)) ; Point3d ptVert1, ptVert2 ; PNTVECTOR vVert ; - m_mVert.insert( std::pair( nNodes - 1, vVert)) ; - m_mVert.insert( std::pair( nNodes, vVert)) ; - if ( ! m_mTree[nId].IsSplitVert()) - { + m_mVert.insert( pair( nNodes - 1, vVert)) ; + m_mVert.insert( pair( nNodes, vVert)) ; + if ( ! m_mTree[nId].IsSplitVert()) { // la cella figlio 1 è quella sopra Point3d ptBL( m_mTree[nId].GetBottomLeft().x, dSplitValue) ; m_mTree[m_mTree[nId].m_nChild1].SetBottomLeft( ptBL) ; @@ -521,7 +477,7 @@ Tree::Split( const int& nId, const double& dSplitValue) //---------------------------------------------------------------------------- bool -Tree::Split( const int& nId) +Tree::Split( int nId) { double dValue ; if ( m_mTree[nId].IsSplitVert()) @@ -533,14 +489,12 @@ Tree::Split( const int& nId) //---------------------------------------------------------------------------- bool -Tree::BuildTree_test( const double& dLinTol, const double& dSideMin, const double& dSideMax) +Tree::BuildTree_test( double dLinTol, double dSideMin, double dSideMax) { // per poter usare questa funzione, anziché quella normale, bisogna: // - commentare la parte di funzione di SetSurf dove si fanno gli split preliminare // - se si usa anche la funzione GetLeaves, bisogna anche lì usare BuildTree_test al posto di BuildTree - - //int nCToSplit = -1 ; //celle 0,1 m_mTree[-1].SetSplitDirVert( true) ; Split( -1) ; @@ -598,7 +552,7 @@ Tree::BuildTree_test( const double& dLinTol, const double& dSideMin, const doubl //---------------------------------------------------------------------------- bool -Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dSideMax) +Tree::BuildTree( double dLinTol, double dSideMin, double dSideMax) { // suddivido lo spazio parametrico con divisioni a metà su uno dei due parametri int nCToSplit = -1 ; @@ -645,7 +599,7 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS DistPointCurve dpc( ptPSrf, clV) ; double dDist ; dpc.GetDist( dDist) ; - dCurvV = std::max( dCurvV, dDist) ; + dCurvV = max( dCurvV, dDist) ; } dStep = 1. / ( m_nDegV * 2) ; for ( double k = dStep ; k < 1 + EPS_SMALL ; k = k + dStep) { @@ -662,7 +616,7 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS DistPointCurve dpc( ptPSrf, clU) ; double dDist ; dpc.GetDist( dDist) ; - dCurvU = std::max( dCurvU, dDist) ; + dCurvU = max( dCurvU, dDist) ; } } @@ -708,18 +662,18 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS double dSideMinVal = 0, dSideMaxVal = 0 ; if ( bVert) { if ( dLen0 > EPS_ZERO && dLen2 > EPS_ZERO) - dSideMinVal = std::min( dLen0, dLen2) ; + dSideMinVal = min( dLen0, dLen2) ; else - dSideMinVal = std::max( dLen0, dLen2) ; + dSideMinVal = max( dLen0, dLen2) ; } else { if ( dLen1 > EPS_ZERO && dLen3 > EPS_ZERO) - dSideMinVal = std::min( dLen1, dLen3) ; + dSideMinVal = min( dLen1, dLen3) ; else - dSideMinVal = std::max( dLen1, dLen3) ; + dSideMinVal = max( dLen1, dLen3) ; } // calcolo le diagonali per controllare la dimensione massima dei triangoli in cui dividerei la cella - dSideMaxVal = std::max( Dist( ptP00, ptP11), Dist( ptP10, ptP01)) ; + dSideMaxVal = max( Dist( ptP00, ptP11), Dist( ptP10, ptP01)) ; // se la cella è abbastanza grande da poter essere divisa ancora, calcolo l'errore di approssimazione bool bSplit = false ; @@ -854,12 +808,7 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS double dDistU = 0, dDistV = 0 ; PNTVECTOR vPtU, vPtV ; if ( ! m_bMulti) { - if ( std::max( dLen0, dLen2) > std::max( dLen1, dLen3)) { - bVert = true ; - } - else { - bVert = false ; - } + bVert = ( max( dLen0, dLen2) > max( dLen1, dLen3)) ; } else { for ( double i = 0.25 ; i < 1 ; i = i + 0.25) { @@ -888,23 +837,10 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS } } - // verifico che la cella sia abbastanza grande da poter essere splittata - double dSideMinVal = 0, dSideMaxVal = 0 ; - if ( bVert) { - if ( dLen0 != 0 && dLen2 != 0) - dSideMinVal = std::max( dLen0, dLen2) ; - else - dSideMinVal = std::max( dLen0, dLen2) ; - } - else { - if ( dLen1 != 0 && dLen3 != 0) - dSideMinVal = std::max( dLen1, dLen3) ; - else - dSideMinVal = std::max( dLen1, dLen3) ; - } - // calcolo le diagonali per controllare la dimensione massima dei triangoli in cui dividerei la cella - dSideMaxVal = std::max( Dist( ptP00, ptP11), Dist( ptP10, ptP01)) ; - + // verifico che la cella sia abbastanza grande da poter essere splittata + double dSideMinVal = ( bVert ? max( dLen0, dLen2) : max( dLen1, dLen3)) ; + // calcolo le diagonali per controllare la dimensione massima dei triangoli in cui dividerei la cella + double dSideMaxVal = max( Dist( ptP00, ptP11), Dist( ptP10, ptP01)) ; double dErr = 0 ; if ( m_bMulti) { @@ -923,7 +859,7 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS double dU = ( ( 1 - i) * m_mTree[nCToSplit].GetTopRight().x + i * m_mTree[nCToSplit].GetBottomLeft().x) / SBZ_TREG_COEFF ; double dV = ( ( 1 - j) * m_mTree[nCToSplit].GetTopRight().y + j * m_mTree[nCToSplit].GetBottomLeft().y) / SBZ_TREG_COEFF ; m_pSrfBz->GetPointD1D2( dU, dV, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, ptPSrf) ; - dErr = std::max( abs( DistPointPlane( ptPSrf, plAppr)), dErr) ; + dErr = max( abs( DistPointPlane( ptPSrf, plAppr)), dErr) ; } } } @@ -983,9 +919,9 @@ Tree::Balance() //---------------------------------------------------------------------------- void -Tree::GetTopNeigh( const int& nId, INTVECTOR& vTopNeighs) const +Tree::GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const { - if ( (int) vTopNeighs.size() == 0) { + if ( vTopNeighs.empty()) { if ( m_mTree.at( nId).m_nTop == -2) return ; if ( m_mTree.at( m_mTree.at( nId).m_nTop).IsLeaf()) @@ -999,9 +935,9 @@ Tree::GetTopNeigh( const int& nId, INTVECTOR& vTopNeighs) const vTopNeighs.push_back( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild2) ; } // altrimenti solo uno dei figli lo sarà - else{ - if ( m_mTree.at( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild1).GetTopRight().x <= m_mTree.at( nId).GetBottomLeft().x || - m_mTree.at( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild1).GetBottomLeft().x >= m_mTree.at( nId).GetTopRight().x ) + else { + if ( m_mTree.at( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild1).GetTopRight().x <= m_mTree.at( nId).GetBottomLeft().x || + m_mTree.at( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild1).GetBottomLeft().x >= m_mTree.at( nId).GetTopRight().x ) vTopNeighs.push_back( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild2) ; else vTopNeighs.push_back( m_mTree.at( m_mTree.at( nId).m_nTop).m_nChild1) ; @@ -1051,10 +987,10 @@ Tree::GetTopNeigh( const int& nId, INTVECTOR& vTopNeighs) const } } } - std::vector vCells ; + vector vCells ; for ( int k : vTopNeighs) vCells.push_back( m_mTree.at( k)) ; - std::sort( vCells.begin(), vCells.end(), Cell::minorX) ; + sort( vCells.begin(), vCells.end(), Cell::minorX) ; vTopNeighs.clear() ; for ( Cell c : vCells) vTopNeighs.push_back( c.m_nId) ; @@ -1063,9 +999,9 @@ Tree::GetTopNeigh( const int& nId, INTVECTOR& vTopNeighs) const //---------------------------------------------------------------------------- void -Tree::GetBottomNeigh( const int& nId, INTVECTOR& vBottomNeighs) const +Tree::GetBottomNeigh( int nId, INTVECTOR& vBottomNeighs) const { - if ( (int) vBottomNeighs.size() == 0) { + if ( vBottomNeighs.empty()) { if ( m_mTree.at( nId).m_nBottom == -2) return ; if ( m_mTree.at( m_mTree.at( nId).m_nBottom).IsLeaf()) @@ -1101,7 +1037,7 @@ Tree::GetBottomNeigh( const int& nId, INTVECTOR& vBottomNeighs) const GetBottomNeigh( nId, vBottomNeighs) ; } else { - for ( int j = 0 ; j != (int) vBottomNeighs.size() ; ++ j) { + for ( int j = 0 ; j < int( vBottomNeighs.size()) ; ++ j) { int i = vBottomNeighs.at( j) ; if ( m_mTree.at( i).IsLeaf()) continue ; @@ -1131,21 +1067,20 @@ Tree::GetBottomNeigh( const int& nId, INTVECTOR& vBottomNeighs) const } } } - std::vector vCells ; + vector vCells ; for ( int k : vBottomNeighs) vCells.push_back( m_mTree.at( k)) ; - std::sort( vCells.begin(), vCells.end(), Cell::minorX) ; + sort( vCells.begin(), vCells.end(), Cell::minorX) ; vBottomNeighs.clear() ; for ( Cell c : vCells) vBottomNeighs.push_back( c.m_nId) ; } - //---------------------------------------------------------------------------- void -Tree::GetLeftNeigh( const int& nId, INTVECTOR& vLeftNeighs) const +Tree::GetLeftNeigh( int nId, INTVECTOR& vLeftNeighs) const { - if ( (int) vLeftNeighs.size() == 0) { + if ( vLeftNeighs.empty()) { if ( m_mTree.at( nId).m_nLeft == -2) return ; if ( m_mTree.at( m_mTree.at( nId).m_nLeft).IsLeaf()) @@ -1181,7 +1116,7 @@ Tree::GetLeftNeigh( const int& nId, INTVECTOR& vLeftNeighs) const GetLeftNeigh( nId, vLeftNeighs) ; } else { - for ( int j = 0 ; j != (int) vLeftNeighs.size() ; ++ j) { + for (int j = 0 ; j < int( vLeftNeighs.size()) ; ++ j) { int i = vLeftNeighs.at( j) ; if ( m_mTree.at( i).IsLeaf()) continue ; @@ -1211,10 +1146,10 @@ Tree::GetLeftNeigh( const int& nId, INTVECTOR& vLeftNeighs) const } } } - std::vector vCells ; + vector vCells ; for ( int k : vLeftNeighs) vCells.push_back( m_mTree.at( k)) ; - std::sort( vCells.begin(), vCells.end(), Cell::minorY) ; + sort( vCells.begin(), vCells.end(), Cell::minorY) ; vLeftNeighs.clear() ; for ( Cell c : vCells) vLeftNeighs.push_back( c.m_nId) ; @@ -1222,9 +1157,9 @@ Tree::GetLeftNeigh( const int& nId, INTVECTOR& vLeftNeighs) const //---------------------------------------------------------------------------- void -Tree::GetRightNeigh( const int& nId, INTVECTOR& vRightNeighs) const +Tree::GetRightNeigh( int nId, INTVECTOR& vRightNeighs) const { - if ( (int) vRightNeighs.size() == 0) { + if ( vRightNeighs.empty()) { if ( m_mTree.at( nId).m_nRight == -2) return ; if ( m_mTree.at( m_mTree.at( nId).m_nRight).IsLeaf()) @@ -1260,7 +1195,7 @@ Tree::GetRightNeigh( const int& nId, INTVECTOR& vRightNeighs) const GetRightNeigh( nId, vRightNeighs) ; } else { - for ( int j = 0 ; j != (int) vRightNeighs.size() ; ++ j) { + for (int j = 0 ; j < int( vRightNeighs.size()) ; ++ j) { int i = vRightNeighs.at( j) ; if ( m_mTree.at( i).IsLeaf()) continue ; @@ -1290,10 +1225,10 @@ Tree::GetRightNeigh( const int& nId, INTVECTOR& vRightNeighs) const } } } - std::vector vCells ; + vector vCells ; for ( int k : vRightNeighs) vCells.push_back( m_mTree.at( k)) ; - std::sort( vCells.begin(), vCells.end(), Cell::minorY) ; + sort( vCells.begin(), vCells.end(), Cell::minorY) ; vRightNeighs.clear() ; for ( Cell c : vCells) vRightNeighs.push_back( c.m_nId) ; @@ -1301,7 +1236,7 @@ Tree::GetRightNeigh( const int& nId, INTVECTOR& vRightNeighs) const //---------------------------------------------------------------------------- void -Tree::GetRootNeigh( const int& nEdge, INTVECTOR& vNeigh) +Tree::GetRootNeigh( int nEdge, INTVECTOR& vNeigh) { int nId = -1 ; bool bMod = false ; @@ -1345,14 +1280,14 @@ Tree::GetRootNeigh( const int& nEdge, INTVECTOR& vNeigh) //---------------------------------------------------------------------------- int -Tree::GetHeightLeaves( const int& nId, INTVECTOR& vnLeaves, int d) const +Tree::GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d) const { if ( nId == -1 && m_mTree.at( -1).IsLeaf()) { vnLeaves.push_back( -1) ; return 0 ; } else { - if ( (int) vnLeaves.size() == 0) { + if ( vnLeaves.empty()) { if ( m_mTree.at( nId).IsLeaf()) return d ; else { @@ -1364,7 +1299,7 @@ Tree::GetHeightLeaves( const int& nId, INTVECTOR& vnLeaves, int d) const } } else { - for ( int j = 0 ; j != (int) vnLeaves.size() ; ++ j) { + for ( int j = 0 ; j < int( vnLeaves.size()) ; ++ j) { int i = vnLeaves.at( j) ; if ( m_mTree.at( i).IsLeaf()) { continue ; @@ -1375,38 +1310,42 @@ Tree::GetHeightLeaves( const int& nId, INTVECTOR& vnLeaves, int d) const -- j ; vnLeaves.push_back( m_mTree.at( i).m_nChild1) ; vnLeaves.push_back( m_mTree.at( i).m_nChild2) ; - d = std::max ( d, m_mTree.at( m_mTree.at( i).m_nChild1).m_nDepth) ; + d = max( d, m_mTree.at( m_mTree.at( i).m_nChild1).m_nDepth) ; } } return d ; } - return d - m_mTree.at( nId).m_nDepth ; + return ( d - m_mTree.at( nId).m_nDepth) ; } } //---------------------------------------------------------------------------- int -Tree::GetDepth( const int& nId, const int& nRef = -2) const +Tree::GetDepth( int nId, int nRef = -2) const { - int c = 0 ; + int i = 0 ; int nCell = nId ; while ( m_mTree.at( nCell).m_nParent != nRef) { nCell = m_mTree.at( nCell).m_nParent ; - ++ c ; + ++ i ; } - return c ; + return i ; } +//---------------------------------------------------------------------------- struct generator { int value ; - generator() { value = -1 ;} - int operator() () { return ++value ; } + generator( void) + { value = -1 ; } + int operator() () + { return ++value ; } } ; //---------------------------------------------------------------------------- bool -Tree::GetPolygons( std::vector& vPolygons) { +Tree::GetPolygons( POLYLINEMATRIX& vPolygons) +{ if ( (int) m_vPolygons.size() == 0) { if ( ! m_bTrimmed) { vPolygons.clear() ; @@ -1419,15 +1358,15 @@ Tree::GetPolygons( std::vector& vPolygons) { } return true ; } - // trimmata + // trimmata else { POLYLINEVECTOR vPolygonsBasic ; GetPolygonsBasic( vPolygonsBasic) ; if ( ! TraceLoopLabelCell( vPolygonsBasic)) return false ; // scorro sulle celle e costruisco i poligoni - int nCells = (int)vPolygonsBasic.size() ; - for ( int i = 0 ; i < nCells ; ++i) { + int nCells = int( vPolygonsBasic.size()) ; + for ( int i = 0 ; i < nCells ; ++ i) { // costruisco i poligoni partendo dal vettore delle intersezioni, come spiegato a pag15 di Cripps int nId = m_vnLeaves[i] ; @@ -1444,7 +1383,7 @@ Tree::GetPolygons( std::vector& vPolygons) { INTVECTOR vnParentChunk ; // vettore in cui salvo i loop che non appartengono al poligono che sto cotruendo nel ciclo attuale e da cui ripasserò dopo INTVECTOR vToCheck( (int) m_mTree[nId].m_vInters.size()) ; - std::generate_n( vToCheck.begin(), (int) m_mTree[nId].m_vInters.size(), generator()) ; + generate_n( vToCheck.begin(), (int) m_mTree[nId].m_vInters.size(), generator()) ; // numero di poligoni aggiunti int nPoly = 0 ; // scorro sui vettori intersezione della cella nId e sui suoi vertici @@ -1541,9 +1480,9 @@ Tree::GetPolygonsBasic( POLYLINEVECTOR& vPolygons) vNeigh.clear() ; vVertices.push_back( m_mTree.at( nId).GetTopRight()) ; GetTopNeigh ( nId, vNeigh) ; - std::reverse( vNeigh.begin(), vNeigh.end()) ; + reverse( vNeigh.begin(), vNeigh.end()) ; // aggiungo i vertici che sono sul lato top, solo se ho più di un vicino top - if ( (int) vNeigh.size() != 0 && (int) vNeigh.size() != 1) { + if ( ! vNeigh.empty() && vNeigh.size() != 1) { // se la superficie è chiusa lungo il parametro U e la cella è sul lato top // devo aggiungere i vertici tenendo conto della periodicità dello spazio parametrico. if ( m_bClosedU && m_mTree.at( nId).m_bOnTopEdge) { @@ -1562,7 +1501,7 @@ Tree::GetPolygonsBasic( POLYLINEVECTOR& vPolygons) bTopLeft = false ; vNeigh.clear() ; GetLeftNeigh ( nId, vNeigh) ; - std::reverse( vNeigh.begin(), vNeigh.end()) ; + reverse( vNeigh.begin(), vNeigh.end()) ; // aggiungo i vertici che sono sul lato left, solo se ho più di un vicino left if ( (int) vNeigh.size() != 0 && (int) vNeigh.size() != 1) { // se la superficie è chiusa lungo il parametro U e la cella è sul lato left @@ -1741,16 +1680,16 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) double dLinTol = - EPS_SMALL ; // percorro i loop trovando le interezioni con le celle e riempiendo i vettori m_vInters delle varie celle for ( int i = 0 ; i < (int) m_vPlApprox.size() ; ++ i) { - PolyLine plLoop = std::get<0>(m_vPlApprox[i]) ; + PolyLine plLoop = get<0>( m_vPlApprox[i]) ; // controllo se il loop è CCW o CW - bool bCCW = std::get<1>(m_vPlApprox[i]) ; + bool bCCW = get<1>( m_vPlApprox[i]) ; // trovo in quale cella è il ptStart Point3d ptStart ; plLoop.GetFirstPoint( ptStart) ; PNTULIST lPt = plLoop.GetUPointList() ; PNTULIST:: iterator ptFirst = lPt.begin() ; PNTULIST:: iterator ptSecond = ptFirst ; - std::advance( ptSecond, 1) ; + advance( ptSecond, 1) ; CurveLine clFirst ; clFirst.Set( ptFirst->first, ptSecond->first) ; // individuo la cella da cui parte il loop @@ -1776,8 +1715,8 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) m_mTree[nId].m_vInters.back().nChunk = m_mChunk[i] ; bool bLoopInside = true ; Point3d ptCurr ; - INTVECTOR :: iterator iter = find( m_vnLeaves.begin(), m_vnLeaves.end(), nId) ; - int nIdPolygon = std::distance( m_vnLeaves.begin(), iter) ; + auto iter = find( m_vnLeaves.begin(), m_vnLeaves.end(), nId) ; + int nIdPolygon = distance( m_vnLeaves.begin(), iter) ; bool bEraseNextPoint = false ; while ( plLoop.GetNextPoint( ptCurr)) { Point3d ptTStart, ptTEnd ; @@ -1786,7 +1725,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) CurveLine clTrim ; clTrim.Set( ptTStart, ptTEnd) ; // qui devo mettere una tolleranza negativa per poter tener conto anche dei punti che sono SULLA curva - while( ! IsPointInsidePolyLine( ptCurr, vplPolygons[nIdPolygon], dLinTol)) { + while ( ! IsPointInsidePolyLine( ptCurr, vplPolygons[nIdPolygon], dLinTol)) { // sto uscendo dalla cella, quindi cerco l'intersezione if ( bEraseNextPoint) { vptInters.pop_back() ; @@ -1811,7 +1750,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) } // ricalcolo la posizione di nId nel vettore delle foglie iter = find( m_vnLeaves.begin(), m_vnLeaves.end(), nId) ; - nIdPolygon = std::distance( m_vnLeaves.begin(), iter) ; + nIdPolygon = distance( m_vnLeaves.begin(), iter) ; // salvo il verso del loop m_mTree[nId].m_vInters.back().bCCW = bCCW ; // salvo il chunk del loop @@ -1869,7 +1808,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) // riordino i vettori di intersezione per ogni cella e setto il flag RightEdgeIn for ( int nId : m_vnLeaves) { - std::sort( m_mTree[nId].m_vInters.begin(), m_mTree[nId].m_vInters.end()) ; + sort( m_mTree[nId].m_vInters.begin(), m_mTree[nId].m_vInters.end()) ; SetRightEdgeIn( nId) ; } @@ -2181,7 +2120,7 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool INTVECTOR vNeigh, vNeigh1 ; if ( nEdge == 0) { GetTopNeigh( nId, vNeigh) ; - std::reverse( vNeigh.begin(), vNeigh.end()) ; + reverse( vNeigh.begin(), vNeigh.end()) ; for ( int j : vNeigh) { if ( ptInters.x >= m_mTree[j].GetBottomLeft().x) { nId = j ; @@ -2201,7 +2140,7 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool } else if ( nEdge == 1) { GetLeftNeigh( nId, vNeigh) ; - std::reverse( vNeigh.begin(), vNeigh.end()) ; + reverse( vNeigh.begin(), vNeigh.end()) ; for ( int j : vNeigh) { if ( ptInters.y >= m_mTree[j].GetBottomLeft().y) { nId = j ; @@ -2461,11 +2400,11 @@ Tree::FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool //---------------------------------------------------------------------------- bool -Tree::CreateCellPolygons( const int& nLeafId, std::vector& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) +Tree::CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) { // conto quanti vertici in più ho per lato e creo un vettore dei vertici per lato int nId = m_vnLeaves[nLeafId] ; - std::vector vEdgeVertex ; + PNTMATRIX vEdgeVertex ; Point3d ptTl( m_mTree[nId].GetBottomLeft().x, m_mTree[nId].GetTopRight().y) ; Point3d ptBr( m_mTree[nId].GetTopRight().x, m_mTree[nId].GetBottomLeft().y) ; vEdgeVertex.emplace_back() ; @@ -2720,7 +2659,7 @@ Tree::CreateCellPolygons( const int& nLeafId, std::vector& vPoly //---------------------------------------------------------------------------- bool -Tree::CreateIslandAndHoles( const int& nLeafId, std::vector& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) +Tree::CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) { // vettore dei poligoni ( loop) della cella nId POLYLINEVECTOR vCellPolygons ; @@ -2829,7 +2768,7 @@ Tree::CreateIslandAndHoles( const int& nLeafId, std::vector& vPo //---------------------------------------------------------------------------- bool -Tree::CheckIfBefore( const PolyLine& pl, const int& nEdge) const +Tree::CheckIfBefore( const PolyLine& pl, int nEdge) const { // controllo se ptEnd è prima di ptStart sul lato nEdge rispetto al senso antiorario ( quindi se è dopo in senso orario) Point3d ptStart, ptEnd ; @@ -2866,10 +2805,10 @@ Tree::CheckIfBefore( const Inters& inA) const INTVECTOR vEdges = { 7, 0, 4, 1, 5, 2, 6} ; // controllo se nEdge1 viene prima di nEdge2. la partenza è da ptTR e l'arrivo è ptBr - INTVECTOR :: iterator iter1 = find( vEdges.begin(), vEdges.end(), nEdge1) ; - int nPos1 = std::distance( vEdges.begin(), iter1) ; - INTVECTOR :: iterator iter2 = find( vEdges.begin(), vEdges.end(), nEdge2) ; - int nPos2 = std::distance( vEdges.begin(), iter2) ; + auto iter1 = find( vEdges.begin(), vEdges.end(), nEdge1) ; + int nPos1 = distance( vEdges.begin(), iter1) ; + auto iter2 = find( vEdges.begin(), vEdges.end(), nEdge2) ; + int nPos2 = distance( vEdges.begin(), iter2) ; if ( nPos1 < nPos2) return true ; else if ( nPos1 > nPos2) @@ -2886,17 +2825,17 @@ Tree::CheckIfBefore( const Inters& inA) const //---------------------------------------------------------------------------- bool -Tree::CheckIfBefore( const int& nEdge1, const Point3d& ptP1, const int& nEdge2, const Point3d& ptP2) const +Tree::CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const { if ( nEdge1 == -1 || nEdge2 == -1) return false ; // questa funzione è pensata in riferimento al lato 3, quindi nessuno dei due punti può stare su Edge = 3 INTVECTOR vEdges = { 7, 0, 4, 1, 5, 2, 6} ; // controllo se ptP1, che è su nEdge1, viene prima di ptP2, che è su nEdge2. la partenza è da ptTR e l'arrivo è ptBr - INTVECTOR :: iterator iter1 = find( vEdges.begin(), vEdges.end(), nEdge1) ; - int nPos1 = std::distance( vEdges.begin(), iter1) ; - INTVECTOR :: iterator iter2 = find( vEdges.begin(), vEdges.end(), nEdge2) ; - int nPos2 = std::distance( vEdges.begin(), iter2) ; + auto iter1 = find( vEdges.begin(), vEdges.end(), nEdge1) ; + int nPos1 = distance( vEdges.begin(), iter1) ; + auto iter2 = find( vEdges.begin(), vEdges.end(), nEdge2) ; + int nPos2 = distance( vEdges.begin(), iter2) ; if ( nPos1 < nPos2) return true ; else if ( nPos1 > nPos2) @@ -2915,14 +2854,14 @@ Tree::CheckIfBefore( const int& nEdge1, const Point3d& ptP1, const int& nEdge2, //---------------------------------------------------------------------------- bool -Tree::CheckIfBefore( const int& nEdge, const Point3d& ptP1, const Point3d& ptP2, const int& nEdge2) const +Tree::CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2) const { - // i punti devono essere sullo stesso lato nEdge - // nEdge2 è di backup, in caso nEdge sia un vertice, per capire di quale lato si tratta - int nEdgeRef ; + // i punti devono essere sullo stesso lato nEdge + // nEdge2 è di backup, in caso nEdge sia un vertice, per capire di quale lato si tratta + int nEdgeRef = -1 ; if ( nEdge != nEdge2 && nEdge2 != -1) { - if ( std::min(nEdge, nEdge2) < 4) - nEdgeRef = std::min(nEdge, nEdge2) ; + if ( min( nEdge, nEdge2) < 4) + nEdgeRef = min( nEdge, nEdge2) ; else if ( AreSameEdge( nEdge, 0) && AreSameEdge( nEdge2, 0)) nEdgeRef = 0 ; else if ( AreSameEdge( nEdge, 1) && AreSameEdge( nEdge2, 1)) @@ -2934,84 +2873,52 @@ Tree::CheckIfBefore( const int& nEdge, const Point3d& ptP1, const Point3d& ptP2, } else nEdgeRef = nEdge ; - // sul lato nEdge controllo se ptP1 viene prima di ptP2. - // i lati vengono percorsi in senso antiorario + // sul lato nEdge controllo se ptP1 viene prima di ptP2. + // i lati vengono percorsi in senso antiorario if ( AreSameEdge( nEdgeRef, 0)) { - return ptP1.x > ptP2.x ; + return ( ptP1.x > ptP2.x) ; } else if ( AreSameEdge( nEdgeRef, 1)) { - return ptP1.y > ptP2.y ; + return ( ptP1.y > ptP2.y) ; } else if ( AreSameEdge( nEdgeRef, 2)) { - return ptP1.x < ptP2.x ; + return ( ptP1.x < ptP2.x) ; } else if ( AreSameEdge( nEdgeRef, 3)) { - return ptP1.y < ptP2.y ; + return ( ptP1.y < ptP2.y) ; } return false ; } //---------------------------------------------------------------------------- bool -Tree::AreSameEdge( const int& nEdge1, const int nEdge2) const +Tree::AreSameEdge( int nEdge1, int nEdge2) const { - if ( nEdge1 == 0) { - if ( nEdge2 == 4 || nEdge2 == 0 || nEdge2 == 7) - return true ; - else - return false ; - } - else if ( nEdge1 == 1) { - if ( nEdge2 == 4 || nEdge2 == 1 || nEdge2 == 5) - return true ; - else - return false ; - } - else if ( nEdge1 == 2) { - if ( nEdge2 == 6 || nEdge2 == 2 || nEdge2 == 5) - return true ; - else - return false ; - } - else if ( nEdge1 == 3) { - if ( nEdge2 == 6 || nEdge2 == 3 || nEdge2 == 7) - return true ; - else - return false ; - } - else if ( nEdge1 == 4) { - if ( nEdge2 == 0 || nEdge2 == 1 || nEdge2 == 7 || nEdge2 == 5) - return true ; - else - return false ; - } - else if ( nEdge1 == 5) { - if ( nEdge2 == 2 || nEdge2 == 1 || nEdge2 == 4 || nEdge2 == 6) - return true ; - else - return false ; - } - else if ( nEdge1 == 6) { - if ( nEdge2 == 2 || nEdge2 == 3 || nEdge2 == 5 || nEdge2 == 7) - return true ; - else - return false ; - } - else if ( nEdge1 == 7) { - if ( nEdge2 == 0 || nEdge2 == 3 || nEdge2 == 4 || nEdge2 == 6) - return true ; - else - return false ; - } + if ( nEdge1 == 0) + return ( nEdge2 == 4 || nEdge2 == 0 || nEdge2 == 7) ; + else if ( nEdge1 == 1) + return ( nEdge2 == 4 || nEdge2 == 1 || nEdge2 == 5) ; + else if ( nEdge1 == 2) + return ( nEdge2 == 6 || nEdge2 == 2 || nEdge2 == 5) ; + else if ( nEdge1 == 3) + return ( nEdge2 == 6 || nEdge2 == 3 || nEdge2 == 7) ; + else if ( nEdge1 == 4) + return ( nEdge2 == 0 || nEdge2 == 1 || nEdge2 == 7 || nEdge2 == 5) ; + else if ( nEdge1 == 5) + return ( nEdge2 == 2 || nEdge2 == 1 || nEdge2 == 4 || nEdge2 == 6) ; + else if ( nEdge1 == 6) + return ( nEdge2 == 2 || nEdge2 == 3 || nEdge2 == 5 || nEdge2 == 7) ; + else if ( nEdge1 == 7) + return ( nEdge2 == 0 || nEdge2 == 3 || nEdge2 == 4 || nEdge2 == 6) ; else return false ; } //---------------------------------------------------------------------------- bool -Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const +Tree::AddVertex( int nId, const PNTMATRIX& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const { - // se è il primo punto della PolyLine lo aggiungo + // se è il primo punto della PolyLine lo aggiungo if ( plTrimmedPoly.GetPointNbr() == 0) { plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; @@ -3023,13 +2930,13 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly Point3d ptBL = vEdgeVertex[2][0] ; Point3d ptLast ; plTrimmedPoly.GetLastPoint( ptLast) ; - // verifico di essere allineato con un lato, sennò aggiungo e basta + // verifico di essere allineato con un lato, sennò aggiungo e basta Vector3d vDir ; if ( ! AreSamePointApprox( ptToAdd, ptLast)) vDir = ptToAdd - ptLast ; else return true ; - // se non riesco a normalizzare perché sono troppo vicino ad un vertice allora aggiungo direttamente il vertice + // se non riesco a normalizzare perché sono troppo vicino ad un vertice allora aggiungo direttamente il vertice if ( ! vDir.Normalize()) { plTrimmedPoly.EraseLastUPoint() ; if ( AreSamePointApprox( ptToAdd, ptBr)) @@ -3046,8 +2953,8 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly return true ; } if ( abs( vDir.x) > 1 - EPS_SMALL || abs( vDir.y) > 1 - EPS_SMALL) { - // se su un edge devo fare dei controlli - // edge 0 + // se su un edge devo fare dei controlli + // edge 0 if ( ptToAdd.x >= ptBL.x && ptToAdd.x <= ptTR.x && ptToAdd.y == ptTR.y && abs( vDir.x) > 1 - EPS_SMALL) { for ( int t = 0 ; t < (int)vEdgeVertex[0].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[0][t] ; @@ -3059,7 +2966,7 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; } - // edge 1 + // edge 1 else if ( ptToAdd.y >= ptBL.y && ptToAdd.y <= ptTR.y && ptToAdd.x == ptBL.x && abs( vDir.y) > 1 - EPS_SMALL) { for ( int t = 0 ; t < (int)vEdgeVertex[1].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[1][t] ; @@ -3071,7 +2978,7 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; } - // edge 2 + // edge 2 else if ( ptToAdd.x >= ptBL.x && ptToAdd.x <= ptTR.x && ptToAdd.y == ptBL.y && abs( vDir.x) > 1 - EPS_SMALL) { for ( int t = 0 ; t < (int)vEdgeVertex[2].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[2][t] ; @@ -3083,7 +2990,7 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; } - // edge 3 + // edge 3 else if ( ptToAdd.y >= ptBL.y && ptToAdd.y <= ptTR.y && ptToAdd.x == ptTR.x && abs( vDir.y) > 1 - EPS_SMALL) { for ( int t = 0 ; t < (int)vEdgeVertex[3].size() ; ++ t) { Point3d ptIntermed = vEdgeVertex[3][t] ; @@ -3095,14 +3002,14 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; } - // sono allineato con un lato, ma NON sono su un lato - // aggiungo e basta + // sono allineato con un lato, ma NON sono su un lato + // aggiungo e basta else { plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; } } - // non su un edge, quindi aggiungo e basta + // non su un edge, quindi aggiungo e basta else { plTrimmedPoly.AddUPoint( c, ptToAdd) ; ++ c ; @@ -3110,84 +3017,20 @@ Tree::AddVertex( const int& nId, const std::vector& vEdgeVertex, Poly return true ; } -//usando i poligoni // deprecato e non funzionante -////---------------------------------------------------------------------------- -//bool -//Tree::SetRightEdgeIn( int nId, std::vector& vEdgeVertex, PolyLine& plTrimmedPoly) -//{ -// Point3d ptBr( m_mTree.at( nId).GetTopRight().x , m_mTree.at( nId).GetBottomLeft().y) ; -// Point3d ptTR = m_mTree.at( nId).GetTopRight() ; -// int nPos0 = -1 , nPos1 = -1 ; -// bool bSave = false ; -// PNTLIST lPtInt ; -// for ( int k = 0 ; k < plTrimmedPoly.GetPointNbr() ; ++ k) { -// Point3d ptIter ; -// plTrimmedPoly. GetNextPoint( ptIter) ; -// if ( AreSamePointExact( ptIter, ptBr)) { -// nPos0 = k ; -// bSave = bSave ^ true ; -// } -// if ( AreSamePointExact( ptIter, ptTR)) { -// nPos1 = k ; -// bSave = bSave ^ true ; -// } -// if ( bSave) { -// lPtInt.push_back( ptIter) ; -// } -// } -// lPtInt.pop_front() ; -// // verifico se ci sono tutti e due i punti -// if ( nPos0 != -1 && nPos1 != -1) { -// // se sono di seguito tutto il lato destro è dentro -// if ( nPos1 == nPos0 + 1 || nPos0 == nPos1 + 1) { -// m_mTree[nId].m_nRightEdgeIn = 1 ; -// } -// // ci sono dei punti in mezzo, devo capire se sono allineati o no -// else { -// // verifico se tutti i punti intermedi sono allineati o no -// CurveLine clRightEdge ; -// clRightEdge.Set( ptBr, ptTR) ; -// bool bAllOn = true ; -// -// PNTLIST::iterator lIter = lPtInt.begin() ; -// std::advance( lIter, 0) ; -// for ( int p = 0 ; p < (int)lPtInt.size() ; ++ p) { -// if ( ! clRightEdge.IsPointOn( *lIter)) { -// bAllOn = false ; -// break ; -// } -// } -// // divisi da punti allineati e quindi lato dentro -// if ( bAllOn) { -// m_mTree[nId].m_nRightEdgeIn = 1 ; -// } -// // se sono dentro, ma non allineati, allora solo in parte -// else { -// m_mTree[nId].m_nRightEdgeIn = 2 ; -// } -// } -// } -// // il lato destro è sicuramente esterno -// else { -// m_mTree[nId].m_nRightEdgeIn = 0 ; -// } -// return true ; -//} - //usando le intersezioni con le celle //---------------------------------------------------------------------------- bool -Tree::SetRightEdgeIn( const int& nId) +Tree::SetRightEdgeIn( int nId) { - // categorizzo la cella in base a quanta parte del lato destro è conenuta all'interno delle curve di trim - // RightEdgeIn -> 0 non contenuto ; 1 contenuto ; 2 in parte contenuto + // categorizzo la cella in base a quanta parte del lato destro è conenuta all'interno delle curve di trim + // RightEdgeIn -> 0 non contenuto ; 1 contenuto ; 2 in parte contenuto int nPass = (int) m_mTree[nId].m_vInters.size() ; - if ( nPass == 0 ) { + if ( nPass == 0) { m_mTree[nId].m_nRightEdgeIn = 0 ; return true ; } bool bDone = false ; - // se ho solo loop interni devo controllare se il più esterno è CCW ( lato destro esterno) o CW ( lato destro interno) + // se ho solo loop interni devo controllare se il più esterno è CCW ( lato destro esterno) o CW ( lato destro interno) if ( m_mTree[nId].m_nFlag == 2) { bool bAllContained = true ; bool bContained = false ; @@ -3199,7 +3042,7 @@ Tree::SetRightEdgeIn( const int& nId) if ( ! inA.bCCW) { bContained = false ; Inters inB = m_mTree[nId].m_vInters[0] ; - for( int c = 0 ; c < nInters ; ++ c){ + for ( int c = 0 ; c < nInters ; ++ c) { inB = m_mTree[nId].m_vInters[c] ; if ( inB.nIn == -1) { if ( inB != inA && inB.nChunk == inA.nChunk && inB.bCCW) { @@ -3288,15 +3131,12 @@ Tree::SetRightEdgeIn( const int& nId) m_mTree[nId].m_nRightEdgeIn = 0 ; } - if ( m_mTree[nId].m_nRightEdgeIn != -1) - return true ; - else - return false ; + return ( m_mTree[nId].m_nRightEdgeIn != -1) ; } //---------------------------------------------------------------------------- bool -Tree::CategorizeCell( const int& nId) +Tree::CategorizeCell( int nId) { if ( m_mTree[nId].m_nFlag != -1) { return true ; @@ -3306,10 +3146,10 @@ Tree::CategorizeCell( const int& nId) // mi servono i vicini di sinistra per capire se sono dentro il loop o fuori // nRightEdgeIn // 0 right edge fuori, 1 right edge dentro, 2 metà e metà // nFlag // 0 fuori, 1 intersecata, 2 contiene loop, 3 = 1 & 2, 4 dentro - if ( (int)vNeigh.size() == 0) { + if ( vNeigh.empty()) { m_mTree[nId].m_nFlag = 0 ; } - else if ( (int)vNeigh.size() == 1) { + else if ( vNeigh.size() == 1) { if ( m_mTree[vNeigh[0]].m_nRightEdgeIn == 1) m_mTree[nId].m_nFlag = 4 ; else if ( m_mTree[vNeigh[0]].m_nRightEdgeIn == 0) @@ -3317,18 +3157,16 @@ Tree::CategorizeCell( const int& nId) if ( m_mTree[vNeigh[0]].m_nFlag == 1 || m_mTree[vNeigh[0]].m_nFlag == 3) m_mTree[nId].m_nFlag = 0 ; else { - if ( m_mTree[vNeigh[0]].m_nFlag == 4) { + if ( m_mTree[vNeigh[0]].m_nFlag == 4) m_mTree[nId].m_nFlag = 4 ; - } - else if ( m_mTree[vNeigh[0]].m_nFlag == 0) { + else if ( m_mTree[vNeigh[0]].m_nFlag == 0) m_mTree[nId].m_nFlag = 0 ; - } } // se solo parte del right edge del vicino è compreso, allora devo verificare se la cella è contenuta o no // guardando nFlag del vicino bottom, che è già categorizzato! else if ( m_mTree[vNeigh[0]].m_nRightEdgeIn == 2) { GetBottomNeigh( nId, vNeigh1) ; - if ( (int) vNeigh1.size() > 0) { + if ( ! vNeigh1.empty()) { int nNeigh = vNeigh1[0] ; if ( m_mTree[nNeigh].m_nFlag == 0 || m_mTree[nNeigh].m_nFlag == 2) { m_mTree[nId].m_nFlag = 0 ; @@ -3401,7 +3239,7 @@ Tree::CategorizeCell( const int& nId) } } } - // se non ho vicini bottom devo per forza guardare il vicino a sinistra + // se non ho vicini bottom devo per forza guardare il vicino a sinistra else { Point3d ptInters = m_mTree[vNeigh[0]].GetTopRight() ; int nEdge = 3 ; @@ -3518,7 +3356,7 @@ Tree::CheckIfBetween( const Inters& inA, const Inters& inB) const //---------------------------------------------------------------------------- bool -Tree::GetLeaves( std::vector& vLeaves) const +Tree::GetLeaves( vector& vLeaves) const { vLeaves.clear() ; for ( int k : m_vnLeaves) { @@ -3531,7 +3369,7 @@ Tree::GetLeaves( std::vector& vLeaves) const //---------------------------------------------------------------------------- bool -Tree::OnWhichEdge( const int& nId, const Point3d& ptToAssign, int& nEdge) const +Tree::OnWhichEdge( int nId, const Point3d& ptToAssign, int& nEdge) const { Point3d ptTR = m_mTree.at( nId).GetTopRight() ; Point3d ptBL = m_mTree.at( nId).GetBottomLeft() ; diff --git a/Tree.h b/Tree.h index 541101f..ca485ca 100644 --- a/Tree.h +++ b/Tree.h @@ -14,12 +14,13 @@ #pragma once //--------------------------- Include ---------------------------------------- -#include #include "SurfBezier.h" #include "GeoConst.h" #include "CurveLine.h" #include "/EgtDev/Include/EGkPolyLine.h" +#include +//---------------------------------------------------------------------------- struct Inters { int nIn ; PNTVECTOR vpt ; @@ -29,12 +30,13 @@ struct Inters { int nChunk ; // riordino le intersezioni per lato in senso antiorario dal top // se ho più intersezioni che entrano in un lato le riordino considerando che percorro i lati in senso antiorario a partire da ptTR - bool operator < ( Inters& b) { + bool operator < ( Inters& b) + { // trovo in che ordine stanno i due strat, tenendo conto anche della possibilità che siano vertici INTVECTOR vEdges = { 7, 0, 4, 1, 5, 2, 6, 3} ; - INTVECTOR::iterator iter1 = find( vEdges.begin(), vEdges.end(), nIn) ; + const auto iter1 = find( vEdges.begin(), vEdges.end(), nIn) ; int nPos1 = std::distance( vEdges.begin(), iter1) ; - INTVECTOR::iterator iter2 = find( vEdges.begin(), vEdges.end(), b.nIn) ; + const auto iter2 = find( vEdges.begin(), vEdges.end(), b.nIn) ; int nPos2 = std::distance( vEdges.begin(), iter2) ; // se sono loop interni li ordino in modo decrescente rispetto all'area bool bEqIn = ( nIn == b.nIn) ; @@ -55,17 +57,19 @@ struct Inters { int nEdgeIn = nIn ; if ( nIn > 3) nEdgeIn = nIn - 4 ; - return nPos1 < nPos2 || - ( bEqIn && nEdgeIn == -1 && abs(dAreaA) > abs(dAreaB)) || - ( bEqIn && nEdgeIn == 0 && vpt[0].x > b.vpt[0].x) || - ( bEqIn && nEdgeIn == 1 && vpt[0].y > b.vpt[0].y) || - ( bEqIn && nEdgeIn == 2 && vpt[0].x < b.vpt[0].x) || - ( bEqIn && nEdgeIn == 3 && vpt[0].y < b.vpt[0].y) - ; } - bool operator == ( Inters& b) { + return ( nPos1 < nPos2 || + ( bEqIn && nEdgeIn == -1 && abs( dAreaA) > abs( dAreaB)) || + ( bEqIn && nEdgeIn == 0 && vpt[0].x > b.vpt[0].x) || + ( bEqIn && nEdgeIn == 1 && vpt[0].y > b.vpt[0].y) || + ( bEqIn && nEdgeIn == 2 && vpt[0].x < b.vpt[0].x) || + ( bEqIn && nEdgeIn == 3 && vpt[0].y < b.vpt[0].y)) ; + } + bool operator == ( Inters& b) + { return AreSamePointExact( vpt[0], b.vpt[0]) ; } - bool operator != ( Inters& b){ + bool operator != ( Inters& b) + { return ! AreSamePointExact( vpt[0], b.vpt[0]) ; } } ; @@ -86,23 +90,42 @@ class Cell // |_________________| // Edge 5 ( SW) Edge 2 (Bottom) Edge 6 ( SE) public : - ~Cell( void) ; - Cell( void) ; - Cell( const Point3d& ptBL, const Point3d& ptTR) ; - inline bool IsSame( const Cell& cOtherCell) const ; - void SetBottomLeft( const Point3d ptBL) { m_ptPbl = ptBL ; } - void SetTopRight( const Point3d ptTR) { m_ptPtr = ptTR ; } - void SetSplitDirVert( const bool bVert) { m_bSplitVert = bVert ; } - void SetParent( const int& nParent) { m_nParent = nParent ; } - Point3d GetBottomLeft( void) const { return m_ptPbl ; } - Point3d GetTopRight( void) const { return m_ptPtr ; } - double GetSplitValue( void) const { return m_dSplit ; } - bool IsSplitVert( void) const { return m_bSplitVert ; } // se true la cella verrebbe splittata verticalmente, sennò orizzontalmente - bool IsLeaf( void) const ; // flag che indica se la cella ha figli o se è una foglia - bool IsProcessed( void) const { return m_bProcessed ; } // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati - void SetProcessed( const bool bProcessed = true) { m_bProcessed = bProcessed ; } - static bool minorX ( const Cell& c1, const Cell& c2) { return c1.m_ptPbl.x < c2.m_ptPbl.x ; } - static bool minorY ( const Cell& c1, const Cell& c2) { return c1.m_ptPbl.y < c2.m_ptPbl.y ; } + Cell( void) + : m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0), + m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), + m_ptPbl( ORIG), m_ptPtr( SBZ_TREG_COEFF, SBZ_TREG_COEFF, 0), m_bProcessed( false), m_bSplitVert( true) {} + Cell( const Point3d& ptBL, const Point3d& ptTR) + : m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0), + m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), + m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) {} + bool IsSame( const Cell& cOtherCell) const + { return ( m_nId == cOtherCell.m_nId) ; } + void SetBottomLeft( const Point3d& ptBL) + { m_ptPbl = ptBL ; } + void SetTopRight( const Point3d& ptTR) + { m_ptPtr = ptTR ; } + void SetSplitDirVert( bool bVert) + { m_bSplitVert = bVert ; } + void SetParent( int nParent) + { m_nParent = nParent ; } + Point3d GetBottomLeft( void) const + { return m_ptPbl ; } + Point3d GetTopRight( void) const + { return m_ptPtr ; } + double GetSplitValue( void) const + { return m_dSplit ; } + bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, sennò orizzontalmente + { return m_bSplitVert ; } + bool IsLeaf( void) const // flag che indica se la cella ha figli o se è una foglia + { return ( m_nChild1 == -2 && m_nChild2 == -2) ; } + bool IsProcessed( void) const // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati + { return m_bProcessed ; } + void SetProcessed( bool bProcessed = true) + { m_bProcessed = bProcessed ; } + static bool minorX( const Cell& c1, const Cell& c2) + { return c1.m_ptPbl.x < c2.m_ptPbl.x ; } + static bool minorY( const Cell& c1, const Cell& c2) + { return c1.m_ptPbl.y < c2.m_ptPbl.y ; } public : int m_nId ; // Id della cella @@ -120,8 +143,8 @@ class Cell int m_nFlag2 ; // falg che indica se la cella è stata attraversata durante l'ultima fase del labelling int m_nRightEdgeIn ; // 0 right edge fuori, 1 right edge dentro, 2 metà e metà bool m_bOnLeftEdge ; // flag che indica se la cella è sul lato sinistro ( per superfici chiuse sul parametro U) - bool m_bOnTopEdge ; // flag che indica se la cella è sul lato top ( per superfici chiuse sul parametro V) - std::vector m_vInters ; // vettore delle intersezioni della cella con i loop di trim + bool m_bOnTopEdge ; // flag che indica se la cella è sul lato top ( per superfici chiuse sul parametro V) + std::vector m_vInters ; // vettore delle intersezioni della cella con i loop di trim // ogni elemento del vettore è l'insieme dei punti che caratterizza un atrtaversamento della cella private : @@ -134,71 +157,70 @@ class Cell //---------------------------------------------------------------------------- class Tree { -public : - ~Tree( void) ; - Tree( void) ; - Tree ( const SurfBezier* pSrfBz, const bool bSplitPatches = true, const Point3d ptMin = ORIG, const Point3d ptMax = ORIG) ; - void SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches = true, const Point3d ptMin = ORIG, const Point3d ptMax = ORIG) ; - bool GetIndependentTrees( std::vector>& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini) - bool BuildTree( const double& dLinTol = LIN_TOL_STD, const double& dSideMin = 1, const double& dSideMax = INFINITO) ; // dSideMax è il massimo per la dimensione maggiore di un triangolo della trimesh - // dSideMin è lunghezza minima del lato di una cella nello spazio reale - bool BuildTree_test( const double& dLinTol = LIN_TOL_STD, const double& dSideMin = 1, const double& dSideMax = INFINITO) ; - bool GetPolygons( std::vector& vPolygons) ; - bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero - // ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati - bool GetLeaves ( std::vector& vLeaves) const ; + public : + ~Tree( void) ; + Tree( void) ; + Tree ( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ; + void SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ; + bool GetIndependentTrees( BIPNTVECTOR& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini) + bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax è il massimo per la dimensione maggiore di un triangolo della trimesh + // dSideMin è lunghezza minima del lato di una cella nello spazio reale + bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; + bool GetPolygons( POLYLINEMATRIX& vPolygons) ; + bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero + // ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati + bool GetLeaves ( std::vector& vLeaves) const ; -private : - bool Split( const int& nId, const double& dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert - bool Split( const int& nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert - void Balance () ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profonditù di +- 1 - int GetHeightLeaves ( const int& nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId - int GetDepth ( const int& nId, const int& nRef) const ; // livello del nodo nId - void GetTopNeigh( const int& nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top - void GetBottomNeigh( const int& nId, INTVECTOR& vBottomNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato bottom - void GetLeftNeigh( const int& nId, INTVECTOR& vLeftNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato left - void GetRightNeigh( const int& nId, INTVECTOR& vRightNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato right - void GetRootNeigh( const int& nEdge, INTVECTOR& vNeigh) ; // restituisce le foglie dell'albero che sono adiacenti al lato nEdge, numerato a partire dal top ( 0) in senso antiorario - void ResetTree ( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero - INTVECTOR FindCell ( const Point3d& ptToAssign, const CurveLine& cl) const ; // dato un punto, trova la cella foglia a cui appartiene - INTVECTOR FindCell ( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells) const ; // dato un punto, trova la cella foglia a cui appartiene - bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle - bool FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim - // resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto - bool CreateCellPolygons ( const int& nLeafId, std::vector& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) ; - bool CreateIslandAndHoles ( const int& nLeafId, std::vector& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) ; - bool CheckIfBefore( const PolyLine& pl, const int& nEdge) const ; - bool CheckIfBefore( const Inters& inA) const ; - bool CheckIfBefore( const int& nEdge1, const Point3d& ptP1, const int& nEdge2, const Point3d& ptP2) const ; // punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3 - bool CheckIfBefore( const int& nEdge, const Point3d& ptP1, const Point3d& ptP2, const int& nEdge2 = -1) const ; // entrambi i punti sullo stesso lato, nEdge. nEdge2 serve come backup, in caso nEdge sia un vertice. - bool AreSameEdge( const int& nEdge1, const int nEdge2) const ; - bool AddVertex( const int& nId, const std::vector& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const ; - //bool SetRightEdgeIn( int nId, std::vector& vEdgeVertex, PolyLine& plTrimmedPoly) ; - bool SetRightEdgeIn( const int& nId) ; - bool CategorizeCell( const int& nId) ; - bool CheckIfBetween( const Inters& inA, const Inters& inB) const ; - bool OnWhichEdge( const int& nId, const Point3d& ptToAssign, int& nEdge) const ; + private : + bool Split( int nId, double dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert + bool Split( int nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert + void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profonditù di +- 1 + int GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId + int GetDepth( int nId, int nRef) const ; // livello del nodo nId + void GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top + void GetBottomNeigh( int nId, INTVECTOR& vBottomNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato bottom + void GetLeftNeigh( int nId, INTVECTOR& vLeftNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato left + void GetRightNeigh( int nId, INTVECTOR& vRightNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato right + void GetRootNeigh( int nEdge, INTVECTOR& vNeigh) ; // restituisce le foglie dell'albero che sono adiacenti al lato nEdge, numerato a partire dal top ( 0) in senso antiorario + void ResetTree( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero + INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl) const ; // dato un punto, trova la cella foglia a cui appartiene + INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells) const ; // dato un punto, trova la cella foglia a cui appartiene + bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle + bool FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim + // resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto + bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) ; + bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) ; + bool CheckIfBefore( const PolyLine& pl, int nEdge) const ; + bool CheckIfBefore( const Inters& inA) const ; + bool CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const ; // punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3 + bool CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2 = -1) const ; // entrambi i punti sullo stesso lato, nEdge. nEdge2 serve come backup, in caso nEdge sia un vertice. + bool AreSameEdge( int nEdge1, int nEdge2) const ; + bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const ; + bool SetRightEdgeIn( int nId) ; + bool CategorizeCell( int nId) ; + bool CheckIfBetween( const Inters& inA, const Inters& inB) const ; + bool OnWhichEdge( int nId, const Point3d& ptToAssign, int& nEdge) const ; -private : - const SurfBezier* m_pSrfBz ; // superficie di bezier - DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00 - bool m_bTrimmed ; // superficie trimmata - std::vector m_vChunk ; // elenco dei loop divisi per chunk - std::map m_mChunk ; - ICURVEPOVECTOR m_vLoop ; // curve di loop - std::vector> m_vPlApprox ; - bool m_bBilinear ; // superficie bilineare - bool m_bMulti ; // superficie multi-patch - bool m_bClosedU ; // superficie chiusa lungo il parametro U - bool m_bClosedV ; // superficie chiusa lungo il parametro V - bool m_bSplitPatches ; // flag che indica se le patches sono state divise prima della creazione dell'albero - int m_nDegU ; // grado della superficie nel parametro U - int m_nDegV ; // grado della superficie nel parametro V - int m_nSpanU ; - int m_nSpanV ; - std::vector m_vPolygons ; // vettore dei poligoni del tree - std::map m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root - std::map m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id è lo stesso che la cella ha in m_mTree - INTVECTOR m_vnLeaves ; // vettore delle foglie - INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch + private : + const SurfBezier* m_pSrfBz ; // superficie di bezier + DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00 + bool m_bTrimmed ; // superficie trimmata + INTMATRIX m_vChunk ; // elenco dei loop divisi per chunk + std::map m_mChunk ; + ICURVEPOVECTOR m_vLoop ; // curve di loop + std::vector> m_vPlApprox ; + bool m_bBilinear ; // superficie bilineare + bool m_bMulti ; // superficie multi-patch + bool m_bClosedU ; // superficie chiusa lungo il parametro U + bool m_bClosedV ; // superficie chiusa lungo il parametro V + bool m_bSplitPatches ; // flag che indica se le patches sono state divise prima della creazione dell'albero + int m_nDegU ; // grado della superficie nel parametro U + int m_nDegV ; // grado della superficie nel parametro V + int m_nSpanU ; + int m_nSpanV ; + POLYLINEMATRIX m_vPolygons ; // matrice dei poligoni del tree + std::map m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root + std::map m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id è lo stesso che la cella ha in m_mTree + INTVECTOR m_vnLeaves ; // vettore delle foglie + INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch } ; \ No newline at end of file From ac5fe3ac65d9c893970c866eda7a450d0820faea Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 29 Dec 2023 13:01:09 +0100 Subject: [PATCH 03/13] EgtGeomKernel : - modifiche estetiche. --- CalcPocketing.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/CalcPocketing.cpp b/CalcPocketing.cpp index de2d4f2..dffed81 100644 --- a/CalcPocketing.cpp +++ b/CalcPocketing.cpp @@ -13,22 +13,21 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include "DllMain.h" -#include "GeoConst.h" #include "CurveLine.h" #include "CurveArc.h" #include "CurveComposite.h" #include "BiArcs.h" #include "SurfFlatRegion.h" +#include "GeoConst.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkCalcPocketing.h" -#include "EgtDev/Include/EGkFilletChamfer.h" -#include "EgtDev/Include/EGkDistPointCurve.h" -#include "EgtDev/Include/EGkDistPointCurve.h" -#include "EgtDev/Include/EGkCurveLocal.h" -#include "EgtDev/Include/EGkMedialAxis.h" -#include "EgtDev/Include/EGkLinePntTgCurve.h" +#include "/EgtDev/Include/EGkFilletChamfer.h" +#include "/EgtDev/Include/EGkDistPointCurve.h" +#include "/EgtDev/Include/EGkDistPointCurve.h" +#include "/EgtDev/Include/EGkCurveLocal.h" +#include "/EgtDev/Include/EGkMedialAxis.h" +#include "/EgtDev/Include/EGkLinePntTgCurve.h" #include using namespace std ; From 0dc918880e56d5ebc492c9ef623fa13327a03008 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 2 Jan 2024 15:57:23 +0100 Subject: [PATCH 04/13] EgtGeomKernel : - piccola modifica della tolleranza movimenti di Collision Avoid per Trimesh. --- CAvToolTriangle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CAvToolTriangle.cpp b/CAvToolTriangle.cpp index b5e1bdb..7c04daf 100644 --- a/CAvToolTriangle.cpp +++ b/CAvToolTriangle.cpp @@ -146,7 +146,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& const Triangle3d& trTria, const Vector3d& vtMove) { // Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile - if ( vtMove * vtToolAx < - EPS_ZERO) + if ( vtMove * vtToolAx < - 10 * EPS_ZERO) return -1. ; // Se avvicinamento non devo fare nulla if ( vtMove * trTria.GetN() < - EPS_ZERO) From 0e927d7294d5afe1666c3708879e561f82fe7781 Mon Sep 17 00:00:00 2001 From: SaraP Date: Fri, 5 Jan 2024 17:18:40 +0100 Subject: [PATCH 05/13] EgtGeomKernel : - piccola correzione in RemoveCurveSmallParts. --- RemoveCurveDefects.cpp | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/RemoveCurveDefects.cpp b/RemoveCurveDefects.cpp index f3b0a42..48d81f5 100644 --- a/RemoveCurveDefects.cpp +++ b/RemoveCurveDefects.cpp @@ -158,7 +158,6 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) Point3d ptStart ; pFirstCrv->GetStartPoint( ptStart) ; delete( pCurve->RemoveFirstOrLastCurve( false)) ; pCurve->ModifyStart( ptStart) ; - -- nCrvCount ; } // curva finale const ICurve* pLastCrv = pCurve->GetLastCurve() ; @@ -167,38 +166,40 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) Point3d ptEnd ; pLastCrv->GetStartPoint( ptEnd) ; delete( pCurve->RemoveFirstOrLastCurve( true)) ; pCurve->ModifyEnd( ptEnd) ; - -- nCrvCount ; } } - // ciclo sulle curve elementari della composita - int nStart = pCurve->IsClosed() ? 0 : 1 ; - int nEnd = pCurve->IsClosed() ? nCrvCount : nCrvCount - 1 ; - for ( int i = nStart ; i < nEnd ; ++ i) { - // recupero la curva corrente - const ICurve* pCurrCrv = pCurve->GetCurve( i) ; - // se la curva corrente è troppo corta - double dLen ; pCurrCrv->GetLength( dLen) ; - if ( dLen < dLinTol) { - // recupero il punto medio della curva - Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ; - // rimuovo il segmento - if ( pCurve->RemoveJoint( i)) { - -- nCrvCount ; - -- nEnd ; - -- i ; - // porto il nuovo estremo sul punto medio - pCurve->ModifyJoint( i + 1, ptMid) ; - } - // altrimenti devo rimuovere anche il successivo - else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) { - nCrvCount -= 2 ; - nEnd -= 2 ; - -- i ; - // porto il nuovo estremo sul punto medio - pCurve->ModifyJoint( i + 1, ptMid) ; + // ciclo sulle curve elementari della composita finchè trovo tratti da eliminare + bool bRemoved = false ; + do { + int nStart = pCurve->IsClosed() ? 0 : 1 ; + int nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ; + bRemoved = false ; + for ( int i = nStart ; i < nEnd ; ++ i) { + // recupero la curva corrente + const ICurve* pCurrCrv = pCurve->GetCurve( i) ; + // se la curva corrente è troppo corta + double dLen ; pCurrCrv->GetLength( dLen) ; + if ( dLen < dLinTol) { + // recupero il punto medio della curva + Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ; + // rimuovo il segmento + if ( pCurve->RemoveJoint( i)) { + bRemoved = true ; + // porto il nuovo estremo sul punto medio + pCurve->ModifyJoint( i, ptMid) ; + break ; + } + // altrimenti devo rimuovere anche il successivo + else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) { + bRemoved = true ; + // porto il nuovo estremo sul punto medio + pCurve->ModifyJoint( i, ptMid) ; + break ; + } } } } + while ( bRemoved) ; return true ; -} +} \ No newline at end of file From 1c2b127a91de11ce4d9238100c127fd1df81d34a Mon Sep 17 00:00:00 2001 From: SaraP Date: Mon, 8 Jan 2024 10:17:15 +0100 Subject: [PATCH 06/13] EgtGeomKernel : - migliorie in RemoveCurveSmallParts per evitare conti superflui introdotti con ultima correzione. --- RemoveCurveDefects.cpp | 53 +++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/RemoveCurveDefects.cpp b/RemoveCurveDefects.cpp index 48d81f5..fbc0a55 100644 --- a/RemoveCurveDefects.cpp +++ b/RemoveCurveDefects.cpp @@ -149,6 +149,7 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) int nCrvCount = pCurve->GetCurveCount() ; if ( nCrvCount < 2 || ( nCrvCount < 3 && pCurve->IsClosed())) return true ; + // se aperta, verifico le due curve agli estremi if ( ! pCurve->IsClosed()) { // curva iniziale @@ -158,6 +159,7 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) Point3d ptStart ; pFirstCrv->GetStartPoint( ptStart) ; delete( pCurve->RemoveFirstOrLastCurve( false)) ; pCurve->ModifyStart( ptStart) ; + -- nCrvCount ; } // curva finale const ICurve* pLastCrv = pCurve->GetLastCurve() ; @@ -166,40 +168,33 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) Point3d ptEnd ; pLastCrv->GetStartPoint( ptEnd) ; delete( pCurve->RemoveFirstOrLastCurve( true)) ; pCurve->ModifyEnd( ptEnd) ; + -- nCrvCount ; } } - // ciclo sulle curve elementari della composita finchè trovo tratti da eliminare - bool bRemoved = false ; - do { - int nStart = pCurve->IsClosed() ? 0 : 1 ; - int nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ; - bRemoved = false ; - for ( int i = nStart ; i < nEnd ; ++ i) { - // recupero la curva corrente - const ICurve* pCurrCrv = pCurve->GetCurve( i) ; - // se la curva corrente è troppo corta - double dLen ; pCurrCrv->GetLength( dLen) ; - if ( dLen < dLinTol) { - // recupero il punto medio della curva - Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ; - // rimuovo il segmento - if ( pCurve->RemoveJoint( i)) { - bRemoved = true ; - // porto il nuovo estremo sul punto medio - pCurve->ModifyJoint( i, ptMid) ; - break ; - } - // altrimenti devo rimuovere anche il successivo - else if ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i)) { - bRemoved = true ; - // porto il nuovo estremo sul punto medio - pCurve->ModifyJoint( i, ptMid) ; - break ; - } + + // ciclo sulle curve elementari della composita + int nStart = pCurve->IsClosed() ? 0 : 1 ; + int nEnd = pCurve->IsClosed() ? nCrvCount : nCrvCount - 1 ; + for ( int i = nStart ; i < nEnd ; ++ i) { + // recupero la curva corrente + const ICurve* pCurrCrv = pCurve->GetCurve( i) ; + // se la curva corrente è troppo corta + double dLen ; pCurrCrv->GetLength( dLen) ; + if ( dLen < dLinTol) { + // recupero il punto medio della curva + Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ; + // rimuovo il segmento oppure in caso di fallimento rimuovo anche il successivo + if ( pCurve->RemoveJoint( i) || ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i))) { + // porto il nuovo estremo sul punto medio + pCurve->ModifyJoint( i, ptMid) ; + // aggiorno valore di i tenendo conto che ModifyJoint potrebbe modificare la curva precedente + // che quindi va ricontrollata + i = max( i - 2, nStart - 1) ; + // aggiorno valore di nEnd ( ModifyJoint potrebbe aver rimosso la curva precedente e la successiva) + nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ; } } } - while ( bRemoved) ; return true ; } \ No newline at end of file From 7ee7fea37593c14697b7aed51583790449a0c593 Mon Sep 17 00:00:00 2001 From: SaraP Date: Mon, 8 Jan 2024 16:00:19 +0100 Subject: [PATCH 07/13] EgtGeomKernel : - correzioni nella verifica di collisione tra triangoli. --- CDeTriaTria.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CDeTriaTria.cpp b/CDeTriaTria.cpp index 1472bfd..c4499f0 100644 --- a/CDeTriaTria.cpp +++ b/CDeTriaTria.cpp @@ -34,7 +34,7 @@ GetTwoGreater( int nVal0, int nVal1, int nVal2, int& nFirstMaxPos, int& nSecondM } else { nFirstMaxPos = 2 ; - nSecondMaxPos = 1 ; + nSecondMaxPos = 0 ; } } else if ( nVal0 > nVal2) { @@ -168,7 +168,7 @@ CDeTriaTria( const Triangle3d& trTriaA, const Triangle3d& trTriaB) Vector3d vtSegSecondB = trTriaB.GetP( ( nSecondMaxPosB + 1) % 3) - trTriaB.GetP( nSecondMaxPosB) ; double dSegLenSecondB = vtSegSecondB.Len() ; vtSegSecondB /= dSegLenSecondB ; - DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosA), vtSegSecondB, dSegLenSecondB, false) ; + DistLineLine LineLineDistCalcSecondB( ptLineP, vtLineV, 100., trTriaB.GetP( nSecondMaxPosB), vtSegSecondB, dSegLenSecondB, false) ; double dIntParEnB, dOtherParSecondB ; LineLineDistCalcSecondB.GetPositionsAtMinDistPoints( dIntParEnB, dOtherParSecondB) ; // Ordino i parametri lungo la retta di intersezione fra i piani From 5c222cc59f8c764b7a879e65110780a808620f33 Mon Sep 17 00:00:00 2001 From: SaraP Date: Wed, 10 Jan 2024 10:09:26 +0100 Subject: [PATCH 08/13] EgtGeomKernel : - in OffsetCurve aggiuto membro per tolleranza lineare - in SurfFrFromFatCurve aggiunta tolleranza per l'offset. --- OffsetCurve.cpp | 20 ++++++++++---------- SfrCreate.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/OffsetCurve.cpp b/OffsetCurve.cpp index f12841a..106d22c 100644 --- a/OffsetCurve.cpp +++ b/OffsetCurve.cpp @@ -85,7 +85,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) else { const CurveComposite* pCompo = GetBasicCurveComposite( pCrv) ; Point3d ptStart, ptEnd ; - if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd)) + if ( pCompo != nullptr && pCompo->IsALine( m_dLinTol, ptStart, ptEnd)) bIsLine = true ; } // verifico che la curva sia piana (per le linee è comunque sempre vero) @@ -171,15 +171,15 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) if ( ! bUseVoronoi) { // verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+) - if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( 10 * EPS_SMALL, ANG_TOL_STD_DEG)) + if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, ANG_TOL_STD_DEG)) return false ; // elimino eventuali piccole Z - if ( ! RemoveCurveSmallZs( &ccCopy, 10 * EPS_SMALL)) + if ( ! RemoveCurveSmallZs( &ccCopy, m_dLinTol)) return false ; // elimino tratti molto corti - if ( ! RemoveCurveSmallParts( &ccCopy, 10 * EPS_SMALL)) + if ( ! RemoveCurveSmallParts( &ccCopy, m_dLinTol)) return false ; // converto archi diritti in segmenti di retta @@ -187,7 +187,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) if ( ! ccCopy.StraightArcsToLines( 2 * EPS_SMALL, ANG_CEN_MAX)) return false ; // unisco parti allineate - if ( ! ccCopy.MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG, bClosed)) + if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed)) return false ; // verifico se il punto iniziale è stato modificato @@ -437,7 +437,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) // se non rimasto nulla, esco double dLen ; - if ( ! pCrvCompo->IsValid() || ! pCrvCompo->GetLength( dLen) || dLen < 10 * EPS_SMALL) + if ( ! pCrvCompo->IsValid() || ! pCrvCompo->GetLength( dLen) || dLen < m_dLinTol) return true ; // inserisco la curva nella lista m_CrvLst.push_back( Release( pCrvCompo)) ; @@ -656,14 +656,14 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) pCrvCo2->GetStartPoint( ptStart2) ; pCrvCo2->GetEndPoint( ptEnd2) ; // verifiche di concatenamento - if ( AreSamePointEpsilon( ptEnd, ptStart2, 10 * EPS_SMALL)) { - if ( pCrvCo->AddCurve( pCrvCo2, true, 10 * EPS_SMALL)) + if ( AreSamePointEpsilon( ptEnd, ptStart2, m_dLinTol)) { + if ( pCrvCo->AddCurve( pCrvCo2, true, m_dLinTol)) ptEnd = ptEnd2 ; m_CrvLst.erase( iIter2) ; iIter2 = next( iIter) ; } - else if ( AreSamePointEpsilon( ptEnd2, ptStart, 10 * EPS_SMALL)) { - if ( pCrvCo->AddCurve( pCrvCo2, false, 10 * EPS_SMALL)) + else if ( AreSamePointEpsilon( ptEnd2, ptStart, m_dLinTol)) { + if ( pCrvCo->AddCurve( pCrvCo2, false, m_dLinTol)) ptStart = ptStart2 ; m_CrvLst.erase( iIter2) ; iIter2 = next( iIter) ; diff --git a/SfrCreate.cpp b/SfrCreate.cpp index 96f6671..107c53c 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -114,7 +114,7 @@ GetSurfFlatRegionDisk( double dRadius) //------------------------------------------------------------------------------- ISurfFlatRegion* -GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids) +GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, bool bSquareMids, double dOffsLinTol) { // imposto metodo di calcolo bool bUseVoronoi = false ; @@ -187,7 +187,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b // per creare la regione SurfFlatRegionByContours SfrCntr( false, false) ; // offset della prima curva a destra del raggio - OffsetCurve OffsCrv1 ; + OffsetCurve OffsCrv1( dOffsLinTol) ; if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType)) return nullptr ; ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ; @@ -197,7 +197,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b } // offset della seconda curva a destra del raggio (è invertita rispetto alla precedente) - OffsetCurve OffsCrv2 ; + OffsetCurve OffsCrv2( dOffsLinTol) ; if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType)) return nullptr ; ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ; @@ -227,7 +227,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b SurfFlatRegionByContours SfrCntr( false, false) ; // offset della prima curva a destra del raggio - OffsetCurve OffsCrv1 ; + OffsetCurve OffsCrv1( dOffsLinTol) ; if ( ! OffsCrv1.Make( pCompo1, dRadius, nOffsType)) return nullptr ; ICurve* pOffs1 = OffsCrv1.GetLongerCurve() ; @@ -243,7 +243,7 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b } // offset della seconda curva a destra del raggio - OffsetCurve OffsCrv2 ; + OffsetCurve OffsCrv2( dOffsLinTol) ; if ( ! OffsCrv2.Make( pCompo2, dRadius, nOffsType)) return nullptr ; ICurve* pOffs2 = OffsCrv2.GetLongerCurve() ; From 1f77e00f342ecaf0948134cd2f5d6e8b0016dc78 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 16 Jan 2024 15:14:25 +0100 Subject: [PATCH 09/13] EgtGeomKernel 2.6a1 : - ricompilazione con cambio versione. --- EgtGeomKernel.rc | Bin 11718 -> 11710 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 693c79cad1e40a7fcb7fca37e168997569dd892a..f895a8ec332d7d0ad4593c643cfc06d999a1ef48 100644 GIT binary patch delta 250 zcmX>Wy)SyhCpJzq1|0@N5T1OWPm|GXGbjI2rpa|eI+K5JDzTa|BmyNAg>@(UaBW~T z+5DHQm=UO^kSCc5i$;ECbPbdLa!s8)LHHh6PbA~!6QW#<#B1!6hG-0Aocw^5WAX{n ftjPv)3$W Date: Fri, 19 Jan 2024 10:28:34 +0100 Subject: [PATCH 10/13] EgtGeomKernel : - correzioni e miglioramenti nel calcolo dei bisettori di Voronoi - corretto il modo di gestire gli archi per rispettare le tolleranze di vroni - in GetSurfTriMeshBeveledRectSwept tolto il calcolo in parallelo degli offset se conti fatti con Voronoi. --- StmFromCurves.cpp | 35 ++++++++++---- Voronoi.cpp | 118 +++++++++++++++++++++++++++------------------- 2 files changed, 94 insertions(+), 59 deletions(-) diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 7e66517..974683e 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -440,6 +440,12 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, static ISurfTriMesh* GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) { + // imposto metodo di calcolo + bool bUseVoronoi = false ; + #ifdef _VRONI + bUseVoronoi = true ; + #endif // _VRONI + // verifico che la linea guida sia piana Plane3d plGuide ; if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL)) @@ -456,19 +462,28 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub const int NUM_OFFS = 4 ; OffsetCurve vOffsCrv[NUM_OFFS] ; double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ; - future vRes[NUM_OFFS] ; - for ( int i = 0 ; i < NUM_OFFS ; ++ i) - vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ; bool bOk = true ; - int nFin = 0 ; - while ( nFin < NUM_OFFS) { - for ( int i = 0 ; i < NUM_OFFS ; ++ i) { - if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) { - bOk = vRes[i].get() && bOk ; - ++ nFin ; + if ( ! bUseVoronoi) { + future vRes[NUM_OFFS] ; + for ( int i = 0 ; i < NUM_OFFS ; ++ i) + vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ; + bool bOk = true ; + int nFin = 0 ; + while ( nFin < NUM_OFFS) { + for ( int i = 0 ; i < NUM_OFFS ; ++ i) { + if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) { + bOk = vRes[i].get() && bOk ; + ++ nFin ; + } } - } + } } + else { + // se Voronoi non è possibile calcolare gli offset di una stessa curva in parallelo + for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i) + bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ; + } + if ( ! bOk || vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 || vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0) diff --git a/Voronoi.cpp b/Voronoi.cpp index 641494d..b0db98e 100644 --- a/Voronoi.cpp +++ b/Voronoi.cpp @@ -244,7 +244,7 @@ Voronoi::AddArcToVroni( const ICurveArc* pArc, int& nVroniCrv, int nLoopId, int Point3d ptCen = pArc->GetCenter() ; double dAngCen = pArc->GetAngCenter() ; - int nArcSiteType = ( dAngCen > EPS_SMALL ? ARC : -ARC ) ; + int nArcSiteType = ( dAngCen > 0 ? ARC : -ARC ) ; Vector3d vtN = pArc->GetNormVersor() ; if ( AreOppositeVectorApprox( vtN, Z_AX)) nArcSiteType *= -1 ; @@ -377,65 +377,85 @@ Voronoi::GetBisectorCurve( int i) { if ( i >= m_vroni->GetNumberOfEdges()) return nullptr ; - - // recupero estremi del bisettore - Point3d ptS, ptE ; - m_vroni->GetVDBisectorPoints( i, ptS.v, ptE.v) ; - if ( AreSamePointApprox( ptS, ptE)) - return nullptr ; - - // recupero parametri del bisettore - double dParS, dParE ; - m_vroni->GetVDBisectorParams( i, dParS, dParE) ; - - // eventuale inversione - if ( dParS > dParE + EPS_SMALL) { - swap( dParS, dParE) ; - swap( ptS, ptE) ; - } - - // costruisco la curva - int nType = m_vroni->GetVDBisectorType( i) ; - if ( nType == LINE) { + + // identifico il tipo di bisettore + int nType = m_vroni->GetBisectorType( i) ; + + // linea + if ( nType == BisectorType::LINE) { + // recupero i dati del bisettore da vroni + Point3d ptS, ptE ; + double dParS, dParE ; + m_vroni->GetLinearBisectorData( i, ptS.v, ptE.v, dParS, dParE) ; + // creo la linea CurveLine* pLine = CreateBasicCurveLine() ; if ( pLine == nullptr) return nullptr ; pLine->Set( ptS, ptE) ; - pLine->ToGlob( m_Frame) ; - // salvo le distanze nei suoi estremi come TempParam pLine->SetTempParam( dParS, 0) ; pLine->SetTempParam( dParE, 1) ; + pLine->ToGlob( m_Frame) ; return pLine ; } - else if ( nType != NONE) { - // creo una composita campionando il bisettore + + // degenerate hyperellipse ( arco) + else if ( nType == BisectorType::DEGENERATE_HYPERELL) { + // recupero i dati del bisettore da vroni + Point3d ptS, ptE, ptC ; + double dParS, dParE ; + m_vroni->GetDegenerateHyperEllipticBisectorData( i, ptS.v, ptE.v, ptC.v, dParS, dParE) ; + // creo arco + CurveArc* pArc = CreateBasicCurveArc() ; + if ( pArc == nullptr) + return nullptr ; + pArc->SetC2P( ptC, ptS, ptE) ; + pArc->SetTempParam( dParS, 0) ; + pArc->SetTempParam( dParS, 1) ; + pArc->ToGlob( m_Frame) ; + return pArc ; + } + + // bisettore generico + else if ( nType != BisectorType::NONE) { + // approssimo linearmente il bisettore + int nPoints = m_vroni->GetApproxedBisectorPointsNbr( i) ; + if ( nPoints < 2) + return nullptr ; + CurveComposite* pCompo = CreateBasicCurveComposite() ; if ( pCompo == nullptr) - return nullptr ; - int nMaxPnts = 100 ; - double dDelta = ( dParE - dParS) / nMaxPnts ; - pCompo->AddPoint( ptS) ; - for ( int j = 1 ; j < nMaxPnts ; j ++) { - Point3d ptP ; - m_vroni->GetVDBisectorPointAtParam( i, dParS + j * dDelta, ptP.v) ; - if ( pCompo->AddLine( ptP)) { - // salvo le distanze dalla curva nei suoi estremi come temp param - pCompo->SetCurveTempParam( pCompo->GetCurveCount() - 1, dParS + ( j - 1) * dDelta, 0) ; - pCompo->SetCurveTempParam( pCompo->GetCurveCount() - 1, dParS + j * dDelta, 1) ; - } - } - // ultimo punto - if ( pCompo->AddLine( ptE)) { - pCompo->SetCurveTempParam( pCompo->GetCurveCount() - 1, dParS + ( nMaxPnts - 1) * dDelta, 0) ; - pCompo->SetCurveTempParam( pCompo->GetCurveCount() - 1, dParE, 1) ; + return nullptr ; + + // punto iniziale + Point3d pt ; + double dParS ; + m_vroni->GetApproxedBisectorPoint( i, 0, pt.v, dParS) ; + pCompo->AddPoint( pt) ; + int nCrvCount = 0 ; + + double dParPrev = dParS ; + for ( int j = 1 ; j < nPoints ; j ++) { + double dPar ; + m_vroni->GetApproxedBisectorPoint( i, j, pt.v, dPar) ; + if ( pCompo->AddLine( pt)) { + // setto i parametri sulla sottocurva + pCompo->SetCurveTempParam( nCrvCount, dParPrev, 0) ; + pCompo->SetCurveTempParam( nCrvCount, dPar, 1) ; + // aggiorno parametro precedente + dParPrev = dPar ; + nCrvCount ++ ; + } } + + // setto parametri sulla curva pCompo->SetTempParam( dParS, 0) ; - pCompo->SetTempParam( dParE, 1) ; - pCompo->ToGlob( m_Frame) ; - return pCompo ; + pCompo->SetTempParam( dParPrev, 1) ; + + pCompo->ToGlob( m_Frame) ; + return pCompo ; } - else - return nullptr ; + + return nullptr ; } //---------------------------------------------------------------------------- @@ -454,7 +474,7 @@ Voronoi::CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound) for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) { // recupero la curva del bisettore PtrOwner pCrv( GetBisectorCurve( i)) ; - if ( ! IsNull( pCrv)) + if ( ! IsNull( pCrv) && pCrv->IsValid()) vCrvs.emplace_back( Release( pCrv)) ; } @@ -488,7 +508,7 @@ Voronoi::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) // verifico se il lato appartiene al medial axis if ( m_vroni->IsWMATEdge( i)) { PtrOwner pCrv( GetBisectorCurve( i)) ; - if ( ! IsNull( pCrv)) + if ( ! IsNull( pCrv) && pCrv->IsValid()) vCrvs.emplace_back( Release( pCrv)) ; } } From d96660e6d1432d2ed5bed88a1cb8948ac1a95e0f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 22 Jan 2024 08:37:05 +0100 Subject: [PATCH 11/13] EgtGeomKernel : - correzione verifica collisione tra SurfTrimesh chiusa e Zmap. --- VolZmapCalculus.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/VolZmapCalculus.cpp b/VolZmapCalculus.cpp index 9e7e8f6..cadc688 100644 --- a/VolZmapCalculus.cpp +++ b/VolZmapCalculus.cpp @@ -1930,9 +1930,12 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis } // Intersezione della linea con triangolo eventualmente offsettato Point3d ptInt, ptInt2 ; - if ( IntersLineTria( ptT, vtK, 1, trNewTria, ptInt, ptInt2, false) != IntLineTriaType::ILTT_NO) { + int nIntLnTr = IntersLineTria( ptT, vtK, 1, trNewTria, ptInt, ptInt2, false) ; + if ( nIntLnTr != ILTT_NO) { double dZmin = ( ptInt - ptT) * vtK ; - double dZmax = ( ptInt2 - ptT) * vtK ; + double dZmax = dZmin ; + if ( nIntLnTr == ILTT_SEGM || nIntLnTr == ILTT_SEGM_ON_EDGE) + dZmax = ( ptInt2 - ptT) * vtK ; for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) { if ( dZmax > m_Values[0][nPos][nIndex].dMin - EPS_SMALL && dZmin < m_Values[0][nPos][nIndex].dMax + EPS_SMALL) From d5e1be8be29cd7fc41e4b80d36cbea69ce57cc98 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 22 Jan 2024 11:26:49 +0100 Subject: [PATCH 12/13] =?UTF-8?q?EgtGeomKernel=20:=20-=20in=20OffsetCurve?= =?UTF-8?q?=20modifica=20merge=20per=20stesse=20propriet=C3=A0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OffsetCurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OffsetCurve.cpp b/OffsetCurve.cpp index 106d22c..17de301 100644 --- a/OffsetCurve.cpp +++ b/OffsetCurve.cpp @@ -187,7 +187,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) if ( ! ccCopy.StraightArcsToLines( 2 * EPS_SMALL, ANG_CEN_MAX)) return false ; // unisco parti allineate - if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed)) + if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed, true)) return false ; // verifico se il punto iniziale è stato modificato From 44d080eae9c0f5e36bfac9aba6b586992c8c814b Mon Sep 17 00:00:00 2001 From: SaraP Date: Mon, 22 Jan 2024 13:22:50 +0100 Subject: [PATCH 13/13] EgtGeomKernel : - correzione in RemoveCurveSmallParts. --- RemoveCurveDefects.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/RemoveCurveDefects.cpp b/RemoveCurveDefects.cpp index fbc0a55..fcdd695 100644 --- a/RemoveCurveDefects.cpp +++ b/RemoveCurveDefects.cpp @@ -183,8 +183,8 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) if ( dLen < dLinTol) { // recupero il punto medio della curva Point3d ptMid ; pCurrCrv->GetMidPoint( ptMid) ; - // rimuovo il segmento oppure in caso di fallimento rimuovo anche il successivo - if ( pCurve->RemoveJoint( i) || ( pCurve->RemoveJoint( i + 1) && pCurve->RemoveJoint( i))) { + // rimuovo il segmento + if ( pCurve->RemoveJoint( i)) { // porto il nuovo estremo sul punto medio pCurve->ModifyJoint( i, ptMid) ; // aggiorno valore di i tenendo conto che ModifyJoint potrebbe modificare la curva precedente @@ -193,6 +193,13 @@ RemoveCurveSmallParts( ICurveComposite* pCurve, double dLinTol) // aggiorno valore di nEnd ( ModifyJoint potrebbe aver rimosso la curva precedente e la successiva) nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ; } + // altrimenti rimuovo anche il successivo + else if ( pCurve->RemoveJoint( i + 1)) { + pCurve->RemoveJoint( i) ; + pCurve->ModifyJoint( i, ptMid) ; + i = max( i - 2, nStart - 1) ; + nEnd = pCurve->GetCurveCount() - ( pCurve->IsClosed() ? 0 : 1) ; + } } }