From bd80f16812b79ff614fdc1f4e2dbf514e1ff54ea Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Thu, 15 Dec 2022 16:24:58 +0100 Subject: [PATCH] EgtGeomKernel : - Modifica Medial Axis. --- MedialAxis.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MedialAxis.cpp b/MedialAxis.cpp index 55141ac..911bd80 100644 --- a/MedialAxis.cpp +++ b/MedialAxis.cpp @@ -23,6 +23,11 @@ #include "/EgtDev/Include/EGkIntersCurves.h" #include "/EgtDev/Include/EGkMedialAxis.h" + + +#include + + using namespace std ; //---------------------------------------------------------------------------- @@ -30,6 +35,7 @@ static bool ProcessCircleCurve( const Point3d& ptCen, double dDiam, const CurveComposite& crvCompo, PNTVECTOR& vPnt, DBLVECTOR& vDiam) { + // pulizia risultati vPnt.clear() ; vDiam.clear() ; @@ -42,8 +48,13 @@ ProcessCircleCurve( const Point3d& ptCen, double dDiam, const CurveComposite& cr if ( ! LnCmpInt.GetCurveClassification( 0, 10 * EPS_SMALL, ccClass)) return false ; int nCount = int( ccClass.size()) ; + + // ... per evitare percorsi di ritorno + int nInparts = 0 ; + for ( int i = 0 ; i < nCount ; ++ i) { if ( ccClass[i].nClass == CRVC_IN) { + nInparts ++ ; // gestione unione intervallo a cavallo del parametro 0==1 if ( i == nCount - 1 && ccClass[0].nClass == CRVC_IN && ccClass[0].dParS < EPS_ZERO && ccClass[i].dParE > 1 - EPS_ZERO) { double dPar = ( ccClass[i].dParS + 1 + ccClass[0].dParE) / 2 ; @@ -54,6 +65,7 @@ ProcessCircleCurve( const Point3d& ptCen, double dDiam, const CurveComposite& cr vPnt[0] = ptP ; double dDelta = ccClass[i].dParE - ccClass[i].dParS + ccClass[0].dParE - ccClass[0].dParS ; vDiam[0] = PIGRECO * dDiam * dDelta ; + nInparts-- ; } // altrimenti caso standard else { @@ -66,6 +78,10 @@ ProcessCircleCurve( const Point3d& ptCen, double dDiam, const CurveComposite& cr } } } + + if ( nInparts == 1) + vPnt.clear() ; + return true ; } @@ -135,6 +151,7 @@ CurveSimpleMedialAxis( const ICurve* pCrv, PolyLine& PL) Point3d ptP2 = ptP1 + 1.2 * b3Compo.GetDimX() * X_AX ; crvLine.Set( ptP1, ptP2) ; } + IntersCurveCurve LnCmpInt( crvLine, crvCompo) ; if ( LnCmpInt.GetCrossIntersCount() < 2) return false ; @@ -152,6 +169,7 @@ CurveSimpleMedialAxis( const ICurve* pCrv, PolyLine& PL) double dDiam = dDiamOrig ; Vector3d vtDir = vtDirOrig ; int i = 0 ; + while ( i < 1000) { PNTVECTOR vPnt ; DBLVECTOR vDiam ; @@ -180,6 +198,7 @@ CurveSimpleMedialAxis( const ICurve* pCrv, PolyLine& PL) PL.AddUPoint( 0, GetToGlob( ptStart, frLoc)) ; ++ i ; } + // movimento lungo l'altro ramo ptStart = ptOrig ; dDiam = dDiamOrig ;