From 583e30170a75f9fb78ed28214b7eb48a3eae7fd5 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 12 Apr 2024 15:27:52 +0200 Subject: [PATCH] EgtGeomKernel : - ricalcolo delle facce dopo scalatura per TriMesh - Rimozione punti allineati nei contatti tra facce diverse. --- SurfTriMesh.cpp | 8 ++------ SurfTriMeshUtilities.cpp | 32 +++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index c2d741c..3699847 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -3244,7 +3244,6 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double bMirror = ( bMirror ? ( dCoeffZ > 0) : ( dCoeffZ < 0)) ; // aggiorno le facce - bool bRecalc = ( abs( dCoeffX) < EPS_ZERO || abs( dCoeffY) < EPS_ZERO || abs( dCoeffZ) < EPS_ZERO) ; for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { if ( m_vTria[i].nIdVert[0] != SVT_DEL) { // se c'è mirror, devo invertire la faccia @@ -3254,15 +3253,12 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double if ( ! CalcTriangleNormal( i)) { // elimino il triangolo RemoveTriangle( i) ; - // richiedo ricalcolo vertici e topologia - bRecalc = true ; } } } - if ( bRecalc) - return DoCompacting() ; - return true ; + return DoCompacting() ; + } //---------------------------------------------------------------------------- diff --git a/SurfTriMeshUtilities.cpp b/SurfTriMeshUtilities.cpp index 99999fb..41427ef 100644 --- a/SurfTriMeshUtilities.cpp +++ b/SurfTriMeshUtilities.cpp @@ -313,15 +313,41 @@ AdjustLoop( PNTULIST& PointList, double dMaxEdgeLen, bool& bModif) { // Ciclo sui punti del loop auto itLast = PointList.begin() ; + vector VT ; for ( auto it = next( itLast) ; it != PointList.end() ; ++ it) { // Se dal punto corrente inizia un segmento adiacente a un'altra faccia if ( itLast->second != it->second) { - // Elimino i punti interni + // Elimino i punti interni allineati auto itNextToLast = next( itLast) ; + PolyLine PL ; + int nPar = 0 ; + PL.AddUPoint( nPar, itLast->first) ; for ( auto itInn = itNextToLast ; itInn != it ; ) { - itInn = PointList.erase( itInn) ; - bModif = true ; + ++ nPar ; + PL.AddUPoint( nPar, itInn->first) ; + itInn = next( itInn) ; + } + PL.AddUPoint( nPar + 1, it->first) ; + // se ho almeno 3 punti riferiti alla stessa adiacenza ( quindi 2 edges ) + if ( PL.GetPointNbr() > 2) { + PL.RemoveAlignedPoints( 50 * EPS_SMALL) ; // può cambiare... + // aggiorno la lista di punti con i rimanenti + for ( auto itInn = itNextToLast ; itInn != it ; ) { + Point3d ptCurr ; + bool bFound = false ; + if ( PL.GetFirstPoint( ptCurr)) { + bFound = AreSamePointApprox( ptCurr, itInn->first) ; + while ( ! bFound && PL.GetNextPoint( ptCurr)) + bFound = AreSamePointApprox( ptCurr, itInn->first) ; + } + if ( ! bFound) { + itInn = PointList.erase( itInn) ; + bModif = true ; + } + else + itInn = next( itInn) ; + } } // Se la lunghezza del segmento supera il limite imposto double dSegLen = Dist( it->first, itLast->first) ;