From 0030b684f3b596216230133d3de9590866334bf8 Mon Sep 17 00:00:00 2001 From: SaraP Date: Wed, 28 Dec 2022 14:18:47 +0100 Subject: [PATCH] EgtGeomKernel 2.4l4 : - nelle polylines modificato il modo in cui vengono calcolati i vertici a minima distanza - modifiche varie alle polylines. --- EgtGeomKernel.rc | Bin 11726 -> 11726 bytes PolyLine.cpp | 114 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 79 insertions(+), 35 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 1fdd45cf2663e9a27066720aecadd504951113ca..f1391bcef0678241cfaac6ebce042bdaac182203 100644 GIT binary patch delta 254 zcmX>XeJ*;#I%aiGhCGIJh8%`ehGHOAV9;O)W+-7u1ma8}FBB-731Ux{R&U)L$1;zJ z(PZ;|zVl3z6=ZZK-&0g$G?}a@th+ft%8haJByJyOu(U0Zf(m;8g@uDKgeS4!F{eWL r2P3iW+B{pem{Bkv>~K%8!*hTRPTVZ5zL6PIc=Bx3gPUh*n=kXeJ*;#I%aKGhCGIJh8%`WhGK>c1_cHUhESkLCPN8BDnkm89}HwAf_cT0Z)! 16 * dSqDistMin) - break ; } - if ( i < nTotP1 - 1 && dSqDistMin < EPS_SMALL) + int nMinJ = ( int)( dMinDistPar + 0.5) ; + + // eventuale correzione per i primi punti ( da forzare nel vertice 0) + if ( nLastJ == 0 && nFirstMinJ > 0.5 * nTotP2 && nMinJ >= nFirstMinJ) + nMinJ = 0 ; + + if ( nMinJ < nLastJ) + nMinJ = nLastJ ; + + // verifica se è un punto interno in comune con l'altra polyline + if ( i < nTotP1 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL) bCommonInternalPoints = true ; - vPnt1[i].second = MinJ ; - LastJ = MinJ ; + + vPnt1[i].second = nMinJ ; + nLastJ = nMinJ ; } - + // calcoli per seconda curva - int LastI = 0 ; + int nLastI = 0 ; vPnt2[0].second = 0 ; + + DistPointPolyLine( vPnt2[0].first, PL1, dFirstDist, dFirstParMinDist) ; + int nFirstMinI = ( int)( dFirstParMinDist + 0.5) ; + for ( int j = 1 ; j < nTotP2 ; ++ j) { - double dSqDistMin = SqDist( vPnt2[j].first, vPnt1[LastI].first) ; - double dApprDistMin = ApproxDist( vPnt2[j].first, vPnt1[LastI].first) ; - int MinI = LastI ; - for ( int i = LastI + 1 ; i < nTotP1 ; ++ i) { - double dSqDist = SqDist( vPnt2[j].first, vPnt1[i].first) ; - if ( dSqDist < dSqDistMin - 2 * dApprDistMin * EPS_SMALL) { - dSqDistMin = dSqDist ; - dApprDistMin = ApproxDist( vPnt2[j].first, vPnt1[i].first) ; - MinI = i ; + + double dDist = INFINITO ; + double dMinDistPar = nLastI ; + for ( int i = max( nLastI, 1) ; i < nTotP1 ; ++ i) { + // distanza del punto dal segmento della polilinea + DistPointLine PointLineDistCalc( vPnt2[j].first, vPnt1[i-1].first, vPnt1[i].first) ; + double dPlDist ; + PointLineDistCalc.GetDist( dPlDist) ; + if ( dPlDist < dDist) { + dDist = dPlDist ; + PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ; + dMinDistPar += i - 1 ; } - else if ( dSqDist > 16 * dSqDistMin) - break ; } - if ( j < nTotP2 - 1 && dSqDistMin < EPS_SMALL) + int nMinI = ( int)( dMinDistPar + 0.5) ; + + // eventuale correzione per primi punti + if ( nLastI == 0 && nFirstMinI > 0.5 * nTotP1 && nMinI >= nFirstMinI) + nMinI = 0 ; + + if ( nMinI < nLastI) + nMinI = nLastI ; + + if ( j < nTotP2 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL) bCommonInternalPoints = true ; - vPnt2[j].second = MinI ; - LastI = MinI ; + + vPnt2[j].second = nMinI ; + nLastI = nMinI ; } return true ;