diff --git a/Drilling.cpp b/Drilling.cpp index d65cd58..20f9f40 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -31,6 +31,7 @@ #include "/EgtDev/Include/EGnStringKeyVal.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EGkGeoFrame3d.h" +#include "/EgtDev/Include/EgtIniFile.h" using namespace std ; @@ -3575,6 +3576,28 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO // parametri per foro in doppio bool bDouble = ( GetDoubleType( m_Params.m_sUserNotes) != 0) ; double dDoubleLastStep = GetDoubleLastStep() ; + bool dDoubleParallel = false ; + if ( bDouble) { + // nel caso di lavorazione in doppio con flag nel file .ini abilitato, prima della risalita finale, risalgo dell'ultimo step compiuto + // se il piano di mirror presenta una normale circa parallela alla direzione del foro ( da BTL 1 grado di tolleranza) + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch != nullptr) { + string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; + const char* SEC_MACH = "Customizations" ; + const char* KEY_DRILLING_DOUBLE = "DrillingDoubleNT" ; + int nDrillingDouble = GetPrivateProfileInt( SEC_MACH, KEY_DRILLING_DOUBLE, 0, sMachIni.c_str()) ; + if ( nDrillingDouble == 1) { + int nDouble = GetDoubleType( m_Params.m_sUserNotes) ; + Vector3d vtNorm = V_INVALID ; + switch ( nDouble) { + case 1 : vtNorm = X_AX ; break ; + case 2 : vtNorm = Y_AX ; break ; + case 3 : vtNorm = Z_AX ; break ; + } + dDoubleParallel = ( vtNorm.IsValid() && hole.vtDir * vtNorm > cos( 1. * DEGTORAD)) ; + } + } + } // ciclo di affondamento a step const double MIN_STEP = 1 ; const double APPR_STEP = 1 ; @@ -3625,8 +3648,14 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO Point3d ptP3 = hole.ptIni - hole.vtDir * dLen ; if ( bHoleEnd) ptP3 -= hole.vtDir * dAddLen ; - if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL) - return false ; + if ( dDoubleParallel && i == nStep) { + if ( AddLinearMove( ptP3, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + return false ; + } + else { + if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL) + return false ; + } // aggiorno posizione e verifico se step completato dCurrLen = dLen ; if ( bHoleEnd || bStepEnd) @@ -3650,8 +3679,14 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO Point3d ptP4 = hole.ptIni - hole.vtDir * dLen ; if ( bHoleEnd) ptP4 -= hole.vtDir * dAddLen ; - if ( AddLinearMove( ptP4, bSplitArcs) == GDB_ID_NULL) - return false ; + if ( dDoubleParallel && i == nStep) { + if ( AddLinearMove( ptP4, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + return false ; + } + else { + if ( AddLinearMove( ptP4, bSplitArcs) == GDB_ID_NULL) + return false ; + } // aggiorno posizione e verifico se step completato dCurrLen = dLen ; if ( bHoleEnd || bStepEnd) @@ -3674,8 +3709,14 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO Point3d ptP5 = hole.ptIni - hole.vtDir * dLen ; if ( bHoleEnd) ptP5 -= hole.vtDir * dAddLen ; - if ( AddLinearMove( ptP5, bSplitArcs) == GDB_ID_NULL) - return false ; + if ( dDoubleParallel && i == nStep) { + if ( AddLinearMove( ptP5, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + return false ; + } + else { + if ( AddLinearMove( ptP5, bSplitArcs) == GDB_ID_NULL) + return false ; + } // aggiorno posizione dCurrLen = dLen ; } @@ -3684,6 +3725,16 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO // 6 -> ritorno all'approccio del foro SetFeed( GetEndFeed()) ; SetFlag( 104) ; // risalita sopra il foro + if ( dDoubleParallel) { + // aggiungo risalita aggiuntiva per lavorazione in doppio pari a due volte il LastStep + Point3d ptEnd ; GetCurrPos( ptEnd) ; + if ( AddLinearMove( ptEnd + min( 2. * dLastStep, dCurrLen) * hole.vtDir, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + return false ; + // aggiungo discensa di LastStep per simmetria con secondo utensile + GetCurrPos( ptEnd) ; + if ( AddLinearMove( ptEnd - dLastStep * hole.vtDir, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + return false ; + } if ( AddLinearMove( ptP1, bSplitArcs) == GDB_ID_NULL) return false ; diff --git a/Machining.cpp b/Machining.cpp index 83bce12..8d56406 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -596,14 +596,22 @@ Machining::PrepareToolPreview() RemoveToolPreview() ; return false ; } + m_pGeomDB->SetName( nStdIdDBL, MCH_ST_DBL) ; + m_pGeomDB->SetLevel( nStdIdDBL, GDB_LV_TEMP) ; } - m_pGeomDB->SetName( nStdIdDBL, MCH_ST_DBL) ; - m_pGeomDB->SetLevel( nStdIdDBL, GDB_LV_TEMP) ; } // altrimenti lo svuoto else m_pGeomDB->EmptyGroup( nStdIdDBL) ; + // reset delle variabili membro + m_nPreviewHeadId = GDB_ID_NULL ; + m_nPreviewHeadIdDBL = GDB_ID_NULL ; + m_nPreviewToolTip = GDB_ID_NULL ; + m_nPreviewToolTipDBL = GDB_ID_NULL ; + m_vPreviewAxisIds.clear() ; + m_vPreviewAxisIdsBBL.clear() ; + // preparo l'anteprima per il gruppo ST bool bOk = true ; if ( nStId != GDB_ID_NULL) { @@ -740,16 +748,8 @@ Machining::GetToolPreviewNext( int nEntId, int nParentId, int nStId) const //---------------------------------------------------------------------------- int -Machining::GetToolPreviewPrev( int nEntId, int nParentId, int nStId) /*const*/ +Machining::GetToolPreviewPrev( int nEntId, int nParentId, int nStId) const { - - if ( m_nLookFlag == MCH_LOOK_TAB_HEAD) - ChangeToolPreviewShow( MCH_LOOK_TAB_TOOL) ; - else if ( m_nLookFlag == MCH_LOOK_TAB_TOOL) - ChangeToolPreviewShow( MCH_LOOK_NONE) ; - else - ChangeToolPreviewShow( MCH_LOOK_TAB_HEAD) ; - // recupero la precedente int nNewId = ( ( nEntId != GDB_ID_NULL) ? m_pGeomDB->GetPrev( nEntId) : m_pGeomDB->GetLastInGroup( nParentId)) ; int nNewParentId = nParentId ; @@ -781,7 +781,7 @@ Machining::GetToolPreviewPrev( int nEntId, int nParentId, int nStId) /*const*/ //---------------------------------------------------------------------------- bool -Machining::MyToolPreview( int nEntId, bool bDouble) +Machining::MyToolPreview( int nEntId, bool bDouble) const { // verifico validità gestori DB geometrico e CAM if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) @@ -829,7 +829,7 @@ Machining::MyToolPreview( int nEntId, bool bDouble) } // scorro gli assi dentro al gruppo "ST" ( considero solo quelli rotativi) - INTVECTOR& vCurrPreviewAxisIds = ( ! bDouble ? m_vPreviewAxisIds : m_vPreviewAxisIdsBBL) ; + const INTVECTOR& vCurrPreviewAxisIds = ( ! bDouble ? m_vPreviewAxisIds : m_vPreviewAxisIdsBBL) ; for ( auto Iter = vCurrPreviewAxisIds.begin() ; Iter != vCurrPreviewAxisIds.end() ; ++ Iter) { // recupero l'Id dell'asse corrente int nAxisId = *Iter ; @@ -885,7 +885,7 @@ Machining::MyToolPreview( int nEntId, bool bDouble) //---------------------------------------------------------------------------- int -Machining::ToolPreview( int nEntId, int nStep) /*const*/ +Machining::ToolPreview( int nEntId, int nStep) const { // verifico validità gestori DB geometrico e CAM if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) @@ -997,7 +997,7 @@ Machining::GetDoubleType( const string& sUserNotes) //---------------------------------------------------------------------------- bool -Machining::GetDoubleToolData( string& sDblTool, string& sDblHead, int& nDblExit) +Machining::GetDoubleToolData( string& sDblTool, string& sDblHead, int& nDblExit) const { if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) return false ; @@ -1091,8 +1091,49 @@ Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) while ( nPathId != GDB_ID_NULL) { int nEntId = m_pGeomDB->GetFirstInGroup( nPathId) ; while ( nEntId != GDB_ID_NULL) { - m_pGeomDB->Mirror( nEntId, ptOn, vtNorm) ; - nEntId = m_pGeomDB->GetNext( nEntId) ; + string sName ; m_pGeomDB->GetName( nEntId, sName) ; + // nel caso di fuorature in doppio, il movimento deve essere sincronizzato + if ( sName == MCH_CL_DBP) { + INTVECTOR vSyncEntId ; + do { + vSyncEntId.push_back( nEntId) ; + nEntId = m_pGeomDB->GetNext( nEntId) ; + sName.clear() ; + m_pGeomDB->GetName( nEntId, sName) ; + } while ( sName == MCH_CL_DBP) ; + Vector3d vtRef ; + bool bOk = true ; + for ( int i = 0 ; bOk && i < ssize( vSyncEntId) ; ++ i) { + // curva corrente di sincronizzazione + const ICurve* pCrv = GetCurve( m_pGeomDB->GetGeoObj( vSyncEntId[i])) ; + bOk = ( pCrv != nullptr && pCrv->IsValid()) ; + if ( bOk) { + if ( i == 0) { + Point3d ptS ; pCrv->GetStartPoint( ptS) ; + Point3d ptE ; pCrv->GetEndPoint( ptE) ; + Point3d ptSMirror = ptS ; ptSMirror.Mirror( ptOn, vtNorm) ; + vtRef = ( ptSMirror - ptS) ; + } + m_pGeomDB->Translate( vSyncEntId[i], vtRef) ; + CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( vSyncEntId[i])) ; + bOk = ( pCamData != nullptr) ; + if ( bOk) { + Vector3d vtTool = pCamData->GetToolDir() ; + vtTool.Mirror( vtNorm) ; + pCamData->SetToolDir( vtTool) ; + } + } + } + if ( ! bOk) { + m_pGeomDB->Erase( nPathId) ; + return false ; + } + } + // per tutti gli altri casi si fa il mirror + else { + m_pGeomDB->Mirror( nEntId, ptOn, vtNorm) ; + nEntId = m_pGeomDB->GetNext( nEntId) ; + } } nPathId = m_pGeomDB->GetNextName( nPathId, MCH_PATH + "*") ; } diff --git a/Machining.h b/Machining.h index 8976ec3..ea81632 100644 --- a/Machining.h +++ b/Machining.h @@ -54,7 +54,7 @@ class Machining : public Operation bool PrepareToolPreview( void) ; bool RemoveToolPreview( void) ; int GetToolPreviewStepCount( void) const ; - int ToolPreview( int nEntId, int nStep) /*const*/ ; + int ToolPreview( int nEntId, int nStep) const ; protected : Machining( void) ; @@ -62,16 +62,16 @@ class Machining : public Operation bool SpecialApply( std::string& sErr) ; bool PostApply( std::string& sErr) ; int GetDoubleType( const std::string& sUserNotes) ; - bool GetDoubleToolData( std::string& sDblTool, std::string& sDblHead, int& nDblExit) ; + bool GetDoubleToolData( std::string& sDblTool, std::string& sDblHead, int& nDblExit) const ; bool CalcMirrorByDouble( int nClId, const std::string& sUserNotes) ; bool ActivateDrillingUnit( int nHeadId, const INTVECTOR& vActExit) const ; private : int GetToolPreviewNext( int nEntId, int nParentId, int nStId) const ; - int GetToolPreviewPrev( int nEntId, int nParentId, int nStId) /*const*/ ; + int GetToolPreviewPrev( int nEntId, int nParentId, int nStId) const ; bool MyPrepareToolPreview( bool bDouble) ; bool MyChangeToolPreviewShow( int nLookFlag, bool bDouble) ; - bool MyToolPreview( int nEntId, bool bDouble) ; + bool MyToolPreview( int nEntId, bool bDouble) const ; private : int m_nLookFlag ; // flag di Visualizzazione per Preview