diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index df151c7..a8e228d 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -547,7 +547,8 @@ ExeSpiralizeCurveAlongGuide( int nCrvId, int nGuideId, double dLinTol) vtNext.Normalize() ; vSharpCorner1[i] = ( vtPrev * vtNext < CORNER_COS) ; } - vSharpCorner1.back() = vSharpCorner1.front() ; + if ( bOk) + vSharpCorner1.back() = vSharpCorner1.front() ; for ( int i = 0 ; i < nTotP2 - 1 ; i ++) { if ( i == 0 && ! PL2.IsClosed()) @@ -560,7 +561,8 @@ ExeSpiralizeCurveAlongGuide( int nCrvId, int nGuideId, double dLinTol) vtNext.Normalize() ; vSharpCorner2[i] = ( vtPrev * vtNext < CORNER_COS) ; } - vSharpCorner2.back() = vSharpCorner2.front() ; + if ( bOk) + vSharpCorner2.back() = vSharpCorner2.front() ; // se spigolo non associato ad altro spigolo, verifico se esiste un possibile spigolo da associare for ( int i = 0 ; i < nTotP1 ; i ++) { @@ -572,12 +574,17 @@ ExeSpiralizeCurveAlongGuide( int nCrvId, int nGuideId, double dLinTol) int nNextJ = vPnt1[nNextI].second ; int nStart = ( vSharpCorner2[nPrevJ] ? nPrevJ + 1 : nPrevJ) ; int nEnd = ( vSharpCorner2[nNextJ] ? nNextJ - 1 : nNextJ) ; - double dMinDist = INFINITO ; + double dSqMinDist = INFINITO ; int nCorner = vPnt1[i].second ; // cerco lo spigolo più vicino nel range fissato - for ( int j = nStart ; j <= nEnd ; j ++) { - if ( vSharpCorner2[j] && Dist( vPnt1[i].first, vPnt2[j].first) < dMinDist) - nCorner = j ; + for ( int j = nStart ; j <= nEnd ; j ++) { + if ( vSharpCorner2[j]) { + double dSqDist = SqDist( vPnt1[i].first, vPnt2[j].first) ; + if ( dSqDist < dSqMinDist) { + dSqMinDist = dSqDist ; + nCorner = j ; + } + } } vPnt1[i].second = nCorner ; } @@ -1005,7 +1012,7 @@ MyTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int& nCo // calcolo la classificazione della curva rispetto alla regione CRVCVECTOR ccClass ; if ( ! pSFR->GetCurveClassification( *CrvLoc, EPS_SMALL, ccClass)) - return GDB_ID_NULL ; + return GDB_ID_NULL ; // determino gli intervalli di curva da conservare Intervals inOk( 100 * EPS_PARAM) ; for ( auto& ccOne : ccClass) {