EgtMachKernel :

- in MachConst aggiunte Key per lettura da file .ini della macchina per Drilling in doppio in parallelo e per calcolo Feeds in PocketingNT
- in Drilling migliorate le considerazioni per lavorazioni in Doppio con possibilità di movimenti in parallelo per gli utensili
- in Preview Utensile corretta la posizione del secondo Tool in caso di lavorazioni in doppio con utensili di lunghezza differente
- in Machining aggiunta la funzione per calcolare il piano di Mirroring
- in PocketingNT aggiunta la lettura dal file .ini della macchina per calcolo delle Feeds.
This commit is contained in:
Riccardo Elitropi
2026-04-22 13:16:17 +02:00
parent 8648a2c61b
commit e1ef39ad72
6 changed files with 130 additions and 61 deletions
+60 -33
View File
@@ -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
+1
View File
@@ -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) ;
+4
View File
@@ -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
+49 -23
View File
@@ -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<IGeoPoint3d> 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) {
+5 -3
View File
@@ -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 :
+11 -2
View File
@@ -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 <algorithm>
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 ;