diff --git a/CalcPocketing.cpp b/CalcPocketing.cpp index cb9e8f5..93bece0 100644 --- a/CalcPocketing.cpp +++ b/CalcPocketing.cpp @@ -6236,9 +6236,6 @@ AddEpicycles( const PocketParams& PockParam, ICurveComposite* pCompo, ICurveComp if ( pCompo == nullptr || ! pCompo->IsValid()) return false ; - if ( PockParam.bInvert) - pCompo->Invert() ; // oriento la curva in senso antiorario - // calcolo l'Offset definito dal valore dell'raggio dell'epiciclo OffsetCurve OffsCrv ; if ( ! OffsCrv.Make( pCompo, PockParam.dEpicyclesRad, ICurve::OFF_FILLET) || OffsCrv.GetCurveCount() > 1) @@ -6544,7 +6541,7 @@ CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, co } // se non ho Chunks e devo usare un Offset più piccolo... else if ( ! bSmallRad) { - if ( PockParams.dRad < EPS_SMALL) + if ( PockParams.dRad < EPS_SMALL || PockParams.bPolishing) break ; dOffs = dOffsPrec + ( nIter == 0 ? PockParams.dRad + PockParams.dRadialOffset : PockParams.dRad) ; } diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index b702c2f..b529de0 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/IntersCrvCompoCrvCompo.cpp b/IntersCrvCompoCrvCompo.cpp index 5435673..157ef3c 100644 --- a/IntersCrvCompoCrvCompo.cpp +++ b/IntersCrvCompoCrvCompo.cpp @@ -802,12 +802,19 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, INTVECTOR vNewOverlap ; // salvo eventuali incoerenze col precedente 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 ; + 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 ( bSpike) { + bSpike = abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM || + abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[1].dU) < EPS_PARAM || + abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[0].dU) < EPS_PARAM || + abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ; + } 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 ( vIncoherenceWithPrev.empty() || vIncoherenceWithPrev.back() != i) + vIncoherenceWithPrev.push_back( i) ; if ( bSpike) { // se ho uno spike sistemo anche il successivo int k = i == m_nNumInters - 1 ? -1 : i + 1 ; @@ -823,8 +830,8 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, // incoerenze sulla curva A if ( ! bCoherent) { for ( int i : vIncoherenceWithPrev) { - int j = i == 0 ? m_nNumInters - 1 : i - 1 ; - int kj = m_Info[j].bOverlap ? 1 : 0 ; + int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ; + int kj = ( m_Info[j].bOverlap ? 1 : 0) ; int nType = 0 ; CalcSide( j, i, &CCompoA, &CCompoB, true, nType) ; if ( nType != ICCT_ON) { @@ -846,16 +853,23 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, vIncoherenceWithPrev.clear() ; // salvo eventuali incoerenze col precedente for ( int i = bCrvBClosed ? 0 : 1 ; i < m_nNumInters ; ++i) { - 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 ; + 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 ( bSpike) { + bSpike = abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM || + abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[1].dU) < EPS_PARAM || + abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[0].dU) < EPS_PARAM || + abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ; + } 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 ( vIncoherenceWithPrev.empty() || vIncoherenceWithPrev.back() != i) + vIncoherenceWithPrev.push_back( i) ; if ( bSpike) { // se ho uno spike sistemo anche il successivo - int k = i == m_nNumInters - 1 ? -1 : i + 1 ; + int k = ( i == m_nNumInters - 1 ? -1 : i + 1) ; if ( k == -1 && bCrvBClosed) k = 0 ; @@ -868,9 +882,9 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA, // incoerenze sulla curva B if ( ! bCoherent) { for ( int i : vIncoherenceWithPrev) { - 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 ; + 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) ; int nType = 0 ; CalcSide( j, i, &CCompoB, &CCompoA, false, nType) ; if ( nType != ICCT_ON) { @@ -903,10 +917,10 @@ IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICu 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 ; + 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 ; + 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 ; @@ -1045,8 +1059,11 @@ IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICu bool IntersCrvCompoCrvCompo::MergeNewOverlap( int i, bool bCrvAOrB) { + if ( i >= ssize(m_Info)) + return false ; + // faccio il merge col precedente - int j = i == 0 ? m_nNumInters - 1 : i - 1 ; + int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ; if ( m_Info[j].bOverlap) { m_Info[i].IciA[0] = m_Info[j].IciA[0] ; m_Info[i].IciB[0] = m_Info[j].IciB[0] ; @@ -1185,21 +1202,25 @@ SortGreaterB( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2) dU1 = aInfo1.IciB[0].dU ; if ( aInfo1.bOverlap) { // caso normale - if ( aInfo1.IciB[0].dU < aInfo1.IciB[1].dU) + if ( ( aInfo1.bCBOverEq && aInfo1.IciB[0].dU < aInfo1.IciB[1].dU) || ( ! aInfo1.bCBOverEq && aInfo1.IciB[0].dU > aInfo1.IciB[1].dU)) dU1 = 0.5 * ( aInfo1.IciB[0].dU + aInfo1.IciB[1].dU) ; // a cavallo di fine / inizio - else + else if ( aInfo1.bCBOverEq) dU1 = aInfo1.IciB[0].dU + SPAN_PARAM ; + else + dU1 = aInfo1.IciB[1].dU + SPAN_PARAM ; } // determino il secondo termine del confronto dU2 = aInfo2.IciB[0].dU ; if ( aInfo2.bOverlap) { // caso normale - if ( aInfo2.IciB[0].dU < aInfo2.IciB[1].dU) + if ( ( aInfo2.bCBOverEq && aInfo2.IciB[0].dU < aInfo2.IciB[1].dU) || ( ! aInfo2.bCBOverEq && aInfo2.IciB[0].dU > aInfo2.IciB[1].dU)) dU2 = 0.5 * ( aInfo2.IciB[0].dU + aInfo2.IciB[1].dU) ; // a cavallo di fine / inizio - else + else if ( aInfo2.bCBOverEq) dU2 = aInfo2.IciB[0].dU + SPAN_PARAM ; + else + dU2 = aInfo2.IciB[1].dU + SPAN_PARAM ; } return ( dU2 > dU1 + EPS_PARAM) ; diff --git a/Trimming.cpp b/Trimming.cpp index 567cf7e..098d9a9 100644 --- a/Trimming.cpp +++ b/Trimming.cpp @@ -4855,7 +4855,7 @@ GetTrimmingHoleBorders( const CISURFPVECTOR& vpSurf, const Point3d& ptRef, doubl // Scorro le curve successive for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) { // Recupero la curva corrente, se non presente allora passo alla successiva - if ( IsNull( vHoles[i].pCompoHole)) + if ( IsNull( vHoles[j].pCompoHole)) continue ; // Se il tipo è differente non possono essere in coppia if ( vHoles[i].nType != vHoles[j].nType)