From e1ef39ad722872b0d9cbf57ceea2b205791d701a Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Wed, 22 Apr 2026 13:16:17 +0200 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=20:=20-=20in=20MachConst=20aggiun?= =?UTF-8?q?te=20Key=20per=20lettura=20da=20file=20.ini=20della=20macchina?= =?UTF-8?q?=20per=20Drilling=20in=20doppio=20in=20parallelo=20e=20per=20ca?= =?UTF-8?q?lcolo=20Feeds=20in=20PocketingNT=20-=20in=20Drilling=20migliora?= =?UTF-8?q?te=20le=20considerazioni=20per=20lavorazioni=20in=20Doppio=20co?= =?UTF-8?q?n=20possibilit=C3=A0=20di=20movimenti=20in=20parallelo=20per=20?= =?UTF-8?q?gli=20utensili=20-=20in=20Preview=20Utensile=20corretta=20la=20?= =?UTF-8?q?posizione=20del=20secondo=20Tool=20in=20caso=20di=20lavorazioni?= =?UTF-8?q?=20in=20doppio=20con=20utensili=20di=20lunghezza=20differente?= =?UTF-8?q?=20-=20in=20Machining=20aggiunta=20la=20funzione=20per=20calcol?= =?UTF-8?q?are=20il=20piano=20di=20Mirroring=20-=20in=20PocketingNT=20aggi?= =?UTF-8?q?unta=20la=20lettura=20dal=20file=20.ini=20della=20macchina=20pe?= =?UTF-8?q?r=20calcolo=20delle=20Feeds.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drilling.cpp | 93 +++++++++++++++++++++++++++++++------------------ Drilling.h | 1 + MachConst.h | 4 +++ Machining.cpp | 72 ++++++++++++++++++++++++++------------ Machining.h | 8 +++-- PocketingNT.cpp | 13 +++++-- 6 files changed, 130 insertions(+), 61 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index bf4d576..9b8b05c 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -3336,6 +3336,51 @@ Drilling::VerifyHoleFromBottom( const Hole& hole, SelData Id) return true ; } +//---------------------------------------------------------------------------- +bool +Drilling::VerifyParallelDrilling( int nDouble, const Hole& hole) +{ + // verifico se lavorazione in doppio valida + if ( nDouble != 1 && nDouble != 2 && nDouble != 3) + return false ; + + // se la macchina non presenta nel file .ini la possibilità di lavorazione in doppio parallela, esco + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + + // verifico se la macchina presenta nel file .ini l'abilitazione per le forature in doppio in parallelo + string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; + int nDrillingDouble = GetPrivateProfileInt( MACHININGS_SEC.c_str(), DRILLING_PARALLEL_KEY.c_str(), 0, sMachIni.c_str()) ; + if ( nDrillingDouble != 1) + return false ; + + // recupero il piano di Mirror + Point3d ptOn ; Vector3d vtNorm ; + if ( ! CalcMirrorPlaneByDouble( nDouble, m_Params.m_sUserNotes, ptOn, vtNorm)) + return false ; + Plane3d plMirror ; + if ( ! plMirror.Set( ptOn, vtNorm)) + return false ; + + // verifico subito che la normale del piano si trovi entro un grado rispetto alla direzione del foro ( tolleranza da .BTL) + if ( abs( hole.vtDir * vtNorm) < cos( ( 1. - EPS_ANG_SMALL) * DEGTORAD)) + return false ; + + // se il punto finale del foro si trova nel semipiano positivo di Mirroring e sufficientemente distante da esso, non eseguo + // lavorazione in parallelo + Point3d ptHoleEnd = hole.ptIni - hole.dLen * hole.vtDir ; + const double SAFE_DIST_TOL = 5. ; + double dDist = ( ptHoleEnd - ptOn) * vtNorm ; + if ( dDist < EPS_SMALL) + return true ; + double dSafeTipDist = m_TParams.m_dTLen - m_TParams.m_dLen ; + if ( dDist < dSafeTipDist + SAFE_DIST_TOL) + return true ; + + return false ; +} + //---------------------------------------------------------------------------- bool Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double dMHOff, const Vector3d& vtA, const ToolData& currToolData) @@ -3579,30 +3624,12 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO return false ; } // parametri per foro in doppio - bool bDouble = ( GetDoubleType( m_Params.m_sUserNotes) != 0) ; + int nDouble = GetDoubleType( m_Params.m_sUserNotes) ; + bool bDouble = ( nDouble != 0) ; + bool bDoubleParallel = false ; + if ( bDouble) + bDoubleParallel = VerifyParallelDrilling( nDouble, hole) ; 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() && abs( hole.vtDir * vtNorm) > cos( 1. * DEGTORAD)) ; - } - } - } // ciclo di affondamento a step const double MIN_STEP = 1 ; const double APPR_STEP = 1 ; @@ -3653,9 +3680,9 @@ 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 ( dDoubleParallel && i == nStep) { + if ( bDoubleParallel && i == nStep) { SetFlag( 105) ; // movimento in doppio parallelo - if ( AddLinearMove( ptP3, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptP3, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; } else { @@ -3685,9 +3712,9 @@ 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 ( dDoubleParallel && i == nStep) { + if ( bDoubleParallel && i == nStep) { SetFlag( 105) ; // movimento in doppio parallelo - if ( AddLinearMove( ptP4, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptP4, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; } else { @@ -3716,9 +3743,9 @@ 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 ( dDoubleParallel && i == nStep) { + if ( bDoubleParallel && i == nStep) { SetFlag( 105) ; // movimento in doppio parallelo - if ( AddLinearMove( ptP5, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptP5, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; } else { @@ -3732,20 +3759,20 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO // 6 -> ritorno all'approccio del foro SetFeed( GetEndFeed()) ; - if ( dDoubleParallel) { + if ( bDoubleParallel) { SetFlag( 105) ; // movimento in doppio parallelo // aggiungo risalita aggiuntiva per lavorazione in doppio pari a due volte il LastStep Point3d ptEnd ; GetCurrPos( ptEnd) ; - if ( AddLinearMove( ptEnd + min( dLastStep, dCurrLen) * hole.vtDir, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptEnd + min( dLastStep, dCurrLen) * hole.vtDir, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; SetFeed( GetFeed()) ; GetCurrPos( ptEnd) ; - if ( AddLinearMove( ptEnd + min( dLastStep, dCurrLen) * hole.vtDir, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptEnd + min( dLastStep, dCurrLen) * hole.vtDir, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; SetFeed( GetEndFeed()) ; // aggiungo discensa di LastStep per simmetria con secondo utensile GetCurrPos( ptEnd) ; - if ( AddLinearMove( ptEnd - dLastStep * hole.vtDir, bSplitArcs, MCH_CL_DBP) == GDB_ID_NULL) + if ( AddLinearMove( ptEnd - dLastStep * hole.vtDir, bSplitArcs, MCH_CL_PARALLEL_DBL) == GDB_ID_NULL) return false ; } SetFlag( 104) ; // risalita sopra il foro diff --git a/Drilling.h b/Drilling.h index 9ba2ac6..744ce2b 100644 --- a/Drilling.h +++ b/Drilling.h @@ -105,6 +105,7 @@ class Drilling : public Machining bool GenerateHoleRegionPv( int nFirstId, int nCount, int nPvId) ; bool VerifyDiameter( double dHdiam, double dTdiam, double ddiamTol) ; bool VerifyHoleFromBottom( const Hole& hole, SelData Id) ; + bool VerifyParallelDrilling( int nDouble, const Hole& hole) ; bool DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double nMHOff, const Vector3d& vtA, const ToolData& currToolData) ; bool DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHOff, const Vector3d& vtA, const ToolData& currToolData) ; bool MultiHeadDrilling( const SELVECTOR& vId, int nClId, bool bFixed, TABMHDRILL& vDrills, double& dMHOff) ; diff --git a/MachConst.h b/MachConst.h index f8f9732..fb160b4 100644 --- a/MachConst.h +++ b/MachConst.h @@ -140,6 +140,10 @@ const std::string TOOLHOLDER_SEC = "ToolHolder" ; const std::string MACHININGS_SEC = "Machinings" ; // Chiave per abilitare discesa e risalita in rapido da fresature con estremi fuori dal grezzo const std::string RAPIDONOUT_KEY = "RapidOnOut" ; +// Chiave per Drilling in Doppio in Parallelo +const std::string DRILLING_PARALLEL_KEY = "DrillingDoubleNT" ; +// Chiave per Ottimizzazione delle Feed in PocketingNT +const std::string POCKETING_FEED_KEY = "PocketingAdjustFeedNT" ; //---------------------------------------------------------------------------- // Minimo spessore del grezzo diff --git a/Machining.cpp b/Machining.cpp index b0f49e0..0b64532 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -326,13 +326,15 @@ Machining::MyPrepareToolPreview( bool bDouble) // se necessario, imposto l'utensile corrente string sTool, sTcPos, sHead ; + double dTLen ; int nExitDBLId ; if ( ! bDouble) { sTool = GetToolName() ; sHead = GetHeadName() ; + dTLen = GetToolData().m_dLen ; } else { - if ( ! GetDoubleToolData( sTool, sTcPos, sHead, nExitDBLId)) + if ( ! GetDoubleToolData( sTool, sTcPos, sHead, nExitDBLId, dTLen)) return false ; } @@ -584,7 +586,7 @@ Machining::MyPrepareToolPreview( bool bDouble) bOk = bOk && ( nFrId != GDB_ID_NULL) ; const IGeoFrame3d* frExit = ( bOk ? GetGeoFrame3d( m_pGeomDB->GetGeoObj( nFrId)) : nullptr) ; bOk = bOk && ( frExit != nullptr) ; - Point3d ptToolTip = ( bOk ? ( frExit->GetFrame()).Orig() - GetToolData().m_dLen * ( frExit->GetFrame()).VersZ() : P_INVALID) ; + Point3d ptToolTip = ( bOk ? ( frExit->GetFrame()).Orig() - dTLen * ( frExit->GetFrame()).VersZ() : P_INVALID) ; bOk = bOk && ptToolTip.IsValid() ; if ( bOk) { PtrOwner ptGToolTip( CreateGeoPoint3d()) ; @@ -1043,7 +1045,7 @@ Machining::ToolPreview( int nEntId, int nStep) const //---------------------------------------------------------------------------- int -Machining::GetDoubleType( const string& sUserNotes) +Machining::GetDoubleType( const string& sUserNotes) const { int nDouble ; if ( ! GetValInNotes( sUserNotes, UN_DOUBLE, nDouble) || @@ -1056,6 +1058,14 @@ Machining::GetDoubleType( const string& sUserNotes) //---------------------------------------------------------------------------- bool Machining::GetDoubleToolData( string& sDblTool, string& sDblTcPos, string& sDblHead, int& nDblExit) const +{ + double dDummy ; + return GetDoubleToolData( sDblTool, sDblTcPos, sDblHead, nDblExit, dDummy) ; +} + +//---------------------------------------------------------------------------- +bool +Machining::GetDoubleToolData( string& sDblTool, string& sDblTcPos, string& sDblHead, int& nDblExit, double& dDblLen) const { if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) return false ; @@ -1066,10 +1076,11 @@ Machining::GetDoubleToolData( string& sDblTool, string& sDblTcPos, string& sDblH // recupero dati utensile in doppio if ( ! GetValInNotes( GetToolData().m_sUserNotes, TUN_DOUBLE, sDblTool)) return false ; + const ToolData* pTdata = pTMgr->GetTool( sDblTool) ; + if ( pTdata == nullptr) + return false ; + dDblLen = pTdata->m_dLen ; if ( ! m_pMchMgr->GetCurrSetupMgr().GetToolData( sDblTool, sDblTcPos, sDblHead, nDblExit)) { - const ToolData* pTdata = pTMgr->GetTool( sDblTool) ; - if ( pTdata == nullptr) - return false ; sDblHead = pTdata->m_sHead ; nDblExit = pTdata->m_nExit ; } @@ -1078,7 +1089,32 @@ Machining::GetDoubleToolData( string& sDblTool, string& sDblTcPos, string& sDblH //---------------------------------------------------------------------------- bool -Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) +Machining::CalcMirrorPlaneByDouble( int nDouble, const string& sUserNotes, Point3d& ptOn, Vector3d& vtNorm) const +{ + // verifico parametro per lavorazione in doppio + if ( nDouble != 1 && nDouble != 2 && nDouble != 3) + return false ; + + // determino posizione del piano di mirroring mediante centro del Box del grezzo + BBox3d b3Raw ; + if ( ! GetCurrRawsGlobBox( b3Raw) || ! b3Raw.GetCenter( ptOn)) + return false ; + switch ( nDouble) { + case 1 : vtNorm = X_AX ; break ; + case 2 : vtNorm = Y_AX ; break ; + case 3 : vtNorm = Z_AX ; break ; + } + // se presente nota utente con posizione del piano, allora dal punto più basso salgo di tale valore per individuare la quota + double dPlanePos ; + if ( GetValInNotes( sUserNotes, UN_MIRRORAX, dPlanePos)) + ptOn = b3Raw.GetMin() + dPlanePos * vtNorm ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) const { if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) return false ; @@ -1128,20 +1164,10 @@ Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) nPathId = m_pGeomDB->GetNextName( nPathId, MCH_PATH + "*") ; } - // determino posizione del piano di mirroring - BBox3d b3Raw ; - Point3d ptOn ; - if ( ! GetCurrRawsGlobBox( b3Raw) || ! b3Raw.GetCenter( ptOn)) + // calcolo il piano di Mirroring + Point3d ptOn ; Vector3d vtNorm ; + if ( ! CalcMirrorPlaneByDouble( nDouble, sUserNotes, ptOn, vtNorm)) return false ; - Vector3d vtNorm ; - switch ( nDouble) { - case 1 : vtNorm = X_AX ; break ; - case 2 : vtNorm = Y_AX ; break ; - case 3 : vtNorm = Z_AX ; break ; - } - double dPlanePos ; - if ( GetValInNotes( sUserNotes, UN_MIRRORAX, dPlanePos)) - ptOn = b3Raw.GetMin() + dPlanePos * vtNorm ; // eseguo mirroring rispetto a piano opportuno nPathId = m_pGeomDB->GetFirstNameInGroup( nDblId, MCH_PATH + "*") ; @@ -1149,15 +1175,15 @@ Machining::CalcMirrorByDouble( int nClId, const string& sUserNotes) int nEntId = m_pGeomDB->GetFirstInGroup( nPathId) ; while ( nEntId != GDB_ID_NULL) { string sName ; m_pGeomDB->GetName( nEntId, sName) ; - // nel caso di fuorature in doppio, il movimento deve essere sincronizzato - if ( sName == MCH_CL_DBP) { + // nel caso di forature in doppio, il movimento deve essere sincronizzato + if ( sName == MCH_CL_PARALLEL_DBL) { INTVECTOR vSyncEntId ; do { vSyncEntId.push_back( nEntId) ; nEntId = m_pGeomDB->GetNext( nEntId) ; sName.clear() ; m_pGeomDB->GetName( nEntId, sName) ; - } while ( sName == MCH_CL_DBP) ; + } while ( sName == MCH_CL_PARALLEL_DBL) ; Vector3d vtRef ; bool bOk = true ; for ( int i = 0 ; bOk && i < ssize( vSyncEntId) ; ++ i) { diff --git a/Machining.h b/Machining.h index 47db688..37a5088 100644 --- a/Machining.h +++ b/Machining.h @@ -26,6 +26,7 @@ class Machining : public Operation int GetExitNbr( void) const override ; const std::string& GetToolTcPos( void) const override ; bool NeedPrevHome( void) const override ; + bool GetDoubleToolData( std::string& sDblTool, std::string& sDblTcPos, std::string& sDblHead, int& nDblExit) const override ; public : virtual bool Prepare( const std::string& sMchName) = 0 ; @@ -61,9 +62,10 @@ class Machining : public Operation ~Machining( void) ; bool SpecialApply( std::string& sErr) ; bool PostApply( std::string& sErr) ; - int GetDoubleType( const std::string& sUserNotes) ; - bool GetDoubleToolData( std::string& sDblTool, std::string& sDblTcPos, std::string& sDblHead, int& nDblExit) const override ; - bool CalcMirrorByDouble( int nClId, const std::string& sUserNotes) ; + int GetDoubleType( const std::string& sUserNotes) const ; + bool GetDoubleToolData( std::string& sDblTool, std::string& sDblTcPos, std::string& sDblHead, int& nDblExit, double& dDblLen) const ; + bool CalcMirrorPlaneByDouble( int nDouble, const std::string& sUserNotes, Point3d& ptOn, Vector3d& vtNorm) const ; + bool CalcMirrorByDouble( int nClId, const std::string& sUserNotes) const ; bool ActivateDrillingUnit( int nHeadId, const INTVECTOR& vActExit) const ; private : diff --git a/PocketingNT.cpp b/PocketingNT.cpp index cd264ea..18ed67a 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -47,6 +47,7 @@ #include "/EgtDev/Include/EGkDistPointSurfFr.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h" +#include "/EgtDev/Include/EgtIniFile.h" #include using namespace std ; @@ -4535,8 +4536,16 @@ PocketingNT::CalcPaths( STEPINFOPOVECTOR& vStepInfo) GetValInNotes( m_Params.m_sUserNotes, UN_MAXOPTSIZE, dMaxOptSize) ; // recupero flag per calcolo delle Feed - bool bAdjustFeed = true ; - GetValInNotes( m_Params.m_sUserNotes, UN_ADJUSTFEED, bAdjustFeed) ; + bool bAdjustFeed = false ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch != nullptr) { + string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; + int nAdjustFeed = GetPrivateProfileInt( MACHININGS_SEC.c_str(), POCKETING_FEED_KEY.c_str(), 0, sMachIni.c_str()) ; + bAdjustFeed = ( nAdjustFeed != 0) ; + } + bool bUnAdjustFeed = false ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_ADJUSTFEED, bUnAdjustFeed) && bUnAdjustFeed) + bAdjustFeed = true ; // verifico se percorso di lucidatura bool bAllOffset = false ;