From 4dfc24345f409ffb364346b4a93b2ae78e5331e0 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 12 Mar 2016 18:21:54 +0000 Subject: [PATCH] EgtExecutor 1.6o1 : - in nesting aggiunta verifica interferenza con atgli inclinati. --- EXE_Const.h | 17 +-- EXE_Nst.h | 2 + EXE_NstCreateFlatParts.cpp | 247 +++++++++++++++++++++++++++++++++++++ EXE_NstMachining.cpp | 44 +++++++ EXE_NstPartNesting.cpp | 192 ++++++++++++++++++++++++++-- EgtExecutor.rc | Bin 11710 -> 11694 bytes 6 files changed, 486 insertions(+), 16 deletions(-) diff --git a/EXE_Const.h b/EXE_Const.h index f1fc672..241183f 100644 --- a/EXE_Const.h +++ b/EXE_Const.h @@ -17,12 +17,15 @@ //---------------------------------------------------------------------------- // Curve originali di composite o curva originale di area danneggiata -static std::string CRV_ORIG = "ORIG" ; +const std::string CRV_ORIG = "ORIG" ; // Per FlatParts (Nesting) -static std::string NST_PARTREG_LAYER = "Region" ; -static std::string NST_EXT_LAYER = "OutLoop" ; -static std::string NST_IN_LAYER = "InLoop" ; -static std::string NST_ON_LAYER = "OnPath" ; +const std::string NST_PARTREG_LAYER = "Region" ; +const std::string NST_PARTDOWNREG_LAYER = "DwnReg" ; +const std::string NST_EXT_LAYER = "OutLoop" ; +const std::string NST_EXT_ORIG_LAYER = "OutLoop.orig" ; +const std::string NST_IN_LAYER = "InLoop" ; +const std::string NST_ON_LAYER = "OnPath" ; +const std::string NST_KEY_SIDEANG = "SideAng" ; // Per Sheets (Nesting) -static std::string NST_SHEET_OUTREG = "SheetOut" ; -static std::string NST_DAMAGED_REG = "DmgReg" ; +const std::string NST_SHEET_OUTREG = "SheetOut" ; +const std::string NST_DAMAGED_REG = "DmgReg" ; diff --git a/EXE_Nst.h b/EXE_Nst.h index f367f56..3754bf5 100644 --- a/EXE_Nst.h +++ b/EXE_Nst.h @@ -17,7 +17,9 @@ class IGeomDB ; //---------------------------------------------------------------------------- int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) ; +int GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId) ; bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; +bool GetFlatPartDownCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ; int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ; int GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ; diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 851665a..839853b 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -735,6 +735,210 @@ ExeAdjustFlatPartLayer( int nLayerId) return bOk ; } +//---------------------------------------------------------------------------- +static bool +AdjustCurves( ICurve* pCrv1, ICurve* pCrv2) +{ + // se fine della prima coincide con inizio della seconda non devo fare alcunchè + Point3d ptEnd1 ; + pCrv1->GetEndPoint( ptEnd1) ; + Point3d ptStart2 ; + pCrv2->GetStartPoint( ptStart2) ; + if ( AreSamePointApprox( ptEnd1, ptStart2)) + return true ; + // allungo le due curve + if ( ! pCrv1->ExtendEndByLen( 200) || + ! pCrv2->ExtendStartByLen( 200)) + return false ; + // cerco intersezioni + IntersCurveCurve intCC( *pCrv1, *pCrv2) ; + if ( intCC.GetIntersCount() == 0) + return false ; + // prendo l'intersezione più vicina al punto medio tra gli estremi originali delle curve + Point3d ptMid = 0.5 * ( ptEnd1 + ptStart2) ; + Point3d ptNew1, ptNew2 ; + if ( ! intCC.GetIntersPointNearTo( 0, ptMid, ptNew1) || + ! intCC.GetIntersPointNearTo( 1, ptMid, ptNew2)) + return false ; + // modifico le due curve sul punto medio + Point3d ptNew = 0.5 * ( ptNew1 + ptNew2) ; + return ( pCrv1->ModifyEnd( ptNew) && pCrv2->ModifyStart( ptNew)) ; +} + +//---------------------------------------------------------------------------- +bool +ExeCalcFlatPartDownRegion( int nPartId, double dH) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + + // ripristino lo stato originale + pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTDOWNREG_LAYER)) ; + int nOlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_ORIG_LAYER) ; + if ( nOlOrigId != GDB_ID_NULL) { + pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER)) ; + pGeomDB->SetName( nOlOrigId, NST_EXT_LAYER) ; + pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ; + } + // se spessore nullo, non devo fare alcunché + if ( dH < EPS_SMALL) + return true ; + // recupero il layer esterno + int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ; + if ( nOlId == GDB_ID_NULL) + return false ; + // se il pezzo non ha lati esterni inclinati non devo fare alcunchè + bool bAllVertSides = true ; + int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; + while ( nCrvId != GDB_ID_NULL) { + double dSideAng ; + if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) { + bAllVertSides = false ; + break ; + } + nCrvId = pGeomDB->GetNext( nCrvId) ; + } + if ( bAllVertSides) + return true ; + + // creo una copia del layer esterno + nOlOrigId = pGeomDB->Copy( nOlId, GDB_ID_NULL, nOlId, GDB_AFTER) ; + if ( nOlOrigId == GDB_ID_NULL) + return false ; + pGeomDB->SetName( nOlOrigId, NST_EXT_ORIG_LAYER) ; + pGeomDB->SetStatus( nOlOrigId, GDB_ST_OFF) ; + // creo il layer per la regione sotto (con il medesimo riferimento del layer esterno) + Frame3d frOl ; + pGeomDB->GetGroupFrame( nOlId, frOl) ; + int nDwnRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ; + if ( nDwnRegId == GDB_ID_NULL) + return false ; + pGeomDB->SetName( nDwnRegId, NST_PARTDOWNREG_LAYER) ; + + // copio le entità del contorno esterno e le offsetto opportunamente + nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; + while ( nCrvId != GDB_ID_NULL) { + // copio la curva nel gruppo downregion + int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nDwnRegId) ; + if ( nNewId == GDB_ID_NULL) + return false ; + // determino ed eseguo offset + double dSideAng ; + if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) { + double dOffset = dH * tan( dSideAng * DEGTORAD) ; + ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; + if ( pCrv == nullptr) + return false ; + pCrv->SimpleOffset( dOffset) ; + } + // passo alla successiva + nCrvId = pGeomDB->GetNext( nCrvId) ; + } + // aggiusto tra loro le entità offsettate + int nFirstCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ; + ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ; + int nNextCrvId = pGeomDB->GetNext( nFirstCrvId) ; + ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ; + while ( nNextCrvId != GDB_ID_NULL) { + // sistemo le curve + pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ; + if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2)) + return false ; + // passo alla successiva + pCrv1 = pCrv2 ; + nNextCrvId = pGeomDB->GetNext( nNextCrvId) ; + } + // anche prima e ultima + pCrv2 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ; + if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2)) + return false ; + + // eventuali allungamenti per le curve del loop esterno + for ( int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; + nCrvId != GDB_ID_NULL ; + nCrvId = pGeomDB->GetNext( nCrvId)) { + // recupero il nome + string sName ; + if ( ! pGeomDB->GetName( nCrvId, sName)) + continue ; + // recupero curva con lo stesso nome nel gruppo della regione sotto + int nCrvDrId = pGeomDB->GetFirstNameInGroup( nDwnRegId, sName) ; + if ( nCrvDrId == GDB_ID_NULL) + continue ; + // verifico siano curve + ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ; + ICurve* pCrvDr = GetCurve( pGeomDB->GetGeoObj( nCrvDrId)) ; + if ( pCrv == nullptr || pCrvDr == nullptr) + continue ; + // verifico se devo allungare o accorciare la curva all'inizio + double dPrevAng = 0 ; + pGeomDB->GetInfo( nCrvId, MCH_PV_KEY_PREVANG, dPrevAng) ; + Point3d ptStart ; + pCrv->GetStartPoint( ptStart) ; + Vector3d vtStartDir ; + pCrv->GetStartDir( vtStartDir) ; + Point3d ptStartDr ; + pCrvDr->GetStartPoint( ptStartDr) ; + double dStartPro = - ( ( ptStartDr - ptStart) * vtStartDir) ; + if ( dPrevAng > - EPS_ANG_SMALL) { + if ( dStartPro > EPS_SMALL) + pCrv->ExtendStartByLen( dStartPro) ; + } + else { + if ( dStartPro < - EPS_SMALL) + pCrv->TrimStartAtLen( - dStartPro) ; + } + // verifico se devo allungare la curva alla fine + double dNextAng = 0 ; + pGeomDB->GetInfo( nCrvId, MCH_PV_KEY_NEXTANG, dNextAng) ; + Point3d ptEnd ; + pCrv->GetEndPoint( ptEnd) ; + Vector3d vtEndDir ; + pCrv->GetStartDir( vtEndDir) ; + Point3d ptEndDr ; + pCrvDr->GetEndPoint( ptEndDr) ; + double dEndPro = ( ptEndDr - ptEnd) * vtEndDir ; + if ( dNextAng > - EPS_ANG_SMALL) { + if ( dEndPro > EPS_SMALL) + pCrv->ExtendEndByLen( dEndPro) ; + } + else { + if ( dEndPro < - EPS_SMALL) { + double dLen ; + pCrv->GetLength( dLen) ; + pCrv->TrimEndAtLen( dLen + dEndPro) ; + } + } + } + + // creo la regione + PtrOwner pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo)) + return false ; + for ( int nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ; + nCrvId != GDB_ID_NULL ; + nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId)) { + ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ; + if ( pCrv != nullptr) { + pCompo->AddCurve( pCrv) ; + pGeomDB->RemoveGeoObjAndErase( nCrvId) ; + } + else + pGeomDB->Erase( nCrvId) ; + } + SurfFlatRegionByContours SfrCntr( false) ; + SfrCntr.AddCurve( Release( pCompo)) ; + int nSfrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDwnRegId, SfrCntr.GetSurf()) ; + if ( nSfrId == GDB_ID_NULL) + return false ; + // assegno il colore + Color cCol = AQUA ; + cCol.SetAlpha( 0.3) ; + pGeomDB->SetMaterial( nSfrId, cCol) ; + + return true ; +} + //---------------------------------------------------------------------------- int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) @@ -750,6 +954,21 @@ GetFlatPartRegion( IGeomDB* pGeomDB, int nId) return nRegId ; } +//---------------------------------------------------------------------------- +int +GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId) +{ + // recupero regione del pezzo (è la prima del sottogruppo di nome DwnReg) + int nRegGrp = pGeomDB->GetFirstNameInGroup( nId, NST_PARTDOWNREG_LAYER) ; + int nRegId = pGeomDB->GetFirstInGroup( nRegGrp) ; + while ( nRegId != GDB_ID_NULL) { + if ( pGeomDB->GetGeoType( nRegId) == SRF_FLATRGN) + break ; + nRegId = pGeomDB->GetNext( nRegId) ; + } + return nRegId ; +} + //---------------------------------------------------------------------------- bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) @@ -775,6 +994,34 @@ GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrI return true ; } +//---------------------------------------------------------------------------- +bool +GetFlatPartDownCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vDwnCrId) +{ + // recupero gruppo preview lavorazioni del pezzo + int nPVGrp = pGeomDB->GetFirstNameInGroup( nId, MCH_PV) ; + if ( nPVGrp == GDB_ID_NULL) + return true ; + // ciclo sulle lavorazioni + int nMchId = pGeomDB->GetFirstGroupInGroup( nPVGrp) ; + while ( nMchId != GDB_ID_NULL) { + int nClId = pGeomDB->GetFirstGroupInGroup( nMchId) ; + while ( nClId != GDB_ID_NULL) { + // ciclo sui sopra e salvo gli eventuali sotto (per tenerli sincronizzati) + int nCrId = pGeomDB->GetFirstNameInGroup( nClId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; + int nDwnCrId = pGeomDB->GetFirstNameInGroup( nClId, ( bReduced ? MCH_PV_DOWN_RRCUT : MCH_PV_DOWN_RCUT)) ; + while ( nCrId != GDB_ID_NULL) { + vDwnCrId.emplace_back( nDwnCrId) ; + nCrId = pGeomDB->GetNextName( nCrId, ( bReduced ? MCH_PV_RRCUT : MCH_PV_RCUT)) ; + nDwnCrId = pGeomDB->GetNextName( nDwnCrId, ( bReduced ? MCH_PV_DOWN_RRCUT : MCH_PV_DOWN_RCUT)) ; + } + nClId = pGeomDB->GetNextGroup( nClId) ; + } + nMchId = pGeomDB->GetNextGroup( nMchId) ; + } + return true ; +} + //---------------------------------------------------------------------------- int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) diff --git a/EXE_NstMachining.cpp b/EXE_NstMachining.cpp index 16d34aa..5bd508c 100644 --- a/EXE_NstMachining.cpp +++ b/EXE_NstMachining.cpp @@ -40,6 +40,7 @@ ExeVerifyMachining( int nMchId, int& nResult) // Recupero il box e le regioni della lavorazione BBox3d b3Mch ; INTVECTOR vMchRReg, vMchLiReg, vMchLoReg ; + INTVECTOR vMchDwnRReg, vMchDwnLiReg, vMchDwnLoReg ; // recupero gruppo preview lavorazioni nella lavorazione int nPVGrp = pGeomDB->GetFirstNameInGroup( nMchId, MCH_PV) ; if ( nPVGrp == GDB_ID_NULL) @@ -53,33 +54,42 @@ ExeVerifyMachining( int nMchId, int& nResult) while ( nClId != GDB_ID_NULL) { // tagli ridotti int nCrId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RRCUT) ; + int nDwnCrId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_DOWN_RRCUT) ; while ( nCrId != GDB_ID_NULL) { BBox3d b3Reg ; if ( ! pGeomDB->GetGlobalBBox( nCrId, b3Reg, BBF_MCH_MY_FLAG)) return false ; b3Mch.Add( b3Reg) ; vMchRReg.emplace_back( nCrId) ; + vMchDwnRReg.emplace_back( nDwnCrId) ; nCrId = pGeomDB->GetNextName( nCrId, MCH_PV_RRCUT) ; + nDwnCrId = pGeomDB->GetNextName( nDwnCrId, MCH_PV_DOWN_RRCUT) ; } // ingressi int nLiId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RLICUT) ; + int nDwnLiId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_DOWN_RLICUT) ; while ( nLiId != GDB_ID_NULL) { BBox3d b3Reg ; if ( ! pGeomDB->GetGlobalBBox( nLiId, b3Reg, BBF_MCH_MY_FLAG)) return false ; b3Mch.Add( b3Reg) ; vMchLiReg.emplace_back( nLiId) ; + vMchDwnLiReg.emplace_back( nDwnLiId) ; nLiId = pGeomDB->GetNextName( nLiId, MCH_PV_RLICUT) ; + nDwnLiId = pGeomDB->GetNextName( nDwnLiId, MCH_PV_DOWN_RLICUT) ; } // uscite int nLoId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RLOCUT) ; + int nDwnLoId = pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_DOWN_RLOCUT) ; while ( nLoId != GDB_ID_NULL) { BBox3d b3Reg ; if ( ! pGeomDB->GetGlobalBBox( nLoId, b3Reg, BBF_MCH_MY_FLAG)) return false ; b3Mch.Add( b3Reg) ; vMchLoReg.emplace_back( nLoId) ; + vMchDwnLoReg.emplace_back( nDwnLoId) ; nLoId = pGeomDB->GetNextName( nLoId, MCH_PV_RLOCUT) ; + nDwnLoId = pGeomDB->GetNextName( nDwnLoId, MCH_PV_DOWN_RLOCUT) ; } // passo al successivo percorso utensile nClId = pGeomDB->GetNextGroup( nClId) ; @@ -96,6 +106,7 @@ ExeVerifyMachining( int nMchId, int& nResult) // Determino le regioni di tutti gli altri pezzi compresi nella regione della lavorazione INTVECTOR vOthReg ; + INTVECTOR vOthDwnReg ; int nRawId = ExeGetFirstRawPart() ; while ( nRawId != GDB_ID_NULL) { // se il grezzo appartiene alla fase di lavorazione @@ -113,6 +124,9 @@ ExeVerifyMachining( int nMchId, int& nResult) vOthReg.emplace_back( nRegId) ; else return false ; + // recupero eventuale regione sotto del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId) ; + vOthDwnReg.emplace_back( nDwnRegId) ; } } nId = ExeGetNextPartInRawPart( nId) ; @@ -130,6 +144,16 @@ ExeVerifyMachining( int nMchId, int& nResult) nResult |= FMI_LI ; } } + for ( size_t i = 0 ; i < vMchDwnLiReg.size() ; ++ i) { + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( vMchDwnLiReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nMchRegId = ( ( vMchDwnLiReg[i] != GDB_ID_NULL) ? vMchDwnLiReg[i] : vMchLiReg[i]) ; + int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT) + nResult |= FMI_LI ; + } + } + } // confronto la regione ridotta della lavorazione con le regioni degli altri pezzi for ( int nMchRegId : vMchRReg) { for ( int nOthRegId : vOthReg) { @@ -137,6 +161,16 @@ ExeVerifyMachining( int nMchId, int& nResult) nResult |= FMI_RM ; } } + for ( size_t i = 0 ; i < vMchDwnRReg.size() ; ++ i) { + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( vMchDwnRReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nMchRegId = ( ( vMchDwnRReg[i] != GDB_ID_NULL) ? vMchDwnRReg[i] : vMchRReg[i]) ; + int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT) + nResult |= FMI_LO ; + } + } + } // confronto la regione di uscita della lavorazione con le regioni degli altri pezzi for ( int nMchRegId : vMchLoReg) { for ( int nOthRegId : vOthReg) { @@ -144,6 +178,16 @@ ExeVerifyMachining( int nMchId, int& nResult) nResult |= FMI_LO ; } } + for ( size_t i = 0 ; i < vMchDwnLoReg.size() ; ++ i) { + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( vMchDwnLoReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nMchRegId = ( ( vMchDwnLoReg[i] != GDB_ID_NULL) ? vMchDwnLoReg[i] : vMchLoReg[i]) ; + int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nMchRegId, 0, nOthRegId, 0) != REGC_OUT) + nResult |= FMI_LO ; + } + } + } return true ; } diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 3ca23d3..12954d2 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -354,7 +354,9 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& // Determino le regioni dei pezzi INTVECTOR vReg ; + INTVECTOR vDwnReg ; INTVECTOR vCutReg ; + INTVECTOR vDwnCutReg ; BBox3d b3RegCluster ; for ( int nId : vTrueIds) { // recupero regione del pezzo @@ -366,9 +368,14 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& } else return false ; + // recupero eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId) ; + vDwnReg.emplace_back( nDwnRegId) ; // recupero regioni dei tagli del pezzo if ( ! GetFlatPartCutRegions( pGeomDB, nId, bReducedCut, vCutReg)) return false ; + // recupero regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nId, bReducedCut, vDwnCutReg) ; } // Verifico se pezzi sotto la radice o pezzi in altro gruppo @@ -388,6 +395,11 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nBoxId, 0) != REGC_OUT) return false ; } + for ( int nDwnRegId : vDwnReg) { + if ( nDwnRegId != GDB_ID_NULL && + ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nBoxId, 0) != REGC_OUT) + return false ; + } // Verifico con le eventuali aree danneggiate // recupero le aree @@ -404,10 +416,20 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& return false ; } } + for ( int nDwnRegId : vDwnReg) { + if ( nDwnRegId != GDB_ID_NULL) { + for ( int nDmgRegId : vDmgReg) { + if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nDmgRegId, 0) != REGC_OUT) + return false ; + } + } + } // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse INTVECTOR vOthReg ; + INTVECTOR vOthDwnReg ; INTVECTOR vOthCutReg ; + INTVECTOR vOthDwnCutReg ; int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { @@ -420,9 +442,14 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& vOthReg.emplace_back( nRegId) ; else return false ; + // recupero eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId2) ; + vOthDwnReg.emplace_back( nDwnRegId) ; // recupero regioni dei tagli del pezzo if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vOthCutReg)) return false ; + // recupero regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nId2, bReducedCut, vOthDwnCutReg) ; } } nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; @@ -442,6 +469,27 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& return false ; } } + // regioni sotto dei pezzi + for ( size_t i = 0 ; i < vDwnReg.size() ; ++ i) { + // verifico con le regioni sotto degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; + int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnRegId, 0) != REGC_OUT) + return false ; + } + } + // e con le regioni sotto dei tagli degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { + int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; + int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnCutRegId, 0) != REGC_OUT) + return false ; + } + } + } // regioni delle lavorazioni dei pezzi for ( int nCutRegId : vCutReg) { // le confronto con le regioni degli altri pezzi @@ -450,6 +498,18 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& return false ; } } + // regioni sotto delle lavorazioni dei pezzi + for ( size_t i = 0 ; i < vDwnCutReg.size() ; ++ i) { + // le confronto con le regioni sotto degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( vDwnCutReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nDwnCutRegId = ( vDwnCutReg[i] != GDB_ID_NULL ? vDwnCutReg[i] : vCutReg[i]) ; + int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; + if ( ExeSurfFrChunkSimpleClassify( nDwnCutRegId, 0, nOthDwnRegId, 0) != REGC_OUT) + return false ; + } + } + } return true ; } @@ -801,7 +861,9 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse INTVECTOR vOthReg ; + INTVECTOR vOthDwnReg ; INTVECTOR vOthCutReg ; + INTVECTOR vOthDwnCutReg ; int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { @@ -814,9 +876,14 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster vOthReg.emplace_back( nRegId) ; else return false ; + // recupero eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId2) ; + vOthDwnReg.emplace_back( nDwnRegId) ; // recupero regioni dei tagli del pezzo if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vOthCutReg)) return false ; + // recupero regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nId2, bReducedCut, vOthDwnCutReg) ; } } nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; @@ -828,14 +895,15 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster double dPrevLen = dLen ; Vector3d vtDir = ( dLen > EPS_SMALL ? vtMoveXY / dLen : V_NULL) ; for ( auto nTrueId : vTrueIds) { + // info di collisione correnti + SCollInfo scInfoCurr ; + // ----------------------------------------- // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nTrueId) ; if ( nRegId == GDB_ID_NULL) { bOk = false ; break ; } - // info di collisione correnti - SCollInfo scInfoCurr ; // la confronto con il box MySurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nBoxId, false, false, scInfoCurr) ; @@ -854,6 +922,40 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster MySurfFrMoveSimpleNoCollision( nRegId, nOthCutRegId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthCutRegId, false, true, scInfoCurr) ; } + // ----------------------------------------- + // recupero regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ; + // la confronto con il box + if ( nDwnRegId != GDB_ID_NULL) { + MySurfFrMoveSimpleNoCollision( nDwnRegId, nBoxId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nBoxId, false, false, scInfoCurr) ; + } + // la confronto con le aree danneggiate + if ( nDwnRegId != GDB_ID_NULL) { + for ( int nDmgRegId : vDmgReg) { + MySurfFrMoveSimpleNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, scInfoCurr) ; + } + } + // la confronto con le regioni in basso degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; + int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; + MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, scInfoCurr) ; + } + } + // e con le regioni in basso dei tagli degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { + int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; + int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; + MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, scInfoCurr) ; + } + } + // ----------------------------------------- // recupero regioni di lavorazione del pezzo INTVECTOR vCrId ; if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, bReducedCut, vCrId)) { @@ -867,6 +969,24 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, scInfoCurr) ; } } + // ----------------------------------------- + // recupero regioni in basso di lavorazione del pezzo + INTVECTOR vDwnCrId ; + if ( ! GetFlatPartDownCutRegions( pGeomDB, nTrueId, bReducedCut, vDwnCrId)) { + bOk = false ; + break ; + } + // le confronto con le regioni in basso degli altri pezzi + for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) { + for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) { + if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { + int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; + int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; + MySurfFrMoveSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, scInfoCurr) ; + } + } + } } // Se errore @@ -984,8 +1104,10 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse - INTVECTOR vReg ; - INTVECTOR vCutReg ; + INTVECTOR vOthReg ; + INTVECTOR vOthDwnReg ; + INTVECTOR vOthCutReg ; + INTVECTOR vOthDwnCutReg ; int nId2 = ( bInRoot ? ExeGetFirstPart( true) : ExeGetFirstGroupInGroup( nGroupId)) ; while ( nId2 != GDB_ID_NULL) { if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) { @@ -995,12 +1117,17 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus // 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 eventuale regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nId2) ; + vOthDwnReg.emplace_back( nDwnRegId) ; // recupero regioni dei tagli del pezzo - if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vCutReg)) + if ( ! GetFlatPartCutRegions( pGeomDB, nId2, bReducedCut, vOthCutReg)) return false ; + // recupero eventuali regioni in basso dei tagli del pezzo + GetFlatPartDownCutRegions( pGeomDB, nId2, bReducedCut, vOthDwnCutReg) ; } } nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; @@ -1010,6 +1137,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus bool bOk = true ; double dAng = dRotAngDeg ; for ( auto nTrueId : vTrueIds) { + // ----------------------------------------- // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nTrueId) ; if ( nRegId == GDB_ID_NULL) { @@ -1023,13 +1151,42 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ; } // la confronto con le regioni degli altri pezzi - for ( int nOthRegId : vReg) { + for ( int nOthRegId : vOthReg) { ExeSurfFrRotateSimpleNoCollision( nRegId, nOthRegId, ptCen, dAng, RTY_GLOB) ; } // e con le regioni dei tagli degli altri pezzi - for ( int nOthCutRegId : vCutReg) { + for ( int nOthCutRegId : vOthCutReg) { ExeSurfFrRotateSimpleNoCollision( nRegId, nOthCutRegId, ptCen, dAng, RTY_GLOB) ; } + // ----------------------------------------- + // recupero regione in basso del pezzo + int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ; + // la confronto con il box + if ( nDwnRegId != GDB_ID_NULL) + ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nBoxId, ptCen, dAng, RTY_GLOB) ; + // la confronto con le aree danneggiate + if ( nDwnRegId != GDB_ID_NULL) { + for ( int nDmgRegId : vDmgReg) { + ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ; + } + } + // la confronto con le regioni in basso degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { + int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; + int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; + ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ; + } + } + // e con le regioni in basso dei tagli degli altri pezzi + for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { + int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; + int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; + ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, RTY_GLOB) ; + } + } + // ----------------------------------------- // recupero regioni di lavorazione del pezzo INTVECTOR vCrId ; if ( ! GetFlatPartCutRegions( pGeomDB, nTrueId, bReducedCut, vCrId)) { @@ -1038,10 +1195,27 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } // le confronto con le regioni degli altri pezzi for ( int nCrId : vCrId) { - for ( int nOthRegId : vReg) { + for ( int nOthRegId : vOthReg) { ExeSurfFrRotateSimpleNoCollision( nCrId, nOthRegId, ptCen, dAng, RTY_GLOB) ; } } + // ----------------------------------------- + // recupero regioni in basso di lavorazione del pezzo + INTVECTOR vDwnCrId ; + if ( ! GetFlatPartDownCutRegions( pGeomDB, nTrueId, bReducedCut, vDwnCrId)) { + bOk = false ; + break ; + } + // le confronto con le regioni in basso degli altri pezzi + for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) { + for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) { + if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { + int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; + int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; + ExeSurfFrRotateSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ; + } + } + } } // Se errore diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 1c035cf202b7c3f087a697433865d8f6665d4a9c..a7723c8318f763d0e62f2c93d56047d1cd6029ec 100644 GIT binary patch delta 121 zcmdlNy)Jsg4>nd)1|0^&&Hve)nVIt$3@3l&)ZH8)<;S@B5VsaHRPwysWv0o;1asgD k9F*J`H?Iooa1|0@N2II{a#jZ0=zQUQqng`-e4&>I|T)bL=ie