diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index facd924..89845e5 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 2b0fdd3..94e39ce 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -89,6 +89,7 @@ class MachMgr : public IMachMgr bool ModifyRawPartHeight( int nRawId, double dHeight) override ; bool KeepRawPart( int nRawId) override ; bool VerifyRawPartPhase( int nRawId, int nPhase) const override ; + bool RemoveRawPartFromCurrPhase( int nRawId) override ; bool RemoveRawPart( int nRawId) override ; bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) override ; bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) override ; diff --git a/MachMgrPhases.cpp b/MachMgrPhases.cpp index 0c75557..8d38996 100644 --- a/MachMgrPhases.cpp +++ b/MachMgrPhases.cpp @@ -193,10 +193,16 @@ MachMgr::RemoveLastPhase( void) // se appartiene solo a questa fase, lo elimino if ( vPhase.size() == 1) RemoveRawPart( nRawId) ; - // altrimenti aggiorno l'elenco delle fasi di appartenenza + // altrimenti else { + // aggiorno l'elenco delle fasi di appartenenza vPhase.erase( iIter) ; m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, vPhase) ; + // se questa fase è la corrente, tolgo i pezzi dal grezzo e lo nascondo + if ( m_nCurrPhase == m_nPhasesCount) { + SwapRawPartParts( nRawId, false) ; + m_pGeomDB->SetStatus( nRawId, GDB_ST_OFF) ; + } } } // passo al prossimo diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index e4ee0e9..39c78fa 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -517,6 +517,36 @@ MachMgr::VerifyRawPartPhase( int nRawId, int nPhase) const return ( find( vPhase.begin(), vPhase.end(), nPhase) != vPhase.end()) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::RemoveRawPartFromCurrPhase( int nRawId) +{ + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero le fasi in cui è presente il grezzo (se manca è fase 1) + INTVECTOR vPhase ; + if ( ! m_pGeomDB->GetInfo( nRawId, MACH_RAW_PHASE, vPhase) || vPhase.empty()) + vPhase.emplace_back( 1) ; + // se non appartiene alla fase corrente, non devo fare alcunché + auto iIter = find( vPhase.begin(), vPhase.end(), m_nPhasesCount) ; + if ( iIter == vPhase.end()) + return true ; + // se appartiene solo a questa fase, lo elimino + if ( vPhase.size() == 1) + RemoveRawPart( nRawId) ; + // altrimenti + else { + // aggiorno l'elenco delle fasi di appartenenza + vPhase.erase( iIter) ; + m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, vPhase) ; + // tolgo i pezzi dal grezzo e lo nascondo + SwapRawPartParts( nRawId, false) ; + m_pGeomDB->SetStatus( nRawId, GDB_ST_OFF) ; + } + return true ; +} + //---------------------------------------------------------------------------- bool MachMgr::RemoveRawPart( int nRawId) diff --git a/Machining.cpp b/Machining.cpp index 019782f..7fe8377 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -20,6 +20,7 @@ #include "CamData.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EgkIntersCurves.h" #include "/EgtDev/Include/EGkIntersLineSurfTm.h" #include "/EgtDev/Include/EGkGeomDB.h" @@ -218,10 +219,26 @@ Machining::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3 while ( nRawId != GDB_ID_NULL) { // verifico che il grezzo compaia nella fase if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + // pre-filtro con il box BBox3d b3Raw ; int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) { - break ; + // porto il punto nel riferimento del grezzo + Frame3d frRaw ; + m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ; + Point3d ptPL = ptP ; + ptPL.ToLoc( frRaw) ; + // verifica con il contorno + int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ; + ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ; + if ( pCurve != nullptr) { + int nSide ; + double dDist ; + DistPointCurve distPC( ptPL, *pCurve) ; + if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL || + (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) + break ; + } } } // passo al grezzo successivo