From c704d948294cfa3aecdfef3d4b7de84ab7364d81 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 2 Apr 2026 15:14:29 +0200 Subject: [PATCH] EgtGeomKernel : - piccola aggiunta per la gestione di spike nelle categorizzazioni tra curve. --- IntersCrvCompoCrvCompo.cpp | 54 ++++++++++++++++++++++++++++---------- IntersCurveCurve.cpp | 24 +++++++++++++++-- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/IntersCrvCompoCrvCompo.cpp b/IntersCrvCompoCrvCompo.cpp index 6347025..5435673 100644 --- a/IntersCrvCompoCrvCompo.cpp +++ b/IntersCrvCompoCrvCompo.cpp @@ -804,9 +804,19 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, for ( int i = bCrvAClosed ? 0 : 1 ; i < m_nNumInters ; ++i) { int j = i == 0 ? m_nNumInters - 1 : i - 1 ; int kj = m_Info[j].bOverlap ? 1 : 0 ; + bool bSpike = m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq ; if ( (m_Info[j].IciA[kj].nNextTy == ICCT_NULL || m_Info[i].IciA[0].nPrevTy == ICCT_NULL || m_Info[j].IciA[kj].nNextTy != m_Info[i].IciA[0].nPrevTy) && m_Info[j].IciA[kj].nNextTy != ICCT_SPK && m_Info[i].IciA[0].nPrevTy != ICCT_SPK) { vIncoherenceWithPrev.push_back( i) ; + if ( bSpike) { + // se ho uno spike sistemo anche il successivo + int k = i == m_nNumInters - 1 ? -1 : i + 1 ; + if ( k == -1 && bCrvAClosed) + k = 0 ; + + if ( k != -1) + vIncoherenceWithPrev.push_back( k) ; + } bCoherent = false ; } } @@ -839,9 +849,19 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, int j = i == 0 ? m_nNumInters - 1 : i - 1 ; int ki = m_Info[i].bOverlap && ! m_Info[i].bCBOverEq ? 1 : 0 ; int kj = m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0 ; + bool bSpike = m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq ; if ( ( m_Info[j].IciB[kj].nNextTy == ICCT_NULL || m_Info[i].IciB[ki].nPrevTy == ICCT_NULL || m_Info[j].IciB[kj].nNextTy != m_Info[i].IciB[ki].nPrevTy) && m_Info[j].IciB[kj].nNextTy != ICCT_SPK && m_Info[i].IciB[ki].nPrevTy != ICCT_SPK) { vIncoherenceWithPrev.push_back( i) ; + if ( bSpike) { + // se ho uno spike sistemo anche il successivo + int k = i == m_nNumInters - 1 ? -1 : i + 1 ; + if ( k == -1 && bCrvBClosed) + k = 0 ; + + if ( k != -1) + vIncoherenceWithPrev.push_back( k) ; + } bCoherent = false ; } } @@ -882,13 +902,19 @@ IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICu const IntCrvCrvInfo& Icci1 = m_Info[j] ; const IntCrvCrvInfo& Icci2 = m_Info[i] ; // calcolo tra l'intersezione 1 e 2 se la curva sta dentro o fuori + int ki = 0 ; int kj = Icci1.bOverlap ? 1 : 0 ; + if ( ! bCrvAOrB) { + ki = m_Info[i].bOverlap && ! m_Info[i].bCBOverEq ? 1 : 0 ; + kj = m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0 ; + } + double dU = 0 ; bool bPrevIsBefore = true ; if ( bCrvAOrB) { // se precedente minore del successivo faccio la media - if ( Icci1.IciA[kj].dU < Icci2.IciA[0].dU) - dU = ( Icci2.IciA[0].dU + Icci1.IciA[kj].dU) / 2 ; + if ( Icci1.IciA[kj].dU < Icci2.IciA[ki].dU) + dU = ( Icci2.IciA[ki].dU + Icci1.IciA[kj].dU) / 2 ; // altrimenti guardo tra lo start e il successivo else { bPrevIsBefore = false ; @@ -904,8 +930,8 @@ IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICu } else { // se precedente minore del successivo faccio la media - if ( Icci1.IciB[kj].dU < Icci2.IciB[0].dU) - dU = ( Icci2.IciB[0].dU + Icci1.IciB[kj].dU) / 2 ; + if ( Icci1.IciB[kj].dU < Icci2.IciB[ki].dU) + dU = ( Icci2.IciB[ki].dU + Icci1.IciB[kj].dU) / 2 ; // altrimenti guardi tra lo start e il successivo else { bPrevIsBefore = false ; @@ -933,24 +959,24 @@ IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICu bool bIsOn = false ; if ( bCrvAOrB) { if ( bPrevIsBefore) { - vdU[0] = ( 1 - dFactor) * Icci2.IciA[0].dU + dFactor * Icci1.IciA[kj].dU ; - vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciA[0].dU + 2 * dFactor * Icci1.IciA[kj].dU ; + vdU[0] = ( 1 - dFactor) * Icci2.IciA[ki].dU + dFactor * Icci1.IciA[kj].dU ; + vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciA[ki].dU + 2 * dFactor * Icci1.IciA[kj].dU ; } - else if ( Icci2.IciA[0].dU > 2 * EPS_SMALL){ - vdU[0] = ( Icci2.IciA[0].dU + 0.) * dFactor ; - vdU[1] = ( Icci2.IciA[0].dU + 0.) * 2 * dFactor ; + else if ( Icci2.IciA[ki].dU > 2 * EPS_SMALL){ + vdU[0] = ( Icci2.IciA[ki].dU + 0.) * dFactor ; + vdU[1] = ( Icci2.IciA[ki].dU + 0.) * 2 * dFactor ; } else bIsOn = true ; } else { if ( bPrevIsBefore) { - vdU[0] = ( 1 - dFactor) * Icci2.IciB[0].dU + dFactor * Icci1.IciB[kj].dU ; - vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciB[0].dU + 2 * dFactor * Icci1.IciB[kj].dU ; + vdU[0] = ( 1 - dFactor) * Icci2.IciB[ki].dU + dFactor * Icci1.IciB[kj].dU ; + vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciB[ki].dU + 2 * dFactor * Icci1.IciB[kj].dU ; } - else if ( Icci2.IciB[0].dU > 2 * EPS_SMALL) { - vdU[0] = ( Icci2.IciB[0].dU + 0.) * dFactor ; - vdU[1] = ( Icci2.IciB[0].dU + 0.) * 2 * dFactor ; + else if ( Icci2.IciB[ki].dU > 2 * EPS_SMALL) { + vdU[0] = ( Icci2.IciB[ki].dU + 0.) * dFactor ; + vdU[1] = ( Icci2.IciB[ki].dU + 0.) * 2 * dFactor ; } else bIsOn = true ; diff --git a/IntersCurveCurve.cpp b/IntersCurveCurve.cpp index 8ff1d0c..62a464b 100644 --- a/IntersCurveCurve.cpp +++ b/IntersCurveCurve.cpp @@ -576,9 +576,25 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO } } // costruisco il vettore delle classificazioni - for ( int i = 0 ; i < nNumInters ; ++ i) { + for ( int i = 0 ; i < nNumInters ; ++ i) { // se รจ definito un tratto precedente double dLenU ; pCurve->GetLengthAtParam( InfoCorr[i].IciA[0].dU, dLenU) ; + /*int j = i < nNumInters - 1 ? i + 1 : -1 ; + if ( pCurve->IsClosed() && j == - 1) + j = 0 ;*/ + int j = i == 0 ? -1 : i - 1 ; + if ( pCurve->IsClosed() && j == - 1) + j = nNumInters - 1 ; + bool bSpike = false ; + if ( j != -1) { + bSpike = InfoCorr[i].bOverlap && InfoCorr[j].bOverlap && InfoCorr[i].bCBOverEq != InfoCorr[j].bCBOverEq ; + if ( bSpike) { + bSpike = abs( InfoCorr[i].IciA[0].dU - InfoCorr[j].IciA[0].dU) < EPS_PARAM || + abs( InfoCorr[i].IciA[0].dU - InfoCorr[j].IciA[1].dU) < EPS_PARAM || + abs( InfoCorr[i].IciA[1].dU - InfoCorr[j].IciA[0].dU) < EPS_PARAM || + abs( InfoCorr[i].IciA[1].dU - InfoCorr[j].IciA[1].dU) < EPS_PARAM ; + } + } if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > dLenMin) { // verifico che la definizione sul tratto sia omogenea e valida int nPrevTy = InfoCorr[i].IciA[0].nPrevTy ; @@ -610,7 +626,11 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO // salvo dati correnti dCurrPar = InfoCorr[i].IciA[1].dU ; dCurrLen = dLenU ; - nLastTy = InfoCorr[i].IciA[1].nNextTy ; + // se sono in un caso di spike devo trattare l'overlap in modo diverso + if ( ! bSpike) + nLastTy = InfoCorr[i].IciA[1].nNextTy ; + else + nLastTy = InfoCorr[i].IciA[0].nPrevTy ; } } // eventuale tratto finale rimasto