diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 6d686da..1db4a5a 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -539,8 +539,20 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp) double dRegClDimX = b3RegCluster.GetMax().x - b3RegCluster.GetMin().x ; double dRegClDimY = b3RegCluster.GetMax().y - b3RegCluster.GetMin().y ; + // Determino lo step per i tentativi di inserimento + const double STEP_STD = 50 ; + double dStepX = STEP_STD ; + double dStepY = STEP_STD ; + double dBoxDimX = b3Box.GetMax().x - b3Box.GetMin().x ; + double dRegCluDimX = b3RegCluster.GetMax().x - b3RegCluster.GetMin().x ; + if ( dBoxDimX - dRegCluDimX < 5 * STEP_STD) + dStepX = STEP_STD / 5 ; + double dBoxDimY = b3Box.GetMax().y - b3Box.GetMin().y ; + double dRegCluDimY = b3RegCluster.GetMax().y - b3RegCluster.GetMin().y ; + if ( dBoxDimY - dRegCluDimY < 5 * STEP_STD) + dStepY = STEP_STD / 5 ; + // Procedo per tentativi - const double STEP = 50 ; bool bFit = false ; Point3d ptOrig = b3RegCluster.GetMin() ; Point3d ptLineStart = ( bBottomUp ? b3Box.GetMin() : b3Box.GetMax() - Vector3d(0, -dRegClDimY, 0)) ; @@ -559,10 +571,10 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp) break ; } // nuova posizione di inserimento (incrementando X) - ptIns += Vector3d( STEP, 0, 0) ; + ptIns += Vector3d( dStepX, 0, 0) ; // se esco dal box torno all'inizio e incremento Y if ( ! b3Box.EnclosesXY( ptIns + Vector3d( dRegClDimX, 0, 0))) { - ptLineStart += Vector3d( 0, ( bBottomUp ? STEP : - STEP), 0) ; + ptLineStart += Vector3d( 0, ( bBottomUp ? dStepY : - dStepY), 0) ; if ( ( ! b3Box.EnclosesXY( ptLineStart + Vector3d( 0, dRegClDimY, 0)))) break ; ptIns = ptLineStart ;