diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 2c34eab..974abd7 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -30,6 +30,7 @@ #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkIntervals.h" #include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include @@ -1321,8 +1322,8 @@ CurveComposite::ApproxWithLines( double dLinTol, double dAngTolDeg, int nType, P // se lineare con lato obbligato... if ( nType == APL_LEFT || nType == APL_LEFT_CONVEX || nType == APL_RIGHT || nType == APL_RIGHT_CONVEX) { - // prima approssimazione lineare a 10 * Epsilon - if ( ! ApproxWithLines( 10 * EPS_SMALL, dAngTolDeg, APL_SPECIAL, PL)) + // prima approssimazione lineare alla tolleranza minima del programma + if ( ! ApproxWithLines( EPS_SMALL, dAngTolDeg, APL_SPECIAL, PL)) return false ; // eliminazione dei punti in tolleranza andando solo dalla parte ammessa Vector3d vtExtr = ( m_VtExtr.IsSmall() ? Z_AX : m_VtExtr) ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 1feb06a..6280b38 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/SurfTriMeshUtilities.cpp b/SurfTriMeshUtilities.cpp index 0b3ce6d..ee7f2cc 100644 --- a/SurfTriMeshUtilities.cpp +++ b/SurfTriMeshUtilities.cpp @@ -151,9 +151,9 @@ AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif) bModif = true ; } } + // Nuovo punto di riferimento + itLast = it ; } - // Nuovo punto di riferimento - itLast = it ; } } } @@ -193,7 +193,7 @@ SurfTriMesh::SimplifyFacets( double dMaxEdgeLen) // Mi assicuro che il punto iniziale/finale non sia all'interno di un possibile segmento if ( ! ChooseGoodStartPoint( PointList)) continue ; - + // Sistemo il loop bool bModif = false ; if ( ! AdjustLoop( PointList, dMaxEdgeLen, bModif)) diff --git a/Triangulate.cpp b/Triangulate.cpp index a513ffb..aaf2b50 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -72,16 +72,9 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) if ( ! bCCW) reverse( vPt.begin(), vPt.end()) ; - // creo il vettore degli indici del Poligono - INTVECTOR vPol ; - int n = int( vPt.size()) ; - vPol.reserve( n) ; - for ( int i = 0 ; i < n ; ++ i) - vPol.push_back( i) ; - // eseguo la triangolazione - if ( ! MakeByEC2( vPt, vPol, vTr) && - ! MakeByEC3( vPt, vPol, vTr)) { + if ( ! MakeByEC2( vPt, vTr) && + ! MakeByEC3( vPt, vTr)) { LOG_ERROR( GetEGkLogger(), "Error in MakeByEC23(1)") return MakeByEC_HPP( PL, bCCW, vPt, vTr) ; } @@ -191,19 +184,11 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) const_cast(vPL[i]).Invert( true) ; } if ( ! bOk) - return false ; - - // creo il vettore degli indici del Poligono - INTVECTOR vPol ; - int n = int( vPt.size()) ; - vPol.reserve( n) ; - // non devo gestire separatamente CCW perchè ho già invertito i punti - for ( int i = 0 ; i < n ; ++ i) - vPol.push_back( i) ; + return MakeByEC_HPP( vPL, bCCW, vPt, vTr) ; // eseguo la triangolazione - if ( ! MakeByEC2( vPt, vPol, vTr) && - ! MakeByEC3( vPt, vPol, vTr)) { + if ( ! MakeByEC2( vPt, vTr) && + ! MakeByEC3( vPt, vTr)) { LOG_ERROR( GetEGkLogger(), "Error in MakeByEC23(N)") return MakeByEC_HPP( vPL, bCCW, vPt, vTr) ; } @@ -330,16 +315,22 @@ Triangulate::MakeByEC_HPP( const POLYLINEVECTOR& vPL, bool bCCW, PNTVECTOR& vPt, // Ear Clipping algorithm //---------------------------------------------------------------------------- bool -Triangulate::MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) +Triangulate::MakeByEC( const PNTVECTOR& vPt, INTVECTOR& vTr) { // Clear triangle vector vTr.clear() ; // At least 3 points - int n = int( vPol.size()) ; + int n = int( vPt.size()) ; if ( n < 3) return false ; + // Creo il vettore degli indici del Poligono + INTVECTOR vPol ; + vPol.reserve( n) ; + for ( int i = 0 ; i < n ; ++ i) + vPol.push_back( i) ; + // Preallocate triangle vector ( #triangles = n - 2) vTr.reserve( 3 * ( n - 2)) ; @@ -402,16 +393,22 @@ Triangulate::MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& v // Ear Clipping algorithm enhanced, choose smaller diagonal //---------------------------------------------------------------------------- bool -Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) +Triangulate::MakeByEC2( const PNTVECTOR& vPt, INTVECTOR& vTr) { // Clear triangle vector vTr.clear() ; // At least 3 points - int n = int( vPol.size()) ; + int n = int( vPt.size()) ; if ( n < 3) return false ; + // Creo il vettore degli indici del Poligono + INTVECTOR vPol ; + vPol.reserve( n) ; + for ( int i = 0 ; i < n ; ++ i) + vPol.push_back( i) ; + // Preallocate triangle vector ( #triangles = n - 2) vTr.reserve( 3 * ( n - 2)) ; @@ -523,16 +520,22 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& // AR = ( Lmax * Lmax) / ( 2 * Area) = SqLenMax / L1 * L2 //---------------------------------------------------------------------------- bool -Triangulate::MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) +Triangulate::MakeByEC3( const PNTVECTOR& vPt, INTVECTOR& vTr) { // Clear triangle vector vTr.clear() ; // At least 3 points - int n = int( vPol.size()) ; + int n = int( vPt.size()) ; if ( n < 3) return false ; + // Creo il vettore degli indici del Poligono + INTVECTOR vPol ; + vPol.reserve( n) ; + for ( int i = 0 ; i < n ; ++ i) + vPol.push_back( i) ; + // Preallocate triangle vector ( #triangles = n - 2) vTr.reserve( 3 * ( n - 2)) ; @@ -959,7 +962,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n double dCoeff = ( ptP.y - vPt[i].y) / ( vPt[j].y - vPt[i].y) ; double dX = vPt[i].x + ( vPt[j].x - vPt[i].x) * dCoeff ; // se sta sul raggio e distanza minore della minima - if ( dX > ptP.x - 5 * EPS_SMALL && ( dX - ptP.x) < dMinDist) { + if ( dX > ptP.x - EPS_SMALL && ( dX - ptP.x) < dMinDist) { dMinDist = dX - ptP.x ; nI = ( vPt[i].x >= vPt[j].x) ? i : j ; double dZ = vPt[i].z + ( vPt[j].z - vPt[i].z) * dCoeff ; @@ -990,7 +993,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n double dCoeff = ( ptP.z - vPt[i].z) / ( vPt[j].z - vPt[i].z) ; double dY = vPt[i].y + ( vPt[j].y - vPt[i].y) * dCoeff ; // se sta sul raggio e distanza minore della minima - if ( dY > ptP.y - 5 * EPS_SMALL && ( dY - ptP.y) < dMinDist) { + if ( dY > ptP.y - EPS_SMALL && ( dY - ptP.y) < dMinDist) { dMinDist = dY - ptP.y ; nI = ( vPt[i].y >= vPt[j].y) ? i : j ; double dX = vPt[i].x + ( vPt[j].x - vPt[i].x) * dCoeff ; @@ -1021,7 +1024,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n double dCoeff = ( ptP.x - vPt[i].x) / ( vPt[j].x - vPt[i].x) ; double dZ = vPt[i].z + ( vPt[j].z - vPt[i].z) * dCoeff ; // se sta sul raggio e distanza minore della minima - if ( dZ > ptP.z - 5 * EPS_SMALL && ( dZ - ptP.z) < dMinDist) { + if ( dZ > ptP.z - EPS_SMALL && ( dZ - ptP.z) < dMinDist) { dMinDist = dZ - ptP.z ; nI = ( vPt[i].z >= vPt[j].z) ? i : j ; double dY = vPt[i].y + ( vPt[j].y - vPt[i].y) * dCoeff ; diff --git a/Triangulate.h b/Triangulate.h index ec16b8c..ac19507 100644 --- a/Triangulate.h +++ b/Triangulate.h @@ -26,9 +26,9 @@ class Triangulate private : bool MakeByEC_HPP( const PolyLine& PL, bool bCCW, PNTVECTOR& vPt, INTVECTOR& vTr) ; bool MakeByEC_HPP( const POLYLINEVECTOR& vPL, bool bCCW, PNTVECTOR& vPt, INTVECTOR& vTr) ; - bool MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; - bool MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; - bool MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; + bool MakeByEC( const PNTVECTOR& vPt, INTVECTOR& vTr) ; + bool MakeByEC2( const PNTVECTOR& vPt, INTVECTOR& vTr) ; + bool MakeByEC3( const PNTVECTOR& vPt, INTVECTOR& vTr) ; bool PrepareGrid( const PNTVECTOR& vPt, const INTVECTOR& vPol, const INTVECTOR& vPrev, const INTVECTOR& vNext) ; bool TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,