From 4ae630e94a0c6d3da429f01f89f8c56cc9ccfb3b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 22 Jan 2020 07:37:40 +0000 Subject: [PATCH] EgtExecutor : - piccola miglioria nella gestione dei pezzi piani per nesting. --- EXE_NstCreateFlatParts.cpp | 75 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index f8d1734..2fb9644 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -1006,6 +1006,25 @@ ExeAdjustFlatPart( int nPartId) return true ; } +//---------------------------------------------------------------------------- +static bool +MyCreateCurveCompoByReorder( IGeomDB* pGeomDB, int nLayerId, const INTVECTOR& vCrvIds) +{ + int nCount = 0 ; + int nFirstId = ExeCreateCurveCompoByReorder( nLayerId, vCrvIds, ORIG, false, RTY_GLOB, &nCount) ; + for ( int i = 0 ; i < nCount ; ++ i) { + int nCurrId = nFirstId + i ; + INTVECTOR vOrigId ; + pGeomDB->GetInfo( nCurrId, CRV_ORIG, vOrigId) ; + for ( int j = 0 ; j < int( vOrigId.size()) ; ++ j) { + if ( j == 0) + pGeomDB->CopyAttributes( vOrigId[j], nCurrId) ; + pGeomDB->Erase( vOrigId[j]) ; + } + } + return ( nCount > 0) ; +} + //---------------------------------------------------------------------------- bool ExeAdjustFlatPartLayer( int nLayerId) @@ -1034,9 +1053,9 @@ ExeAdjustFlatPartLayer( int nLayerId) // Se curva composita if ( pGeomDB->GetGeoType( nId) == CRV_COMPO) { // Compatto - bOk = ExeMergeCurvesInCurveCompo( nId, 10 * EPS_SMALL, true) ; + bOk = ExeMergeCurvesInCurveCompo( nId, 10 * EPS_SMALL, true) && bOk ; // Esplodo in curve semplici - bOk = bOk && ExeExplodeCurveCompo( nId, nullptr) ; + bOk = ExeExplodeCurveCompo( nId, nullptr) && bOk ; } // Passo all'entitą successiva nId = nNextId ; @@ -1056,44 +1075,32 @@ ExeAdjustFlatPartLayer( int nLayerId) } nId = pGeomDB->GetNext( nId) ; } - if ( bOk && vAccwIds.size() > 1) { - int nCount = 0 ; - int nFirstId = ExeCreateCurveCompoByReorder( nLayerId, vAccwIds, ORIG, false, RTY_GLOB, &nCount) ; - for ( int i = 0 ; i < nCount ; ++ i) { - int nCurrId = nFirstId + i ; - INTVECTOR vOrigId ; - pGeomDB->GetInfo( nCurrId, CRV_ORIG, vOrigId) ; - for ( int j = 0 ; j < int( vOrigId.size()) ; ++ j) { - if ( j == 0) - pGeomDB->CopyAttributes( vOrigId[j], nCurrId) ; - pGeomDB->Erase( vOrigId[j]) ; - } - } - bOk = bOk && ( nCount > 0) ; - } - if ( bOk && vAcwIds.size() > 1) { - int nCount = 0 ; - int nFirstId = ExeCreateCurveCompoByReorder( nLayerId, vAcwIds, ORIG, false, RTY_GLOB, &nCount) ; - for ( int i = 0 ; i < nCount ; ++ i) { - int nCurrId = nFirstId + i ; - INTVECTOR vOrigId ; - pGeomDB->GetInfo( nCurrId, CRV_ORIG, vOrigId) ; - for ( int j = 0 ; j < int( vOrigId.size()) ; ++ j) { - if ( j == 0) - pGeomDB->CopyAttributes( vOrigId[j], nCurrId) ; - pGeomDB->Erase( vOrigId[j]) ; - } - } - bOk = bOk && ( nCount > 0) ; - } - // spezzo le curve composite con discontinuitą + if ( vAccwIds.size() > 1) + bOk = MyCreateCurveCompoByReorder( pGeomDB, nLayerId, vAccwIds) && bOk ; + if ( vAcwIds.size() > 1) + bOk = MyCreateCurveCompoByReorder( pGeomDB, nLayerId, vAcwIds) && bOk ; + // Spezzo le curve composite con discontinuitą nId = pGeomDB->GetFirstInGroup( nLayerId) ; while ( nId != GDB_ID_NULL && bOk) { // Recupero successiva int nNextId = pGeomDB->GetNext( nId) ; // Se curva composita if ( pGeomDB->GetGeoType( nId) == CRV_COMPO) { - bOk = ( ExeSplitCurveAtCorners( nId, 5.0, nullptr) != GDB_ID_NULL) ; + bOk = ( ExeSplitCurveAtCorners( nId, 5.0, nullptr) != GDB_ID_NULL) && bOk ; + } + // Passo all'entitą successiva + nId = nNextId ; + } + // Riconduco a curva semplice le composite formate da una sola curva semplice + nId = pGeomDB->GetFirstInGroup( nLayerId) ; + while ( nId != GDB_ID_NULL && bOk) { + // Recupero successiva + int nNextId = pGeomDB->GetNext( nId) ; + // Se curva composita formata da una sola curva semplice + if ( pGeomDB->GetGeoType( nId) == CRV_COMPO) { + const ICurveComposite* pCrvCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; + if ( pCrvCompo->GetCurveCount() == 1) + bOk = ExeExplodeCurveCompo( nId, nullptr) && bOk ; } // Passo all'entitą successiva nId = nNextId ;