diff --git a/OffsetCurve3d.cpp b/OffsetCurve3d.cpp index 495d92d..52dde76 100644 --- a/OffsetCurve3d.cpp +++ b/OffsetCurve3d.cpp @@ -429,7 +429,7 @@ AdjustConcavePartsInPath( const ICurveComposite* pCrv, vOffsetSeg& vOffsetCrvs, // controllo l'end di ogni linea per verificare se sta nel cilindro definito da uno degli altri tratti // controllo tutto i punti bool bErasedSomePart = false ; - bool bErasedPrev = false ; + bool bCheckStart = false ; INTVECTOR vInters ; for ( int j = 0 ; j < ssize( vLines) ; ++j) { Point3d ptStart, ptEnd ; @@ -439,15 +439,20 @@ AdjustConcavePartsInPath( const ICurveComposite* pCrv, vOffsetSeg& vOffsetCrvs, pSubCrv->GetEndPoint( ptEnd) ; pSubCrv->GetStartPoint( ptStart) ; // se stanno in uno dei cilindri degli altri tratti della zona concava - for ( int k = 0 ; k < ssize( vLines) ; ++k) { + bool bToErase = false ; + for ( int k = 0 ; k < ssize( vCyl) ; ++k) { if ( j == k) continue ; - bool bToErase = IsPointInsideCylinder( ptEnd, vCyl[k], dLinTol) ; - if ( bErasedPrev && ! bToErase) - bToErase = bToErase || IsPointInsideCylinder( ptStart, vCyl[k], dLinTol) ; + bToErase = IsPointInsideCylinder( ptEnd, vCyl[k], dLinTol) ; + bool bStartInsideCyl = false ; + if ( bCheckStart && ! bToErase) { + bStartInsideCyl = IsPointInsideCylinder( ptStart, vCyl[k], dLinTol) ; + bToErase = bToErase || bStartInsideCyl ; + } if ( bToErase) { bErasedSomePart = true ; - bErasedPrev = true ; + if ( ! bStartInsideCyl) + bCheckStart = true ; // se avevo un'interruzione nella zona da modificare, la colmo if ( ! vInters.empty() && vInters.back() != vLines[j-1]) { // aggiungo tutti i precedenti che mancano @@ -455,14 +460,15 @@ AdjustConcavePartsInPath( const ICurveComposite* pCrv, vOffsetSeg& vOffsetCrvs, vInters.push_back( h) ; } vInters.push_back( vLines[j]) ; - if ( j < ssize( vLines) - 1) + if ( ! bStartInsideCyl && j < ssize( vLines) - 1) { vInters.push_back( vLines[j+1]) ; - ++j ; + ++j ; + } break ; } - else - bErasedPrev = false ; } + if ( ! bToErase) + bCheckStart = false ; } if ( bErasedSomePart) { // calcolo le intersezioni effettive del primo e ultimo tratto cancellati con i cilindri che li hanno cancellati