diff --git a/Chiseling.cpp b/Chiseling.cpp index 033403d..8667539 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -397,7 +397,8 @@ Chiseling::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -413,7 +414,8 @@ Chiseling::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -501,6 +503,10 @@ Chiseling::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1016,7 +1022,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; return true ; @@ -1052,7 +1058,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; } diff --git a/Drilling.cpp b/Drilling.cpp index 1c4d5c7..e6dd171 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -519,7 +519,8 @@ Drilling::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore generale e gestore DB geometrico if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // se lavorazione standard if ( m_Params.m_nSubType == DRI_SUB_STD) { @@ -550,7 +551,8 @@ Drilling::SetGeometry( const SELVECTOR& vIds) } } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty()) ; } @@ -618,6 +620,10 @@ Drilling::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/FiveAxisMilling.cpp b/FiveAxisMilling.cpp index 5c4efbd..df8d732 100644 --- a/FiveAxisMilling.cpp +++ b/FiveAxisMilling.cpp @@ -413,7 +413,8 @@ FiveAxisMilling::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -429,7 +430,8 @@ FiveAxisMilling::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -578,6 +580,10 @@ FiveAxisMilling::MyApply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/GenMachining.cpp b/GenMachining.cpp index 394b07a..cb7f981 100644 --- a/GenMachining.cpp +++ b/GenMachining.cpp @@ -411,7 +411,8 @@ GenMachining::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -427,7 +428,8 @@ GenMachining::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -555,6 +557,10 @@ GenMachining::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/Milling.cpp b/Milling.cpp index 5dfb462..27b5418 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -49,6 +49,13 @@ const double OSC_MIN_LEN = 0.1 ; const double LIM_DOWN_APPRZ = -0.5 ; const double DELTA_ELEV_RAD = 4.0 ; const double LIM_SIN_DIFF_DIR = 0.175 ; +// Parametri avanzati da UserNotes +const string UN_MAXELEV = "MaxElev" ; +const string UN_OUTRAW = "OutRaw" ; +const string UN_SIDEELEV = "SideElev" ; +const string UN_TRIMEXT = "TrimExt" ; +const string UN_VTFACEUSE = "VtFaceUse" ; +const string UN_EDGESFACEUSE = "EdgesFaceUse" ; //------------------------------ Errors -------------------------------------- // 2301 = "Error in Milling : UpdateToolData failed" @@ -377,7 +384,7 @@ Milling::SetParam( int nType, int nVal) if ( ! m_Params.VerifyFaceUse( nVal)) return false ; if ( nVal != m_Params.m_nFaceUse) - m_nStatus |= MCH_ST_PARAM_MODIF ; + m_nStatus |= ( MCH_ST_PARAM_MODIF | MCH_ST_GEO_MODIF) ; m_Params.m_nFaceUse = nVal ; return true ; } @@ -576,8 +583,17 @@ Milling::SetParam( int nType, const string& sVal) m_Params.m_sSysNotes = sVal ; return true ; case MPA_USERNOTES : - if ( sVal != m_Params.m_sUserNotes) + if ( sVal != m_Params.m_sUserNotes) { m_nStatus |= MCH_ST_PARAM_MODIF ; + Vector3d vtNew ; GetValInNotes( sVal, UN_VTFACEUSE, vtNew) ; + Vector3d vtOri ; GetValInNotes( m_Params.m_sUserNotes, UN_VTFACEUSE, vtOri) ; + if ( ! AreSameVectorApprox( vtNew, vtOri)) + m_nStatus |= MCH_ST_GEO_MODIF ; + INTVECTOR vnNew ; GetValInNotes( sVal, UN_EDGESFACEUSE, vnNew) ; + INTVECTOR vnOri ; GetValInNotes( m_Params.m_sUserNotes, UN_EDGESFACEUSE, vnOri) ; + if ( vnNew != vnOri) + m_nStatus |= MCH_ST_GEO_MODIF ; + } m_Params.m_sUserNotes = sVal ; return true ; case MPA_INITANGS : @@ -601,7 +617,8 @@ Milling::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve, tutti testi o tutte facce) int nType = GEO_NONE ; @@ -617,7 +634,8 @@ Milling::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -725,6 +743,10 @@ Milling::Apply( bool bRecalc, bool bPostApply) } m_nHeadSolCh = m_pMchMgr->GetCurrMachine()->GetHeadSolCh( m_TParams.m_sHead) ; + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1376,10 +1398,14 @@ Milling::GetCurves( SelData Id, ICURVEPLIST& lstPC) nToolDir = TOOL_PARAL ; int nFaceUse = ( m_Params.m_nFaceUse & 31) ; Vector3d vtFaceUse ; - if ( GetValInNotes( m_Params.m_sUserNotes, "VtFaceUse", vtFaceUse) && ! vtFaceUse.IsSmall()) + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTFACEUSE, vtFaceUse) && ! vtFaceUse.IsSmall()) nFaceUse = FACE_VERSOR ; + INTVECTOR vnEdgesFaceUse ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_EDGESFACEUSE, vnEdgesFaceUse) && ! vnEdgesFaceUse.empty()) + nFaceUse = FACE_EDGES ; double dSawThick = ( ( m_TParams.m_nType & TF_SAWBLADE) != 0 ? m_TParams.m_dThick : 0) ; - AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, vtFaceUse, dSawThick) ; + if ( ! AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, vtFaceUse, vnEdgesFaceUse, dSawThick)) + return false ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; return true ; @@ -1404,8 +1430,11 @@ Milling::GetCurves( SelData Id, ICURVEPLIST& lstPC) nToolDir = TOOL_PARAL ; int nFaceUse = ( m_Params.m_nFaceUse & 31) ; Vector3d vtFaceUse ; - if ( GetValInNotes( m_Params.m_sUserNotes, "VtFaceUse", vtFaceUse) && ! vtFaceUse.IsSmall()) + if ( GetValInNotes( m_Params.m_sUserNotes, UN_VTFACEUSE, vtFaceUse) && ! vtFaceUse.IsSmall()) nFaceUse = FACE_VERSOR ; + INTVECTOR vnEdgesFaceUse ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_EDGESFACEUSE, vnEdgesFaceUse) && ! vnEdgesFaceUse.empty()) + nFaceUse = FACE_EDGES ; double dSawThick = ( ( m_TParams.m_nType & TF_SAWBLADE) != 0 ? m_TParams.m_dThick : 0) ; // determino intervallo di chunk int nCstart = 0 ; @@ -1414,6 +1443,10 @@ Milling::GetCurves( SelData Id, ICURVEPLIST& lstPC) nCstart = Id.nSub ; nCend = nCstart + 1 ; } + else if ( nFaceUse == FACE_EDGES) { + nCstart = 0 ; + nCend = nCstart + 1 ; + } // ciclo sui chunk for ( int nC = nCstart ; nC < nCend ; ++ nC) { // recupero i contorni del chunk @@ -1428,7 +1461,8 @@ Milling::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, vtFaceUse, dSawThick) ; + if ( ! AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, vtFaceUse, vnEdgesFaceUse, dSawThick)) + return false ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; } @@ -1834,13 +1868,13 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) return false ; // eventuale imposizione massima elevazione da note utente double dMaxElev ; - if ( GetValInNotes( m_Params.m_sUserNotes, "MaxElev", dMaxElev) && dElev > dMaxElev) + if ( GetValInNotes( m_Params.m_sUserNotes, UN_MAXELEV, dMaxElev) && dElev > dMaxElev) dElev = dMaxElev ; // eventuale aggiuntivo all'elevazione per l'oscillazione double dAddElev = ( bPathOscEnable ? abs( m_Params.m_dOscHeight) : 0) ; // eventuale elevazione di fianco (solo per lama) double dSideElev = 0 ; - GetValInNotes( m_Params.m_sUserNotes, "SideElev", dSideElev) ; + GetValInNotes( m_Params.m_sUserNotes, UN_SIDEELEV, dSideElev) ; // verifico che lo step dell'utensile sia sensato double dOkStep = 0 ; @@ -1960,7 +1994,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // recupero eventuale flag di inizio forzato fuori dal grezzo int nStartOutRaw = 0 ; - GetValInNotes( m_Params.m_sUserNotes, "OutRaw", nStartOutRaw) ; + GetValInNotes( m_Params.m_sUserNotes, UN_OUTRAW, nStartOutRaw) ; m_bStartOutRaw = (( nStartOutRaw & 1) != 0) ; m_bEndOutRaw = (( nStartOutRaw & 2) != 0) ; @@ -3936,7 +3970,7 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT // recupero eventuale superficie trimesh chiusa per trim/extend int nTriExtCstm = GDB_ID_NULL ; int nTesId ; - if ( GetValInNotes( m_Params.m_sUserNotes, "TrimExt", nTesId)) { + if ( GetValInNotes( m_Params.m_sUserNotes, UN_TRIMEXT, nTesId)) { const ISurfTriMesh* pTes = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nTesId)) ; if ( pTes != nullptr && pTes->IsClosed()) nTriExtCstm = nTesId ; @@ -4112,7 +4146,7 @@ Milling::AddSawOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtT // recupero eventuale superficie trimesh chiusa per trim/extend int nTriExtCstm = GDB_ID_NULL ; int nTesId ; - if ( GetValInNotes( m_Params.m_sUserNotes, "TrimExt", nTesId)) { + if ( GetValInNotes( m_Params.m_sUserNotes, UN_TRIMEXT, nTesId)) { const ISurfTriMesh* pTes = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nTesId)) ; if ( pTes != nullptr && pTes->IsClosed()) nTriExtCstm = nTesId ; diff --git a/Mortising.cpp b/Mortising.cpp index fbd9b71..b160acc 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -273,7 +273,7 @@ Mortising::SetParam( int nType, int nVal) if ( ! m_Params.VerifyFaceUse( nVal)) return false ; if ( nVal != m_Params.m_nFaceUse) - m_nStatus |= MCH_ST_PARAM_MODIF ; + m_nStatus |= ( MCH_ST_PARAM_MODIF | MCH_ST_GEO_MODIF) ; m_Params.m_nFaceUse = nVal ; return true ; } @@ -417,7 +417,8 @@ Mortising::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -433,7 +434,8 @@ Mortising::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -521,6 +523,10 @@ Mortising::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1022,7 +1028,7 @@ Mortising::GetCurve( SelData Id) else nToolDir = TOOL_PAR_SLANT ; int nFaceUse = ( m_Params.m_nFaceUse & 31) ; - AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, V_NULL, m_TParams.m_dThick, 2) ; + AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, V_NULL, {}, m_TParams.m_dThick, 2) ; // la restituisco return Release( pCrvCompo) ; } diff --git a/Operation.cpp b/Operation.cpp index 0bf574b..3cdd8b7 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -990,7 +990,7 @@ GetDirInFacePerpSide( int nFaceUse, const Vector3d& vtFaceUse, const Vector3d& v //---------------------------------------------------------------------------- bool Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, const Vector3d& vtFaceUse, - double dToolThick, int nGrade) + const INTVECTOR& vnEdgesFaceUse, double dToolThick, int nGrade) { // copia della curva originale PtrOwner pCopy( pCrvCompo->Clone()) ; @@ -1023,6 +1023,18 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF if ( dUmax != 0) pCrvCompo->ChangeStartPoint( dUmax) ; } + // se altrimenti richiesta una parte del contorno + else if ( nFaceUse == FACE_EDGES) { + // verifico che il vettore degli indici dei lati non sia vuoto + if ( vnEdgesFaceUse.empty()) + return false ; + // parametri di trim + double dUStart = vnEdgesFaceUse.front() ; + double dUEnd = vnEdgesFaceUse.back() + 1 ; + // taglio le parti che non interessano + if ( ! pCrvCompo->TrimStartEndAtParam( dUStart, dUEnd)) + return false ; + } // altrimenti else { // determino la direzione di riferimento diff --git a/Operation.h b/Operation.h index faa6fee..f21d784 100644 --- a/Operation.h +++ b/Operation.h @@ -168,7 +168,7 @@ class Operation : public IUserObj bool GetCurrRawsGlobBox( BBox3d& b3Raw) const ; bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, const Vector3d& vtFaceUse, - double dToolThick, int nGrade = 3) ; + const INTVECTOR& vnEdgesFaceUse, double dToolThick, int nGrade = 3) ; bool ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp = false) const ; bool ApproxWithLines( ICurveComposite* pCompo, bool bFeed = true) const ; bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) const ; @@ -326,7 +326,8 @@ inline Operation* GetOperation( IUserObj* pUserObj) // tipo posizione utensile enum { TOOL_PARAL = 1, TOOL_ORTHO = 2, TOOL_ORTUP = 3, TOOL_PAR_SLANT= 4} ; // tipo di utilizzo contorno faccia -enum { FACE_DOWN = 1, FACE_TOP = 2, FACE_FRONT = 3, FACE_BACK = 4, FACE_LEFT = 5, FACE_RIGHT = 6, FACE_CONT = 7, FACE_VERSOR = 8} ; +enum { FACE_DOWN = 1, FACE_TOP = 2, FACE_FRONT = 3, FACE_BACK = 4, FACE_LEFT = 5, FACE_RIGHT = 6, + FACE_CONT = 7, FACE_VERSOR = 8, FACE_EDGES = 9} ; // risultato di SpecialTestCollisionAvoid enum { SCAV_ERROR = -1, SCAV_COLLIDE = 0, SCAV_AVOID = 1, SCAV_TOTEST = 2} ; // ordine di movimento assi nei link diff --git a/Pocketing.cpp b/Pocketing.cpp index 6ab2f29..b4f9b1c 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -43,6 +43,16 @@ using namespace std ; +//------------------------------ Constants ------------------------------------ +static int LINK_CURVE_PROP = -3 ; +static string KEY_OPEN = "OPEN" ; +// Parametri avanzati da UserNotes +const string UN_MAXELEV = "MaxElev" ; +const string UN_OPEN = "Open" ; +const string UN_OPENOUTRAW = "OpenOutRaw" ; +const string UN_OPENMINSAFE = "OpenMinSafe" ; +const string UN_MAXOPTSIZE = "MaxOptSize" ; + //------------------------------ Errors -------------------------------------- // 2401 = "Error in Pocketing : UpdateToolData failed" // 2402 = "Error in Pocketing : Open Contour" @@ -84,10 +94,6 @@ using namespace std ; // 2457 = "Warning in Pocketing : machining step (xxx) bigger than MaxMaterial (yyy)" // 2458 = "Warning in Pocketing : machining depth (xxx) bigger than MaxMaterial (yyy)" -//---------------------------------------------------------------------------- -static string KEY_OPEN = "OPEN" ; -static int LINK_CURVE_PROP = -3 ; - //---------------------------------------------------------------------------- #if POCKETING_NT != 1 USEROBJ_REGISTER( GetOperationClass( OPER_POCKETING), Pocketing) ; @@ -506,7 +512,8 @@ Pocketing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -522,7 +529,8 @@ Pocketing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -628,6 +636,10 @@ Pocketing::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1229,7 +1241,7 @@ Pocketing::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; return true ; @@ -1267,7 +1279,7 @@ Pocketing::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; } @@ -1608,7 +1620,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) return false ; // eventuale imposizione massima elevazione da note utente double dMaxElev ; - if ( GetValInNotes( m_Params.m_sUserNotes, "MaxElev", dMaxElev) && dElev > dMaxElev) + if ( GetValInNotes( m_Params.m_sUserNotes, UN_MAXELEV, dMaxElev) && dElev > dMaxElev) dElev = dMaxElev ; // verifico che lo step dell'utensile sia sensato @@ -1679,11 +1691,11 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) // recupero eventuale flag di lato aperto forzato fuori dal grezzo int nOpenOutRaw ; - m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, "OpenOutRaw", nOpenOutRaw) && nOpenOutRaw != 0) ; + m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, UN_OPENOUTRAW, nOpenOutRaw) && nOpenOutRaw != 0) ; // recupero eventuale minima lunghezza di attacco su lato aperto m_dOpenMinSafe = 0 ; - GetValInNotes( m_Params.m_sUserNotes, "OpenMinSafe", m_dOpenMinSafe) ; + GetValInNotes( m_Params.m_sUserNotes, UN_OPENMINSAFE, m_dOpenMinSafe) ; // se richiesta anteprima if ( nPvId != GDB_ID_NULL) { @@ -3881,7 +3893,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs, Vector3d vtOrtho = OrthoCompo( vtOtherDir, vtDir) ; double dPocketSize = vtOrtho.Len() ; double dMaxOptSize = m_Params.m_dSideStep ; - GetValInNotes( m_Params.m_sUserNotes, "MaxOptSize", dMaxOptSize) ; + GetValInNotes( m_Params.m_sUserNotes, UN_MAXOPTSIZE, dMaxOptSize) ; if ( ( ( bSomeOpen && dPocketSize < m_TParams.m_dDiam + EPS_SMALL) || abs( dPocketSize - m_TParams.m_dDiam) < EPS_SMALL) && dPocketSize < dMaxOptSize + 10 * EPS_SMALL) { if ( nReg == 0) { @@ -5507,10 +5519,7 @@ bool Pocketing::GetForcedClosed( void) { int nOpen ; - if ( GetValInNotes( m_Params.m_sUserNotes, "Open", nOpen) && nOpen == 0) - return true ; - else - return false ; + return ( GetValInNotes( m_Params.m_sUserNotes, UN_OPEN, nOpen) && nOpen == 0) ; } //---------------------------------------------------------------------------- diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 13ff64e..645f949 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -48,6 +48,17 @@ using namespace std ; +//------------------------------ Constants ------------------------------------ +static string KEY_OPEN = "OPEN" ; +static string KEY_THICK = "THICK" ; +static int LINK_CURVE_PROP = -3 ; +// Parametri avanzati da UserNotes +const string UN_MAXELEV = "MaxElev" ; +const string UN_OPEN = "Open" ; +const string UN_OPENOUTRAW = "OpenOutRaw" ; +const string UN_OPENMINSAFE = "OpenMinSafe" ; +const string UN_OPENEXTENSION = "OpenExtension" ; + //------------------------------ Errors -------------------------------------- // 2401 = "Error in PocketingNT : UpdateToolData failed" // 2402 = "Error in PocketingNT : Open Contour" @@ -91,11 +102,6 @@ using namespace std ; // 2458 = "Warning in PocketingNT : machining depth (xxx) bigger than MaxMaterial (yyy)" // 2459 = "Warning in PocketingNT : Steps too far away from Raw" -//---------------------------------------------------------------------------- -static string KEY_OPEN = "OPEN" ; -static string KEY_THICK = "THICK" ; -static int LINK_CURVE_PROP = -3 ; - //---------------------------------------------------------------------------- // _debug #define DEBUG_OPEN_EDGE_EXTENSION 0 @@ -523,7 +529,8 @@ PocketingNT::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve o tutte facce) int nType = GEO_NONE ; @@ -539,7 +546,8 @@ PocketingNT::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -645,6 +653,10 @@ PocketingNT::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1256,7 +1268,7 @@ PocketingNT::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco if ( m_bAllClose) ResetCurveAllTempProp( pCrvCompo) ; @@ -1297,7 +1309,7 @@ PocketingNT::GetCurves( SelData Id, ICURVEPLIST& lstPC) // la porto in globale pCrvCompo->ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, 0) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTHO, FACE_CONT, V_NULL, {}, 0) ; // la restituisco lstPC.emplace_back( Release( pCrvCompo)) ; } @@ -1402,8 +1414,7 @@ PocketingNT::Chain( int nGrpDestId) // vettore selettori delle curve originali SELVECTOR vInds ; // flag per imposizione lati chiusi - m_bAllClose = false ; - GetValInNotes( m_Params.m_sUserNotes, "bAllClose", m_bAllClose) ; + m_bAllClose = GetForcedClosed() ; // recupero tutte le curve e le porto in globale for ( const auto& Id : m_vId) { // prendo le curve @@ -1895,9 +1906,9 @@ PocketingNT::ExtendOpenEdgesToRaw( ICurveComposite* pCompo, const Vector3d& vtEx #endif // definisco offset di estensione per tratti aperti - double dOffs = 0 ; m_dOpenExtension = 0 ; - GetValInNotes( m_Params.m_sUserNotes, "OpenExtension", m_dOpenExtension) ; + GetValInNotes( m_Params.m_sUserNotes, UN_OPENEXTENSION, m_dOpenExtension) ; + double dOffs = 0 ; if ( m_dOpenExtension < EPS_SMALL) dOffs = max( BBoxRawCut.GetDimX(), BBoxRawCut.GetDimY()) + m_TParams.m_dDiam ; else @@ -2285,7 +2296,7 @@ PocketingNT::ProcessPath( int nPathId, int nPvId, int nClId) } // eventuale imposizione massima elevazione da note utente double dMaxElev ; - if ( GetValInNotes( m_Params.m_sUserNotes, "MaxElev", dMaxElev) && dElev > dMaxElev) + if ( GetValInNotes( m_Params.m_sUserNotes, UN_MAXELEV, dMaxElev) && dElev > dMaxElev) dElev = dMaxElev ; // verifico che lo step dell'utensile sia sensato @@ -2376,11 +2387,11 @@ PocketingNT::ProcessPath( int nPathId, int nPvId, int nClId) // recupero eventuale flag di lato aperto forzato fuori dal grezzo int nOpenOutRaw ; - m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, "OpenOutRaw", nOpenOutRaw) && nOpenOutRaw != 0) ; + m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, UN_OPENOUTRAW, nOpenOutRaw) && nOpenOutRaw != 0) ; // recupero eventuale minima lunghezza di attacco su lato aperto m_dOpenMinSafe = 5. ; - GetValInNotes( m_Params.m_sUserNotes, "OpenMinSafe", m_dOpenMinSafe) ; + GetValInNotes( m_Params.m_sUserNotes, UN_OPENMINSAFE, m_dOpenMinSafe) ; // se richiesta anteprima if ( nPvId != GDB_ID_NULL) { @@ -3747,10 +3758,7 @@ bool PocketingNT::GetForcedClosed( void) { int nOpen ; - if ( GetValInNotes( m_Params.m_sUserNotes, "Open", nOpen) && nOpen == 0) - return true ; - else - return false ; + return ( GetValInNotes( m_Params.m_sUserNotes, UN_OPEN, nOpen) && nOpen == 0) ; } //---------------------------------------------------------------------------- diff --git a/SawFinishing.cpp b/SawFinishing.cpp index fc4fef6..e3001b8 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -449,7 +449,8 @@ SawFinishing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili for ( const auto& Id : vIds) { @@ -464,7 +465,8 @@ SawFinishing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty()) ; } @@ -496,6 +498,10 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 1f5a784..343372a 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -432,7 +432,8 @@ SawRoughing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili for ( const auto& Id : vIds) { @@ -447,7 +448,8 @@ SawRoughing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty()) ; } @@ -479,6 +481,10 @@ SawRoughing::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/Sawing.cpp b/Sawing.cpp index 9361754..98e5a30 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -538,7 +538,8 @@ Sawing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili int nType = GEO_NONE ; @@ -554,7 +555,8 @@ Sawing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -647,6 +649,10 @@ Sawing::Apply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { @@ -1255,7 +1261,7 @@ Sawing::GetCurve( SelData Id) pCrvCompo->ToGlob( frGlob) ; vtN.ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, V_NULL, 0, 1) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, V_NULL, {}, 0, 1) ; // aggiusto lato lavoro e inverti, angolo di fianco e lato mandrino if ( m_Params.m_nWorkSide == SAW_WS_CENTER) m_Params.m_nWorkSide = SAW_WS_RIGHT ; @@ -1304,7 +1310,7 @@ Sawing::GetCurve( SelData Id) pCrvCompo->ToGlob( frGlob) ; vtN.ToGlob( frGlob) ; // sistemazioni varie - AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, V_NULL, 0, 1) ; + AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, V_NULL, {}, 0, 1) ; // aggiusto lato lavoro e inverti, angolo di fianco e lato mandrino if ( m_Params.m_nWorkSide == SAW_WS_CENTER) m_Params.m_nWorkSide = SAW_WS_RIGHT ; diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index d07ee6a..2786187 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -478,7 +478,8 @@ SurfFinishing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili for ( const auto& Id : vIds) { @@ -493,7 +494,8 @@ SurfFinishing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty()) ; } @@ -546,6 +548,10 @@ SurfFinishing::MyApply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/SurfRoughing.cpp b/SurfRoughing.cpp index 2bd7c27..cf7e65e 100644 --- a/SurfRoughing.cpp +++ b/SurfRoughing.cpp @@ -505,7 +505,8 @@ SurfRoughing::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili for ( const auto& Id : vIds) { @@ -520,7 +521,8 @@ SurfRoughing::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty()) ; } @@ -573,6 +575,10 @@ SurfRoughing::MyApply( bool bRecalc, bool bPostApply) return false ; } + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) { diff --git a/WaterJetting.cpp b/WaterJetting.cpp index 5173815..75b4f7e 100644 --- a/WaterJetting.cpp +++ b/WaterJetting.cpp @@ -501,7 +501,8 @@ WaterJetting::SetGeometry( const SELVECTOR& vIds) // verifico validità gestore DB geometrico if ( m_pGeomDB == nullptr) return false ; - // reset della geometria corrente + // copia temporanea e reset della geometria corrente + SELVECTOR vOldId = m_vId ; m_vId.clear() ; // verifico che gli identificativi rappresentino delle entità ammissibili (tutte curve, tutti testi o tutte facce) int nType = GEO_NONE ; @@ -517,7 +518,8 @@ WaterJetting::SetGeometry( const SELVECTOR& vIds) m_vId.emplace_back( Id) ; } // aggiorno lo stato - m_nStatus |= MCH_ST_GEO_MODIF ; + if ( m_vId != vOldId) + m_nStatus |= MCH_ST_GEO_MODIF ; // restituisco presenza geometria da lavorare return ( ! m_vId.empty() || vIds.empty()) ; } @@ -628,6 +630,10 @@ WaterJetting::Apply( bool bRecalc, bool bPostApply) } m_nHeadSolCh = m_pMchMgr->GetCurrMachine()->GetHeadSolCh( m_TParams.m_sHead) ; + // se modificata geometria, necessario ricalcolo + if ( ( m_nStatus & MCH_ST_GEO_MODIF) != 0) + bRecalc = true ; + // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && ! bToolChanged && ( m_nStatus == MCH_ST_OK || m_nStatus == MCH_ST_NO_POSTAPPL)) {