diff --git a/EXE_Const.h b/EXE_Const.h new file mode 100644 index 0000000..c628fa6 --- /dev/null +++ b/EXE_Const.h @@ -0,0 +1,25 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2015 +//---------------------------------------------------------------------------- +// File : EXE.h Data : 05.05.15 Versione : 1.6e2 +// Contenuto : Dichiarazioni locali per moduli EXE. +// +// +// +// Modifiche : 01.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +//---------------------------------------------------------------------------- +// Curve originali di composite +static std::string CRV_ORIG = "ORIG" ; +// Per FlatParts (Nesting) +static std::string NST_PART_REG = "Region" ; +static std::string NST_EXT_LAYER = "OutLoop" ; +static std::string NST_IN_LAYER = "InLoop" ; +static std::string NST_ON_LAYER = "OnPath" ; diff --git a/EXE_GdbCreateCurve.cpp b/EXE_GdbCreateCurve.cpp index 674ae64..436ef53 100644 --- a/EXE_GdbCreateCurve.cpp +++ b/EXE_GdbCreateCurve.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" +#include "EXE_Const.h" #include "EXE_Macro.h" #include "AuxTools.h" #include "GeoTools.h" diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 0a53d8b..d4c95e2 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" +#include "EXE_Const.h" #include "EXE_Macro.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" @@ -340,7 +341,7 @@ VerifyAndAdjustFlatParts( void) // creo un nuovo layer in cui mettere tutti i concatenati int nRegId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ; bOk = bOk && nRegId != GDB_ID_NULL ; - bOk = bOk && pGeomDB->SetName( nRegId, "Region") ; + bOk = bOk && pGeomDB->SetName( nRegId, NST_PART_REG) ; // concateno tutte le curve INTVECTOR vIds ; vIds.push_back( GDB_ID_SEL) ; @@ -362,7 +363,7 @@ VerifyAndAdjustFlatParts( void) else if ( ! pCrv->IsClosed()) { // salvo Id di origine nell'elenco curve aperte da controllare INTVECTOR vTmpIds ; - if ( pGeomDB->GetInfo( pEnt->GetId(), "ORIG", vTmpIds)) + if ( pGeomDB->GetInfo( pEnt->GetId(), CRV_ORIG, vTmpIds)) vOpenIds.insert( vOpenIds.end(), vTmpIds.begin(), vTmpIds.end()) ; bEok = pEnt->EraseAndGoToNext() ; } @@ -372,7 +373,7 @@ VerifyAndAdjustFlatParts( void) bEok = pEnt->GoToNext() ; // salvo stringa con elenco Id di origine string sInfo ; - if ( pGeomDB->GetInfo( nEntId, "ORIG", sInfo)) { + if ( pGeomDB->GetInfo( nEntId, CRV_ORIG, sInfo)) { vClosedIds.emplace_back( sInfo) ; pCrv->SetTempProp( int( vClosedIds.size())) ; } @@ -429,7 +430,7 @@ VerifyAndAdjustFlatParts( void) if ( ! IsNull( pOutCrv)) { int nOutLoopId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ; bOk = bOk && nOutLoopId != GDB_ID_NULL ; - bOk = bOk && pGeomDB->SetName( nOutLoopId, "OutLoop") ; + bOk = bOk && pGeomDB->SetName( nOutLoopId, NST_EXT_LAYER) ; pGeomDB->AddGeoObj( GDB_ID_NULL, nOutLoopId, Release( pOutCrv)) ; } // creo nuovi layer in cui copiare gli eventuali contorni interni @@ -439,7 +440,7 @@ VerifyAndAdjustFlatParts( void) while ( ! IsNull( pInCrv)) { int nInLoopId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ; bOk = bOk && nInLoopId != GDB_ID_NULL ; - bOk = bOk && pGeomDB->SetName( nInLoopId, "InLoop") ; + bOk = bOk && pGeomDB->SetName( nInLoopId, NST_IN_LAYER) ; pGeomDB->AddGeoObj( GDB_ID_NULL, nInLoopId, Release( pInCrv)) ; ++ i ; pInCrv.Set( bOk ? pSfr->GetLoop( 0, i) : nullptr) ; @@ -450,7 +451,7 @@ VerifyAndAdjustFlatParts( void) for ( int i = 0 ; bOk && i < int( vOpenIds.size()) ; ++i) { int nOnPathId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ; bOk = bOk && nOnPathId != GDB_ID_NULL ; - bOk = bOk && pGeomDB->SetName( nOnPathId, "OnPath") ; + bOk = bOk && pGeomDB->SetName( nOnPathId, NST_ON_LAYER) ; pGeomDB->RelocateGlob( vOpenIds[i], nOnPathId) ; } } diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index bc95018..016cd40 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -14,11 +14,13 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" +#include "EXE_Const.h" #include "EXE_Macro.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkSfrCreate.h" +#include "/EgtDev/Include/EMkMachiningGeoConst.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include @@ -29,7 +31,7 @@ static int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) { // recupero regione del pezzo (è la prima del sottogruppo di nome Region) - int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, "Region") ; + int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, NST_PART_REG) ; int nRegId = pGeomDB->GetFirstInGroup( nRegGrp) ; while ( nRegId != GDB_ID_NULL) { if ( pGeomDB->GetGeoType( nRegId) == SRF_FLATRGN) @@ -41,10 +43,10 @@ GetFlatPartRegion( IGeomDB* pGeomDB, int nId) //---------------------------------------------------------------------------- static bool -GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, INTVECTOR& vCrId) +GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) { // recupero gruppo preview lavorazioni del pezzo - int nPVGrp = pGeomDB->GetFirstNameInGroup( nId, "PV") ; + int nPVGrp = pGeomDB->GetFirstNameInGroup( nId, MCH_PV) ; if ( nPVGrp == GDB_ID_NULL) return false ; // ciclo sulle lavorazioni @@ -52,10 +54,10 @@ GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, INTVECTOR& vCrId) while ( nMchId != GDB_ID_NULL) { int nClId = pGeomDB->GetFirstGroupInGroup( nMchId) ; while ( nClId != GDB_ID_NULL) { - int nCrId = pGeomDB->GetFirstNameInGroup( nClId, "RCUT") ; + int nCrId = pGeomDB->GetFirstNameInGroup( nClId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; while ( nCrId != GDB_ID_NULL) { vCrId.emplace_back( nCrId) ; - nCrId = pGeomDB->GetNextName( nCrId, "RCUT") ; + nCrId = pGeomDB->GetNextName( nCrId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; } nClId = pGeomDB->GetNextGroup( nClId) ; } @@ -104,11 +106,272 @@ CreateOutBoxRegion( IGeomDB* pGeomDB, int nParentId, double dXmin, double dYmin, pGeomDB->SetMaterial( nId, INVISIBLE) ; return nId ; } + +//---------------------------------------------------------------------------- +static bool +SetPreviewStatus( IGeomDB* pGeomDB, const INTVECTOR& vIds, bool bShow) +{ + for ( const auto nId : vIds) { + int nPvId = pGeomDB->GetFirstNameInGroup(nId, MCH_PV) ; + pGeomDB->SetStatus( nPvId, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +static bool +UpdateToolOffset( IGeomDB* pGeomDB, const INTVECTOR& vIds, bool bReducedCut, double& dOffs) +{ + for ( const auto nId : vIds) { + int nPvId = pGeomDB->GetFirstNameInGroup(nId, MCH_PV) ; + int nCutId = pGeomDB->GetFirstGroupInGroup( nPvId) ; + while ( nCutId != GDB_ID_NULL) { + int nPathId = pGeomDB->GetFirstGroupInGroup( nCutId) ; + while ( nPathId != GDB_ID_NULL) { + double dVal ; + if ( pGeomDB->GetInfo( nPathId, MCH_PV_KEY_WT, dVal) && dVal > dOffs) + dOffs = dVal ; + if ( ! bReducedCut && pGeomDB->GetInfo( nPathId, MCH_PV_KEY_DT, dVal) && dVal > dOffs) + dOffs = dVal ; + nPathId = pGeomDB->GetNextGroup( nPathId) ; + } + nCutId = pGeomDB->GetNextGroup( nCutId) ; + } + } + return true ; +} //---------------------------------------------------------------------------- bool -ExeMovePartCluster( const INTVECTOR& vIds, Vector3d& vtMove, - double dXmin, double dYmin, double dXmax, double dYmax) +ExeVerifyPartCluster( const INTVECTOR& vIds, bool bReducedCut, + double dXmin, double dYmin, double dXmax, double dYmax) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + + // Box della regione di interesse + BBox3d b3Region( dXmin, dYmin, 0, dXmax, dYmax, 0) ; + // Flag per calcolo box + const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ; + + // Risolvo eventuali riferimenti a oggetti selezionati, compresi nella regione e + // calcolo il box del cluster risultante + INTVECTOR vTrueIds ; + vTrueIds.reserve( vIds.size()) ; + BBox3d b3Cluster ; + for ( auto nId : vIds) { + int nTrueId = (( nId != GDB_ID_SEL) ? nId : pGeomDB->GetFirstSelectedObj()) ; + while ( nTrueId != GDB_ID_NULL) { + BBox3d b3Part ; + if ( pGeomDB->GetGlobalBBox( nTrueId, b3Part, BBF_MY_FLAG)) { + // inserisco l'identificativo nel vettore dei validi + vTrueIds.push_back( nTrueId) ; + // aggiorno il box del cluster + b3Cluster.Add( b3Part) ; + } + // passo al successivo + nTrueId = (( nId != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + // Se non sono rimasti oggetti, esco con successo + if ( vTrueIds.empty()) + return true ; + + // Determino le regioni dei pezzi rimasti + INTVECTOR vReg ; + INTVECTOR vCutReg ; + BBox3d b3RegCluster ; + for ( int nId : vTrueIds) { + // recupero regione del pezzo + int nRegId = GetFlatPartRegion( pGeomDB, nId) ; + BBox3d b3Reg ; + if ( pGeomDB->GetGlobalBBox( nRegId, b3Reg, BBF_MY_FLAG)) { + vReg.emplace_back( nRegId) ; + b3RegCluster.Add( b3Reg) ; + } + else + return false ; + // recupero regioni dei tagli del pezzo + if ( ! GetFlatPartCutRegions( pGeomDB, nId, bReducedCut, vCutReg)) + return false ; + } + + // Verifico di essere all'interno del box esterno + if ( ! b3Region.EnclosesXY( b3RegCluster)) + return false ; + + // Verifico se pezzi sotto la radice o pezzi in altro gruppo + int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ; + bool bInRoot = ( nGroupId == GDB_ID_ROOT) ; + // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse + INTVECTOR vOthReg ; + INTVECTOR vOthCutReg ; + int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; + while ( nId2 != GDB_ID_NULL) { + if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { + BBox3d b3Part2 ; + if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) && + b3Cluster.OverlapsXY( b3Part2)) { + // recupero regione del pezzo + int nRegId = GetFlatPartRegion( pGeomDB, nId2) ; + if ( nRegId != GDB_ID_NULL) + vOthReg.emplace_back( nRegId) ; + else + return false ; + // recupero regioni dei tagli del pezzo + if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vOthCutReg)) + return false ; + } + } + nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; + } + + // Eseguo verifiche + bool bOk = true ; + // regioni dei pezzi + for ( int nRegId : vReg) { + // verifico con le regioni degli altri pezzi + for ( int nOthRegId : vOthReg) { + if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nOthRegId, 0) != REGC_OUT) + bOk = false ; + } + // e con le regioni dei tagli degli altri pezzi + for ( int nOthCutRegId : vOthCutReg) { + if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nOthCutRegId, 0) != REGC_OUT) + bOk = false ; + } + } + // regioni delle lavorazioni dei pezzi + for ( int nCutRegId : vCutReg) { + // le confronto con le regioni degli altri pezzi + for ( int nOthRegId : vOthReg) { + if ( ExeSurfFrChunkSimpleClassify( nCutRegId, 0, nOthRegId, 0) != REGC_OUT) + bOk = false ; + } + } + + return bOk ; +} + +//---------------------------------------------------------------------------- +static bool +MyPackPartCluster( const INTVECTOR& vIds, bool bReducedCut, + double dXmin, double dYmin, double dXmax, double dYmax, bool bBottomUp) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // Verifiche sui parametri + if ( dXmax < dXmin + EPS_SMALL || + dYmax < dYmin + EPS_SMALL) + return false ; + + // Risolvo eventuali riferimenti a oggetti selezionati + INTVECTOR vTrueIds ; + vTrueIds.reserve( vIds.size()) ; + for ( auto nId : vIds) { + int nTrueId = (( nId != GDB_ID_SEL) ? nId : pGeomDB->GetFirstSelectedObj()) ; + while ( nTrueId != GDB_ID_NULL) { + vTrueIds.push_back( nTrueId) ; + // passo al successivo + nTrueId = (( nId != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + // Se non sono rimasti oggetti, esco con successo + 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) ; + + // Box della regione di interesse + BBox3d b3Region( dXmin, dYmin, 0, dXmax, dYmax, 0) ; + // Flag per calcolo box + const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ; + + // Determino tutti gli altri pezzi compresi nella regione di interesse + INTVECTOR vOtherIds ; + int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; + while ( nId2 != GDB_ID_NULL) { + if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { + BBox3d b3Part2 ; + if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) && + b3Region.OverlapsXY( b3Part2)) { + vOtherIds.emplace_back( nId2) ; + } + } + nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; + } + + // nascondo preview delle lavorazioni + SetPreviewStatus( pGeomDB, vTrueIds, false) ; + SetPreviewStatus( pGeomDB, vOtherIds, false) ; + + // calcolo offset per ingombro lavorazioni + double dOffs = 0 ; + UpdateToolOffset( pGeomDB, vTrueIds, bReducedCut, dOffs) ; + UpdateToolOffset( pGeomDB, vOtherIds, bReducedCut, dOffs) ; + + // eseguo primo movimento come box + bool bOk = ExePackBoxCluster( vTrueIds, dXmin, dYmin, dXmax, dYmax, dOffs, bBottomUp) ; + + // se inserimento di massima riuscito, provo a migliorare + if ( bOk) { + const double BIG_MOVE = 1000 ; + ExeMovePartCluster( vTrueIds, bReducedCut, ( bBottomUp ? - 1 : 1) * BIG_MOVE * Y_AX, dXmin, dYmin, dXmax, dYmax) ; + ExeMovePartCluster( vTrueIds, bReducedCut, - BIG_MOVE * X_AX, dXmin, dYmin, dXmax, dYmax) ; + } + + // ripristino preview delle lavorazioni + SetPreviewStatus( pGeomDB, vTrueIds, true) ; + SetPreviewStatus( pGeomDB, vOtherIds, true) ; + + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, + double dXmin, double dYmin, double dXmax, double dYmax, bool bBottomUp) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // Risolvo eventuali riferimenti a oggetti selezionati + INTVECTOR vTrueIds ; + vTrueIds.reserve( vIds.size()) ; + for ( auto nId : vIds) { + int nTrueId = (( nId != GDB_ID_SEL) ? nId : pGeomDB->GetFirstSelectedObj()) ; + while ( nTrueId != GDB_ID_NULL) { + vTrueIds.push_back( nTrueId) ; + // passo al successivo + nTrueId = (( nId != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + + // se con tagli ridotti + if ( bReducedCut) { + return MyPackPartCluster( vTrueIds, true, dXmin, dYmin, dXmax, dYmax, bBottomUp) ; + } + // altrimenti + else { + // provo con tagli ridotti + if ( ! MyPackPartCluster( vTrueIds, true, dXmin, dYmin, dXmax, dYmax, bBottomUp)) + return false ; + // se posizione valida + if ( ExeVerifyPartCluster( vTrueIds, false, dXmin, dYmin, dXmax, dYmax)) { + return true ; + } + // altrimenti, riprovo con tagli standard + else { + return MyPackPartCluster( vTrueIds, false, dXmin, dYmin, dXmax, dYmax, bBottomUp) ; + } + } +} + +//---------------------------------------------------------------------------- +static bool +MyMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove, + double dXmin, double dYmin, double dXmax, double dYmax) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -156,8 +419,8 @@ ExeMovePartCluster( const INTVECTOR& vIds, Vector3d& vtMove, int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ; bool bInRoot = ( nGroupId == GDB_ID_ROOT) ; // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse - INTVECTOR vReg ; - INTVECTOR vCutReg ; + INTVECTOR vOthReg ; + INTVECTOR vOthCutReg ; int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { @@ -167,11 +430,11 @@ ExeMovePartCluster( const INTVECTOR& vIds, Vector3d& vtMove, // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nId2) ; if ( nRegId != GDB_ID_NULL) - vReg.emplace_back( nRegId) ; + vOthReg.emplace_back( nRegId) ; else return false ; // recupero regioni dei tagli del pezzo - if ( ! GetFlatPartCutRegions( pGeomDB, nId2, vCutReg)) + if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vOthCutReg)) return false ; } } @@ -197,22 +460,22 @@ ExeMovePartCluster( const INTVECTOR& vIds, Vector3d& vtMove, // la confronto con il box ExeSurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, RTY_GLOB) ; // la confronto con le regioni degli altri pezzi - for ( int nOthRegId : vReg) { + for ( int nOthRegId : vOthReg) { ExeSurfFrMoveSimpleNoCollision( nRegId, nOthRegId, vtDir, dLen, RTY_GLOB) ; } // e con le regioni dei tagli degli altri pezzi - for ( int nOthCutRegId : vCutReg) { + for ( int nOthCutRegId : vOthCutReg) { ExeSurfFrMoveSimpleNoCollision( nRegId, nOthCutRegId, vtDir, dLen, RTY_GLOB) ; } // recupero regioni di lavorazione del pezzo INTVECTOR vCrId ; - if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, vCrId)) { + if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, bReducedCut, vCrId)) { bOk = false ; break ; } // le confronto con le regioni degli altri pezzi for ( int nCrId : vCrId) { - for ( int nOthRegId : vReg) { + for ( int nOthRegId : vOthReg) { ExeSurfFrMoveSimpleNoCollision( nCrId, nOthRegId, vtDir, dLen, RTY_GLOB) ; } } @@ -241,7 +504,52 @@ ExeMovePartCluster( const INTVECTOR& vIds, Vector3d& vtMove, //---------------------------------------------------------------------------- bool -ExeRotatePartCluster( const INTVECTOR& vIds, const Point3d& ptCen, double& dRotAngDeg, +ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove, + double dXmin, double dYmin, double dXmax, double dYmax) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // Risolvo eventuali riferimenti a oggetti selezionati + INTVECTOR vTrueIds ; + vTrueIds.reserve( vIds.size()) ; + for ( auto nId : vIds) { + int nTrueId = (( nId != GDB_ID_SEL) ? nId : pGeomDB->GetFirstSelectedObj()) ; + while ( nTrueId != GDB_ID_NULL) { + vTrueIds.push_back( nTrueId) ; + // passo al successivo + nTrueId = (( nId != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + + // se con tagli ridotti + if ( bReducedCut) { + return MyMovePartCluster( vTrueIds, true, vtMove, dXmin, dYmin, dXmax, dYmax) ; + } + // altrimenti + else { + // provo con tagli ridotti + Vector3d vtM = vtMove ; + if ( ! MyMovePartCluster( vTrueIds, true, vtM, dXmin, dYmin, dXmax, dYmax)) + return false ; + // se posizione valida + if ( ExeVerifyPartCluster( vTrueIds, false, dXmin, dYmin, dXmax, dYmax)) { + vtMove = vtM ; + return true ; + } + // altrimenti, riprovo con tagli standard + else { + // annullo il movimento + for ( int nId : vTrueIds) + pGeomDB->TranslateGlob( nId, - vtM) ; + // riprovo + return MyMovePartCluster( vTrueIds, false, vtMove, dXmin, dYmin, dXmax, dYmax) ; + } + } +} + +//---------------------------------------------------------------------------- +bool +ExeRotatePartCluster( const INTVECTOR& vIds, bool bReducedCut, const Point3d& ptCen, double& dRotAngDeg, double dXmin, double dYmin, double dXmax, double dYmax) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -301,7 +609,7 @@ ExeRotatePartCluster( const INTVECTOR& vIds, const Point3d& ptCen, double& dRotA else return false ; // recupero regioni dei tagli del pezzo - if ( ! GetFlatPartCutRegions( pGeomDB, nId2, vCutReg)) + if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vCutReg)) return false ; } } @@ -335,7 +643,7 @@ ExeRotatePartCluster( const INTVECTOR& vIds, const Point3d& ptCen, double& dRotA } // recupero regioni di lavorazione del pezzo INTVECTOR vCrId ; - if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, vCrId)) { + if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, bReducedCut, vCrId)) { bOk = false ; break ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 671ddbe..3ae2b1f 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 2bd2e64..eb284b8 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -218,6 +218,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index 24b59d9..1a89ef9 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -90,6 +90,9 @@ File di intestazione + + File di intestazione +