From fda3f6aa198cbdbe2d139b5fa042a9e7cc1501e5 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 21 Sep 2015 08:34:50 +0000 Subject: [PATCH] EgtExecutor : - modifiche su nesting di cluster per pezzi in grezzo. --- EXE_Nesting.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/EXE_Nesting.cpp b/EXE_Nesting.cpp index ef6596e..33a64a5 100644 --- a/EXE_Nesting.cpp +++ b/EXE_Nesting.cpp @@ -633,9 +633,12 @@ ExePackCluster( const INTVECTOR& vIds, double dXmin, double dYmin, double dXmax, b3Cluster.Expand( dOffs - 2 * EPS_SMALL, dOffs - 2 * EPS_SMALL, 0) ; // Box della regione di interesse BBox3d b3Region( dXmin, dYmin, 0, dXmax, dYmax, 0) ; + // Verifico se pezzi sotto la radice o pezzi in altro gruppo + int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ; + bool bInRoot = ( nGroupId == GDB_ID_ROOT) ; // Determino il box di tutti gli altri pezzi compresi nella regione di interesse BOXVECTOR vBox ; - int nId2 = ExeGetFirstPart( true) ; + int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { BBox3d b3Part2 ; @@ -643,7 +646,7 @@ ExePackCluster( const INTVECTOR& vIds, double dXmin, double dYmin, double dXmax, b3Region.OverlapsXY( b3Part2)) vBox.emplace_back( b3Part2) ; } - nId2 = ExeGetNextPart( nId2, true) ; + nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; } // Ordino i box dei pezzi secondo la X crescente sort( vBox.begin(), vBox.end(), []( const BBox3d& a, const BBox3d& b) @@ -867,9 +870,12 @@ ExeMoveCluster( const INTVECTOR& vIds, Vector3d& vtMove, if ( vTrueIds.empty()) return true ; + // Verifico se pezzi sotto la radice o pezzi in altro gruppo + int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ; + bool bInRoot = ( nGroupId == GDB_ID_ROOT) ; // Determino i box di tutti gli altri pezzi compresi nella regione di interesse BOXVECTOR vBox ; - int nId2 = ExeGetFirstPart( true) ; + int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { BBox3d b3Part2 ; @@ -877,7 +883,7 @@ ExeMoveCluster( const INTVECTOR& vIds, Vector3d& vtMove, b3Region.OverlapsXY( b3Part2)) vBox.emplace_back( b3Part2) ; } - nId2 = ExeGetNextPart( nId2, true) ; + nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; } // Ordino questi box in senso contrario al movimento if ( fabs( vtMoveXY.x) >= fabs( vtMoveXY.y)) {