From 70f2f1cb012cee785cfc348bd697384e53e77178 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 16 Nov 2023 18:53:41 +0100 Subject: [PATCH] EgtGeomKernel 2.5k3 : - migliorie alla funzione ProjectCurveOnSurfTm. --- EgtGeomKernel.rc | Bin 11718 -> 11718 bytes ProjectCurveSurfTm.cpp | 66 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index cc04e893e4184254860393da7e93e3d75e2df638..0aa6c485005f3f2b61640aea89d9cd8e1ea7daa1 100644 GIT binary patch delta 260 zcmX>WeJpyzI%aKGhCGIJh8%`WhGK>c1_cHUhESkLCPN8BDnkm89}HwAf_cT0FKS6| z{=m$^%xJv%Hs5)s$u(R$lRrqRF&aWeJpyzI%aiGhCGIJh8%`ehGHOAV9;O)W+-7u1ma8}FBB-731Uyas3kpFPd#gM z9Lqc=Mx)L5`OY&hX`jGK#;zcG^Fwu6)J>CBt_NlipBAM6KDupe@OZchZce6ybVG-gbx%@?)4G64W1 CWk|>X diff --git a/ProjectCurveSurfTm.cpp b/ProjectCurveSurfTm.cpp index 8eed4df..b61f079 100644 --- a/ProjectCurveSurfTm.cpp +++ b/ProjectCurveSurfTm.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2023-2023 //---------------------------------------------------------------------------- -// File : ProjectCurveSurfTm.cpp Data : 31.08.23 Versione : 2.5h3 +// File : ProjectCurveSurfTm.cpp Data : 16.11.23 Versione : 2.5kh3 // Contenuto : Implementazione funzioni proiezione curve su superficie Trimesh. // // @@ -13,10 +13,23 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" +#include "DistPointLine.h" #include "GeoConst.h" #include "/EgtDev/Include/EGkIntersLineSurfTm.h" #include "/EgtDev/Include/EGkProjectCurveSurfTm.h" +//---------------------------------------------------------------------------- +static bool +PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol) +{ + for ( int i = nPrec + 1 ; i < nCurr ; ++ i) { + double dSqDist ; + if ( ! DistPointLine( vPt5ax[i].ptP, vPt5ax[nPrec].ptP, vPt5ax[nNext].ptP).GetSqDist( dSqDist) || dSqDist > dSqTol) + return false ; + } + return true ; +} + //---------------------------------------------------------------------------- bool ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vector3d& vtDir, double dLinTol, @@ -26,7 +39,7 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vec PolyLine PL ; if ( ! crCrv.ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) return false ; - const double MAX_SEG_LEN = 10 ; + const double MAX_SEG_LEN = 1 ; if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN)) return false ; @@ -36,8 +49,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vec return false ; IntersParLinesSurfTm intPLSTM( frRefLine, tmSurf) ; - // Riservo spazio nel vettore risultato - vPt5ax.reserve( PL.GetPointNbr()) ; + // Vettore locale dei punti risultanti + PNT5AXVECTOR vMyPt5ax ; + vMyPt5ax.reserve( PL.GetPointNbr()) ; // proietto i punti della polilinea sulla superficie double dU ; @@ -57,10 +71,52 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vec Triangle3d trTria ; if ( ! tmSurf.GetTriangle( vIntRes[nI].nT, trTria)) return false ; - vPt5ax.emplace_back( ptInt, trTria.GetN(), dU, 1) ; + vMyPt5ax.emplace_back( ptInt, trTria.GetN(), dU, 1) ; } bFound = PL.GetNextUPoint( &dU, &ptP) ; } + // rimuovo i punti allineati entro la tolleranza + double dSqTol = dLinTol * dLinTol ; + int nPrec = 0 ; + int nCurr = 1 ; + int nNext = 2 ; + while ( nNext < int( vMyPt5ax.size())) { + bool bRemove = false ; + // distanza del punto corrente dal segmento che unisce gli adiacenti + DistPointLine dPL( vMyPt5ax[nCurr].ptP, vMyPt5ax[nPrec].ptP, vMyPt5ax[nNext].ptP) ; + double dSqDist ; + // se distanza inferiore a tolleranza lineare + if ( dPL.GetSqDist( dSqDist) && dSqDist < dSqTol && PointsInTolerance( vMyPt5ax, nPrec, nCurr, nNext, dSqTol)) { + // verifico se errore angolare inferiore a limite + double dPar ; dPL.GetParamAtMinDistPoint( dPar) ; + Vector3d vtNew = Media( vMyPt5ax[nPrec].vtDir, vMyPt5ax[nNext].vtDir, dPar) ; + if ( vtNew.Normalize() && vtNew * vMyPt5ax[nCurr].vtDir > cos( 2 * DEGTORAD)) + bRemove = true ; + } + // se da eliminare + if ( bRemove) { + // dichiaro da eliminare il punto + vMyPt5ax[nCurr].nFlag = -1 ; + // avanzo con corrente e successivo + nCurr = nNext ; + ++ nNext ; + } + // altrimenti da tenere + else { + // avanzo il terzetto di uno step + nPrec = nCurr ; + nCurr = nNext ; + ++ nNext ; + } + } + + // copio i punti rimasti nel vettore di ritorno + vPt5ax.clear() ; + for ( const auto& Pt5ax : vMyPt5ax) { + if ( Pt5ax.nFlag != -1) + vPt5ax.emplace_back( Pt5ax) ; + } + return true ; }