From 376695f29eb1507c45f489870a128e56b8830f24 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 7 Mar 2016 09:56:52 +0000 Subject: [PATCH] EgtExecutor 1.6n12 : - aggiunta gestione aree rovinate in nesting. --- EXE_Const.h | 6 +- EXE_NstMachining.cpp | 2 - EXE_NstPartNesting.cpp | 152 +++++++++++++++++++++++++++++++++++------ EgtExecutor.rc | Bin 11710 -> 11710 bytes 4 files changed, 137 insertions(+), 23 deletions(-) diff --git a/EXE_Const.h b/EXE_Const.h index 7f0f009..f1fc672 100644 --- a/EXE_Const.h +++ b/EXE_Const.h @@ -16,11 +16,13 @@ #include //---------------------------------------------------------------------------- -// Curve originali di composite +// Curve originali di composite o curva originale di area danneggiata static 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" ; -static std::string NST_SHEET_OUTREG = "SheetOut" ; \ No newline at end of file +// Per Sheets (Nesting) +static std::string NST_SHEET_OUTREG = "SheetOut" ; +static std::string NST_DAMAGED_REG = "DmgReg" ; diff --git a/EXE_NstMachining.cpp b/EXE_NstMachining.cpp index 2c5c652..16d34aa 100644 --- a/EXE_NstMachining.cpp +++ b/EXE_NstMachining.cpp @@ -201,8 +201,6 @@ ExeVerifyCutAsSplitting( int nMchId) pGseCtx->m_pMachMgr->MachiningPreview( true) ; // se già al bordo grezzo, faccio verifica if ( ! bLiToModif && ! bLoToModif) { - // aggiorno preview - pGseCtx->m_pMachMgr->MachiningPreview( true) ; // verifico interferenza int nRes ; if ( ExeVerifyMachining( nMchId, nRes) && nRes == FMI_NONE) diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 1db4a5a..3ca23d3 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -115,28 +115,29 @@ ExeCreateOutRegion( int nParentId, double dXmin, double dYmin, double dXmax, dou // la converto in curva composita PtrOwner pCompo( CreateCurveComposite()) ; if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) - return GDB_ID_NULL ; + return false ; // costruisco la regione piana SurfFlatRegionByContours SfrCntr ; SfrCntr.AddCurve( Release( pCompo)) ; ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ; if ( pSfr == nullptr) - return GDB_ID_NULL ; + return false ; // recupero il riferimento del gruppo di inserimento Frame3d frLoc ; if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; + return false ; // porto la regione nel riferimento pSfr->ToLoc( frLoc) ; // inserisco la superficie nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ; if ( nId == GDB_ID_NULL) - return GDB_ID_NULL ; + return false ; // assegno nome e la dichiaro di sistema e invisibile pGeomDB->SetName( nId, NST_SHEET_OUTREG) ; pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ; pGeomDB->SetMaterial( nId, INVISIBLE) ; - return ( nId != GDB_ID_NULL) ; + + return true ; } //---------------------------------------------------------------------------- @@ -154,16 +155,16 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) // recupero la curva ICurve* pOutCrv = GetCurve( pGeomDB->GetGeoObj( nOutCrvId)) ; if ( pOutCrv == nullptr) - return GDB_ID_NULL ; + return false ; // verifico sia chiusa if ( ! pOutCrv->IsClosed()) - return GDB_ID_NULL ; + return false ; // la approssimo con linee const double LIN_TOL_STD = 0.1 ; const double ANG_TOL_STD_DEG = 15 ; PolyLine PL ; if ( ! pOutCrv->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) - return GDB_ID_NULL ; + return false ; // porto la polilinea in globale Frame3d frOutCrv ; pGeomDB->GetGlobFrame( nOutCrvId, frOutCrv) ; @@ -171,7 +172,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) // se antioraria la inverto double dArea ; if ( ! PL.GetAreaXY( dArea)) - return GDB_ID_NULL ; + return false ; if ( dArea > 0) PL.Invert() ; // la appiattisco sulla Z iniziale @@ -181,7 +182,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) // la converto in curva composita PtrOwner pCompo( CreateCurveComposite()) ; if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) - return GDB_ID_NULL ; + return false ; // ne ricavo il bbox e lo ingrandisco BBox3d b3Box ; pCompo->GetLocalBBox( b3Box) ; @@ -192,7 +193,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) DistPointCurve distPC( b3Box.GetMax(), *Get( pCompo)) ; if ( ! distPC.GetParamAtMinDistPoint( 0, dU, nFlag) || ! pCompo->ChangeStartPoint( dU)) - return GDB_ID_NULL ; + return false ; // accorcio inizio pCompo->TrimStartAtLen( 5 * EPS_SMALL) ; // creo curva della parte esterna @@ -211,31 +212,103 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) // la converto in curva composita PtrOwner pCompo2( CreateCurveComposite()) ; if ( IsNull( pCompo2) || ! pCompo2->FromPolyLine( PL2)) - return GDB_ID_NULL ; + return false ; // unisco le due curve composite if ( ! pCompo->AddCurve( Release( pCompo2))) - return GDB_ID_NULL ; + return false ; // costruisco la regione piana SurfFlatRegionByContours SfrCntr ; SfrCntr.AddCurve( Release( pCompo)) ; ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ; if ( pSfr == nullptr) - return GDB_ID_NULL ; + return false ; // recupero il riferimento del gruppo di inserimento Frame3d frLoc ; if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; + return false ; // porto la regione nel riferimento pSfr->ToLoc( frLoc) ; // inserisco la superficie nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ; if ( nId == GDB_ID_NULL) - return GDB_ID_NULL ; + return false ; // assegno nome e la dichiaro di sistema e invisibile pGeomDB->SetName( nId, NST_SHEET_OUTREG) ; pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ; pGeomDB->SetMaterial( nId, INVISIBLE) ; - return ( nId != GDB_ID_NULL) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +ExeCreateDamagedRegion( int nParentId, int nDmgCrvId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + + // verifico se esiste già la regione associata + int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_DAMAGED_REG) ; + while ( nRegId != GDB_ID_NULL) { + // recupero l'indice della curva di origine + int nOriId ; + if ( pGeomDB->GetInfo( nRegId, CRV_ORIG, nOriId) && nOriId == nDmgCrvId) + return true ; + // passo alla regione successiva + nRegId = pGeomDB->GetNextName( nRegId, NST_DAMAGED_REG) ; + } + + // recupero la curva e verifico sia chiusa + ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nDmgCrvId)) ; + if ( pCrv == nullptr || ! pCrv->IsClosed()) + return false ; + // la approssimo con linee + const double LIN_TOL_STD = 0.1 ; + const double ANG_TOL_STD_DEG = 15 ; + PolyLine PL ; + if ( ! pCrv->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) + return GDB_ID_NULL ; + // porto la polilinea in globale + Frame3d frDmgCrv ; + pGeomDB->GetGlobFrame( nDmgCrvId, frDmgCrv) ; + PL.ToGlob( frDmgCrv) ; + // se oraria la inverto + double dArea ; + if ( ! PL.GetAreaXY( dArea)) + return false ; + if ( dArea < 0) + PL.Invert() ; + // la appiattisco sulla Z iniziale + Point3d ptP ; + PL.GetFirstPoint( ptP) ; + PL.Flatten( ptP.z) ; + // la converto in curva composita + PtrOwner pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) + return false ; + // costruisco la regione piana + SurfFlatRegionByContours SfrCntr ; + SfrCntr.AddCurve( Release( pCompo)) ; + ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ; + if ( pSfr == nullptr) + return false ; + // recupero il riferimento del gruppo di inserimento + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return false ; + // porto la regione nel riferimento + pSfr->ToLoc( frLoc) ; + // inserisco la superficie nel DB + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ; + if ( nId == GDB_ID_NULL) + return false ; + // assegno nome, id curva di origine e la dichiaro di sistema e invisibile + pGeomDB->SetName( nId, NST_DAMAGED_REG) ; + pGeomDB->SetInfo( nId, CRV_ORIG, nDmgCrvId) ; + pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ; + pGeomDB->SetMaterial( nId, INVISIBLE) ; + + return true ; } //---------------------------------------------------------------------------- @@ -316,6 +389,22 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& return false ; } + // Verifico con le eventuali aree danneggiate + // recupero le aree + INTVECTOR vDmgReg ; + int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ; + while ( nId != GDB_ID_NULL) { + vDmgReg.emplace_back( nId) ; + nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ; + } + // regioni dei pezzi rispetto alle regioni delle aree danneggiate + for ( int nRegId : vReg) { + for ( int nDmgRegId : vDmgReg) { + if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nDmgRegId, 0) != REGC_OUT) + return false ; + } + } + // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse INTVECTOR vOthReg ; INTVECTOR vOthCutReg ; @@ -702,6 +791,14 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region)) return false ; + // Recupero le eventuali aree danneggiate + INTVECTOR vDmgReg ; + int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ; + while ( nId != GDB_ID_NULL) { + vDmgReg.emplace_back( nId) ; + nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ; + } + // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse INTVECTOR vOthReg ; INTVECTOR vOthCutReg ; @@ -725,7 +822,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; } - // Verifico movimento dei pezzi del cluster rispetto agli altri pezzi + // Verifico movimento dei pezzi del cluster rispetto al contorno, alle aree danneggiate e agli altri pezzi bool bOk = true ; double dLen = vtMoveXY.Len() ; double dPrevLen = dLen ; @@ -742,6 +839,11 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster // la confronto con il box MySurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nBoxId, false, false, scInfoCurr) ; + // la confronto con le aree danneggiate + for ( int nDmgRegId : vDmgReg) { + MySurfFrMoveSimpleNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nDmgRegId, false, false, scInfoCurr) ; + } // la confronto con le regioni degli altri pezzi for ( int nOthRegId : vOthReg) { MySurfFrMoveSimpleNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ; @@ -873,6 +975,14 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region)) return false ; + // Recupero le eventuali aree danneggiate + INTVECTOR vDmgReg ; + int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ; + while ( nId != GDB_ID_NULL) { + vDmgReg.emplace_back( nId) ; + nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ; + } + // Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse INTVECTOR vReg ; INTVECTOR vCutReg ; @@ -896,7 +1006,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; } - // Verifico rotazione dei pezzi del cluster rispetto agli altri pezzi + // Verifico rotazione dei pezzi del cluster rispetto al contorno, alle aree danneggiate e agli altri pezzi bool bOk = true ; double dAng = dRotAngDeg ; for ( auto nTrueId : vTrueIds) { @@ -908,6 +1018,10 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } // la confronto con il box ExeSurfFrRotateSimpleNoCollision( nRegId, nBoxId, ptCen, dAng, RTY_GLOB) ; + // la confronto con le aree danneggiate + for ( int nDmgRegId : vDmgReg) { + ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ; + } // la confronto con le regioni degli altri pezzi for ( int nOthRegId : vReg) { ExeSurfFrRotateSimpleNoCollision( nRegId, nOthRegId, ptCen, dAng, RTY_GLOB) ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5d0dbc21c286fe6b395f9cb449229ad504634beb..a23e736d12d34c962cdcd115322803e0c09a0a70 100644 GIT binary patch delta 97 zcmdlNy)SyhKQ>0A&HvflnHh~Hf8^BN93bV#xcLyb0g%7>yxe7`$;Si>pi&M>Zj75( e34^8nvt4JJyh#!!6(Ci|0@mORGsi)xjvD~trXpAX delta 97 zcmdlNy)SyhKQ>0g&HvflnHdcyf8^BN93bV#xcLyb0g%7>yxe7`$;Si>pi&M>Zj75( e34^8nvt4JJyh#!!6(Ci|0@mORGsi)xjvD~sBqC4%