17 Commits

Author SHA1 Message Date
SaraP 66466225d4 Merge commit '8483c1609a76bb54e9ea3a22c2d1f894b51d40d5' into feature/SvuotatureConIsole 2021-11-29 08:35:54 +01:00
SaraP 34ef5388e1 EgtMachKernel :
- in Pocketing adattamenti per modifiche a GeomKernel ( funzione GetCurveClassification).
2021-11-18 10:13:14 +01:00
SaraP a470ffa6ce Merge commit 'cfb2fea0bdd6627485111e68a57482098dc62c82' into feature/SvuotatureConIsole 2021-11-18 09:54:32 +01:00
SaraP 929c724b9f Merge commit '5c6ad44bb517ecd143e3fbd8c727d9d9939ec889' into feature/SvuotatureConIsole 2021-09-20 08:47:50 +02:00
SaraP d1ad8fe9c5 Merge commit '01cb04ac9620d8d98d478e52e4c6baeeac627ea4' into feature/SvuotatureConIsole 2021-09-10 10:35:46 +02:00
SaraP fb02fa7243 Merge commit '0c3ad1ebe5a0fec28823a7a0608055f631ec93cc' into feature/SvuotatureConIsole 2021-09-08 10:23:48 +02:00
SaraP bdb93bf21f EgtMachKernel :
- aggiunte funzioni per importazione ed esportazione lavorazioni.
2021-08-26 08:42:40 +02:00
SaraP 260b35c7e3 Merge remote-tracking branch 'origin/HEAD' into feature/SvuotatureConIsole 2021-08-26 08:36:14 +02:00
SaraP 83cbe5b299 Merge commit '702d4add85c59d6943670f9d9c44375d48629354' into feature/SvuotatureConIsole 2021-08-20 15:47:35 +02:00
SaraP c6ede73c9e Merge branch 'master' into feature/SvuotatureConIsole 2021-08-11 15:05:37 +02:00
SaraP 5fca2321af EgtMachKernel :
- in Pocketing gestione di eventuali isole nella creazione della regione da svuotare
- correzione errori nella rimozione di aree resiude.
2021-08-11 15:04:18 +02:00
SaraP f9ebc68077 Merge branch 'master' into feature/SvuotatureConIsole 2021-07-28 15:17:25 +02:00
SaraP 22aa1cebc8 EgtMachKernel :
- in Pocketing aggiunta la rimozione di regioni residue.
2021-07-28 15:07:32 +02:00
SaraP 9d836abbca Merge remote-tracking branch 'origin/HEAD' into feature/SvuotatureConIsole 2021-07-16 08:33:08 +02:00
SaraP 3f7ad3e961 Merge remote-tracking branch 'origin/HEAD' into feature/SvuotatureConIsole 2021-06-30 15:43:38 +02:00
SaraP bea99328ab Merge remote-tracking branch 'origin/master' into feature/SvuotatureConIsole 2021-06-16 10:45:35 +02:00
SaraP baedb87cd1 EgtMachKernel :
- svuotature con isole, prima implementazione.
2021-05-28 17:14:25 +02:00
58 changed files with 3234 additions and 8263 deletions
+3 -5
View File
@@ -46,7 +46,6 @@ Axis::Clone( void) const
pAx->m_sName = m_sName ;
pAx->m_sToken = m_sToken ;
pAx->m_bInvert = m_bInvert ;
pAx->m_dOffset = m_dOffset ;
pAx->m_nType = m_nType ;
pAx->m_ptPos = m_ptPos ;
pAx->m_vtDir = m_vtDir ;
@@ -110,20 +109,19 @@ Axis::GetGeomDB( void) const
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Axis::Axis( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_bInvert( false), m_dOffset( 0),
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr),
m_nType( MCH_AT_NONE), m_Stroke( {{0,0}}), m_dHomeVal( 0), m_dCurrVal( 0)
{
}
//----------------------------------------------------------------------------
bool
Axis::Set( const string& sName, const string& sToken, bool bInvert, double dOffset,
int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome)
Axis::Set( const string& sName, const string& sToken, bool bInvert, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome)
{
m_sName = sName ;
m_sToken = sToken ;
m_bInvert = bInvert ;
m_dOffset = dOffset ;
m_nType = nType ;
m_ptPos = ptPos ;
m_vtDir = vtDir ;
+4 -7
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : Axis.h Data : 21.09.22 Versione : 2.4i
// File : Axis.h Data : 24.05.15 Versione : 1.6e7
// Contenuto : Dichiarazione della classe Axis.
//
//
@@ -30,8 +30,8 @@ class Axis : public IUserObj
public :
Axis( void) ;
bool Set( const std::string& sName, const std::string& sToken, bool bInvert, double dOffset,
int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome) ;
bool Set( const std::string& sName, const std::string& sToken, bool bInvert, int nType,
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome) ;
bool Modify( const Point3d& ptPos, double dAxisMaxAdjust) ;
bool Modify( const Vector3d& vtDir, double dAxisMaxRotAdj) ;
bool Modify( const STROKE& Stroke) ;
@@ -44,8 +44,6 @@ class Axis : public IUserObj
{ return m_sToken ; }
bool GetInvert( void) const
{ return m_bInvert ; }
double GetOffset( void) const
{ return m_dOffset ; }
int GetType( void) const
{ return m_nType ; }
const Point3d& GetPos( void) const
@@ -65,7 +63,6 @@ class Axis : public IUserObj
std::string m_sName ;
std::string m_sToken ;
bool m_bInvert ;
double m_dOffset ;
int m_nType ;
Point3d m_ptPos ;
Vector3d m_vtDir ;
-8
View File
@@ -504,14 +504,8 @@ Chiseling::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nChisels = nCurrChisels ;
LOG_DBG_INFO( GetEMkLogger(), "Chiseling apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -576,8 +570,6 @@ Chiseling::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "Chiseling apply done") ;
return true ;
}
+1 -10
View File
@@ -1294,7 +1294,6 @@ Disposition::SpecialApply( bool bRecalc)
static const string ON_SPECIAL_APPLY = "OnSpecialApplyDisposition" ;
if ( ! pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) {
m_nStatus = MCH_ST_OK ;
LOG_DBG_INFO( GetEMkLogger(), "Disposition special apply not provided") ;
return true ;
}
@@ -1305,7 +1304,7 @@ Disposition::SpecialApply( bool bRecalc)
m_nShifts = nCurrShifts ;
m_bSomeByHand = bCurrSomeByHand ;
m_sTcPos = sCurrTcPos ;
LOG_DBG_INFO( GetEMkLogger(), "Disposition special apply skipped : status already ok") ;
LOG_DBG_INFO( GetEMkLogger(), "Disposition postapply skipped : status already ok") ;
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -1368,10 +1367,6 @@ Disposition::SpecialApply( bool bRecalc)
m_pMchMgr->SetWarning( 2053, sOut) ;
}
// assegno ingombri dei vari percorsi di lavorazione e della lavorazione nel suo complesso
nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
CalcAndSetBBox( nClId) ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! SpecialUpdate())
return false ;
@@ -1379,7 +1374,6 @@ Disposition::SpecialApply( bool bRecalc)
// aggiorno stato
m_nStatus = MCH_ST_OK ;
LOG_DBG_INFO( GetEMkLogger(), "Disposition special apply ok") ;
return true ;
}
@@ -1415,9 +1409,6 @@ Disposition::SpecialUpdate( void)
m_pMchMgr->SetLastError( 2010, "Error in Disposition : link outstroke ") ;
return false ;
}
// assegno estremi degli assi dei vari percorsi di lavorazione e della lavorazione nel suo complesso
CalcAndSetAxesBBox() ;
return true ;
}
-1
View File
@@ -21,4 +21,3 @@
std::string GetEMkVer( void) ;
ILogger* GetEMkLogger( void) ;
const std::string& GetEMkKey( void) ;
bool GetEMkNetHwKey( void) ;
+4 -15
View File
@@ -544,14 +544,8 @@ Drilling::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nDrillings = nCurrDrillings ;
LOG_DBG_INFO( GetEMkLogger(), "Drilling apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -595,8 +589,6 @@ Drilling::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "Drilling apply done") ;
return true ;
}
@@ -1027,11 +1019,8 @@ Drilling::GenerateHoleCl( int nInd, const SelData& nCircId, const string& sPName
// imposto elevazione da lunghezza foro con possibilità di sovrascrittura da info
double dElev = hole.dLen ;
double dMaxElev ;
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "MaxElev="), dMaxElev) && dElev > dMaxElev) {
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "MaxElev="), dMaxElev) && dElev > dMaxElev)
dElev = dMaxElev ;
hole.ptIni += hole.vtDir * ( dElev - hole.dLen) ;
hole.dLen = dElev ;
}
// limito lunghezza foro a massima lavorazione della punta
double dAddLen = ( hole.bBlind ? 0 : m_Params.m_dThroughAddLen) ;
if ( ( dElev + dAddLen) > m_TParams.m_dMaxMat + EPS_SMALL) {
@@ -1443,7 +1432,7 @@ Drilling::VerifyHoleFromBottom( const Hole& hole, SelData Id)
// calcolo la distanza minima del punto dal contorno del grezzo
double dDist ;
Vector3d vtDir ;
if ( ! GetMinDistanceFromRawSide( m_nPhase, hole.ptIni, 0, m_AggrBottom.vtMDir, MCH_AGB_DELTAMAX_MDIR, dDist, vtDir) || dDist > m_AggrBottom.dDMax) {
if ( ! GetMinDistanceFromRawSide( m_nPhase, hole.ptIni, 0, dDist, vtDir) || dDist > m_AggrBottom.dDMax) {
string sOut = "Error in Drilling : Entity " + ToString( Id) + " skipped because too far from part sides" ;
m_pMchMgr->SetLastError( 2107, sOut) ;
return false ;
@@ -1476,7 +1465,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ;
// determino l'elevazione
double dElev = 0 ;
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, m_TParams.m_dDiam / 2, hole.vtDir, dElev) ;
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, dElev) ;
// determino alcune caratteristiche dell'utensile
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
// imposto dati comuni
@@ -1605,7 +1594,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ;
// determino l'elevazione
double dElev = 0 ;
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, m_TParams.m_dDiam / 2, hole.vtDir, dElev) ;
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, dElev) ;
// determino alcune caratteristiche dell'utensile
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
// imposto dati comuni
-15
View File
@@ -98,7 +98,6 @@ GetEMkLogger( void)
//-----------------------------------------------------------------------------
static std::string s_sKey ;
static bool s_bNetHwKey = false ;
//-----------------------------------------------------------------------------
void
@@ -107,23 +106,9 @@ SetEMkKey( const std::string& sKey)
s_sKey = sKey ;
}
//-----------------------------------------------------------------------------
void
SetEMkNetHwKey( bool bNetHwKey)
{
s_bNetHwKey = bNetHwKey ;
}
//-----------------------------------------------------------------------------
const std::string&
GetEMkKey( void)
{
return s_sKey ;
}
//-----------------------------------------------------------------------------
bool
GetEMkNetHwKey( void)
{
return s_bNetHwKey ;
}
BIN
View File
Binary file not shown.
+2 -4
View File
@@ -27,7 +27,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v120_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
@@ -39,7 +39,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v120_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -132,7 +132,6 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAs>CompileAsCpp</CompileAs>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -201,7 +200,6 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
+1 -9
View File
@@ -20,7 +20,7 @@
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EgkArcSpecial.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
@@ -527,14 +527,8 @@ GenMachining::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nMills = nCurrMills ;
LOG_DBG_INFO( GetEMkLogger(), "GenMachining apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -617,8 +611,6 @@ GenMachining::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "GenMachining apply done") ;
return true ;
}
+5 -12
View File
@@ -47,18 +47,11 @@ bool
Generator::Run( const string& sCncFile, const string& sInfo)
{
// verifico sia abilitato dalla licenza
bool bEnabled = false ;
if ( GetEMkNetHwKey()) {
bEnabled = true ;
}
else {
unsigned int nOpt1, nOpt2 ;
int nOptExpDays ;
int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
bEnabled = ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) ;
}
if ( bEnabled) {
unsigned int nOpt1, nOpt2 ;
int nOptExpDays ;
int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
if ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) {
// emetto info di log
{ string sOut = "Generator Run : " + sCncFile ;
+2 -4
View File
@@ -49,7 +49,6 @@ Head::Clone( void) const
pHead->m_vsHSet = m_vsHSet ;
pHead->m_vtADir = m_vtADir ;
pHead->m_dRot1W = m_dRot1W ;
pHead->m_bMaxDeltaR2On1 = m_bMaxDeltaR2On1 ;
pHead->m_Rot2Stroke = m_Rot2Stroke ;
pHead->m_nSolCh = m_nSolCh ;
}
@@ -103,7 +102,7 @@ Head::GetGeomDB( void) const
//----------------------------------------------------------------------------
Head::Head( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_nType( MCH_HT_NONE), m_nExitCount( 0),
m_dRot1W( 1), m_bMaxDeltaR2On1( true), m_nSolCh( MCH_SCC_NONE)
m_dRot1W( 1), m_nSolCh( MCH_SCC_NONE)
{
m_Rot2Stroke.Min = - INFINITO ;
m_Rot2Stroke.Max = INFINITO ;
@@ -112,7 +111,7 @@ Head::Head( void)
//----------------------------------------------------------------------------
bool
Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl)
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl)
{
m_sName = sName ;
m_nType = nType ;
@@ -125,7 +124,6 @@ Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet,
m_vtADir = vtADir ;
m_vtADir.Normalize() ;
m_dRot1W = dRot1W ;
m_bMaxDeltaR2On1 = bMaxDeltaR2On1 ;
m_Rot2Stroke = Rot2Stroke ;
if ( IsValidHeadScc( nSolCh))
m_nSolCh = nSolCh ;
+1 -4
View File
@@ -31,7 +31,7 @@ class Head : public IUserObj
public :
Head( void) ;
bool Set( const std::string& sName, int nType, int nExitCount, const std::string& sHSet,
const Vector3d& vtADir, double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh,
const Vector3d& vtADir, double dRot1W, const STROKE& Rot2Stroke, int nSolCh,
const STRVECTOR& vsOthColl) ;
bool AddHeadToHSet( const std::string& sHead) ;
bool ModifyHeadAuxDirection( const Vector3d& vtADir) ;
@@ -47,8 +47,6 @@ class Head : public IUserObj
{ return m_vtADir ; }
double GetRot1W( void) const
{ return m_dRot1W ; }
bool GetMaxDeltaR2On1( void) const
{ return m_bMaxDeltaR2On1 ; }
const STROKE& GetRot2Stroke( void) const
{ return m_Rot2Stroke ; }
int GetSolCh( void) const
@@ -65,7 +63,6 @@ class Head : public IUserObj
STRVECTOR m_vsHSet ;
Vector3d m_vtADir ;
double m_dRot1W ;
bool m_bMaxDeltaR2On1 ;
STROKE m_Rot2Stroke ;
int m_nSolCh ;
STRVECTOR m_vsOtherColl ;
-2
View File
@@ -31,8 +31,6 @@ const std::string MACH_FIXT_GROUP = "Fixt" ;
const std::string MACH_SETUP_GROUP = "Setup" ;
// Gruppo dei grezzi in una macchinata
const std::string MACH_RAW_GROUP = "Raws" ;
// Gruppo dei collegamenti per waterjet in una macchinata
const std::string MACH_BRIDGES_GROUP = "Bridges" ;
// Gruppo delle operazioni in una macchinata
const std::string MACH_OPER_GROUP = "Opers" ;
// Chiave per info fase di appartenenza di una fixture
+11 -19
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2021
//----------------------------------------------------------------------------
// File : MachMgr.h Data : 21.09.22 Versione : 2.4i4
// File : MachMgr.h Data : 24.05.21 Versione : 2.3e3
// Contenuto : Dichiarazione della classe MachMgr.
//
//
@@ -10,7 +10,6 @@
// 16.05.19 DS Aggiunto parametro sToolMakersDir a Init.
// 17.08.20 DS Aggiunte GetAxisMin e GetAxisMax.
// 17.03.21 DS Aggiunte funzioni per import/export utensili.
// 21.09.22 DS Aggiunta GetAxisOffset.
//
//----------------------------------------------------------------------------
@@ -52,15 +51,14 @@ struct AxisBlock {
//----------------------------------------------------------------------------
struct MachineData {
std::string sName ;
std::string sDir ;
std::string sName ;
Machine* pMachine ;
ToolsMgr* pTsMgr ;
MachiningsMgr* pMsMgr ;
MachineData( void)
: pMachine( nullptr), pTsMgr( nullptr), pMsMgr( nullptr) {}
MachineData( const std::string& sN, const std::string& sD, Machine* pM, ToolsMgr* pTM, MachiningsMgr* pMM)
{ sName = sN ; sDir = sD ; pMachine = pM ; pTsMgr = pTM ; pMsMgr = pMM ; }
MachineData( const std::string& sN, Machine* pM, ToolsMgr* pTM, MachiningsMgr* pMM)
{ sName = sN ; pMachine = pM ; pTsMgr = pTM ; pMsMgr = pMM ; }
} ;
//----------------------------------------------------------------------------
@@ -82,7 +80,6 @@ class MachMgr : public IMachMgr
std::string GetWarningString( int nInd) const override
{ if ( nInd < 0 || nInd >= int( m_Warnings.size())) return "" ; return m_Warnings[ nInd].second ; }
// Machines
bool GetMachines( STRVECTOR& vsMachineNames, STRVECTOR& vsMachineDirs) const override ;
bool SetCurrMachine( const std::string& sMachineName) override ;
bool GetCurrMachineName( std::string& sMachineName) const override ;
bool GetCurrMachineDir( std::string& sMachineDir) const override ;
@@ -234,10 +231,10 @@ class MachMgr : public IMachMgr
bool MdbReload( void) override ;
bool MdbSave( void) const override ;
bool MdbGetMachiningDir( std::string& sMchDir) const override ;
bool MdbExport( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile) const override ;
bool MdbToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const override ;
bool MdbExport( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile) const ;
bool MdbToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const ;
bool MdbImport( const std::string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames,
STRVECTOR& vsImported) override ;
STRVECTOR& vsImported) ;
// Operations : general
int GetOperationCount( void) const override ;
int GetFirstOperation( void) const override ;
@@ -354,7 +351,6 @@ class MachMgr : public IMachMgr
bool GetAxisToken( const std::string& sAxis, std::string& sToken) const override ;
bool GetAxisType( const std::string& sAxis, bool& bLinear) const override ;
bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const override ;
bool GetAxisOffset( const std::string& sAxis, double& dOffset) const override ;
bool SetAxisPos( const std::string& sAxis, double dVal, double* pdNewVal = nullptr) override ;
bool GetAxisPos( const std::string& sAxis, double& dVal) const override ;
bool GetAxisMin( const std::string& sAxis, double& dMin) const override ;
@@ -433,7 +429,6 @@ class MachMgr : public IMachMgr
bool GetAllCurrAxesName( STRVECTOR& vAxName) const ;
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
bool GetCurrAxisHomePos( int nInd, double& dHome) const ;
const Frame3d& GetCurrLinAxesFrame( void) const ;
bool ApplyRotAxisBlock( void) ;
void ClearRotAxisBlock( void)
{ m_vAxisBlock.clear() ; }
@@ -442,7 +437,6 @@ class MachMgr : public IMachMgr
int GetCalcHead( void) const ;
int GetCalcExit( void) const ;
double GetCalcRot1W( void) const ;
bool GetCalcMaxDeltaR2OnFirst( void) const ;
bool GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool SetCalcSolCh( int nScc, bool bExact) ;
bool VerifyAngleOutstroke( int nInd, double dAng) const ;
@@ -452,11 +446,9 @@ class MachMgr : public IMachMgr
bool GetOperationNewName( std::string& sName) const ;
const ToolData* GetMachiningToolData( void) const ;
// Simulation
bool SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ;
bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ;
bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
int SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ;
// Machine
bool GetHeadAbove( const std::string& sHead) const ;
double GetDeltaSafeZ( const std::string& sHead) const ;
@@ -496,7 +488,7 @@ class MachMgr : public IMachMgr
bool ShowRootParts( bool bShow) ;
// Tools DataBase
bool UpdateAllToolDraws( void) const ;
bool UpdateToolDraw( const EgtUUID& UuidTool, double& dTHoldBase, double& dTHoldLen, double& dTHoldDiam) const ;
bool UpdateToolDraw( const EgtUUID& UuidTool, double& dTHoldLen, double& dTHoldDiam) const ;
int UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const ;
int UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const ;
std::string GetToolMakerKeyFromType( int nType) const ;
@@ -513,7 +505,7 @@ class MachMgr : public IMachMgr
private :
int m_nContextId ; // indice contesto corrente (1-based)
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico del contesto corrente
STRVECTOR m_vMachinesBaseDir ; // direttori di base delle macchine (ordine molto importante)
std::string m_sMachinesDir ; // direttorio delle macchine
std::string m_sToolMakersDir ; // direttorio dei generatori di disegni utensili standard
std::string m_sLuaLibsDir ; // direttorio delle librerie lua
std::string m_sLuaLastRequire ; // nome ultima libreria caricata
+4 -16
View File
@@ -18,7 +18,7 @@
#include "DllMain.h"
#include "/EgtDev/Include/EMkDllMain.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgnFileUtils.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include <new>
@@ -30,7 +30,7 @@ IMachMgr*
CreateMachMgr( void)
{
// verifico la chiave e le opzioni
if ( ! GetEMkNetHwKey() && ! TestKeyForEMk( GetEMkKey(), 0, GetEMkLogger()))
if ( ! TestKeyForEMk( GetEMkKey(), 0, GetEMkLogger()))
return nullptr ;
// creo il MachMgr
return static_cast<IMachMgr*> ( new(nothrow) MachMgr) ;
@@ -94,19 +94,7 @@ MachMgr::Init( const string& sMachinesDir, const string& sToolMakersDir, IGeomDB
{
m_nContextId = nContextId ;
m_pGeomDB = pGeomDB ;
STRVECTOR vsDir ;
Tokenize( sMachinesDir, "|", vsDir) ;
for ( int i = 0 ; i < int( vsDir.size()) ; ++ i) {
string sDir = vsDir[i] ;
TrimRight( sDir, " \\") ;
if ( ExistsDirectory( vsDir[i]) &&
find_if( m_vMachinesBaseDir.begin(), m_vMachinesBaseDir.end(),
[ sDir]( const string& sItem)
{ return ( EqualNoCase( sDir, sItem)) ; }) == m_vMachinesBaseDir.end()) {
m_vMachinesBaseDir.emplace_back( sDir) ;
}
}
m_sMachinesDir = sMachinesDir ;
m_sToolMakersDir = sToolMakersDir ;
m_sLuaLibsDir = sLuaLibsDir ;
m_sLuaLastRequire = sLuaLastRequire ;
@@ -115,7 +103,7 @@ MachMgr::Init( const string& sMachinesDir, const string& sToolMakersDir, IGeomDB
m_nCurrMGrpId = GDB_ID_NULL ;
m_nCurrMch = - 1 ;
m_stuMgr.Reset() ;
return ( m_nContextId > 0 && m_pGeomDB != nullptr && ! m_vMachinesBaseDir.empty()) ;
return ( m_nContextId > 0 && m_pGeomDB != nullptr && ExistsDirectory( m_sMachinesDir)) ;
}
//----------------------------------------------------------------------------
+3 -3
View File
@@ -411,10 +411,10 @@ MachMgr::MdbSave( void) const
bool
MachMgr::MdbGetMachiningDir( string& sMchDir) const
{
string sMachineDir, sMachineName ;
if ( ! GetCurrMachineDir( sMachineDir) || ! GetCurrMachineName( sMachineName))
string sMachineName ;
if ( ! GetCurrMachineName( sMachineName))
return false ;
sMchDir = sMachineDir + "\\" + MACHININGS_DIR ;
sMchDir = m_sMachinesDir + "\\" + sMachineName + "\\" + MACHININGS_DIR ;
return true ;
}
+13 -18
View File
@@ -481,10 +481,10 @@ MachMgr::TdbSave( void) const
bool
MachMgr::TdbGetToolDir( string& sToolDir) const
{
string sMachineDir, sMachineName ;
if ( ! GetCurrMachineDir( sMachineDir) || ! GetCurrMachineName( sMachineName))
string sMachineName ;
if ( ! GetCurrMachineName( sMachineName))
return false ;
sToolDir = sMachineDir + "\\" + TOOLS_DIR ;
sToolDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLS_DIR ;
return true ;
}
@@ -492,10 +492,10 @@ MachMgr::TdbGetToolDir( string& sToolDir) const
bool
MachMgr::TdbGetToolHolderDir( string& sToolHolderDir) const
{
string sMachineDir, sMachineName ;
if ( ! GetCurrMachineDir( sMachineDir) || ! GetCurrMachineName( sMachineName))
string sMachineName ;
if ( ! GetCurrMachineName( sMachineName))
return false ;
sToolHolderDir = sMachineDir + "\\" + TOOLHOLDERS_DIR ;
sToolHolderDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLHOLDERS_DIR ;
return true ;
}
@@ -528,10 +528,10 @@ MachMgr::UpdateAllToolDraws( void) const
bool bNoDraw = ( ! sDraw.empty() && ! ExistsFile( sToolDir + "\\" + sDraw)) ;
// se modificato o senza disegno, ne lancio la creazione e aggiorno dati portautensile
if ( bModif || bNoDraw) {
double dTHoldBase = 0, dTHoldLen = 0, dTHoldDiam = 0 ;
UpdateToolDraw( UuidTool, dTHoldBase, dTHoldLen, dTHoldDiam) ;
double dTHoldLen = 0, dTHoldDiam = 0 ;
UpdateToolDraw( UuidTool, dTHoldLen, dTHoldDiam) ;
pTsMgr->SetCurrTool( sName) ;
pTsMgr->UpdateCurrToolHolderData( dTHoldBase, dTHoldLen, dTHoldDiam) ;
pTsMgr->UpdateCurrToolHolderData( dTHoldLen, dTHoldDiam) ;
pTsMgr->SaveCurrTool() ;
pTsMgr->SetCurrTool( "") ;
}
@@ -548,7 +548,7 @@ MachMgr::UpdateAllToolDraws( void) const
//----------------------------------------------------------------------------
bool
MachMgr::UpdateToolDraw( const EgtUUID& UuidTool, double& dTHoldBase, double& dTHoldLen, double& dTHoldDiam) const
MachMgr::UpdateToolDraw( const EgtUUID& UuidTool, double& dTHoldLen, double& dTHoldDiam) const
{
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
@@ -589,8 +589,6 @@ MachMgr::UpdateToolDraw( const EgtUUID& UuidTool, double& dTHoldBase, double& dT
bOk = bOk && ExeSaveFile( sDrawPath, GDB_SV_BIN) ;
// Recupero i dati del portautensile
int nToolId = ExeGetFirstGroupInGroup( GDB_ID_ROOT) ;
if ( ! ExeGetInfo( nToolId, TTH_BASE, dTHoldBase))
dTHoldBase = 0 ;
if ( ! ExeGetInfo( nToolId, TTH_LEN, dTHoldLen))
dTHoldLen = 0 ;
if ( ! ExeGetInfo( nToolId, TTH_DIAM, dTHoldDiam))
@@ -645,8 +643,6 @@ MachMgr::UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolC
dCore = ( dLen >= dThick ? dThick - 1 : 2 * dLen - dThick) ;
double dSpeed = 0 ;
pTdata->GetParam( TPA_SPEED, dSpeed) ;
double dTipFeed = 0 ;
pTdata->GetParam( TPA_TIPFEED, dTipFeed) ;
string sUserNotes ;
pTdata->GetParam( TPA_USERNOTES, sUserNotes) ;
// Recupero la path dell'eventuale portautensile
@@ -664,7 +660,6 @@ MachMgr::UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolC
// Assegno i dati utensile
bool bOk = ExeLuaSetGlobIntVar( "TOOL.TYPE", nType) ;
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.SPEED", dSpeed) ;
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.TIPFEED", dTipFeed) ;
switch ( nType) {
case TT_DRILL_STD :
case TT_DRILL_LONG :
@@ -860,7 +855,7 @@ MachMgr::TdbExport( const STRVECTOR& vsToolsNames, const string& sOutFile) const
if ( vsToolsNames.empty())
return true ;
// recupero il gestore di utensili della macchina corrente
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
if ( pTsMgr == nullptr)
return false ;
@@ -895,7 +890,7 @@ MachMgr::TdbImport( const string& sFile, const STRVECTOR& vsToolsToImport, const
if ( vsToolsToImport.empty())
return true ;
if ( ! ExistsFile( sFile)) {
if ( ! ExistsFile( sFile)){
LOG_ERROR( GetEMkLogger(), "TdbImport Error : File does not exist") ;
return false ;
}
@@ -904,7 +899,7 @@ MachMgr::TdbImport( const string& sFile, const STRVECTOR& vsToolsToImport, const
return false ;
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
if ( pTsMgr == nullptr) {
if ( pTsMgr == nullptr){
LOG_ERROR( GetEMkLogger(), "TdbImport Error : no current ToolsMgr") ;
return false ;
}
+7 -4
View File
@@ -293,8 +293,9 @@ MachMgr::GetFixturePhases( int nFxtId, INTVECTOR& vPhase) const
// verifica validità bloccaggio
if ( ! VerifyFixtureInGroup( nFxtId))
return false ;
// recupero le fasi in cui è presente la fixture (se manca è non usata)
m_pGeomDB->GetInfo( nFxtId, MACH_FXT_PHASE, vPhase) ;
// recupero le fasi in cui è presente la fixture (se manca è fase 1)
if ( ! m_pGeomDB->GetInfo( nFxtId, MACH_FXT_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
return true ;
}
@@ -312,7 +313,8 @@ MachMgr::GetUnusedFixture( const string& sName, int nPhase) const
while ( nId != GDB_ID_NULL) {
// recupero le fasi in cui è già usato
INTVECTOR vPhase ;
m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) ;
if ( ! m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
// se non c'è la fase corrente, è libero
if ( find( vPhase.begin(), vPhase.end(), nPhase) == vPhase.end())
return nId ;
@@ -335,7 +337,8 @@ MachMgr::IsUnusedFixture( int nId, int nPhase) const
// Verifico non sia usata nella fase indicata
// recupero le fasi in cui è già usato
INTVECTOR vPhase ;
m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) ;
if ( ! m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
// se non c'è la fase corrente, è libero
if ( find( vPhase.begin(), vPhase.end(), nPhase) == vPhase.end())
return true ;
+39 -91
View File
@@ -19,43 +19,12 @@
#include "MachiningsMgr.h"
#include "SawingData.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnFileUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
MachMgr::GetMachines( STRVECTOR& vsMachineNames, STRVECTOR& vsMachineDirs) const
{
// pulisco elenco delle macchine
vsMachineNames.clear() ;
// eseguo ricerca delle macchine nei direttori base
for ( int i = 0 ; i < int( m_vMachinesBaseDir.size()) ; ++ i) {
STRVECTOR vsDirNames ;
if ( FindAllDirectories( m_vMachinesBaseDir[i] + "\\*", vsDirNames)) {
for ( int j = 0 ; j < int( vsDirNames.size()) ; ++ j) {
// nome e direttorio della macchina
string sMachName = vsDirNames[j] ;
string sMachDir = m_vMachinesBaseDir[i] + "\\" + vsDirNames[j] ;
// verifico esista il file mlde ( o mde) della macchina
string sMachineMlde = sMachDir + "\\" + sMachName + ".Mlde" ;
string sMachineMde = sMachDir + "\\" + sMachName + ".Mde" ;
if ( ( ExistsFile( sMachineMlde) || ExistsFile( sMachineMde)) &&
find_if( vsMachineNames.begin(), vsMachineNames.end(),
[ &sMachName]( const string& sName)
{ return EqualNoCase( sName, sMachName) ; }) == vsMachineNames.end()) {
vsMachineNames.emplace_back( sMachName) ;
vsMachineDirs.emplace_back( sMachDir) ;
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::LoadMachine( const string& sMachineName)
@@ -66,25 +35,14 @@ MachMgr::LoadMachine( const string& sMachineName)
// se macchina già caricata, non devo fare alcunchè
if ( GetMachine( sMachineName) != - 1)
return true ;
// cerco il direttorio della macchina
string sMachDir ;
for ( int i = 0 ; i < int( m_vMachinesBaseDir.size()) ; ++ i) {
string sTemp = m_vMachinesBaseDir[i] + "\\" + sMachineName ;
if ( ExistsDirectory( sTemp)) {
sMachDir = sTemp ;
break ;
}
}
if ( IsEmptyOrSpaces( sMachDir))
return false ;
// verifico esista il file mlde ( o mde) della macchina
string sMachineMlde = sMachDir + "\\" + sMachineName + ".Mlde" ;
string sMachineMlde = m_sMachinesDir + "\\" + sMachineName + "\\" + sMachineName + ".Mlde" ;
if ( ! ExistsFile( sMachineMlde))
sMachineMlde = ChangeFileExtension( sMachineMlde, ".Mde") ;
if ( ! ExistsFile( sMachineMlde))
return false ;
// salvo nel vettore
m_vMachines.emplace_back( sMachineName, sMachDir, nullptr, nullptr, nullptr) ;
m_vMachines.emplace_back( sMachineName, nullptr, nullptr, nullptr) ;
return true ;
}
@@ -139,7 +97,7 @@ MachMgr::GetCurrMachineDir( string& sMachineDir) const
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
return false ;
// assegno il direttorio
sMachineDir = m_vMachines[m_nCurrMch].sDir ;
sMachineDir = m_sMachinesDir + "\\" + m_vMachines[m_nCurrMch].sName ;
return true ;
}
@@ -168,7 +126,7 @@ MachMgr::GetCurrMachine( void) const
return nullptr ;
// creo e carico la macchina
PtrOwner<Machine> pMch( new( nothrow) Machine) ;
if ( IsNull( pMch) || ! pMch->Init( m_vMachines[m_nCurrMch].sName, m_vMachines[m_nCurrMch].sDir, const_cast<MachMgr*>(this)))
if ( IsNull( pMch) || ! pMch->Init( m_sMachinesDir, m_vMachines[m_nCurrMch].sName, const_cast<MachMgr*>(this)))
return nullptr ;
// nascondo la macchina
if ( m_pGeomDB != nullptr)
@@ -190,7 +148,7 @@ MachMgr::GetCurrToolsMgr( void) const
// se DB utensili non esiste, provo a crearlo e caricarlo
if ( m_vMachines[m_nCurrMch].pTsMgr == nullptr) {
PtrOwner<ToolsMgr> pTsMgr( new( nothrow) ToolsMgr) ;
string sToolsDir = m_vMachines[m_nCurrMch].sDir + "\\" + TOOLS_DIR ;
string sToolsDir = m_sMachinesDir + "\\" + m_vMachines[m_nCurrMch].sName + "\\" + TOOLS_DIR ;
if ( IsNull( pTsMgr) || ! pTsMgr->Load( sToolsDir, TOOLS_FILE))
return nullptr ;
// salvo nel vettore
@@ -210,7 +168,7 @@ MachMgr::GetCurrMachiningsMgr( void) const
// se DB lavorazioni non esiste, provo a crearlo e caricarlo
if ( m_vMachines[m_nCurrMch].pMsMgr == nullptr) {
PtrOwner<MachiningsMgr> pMsMgr( new( nothrow) MachiningsMgr) ;
string sMachsFile = m_vMachines[m_nCurrMch].sDir + "\\" + MACHININGS_DIR + "\\" + MACHININGS_FILE ;
string sMachsFile = m_sMachinesDir + "\\" + m_vMachines[m_nCurrMch].sName + "\\" + MACHININGS_DIR + "\\" + MACHININGS_FILE ;
if ( IsNull( pMsMgr) || ! pMsMgr->Load( sMachsFile, GetCurrToolsMgr()))
return nullptr ;
// salvo nel vettore
@@ -342,15 +300,6 @@ MachMgr::GetAxisInvert( const string& sAxis, bool& bInvert) const
return ( ( pMch != nullptr) ? pMch->GetAxisInvert( sAxis, bInvert) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAxisOffset( const string& sAxis, double& dOffset) const
{
Machine* pMch = GetCurrMachine() ;
// restituisco il valore di offset asse in visualizzazione
return ( ( pMch != nullptr) ? pMch->GetAxisOffset( sAxis, dOffset) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal)
@@ -587,15 +536,7 @@ double
MachMgr::GetCalcRot1W( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrRot1W() : 1) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcMaxDeltaR2OnFirst( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrMaxDeltaR2OnFirst() : true) ;
return ( ( pMch != nullptr) ? pMch->GetCurrRot1W() : false) ;
}
//----------------------------------------------------------------------------
@@ -604,9 +545,12 @@ MachMgr::GetAllTablesNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco tavole alla macchina corrente
// recupero la macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllTablesNames( vNames) : false) ;
if ( pMch == nullptr)
return false ;
// richiedo elenco tavole alla macchina
return pMch->GetAllTablesNames( vNames) ;
}
//----------------------------------------------------------------------------
@@ -615,9 +559,12 @@ MachMgr::GetAllHeadsNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco teste alla macchina corrente
// recupero la macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllHeadsNames( vNames) : false) ;
if ( pMch == nullptr)
return false ;
// richiedo elenco teste alla macchina
return pMch->GetAllHeadsNames( vNames) ;
}
//----------------------------------------------------------------------------
@@ -626,9 +573,12 @@ MachMgr::GetAllTcPosNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco posizioni cambio utensile alla macchina corrente
// recupero la macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllTcPosNames( vNames) : false) ;
if ( pMch == nullptr)
return false ;
// richiedo elenco posizioni cambio utensile alla macchina
return pMch->GetAllTcPosNames( vNames) ;
}
//----------------------------------------------------------------------------
@@ -671,18 +621,6 @@ MachMgr::GetCurrAxisHomePos( int nInd, double& dHome) const
return ( ( pMch != nullptr) ? pMch->GetCurrAxisHomePos( nInd, dHome) : false) ;
}
//----------------------------------------------------------------------------
const Frame3d&
MachMgr::GetCurrLinAxesFrame( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr) {
static Frame3d frDummy ;
return frDummy ;
}
return pMch->GetCurrLinAxesFrame() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
@@ -744,7 +682,9 @@ bool
MachMgr::GetCalcToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetToolDirFromAngles( vAng, vtDir) : false) ;
if ( pMch == nullptr)
return false ;
return pMch->GetToolDirFromAngles( vAng, vtDir) ;
}
//----------------------------------------------------------------------------
@@ -752,7 +692,9 @@ bool
MachMgr::GetCalcAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAuxDirFromAngles( vAng, vtDir) : false) ;
if ( pMch == nullptr)
return false ;
return pMch->GetAuxDirFromAngles( vAng, vtDir) ;
}
//----------------------------------------------------------------------------
@@ -760,7 +702,9 @@ bool
MachMgr::GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetPartDirFromAngles( vtPart, vAng, vtDir) : false) ;
if ( pMch == nullptr)
return false ;
return pMch->GetPartDirFromAngles( vtPart, vAng, vtDir) ;
}
//----------------------------------------------------------------------------
@@ -816,7 +760,9 @@ string
MachMgr::GetOutstrokeInfo( bool bMM) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetOutstrokeInfo( bMM) : "") ;
if ( pMch == nullptr)
return "" ;
return pMch->GetOutstrokeInfo( bMM) ;
}
//----------------------------------------------------------------------------
@@ -832,5 +778,7 @@ int
MachMgr::GetMachineLook( void) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetLook() : MCH_LOOK_NONE) ;
if ( pMch == nullptr)
return MCH_LOOK_NONE ;
return pMch->GetLook() ;
}
-12
View File
@@ -642,9 +642,6 @@ MachMgr::DispositionSpecialApply( int nId, bool bRecalc)
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nId)) ;
if ( pDisp == nullptr)
return false ;
// Eventuale log
string sOut = "DispositionSpecialApply start --> " + pDisp->GetName() ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
// lancio l'azione
return pDisp->SpecialApply( bRecalc) ;
}
@@ -665,9 +662,6 @@ MachMgr::DispositionSpecialUpdate( int nId)
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nId)) ;
if ( pDisp == nullptr)
return false ;
// Eventuale log
string sOut = "DispositionSpecialUpdate start --> " + pDisp->GetName() ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
// lancio l'azione
return pDisp->SpecialUpdate() ;
}
@@ -1047,9 +1041,6 @@ MachMgr::MachiningApply( bool bRecalc, bool bPostApply)
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ;
if ( pMch == nullptr)
return false ;
// Log
string sOut = "MachiningApply start --> " + pMch->GetName() ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
// imposto fase della lavorazione come temporaneamente corrente
SetTempPhase TmpPhase( this, pMch->GetPhase()) ;
// imposto visualizzazione completa della macchina come temporaneamente corrente
@@ -1078,9 +1069,6 @@ MachMgr::MachiningUpdate( bool bPostApply)
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ;
if ( pMch == nullptr)
return false ;
// Log
string sOut = "MachiningUpdate start --> " + pMch->GetName() ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
// imposto fase della lavorazione come temporaneamente corrente
SetTempPhase TmpPhase( this, pMch->GetPhase()) ;
// imposto visualizzazione completa della macchina come temporaneamente corrente
+1 -1
View File
@@ -24,7 +24,7 @@
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
+4 -26
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2023
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : MachMgrSimulation.cpp Data : 16.01.23 Versione : 2.5a2
// File : MachMgrSimulation.cpp Data : 20.10.15 Versione : 1.6j2
// Contenuto : Implementazione gestione simulazione della classe MachMgr.
//
//
@@ -150,13 +150,13 @@ MachMgr::SimExit( void)
//----------------------------------------------------------------------------
bool
MachMgr::SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// aggiungo un oggetto da verificare per la collisione con il grezzo
return m_pSimul->AddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
}
//----------------------------------------------------------------------------
@@ -180,25 +180,3 @@ MachMgr::SimOnCollision( int nCdInd, int nObjInd, int& nErr)
// lancio funzione di gestione collisione
return m_pSimul->OnCollision( nCdInd, nObjInd, nErr) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimSetToolForVmill( const string& sTool, const string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// imposto utensile per Vmill
return m_pSimul->SetToolForVmill( sTool, sHead, nExit, vVmill, bFirst) ;
}
//----------------------------------------------------------------------------
int
MachMgr::SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// lancio movimento assi
return m_pSimul->MoveAxes( nMoveType, vAxNaEpSt) ;
}
+10 -17
View File
@@ -46,18 +46,11 @@ Machine::Machine( void)
m_nCalcExitId = GDB_ID_NULL ;
m_nCalcToolId = GDB_ID_NULL ;
m_dCalcRot1W = 1 ;
m_bCalcMaxDeltaR2On1 = true ;
m_nCalcSolCh = MCH_SCC_NONE ;
m_dCalcTLen = 0 ;
m_dCalcTRad = 0 ;
m_dCalcTOvLen = 0 ;
m_dCalcTOvRad = 0 ;
m_nTabLinAxes = 0 ;
m_nTabRotAxes = 0 ;
m_nHeadLinAxes = 0 ;
m_nHeadRotAxes = 0 ;
m_nHeadSpecRotAxis = -1 ;
m_frLinAx.Reset( false) ;
m_nMachineLook = MCH_LOOK_NONE ;
}
@@ -93,7 +86,7 @@ Machine::Clear( void)
//----------------------------------------------------------------------------
bool
Machine::Init( const string& sMachineName, const string& sMachineDir, MachMgr* pMchMgr)
Machine::Init( const string& sMachinesDir, const string& sMachineName, MachMgr* pMchMgr)
{
// pulisco
Clear() ;
@@ -103,7 +96,7 @@ Machine::Init( const string& sMachineName, const string& sMachineDir, MachMgr* p
m_pMchMgr = pMchMgr ;
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
// verifico direttorio dati macchina
m_sMachineDir = sMachineDir ;
m_sMachineDir = sMachinesDir + "\\" + sMachineName ;
if ( ! ExistsDirectory( m_sMachineDir))
return false ;
// creo il gruppo per la macchina
@@ -287,7 +280,7 @@ Machine::AdjustTable( int nLay, const Point3d& ptRef1)
//----------------------------------------------------------------------------
bool
Machine::LoadMachineAxis( const string& sName, const string& sParent, const string& sToken, bool bInvert,
double dOffset, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
double dHome, bool bAdjustAux, const string& sGeo, const STRVECTOR& vsAux)
{
// verifico sia di tipo ammesso
@@ -328,7 +321,7 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, const stri
Axis* pAxis = new(nothrow) Axis ;
if ( pAxis == nullptr)
return false ;
pAxis->Set( sName, sToken, bInvert, dOffset, nType, ptPos, vtDir, Stroke, dHome) ;
pAxis->Set( sName, sToken, bInvert, nType, ptPos, vtDir, Stroke, dHome) ;
m_pGeomDB->SetUserObj( nLay, pAxis) ;
// verifico il vettore rappresentativo dell'asse
if ( ! AdjustAxis( nLay, sPart, sName, nType, ptPos, vtDir, bAdjustAux))
@@ -500,7 +493,7 @@ Machine::ModifyMachineAxisHome( const string& sName, double dHome)
bool
Machine::LoadMachineStdHead( const string& sName, const string& sParent, const string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della testa
@@ -528,7 +521,7 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_STD, 1, sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_STD, 1, sHSet, vtADir, dRot1W, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
@@ -549,7 +542,7 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
bool
Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const string& sHSet,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della testa
@@ -577,7 +570,7 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_MULTI, int( vMuExit.size()), sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_MULTI, int( vMuExit.size()), sHSet, vtADir, dRot1W, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
@@ -596,7 +589,7 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
bool
Machine::LoadMachineSpecialHead( const string& sName, const string& sParent, const string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della testa
@@ -624,7 +617,7 @@ Machine::LoadMachineSpecialHead( const string& sName, const string& sParent, con
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_SPECIAL, 1, sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_SPECIAL, 1, sHSet, vtADir, dRot1W, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
+11 -30
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2023
// EgalTech 2015-2021
//----------------------------------------------------------------------------
// File : Machine.h Data : 16.01.23 Versione : 2.5a2
// File : Machine.h Data : 14.10.21 Versione : 2.3j5
// Contenuto : Dichiarazione della classe Machine.
//
//
@@ -34,7 +34,7 @@ class Machine
public :
Machine( void) ;
~Machine( void) ;
bool Init( const std::string& sMachineName, const std::string& sMachineDir, MachMgr* pMchMgr) ;
bool Init( const std::string& sMachinesDir, const std::string& sMachineName, MachMgr* pMchMgr) ;
const std::string& GetMachineName( void) const
{ return m_sName ; }
const std::string& GetMachineDir( void) const
@@ -53,10 +53,6 @@ class Machine
int GetHeadId( const std::string& sHead) const
{ int nId = GetGroup( sHead) ;
return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetExitId( const std::string& sHead, int nExit) const
{ int nHeadId = GetHeadId( sHead) ;
int nId = ( m_pGeomDB != nullptr ? m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_EXIT + ToString( nExit)) : GDB_ID_NULL) ;
return ( IsExitGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetTcPosId( const std::string& sTcPos) const
{ int nId = GetGroup( sTcPos) ;
return ( IsTcPosGroup( nId) ? nId : GDB_ID_NULL) ; }
@@ -79,7 +75,6 @@ class Machine
bool ResetHeadSet( const std::string& sHead) ;
bool GetAxisToken( const std::string& sAxis, std::string& sToken) const ;
bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const ;
bool GetAxisOffset( const std::string& sAxis, double& dOffset) const ;
bool GetAxisType( const std::string& sAxis, bool& bLinear) const ;
bool SetAxisPos( const std::string& sAxis, double dVal, double* pdNewVal = nullptr) ;
bool GetAxisPos( const std::string& sAxis, double& dVal) const ;
@@ -105,10 +100,7 @@ class Machine
int GetCurrExit( void) const ;
bool GetCurrExit( int& nExit) const ;
bool GetCurrHeadCollGroups( INTVECTOR& vIds) const ;
double GetCurrRot1W( void) const
{ return m_dCalcRot1W ; }
bool GetCurrMaxDeltaR2OnFirst( void) const
{ return m_bCalcMaxDeltaR2On1 ; }
double GetCurrRot1W( void) const ;
std::string GetKinematicAxis( int nInd) const ;
bool BlockKinematicRotAxis( const std::string& sName, double dVal) ;
bool BlockKinematicRotAxis( int nId, double dVal) ;
@@ -127,14 +119,14 @@ class Machine
bool GetCurrAxisMax( int nInd, double& dMax) const ;
bool GetCurrAxisHomePos( int nInd, double& dHome) const ;
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
const Frame3d& GetCurrLinAxesFrame( void) const
{ return m_frLinAx ; }
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ;
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
bool GetPositions( const Point3d& ptP, const DBLVECTOR& vAng,
int& nStat, double& dX, double& dY, double& dZ) const ;
bool GetHeadOffsetDelta( const DBLVECTOR& vAng,
double& dRecX, double& dRecY, double& dRecZ) const ;
bool GetNoseFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
Point3d& ptNose) const ;
bool GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
@@ -192,8 +184,8 @@ class Machine
const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustTable( int nLay, const Point3d& ptRef1) ;
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken, bool bInvert,
double dOffset, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken,
bool bInvert, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
double dHome, bool bAdjustAux, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustAxis( int nLay, const std::string& sPart, const std::string& sName,
int nType, const Point3d& ptPos, const Vector3d& vtDir, bool bAdjustAux) ;
@@ -203,15 +195,15 @@ class Machine
bool ModifyMachineAxisHome( const std::string& sName, double dHome) ;
bool LoadMachineStdHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineMultiHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineSpecialHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineTcPos( const std::string& sName, const std::string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
@@ -287,7 +279,6 @@ class Machine
int m_nCalcExitId ; // uscita corrente per calcoli
int m_nCalcToolId ; // utensile corrente per calcoli
double m_dCalcRot1W ; // peso del primo asse rotante per i confronti
bool m_bCalcMaxDeltaR2On1 ; // flag utilizzo controllo massimo delta secondo asse rotante su inizio lavorazione
int m_nCalcSolCh ; // criterio di scelta della soluzione
bool m_bSolChExact ; // flag per scelta soluzione da soddisfare esattamente
Point3d m_ptCalcPos ; // posizione utensile a riposo per calcoli
@@ -297,14 +288,8 @@ class Machine
double m_dCalcTRad ; // raggio utensile corrente per calcoli
double m_dCalcTOvLen ; // lunghezza di ingombro utensile corrente per calcoli
double m_dCalcTOvRad ; // raggio di ingombro utensile corrente per calcoli
int m_nTabLinAxes ; // numero assi lineari attivi di tavola per calcoli
int m_nTabRotAxes ; // numero assi rotanti attivi di tavola per calcoli
int m_nHeadLinAxes ; // numero assi lineari attivi di testa per calcoli
int m_nHeadRotAxes ; // numero assi rotanti attivi di testa per calcoli
int m_nHeadSpecRotAxis ; // indice eventuale asse rotante speciale di testa prima dei lineari di testa (-1 non esiste)
KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli
KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli
Frame3d m_frLinAx ; // sistema di riferimento definito dagli assi lineari
mutable OutStroke m_OutstrokeInfo ; // informazioni su ultima extra corsa
// stato di visualizzazione
int m_nMachineLook ; // stato di visualizzazione della macchina
@@ -354,10 +339,6 @@ class Machine
static int LuaEmtAddCollisionObjEx( lua_State* L) ;
static int LuaEmtExecCollisionCheck( lua_State* L) ;
static int LuaEmtOnCollision( lua_State* L) ;
static int LuaEmtSetToolForVmill( lua_State* L) ;
static int LuaEmtAddToolForVmill( lua_State* L) ;
static int LuaEmtMoveAxes( lua_State* L) ;
} ;
//----------------------------------------------------------------------------
-16
View File
@@ -54,22 +54,6 @@ Machine::GetAxisInvert( const string& sAxis, bool& bInvert) const
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetAxisOffset( const string& sAxis, double& dOffset) const
{
// controllo GeomDB
if ( m_pGeomDB == nullptr)
return false ;
// recupero il relativo gestore
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
if ( pAx == nullptr)
return false ;
// recupero il valore di offset dell'asse in visualizzazione
dOffset = pAx->GetOffset() ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetAxisType( const string& sAxis, bool& bLinear) const
+95 -196
View File
@@ -174,12 +174,6 @@ Machine::GetCurrTableIsTilting( bool& bTilting) const
// verifico esistenza tavola
if ( m_nCalcTabId == GDB_ID_NULL)
return false ;
// verifico se presente flag che lo forza come tale
bool bTiltingLike ;
if ( m_pGeomDB->GetInfo( m_nCalcTabId, MCH_TILTINGLIKE, bTiltingLike) && bTiltingLike) {
bTilting = true ;
return true ;
}
// recupero gli eventuali assi rotanti della tavola
int nTParId = m_pGeomDB->GetParentId( m_nCalcTabId) ;
if ( nTParId == GDB_ID_NULL)
@@ -215,9 +209,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
// recupero i dati della testa
Head* pHead = GetHead( nHeadId) ;
if ( pHead == nullptr) {
string sOutHead = ( IsEmptyOrSpaces( sHead) ? "???" : sHead) ;
string sOutTool = ( IsEmptyOrSpaces( sTool) ? "???" : sTool) ;
string sOut = "Missing head " + sOutHead + " for tool " + sOutTool ;
string sOut = "Missing head " + sHead + " for tool " + sTool ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
return false ;
}
@@ -281,7 +273,6 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
m_nCalcExitId = nExitId ;
m_nCalcToolId = nToolId ;
m_dCalcRot1W = pHead->GetRot1W() ;
m_bCalcMaxDeltaR2On1 = pHead->GetMaxDeltaR2On1() ;
m_nCalcSolCh = pHead->GetSolCh() ;
m_ptCalcPos = pExit->GetPos() ;
m_vtCalcDir = pExit->GetTDir() ;
@@ -436,6 +427,14 @@ Machine::GetCurrHeadCollGroups( INTVECTOR& vIds) const
return true ;
}
//----------------------------------------------------------------------------
double
Machine::GetCurrRot1W( void) const
{
// restituisco il peso del primo asse rotante nei confronti di movimento
return m_dCalcRot1W ;
}
//----------------------------------------------------------------------------
bool
Machine::CalculateKinematicChain( void)
@@ -444,11 +443,6 @@ Machine::CalculateKinematicChain( void)
if ( m_pGeomDB == nullptr)
return false ;
// azzero tutti gli assi della catena cinematica
m_nTabLinAxes = 0 ;
m_nTabRotAxes = 0 ;
m_nHeadLinAxes = 0 ;
m_nHeadRotAxes = 0 ;
m_nHeadSpecRotAxis = -1 ;
m_vCalcLinAx.clear() ;
m_vCalcRotAx.clear() ;
// recupero gli assi di tavola
@@ -457,8 +451,6 @@ Machine::CalculateKinematicChain( void)
int nTParId = m_pGeomDB->GetParentId( m_nCalcTabId) ;
if ( nTParId == GDB_ID_NULL)
return false ;
m_nTabLinAxes = 0 ;
m_nTabRotAxes = 0 ;
while ( IsAxisGroup( nTParId)) {
if ( ! AddKinematicAxis( false, nTParId))
return false ;
@@ -470,63 +462,40 @@ Machine::CalculateKinematicChain( void)
int nHParId = m_pGeomDB->GetParentId( m_nCalcHeadId) ;
if ( nHParId == GDB_ID_NULL)
return false ;
m_nHeadLinAxes = 0 ;
m_nHeadRotAxes = 0 ;
while ( IsAxisGroup( nHParId)) {
if ( ! AddKinematicAxis( true, nHParId))
return false ;
nHParId = m_pGeomDB->GetParentId( nHParId) ;
}
// verifiche sugli assi lineari :
// aggiusto gli indici di ordine sulla sua catena cinematica (1-based)
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
m_vCalcLinAx[i].nInd += m_nHeadLinAxes + m_nHeadRotAxes + 1 ;
else
m_vCalcLinAx[i].nInd *= -1 ;
}
// devono essere 3
if ( m_vCalcLinAx.size() != 3)
return false ;
// devono essere ordinabili come XYZ
if ( ! m_vCalcLinAx[0].vtDir.IsX()) {
if ( m_vCalcLinAx[1].vtDir.IsX())
if ( ! m_vCalcLinAx[0].vtDir.IsXplus()) {
if ( m_vCalcLinAx[1].vtDir.IsXplus())
swap( m_vCalcLinAx[0], m_vCalcLinAx[1]) ;
else if ( m_vCalcLinAx[2].vtDir.IsX())
else if ( m_vCalcLinAx[2].vtDir.IsXplus())
swap( m_vCalcLinAx[0], m_vCalcLinAx[2]) ;
else {
LOG_ERROR( GetEMkLogger(), "Linear Axes are not aligned with Global XYZ")
LOG_ERROR( GetEMkLogger(), "Linear Axes not aligned with Global XYZ")
return false ;
}
}
if ( ! m_vCalcLinAx[1].vtDir.IsY()) {
if ( m_vCalcLinAx[2].vtDir.IsY())
if ( ! m_vCalcLinAx[1].vtDir.IsYplus()) {
if ( m_vCalcLinAx[2].vtDir.IsYplus())
swap( m_vCalcLinAx[1], m_vCalcLinAx[2]) ;
else {
LOG_ERROR( GetEMkLogger(), "Linear Axes are not aligned with Global XYZ")
LOG_ERROR( GetEMkLogger(), "Linear Axes not aligned with Global XYZ")
return false ;
}
}
if ( ! m_frLinAx.Set( ORIG, m_vCalcLinAx[0].vtDir, m_vCalcLinAx[1].vtDir, m_vCalcLinAx[2].vtDir)) {
LOG_ERROR( GetEMkLogger(), "Linear Axes are not a Rigth-handed Frame")
return false ;
}
// verifiche sugli assi rotanti :
bool bOk = false ;
// aggiusto gli indici di ordine sulla sua catena cinematica (1-based)
for ( int i = 0 ; i < int( m_vCalcRotAx.size()) ; ++ i) {
if ( m_vCalcRotAx[i].bHead)
m_vCalcRotAx[i].nInd += m_nHeadLinAxes + m_nHeadRotAxes + 1 ;
else
m_vCalcRotAx[i].nInd *= -1 ;
}
// se 0 o 1 va bene
if ( m_vCalcRotAx.size() <= 1)
bOk = true ;
return true ;
// se 2 va bene
else if ( m_vCalcRotAx.size() == 2) {
if ( m_vCalcRotAx.size() == 2) {
// se entrambi di testa devo invertirne l'ordine
if ( m_vCalcRotAx[0].bHead && m_vCalcRotAx[1].bHead)
swap( m_vCalcRotAx[0], m_vCalcRotAx[1]) ;
@@ -538,10 +507,10 @@ Machine::CalculateKinematicChain( void)
m_vCalcRotAx[1].stroke.Max = min( m_vCalcRotAx[1].stroke.Max, pHead->GetRot2Stroke().Max) ;
}
}
bOk = true ;
return true ;
}
// se 3 va bene ( uno dovrà poi avere valore assegnato)
else if ( m_vCalcRotAx.size() == 3) {
if ( m_vCalcRotAx.size() == 3) {
int n2ndHeadRotAx = - 1 ;
// se tutti e tre di testa, devo invertire il primo con il terzo
if ( m_vCalcRotAx[0].bHead && m_vCalcRotAx[1].bHead && m_vCalcRotAx[2].bHead) {
@@ -561,48 +530,10 @@ Machine::CalculateKinematicChain( void)
m_vCalcRotAx[n2ndHeadRotAx].stroke.Max = min( m_vCalcRotAx[n2ndHeadRotAx].stroke.Max, pHead->GetRot2Stroke().Max) ;
}
}
bOk = true ;
return true ;
}
if ( ! bOk)
return false ;
// verifico esistenza eventuale asse rotante speciale di testa
if ( m_nHeadRotAxes > 0 && m_nHeadLinAxes > 0) {
// indice di posizione primo asse di testa
int nHeadFirst = 1 ;
// ricerco sui rotanti
for ( int i = 0 ; i < int( m_vCalcRotAx.size()) ; ++ i) {
// se asse di testa
if ( m_vCalcRotAx[i].bHead && m_vCalcRotAx[i].nInd <= nHeadFirst) {
// non sono ammessi due assi di questo tipo
if ( m_nHeadSpecRotAxis != -1)
return false ;
// la tavola non deve avere più di un asse lineare
if ( m_nTabLinAxes > 1)
return false ;
// se ha un asse lineare deve essere allineato con il rotante speciale
else if ( m_nTabLinAxes == 1) {
// ne recupero la direzione
Vector3d vtTabLinDir ;
for ( int j = 0 ; j < int( m_vCalcLinAx.size()) ; ++ j) {
if ( ! m_vCalcLinAx[i].bHead) {
vtTabLinDir = m_vCalcLinAx[i].vtDir ;
break ;
}
}
// la confronto con quella dell'asse rotante speciale
if ( ! AreSameOrOppositeVectorApprox( vtTabLinDir, m_vCalcRotAx[i].vtDir))
return false ;
}
// ne salvo l'indice
m_nHeadSpecRotAxis = i ;
// incremento indice di posizione posibile primo asse lineare di testa
++ nHeadFirst ;
}
}
}
return true ;
// altrimenti non ancora gestito, quindi errore
// altrimenti non ancora gestito, quindi errore
LOG_ERROR( GetEMkLogger(), "Rotary Axes not manageable")
return false ;
}
@@ -622,20 +553,11 @@ Machine::AddKinematicAxis( bool bOnHead, int nId)
KinAxis kAx ;
kAx.nGrpId = nId ;
kAx.bLinear = ( pAx->GetType() != MCH_AT_ROTARY) ;
kAx.bHead = bOnHead ; // catena cinematica di appartenenza (testa o tavola)
kAx.bHead = bOnHead ; // posizione su catena cinematica
kAx.ptPos = pAx->GetPos() ;
kAx.vtDir = pAx->GetDir() ;
kAx.stroke = pAx->GetStroke() ;
kAx.dHomeVal = pAx->GetHomeVal() ;
// ne determino l'indice di posizione nella sua catena cinematica (assegno valore negato perchè provvisorio)
if ( kAx.bHead) {
( kAx.bLinear ? ++ m_nHeadLinAxes : ++ m_nHeadRotAxes) ;
kAx.nInd = - ( m_nHeadLinAxes + m_nHeadRotAxes) ;
}
else {
( kAx.bLinear ? ++ m_nTabLinAxes : ++ m_nTabRotAxes) ;
kAx.nInd = - ( m_nTabLinAxes + m_nTabRotAxes) ;
}
// se lineare di tavola, devo invertirlo
if ( kAx.bLinear && ! kAx.bHead)
kAx.vtDir.Invert() ;
@@ -1103,33 +1025,26 @@ Machine::GetPositions( const Point3d& ptP, const DBLVECTOR& vAng,
// aggiorno punto di lavoro mediante ciclo diretto sugli assi di tavola
Point3d ptW = ptP ;
// annullo la posizione home degli assi lineari
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
for ( size_t i = 0 ; i < m_vCalcLinAx.size() ; ++ i) {
// se asse di tavola
if ( ! m_vCalcLinAx[i].bHead)
ptW.Translate( - m_vCalcLinAx[i].dHomeVal * ( - m_vCalcLinAx[i].vtDir)) ;
}
// effettuo rotazione diminuita della posizione home degli assi rotanti
for ( int i = 0 ; i < int( m_vCalcRotAx.size()) ; ++ i) {
for ( size_t i = 0 ; i < m_vCalcRotAx.size() ; ++ i) {
// se asse di tavola
if ( ! m_vCalcRotAx[i].bHead)
ptW.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i] - m_vCalcRotAx[i].dHomeVal) ;
}
// effettuo rotazione inversa per asse rotante di testa speciale
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptW.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, -vAng[i]) ;
}
// aggiorno posizione e direzione fresa su testa a riposo mediante ciclo inverso sugli assi di testa
Point3d ptPosH = m_ptCalcPos ;
Vector3d vtDirH = m_vtCalcDir ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis) {
ptPosH.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
vtDirH.Rotate( m_vCalcRotAx[i].vtDir, vAng[i]) ;
for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) {
// se asse di testa
if ( m_vCalcRotAx[i-1].bHead) {
ptPosH.Rotate( m_vCalcRotAx[i-1].ptPos, m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
vtDirH.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
}
}
@@ -1142,20 +1057,56 @@ Machine::GetPositions( const Point3d& ptP, const DBLVECTOR& vAng,
// calcolo il recupero di lunghezza utensile
Vector3d vtDtTL = vtDirH * m_dCalcTLen ;
// calcolo i valori degli assi lineari (posizioni)
Point3d ptPos( ptW.x + vtDtHe.x + vtDtAx.x + vtDtTL.x,
ptW.y + vtDtHe.y + vtDtAx.y + vtDtTL.y,
ptW.z + vtDtHe.z + vtDtAx.z + vtDtTL.z) ;
ptPos.ToLoc( m_frLinAx) ;
dX = ptPos.x ;
dY = ptPos.y ;
dZ = ptPos.z ;
// calcolo le posizioni degli assi lineari
dX = ptW.x + vtDtHe.x + vtDtAx.x + vtDtTL.x ;
dY = ptW.y + vtDtHe.y + vtDtAx.y + vtDtTL.y ;
dZ = ptW.z + vtDtHe.z + vtDtAx.z + vtDtTL.z ;
// tutto ok
nStat = 0 ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetHeadOffsetDelta( const DBLVECTOR& vAng,
double& dRecX, double& dRecY, double& dRecZ) const
{
// ovviamente tutto è espresso nel riferimento ZERO MACCHINA
// verifico che siano stati assegnati gli angoli necessari, altrimenti errore
if ( vAng.size() < m_vCalcRotAx.size())
return false ;
// aggiorno posizione e direzione fresa su testa a riposo mediante ciclo inverso sugli assi di testa
Point3d ptPosH = m_ptCalcPos ;
Vector3d vtDirH = m_vtCalcDir ;
for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) {
// se asse di testa
if ( m_vCalcRotAx[i-1].bHead) {
ptPosH.Rotate( m_vCalcRotAx[i-1].ptPos, m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
vtDirH.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
}
}
// assegno l'offset testa
Vector3d vtDtHe = ORIG - m_ptCalcPos ;
// calcolo il recupero degli assi : è l'opposto dello spostamento della posizione
Vector3d vtDtAx = m_ptCalcPos - ptPosH ;
// calcolo il recupero di lunghezza utensile
Vector3d vtDtTL = vtDirH * m_dCalcTLen ;
// calcolo le posizioni degli assi lineari
dRecX = vtDtHe.x + vtDtAx.x + vtDtTL.x ;
dRecY = vtDtHe.y + vtDtAx.y + vtDtTL.y ;
dRecZ = vtDtHe.z + vtDtAx.z + vtDtTL.z ;
// tutto ok
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const
@@ -1215,25 +1166,17 @@ Machine::GetNoseFromPositions( double dX, double dY, double dZ, const DBLVECTOR&
// aggiorno posizione testa a riposo mediante ciclo inverso sugli assi rotanti di testa
ptNose = m_ptCalcPos ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) {
// se asse di testa
if ( m_vCalcRotAx[i-1].bHead)
ptNose.Rotate( m_vCalcRotAx[i-1].ptPos, m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
}
// aggiorno posizione testa con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptNose += m_vCalcLinAx[i].vtDir * vMov[i] ;
for ( size_t i = 1 ; i <= m_vCalcLinAx.size() ; ++ i) {
if ( m_vCalcLinAx[i-1].bHead)
ptNose += m_vCalcLinAx[i-1].vtDir * vMov[i-1] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
return true ;
}
@@ -1245,26 +1188,11 @@ Machine::GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR&
// la posizione deve essere espressa rispetto allo ZERO MACCHINA
// è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di testa)
// aggiorno posizione tip utensile a riposo mediante ciclo inverso sugli assi rotanti di testa
ptTip = m_ptCalcPos - m_vtCalcDir * m_dCalcTLen ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
// aggiorno posizione tip utensile con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptTip += m_vCalcLinAx[i].vtDir * vMov[i] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
// Calcoli recuperi della testa e lunghezza utensile per orientamento
double dRecX, dRecY, dRecZ ;
if ( ! GetHeadOffsetDelta( vAng, dRecX, dRecY, dRecZ))
return false ;
ptTip.Set( dX - dRecX, dY - dRecY, dZ - dRecZ) ;
// Se richiesto ingombro totale o punto sotto del tip utensile
if ( bOverall || bBottom) {
@@ -1308,7 +1236,7 @@ Machine::GetAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const
bool
Machine::GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const
{
// è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di tavola e asse rotante speciale di testa)
// è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di tavola)
// verifico dimensione vettore angoli rispetto al numero di assi rotanti
if ( vAng.size() < m_vCalcRotAx.size())
@@ -1324,14 +1252,6 @@ Machine::GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Ve
vtDir.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
}
// eseguo rotazione inversa eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
vtDir.Rotate( m_vCalcRotAx[i].vtDir, -vAng[i]) ;
}
return true ;
}
@@ -1421,33 +1341,12 @@ Machine::VerifyScc( const Vector3d& vtDirI, const Vector3d& vtDirA, int nSolCh,
bool
Machine::AdjustAngleInStroke( const STROKE& Stroke, double& dAng) const
{
// se asse rotante vero
if ( Stroke.Max - Stroke.Min > EPS_ANG_SMALL) {
// eseguo gli aggiustamenti
while ( dAng < Stroke.Min)
dAng += ANG_FULL ;
while ( dAng > Stroke.Max)
dAng -= ANG_FULL ;
// verifico
return ( dAng >= Stroke.Min && dAng <= Stroke.Max) ;
}
// altrimenti asse rotante senza corsa
else {
// angolo di riferimento
double dStrokeMid = ( Stroke.Min + Stroke.Max) / 2 ;
// eseguo gli aggiustamenti
while ( dAng < dStrokeMid - EPS_ANG_SMALL)
dAng += ANG_FULL ;
while ( dAng > dStrokeMid + EPS_ANG_SMALL)
dAng -= ANG_FULL ;
// verifico
if ( abs( dAng - dStrokeMid) < EPS_ANG_SMALL) {
dAng = dStrokeMid ;
return true ;
}
else
return false ;
}
// eseguo gli aggiustamenti
while ( dAng < Stroke.Min)
dAng += ANG_FULL ;
while ( dAng > Stroke.Max)
dAng -= ANG_FULL ;
return ( dAng >= Stroke.Min && dAng <= Stroke.Max) ;
}
//----------------------------------------------------------------------------
@@ -1458,9 +1357,9 @@ Machine::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const
if ( nInd < 0 || nInd >= int( m_vCalcRotAx.size()))
return true ;
// cerco l'angolo più vicino stando nella corsa
while ( dAng - dAngRef > ANG_STRAIGHT + EPS_ANG_ZERO && dAng - ANG_FULL >= m_vCalcRotAx[nInd].stroke.Min)
while ( dAng - dAngRef > ANG_STRAIGHT && dAng - ANG_FULL >= m_vCalcRotAx[nInd].stroke.Min)
dAng -= ANG_FULL ;
while ( dAng - dAngRef < -ANG_STRAIGHT + EPS_ANG_ZERO && dAng + ANG_FULL <= m_vCalcRotAx[nInd].stroke.Max)
while ( dAng - dAngRef < -ANG_STRAIGHT && dAng + ANG_FULL <= m_vCalcRotAx[nInd].stroke.Max)
dAng += ANG_FULL ;
return ( dAng >= m_vCalcRotAx[nInd].stroke.Min &&
dAng <= m_vCalcRotAx[nInd].stroke.Max) ;
-2
View File
@@ -171,8 +171,6 @@ Machine::LoadTool( Exit* pExit, const string& sTool)
return false ;
// sposto eventuali info relative al porta utensile (ToolHolder) nel gruppo SOLID
double dVal ;
if ( m_pGeomDB->GetInfo( nTGrpId, TTH_BASE, dVal))
m_pGeomDB->SetInfo( nSolidId, TTH_BASE, dVal) ;
if ( m_pGeomDB->GetInfo( nTGrpId, TTH_LEN, dVal))
m_pGeomDB->SetInfo( nSolidId, TTH_LEN, dVal) ;
if ( m_pGeomDB->GetInfo( nTGrpId, TTH_DIAM, dVal))
+12 -123
View File
@@ -41,7 +41,6 @@ static const string FLD_AUX = "Aux" ;
static const string FLD_TOKEN = "Token" ;
static const string FLD_TYPE = "Type" ;
static const string FLD_INVERT = "Invert" ;
static const string FLD_AXIS_OFFSET = "Offset" ;
static const string FLD_REF1 = "Ref1" ;
static const string FLD_SCALE = "Scale" ;
static const string FLD_POS = "Pos" ;
@@ -53,7 +52,6 @@ static const string FLD_HSET = "HSet" ;
static const string FLD_TDIR = "TDir" ;
static const string FLD_ADIR = "ADir" ;
static const string FLD_ROT1W = "Rot1W" ;
static const string FLD_MAXDELTAR2ON1 = "MaxDeltaR2OnFirst" ;
static const string FLD_ROT2STROKE = "Rot2Stroke" ;
static const string FLD_SOLCH = "SolCh" ;
static const string FLD_OTHCOLL = "OthColl" ;
@@ -132,12 +130,6 @@ Machine::LuaInit( const string& sMachineName)
m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ;
// registro la funzione di gestione della collisione in simulazione
m_LuaMgr.RegisterFunction( "EmtOnCollision", Machine::LuaEmtOnCollision) ;
// registro la funzione di impostazione del primo utensile per virtual milling in simulazione
m_LuaMgr.RegisterFunction( "EmtSetToolForVmill", Machine::LuaEmtSetToolForVmill) ;
// registro la funzione di impostazione di utensile aggiuntivo per virtual milling in simulazione
m_LuaMgr.RegisterFunction( "EmtAddToolForVmill", Machine::LuaEmtAddToolForVmill) ;
// registro la funzione di movimento assi in simulazione
m_LuaMgr.RegisterFunction( "EmtMoveAxes", Machine::LuaEmtMoveAxes) ;
return true ;
}
@@ -498,9 +490,6 @@ Machine::LuaEmtAxis( lua_State* L)
// lettura eventuale campo 'Invert' dalla tabella (default false)
bool bInvert = false ;
LuaGetTabFieldParam( L, 1, FLD_INVERT, bInvert) ;
// lettura eventuale campo 'Offset' dalla tabella (default 0)
double dOffset = 0 ;
LuaGetTabFieldParam( L, 1, FLD_AXIS_OFFSET, dOffset) ;
// lettura campo 'Type' dalla tabella
int nType ;
LuaCheckTabFieldParam( L, 1, FLD_TYPE, nType)
@@ -536,8 +525,8 @@ Machine::LuaEmtAxis( lua_State* L)
return luaL_error( L, " Unknown Machine") ;
// carico i dati dell'asse
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, sToken, bInvert, dOffset,
nType, ptPos, vtDir, Stroke, dHome, bAdjustAux, sGeo, vsAux))
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, sToken, bInvert, nType, ptPos, vtDir,
Stroke, dHome, bAdjustAux, sGeo, vsAux))
return luaL_error( L, " Load Machine Axis failed") ;
// restituisco l'indice dell'asse
@@ -601,9 +590,6 @@ Machine::LuaEmtStdHead( lua_State* L)
// lettura eventuale campo 'Rot1W' dalla tabella (default 1)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'MaxDeltaR2OnFirst' dalla tabella (default true)
bool bMaxDeltaR2On1 = true ;
LuaGetTabFieldParam( L, 1, FLD_MAXDELTAR2ON1, bMaxDeltaR2On1) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke{{ -INFINITO, INFINITO}} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
@@ -631,7 +617,7 @@ Machine::LuaEmtStdHead( lua_State* L)
// carico i dati della testa standard
if ( ! m_pMchLua->LoadMachineStdHead( sName, sParent, sHSet, ptPos, vtTDir, vtADir,
dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
dRot1W, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
return luaL_error( L, " Load Machine Standard Head failed") ;
// restituisco l'indice della testa
@@ -682,9 +668,6 @@ Machine::LuaEmtMultiHead( lua_State* L)
// lettura eventuale campo 'Rot1W' dalla tabella (default 1)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'MaxDeltaR2OnFirst' dalla tabella (default true)
bool bMaxDeltaR2On1 = true ;
LuaGetTabFieldParam( L, 1, FLD_MAXDELTAR2ON1, bMaxDeltaR2On1) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke{{ -INFINITO, INFINITO}} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
@@ -712,7 +695,7 @@ Machine::LuaEmtMultiHead( lua_State* L)
// carico i dati della testa multipla
if ( ! m_pMchLua->LoadMachineMultiHead( sName, sParent, sHSet, vMuExit, vtADir,
dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
dRot1W, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
return luaL_error( L, " Load Machine Standard Head failed") ;
// restituisco l'indice della testa
@@ -752,9 +735,6 @@ Machine::LuaEmtSpecialHead( lua_State* L)
// lettura eventuale campo 'Rot1W' dalla tabella (default 1)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'MaxDeltaR2OnFirst' dalla tabella (default true)
bool bMaxDeltaR2On1 = true ;
LuaGetTabFieldParam( L, 1, FLD_MAXDELTAR2ON1, bMaxDeltaR2On1) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke{{ -INFINITO, INFINITO}} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
@@ -782,7 +762,7 @@ Machine::LuaEmtSpecialHead( lua_State* L)
// carico i dati della testa standard
if ( ! m_pMchLua->LoadMachineSpecialHead( sName, sParent, sHSet, ptPos, vtTDir, vtADir,
dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
dRot1W, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
return luaL_error( L, " Load Machine Special Head failed") ;
// restituisco l'indice della testa
@@ -1208,7 +1188,7 @@ Machine::LuaEmtSetLastError( lua_State* L)
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto informazioni di errore
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SetLastError( nErrId, sErrDesc)) ;
string sOut = "(" + ToString( nErrId) + ") " + sErrDesc ;
// se uscita dolce
@@ -1233,7 +1213,7 @@ Machine::LuaEmtSetWarning( lua_State* L)
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto informazioni di warning
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SetWarning( nWarnId, sWarnDesc)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
@@ -1262,7 +1242,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L)
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, false, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1272,7 +1252,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L)
int
Machine::LuaEmtAddCollisionObjEx( lua_State* L)
{
// 7 o 8 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 [,bToolOn]
// 7 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3
int nInd ;
LuaCheckParam( L, 1, nInd)
int nFrameId ;
@@ -1287,14 +1267,12 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L)
LuaCheckParam( L, 6, dPar2)
double dPar3 ;
LuaCheckParam( L, 7, dPar3)
bool bToolOn = false ;
LuaGetParam( L, 8, bToolOn) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
@@ -1304,7 +1282,7 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L)
int
Machine::LuaEmtExecCollisionCheck( lua_State* L)
{
// 1 parametro opzionale : [nMoveType = 0]
// 1 parametro opzionale
int nMoveType = 0 ;
LuaGetParam( L, 1, nMoveType) ;
LuaClearStack( L) ;
@@ -1334,7 +1312,7 @@ Machine::LuaEmtOnCollision( lua_State* L)
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// eseguo gestione della collisione in simulazione
// eseguo la verifica di collisione (nessuna collisione -> true)
int nErr = 0 ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimOnCollision( nCdInd, nObjInd, nErr)) ;
// assegno risultato
@@ -1342,92 +1320,3 @@ Machine::LuaEmtOnCollision( lua_State* L)
LuaSetParam( L, nErr) ;
return 2 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtSetToolForVmill( lua_State* L)
{
// 4 parametri : sTool, sHead, nExit, vVmill
string sTool ;
LuaGetParam( L, 1, sTool) ;
string sHead ;
LuaGetParam( L, 2, sHead) ;
int nExit = 0 ;
LuaGetParam( L, 3, nExit) ;
INTVECTOR vVmill ;
LuaGetParam( L, 4, vVmill) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto dati primo utensile per virtual milling in simulazione
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimSetToolForVmill( sTool, sHead, nExit, vVmill, true)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtAddToolForVmill( lua_State* L)
{
// 4 parametri : sTool, sHead, nExit, vVmill
string sTool ;
LuaGetParam( L, 1, sTool) ;
string sHead ;
LuaGetParam( L, 2, sHead) ;
int nExit = 0 ;
LuaGetParam( L, 3, nExit) ;
INTVECTOR vVmill ;
LuaGetParam( L, 4, vVmill) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto dati utensile aggiuntivo per virtual milling in simulazione
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimSetToolForVmill( sTool, sHead, nExit, vVmill, false)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtMoveAxes( lua_State* L)
{
// 4, ..., 16 parametri : nMoveType, sAx1, dPos1, dStep1 [, sAx2, dPos2, dStep2] [, sAx3, dPos3, dStep3] [, sAx4, dPos4, dStep4] [, sAx5, dPos5, dStep5]
int nMoveType ;
LuaCheckParam( L, 1, nMoveType)
string sAx1 ;
LuaCheckParam( L, 2, sAx1) ;
double dEnd1 ;
LuaCheckParam( L, 3, dEnd1) ;
double dStep1 ;
LuaCheckParam( L, 4, dStep1) ;
SAMVECTOR vAxNaEpSt ;
vAxNaEpSt.emplace_back( sAx1, dEnd1, dStep1) ;
for ( int i = 0 ; i < 4 ; ++ i) {
int nInd = 5 + 3 * i ;
string sAxN ;
double dEndN ;
double dStepN ;
if ( LuaGetParam( L, nInd, sAxN) && LuaGetParam( L, nInd + 1, dEndN) && LuaGetParam( L, nInd + 2, dStepN))
vAxNaEpSt.emplace_back( sAxN, dEndN, dStepN) ;
else
break ;
}
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// eseguo movimento in simulazione
int nRes = 0 ;
if ( m_pMchLua->m_pMchMgr != nullptr)
nRes = m_pMchLua->m_pMchMgr->SimMoveAxes( nMoveType, vAxNaEpSt) ;
// assegno risultato
if ( nRes == SIM_AXMV_RES_STOP)
return luaL_error( L, "STOP") ;
else
LuaSetParam( L, ( nRes == SIM_AXMV_RES_OK)) ;
return 1 ;
}
+6 -13
View File
@@ -44,7 +44,6 @@ struct KinAxis {
int nGrpId ;
bool bLinear ;
bool bHead ;
int nInd ;
Point3d ptPos ;
Vector3d vtDir ;
STROKE stroke ;
@@ -52,7 +51,7 @@ struct KinAxis {
bool bFixed ;
double dFixVal ;
KinAxis( void)
: nGrpId( GDB_ID_NULL), bLinear( true), bHead( true), nInd( 0), ptPos(), vtDir(), dHomeVal( 0), bFixed( false), dFixVal( 0)
: nGrpId( GDB_ID_NULL), bLinear( true), bHead( true), ptPos(), vtDir(), dHomeVal( 0), bFixed( false), dFixVal( 0)
{ stroke.Min = 0 ; stroke.Max = 0 ; }
} ;
typedef std::vector<KinAxis> KINAXISVECTOR ;
@@ -113,20 +112,17 @@ const std::string MCH_ZHOMEDOWN = "ZHOMEDOWN" ;
const std::string MCH_ABOVE = "ABOVE" ;
// Info di testa per una variazione alla Z di sicurezza globale
const std::string MCH_ZSAFEDELTA = "ZSAFEDELTA" ;
// Info di tavola per dichiarare che va considerata come basculante
const std::string MCH_TILTINGLIKE = "TiltingLike" ;
//----------------------------------------------------------------------------
// Dati aggregato rotante da sotto
struct AggrBottom {
int nType ;
double dDMax ;
double dEncH ;
double dEncV ;
Vector3d vtMDir ;
int nType ;
double dDMax ;
double dEncH ;
double dEncV ;
AggrBottom( void) : nType( 0), dDMax( 0), dEncH( 0), dEncV( 0) {}
void Clear( void)
{ nType = 0 ; dDMax= 0 ; dEncH = 0 ; dEncV = 0 ; vtMDir = V_NULL ; }
{ nType = 0 ; dDMax= 0 ; dEncH = 0 ; dEncV = 0 ; }
} ;
//----------------------------------------------------------------------------
@@ -138,6 +134,3 @@ const std::string MCH_AGB_DMAX = "AGB_DMAX" ;
const std::string MCH_AGB_ENCH = "AGB_ENCH" ;
// Info in rinvio rotante da sotto con ingombro verticale
const std::string MCH_AGB_ENCV = "AGB_ENCV" ;
// Info in rinvio rotante da sotto per definire la direzione di approccio preferenziale (consentito delta max di 95deg)
const std::string MCH_AGB_MDIR = "AGB_MDIR" ;
const double MCH_AGB_DELTAMAX_MDIR = cos( 95 * DEGTORAD) ;
+67 -54
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2020
//----------------------------------------------------------------------------
// File : MachiningsMgr.cpp Data : 04.02.22 Versione : 2.4b1
// File : MachiningsMgr.cpp Data : 09.11.20 Versione : 2.2k2
// Contenuto : Implementazione gestore database lavorazioni.
//
//
@@ -15,7 +15,6 @@
// 03.06.20 DS Agg. per nuovi parametri Tab in fresatura (MF_CURR_VER = 1009).
// 22.06.20 DS Agg. per nuovi parametri attacco tagli di lama (MF_CURR_VER = 1010).
// 09.11.20 DS Agg. per nuovi parametri tagli di lama (MF_CURR_VER = 1011).
// 04.02.22 DS Agg. per nuovi parametri svuotature con epicicli (MF_CURR_VER = 1012).
//
//----------------------------------------------------------------------------
@@ -32,6 +31,7 @@
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EGnScanner.h"
#include "/EgtDev/Include/EGnWriter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <cassert>
#include <bitset>
@@ -42,7 +42,7 @@ const string MF_HEADER = "[HEADER]" ;
const string MF_VERSION = "VERSION" ;
const string MF_TOTAL = "TOTAL" ;
const string MF_SIZE = "SIZE" ;
const int MF_CURR_VER = 1012 ;
const int MF_CURR_VER = 1011 ;
const string MF_GENERAL = "[GENERAL]" ;
const string MF_3AXCOMP = "3AXCOMP" ;
const bool MF_CURR_3AXCOMP = false ;
@@ -189,25 +189,11 @@ MachiningsMgr::Reload( void)
// Ciclo di lettura delle lavorazioni
do {
PtrOwner<MachiningData> pMch ;
if ( LoadOneMachining( TheScanner, pMch, bEnd)) {
// salvo i dati della lavorazione
if ( ! IsNull( pMch)) {
if ( ! m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ||
! m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second) {
bOk = false ;
string sOut = "ReloadMachinings : Error adding machining " + pMch->m_sName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
}
Release( pMch) ;
}
}
else {
if ( ! LoadOneMachining( TheScanner, bEnd)) {
bOk = false ;
string sOut = "ReloadMachinings : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
}
} while ( bOk && ! bEnd) ;
// Termino lo scanner
@@ -221,7 +207,7 @@ MachiningsMgr::Reload( void)
//----------------------------------------------------------------------------
bool
MachiningsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) const
MachiningsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd)
{
// leggo la prossima linea
string sLine ;
@@ -325,12 +311,11 @@ MachiningsMgr::LoadGeneral( Scanner& TheScanner, bool& bEnd)
//----------------------------------------------------------------------------
bool
MachiningsMgr::LoadOneMachining( Scanner& TheScanner, PtrOwner<MachiningData>& pMch, bool& bEnd) const
MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd, MachiningData** ppMch)
{
// leggo la prossima linea
string sLine ;
if ( ! TheScanner.GetLine( sLine)) {
pMch.Reset() ;
// fine file
bEnd = true ;
return true ;
@@ -344,7 +329,7 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, PtrOwner<MachiningData>& p
SplitFirst( sLine, "_", sType, sCount) ;
ToUpper( sType) ;
// alloco la lavorazione del tipo corrispondente
pMch.Set( MCHDATA_CREATE( MCHDATA_NAMETOTYPE( sType))) ;
PtrOwner<MachiningData> pMch( MCHDATA_CREATE( MCHDATA_NAMETOTYPE( sType))) ;
if ( IsNull( pMch))
return false ;
bool bOk = true ;
@@ -381,6 +366,14 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, PtrOwner<MachiningData>& p
}
// verifico di aver letto tutti i campi
bOk = bOk && ( Flag.count() == nSize) ;
// salvo i dati della lavorazione
if ( ppMch == nullptr ) {
bOk = bOk && m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ;
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
Release( pMch) ;
}
else
*ppMch = Release( pMch) ;
return bOk ;
}
@@ -449,7 +442,7 @@ MachiningsMgr::Save( bool bCompressed) const
//----------------------------------------------------------------------------
bool
MachiningsMgr::SaveHeader( Writer& TheWriter, int nTotal) const
MachiningsMgr::SaveHeader( Writer& TheWriter, const int nTotal) const
{
// scrivo l'intestazione
bool bOk = true ;
@@ -512,20 +505,14 @@ MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& The
if ( iIter == m_umData.end())
return false ;
const MachiningData* pmData = iIter->second ;
// preparo la lista dei dati (quelli vuoti sono opzionali con default)
STRVECTOR vsOut ;
for ( int i = 0 ; i < pmData->GetSize() ; ++ i) {
string sOut = pmData->ToString( i) ;
if ( ! sOut.empty())
vsOut.emplace_back( sOut) ;
}
// scrivo i dati della lavorazione
string sOut = "[" + pmData->GetTitle() + "_" + ToString( ++ nCounter, 3) + "]" ;
bool bOk = TheWriter.OutText( sOut) ;
sOut = MF_SIZE + "=" + ToString( int( vsOut.size())) ;
sOut = MF_SIZE + "=" + ToString( pmData->GetSize()) ;
bOk = bOk && TheWriter.OutText( sOut) ;
for ( const auto& sOut : vsOut) {
bOk = bOk && TheWriter.OutText( sOut) ;
for ( int i = 0 ; i < pmData->GetSize() ; ++ i) {
string sOut = pmData->ToString( i) ;
bOk = bOk && ! sOut.empty() && TheWriter.OutText( sOut) ;
}
return bOk ;
}
@@ -1260,7 +1247,7 @@ MachiningsMgr::Export( const STRVECTOR& vsMachiningsNames, const string& sOutFil
//----------------------------------------------------------------------------
bool
MachiningsMgr::ToBeImported( const string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const
MachiningsMgr::ToBeImported( const string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes)
{
// inizializzo lo scanner
Scanner TheScanner ;
@@ -1386,27 +1373,22 @@ MachiningsMgr::Import( const string& sFile, const STRVECTOR& vsMachiningsToImpor
return false ;
}
// leggo i dati generali (da versione 1002) e li ignoro
if ( nVersion >= 1002 && ! SkipGeneral( TheScanner, bEnd)) {
// leggo i dati generali (da versione 1002) e li confronto con quelli della classe
if ( nVersion >= 1002 && ! CheckGeneral( TheScanner, bEnd)) {
LOG_ERROR( GetEMkLogger(), " Error Importing Machinings on General") ;
return false ;
}
// ciclo di lettura delle lavorazioni
while ( ! bEnd) {
PtrOwner<MachiningData> pMch ;
if ( ! LoadOneMachining( TheScanner, pMch, bEnd)) {
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : reading at line" + ToString( TheScanner.GetCurrLineNbr())).c_str()) ;
continue ;
}
// se non c'è lavorazione (si è alla fine), si prosegue
if ( IsNull( pMch))
MachiningData* pMch = nullptr ;
if ( ! LoadOneMachining( TheScanner, bEnd, &pMch) || pMch == nullptr)
// se errore nel leggere la lavorazione, proseguo con la successiva
continue ;
// se la lavorazione non deve essere importata proseguo con la successiva
auto it = find( vsMachiningsToImport.begin(), vsMachiningsToImport.end(), pMch->m_sName) ;
if ( it == vsMachiningsToImport.end())
// se la lavorazione non deve essere importata proseguo con la successiva
if ( it == vsMachiningsToImport.end())
continue ;
// assegno il nuovo nome
@@ -1418,13 +1400,13 @@ MachiningsMgr::Import( const string& sFile, const STRVECTOR& vsMachiningsToImpor
}
// aggiungo la lavorazione
if ( ! m_umData.emplace( pMch->m_Uuid, pMch).second ||
! m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second) {
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : failed adding " + pMch->m_sName).c_str()) ;
bool bOk = m_umData.emplace( pMch->m_Uuid, pMch).second ;
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
if ( ! bOk) {
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : adding " + pMch->m_sName + " failed" ).c_str()) ;
continue ;
}
}
vsImported.push_back( pMch->m_sName) ;
Release( pMch) ;
}
if ( ! vsImported.empty())
@@ -1436,7 +1418,7 @@ MachiningsMgr::Import( const string& sFile, const STRVECTOR& vsMachiningsToImpor
//----------------------------------------------------------------------------
bool
MachiningsMgr::SkipGeneral( Scanner& TheScanner, bool& bEnd) const
MachiningsMgr::CheckGeneral( Scanner& TheScanner, bool& bEnd) const
{
// leggo la prossima linea
string sLine ;
@@ -1458,7 +1440,38 @@ MachiningsMgr::SkipGeneral( Scanner& TheScanner, bool& bEnd) const
bEnd = false ;
break ;
}
// separo chiave da valore
string sKey, sVal ;
bool bVal ;
int nVal ;
double dVal ;
SplitFirst( sLine, "=", sKey, sVal) ;
// riconosco la chiave e verifico che il valore corrisponda a quello salvato nella classe
if ( ToUpper( sKey) == MF_3AXCOMP)
bOk = FromString( sVal, bVal) && bVal == m_b3AxComp ;
else if ( ToUpper( sKey) == MF_5AXCOMP)
bOk = FromString( sVal, bVal) && bVal == m_b5AxComp ;
else if ( ToUpper( sKey) == MF_SAFEZ)
bOk = FromString( sVal, dVal) && abs( m_dSafeZ - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_SAFEAGGRBOTTZ)
bOk = FromString( sVal, dVal) && abs( m_dSafeAggrBottZ - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_EXTRALCR)
bOk = FromString( sVal, dVal) && abs( m_dExtraLOnCutRegion - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_EXTRARDR)
bOk = FromString( sVal, dVal) && abs( m_dExtraROnDrillRegion - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_HOLEDTOL)
bOk = FromString( sVal, dVal) && abs( m_dHoleDiamToler - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_EXTSAWARCMINRAD)
bOk = FromString( sVal, dVal) && abs( m_dExtSawArcMinRad - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_INTSAWARCMAXSIDEANG)
bOk = FromString( sVal, dVal) && abs( m_dIntSawArcMaxSideAng - dVal) < EPS_SMALL ;
else if ( ToUpper( sKey) == MF_SPLITARCS)
bOk = FromString( sVal, nVal) && m_nSplitArcs == nVal ;
else if ( ToUpper( sKey) == MF_MAXDEPTHSAFE)
bOk = FromString( sVal, dVal) && abs( m_dMaxDepthSafe - dVal) < EPS_SMALL ;
else
bOk = true ;
}
return bOk ;
}
}
+7 -8
View File
@@ -14,7 +14,6 @@
#pragma once
#include "MachiningData.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <unordered_map>
#include <map>
@@ -30,6 +29,9 @@ class MachiningsMgr
bool Load( const std::string& sMachsFile, const ToolsMgr* pTsMgr) ;
bool Reload( void) ;
bool Save( bool bCompressed = true) const ;
bool Export( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile, bool bCompressed = true) const ;
bool ToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) ;
bool Import( const std::string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames, STRVECTOR& vsImported) ;
bool GetMachiningNewName( std::string& sName) const ;
bool AddMachining( const std::string& sName, int nType) ;
bool CopyMachining( const std::string& sSource, const std::string& sName) ;
@@ -82,17 +84,14 @@ class MachiningsMgr
bool SetMaxDepthSafe( double dSafe) ;
double GetMaxDepthSafe( void) const
{ return m_dMaxDepthSafe ; }
bool Export( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile, bool bCompressed = true) const ;
bool ToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const ;
bool Import( const std::string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames, STRVECTOR& vsImported) ;
private :
bool Clear( bool bReset) ;
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) const ;
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) ;
bool LoadGeneral( Scanner& TheScanner, bool& bEnd) ;
bool SkipGeneral( Scanner& TheScanner, bool& bEnd) const ;
bool LoadOneMachining( Scanner& TheScanner, PtrOwner<MachiningData>& pMch, bool& bEnd) const ;
bool SaveHeader( Writer& TheWriter, int nTotal = -1) const ;
bool CheckGeneral( Scanner& TheScanner, bool& bEnd) const ;
bool LoadOneMachining( Scanner& TheScanner, bool& bEnd, MachiningData** ppMch = nullptr) ;
bool SaveHeader( Writer& TheWriter, const int nTotal = -1) const ;
bool SaveGeneral( Writer& TheWriter) const ;
bool SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
bool VerifyCurrMachining( int nType, std::string& sName) const ;
+195 -521
View File
File diff suppressed because it is too large Load Diff
+10 -13
View File
@@ -88,28 +88,26 @@ class Milling : public Machining
bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ;
bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev,
double dOkStep, bool bStepUp, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev,
double dOkStep, bool bStepUp, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart, bool bAboveStart) ;
bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, double dSafeZ, double dStElev, double dAppr) ;
bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dStElev, double dAppr) ;
bool AddDirectApproach( const Point3d& ptP) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bAboveEnd) ;
bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, double dSafeZ, double dEndElev, double dAppr) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool,
bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dEndElev, double dAppr) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
const Vector3d& vtTool, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ;
bool CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool,
double dEndElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ;
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, double dEndElev,
const Vector3d& vtN, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ;
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, double dEndElev,
bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) ;
bool AdjustOscillParams( const ICurve* pCrv, bool& bPathOscEnable, double& dRampLen, double& dFlatLen) ;
bool AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
@@ -119,7 +117,7 @@ class Milling : public Machining
bool AddTabsLine( const ICurveLine* pLine, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
bool AddTabsArc( const ICurveArc* pArc, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
double GetRadiusForStartEndElevation( bool bExtra = true) const ;
bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, double dSafeZ) const ;
bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, double dElev, double dSafeZ) const ;
bool GetPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool) const ;
bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU) ;
Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU) ;
@@ -151,7 +149,6 @@ class Milling : public Machining
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
MillingData m_Params ; // parametri lavorazione
ToolData m_TParams ; // parametri utensile
double m_dTHoldBase ; // posizione base del porta-utensile
double m_dTHoldLen ; // lunghezza del porta-utensile
double m_dTHoldDiam ; // diametro del porta-utensile
int m_nStatus ; // stato di aggiornamento della lavorazione
+106 -180
View File
@@ -524,14 +524,8 @@ Mortising::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nMortises = nCurrMortises ;
LOG_DBG_INFO( GetEMkLogger(), "Mortising apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -615,8 +609,6 @@ Mortising::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "Mortising apply done") ;
return true ;
}
@@ -993,7 +985,7 @@ Mortising::GetCurve( SelData Id)
else
nToolDir = TOOL_PAR_SLANT ;
int nFaceUse = ( m_Params.m_nFaceUse & 31) ;
AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, m_TParams.m_dThick, 2) ;
AdjustCurveFromSurf( pCrvCompo, nToolDir, nFaceUse, m_TParams.m_dThick) ;
// la restituisco
return Release( pCrvCompo) ;
}
@@ -1187,7 +1179,7 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId)
{
// inclinazione della direzione utensile rispetto al movimento
Vector3d vtTg ; pCompo->GetMidDir( vtTg) ;
double dSinAng = max( ( vtTg ^ vtExtr).Len(), sin( 30 * DEGTORAD)) ;
double dSinAng = max( ( vtTg ^ vtExtr).Len(), sin( 45 * DEGTORAD)) ;
double dStartAddLen = m_Params.m_dStartAddLen / dSinAng ;
double dEndAddLen = m_Params.m_dEndAddLen / dSinAng ;
// verifico che il percorso sia abbastanza lungo
@@ -1299,18 +1291,8 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId)
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "MaxElev="), dMaxElev) && dElev > dMaxElev)
dElev = dMaxElev ;
// ingombro aggiuntivo da larghezza sega a catena quando inclinata rispetto al movimento
Vector3d vtTg ; pCompo->GetMidDir( vtTg) ;
double dSinAng = max( ( vtTg ^ vtExtr).Len(), sin( 30 * DEGTORAD)) ;
double dCosAng = min( abs( vtTg * vtExtr), cos( 30 * DEGTORAD)) ;
double dAddEnc = m_TParams.m_dDiam / 2 * dCosAng / dSinAng ;
// affondamento speciale da note utente (!!! da trasformare in parametro come gli altri !!!)
int nPlunge = 0 ;
FromString( ExtractInfo( m_Params.m_sUserNotes, "Plunge="), nPlunge) ;
// verifico che lo step dell'utensile sia sensato
double dOkStep = ( nPlunge == MORTISE_PLUNGE_STEP ? m_Params.m_dStep : 0) ;
double dOkStep = m_Params.m_dStep ;
const double MIN_ZSTEP = 1.0 ;
if ( dOkStep >= EPS_SMALL && dOkStep < MIN_ZSTEP) {
dOkStep = MIN_ZSTEP ;
@@ -1329,23 +1311,38 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId)
}
// se lo step supera la capacità dell'utensile
if ( dOkStep > m_TParams.m_dMaxMat + EPS_SMALL) {
if ( m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL) {
dOkStep = m_TParams.m_dMaxMat ;
string sInfo = "Warning in Mortising : machining step (" + ToString( m_Params.m_dStep, 1) +
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
m_pMchMgr->SetWarning( 2557, sInfo) ;
}
// massimo affondamento dell'utensile
double dMaxDepth = m_TParams.m_dMaxMat - dAddEnc ;
// se l'elevazione supera il massimo affondamento dell'utensile
if ( dElev > dMaxDepth + EPS_SMALL) {
// segnalo, riduco e continuo
string sInfo = "Warning in Mortising : machining depth (" + ToString( dElev, 1) +
") bigger than MaxDepth (" + ToString( dMaxDepth, 1) + ")" ;
m_pMchMgr->SetWarning( 2558, sInfo) ;
dDepth -= dElev - dMaxDepth ;
dElev = dMaxDepth ;
}
// se lavorazione singola
if ( dOkStep < EPS_SMALL || dOkStep > dElev) {
// se l'elevazione supera la capacità dell'utensile
if ( dElev > m_TParams.m_dMaxMat + EPS_SMALL) {
// segnalo, riduco e continuo
string sInfo = "Warning in Mortising : machining depth (" + ToString(dElev, 1) +
") bigger than MaxMaterial (" + ToString(m_TParams.m_dMaxMat, 1) + ")" ;
m_pMchMgr->SetWarning(2558, sInfo) ;
dDepth -= dElev - m_TParams.m_dMaxMat ;
dElev = m_TParams.m_dMaxMat ;
}
}
// altrimenti lavorazione a step
else {
// massimo affondamento dell'utensile
double dMaxDepth = m_TParams.m_dMaxMat ;
// se l'elevazione supera il massimo affondamento dell'utensile
if ( dElev > dMaxDepth + EPS_SMALL) {
// segnalo, riduco e continuo
string sInfo = "Warning in Mortising : machining depth (" + ToString( dElev, 1) +
") bigger than MaxDepth (" + ToString( dMaxDepth, 1) + ")" ;
m_pMchMgr->SetWarning( 2558, sInfo) ;
dDepth -= dElev - dMaxDepth ;
dElev = dMaxDepth ;
}
}
// se richiesta anteprima
if ( nPvId != GDB_ID_NULL) {
@@ -1382,8 +1379,8 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId)
SetToolDir( vtTool) ;
SetAuxDir( vtAux) ;
// Calcolo la mortasatura
if ( ! GenerateMortisingCl( pCompo, vtTool, dDepth, dElev, dOkStep, nPlunge))
// Calcolo la mortasatura
if ( ! GenerateMortisingCl( pCompo, vtTool, dDepth, dElev, dOkStep))
return false ;
}
@@ -1469,186 +1466,109 @@ Mortising::GenerateMortisingPv( int nPathId, const ICurveComposite* pCompo)
//----------------------------------------------------------------------------
bool
Mortising::GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, int nPlunge)
Mortising::GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep)
{
// inizio e fine
// estremi della curva composita
Point3d ptStart ; pCompo->GetStartPoint( ptStart) ;
Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ;
// verifico se affondamento ripetuto è veramente tale
if ( ( nPlunge == MORTISE_PLUNGE_START_END || nPlunge == MORTISE_PLUNGE_START_TO_END) && Dist( ptStart, ptEnd) < 10 * EPS_SMALL)
nPlunge = MORTISE_PLUNGE_START ;
// se affondamento inizio e fine
if ( nPlunge == MORTISE_PLUNGE_START_END) {
// affondamento iniziale
if ( ! GenerateOnePlungeCl( ptStart, ptEnd, vtTool, dDepth, dElev, dOkStep, MORTISE_PLUNGE_START, true))
return false ;
// affondamento finale
if ( ! GenerateOnePlungeCl( ptStart, ptEnd, vtTool, dDepth, dElev, dOkStep, MORTISE_PLUNGE_END, false))
return false ;
}
// se alrimenti affondamenti ripetuti da inizio a fine con ritorno basso
else if ( nPlunge == MORTISE_PLUNGE_START_TO_END) {
// distanza e vettore spostamento laterale
Vector3d vtDir = ptEnd - ptStart ;
double dLen = vtDir.Len() ;
vtDir.Normalize() ;
// affondamenti iniziale e intermedi
int kMax = ( int) floor( dLen / m_TParams.m_dDiam) ;
for ( int k = 0 ; k <= kMax ; ++ k) {
Point3d ptNewStart = ptStart + vtDir * k * m_TParams.m_dDiam ;
// se non è finale
if ( k != kMax || ! AreSamePointEpsilon( ptNewStart, ptEnd, 10 * EPS_SMALL)) {
if ( ! GenerateOnePlungeCl( ptNewStart, ptEnd, vtTool, dDepth, dElev, dOkStep, MORTISE_PLUNGE_START, k == 0))
return false ;
}
}
// affondamento finale
if ( ! GenerateOnePlungeCl( ptEnd, ptStart, vtTool, dDepth, dElev, dOkStep, MORTISE_PLUNGE_STEP, false))
return false ;
}
// altrimenti affondamento singolo
else {
if ( ! GenerateOnePlungeCl( ptStart, ptEnd, vtTool, dDepth, dElev, dOkStep, nPlunge, true))
return false ;
}
// reset dati di movimento
ResetMoveData() ;
// incremento numero di mortasature
++ m_nMortises ;
return true ;
}
//----------------------------------------------------------------------------
bool
Mortising::GenerateOnePlungeCl( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, double dDepth, double dElev,
double dOkStep, int nPlunge, bool bFirst)
{
// compensazione elevazione/affondamento
double dDelta = dElev - dDepth ;
// determino se l'inizio dell'attacco è esattamente sotto il grezzo, nel qual caso ricalcolo l'elevazione
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() + m_pMchMgr->GetDeltaSafeZ( m_TParams.m_sHead) ;
double dStartElev = 0 ;
Point3d ptLi = ( nPlunge != MORTISE_PLUNGE_END ? ptStart : ptEnd) + vtTool * dDelta ;
Point3d ptLi = ptStart + vtTool * dDelta ;
bool bUnderStart = GetPointUnderRaw( ptLi, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtTool, dStartElev) ;
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStartElev) ;
// altrimenti ridetermino elevazione su inizio percorso di lavoro
if ( ! bUnderStart)
GetElevation( m_nPhase, ptLi, vtTool, GetRadiusForStartEndElevation(), vtTool, dStartElev) ;
// 1 -> punto approccio
int nFirstFlag = ( bFirst ? 1 : 0) ;
SetFlag( nFirstFlag) ;
Point3d ptP1 = ( nPlunge != MORTISE_PLUNGE_END ? ptStart : ptEnd) + vtTool * ( dDelta + dStartElev + dSafeZ) ;
int nStart = ( bFirst ? AddRapidStart( ptP1) : AddRapidMove( ptP1)) ;
if ( nStart == GDB_ID_NULL)
SetFlag( 1) ;
Point3d ptP1 = ptStart + vtTool * ( dDelta + dStartElev + dSafeZ) ;
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
return false ;
SetFlag( 0) ;
// 2 -> punto fuori (se diverso dal precedente)
if ( m_Params.m_dStartPos < dSafeZ - 10 * EPS_SMALL) {
Point3d ptP2 = ( nPlunge != MORTISE_PLUNGE_END ? ptStart : ptEnd) + vtTool * ( dDelta + m_Params.m_dStartPos) ;
if ( m_Params.m_dStartPos < dSafeZ) {
Point3d ptP2 = ptStart + vtTool * ( dDelta + m_Params.m_dStartPos) ;
if ( AddRapidMove( ptP2) == GDB_ID_NULL)
return false ;
}
// eseguo ciclo a seconda del tipo di affondamento
// determino numero e affondamento degli step
if ( dOkStep < EPS_SMALL)
dOkStep = dElev ;
int nStep = max( 1, static_cast<int>( ceil( dElev / dOkStep))) ;
double dStep = dElev / nStep ;
const double RETURN_DIST = 10 ;
// eseguo ciclo a seconda del tipo di step
Point3d ptLast ;
if ( nPlunge == MORTISE_PLUNGE_START) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = ptStart + ( dDelta - dElev) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
ptLast = ptStart ;
}
else if ( nPlunge == MORTISE_PLUNGE_END) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = ptEnd + ( dDelta - dElev) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
ptLast = ptEnd ;
}
else {
// determino numero e affondamento degli step
if ( dOkStep < EPS_SMALL)
dOkStep = dElev ;
int nStep = max( 1, static_cast<int>( ceil( ( dElev - 10 * EPS_SMALL) / dOkStep))) ;
double dStep = dElev / nStep ;
const double RETURN_DIST = 10 ;
// a seconda del tipo
switch ( m_Params.m_nStepType) {
default : // ZIGZAG
for ( int i = 1 ; i <= nStep ; ++ i) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = (( i % 2 == 1) ? ptStart : ptEnd) + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> punto termine
SetFeed( GetFeed()) ;
SetFlag( 0) ;
ptLast = (( i % 2 == 1) ? ptEnd : ptStart) ;
Point3d ptP4 = ptLast + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
}
break ;
case MORTISE_ST_ONEWAY :
for ( int i = 1 ; i <= nStep ; ++ i) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = ptStart + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> punto termine
SetFeed( GetFeed()) ;
SetFlag( 0) ;
ptLast = ptEnd ;
Point3d ptP4 = ptLast + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
// 5 -> ritorno sull'inizio, se non ultimo punto
if ( i < nStep) {
// retrocedo
SetFeed( GetFeed()) ;
SetFlag( 0) ;
Point3d ptP5a = ptP4 + RETURN_DIST * vtTool ;
if ( AddLinearMove( ptP5a) == GDB_ID_NULL)
return false ;
// ritorno sopra inizio
SetFeed( GetFeed()) ;
SetFlag( 0) ;
Point3d ptP5b = ptP3 + RETURN_DIST * vtTool ;
if ( AddLinearMove( ptP5b) == GDB_ID_NULL)
return false ;
}
}
break ;
switch ( m_Params.m_nStepType) {
default : // ZIGZAG
for ( int i = 1 ; i <= nStep ; ++ i) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = (( i % 2 == 1) ? ptStart : ptEnd) + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> punto termine
SetFeed( GetFeed()) ;
SetFlag( 0) ;
ptLast = (( i % 2 == 1) ? ptEnd : ptStart) ;
Point3d ptP4 = ptLast + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
}
break ;
case MORTISE_ST_ONEWAY :
for ( int i = 1 ; i <= nStep ; ++ i) {
// 3 -> punto in affondamento
SetFeed( GetStartFeed()) ;
SetFlag( 0) ;
Point3d ptP3 = ptStart + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> punto termine
SetFeed( GetFeed()) ;
SetFlag( 0) ;
ptLast = ptEnd ;
Point3d ptP4 = ptLast + ( dDelta - i * dStep) * vtTool ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
// 5 -> ritorno sull'inizio, se non ultimo punto
if ( i < nStep) {
// retrocedo
SetFeed( GetFeed()) ;
SetFlag( 0) ;
Point3d ptP5a = ptP4 + RETURN_DIST * vtTool ;
if ( AddLinearMove( ptP5a) == GDB_ID_NULL)
return false ;
// ritorno sopra inizio
SetFeed( GetFeed()) ;
SetFlag( 0) ;
Point3d ptP5b = ptP3 + RETURN_DIST * vtTool ;
if ( AddLinearMove( ptP5b) == GDB_ID_NULL)
return false ;
}
}
break ;
}
// determino se la fine dell'uscita è esattamente sotto il grezzo, nel qual caso ricalcolo l'elevazione
double dEndElev = 0 ;
Point3d ptLo = ptLast + vtTool * dDelta ;
bool bUnderEnd = GetPointUnderRaw( ptLo, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, vtTool, dEndElev) ;
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dEndElev) ;
// altrimenti ridetermino elevazione su fine percorso di lavoro
if ( ! bUnderEnd)
GetElevation( m_nPhase, ptLo, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev) ;
// 6 -> ritorno all'approccio
SetFeed( GetEndFeed()) ;
SetFlag( 104) ; // risalita sopra la fine
@@ -1656,6 +1576,12 @@ Mortising::GenerateOnePlungeCl( const Point3d& ptStart, const Point3d& ptEnd, co
if ( AddLinearMove( ptP6) == GDB_ID_NULL)
return false ;
// reset dati di movimento
ResetMoveData() ;
// incremento numero di mortasature
++ m_nMortises ;
return true ;
}
+1 -3
View File
@@ -74,9 +74,7 @@ class Mortising : public Machining
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dThick, double& dElev) const ;
bool GenerateMortisingPv( int nPathId, const ICurveComposite* pCompo) ;
bool GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep, int nPlunge) ;
bool GenerateOnePlungeCl( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep,
int nPlunge, bool bFirst) ;
bool GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep) ;
double GetRadiusForStartEndElevation( void) const ;
private :
+118 -325
View File
@@ -32,9 +32,7 @@
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkCDeBoxClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -154,36 +152,15 @@ Operation::UpdateFollowingOperationsStatus(int nModif)
return true ;
}
//----------------------------------------------------------------------------
string
Operation::GetName( void) const
{
string sName ;
if ( m_pGeomDB == nullptr || ! m_pGeomDB->GetName( m_nOwnerId, sName))
sName = "___" ;
return sName ;
}
//----------------------------------------------------------------------------
bool
Operation::GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev) const
{
Vector3d vtNorm ;
return GetElevation( nPhase, ptP, vtDir, dElev, vtNorm) ;
}
//----------------------------------------------------------------------------
bool
Operation::GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev, Vector3d& vtNorm) const
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// inizializzo elevazione
dElev = INFINITO ;
// inizializzo la normale
vtNorm = V_NULL ;
// ciclo sui grezzi
bool bFound = false ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
@@ -191,13 +168,11 @@ Operation::GetElevation( int nPhase, const Point3d& ptP,
// verifico che il grezzo compaia nella fase
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) {
// intersezione del raggio dal punto alla trimesh del grezzo
const double RAY_LEN = 100000 ;
const double RAY_LEN = 10000 ;
int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ;
if ( pStm != nullptr) {
bFound = true ;
// indice del triangolo intersecato
int nTria = SVT_NULL ;
// recupero il riferimento della trimesh
Frame3d frStm ;
m_pGeomDB->GetGlobFrame( nStmId, frStm) ;
@@ -213,39 +188,20 @@ Operation::GetElevation( int nPhase, const Point3d& ptP,
// se tratto di intersezione coincidente, considero la posizione più lontana, ovvero 2
if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
// se prosegue un tratto precedente, non devo controllare sia minimo
if ( abs( dElev - Info.dU) < EPS_SMALL) {
if ( abs( dElev - Info.dU) < EPS_SMALL)
dElev = Info.dU2 ;
nTria = Info.nT ;
}
else if ( Info.dU2 < dElev) {
dElev = Info.dU2 ;
nTria = Info.nT ;
}
else
dElev = min( dElev, Info.dU2) ;
}
// se altrimenti intersezione puntuale, verifico che esca (coseno >= 0)
else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) {
if ( Info.dU < dElev) {
dElev = Info.dU ;
nTria = Info.nT ;
}
}
// se altrimenti è la prima ed entra
else if ( i == 0 && Info.dCosDN < - COS_ORTO_ANG_ZERO) {
// se una sola o distante salto tutto
if ( vInfo.size() == 1 || Info.dU > ( dElev > INFINITO - 1 ? 0 : dElev) + MAX_DIST_RAW)
break ;
// altrimenti reset
else
dElev = INFINITO ;
dElev = min( dElev, Info.dU) ;
}
// se altrimenti è la prima, distante ed entra, salto tutto
else if ( i == 0 && Info.dU > MAX_DIST_RAW && Info.dCosDN < - COS_ORTO_ANG_ZERO)
break ;
}
}
// se c'è triangolo di intersezione, ne recupero la normale
if ( nTria != SVT_NULL) {
Triangle3d Tria ;
if ( pStm->GetTriangle( nTria, Tria))
vtNorm = Tria.GetN() ;
}
}
}
// passo al grezzo successivo
@@ -368,7 +324,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool,
return false ;
// considero più direzioni sulla circonferenza
const int MIN_STEP = 8 ;
const double LEN_STEP = 25 ;
const double LEN_STEP = 50 ;
int nStep = max( int( ( 2 * PIGRECO * dRad) / LEN_STEP), MIN_STEP) ;
Vector3d vtRad = FromUprightOrtho( vtTool) * dRad ;
for ( int i = 0 ; i < nStep ; ++ i) {
@@ -388,7 +344,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool,
//----------------------------------------------------------------------------
bool
Operation::GetPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
double dToolLen, bool bIsSaw, double dSafeZ, const Vector3d& vtDir, double& dElev) const
double dToolLen, bool bIsSaw, double dSafeZ, double& dElev) const
{
// punto a metà lunghezza utensile
Point3d ptQ = ptP + vtTool * dToolLen / 2 ;
@@ -403,10 +359,10 @@ Operation::GetPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double
// extra ingombro reale in Z
double dExtraZ = sqrt( 1 - vtTool.z * vtTool.z) * dToolRad ;
// direzione di fuga per l'elevazione
Vector3d vtMyDir = vtDir ;
if ( bIsSaw || vtMyDir.z < - EPS_SMALL)
vtMyDir.z = 0 ;
vtMyDir.Normalize() ;
Vector3d vtDir = vtTool ;
if ( bIsSaw || vtDir.z < - EPS_SMALL)
vtDir.z = 0 ;
vtDir.Normalize() ;
// determino la posizione del punto rispetto al grezzo
// ciclo sui grezzi
int nRawId = m_pMchMgr->GetFirstRawPart() ;
@@ -424,17 +380,17 @@ Operation::GetPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double
// determino elevazione del punto rispetto al grezzo a metà altezza
Point3d ptTest( ptP.x, ptP.y, dRawCentZ) ;
double dNewElev ;
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtMyDir, dNewElev))
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtDir, dNewElev))
dElev = max( dElev, dNewElev) ;
// se direzione di fuga quasi orizzontale (max 30 deg) e ingombro utensile rilevante rispetto ad altezza grezzo
if ( vtMyDir.z < 0.5 && dToolDimZ > dRawDimZ / 2) {
if ( vtDir.z < 0.5 && dToolDimZ > dRawDimZ / 2) {
// determino elevazione del punto rispetto al grezzo a metà altezza più metà ingombro utensile
ptTest = Point3d( ptP.x, ptP.y, dRawCentZ + dToolDimZ / 2) ;
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtMyDir, dNewElev))
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtDir, dNewElev))
dElev = max( dElev, dNewElev) ;
// determino elevazione del punto rispetto al grezzo a metà altezza meno metà ingombro utensile
ptTest = Point3d( ptP.x, ptP.y, dRawCentZ - dToolDimZ / 2) ;
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtMyDir, dNewElev))
if ( GetElevation( m_nPhase, ptTest - 10 * EPS_SMALL * vtTool, vtTool, dToolRadForElev, vtDir, dNewElev))
dElev = max( dElev, dNewElev) ;
}
return true ;
@@ -529,8 +485,7 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3
//----------------------------------------------------------------------------
bool
Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
double& dDist, Vector3d& vtDir) const
Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) const
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
@@ -613,62 +568,26 @@ Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dEx
//----------------------------------------------------------------------------
bool
Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
const Vector3d& vtMainDir, double dCosMaxDelta,
double& dDist, Vector3d& vtDir) const
Operation::GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const
{
// calcolo senza limiti sulla direzione
if ( ! GetMinDistanceFromRawSide( nPhase, ptP, dExpand, dDist, vtDir))
return false ;
// se esterno, non previsti limiti o direzione nei limiti, esco
if ( dDist < EPS_SMALL || vtMainDir.IsSmall() || dCosMaxDelta <= -1 || ( vtMainDir * vtDir) > dCosMaxDelta)
return true ;
// limito la direzione
Vector3d vtPar = vtMainDir * dCosMaxDelta ;
Vector3d vtOrt = OrthoCompo( vtDir, vtMainDir) ;
double dSqOrt = 1 - dCosMaxDelta * dCosMaxDelta ;
if ( vtOrt.Normalize() && dSqOrt > 0)
vtDir = vtPar + vtOrt * sqrt( dSqOrt) ;
else
vtDir = vtMainDir ;
// calcolo con direzione imposta
return GetDistanceFromRawSide( nPhase, ptP, vtDir, dDist) ;
}
//----------------------------------------------------------------------------
bool
Operation::GetDistanceFromRawBottom(int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const
{
if (m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false;
// ricerco grezzi interessati dal percorso
BBox3d b3Compo;
if (!m_pGeomDB->GetGlobalBBox(nPathId, b3Compo))
return false;
return GetDistanceFromRawBottom(nPhase, b3Compo, dToler, dRbDist, dAllRbDist);
}
//----------------------------------------------------------------------------
bool
Operation::GetDistanceFromRawBottom(int nPhase, BBox3d& b3Test, double dToler, double& dRbDist, double& dAllRbDist) const
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// recupero distanza da fondo dei grezzi interessati o no dal percorso
dRbDist = 0 ;
dAllRbDist = 0 ;
b3Test.Expand(dToler, dToler, 0) ;
BBox3d b3Compo ;
if ( ! m_pGeomDB->GetGlobalBBox( nPathId, b3Compo))
return false ;
b3Compo.Expand( dToler, dToler, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
// verifico che il grezzo compaia nella fase
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) {
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if (m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw)) {
double dDist = b3Test.GetMax().z - b3Raw.GetMin().z ;
if ( b3Test.OverlapsXY( b3Raw) && dDist > dRbDist)
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw)) {
double dDist = b3Compo.GetMax().z - b3Raw.GetMin().z ;
if ( b3Compo.OverlapsXY( b3Raw) && dDist > dRbDist)
dRbDist = dDist ;
if ( dDist > dAllRbDist)
dAllRbDist = dDist ;
@@ -754,15 +673,14 @@ GetDirInFacePerpSide( int nFaceUse, const Vector3d& vtN, ICurveComposite* pCrvCo
}
pCrv = pCrvCompo->GetNextCurve() ;
}
// richiedo non più di 85deg di deviazione
if ( dCosMax > 0.087)
if ( dCosMax > 0)
vtRef = vtPerpMax ;
return vtRef ;
}
//----------------------------------------------------------------------------
bool
Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick, int nGrade)
Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick)
{
// copia della curva originale
PtrOwner<ICurveComposite> pCopy( pCrvCompo->Clone()) ;
@@ -771,9 +689,6 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF
Vector3d vtN ;
pCrvCompo->GetExtrusion( vtN) ;
// direzione di riferimento
Vector3d vtRef ;
// direzioni lati precedente e successivo
Vector3d vtDirPrev ;
Vector3d vtDirNext ;
@@ -798,11 +713,10 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF
// altrimenti
else {
// determino la direzione di riferimento
vtRef = GetDirInFacePerpSide( nFaceUse, vtN, pCrvCompo) ;
Vector3d vtRef = GetDirInFacePerpSide( nFaceUse, vtN, pCrvCompo) ;
// la curva gira in senso antiorario attorno al contorno faccia vista dalla normale uscente
// elimino i segmenti che hanno la direzione di riferimento a destra o quasi (16 deg o 31 deg o 46deg)
nGrade = Clamp( nGrade, 1, 3) ;
const double COS_ANG_MAX = ( nGrade == 1 ? cos( 16.01 * DEGTORAD) : ( nGrade == 2 ? cos( 31.01 * DEGTORAD) : cos( 46.01 * DEGTORAD))) ;
// elimino i segmenti che hanno la direzione di riferimento a destra o quasi (46deg)
const double COS_ANG_MAX = cos( 46.01 * DEGTORAD) ;
// cerco primo elemento del contorno non valido e vi pongo inizio/fine della curva
int i = 0 ;
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
@@ -866,19 +780,13 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF
}
else { // nToolDir == TOOL_PARAL o TOOL_PAR_SLANT
// sistemo versore
Vector3d vtExtr ;
Vector3d vtTm ; pCrvCompo->GetMidDir( vtTm) ;
Vector3d vtEm = vtN ^ vtTm ;
if ( vtEm.Normalize())
vtExtr = vtEm ;
Vector3d vtTs ; pCrvCompo->GetStartDir( vtTs) ;
Vector3d vtEs = vtN ^ vtTs ;
if ( vtEs.Normalize() && vtEs * vtRef > vtExtr * vtRef)
vtExtr = vtEs ;
Vector3d vtTe ; pCrvCompo->GetEndDir( vtTe) ;
Vector3d vtEe = vtN ^ vtTe ;
if ( vtEe.Normalize() && vtEe * vtRef > vtExtr * vtRef)
vtExtr = vtEe ;
Point3d ptStart, ptEnd ;
pCrvCompo->GetStartPoint( ptStart) ;
pCrvCompo->GetEndPoint( ptEnd) ;
Vector3d vtT = ptEnd - ptStart ;
Vector3d vtExtr = vtN ^ vtT ;
if ( ! vtExtr.Normalize())
return false ;
if ( nToolDir == TOOL_PAR_SLANT) {
Vector3d vtDirPN = -vtDirPrev + vtDirNext ;
// se le direzioni prima e dopo non sono troppo diverse tra loro (15deg) e la loro media è normalizzabile
@@ -924,16 +832,8 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF
frExtr.Set( ORIG, vtExtr) ;
frExtr.Invert() ;
BBox3d b3Extr ; pCopy->GetBBox( frExtr, b3Extr) ;
if ( ! b3Extr.IsEmpty()) {
double dThick = b3Extr.GetMax().z - b3Extr.GetMin().z ;
Point3d ptStart, ptEnd ;
if ( nToolDir == TOOL_PAR_SLANT && pCrvCompo->IsALine( LIN_TOL_STD, ptStart, ptEnd)) {
BBox3d b3Crv ; pCrvCompo->GetBBox( frExtr, b3Crv) ;
if ( ! b3Crv.IsEmpty())
dThick -= b3Crv.GetMax().z - b3Crv.GetMin().z ;
}
pCrvCompo->SetThickness( dThick) ;
}
if ( ! b3Extr.IsEmpty())
pCrvCompo->SetThickness( b3Extr.GetMax().z - b3Extr.GetMin().z) ;
}
}
return true ;
@@ -965,22 +865,16 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp)
BBox3d b3Crv ;
if ( ! pCompo->GetBBox( frRef, b3Crv) || abs( b3Crv.GetMax().z - b3Crv.GetMin().z - dThick) > 100 * EPS_SMALL)
return true ;
// porto la curva nel suo piano perchè ApproxWithArcsEx funziona bene solo nel piano XY (all'uscita va ripristinato il rif. originale)
pCompo->ToLoc( frRef) ;
// se posso ignorare la proprietà temporanea
if ( ! bCareTempProp) {
// calcolo approssimazione con archi (se possibile)
PolyArc PA ;
if ( ! pCompo->ApproxWithArcsEx( LIN_TOL_MID, ANG_TOL_STD_DEG, LIN_FEA_STD, PA)) {
pCompo->ToGlob( frRef) ;
if ( ! pCompo->ApproxWithArcsEx( LIN_TOL_MID, ANG_TOL_STD_DEG, LIN_FEA_STD, PA))
return true ;
}
// sostituisco gli archi alle curve originali
pCompo->Clear() ;
if ( ! pCompo->FromPolyArc( PA)) {
pCompo->ToGlob( frRef) ;
if ( ! pCompo->FromPolyArc( PA))
return false ;
}
}
// altrimenti divido la curva in parti con la stessa proprietà e approssimo separatamente ciascuna parte
else {
@@ -1006,10 +900,8 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp)
for ( int i = 0 ; i < int( vInt.size()) ; ++ i) {
// recupero l'intervallo
vpCrvs.emplace_back( pCompo->Clone()) ;
if ( IsNull( vpCrvs.back())) {
pCompo->ToGlob( frRef) ;
if ( IsNull( vpCrvs.back()))
return false ;
}
vpCrvs.back()->TrimEndAtParam( vInt[i].first) ;
if ( i > 0)
vpCrvs.back()->TrimStartAtParam( vInt[i-1].first) ;
@@ -1018,10 +910,8 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp)
if ( vpCrvs.back()->ApproxWithArcsEx( LIN_TOL_MID, ANG_TOL_STD_DEG, LIN_FEA_STD, PA)) {
// sostituisco gli archi alle curve originali
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
if ( IsNull( pCC) || ! pCC->FromPolyArc( PA)) {
pCompo->ToGlob( frRef) ;
if ( IsNull( pCC) || ! pCC->FromPolyArc( PA))
return false ;
}
// assegno la proprietà originale ad ogni curva semplice della composita
for ( int j = 0 ; j < pCC->GetCurveCount() ; ++ j)
pCC->SetCurveTempProp( j, vInt[i].second) ;
@@ -1035,9 +925,6 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp)
pCompo->AddCurve( Release( vpCrvs[i])) ;
}
}
// riporto in globale
pCompo->ToGlob( frRef) ;
// riassegno estrusione e spessore
pCompo->SetExtrusion( vtExtr) ;
pCompo->SetThickness( dThick) ;
@@ -1119,30 +1006,24 @@ Operation::CalcAndSetBBox( int nClId)
Vector3d vtN = pCamData->GetNormDir() ;
double dDeltaN = pCamData->GetDeltaN() ;
// ricavo i punti
const double ANG_STEP = 4.9 ;
const double ANG_STEP = 15.0 ;
int nStep = 1 + int( abs( dAngCen) / ANG_STEP) ;
double dCoeff = -1. / nStep ;
double dCosRot = cos( dCoeff * dAngCen * DEGTORAD) ;
double dSinRot = sin( dCoeff * dAngCen * DEGTORAD) ;
Point3d ptT = ptP ;
for ( int i = 1 ; i < nStep ; ++ i) {
ptT.Rotate( ptCen, vtN, dCosRot, dSinRot) ;
ptT.Translate( vtN * ( dCoeff * dDeltaN)) ;
Point3d ptT = ptP ;
ptT.Rotate( ptCen, vtN, i * dCoeff * dAngCen) ;
ptT.Translate( vtN * ( i * dCoeff * dDeltaN)) ;
b3Grp.Add( ptT) ;
}
}
}
if ( ! b3Grp.IsEmpty()) {
m_pGeomDB->SetInfo( nClPathId, KEY_PMIN, b3Grp.GetMin()) ;
m_pGeomDB->SetInfo( nClPathId, KEY_PMAX, b3Grp.GetMax()) ;
b3AllMch.Add( b3Grp) ;
}
m_pGeomDB->SetInfo( nClPathId, KEY_PMIN, b3Grp.GetMin()) ;
m_pGeomDB->SetInfo( nClPathId, KEY_PMAX, b3Grp.GetMax()) ;
b3AllMch.Add( b3Grp) ;
nClPathId = m_pGeomDB->GetNext( nClPathId) ;
}
if ( ! b3AllMch.IsEmpty()) {
m_pGeomDB->SetInfo( nClId, KEY_MMIN, b3AllMch.GetMin()) ;
m_pGeomDB->SetInfo( nClId, KEY_MMAX, b3AllMch.GetMax()) ;
}
m_pGeomDB->SetInfo( nClId, KEY_MMIN, b3AllMch.GetMin()) ;
m_pGeomDB->SetInfo( nClId, KEY_MMAX, b3AllMch.GetMax()) ;
return true ;
}
@@ -1196,16 +1077,14 @@ Operation::CalcAndSetAxesBBox( void)
Vector3d vtN = pCamData->GetAxesNormDir() ;
double dDeltaN = ( ptAxEnd - ptCen) * vtN ;
// ricavo i punti
const double ANG_STEP = 4.9 ;
const double ANG_STEP = 15.0 ;
int nStep = 1 + int( abs( dAngCen) / ANG_STEP) ;
double dCoeff = -1. / nStep ;
double dCosRot = cos( dCoeff * dAngCen * DEGTORAD) ;
double dSinRot = sin( dCoeff * dAngCen * DEGTORAD) ;
Point3d ptAxT = ptAxEnd ;
for ( int i = 1 ; i < nStep ; ++ i) {
// assi lineari
ptAxT.Rotate( ptCen, vtN, dCosRot, dSinRot) ;
ptAxT.Translate( vtN * ( dCoeff * dDeltaN)) ;
Point3d ptAxT = ptAxEnd ;
ptAxT.Rotate( ptCen, vtN, i * dCoeff * dAngCen) ;
ptAxT.Translate( vtN * ( i * dCoeff * dDeltaN)) ;
for ( int i = 0 ; i < min( nLinAxes, 3) ; ++ i)
vMmAxGrp[i].Add( ptAxT.v[i]) ;
}
@@ -1409,9 +1288,6 @@ Operation::SetBlockedRotAxis( const string& sBlockedAxis) const
return false ;
// cancello bloccaggio attuale
m_pMchMgr->ClearRotAxisBlock() ;
// imposto l'utensile per i calcoli macchina
if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
return false ;
// se non ci sono bloccaggi, esco
if ( sBlockedAxis.empty())
return true ;
@@ -1423,6 +1299,9 @@ Operation::SetBlockedRotAxis( const string& sBlockedAxis) const
double dVal = 0 ;
if ( ! FromString( sVal, dVal))
return true ;
// imposto l'utensile per i calcoli macchina
if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
return false ;
// recupero numero assi lineari e rotanti correnti
int nLinAxes = m_pMchMgr->GetCurrLinAxes() ;
int nRotAxes = m_pMchMgr->GetCurrRotAxes() ;
@@ -1522,9 +1401,6 @@ Operation::CalculateAxesValues( const string& sHint, bool bSolChExact)
// recupero peso primo asse rotante di testa
double dRot1W = m_pMchMgr->GetCalcRot1W() ;
// recupero flag controllo delta massimo secondo asse rotante anche su primo movimento di lavorazione
bool bMaxDeltaR2OnFirst = m_pMchMgr->GetCalcMaxDeltaR2OnFirst() ;
// recupero la minima differenza angolare da posizione precedente per stare vicino a posizione home
double dAngDeltaMinForHome = m_pMchMgr->GetAngDeltaMinForHome() ;
@@ -1545,21 +1421,18 @@ Operation::CalculateAxesValues( const string& sHint, bool bSolChExact)
while ( nClPathId != GDB_ID_NULL) {
DBLVECTOR vAxRotPrecOri = vAxRotPrec ;
int nOutStrC = 0 ;
if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, bMaxDeltaR2OnFirst,
dAngDeltaMinForHome, vAxRotHome, vAxRotPrec, nOutStrC)) {
if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, dAngDeltaMinForHome, vAxRotHome, vAxRotPrec, nOutStrC)) {
// se attivata scelta angolo iniziale vicino ad home ed extra corsa C, provo a rifarlo disattivando
if ( dAngDeltaMinForHome < ANG_FULL && nOutStrC != 0) {
m_pMchMgr->GetCurrMachine()->ResetOutstrokeInfo() ;
CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, bMaxDeltaR2OnFirst,
INFINITO, vAxRotHome, vAxRotPrec, nOutStrC) ;
CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC) ;
}
// se extracorsa dell'asse C, provo a precaricarlo al contrario
if ( nOutStrC != 0) {
vAxRotPrec = vAxRotPrecOri ;
vAxRotPrec[0] = vAxRotPrecOri[0] + ( nOutStrC > 0 ? - ANG_FULL : ANG_FULL) ;
vAxRotPrec[1] = vAxRotPrecOri[1] ;
m_pMchMgr->GetCurrMachine()->ResetOutstrokeInfo() ;
if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, bMaxDeltaR2OnFirst,
INFINITO, vAxRotHome, vAxRotPrec, nOutStrC))
if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC))
bOk = false ;
}
else
@@ -1573,13 +1446,14 @@ Operation::CalculateAxesValues( const string& sHint, bool bSolChExact)
//----------------------------------------------------------------------------
bool
Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, bool bMaxDeltaR2OnFirst,
Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC)
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// massima variazione secondo asse rotante per continuità
double dMaxDeltaR2 = 30 ;
double dDeltaR2Max = 30 ;
// recupero il numero degli assi lineari e rotanti
// predispongo variabile per valori assi
DBLVECTOR vAxVal ;
vAxVal.reserve( 8) ;
@@ -1727,10 +1601,10 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
if ( bAng2 && ( dDelta2 < dDelta1 - EPS_ANG_SMALL || ! bAng1))
swap( vAng1, vAng2) ;
// se imposto limite su variazione di secondo asse rotante
if ( ( bMaxDeltaR2OnFirst || ! bFirst) && dMaxDeltaR2 > EPS_ANG_SMALL && vAng1.size() >= 2) {
if ( dDeltaR2Max > EPS_ANG_SMALL && vAng1.size() >= 2) {
double dR2Diff1 = vAng1[1] - vAxRotPrec[1] ;
double dR2Diff2 = vAng2[1] - vAxRotPrec[1] ;
if ( abs( dR2Diff1) > abs( dR2Diff2) && abs( dR2Diff1) > dMaxDeltaR2)
if ( abs( dR2Diff1) > abs( dR2Diff2) && abs( dR2Diff1) > dDeltaR2Max)
swap( vAng1, vAng2) ;
}
}
@@ -1873,10 +1747,9 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
// se realmente arco
if ( pCurve->GetType() == CRV_ARC) {
ICurveArc* pArc = GetCurveArc( pCurve) ;
// verifico il piano (il vettore va portato nel riferimento degli assi lineari)
// verifico il piano
Vector3d vtRef ;
m_pMchMgr->GetCalcPartDirFromAngles( pCamData->GetNormDir(), vAngEnd, vtRef) ;
vtRef.ToLoc( m_pMchMgr->GetCurrLinAxesFrame()) ;
if ( pArc->GetNormVersor() * vtRef < 0)
pArc->InvertN() ;
// assegno il centro e il raggio di questo arco ai dati cam
@@ -2011,7 +1884,6 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink)
}
// Verifico non ci sia collisione a HomeZ
bool bToZmax = false ;
bool bToMyHomeZ = false ;
DBLVECTOR vAxVal2 = vAxVal ; vAxVal2[2] = dHomeZ ;
DBLVECTOR vAxIni2 = vAxIni ; vAxIni2[2] = dHomeZ ;
if ( ! TestCollisionAvoid( vAxVal2, vAxIni2)) {
@@ -2024,10 +1896,8 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink)
double dMyHomeZ = dHomeZ + dExtraZ ;
vAxVal2[2] = dMyHomeZ ;
vAxIni2[2] = dMyHomeZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
if ( TestCollisionAvoid( vAxVal2, vAxIni2))
dHomeZ = dMyHomeZ ;
bToMyHomeZ = true ;
}
else
bToZmax = true ;
}
@@ -2072,43 +1942,41 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink)
bMaxZ = true ;
}
// altrimenti, verifico se la testa interferisce con i pezzi o i bloccaggi sulla tavola
else if ( bToMyHomeZ || ! TestCollisionAvoid( vAxVal, vAxIni)) {
else if ( ! TestCollisionAvoid( vAxVal, vAxIni)) {
// riprovo con risalita parziale
bool bPartRise = false ;
double dSafeZ = dHomeZ ;
double dUnsafeZ = ( bZHomeDown ? min( vAxVal[2], vAxIni[2]) : max( vAxVal[2], vAxIni[2])) ;
if ( ( ! bZHomeDown && dUnsafeZ < dSafeZ) || ( bZHomeDown && dUnsafeZ > dSafeZ)) {
DBLVECTOR vAxVal2 = vAxVal ;
DBLVECTOR vAxIni2 = vAxIni ;
vAxVal2[2] = dUnsafeZ ;
vAxIni2[2] = dUnsafeZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
bPartRise = true ;
dSafeZ = dUnsafeZ ;
}
else {
for ( int i = 1 ; i <= 3 ; ++ i) {
double dTestSafeZ = ( dUnsafeZ + dSafeZ) / 2 ;
vAxVal2[2] = dTestSafeZ ;
vAxIni2[2] = dTestSafeZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
bPartRise = true ;
dSafeZ = dTestSafeZ ;
}
else {
dUnsafeZ = dTestSafeZ ;
}
}
}
// se necessario, riprovo appena prima di Zmax
if ( ! bPartRise) {
double dOffsZ = 1 * ( bZHomeDown ? 1 : -1) ;
vAxVal2[2] = dHomeZ + dOffsZ ;
vAxIni2[2] = dHomeZ + dOffsZ ;
DBLVECTOR vAxVal2 = vAxVal ;
DBLVECTOR vAxIni2 = vAxIni ;
vAxVal2[2] = dUnsafeZ ;
vAxIni2[2] = dUnsafeZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
bPartRise = true ;
dSafeZ = dUnsafeZ ;
}
else {
for ( int i = 1 ; i <= 3 ; ++ i) {
double dTestSafeZ = ( dUnsafeZ + dSafeZ) / 2 ;
vAxVal2[2] = dTestSafeZ ;
vAxIni2[2] = dTestSafeZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
bPartRise = true ;
dSafeZ = dHomeZ + dOffsZ ;
dSafeZ = dTestSafeZ ;
}
else {
dUnsafeZ = dTestSafeZ ;
}
}
}
// se necessario, riprovo appena prima di Zmax
if ( ! bPartRise) {
double dOffsZ = 5 * ( bZHomeDown ? 1 : -1) ;
vAxVal2[2] = dHomeZ + dOffsZ ;
vAxIni2[2] = dHomeZ + dOffsZ ;
if ( TestCollisionAvoid( vAxVal2, vAxIni2)) {
bPartRise = true ;
dSafeZ = dHomeZ + dOffsZ ;
}
}
if ( ! bPartRise) {
@@ -2209,7 +2077,6 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink)
// passo al successivo
nPrevClPathId = nClPathId ;
nClPathId = m_pGeomDB->GetNextGroup( nClPathId) ;
pPrevOp = nullptr ;
}
// aggiungo risalita finale
@@ -2276,12 +2143,6 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation*
if ( bModif) {
vAxNew = vAxTmp ;
pCamData->SetToolDir( vtTool) ;
Vector3d vtAux = pCamData->GetAuxDir() ;
if ( ! vtAux.IsSmall()) {
DBLVECTOR vAng( vAxNew.begin() + 3, vAxNew.end()) ;
if ( m_pMchMgr->GetCalcAuxDirFromAngles( vAng, vtAux))
pCamData->SetAuxDir( vtAux) ;
}
nFlagNew = nFlagTmp ;
nFlag2New = nFlag2Tmp ;
}
@@ -2338,17 +2199,14 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation*
}
// risalita sopra fine percorso precedente
DBLVECTOR vAxNew1 ;
double dDelta = ( ! bZHomeDown ? max( dSafeZ - vAxPrev[2], 0.) : min( dSafeZ - vAxPrev[2], 0.)) ;
if ( nPrevClPathId == GDB_ID_NULL) {
if ( pPrevOp == nullptr || ! pPrevOp->RemoveRise())
return false ;
DBLVECTOR vAxPrevNoRise ;
pPrevOp->GetFinalAxesValues( false, vAxPrevNoRise) ;
double dDelta = ( ! bZHomeDown ? max( dSafeZ - vAxPrevNoRise[2], 0.) : min( dSafeZ - vAxPrevNoRise[2], 0.)) ;
if ( ! pPrevOp->AddRise( vAxNew1, dDelta, GDB_ID_NULL, bZHomeDown))
if ( pPrevOp == nullptr ||
! pPrevOp->RemoveRise() ||
! pPrevOp->AddRise( vAxNew1, dDelta, GDB_ID_NULL, bZHomeDown))
return false ;
}
else {
double dDelta = ( ! bZHomeDown ? max( dSafeZ - vAxPrev[2], 0.) : min( dSafeZ - vAxPrev[2], 0.)) ;
if ( ! AddRise( vAxNew1, dDelta, nPrevClPathId, bZHomeDown))
return false ;
}
@@ -2362,22 +2220,16 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation*
int nFlagNew = 2 ;
int nFlag2New = ( bPartRise ? 0 : 1) ;
// eventuali aggiustamenti speciali dipendenti dalla macchina
DBLVECTOR vAxTmp = vAxNew ;
Vector3d vtTool = pCamData->GetToolDir() ;
DBLVECTOR vAxTmp = vAxNew ;
int nFlagTmp = nFlagNew ;
int nFlag2Tmp = nFlag2New ;
bool bModif ;
if ( ! SpecialMoveZup( vAxTmp, vtTool, nFlagTmp, nFlag2Tmp, bModif))
return false ;
if ( bModif) {
vAxNew = vAxTmp ;
pCamData->SetToolDir( vtTool) ;
Vector3d vtAux = pCamData->GetAuxDir() ;
if ( ! vtAux.IsSmall()) {
DBLVECTOR vAng( vAxNew.begin() + 3, vAxNew.end()) ;
if ( m_pMchMgr->GetCalcAuxDirFromAngles( vAng, vtAux))
pCamData->SetAuxDir( vtAux) ;
}
vAxNew = vAxTmp ;
nFlagNew = nFlagTmp ;
nFlag2New = nFlag2Tmp ;
}
@@ -2416,22 +2268,16 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation*
int nFlagNew = 2 ;
int nFlag2New = 0 ;
// eventuali aggiustamenti speciali dipendenti dalla macchina
DBLVECTOR vAxTmp = vAxNew ;
Vector3d vtTool = pCamData->GetToolDir() ;
DBLVECTOR vAxTmp = vAxNew ;
int nFlagTmp = nFlagNew ;
int nFlag2Tmp = nFlag2New ;
bool bModif ;
if ( ! SpecialMoveZup( vAxTmp, vtTool, nFlagTmp, nFlag2Tmp, bModif))
return false ;
if ( bModif) {
vAxNew = vAxTmp ;
pCamData->SetToolDir( vtTool) ;
Vector3d vtAux = pCamData->GetAuxDir() ;
if ( ! vtAux.IsSmall()) {
DBLVECTOR vAng( vAxNew.begin() + 3, vAxNew.end()) ;
if ( m_pMchMgr->GetCalcAuxDirFromAngles( vAng, vtAux))
pCamData->SetAuxDir( vtAux) ;
}
vAxNew = vAxTmp ;
nFlagNew = nFlagTmp ;
nFlag2New = nFlag2Tmp ;
}
@@ -2554,22 +2400,16 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta, int nClPathId, bool bZHome
nFlag2 = 1 ;
}
// eventuale aggiustamenti speciali dipendenti dalla macchina
DBLVECTOR vAxTmp = vAxVal ;
Vector3d vtTool = pCam->GetToolDir() ;
DBLVECTOR vAxTmp = vAxVal ;
int nFlagTmp = nFlag ;
int nFlag2Tmp = nFlag2 ;
bool bModif ;
if ( ! SpecialMoveZup( vAxTmp, vtTool, nFlagTmp, nFlag2Tmp, bModif))
return false ;
if ( bModif) {
vAxVal = vAxTmp ;
pCam->SetToolDir( vtTool) ;
Vector3d vtAux = pCam->GetAuxDir() ;
if ( ! vtAux.IsSmall()) {
DBLVECTOR vAng( vAxVal.begin() + 3, vAxVal.end()) ;
if ( m_pMchMgr->GetCalcAuxDirFromAngles( vAng, vtAux))
pCam->SetAuxDir( vtAux) ;
}
vAxVal = vAxTmp ;
nFlag = nFlagTmp ;
nFlag2 = nFlag2Tmp ;
}
@@ -2577,7 +2417,9 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta, int nClPathId, bool bZHome
double dL1 = vAxVal[0] ;
double dL2 = vAxVal[1] ;
double dL3 = vAxVal[2] ;
DBLVECTOR vAng( vAxVal.begin() + 3, vAxVal.end()) ;
DBLVECTOR vAng ;
for ( int i = 0 ; i < int( vAxVal.size()) - 3 ; ++ i)
vAng.emplace_back( vAxVal[i+3]) ;
int nStat ;
bool bOk = ( m_pMchMgr->VerifyOutstroke( dL1, dL2, dL3, vAng, false, nStat) && nStat == 0) ;
// assegno i dati
@@ -3065,7 +2907,7 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
pMch->GetCurrHeadCollGroups( vCollId) ;
// distanza di sicurezza
const double TOL_SAFEDIST = 5.0 ;
const double MIN_SAFEDIST = 5.0 ;
const double MIN_SAFEDIST = 10.0 ;
double dSafeDist = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
dSafeDist = max( dSafeDist - TOL_SAFEDIST, MIN_SAFEDIST) ;
// Vado nelle posizioni da controllare
@@ -3074,20 +2916,10 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
for ( int i = 0 ; i < COLL_STEP && ! bCollide ; ++ i) {
// Imposto la posizione
double dCoeff = double( i) / COLL_STEP ;
for ( int j = 0 ; j < int( vAxName.size()) ; ++ j) {
for ( size_t j = 0 ; j < vAxStart.size() ; ++ j) {
double dPos = ( 1 - dCoeff) * vAxStart[j] + dCoeff * vAxEnd[j] ;
pMch->SetAxisPos( vAxName[j], dPos) ;
}
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
string sAxes = "Test Collision at " ;
for ( int j = 0 ; j < int( vAxName.size()) ; ++ j) {
double dPos ;
pMch->GetAxisPos( vAxName[j], dPos) ;
sAxes += vAxName[j] + "=" + ToString( dPos, 1) + " " ;
}
LOG_DBG_INFO( GetEMkLogger(), sAxes.c_str()) ;
}
// Determino sottobox e box della testa e degli altri oggetti da considerare per la collisione
BOXIVECTOR vbiSH ;
BBox3d b3Head ;
@@ -3103,32 +2935,13 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
}
nHId = m_pGeomDB->GetNext( nHId) ;
}
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
string sHead ;
if ( ! m_pGeomDB->GetName( nCId, sHead))
sHead = "---" ;
string sOut = " " + sHead + " : " + ToString( b3Head, 1) ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
}
}
// Li confronto con i grezzi
for ( const auto nRawId : vRawId) {
// verifico i box
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) ;
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
string sBox = " Raw : " + ( b3Raw.IsEmpty() ? string( "Empty Box") : ToString( b3Raw, 1)) ;
LOG_DBG_INFO( GetEMkLogger(), sBox.c_str()) ;
}
// se i box interferiscono
if ( ! b3Raw.IsEmpty() && b3Head.Overlaps( b3Raw)) {
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
LOG_DBG_INFO( GetEMkLogger(), " Can collide -->") ;
}
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Head.Overlaps( b3Raw)) {
// solido del grezzo
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nRawSolidId)) ;
// riferimento del grezzo
@@ -3179,28 +2992,13 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
break ;
}
}
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
LOG_DBG_INFO( GetEMkLogger(), ( bCollide ? " COLLIDE" : " avoid")) ;
}
// Se non trovata collisione, li confronto con i bloccaggi
if ( ! bCollide) {
for ( const auto nFxtId : vFxtId) {
// verifico i box
BBox3d b3Fxt ;
int nFlag = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
m_pGeomDB->GetGlobalBBox( nFxtId, b3Fxt, nFlag) ;
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
string sBox = " Fxt : " + ( b3Fxt.IsEmpty() ? string( "Empty Box") : ToString( b3Fxt, 1)) ;
LOG_DBG_INFO( GetEMkLogger(), sBox.c_str()) ;
}
// se i box interferiscono
if ( ! b3Fxt.IsEmpty() && b3Head.Overlaps( b3Fxt)) {
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
LOG_DBG_INFO( GetEMkLogger(), " Can collide -->") ;
}
if ( m_pGeomDB->GetGlobalBBox( nFxtId, b3Fxt, nFlag) && b3Head.Overlaps( b3Fxt)) {
// verifico i sottobox
for ( const auto& biSH : vbiSH) {
if ( biSH.first.Overlaps( b3Fxt)) {
@@ -3212,10 +3010,6 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
break ;
}
}
// eventuale emissione Log
if ( ExeGetDebugLevel() >= 5) {
LOG_DBG_INFO( GetEMkLogger(), ( bCollide ? " COLLIDE" : " avoid")) ;
}
}
}
// Riporto la macchina in home
@@ -3360,6 +3154,5 @@ Operation::GetAggrBottomData( const string& sHead, AggrBottom& agbData) const
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_DMAX, agbData.dDMax) ;
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_ENCH, agbData.dEncH) ;
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_ENCV, agbData.dEncV) ;
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_MDIR, agbData.vtMDir) ;
return true ;
}
+5 -12
View File
@@ -43,7 +43,6 @@ class Operation : public IUserObj
virtual int GetPhase( void) const
{ return m_nPhase ; }
virtual bool RemoveHome( void) ;
std::string GetName( void) const ;
public :
virtual int GetType( void) const = 0 ;
@@ -69,8 +68,6 @@ class Operation : public IUserObj
bool UpdateFollowingOperationsStatus( int nModif) ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev, Vector3d& vtNorm) const ;
bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3,
@@ -78,22 +75,17 @@ class Operation : public IUserObj
bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad,
const Vector3d& vtDir, double& dElev) const ;
bool GetPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
double dToolLen, bool bIsSaw, double dSafeZ, const Vector3d& vtDir, double& dElev) const ;
double dToolLen, bool bIsSaw, double dSafeZ, double& dElev) const ;
bool GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) const ;
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
double& dDist, Vector3d& vtDir) const ;
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
const Vector3d& vtMainDir, double dCosMaxDelta,
double& dDist, Vector3d& vtDir) const ;
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) const ;
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) const
{ double dDummy ;
return GetDistanceFromRawBottom( nPhase, nPathId, dToler, dRbDist, dDummy) ; }
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const ;
bool GetDistanceFromRawBottom( int nPhase, BBox3d& b3Test, double dToler, double& dRbDist, double& dAllRbDist) const;
bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) const ;
bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) const ;
bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick, int nGrade = 3) ;
bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick) ;
bool ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp = false) const ;
bool ApproxWithLines( ICurveComposite* pCompo) const ;
bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) const ;
@@ -117,7 +109,7 @@ class Operation : public IUserObj
std::string ExtractHint( const std::string& sNotes) const ;
bool SetBlockedRotAxis( const std::string& sBlockedAxis) const ;
bool CalculateAxesValues( const std::string& sHint, bool bSolChExact = false) ;
bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, bool bMaxDeltaR2OnFirst,
bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) ;
bool AdjustStartEndMovements( bool bVerifyPreviousLink = true) ;
bool AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation* pPrevOp, const DBLVECTOR& vAxPrev, bool bMaxZ) ;
@@ -134,6 +126,7 @@ class Operation : public IUserObj
bool SpecialGetMaxZ( const DBLVECTOR& vAx1, const Vector3d& vtTool1,
const DBLVECTOR& vAx2, const Vector3d& vtTool2,
double& dMaxZ) const ;
bool SpecialGetMaxZ( DBLVECTOR& vAx1, Vector3d& vtTool1, DBLVECTOR& vAx2, Vector3d& vtTool2, int& dMaxZ) ;
bool GetRotationAtZmax( void) const ;
bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
int GetUserNotesZmax( void) const ;
-2
View File
@@ -65,7 +65,6 @@ static const std::string GVAR_TDIAM = ".TDIAM" ; // (num) diametro
static const std::string GVAR_TTOTDIAM = ".TTOTDIAM" ; // (num) diametro totale utensile
static const std::string GVAR_TLEN = ".TLEN" ; // (num) lunghezza utensile
static const std::string GVAR_TTOTLEN = ".TTOTLEN" ; // (num) lunghezza totale utensile
static const std::string GVAR_TDIST = ".TDIST" ; // (num) distanza utensile (per mortasatrice/sega a catena)
static const std::string GVAR_TUSED = ".TUSED" ; // (bool) flag per indicare che l'utensile attrezzato è anche utilizzato
static const std::string GVAR_SMAX = ".SMAX" ; // (num) massima speed utensile
static const std::string GVAR_FIRST = ".FIRST" ; // (bool) flag per primo utensile
@@ -151,7 +150,6 @@ static const std::string GVAR_SHOWAXES = ".ShowAxes" ; // (bool) flag visu
static const std::string GVAR_AUXAXES = ".AuxAxes" ; // (int) numero assi ausiliari per simulazione
static const std::string GVAR_AN = ".AN" ; // (num) valore del N-esimo asse ausiliario per simulazione
static const std::string GVAR_ANN = ".ANn" ; // (string) nome del N-esimo asse ausiliario per simulazione
static const std::string GVAR_ANM = ".ANm" ; // (string) asse master del N-esimo asse ausiliario per simulazione
static const std::string GVAR_VMILL = ".VMILL" ; // (int/s) identificativi Zmap attivi per Virtual Milling
static const std::string GVAR_CODET = ".CODET" ; // (int/s) identificativi Zmap attivi per Collision Detection
static const std::string GVAR_SIM1ST = ".SIM1ST" ; // (bool) flag inizio simulazione
+2204 -5513
View File
File diff suppressed because it is too large Load Diff
+38 -90
View File
@@ -17,7 +17,6 @@
#include "PocketingData.h"
#include "ToolData.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
@@ -72,101 +71,54 @@ class Pocketing : public Machining
bool SetCurveAllTempProp( int nCrvId, ICurve* pCurve) ;
bool ResetCurveAllTempProp( ICurve* pCurve) ;
bool Chain( int nGrpDestId) ;
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
bool ProcessPath( int nAuxId, int nPvId, int nClId) ;
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
bool VerifyPathFromBottom( const ISurfFlatRegion* pSrf, const Vector3d& vtTool) ;
bool GeneratePocketingPv( int nPathId, const ISurfFlatRegion* pSrfPock) ;
bool ModifyCurveToSmooted( ICurveComposite* pCrvOffset, double dRightPer, double dleftPer) ;
// ===== ZigZag =====
bool AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, double dOkStep,
bool bSplitArcs, int nPathId) ;
bool CalcZigZag( const ISurfFlatRegion* pSrfZigZag, ICRVCOMPOPOVECTOR& vpCrvs) ;
bool CalcBoundedZigZagLink( ICurveLine* pCrv1, ICurveLine* pCrv2, ICRVCOMPOPOVECTOR& vOffIslands, ICurveComposite* pCrvLink, int nIndexCut = 3) ;
bool OptimizedZigZag( ISurfFlatRegion* pSrf, const Vector3d & vtTool, double dDepth, double dSafeZ, Frame3d & frPocket, bool & bOptimizedZigZag,
ICRVCOMPOPOVECTOR & vpCrvs) ;
bool ZigZagOptimizedNoClosedEdges( ICurveComposite* pCrvPocket, bool& bOptimizedZigZag, Vector3d& vtDir) ;
bool ZigZagOptimizedOneClosedEdge( ICurveComposite* pCrvPocket, int nClosedId, bool& bOptimizedZigZag, Vector3d& vtDir) ;
bool ZigZagOptimizedTwoClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
bool& bOpposite, Vector3d& vtDir) ;
bool ZigZagOptimizedThreeClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
bool& bOpposite, Vector3d& vtDir) ;
bool ZigZagOptimizedComputeOffset( ICurveComposite* pCrvPocket, const Vector3d& vtMainDir, int nOffsettedEdgesOnY,
const INTVECTOR& vnClosedIds) ;
bool CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) ;
bool GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICURVEPOVECTOR& vLinks, ISurfFlatRegion* pSrfToCut) ;
// ==================
// ==== OneWay ======
bool AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
// ==================
// ==== SpiralIn/Out ====
bool AddSpiralIn( const ISurfFlatRegion* pSrfPock, const PNTVECTOR vPtStart, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth,
double dElev, double dOkStep, bool bSplitArcs, BOOLVECTOR vbMidOpen, PNTVECTOR vPtMidOpen, VCT3DVECTOR vVtMidOut, int nPathId) ;
bool AddSpiralOut( const ISurfFlatRegion* pSrfpock, const PNTVECTOR vPtStart, const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, double dElev,
double dOkStep, bool bSplitArcs, int nPathId) ;
bool CalcSpiral( const ISurfFlatRegion* pSrfChunk, int nReg, Point3d ptStart, bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv, int nPathId,
bool& bOptimizedTrap) ;
bool RemoveExtraParts( ISurfFlatRegion* pSrfToCut, ICRVCOMPOPOVECTOR& vOffs, ICRVCOMPOPOVECTOR& vOffsClosedCurves, ICRVCOMPOPOVECTOR& vOffsFirstCurve,
ICURVEPOVECTOR& vLinks) ;
bool RemoveExtraPartByMedialAxis( ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECTOR& vOffsFirstCurve, int& nOptFlag, Point3d& ptCentroid,
ICurveComposite* pCrvPath) ;
bool CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR& vOffIslands, ICurveComposite* pCrvLink) ;
bool CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const Point3d& ptEnd, const Vector3d& vtEnd, double dParMeet,
ICRVCOMPOPOVECTOR& vOffIslands, ICurveComposite* pCrvLink) ;
bool ModifyBiArc( ICurve* pCrvBiArc, double dCutToll, ICurveComposite* pNewCrv) ;
bool CutCurveByOffsets( ICurveComposite* pCurve, ICRVCOMPOPOVECTOR& vOffs) ;
bool GetCurveWeightInfo( ICurveComposite* pCrvCompo, double dMaxLen, double& dToTRot, int& nSmallArcs, int& nSmallLines) ;
bool ChoosePath( ICurveComposite* pCrv1, ICurveComposite* pCrv2, int nP, double dPerP, double dMaxLen, int& nC) ;
bool CutCurveToConnect( ICurveComposite* pCrvS, ICurveComposite* pCrvE, ICRVCOMPOPOVECTOR& vOffs, ICRVCOMPOPOVECTOR& vOffIslands,
ICurveComposite* pCrvLink, double dLenPercS = 0.01, double dLenPercE = 0.01, int nMaxIter = 2) ;
bool GetNewCurvetWithCentroid( ICurveComposite* pCrvH1, ICurveComposite* pCrvH2, Point3d& ptC, bool bCir, ICRVCOMPOPOVECTOR& VFirstOff,
ICurveComposite* pCrvNewCurve) ;
bool GetNewCurvetWithPath( ICurveComposite* pCrvH1, ICurveComposite* pCrvH2, ICurveComposite* pCrvPath, ICRVCOMPOPOVECTOR& VFirstOff, ICRVCOMPOPOVECTOR& VoffsCl,
ICurveComposite* pCrvNewCurve) ;
bool ManageSmoothAndAutoInters( ICurveComposite* pCrv, ICurveComposite* pCrvPath, ICurveComposite* pPath1, ICurveComposite* pPath2, ICRVCOMPOPOVECTOR& vOffsCL) ;
bool CalcBoundedLinkWithBiArcs( const Point3d& ptStart, const Vector3d& vtStart, const Point3d& ptEnd, const Vector3d& vtEnd,
const ICurve* pCrvBound, ICurveComposite* pCrvLink) ;
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
bool GeneratePocketingPv( int nPathId, const ISurfFlatRegion* pSrf) ;
bool AddZigZag( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool CalcZigZag( const ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vpCrvs) ;
bool AddOneWay( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool AddSpiralIn( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bMidOpen,
const Point3d& ptMidOpen, const Vector3d& vtMidOut) ;
bool AddSpiralOut( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool CalcSpiral( const ISurfFlatRegion* pSrf, int nReg, bool bSplitArcs,
ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
bool RemoveUncutRegions( const ISurfFlatRegion * pCutRegion, ICRVCOMPOPVECTOR& vOffs, const ISurfFlatRegion * pSrfBound) ;
bool FindCurveForPathAdd( const ICurve* pResidualCrv, const ICRVCOMPOPOVECTOR& vOffs, size_t& nIdxMin, Point3d& ptMinDist,
double& dMinDistPar, const ISurfFlatRegion * pSrfBound) ;
bool ComputeAdditionalPath( const Point3d ptStart, Point3d ptEnd, bool bUsePtEnd, ICurveComposite * pAddPath,
const ICurve * pResidualCrv, const ISurfFlatRegion * pSrfBound, ISurfFlatRegion * pNewCutRegion) ;
bool AdditionalPathExternalCentroid( const Point3d ptStart, ICurveComposite * pAddPath, ICurveComposite * pResidualCrv,
const ISurfFlatRegion * pSrfBound, ISurfFlatRegion * pNewCutRegion) ;
bool CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, const ISurfFlatRegion * pSrf,
ICurveComposite* pCrvLink) ;
bool CircleSpiral( ISurfFlatRegion* pSrf, bool bSplitArcs, ICRVCOMPOPVECTOR& vOffs, ICurveComposite* pRCrv) ;
bool CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double dOutRad, double dIntRad,
bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
bool CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtDir, double dPocketSize,
ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool& bOptimizedTrap) ;
bool CalcTrapezoidSpiralLocalFrame( ICurveComposite * pCrvPocket, const Vector3d& vtDir, Frame3d& frLoc) ;
bool CalcTrapezoidSpiralXCoord( const ICurveComposite * pCrvPocket, bool bStart, double dYCoord, double& dXCoord, double dPocketSize) ;
bool AdjustTrapezoidSpiralForAngles( ICurveComposite * pMCrv, const ICurveComposite * pCrvPocket, bool bStart) ;
bool SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* pCrvPocket) ;
bool AdjustTrapezoidSpiralForLeadInLeadOut( ICurveComposite * pCompo, ICurveComposite * pRCrv, const Vector3d& vtTool,
double dDepth, int& nOutsideRaw) ;
bool ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite * pCompo, const Vector3d& vtMainDir, bool bLeadIn, const Vector3d& vtTool, double dDepth,
bool& bIsOutsideRaw) ;
// ==================
bool ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs) ;
bool AddEpicycles( ICurveComposite * pCompo, ICurveComposite * pCrv, ICurveComposite * pCrvBound = nullptr) ;
bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart) ;
double dElev, double dAppr, bool bOutStart) ;
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart = false) ;
double dElev, double dAppr) ;
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr) ;
double dElev, double dAppr) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr) ;
double dElev, double dAppr) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
const ICurveComposite* pRCrv, Point3d& ptP1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
ISurfFlatRegion* pSrfChunk, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
bool bNoneForced = false, bool bSkipControl = false) ;
const ICurveComposite* pRCrv, Point3d& ptP1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
const ISurfFlatRegion* pSrf, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs, bool bNoneForced = false) ;
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev, bool bNoneForced = false) ;
const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev, bool bNoneForced = false) ;
double GetRadiusForStartEndElevation( void) const ;
bool GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMid, Vector3d& vtMidOut) ;
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
bool AdjustContourStart( ICurveComposite* pCompo) ;
bool VerifyLeadInHelix( ISurfFlatRegion* pSrfChunk, const Point3d& ptCen, double dRad) const ;
bool VerifyLeadInZigZag( ISurfFlatRegion* pSrfChunk, const Point3d& ptPa, const Point3d& ptPb) const ;
bool CalcDistanceFromRawSurface( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist, Vector3d& vtNorm) ;
bool VerifyLeadInHelix( const ISurfFlatRegion* pSrf, const Point3d& ptCen, double dRad) const ;
bool VerifyLeadInZigZag( const ISurfFlatRegion* pSrf, const Point3d& ptPa, const Point3d& ptPb) const ;
private :
double GetSpeed( void) const
@@ -194,8 +146,7 @@ class Pocketing : public Machining
int LeadInIsOk( void) const
{ if ( m_TParams.m_nType != TT_MILL_NOTIP)
return true ;
return (( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX) &&
m_Params.m_dLiTang >= 0.9 * m_TParams.m_dDiam && m_Params.m_dLiElev <= 2) ; }
return ( GetLeadInType() == POCKET_LI_HELIX && m_Params.m_dLiTang >= 0.49 * m_TParams.m_dDiam && m_Params.m_dLiElev <= 2) ; }
int GetLeadOutType( void) const
{ if ( m_Params.m_dLoTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
return POCKET_LO_NONE ;
@@ -205,7 +156,6 @@ class Pocketing : public Machining
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
PocketingData m_Params ; // parametri lavorazione
ToolData m_TParams ; // parametri utensile
double m_dTHoldBase ; // posizione base del porta-utensile
double m_dTHoldLen ; // lunghezza del porta-utensile
double m_dTHoldDiam ; // diametro del porta-utensile
double m_dMaxHelixRad ; // raggio massimo attacco ad elica nel caso di cerchi
@@ -216,6 +166,4 @@ class Pocketing : public Machining
bool m_bAggrBottom ; // flag di utilizzo dell'aggregato da sotto
Vector3d m_vtAggrBottom ; // vettore direzione ausiliaria aggregato da sotto
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
bool m_bOpenOutRaw ; // flag forzatura lati aperti sempre fuori dal grezzo
POLYLINEVECTOR m_VplIsland ; // vettore che contiene le curve che descrivono le isole
} ;
+1 -14
View File
@@ -29,8 +29,6 @@ enum nPocketingKey {
KEY_AB = 0,
KEY_AI,
KEY_DH,
KEY_EPCD,
KEY_EPCR,
KEY_F,
KEY_FE,
KEY_FS,
@@ -63,8 +61,6 @@ static const array<string,KEY_ZZZ> sPocketingKey = {
"AB",
"AI",
"DH",
"EPCD",
"EPCR",
"F",
"FE",
"FS",
@@ -245,12 +241,6 @@ PocketingData::FromString( const string& sString, int& nKey)
if ( m_sDepth.empty())
m_sDepth = "0" ;
break ;
case KEY_EPCD :
bOk = ::FromString( sVal, m_dEpicyclesDist) ;
break ;
case KEY_EPCR :
bOk = ::FromString( sVal, m_dEpicyclesRad) ;
break ;
case KEY_F :
bOk = ::FromString( sVal, m_dFeed) ;
break ;
@@ -345,8 +335,6 @@ PocketingData::ToString( int nInd) const
case KEY_AB : return ( sPocketingKey[KEY_AB] + "=" + m_sBlockedAxis) ;
case KEY_AI : return ( sPocketingKey[KEY_AI] + "=" + m_sInitAngs) ;
case KEY_DH : return ( sPocketingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_EPCD : return ( m_dEpicyclesRad < EPS_SMALL ? "" : sPocketingKey[KEY_EPCD] + "=" + ::ToString( m_dEpicyclesDist)) ;
case KEY_EPCR : return ( m_dEpicyclesRad < EPS_SMALL ? "" : sPocketingKey[KEY_EPCR] + "=" + ::ToString( m_dEpicyclesRad)) ;
case KEY_F : return ( sPocketingKey[KEY_F] + "=" + ::ToString( m_dFeed)) ;
case KEY_FE : return ( sPocketingKey[KEY_FE] + "=" + ::ToString( m_dEndFeed)) ;
case KEY_FS : return ( sPocketingKey[KEY_FS] + "=" + ::ToString( m_dStartFeed)) ;
@@ -381,8 +369,7 @@ PocketingData::ToString( int nInd) const
bool
PocketingData::IsOptional( int nKey) const
{
return ( nKey == KEY_AB || nKey == KEY_AI || nKey == KEY_EPCD || nKey == KEY_EPCR ||
nKey == KEY_LIEL || nKey == KEY_TI) ;
return ( nKey == KEY_AB || nKey == KEY_AI || nKey == KEY_LIEL || nKey == KEY_TI) ;
}
//----------------------------------------------------------------------------
+1 -3
View File
@@ -43,8 +43,6 @@ struct PocketingData : public MachiningData
double m_dLiElev ; // elevazione di uno step di attacco
int m_nLeadOutType ; // tipo di uscita (come attacco, nessuno, lineare, tangente, inseguimento)
double m_dLoTang ; // distanza tangente verso fine uscita
double m_dEpicyclesRad ; // raggio epicicli lucidatura
double m_dEpicyclesDist ; // distanza epicicli lucidatura
std::string m_sSysNotes ; // note interne
std::string m_sUserNotes ; // note dell'utente
@@ -53,7 +51,7 @@ struct PocketingData : public MachiningData
m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR), m_bToolInvert( false), m_bInvert( false),
m_dStartPos( 0), m_dStep( 0), m_dSideStep( 0), m_nSubType( 0), m_dSideAngle( 0),
m_nLeadInType( 0), m_dLiTang( 0), m_dLiElev( 0),
m_nLeadOutType( 0), m_dLoTang( 0), m_dEpicyclesRad( 0), m_dEpicyclesDist( 0) {}
m_nLeadOutType( 0), m_dLoTang( 0) {}
PocketingData* Clone( void) const override ;
bool CopyFrom( const MachiningData* pMdata) override ;
bool SameAs(const MachiningData* pMdata) const override ;
+11 -27
View File
@@ -447,13 +447,13 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd,
int nMove = pCamData->GetMoveType() ;
switch ( nMove) {
case 0 : // rapido
if ( ! OnRapid( nEntId, nEntInd, nMove, AxesEnd, pCamData->GetAxesMask(),
if ( ! OnRapid( nMove, AxesEnd, pCamData->GetAxesMask(),
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
return false ;
break ;
case 1 : // linea
if ( ! OnLinear( nEntId, nEntInd, nMove, AxesEnd,
if ( ! OnLinear( nMove, AxesEnd,
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
return false ;
@@ -462,8 +462,7 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd,
case 3 : // arco CCW
Point3d ptMid( AxesEnd[0], AxesEnd[1], AxesEnd[2]) ;
ptMid.Rotate( pCamData->GetAxesCen(), pCamData->GetAxesNormDir(), - pCamData->GetAxesAngCen() / 2) ;
if ( ! OnArc( nEntId, nEntInd, nMove, AxesEnd,
pCamData->GetAxesCen(), ptMid, pCamData->GetAxesRad(), pCamData->GetAxesAngCen(),
if ( ! OnArc( nMove, AxesEnd, pCamData->GetAxesCen(), ptMid, pCamData->GetAxesRad(), pCamData->GetAxesAngCen(),
pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(),
pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex()))
return false ;
@@ -608,10 +607,9 @@ Processor::ProcessToolData( void)
double dTDiam ;
double dLen ;
double dTLen ;
double dDist ;
double dMaxSpeed ;
MyToolData( void)
: sName(), sHead(), nExit( 0), sTcPos(), nComp(0), dDiam( 0), dLen( 0), dDist( 0), dMaxSpeed( 0) {}
: sName(), sHead(), nExit( 0), sTcPos(), nComp(0), dDiam( 0), dLen( 0), dMaxSpeed( 0) {}
} ;
typedef vector<MyToolData> TDATAVECTOR ;
TDATAVECTOR vTdata ;
@@ -641,7 +639,6 @@ Processor::ProcessToolData( void)
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, Tdata.dTDiam) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, Tdata.dLen) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, Tdata.dTLen) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIST, Tdata.dDist) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_MAXSPEED, Tdata.dMaxSpeed) ;
vTdata.push_back( Tdata) ;
}
@@ -674,20 +671,18 @@ Processor::ProcessToolData( void)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ;
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
int nComp ; double dDiam ; double dTDiam ; double dLen ; double dTLen ; double dDist ; double dMaxSpeed ;
int nComp ; double dDiam ; double dTDiam ; double dLen ; double dTLen ; double dMaxSpeed ;
m_pMchMgr->TdbGetCurrToolParam( TPA_CORR, nComp) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dDiam) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTDiam) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, dTLen) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIST, dDist) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_MAXSPEED, dMaxSpeed) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, nComp) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, dDiam) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTDIAM, dTDiam) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, dLen) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTLEN, dTLen) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIST, dDist) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, dMaxSpeed) ;
}
bool bUsed = false ;
@@ -726,7 +721,6 @@ Processor::ProcessToolData( void)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTDIAM, vTdata[i].dTDiam) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, vTdata[i].dLen) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTLEN, vTdata[i].dTLen) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIST, vTdata[i].dDist) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, vTdata[i].dMaxSpeed) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TUSED, true) ;
// se esiste, chiamo la funzione di emissione dati utensile
@@ -960,17 +954,14 @@ Processor::OnPathEndAux( int nInd, const string& sAE)
//----------------------------------------------------------------------------
bool
Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
Processor::OnRapid( int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
int nFlag, int nFlag2, int nIndex)
{
// cancello variabili estranee
ResetArcData() ;
// assegno Id e indice entità di movimento
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, nEntId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, nEntInd) ;
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
@@ -1000,17 +991,14 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd
//----------------------------------------------------------------------------
bool
Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
Processor::OnLinear( int nMove, const DBLVECTOR& AxesEnd,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex)
{
// cancello variabili estranee
ResetArcData() ;
// assegno Id e indice entità di movimento
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, nEntId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, nEntInd) ;
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
@@ -1040,16 +1028,12 @@ Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEn
//----------------------------------------------------------------------------
bool
Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
Processor::OnArc( int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex)
{
// assegno Id e indice entità di movimento
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, nEntId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, nEntInd) ;
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
+3 -5
View File
@@ -59,14 +59,12 @@ class Processor
bool OnPathEnd( int nAE) ;
bool OnPathStartAux( int nInd, const std::string& sAS) ;
bool OnPathEndAux( int nInd, const std::string& sAE) ;
bool OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
bool OnRapid( int nMove, const DBLVECTOR& AxesEnd, int nAxesMask,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
int nFlag, int nFlag2, int nIndex) ;
bool OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
bool OnLinear( int nMove, const DBLVECTOR& AxesEnd, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex) ;
bool OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
bool OnArc( int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen,
const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux,
double dFeed, int nFlag, int nFlag2, int nIndex) ;
bool ResetArcData( void) ;
+16 -10
View File
@@ -23,8 +23,8 @@
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkOffsetCurveOnX.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EgkOffsetCurveOnX.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
@@ -499,14 +499,8 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nCuts = nCurrCuts ;
LOG_DBG_INFO( GetEMkLogger(), "SawFinishing apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -588,8 +582,6 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "SawFinishing apply done") ;
return true ;
}
@@ -1564,6 +1556,18 @@ SawFinishing::CalculateCurvedAcrossToolPath( int nAuxId, int nClId)
// La porto in globale
PL.ToGlob( frSect) ;
// Calcolo eventuale anticipo dell'inizio
double dAddStart = 0 ;
if ( m_Params.m_nLeadLinkType == SAWFIN_LL_OUT) {
BBox3d b3PL ;
PL.GetLocalBBox( b3PL) ;
double dMaxElev = min( dDepth, b3Raw.GetMax().z - b3PL.GetMin().z) ;
if ( dMaxElev > 0.0 && dMaxElev < 0.5 * m_TParams.m_dDiam)
dAddStart = sqrt( dMaxElev * m_TParams.m_dDiam - dMaxElev * dMaxElev) ;
else
dAddStart = 0.5 * m_TParams.m_dDiam ;
}
// Imposto versore fresa come Z+
Vector3d vtTool = Z_AX ;
@@ -1845,6 +1849,7 @@ SawFinishing::ClassifySection( ICurve* pCrv, INTVECTOR& vnClass)
{
const ICurveComposite* pCompo = GetCurveComposite( pCrv) ;
if ( pCompo != nullptr) {
int Ind = 0 ;
const ICurve* pSimpCrv = pCompo->GetFirstCurve() ;
while ( pSimpCrv != nullptr) {
// analizzo la curva
@@ -1862,6 +1867,7 @@ SawFinishing::ClassifySection( ICurve* pCrv, INTVECTOR& vnClass)
else
vnClass.push_back( CCL_FALL) ;
// passo alla curva successiva
++ Ind ;
pSimpCrv = pCompo->GetNextCurve() ;
}
}
+2 -10
View File
@@ -23,8 +23,8 @@
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkOffsetCurveOnX.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EgkOffsetCurveOnX.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
@@ -482,14 +482,8 @@ SawRoughing::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nCuts = nCurrCuts ;
LOG_DBG_INFO( GetEMkLogger(), "SawRoughing apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -552,8 +546,6 @@ SawRoughing::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "SawRoughing apply done") ;
return true ;
}
+5 -32
View File
@@ -647,14 +647,8 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nCuts = nCurrCuts ;
LOG_DBG_INFO( GetEMkLogger(), "Sawing apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -723,8 +717,6 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "Sawing apply done") ;
return true ;
}
@@ -1222,7 +1214,7 @@ Sawing::GetCurve( SelData Id)
pCrvCompo->ToGlob( frGlob) ;
vtN.ToGlob( frGlob) ;
// sistemazioni varie
AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, 0, 1) ;
AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, 0) ;
// 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 ;
@@ -1271,7 +1263,7 @@ Sawing::GetCurve( SelData Id)
pCrvCompo->ToGlob( frGlob) ;
vtN.ToGlob( frGlob) ;
// sistemazioni varie
AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, 0, 1) ;
AdjustCurveFromSurf( pCrvCompo, TOOL_ORTUP, FACE_DOWN, 0) ;
// 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 ;
@@ -1768,11 +1760,10 @@ Sawing::ProcessLine( const ICurve* pCrvP, const ICurveLine* pLineC, const ICurve
// aggiungo affondamento
pLine->Translate( - vtCorr * dDepth) ;
// calcolo elevazione (sui due bordi della striscia, leggermente allargata)
const double DELTA_ELEV_THICK = 2.0 ;
double dElev, dElev2 ;
Vector3d vtToolH( vtTool.x, vtTool.y, 0) ;
Vector3d vtSafe = vtToolH * DELTA_ELEV_THICK ;
Vector3d vtThick = vtToolH * ( m_TParams.m_dThick / vtToolH.SqLen() + DELTA_ELEV_THICK) ;
Vector3d vtSafe = vtToolH * ( 10 * EPS_SMALL) ;
Vector3d vtThick = vtToolH * ( m_TParams.m_dThick / vtToolH.SqLen() + 10 * EPS_SMALL) ;
if ( ! GetElevation( m_nPhase, pLine->GetStart() - vtSafe, pLine->GetEnd() - vtSafe, vtCorr, dElev) ||
! GetElevation( m_nPhase, pLine->GetStart() + vtThick, pLine->GetEnd() + vtThick, vtCorr, dElev2) ) {
m_pMchMgr->SetLastError( 2210, "Error in Sawing : Entity GetElevation") ;
@@ -1983,10 +1974,7 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V
double dMove = ( dElev - dExtraCut) ;
// se sottosquadra (controllo il lato opposto della lama, quindi ...)
if ( m_Params.m_dSideAngle < 0)
dMove = dElev - dExtraCut - m_TParams.m_dThick * tan( abs( m_Params.m_dSideAngle) * DEGTORAD) ;
// altrimenti tengo conto di dove si trova il sopra del lato esterno
else
dMove = dElev - max( dExtraCut, m_TParams.m_dThick * tan( abs( m_Params.m_dSideAngle) * DEGTORAD)) ;
dMove -= m_TParams.m_dThick * tan( abs( m_Params.m_dSideAngle) * DEGTORAD) ;
// vettore movimento
Vector3d vtMove = - dMove * vtCorr ; vtMove.z = 0 ;
// rettangolo per parte di taglio completo
@@ -2017,21 +2005,6 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V
int nDwnReId = m_pGeomDB->Copy( nReId, GDB_ID_NULL, nPxId) ;
m_pGeomDB->Translate( nDwnReId, vtMove) ;
m_pGeomDB->SetName( nDwnReId, MCH_PV_DOWN_RLOCUT) ;
// riduzione larghezza regioni per tagli da sopra
if ( m_Params.m_dSideAngle > 0) {
double dRefH = max( m_TParams.m_dThick * sin( m_Params.m_dSideAngle * DEGTORAD) - dExtraCut * cos( m_Params.m_dSideAngle * DEGTORAD), 0.) ;
if ( dRefH > EPS_SMALL) {
double dLargh = vtToolH.LenXY() ;
double dRedLargh = dLargh - dRefH * tan( m_Params.m_dSideAngle * DEGTORAD) - EPS_SMALL ;
double dCoeff = dRedLargh / dLargh ;
Frame3d frScale ;
frScale.Set( ptRCross + vtMove, Z_AX, vtDir) ;
m_pGeomDB->Scale( nDwnRId, frScale, 1, dCoeff, 1) ;
m_pGeomDB->Scale( nDwnRrId, frScale, 1, dCoeff, 1) ;
m_pGeomDB->Scale( nDwnRsId, frScale, 1, dCoeff, 1) ;
m_pGeomDB->Scale( nDwnReId, frScale, 1, dCoeff, 1) ;
}
}
}
// salvo in info gruppo : larghezza XY del taglio, distanza XY tra centro e bordo taglio, extra taglio e quota minima della lama
+6
View File
@@ -181,12 +181,16 @@ SetupMgr::Import( const string& sFileName)
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
return false ;
// recupero il gruppo di setup
int nSetupId = m_pMchMgr->GetCurrSetupGroupId() ;
// inizializzo lo scanner
Scanner TheScanner ;
if ( ! TheScanner.Init( sFileName, ";"))
return false ;
// eseguo la lettura dei campi di attrezzaggio
int nPos = 1 ;
string sLine ;
while ( TheScanner.GetLine( sLine)) {
// salto dichiarazione sezione
@@ -224,6 +228,8 @@ SetupMgr::Import( const string& sFileName)
stuData.m_nExit = 0 ;
m_vStuData.emplace_back( stuData) ;
}
// passo alla successiva posizione
++ nPos ;
}
return true ;
+111 -438
View File
@@ -26,9 +26,7 @@
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EXeCmdLogOff.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EMkToolConst.h"
#include "/EgtDev/Include/EMkOperationConst.h"
@@ -44,11 +42,8 @@ using namespace std ;
static const double MIN_STEP = 1.0 ;
static const double MAX_STEP = 100.0 ;
static const double MID_STEP = 50.0 ;
static const double COLL_STEP = 10. ;
static const double COEFF_LIM = 0.999 ;
static const double SAFEDIST_STD = 5.0 ;
static const int ERR_OUTSTROKE = 1 ;
static const int ERR_COLLISION = 11 ;
//----------------------------------------------------------------------------
Simulator::Simulator( void)
@@ -72,8 +67,9 @@ Simulator::Simulator( void)
m_nAuxEInd = 0 ;
m_nExit = 0 ;
m_dTDiam = 0 ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
m_dSafeDist = SAFEDIST_STD ;
m_nAxesMask = 0 ;
m_bEnabAxes = true ;
m_bShowAxes = true ;
m_AxesName.reserve( 8) ;
@@ -161,7 +157,7 @@ Simulator::Start( bool bFirst)
// Arrivo alla preparazione per la prima lavorazione
int nStatus ;
if ( ! FindAndManageOperationStart( true, bFirst, nStatus) && nStatus != MCH_SIM_STOP)
if ( ! FindAndManageOperationStart( true, bFirst, nStatus))
bOk = false ;
// Reset timer
@@ -209,10 +205,9 @@ Simulator::ResetInterpolation( void)
m_nAuxEInd = 0 ;
m_VmId.clear() ;
m_CdId.clear() ;
m_VmTool.clear() ;
m_CollObj.clear() ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
m_dSafeDist = SAFEDIST_STD ;
m_nAxesMask = 0 ;
m_bEnabAxes = true ;
m_bShowAxes = true ;
return true ;
@@ -316,16 +311,14 @@ Simulator::GetAxisInfoPos( int nI, string& sName, string& sToken, bool& bLinear,
// recupero la posizione
if ( ! m_pMchMgr->GetAxisPos( sName, dVal))
return false ;
// verifico se da invertire o offsettare
// verifico se da invertire
if ( nI < nAxisCount) {
if ( m_AxesInvert[nI])
dVal = - dVal ;
dVal += m_AxesOffset[nI] ;
}
else {
if ( m_AuxAxesInvert[nI - nAxisCount])
dVal = - dVal ;
dVal += m_AxesOffset[nI - nAxisCount] ;
}
return true ;
}
@@ -453,7 +446,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != ERR_COLLISION)
if ( nCurrErr != 11)
return false ;
}
}
@@ -475,12 +468,29 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
// aggiorno gli assi macchina
if ( ! UpdateAxes())
return false ;
// eventuali offset per Vmill (per adattare lo ZeroT macchina con quello di Zmap)
int nToolType ; m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, nToolType) ;
if ( nToolType == TT_MORTISE_STD) {
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0.5 * dThick ;
}
else if ( nToolType == TT_SAW_STD || nToolType == TT_SAW_FLAT) {
double dLen ; m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
m_dVmTdOffs = ( ( dLen <= dThick) ? -dLen + dThick : 0) ;
m_dVmAdOffs = 0 ;
}
else {
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
}
// se cambiato oppure prima volta, lancio lo script di selezione
if ( bDiffTool || bFirst) {
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != ERR_COLLISION)
if ( nCurrErr != 11)
return false ;
}
}
@@ -498,7 +508,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != ERR_COLLISION)
if ( nCurrErr != 11)
return false ;
}
}
@@ -516,7 +526,7 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != ERR_COLLISION)
if ( nCurrErr != 11)
return false ;
}
return ( nErr == 0) ;
@@ -542,9 +552,6 @@ Simulator::UpdateAxes( void)
bool bInvert ;
m_pMachine->GetAxisInvert( m_AxesName[i], bInvert) ;
m_AxesInvert.push_back( bInvert) ;
double dOffset ;
m_pMachine->GetAxisOffset( m_AxesName[i], dOffset) ;
m_AxesOffset.push_back( dOffset) ;
bool bLinear ;
m_pMachine->GetAxisType( m_AxesName[i], bLinear) ;
m_AxesLinear.push_back( bLinear) ;
@@ -583,7 +590,6 @@ Simulator::ResetAxes( void)
m_AxesInvert.clear() ;
m_AxesLinear.clear() ;
m_AxesVal.clear() ;
m_nAxesMask = 0 ;
return true ;
}
@@ -595,11 +601,9 @@ Simulator::ResetAuxAxes( void)
m_AuxAxesName.clear() ;
m_AuxAxesToken.clear() ;
m_AuxAxesInvert.clear() ;
m_AuxAxesOffset.clear() ;
m_AuxAxesLinear.clear() ;
m_AuxAxesVal.clear() ;
m_AuxAxesEnd.clear() ;
m_AuxAxesLink.clear() ;
// abilito assi principali
m_bEnabAxes = true ;
m_bShowAxes = true ;
@@ -625,14 +629,13 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
// se lavorazione valida
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch != nullptr && ! pMch->IsEmpty()) {
bool bOk = true ;
// aggiorno utensile e assi conseguenti
int nErr ;
if ( ! UpdateTool( bFirst, nErr)) {
string sOut = "Err=" + ToString( nErr) ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
nStatus = CalcStatusOnError( nErr) ;
bOk = false ;
return false ;
}
++ m_nOpInd ;
// imposto la lavorazione come corrente
@@ -648,10 +651,8 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
// richiamo gestione evento inizio lavorazione
if ( ! OnMachiningStart( m_nOpId, m_nOpInd, ptMin, ptMax, vAxMin, vAxMax)) {
nStatus = CalcStatusOnError( 0) ;
bOk = false ;
}
if ( ! bOk)
return false ;
}
break ;
}
// se disposizione con cambio di fase
@@ -941,13 +942,10 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
DBLVECTOR AxesEnd = pCamData->GetAxesVal() ;
// Tipo di movimento
int nMoveType = pCamData->GetMoveType() ;
// Se inizio di nuova entità, mascheratura movimento
if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO)
m_nAxesMask = pCamData->GetAxesMask() ;
// Se movimento in rapido muovo solo gli assi abilitati dal mask
if ( nMoveType == 0) {
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
if ( ( m_nAxesMask & 1 << i) == 0)
if ( ( pCamData->GetAxesMask() & 1 << i) == 0)
AxesEnd[i] = m_AxesVal[i] ;
}
}
@@ -963,7 +961,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
// Se movimento in rapido aggiorno quote degli assi disabilitati dal mask
if ( nMoveType == 0) {
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
if ( ( m_nAxesMask & 1 << i) == 0)
if ( ( pCamData->GetAxesMask() & 1 << i) == 0)
AxesEnd[i] = m_AxesVal[i] ;
}
}
@@ -995,13 +993,9 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
m_dCoeff = 1 ;
dMove = ( m_dCoeff - dPrevCoeff) * dDist ;
// Posizione e direzione attuali degli utensili e riferimenti dei pezzi (per Vmill)
bool bOkI = true ;
PNTVECTOR vPtNoseI( m_VmTool.size()) ;
VCT3DVECTOR vVtDirI( m_VmTool.size()) ;
VCT3DVECTOR vVtAuxI( m_VmTool.size()) ;
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i)
bOkI = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, vPtNoseI[i], vVtDirI[i], vVtAuxI[i]) && bOkI ;
// Posizione e direzione attuali dell'utensile e riferimento attuale del pezzo (per Vmill)
Point3d ptNoseI ; Vector3d vtDirI ; Vector3d vtAuxI ;
bool bOkI = GetHeadCurrPosDirAux( ptNoseI, vtDirI, vtAuxI) ;
vector<Frame3d> vFrVzmI( m_VmId.size()) ;
for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i)
bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ;
@@ -1010,32 +1004,20 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
if ( nMoveType != 2 && nMoveType != 3) {
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck())
nStep = max( int( dMove / COLL_STEP), 1) ;
if ( NeedCollisionCheck()) {
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
DBLVECTOR vDeltaVal( m_AxesName.size()) ;
// assegno posizioni finali
for ( int j = 0 ; j < int( m_AxesName.size()) ; ++ j) {
double dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[j], dPrevVal) ;
double dVal = m_AxesVal[j] * ( 1 - dCurrCoeff) + AxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AxesName[j], dVal) ;
vDeltaVal[j] = dVal - dPrevVal ;
}
// muovo eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = 0 ;
if ( m_AuxAxesLink[j] == 0) {
dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
}
else {
m_pMachine->GetAxisPos( m_AuxAxesName[j], dVal) ;
if ( m_AuxAxesLink[j] > 0)
dVal += vDeltaVal[m_AuxAxesLink[j] - 1] ;
else
dVal -= vDeltaVal[-m_AuxAxesLink[j] - 1] ;
}
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale collision check
@@ -1043,15 +1025,12 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
// se non è rapido o non c'è verifica collisioni, eseguo eventuale Vmill
if ( nMoveType != 0 || ! NeedCollisionCheck()) {
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, ptNoseF, vtDirF, vtAuxF) ;
for ( int j = 0 ; j < int( m_VmId.size()) ; ++ j) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[j], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[j], i, m_VmTool[i].dTdOffs, m_VmTool[i].dAdOffs,
vPtNoseI[i], vVtDirI[i], vVtAuxI[i], vFrVzmI[j], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
}
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( ptNoseF, vtDirF, vtAuxF) ;
for ( int j = 0 ; j < int( m_VmId.size()) ; ++ j) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[j], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[j], ptNoseI, vtDirI, vtAuxI, vFrVzmI[j], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
}
}
}
@@ -1079,64 +1058,36 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
DBLVECTOR vDeltaVal( m_AxesName.size()) ;
// assi lineari
vtRot.Rotate( vtN, dDiffAng / nStep) ;
double dPrevVal, dVal ;
m_pMachine->GetAxisPos( m_AxesName[0], dPrevVal) ;
dVal = ptCen.x + vtRot.x + dCurrCoeff * dDeltaN * vtN.x ;
m_pMachine->SetAxisPos( m_AxesName[0], dVal) ;
vDeltaVal[0] = dVal - dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[1], dPrevVal) ;
dVal = ptCen.y + vtRot.y + dCurrCoeff * dDeltaN * vtN.y ;
m_pMachine->SetAxisPos( m_AxesName[1], dVal) ;
vDeltaVal[1] = dVal - dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[2], dPrevVal) ;
dVal = ptCen.z + vtRot.z + dCurrCoeff * dDeltaN * vtN.z ;
m_pMachine->SetAxisPos( m_AxesName[2], dVal) ;
vDeltaVal[2] = dVal - dPrevVal ;
m_pMachine->SetAxisPos( m_AxesName[0], ptCen.x + vtRot.x + dCurrCoeff * dDeltaN * vtN.x) ;
m_pMachine->SetAxisPos( m_AxesName[1], ptCen.y + vtRot.y + dCurrCoeff * dDeltaN * vtN.y) ;
m_pMachine->SetAxisPos( m_AxesName[2], ptCen.z + vtRot.z + dCurrCoeff * dDeltaN * vtN.z) ;
// assi rotanti
for ( int j = 3 ; j < int( m_AxesName.size()) ; ++ j) {
double dPrevVal ; m_pMachine->GetAxisPos( m_AxesName[j], dPrevVal) ;
double dVal = m_AxesVal[j] * ( 1 - dCurrCoeff) + AxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AxesName[j], dVal) ;
vDeltaVal[j] = dVal - dPrevVal ;
}
// eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = 0 ;
if ( m_AuxAxesLink[j] == 0) {
dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
}
else {
m_pMachine->GetAxisPos( m_AuxAxesName[j], dVal) ;
if ( m_AuxAxesLink[j] > 0)
dVal += vDeltaVal[m_AuxAxesLink[j] - 1] ;
else
dVal -= vDeltaVal[-m_AuxAxesLink[j] - 1] ;
}
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale Vmill
for ( int j = 0 ; j < int( m_VmTool.size()) ; ++ j) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[j].sHead, m_VmTool[j].nExit, ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], j, m_VmTool[j].dTdOffs, m_VmTool[j].dAdOffs,
vPtNoseI[j], vVtDirI[j], vVtAuxI[j], vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// se ultimo utensile, salvo riferimento per prossimo inizio
if ( j == int( m_VmTool.size()) - 1)
vFrVzmI[k] = frVzmF ;
}
// aggiorno prossimo inizio
vPtNoseI[j] = ptNoseF ;
vVtDirI[j] = vtDirF ;
vVtAuxI[j] = vtAuxF ;
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], ptNoseI, vtDirI, vtAuxI, vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// salvo riferimento per prossimo inizio
vFrVzmI[k] = frVzmF ;
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
// aggiorno prossimo inizio
ptNoseI = ptNoseF ;
vtDirI = vtDirF ;
}
}
}
@@ -1164,19 +1115,16 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
dMove = ( m_dCoeff - dPrevCoeff) * dDist ;
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck())
nStep = max( int( dMove / COLL_STEP), 1) ;
if ( NeedCollisionCheck()) {
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
// muovo eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
if ( m_AuxAxesLink[j] == 0) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
else {
}
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
@@ -1225,9 +1173,9 @@ Simulator::CalcStatusOnError( int nErr)
{
if ( Stopped())
return MCH_SIM_STOP ;
else if ( nErr == ERR_OUTSTROKE)
else if ( nErr == 1)
return MCH_SIM_OUTSTROKE ;
else if ( nErr == ERR_COLLISION)
else if ( nErr == 11)
return MCH_SIM_COLLISION ;
else
return MCH_SIM_ERR ;
@@ -1235,33 +1183,30 @@ Simulator::CalcStatusOnError( int nErr)
//----------------------------------------------------------------------------
bool
Simulator::GetHeadCurrPosDirAux( const std::string& sHead, int nExit, Point3d& ptH, Vector3d& vtH, Vector3d& vtA)
Simulator::GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA)
{
int nHeadId = m_pMachine->GetHeadId( sHead) ;
int nExitId = m_pMachine->GetExitId( sHead, nExit) ;
if ( nHeadId == GDB_ID_NULL || nExitId == GDB_ID_NULL)
// ci devono essere almeno i tre assi lineari
if ( m_AxesName.size() < 3)
return false ;
Frame3d frExit ; m_pGeomDB->GetGroupGlobFrame( nExitId, frExit) ;
ptH = frExit.Orig() ;
vtH = frExit.VersZ() ;
vtA = V_NULL ;
int nDirAuxId = m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_AUX_VECT) ;
if ( nDirAuxId != GDB_ID_NULL) {
const IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nDirAuxId)) ;
if ( pGV != nullptr) {
Frame3d frHead ; m_pGeomDB->GetGroupGlobFrame( nHeadId, frHead) ;
vtA = pGV->GetVector() ;
vtA.ToGlob( frHead) ;
}
}
// recupero le posizioni degli assi lineari
DBLVECTOR vLinAx( 3) ;
for ( size_t i = 0 ; i < 3 ; ++ i)
m_pMachine->GetAxisPos( m_AxesName[i], vLinAx[i]) ;
// recupero le posizioni degli eventuali assi rotanti
DBLVECTOR vRotAx( m_AxesName.size() - 3) ;
for ( size_t i = 3 ; i < m_AxesName.size() ; ++ i)
m_pMachine->GetAxisPos( m_AxesName[i], vRotAx[i-3]) ;
// determino posizione e orientamento della testa
m_pMachine->GetNoseFromPositions( vLinAx[0], vLinAx[1], vLinAx[2], vRotAx, ptH) ;
m_pMachine->GetToolDirFromAngles( vRotAx, vtH) ;
m_pMachine->GetAuxDirFromAngles( vRotAx, vtA) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVmAdOffs,
const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI,
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF)
Simulator::ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI,
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF)
{
// Recupero Zmap
IVolZmap* pVZM = GetVolZmap( m_pGeomDB->GetGeoObj( nVmId)) ;
@@ -1275,17 +1220,16 @@ Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVm
Vector3d vtHfL = vtHf ; vtHfL.ToLoc( frVzmF) ;
Vector3d vtAfL = vtAf ; vtAfL.ToLoc( frVzmF) ;
// Eventuali offset
ptHiL += dVmTdOffs * vtHiL + dVmAdOffs * vtAiL ;
ptHfL += dVmTdOffs * vtHfL + dVmAdOffs * vtAfL ;
ptHiL += m_dVmTdOffs * vtHiL + m_dVmAdOffs * vtAiL ;
ptHfL += m_dVmTdOffs * vtHfL + m_dVmAdOffs * vtAfL ;
// Log per debug
if ( ExeGetDebugLevel() >= 10) {
string sOut = "Zmap=" + ToString( nVmId) + " CurrTool=" + ToString( nCurrTool) +
"Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
string sOut = "Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
") Pf=(" + ToString( ptHfL) + ") Vf=(" + ToString( vtHfL) + ") Af=(" + ToString( vtAfL) + ")" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
}
// Eseguo
return pVZM->MillingStep( nCurrTool, ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
return pVZM->MillingStep( ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
}
//----------------------------------------------------------------------------
@@ -1319,8 +1263,8 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
// verifico se è l'utensile attivo
string sHead ; m_pGeomDB->GetName( m_pGeomDB->GetParentId( m_CollObj[j].nFrameId), sHead) ;
string sExit ; m_pGeomDB->GetName( m_CollObj[j].nFrameId, sExit) ;
bool bIsTool = m_CollObj[j].bToolOn ||
( sHead == m_sHead && ( sExit == "_T" + ToString( m_nExit) || sExit == "_TT" + ToString( m_nExit))) ;
bool bIsTool = ( sHead == m_sHead &&
( sExit == string( "_T") + ToString( m_nExit) || sExit == string( "_TT") + ToString( m_nExit))) ;
// se utensile attivo su grezzo in lavoro e non è rapido, salto
if ( bIsTool && bIsRaw && nMoveType != 0)
continue ;
@@ -1512,9 +1456,8 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_SELECT) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
// recupero dati per verifica collisione
// recupero distanza di sicurezza per verifica collisione
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_SAFEDIST, m_dSafeDist) ;
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_CODET, m_CdId) ;
// verifico codice di errore
bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// recupero i dati di ritorno per assi ausiliari
@@ -1525,17 +1468,15 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
m_AuxAxesName.reserve( nNumAuxAxes) ;
m_AuxAxesToken.reserve( nNumAuxAxes) ;
m_AuxAxesInvert.reserve( nNumAuxAxes) ;
m_AuxAxesOffset.reserve( nNumAuxAxes) ;
m_AuxAxesLinear.reserve( nNumAuxAxes) ;
m_AuxAxesVal.reserve( nNumAuxAxes) ;
m_AuxAxesEnd.reserve( nNumAuxAxes) ;
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
string sName ; string sToken ; bool bInvert ; double dOffset ; bool bLinear ; double dVal ;
string sName ; string sToken ; bool bInvert ; bool bLinear ; double dVal ;
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
m_pMachine->GetAxisToken( sName, sToken) &&
m_pMachine->GetAxisInvert( sName, bInvert) &&
m_pMachine->GetAxisOffset( sName, dOffset) &&
m_pMachine->GetAxisType( sName, bLinear) &&
m_pMachine->GetAxisPos( sName, dVal)) {
// se non è già negli assi principali, lo aggiungo
@@ -1543,11 +1484,9 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesOffset.push_back( dOffset) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dVal) ;
m_AuxAxesLink.emplace_back( 0) ;
}
}
else
@@ -1730,7 +1669,6 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, m_nEntId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, m_nEntInd) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, pCamData->GetMoveType()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MASK, pCamData->GetAxesMask()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, pCamData->GetFlag()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, pCamData->GetFlag2()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, pCamData->GetIndex()) ;
@@ -1782,7 +1720,6 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
ResetAuxAxes() ;
// recupero i dati di ritorno
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_MASK, m_nAxesMask) ;
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ENABAXES, m_bEnabAxes))
m_bEnabAxes = true ;
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_SHOWAXES, m_bShowAxes))
@@ -1793,63 +1730,32 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
m_AuxAxesName.reserve( nNumAuxAxes) ;
m_AuxAxesToken.reserve( nNumAuxAxes) ;
m_AuxAxesInvert.reserve( nNumAuxAxes) ;
m_AuxAxesOffset.reserve( nNumAuxAxes) ;
m_AuxAxesLinear.reserve( nNumAuxAxes) ;
m_AuxAxesVal.reserve( nNumAuxAxes) ;
m_AuxAxesEnd.reserve( nNumAuxAxes) ;
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
string sName ; string sToken ; bool bInvert ; double dOffset ; bool bLinear ; double dVal ; double dEnd ; string sLink ;
string sName ; string sToken ; bool bInvert ; bool bLinear ; double dVal ; double dEnd ;
string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ;
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
string sAuxAxMaster = GLOB_VAR + GVAR_ANM ; ReplaceString( sAuxAxMaster, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
m_pMachine->GetAxisToken( sName, sToken) &&
m_pMachine->GetAxisInvert( sName, bInvert) &&
m_pMachine->GetAxisOffset( sName, dOffset) &&
m_pMachine->GetAxisType( sName, bLinear) &&
m_pMachine->GetAxisPos( sName, dVal)) {
// se assi principali abilitati e da agganciare ad asse principale
if ( m_bEnabAxes && m_pMachine->LuaGetGlobVar( sAuxAxMaster, sLink)) {
bool bNeg = ( sLink.find( '-') != string::npos) ;
string sMainAxis = sLink ; ReplaceString( sMainAxis, "-", "") ;
int nInd = 0 ;
for ( int i = 0 ; nInd == 0 && i < int( m_AxesName.size()) ; ++ i) {
if ( m_AxesName[i] == sMainAxis)
nInd = i + 1 ;
}
// se trovato asse principale di riferimento
if ( nInd > 0) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesOffset.push_back( dOffset) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( 0) ;
m_AuxAxesEnd.emplace_back( 0) ;
m_AuxAxesLink.emplace_back( ( bNeg ? -nInd : nInd)) ;
m_pMachine->GetAxisPos( sName, dVal) &&
m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
// se assi principali disabilitati o non è tra questi, lo aggiungo
if ( ! m_bEnabAxes || find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dEnd) ;
if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) {
nErr = 1 ;
bOk = false ;
}
}
// se altrimenti specificato valore finale del movimento
else if ( m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
// se assi principali disabilitati o non è tra questi, lo aggiungo
if ( ! m_bEnabAxes || find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesOffset.push_back( dOffset) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dEnd) ;
m_AuxAxesLink.emplace_back( 0) ;
if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) {
nErr = 1 ;
bOk = false ;
}
}
}
// altrimenti errore
else
bOk = false ;
}
else
bOk = false ;
@@ -1902,10 +1808,8 @@ Simulator::OnCollision( int nCdInd, int nObjInd, int& nErr)
// verifico codice di errore
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// l'errore standard di collisione è stato portato da 1 a 11 per non collidere con altri tipi di errori
if ( nErr == 1) {
nErr = ERR_COLLISION ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
}
if ( nErr == 1)
nErr = 11 ;
return ( nErr == 0) ;
}
@@ -1922,7 +1826,7 @@ Simulator::OnResetMachine( void)
//----------------------------------------------------------------------------
bool
Simulator::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
{
// verifiche sui parametri
if ( nInd <= 0 || nFrameId <= GDB_ID_NULL)
@@ -1948,237 +1852,6 @@ Simulator::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, con
return false ;
}
// aggiungo al vettore
m_CollObj.emplace_back( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::SetToolForVmill( const string& sTool, const string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst)
{
// disabilito eventuale registrazione comandi EXE (riabilitazione automatica)
CmdLogOff cmdLogOff ;
// se vVmill vuoto, esco
if ( vVmill.empty())
return true ;
// se utensile, testa o uscita non definiti, reset ed esco
if ( IsEmptyOrSpaces( sTool) || IsEmptyOrSpaces( sHead) || nExit < 1) {
ExeVolZmapResetTools( vVmill) ;
return false ;
}
// imposto utensile come corrente
string sOldTool ; m_pMchMgr->TdbGetCurrToolParam( TPA_NAME, sOldTool) ;
if ( sTool != sOldTool && ! m_pMchMgr->TdbSetCurrTool( sTool)) {
ExeVolZmapResetTools( vVmill) ;
return false ;
}
// recupero dati utensile
int nFlag = 1 ;
int nType ; m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, nType) ;
double dLen ; m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
double dDiam ; m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dDiam) ;
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
double dCornR ; m_pMchMgr->TdbGetCurrToolParam( TPA_CORNRAD, dCornR) ;
double dSideAng ; m_pMchMgr->TdbGetCurrToolParam( TPA_SIDEANG, dSideAng) ;
double dMaxMat ; m_pMchMgr->TdbGetCurrToolParam( TPA_MAXMAT, dMaxMat) ;
// ricerca dell'outline e del diametro gambo
int nExitId = m_pMachine->GetExitId( sHead, nExit) ;
int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ;
int nOutlineId = m_pGeomDB->GetFirstNameInGroup( nToolId, "Outline") ;
double dMaxStemDiam = dDiam ; m_pGeomDB->GetInfo( nToolId, "D_STEM", dMaxStemDiam) ;
// imposto profilo utensile per Vmill
if ( nOutlineId != GDB_ID_NULL)
ExeVolZmapSetGenTool( vVmill, sTool, nOutlineId, nFlag, bFirst) ;
else if ( nType == TT_MORTISE_STD)
ExeVolZmapSetMortiserTool( vVmill, sTool, dLen, dDiam, dThick, dCornR, nFlag, bFirst) ;
else if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT)
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dThick, 0, dCornR, nFlag, bFirst) ;
else if ( nType == TT_WATERJET)
ExeVolZmapSetStdTool( vVmill, sTool, dLen + 50, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else if ( abs( dSideAng) < EPS_ANG_SMALL || abs( dThick) < EPS_SMALL) {
if ( dDiam <= dMaxStemDiam)
ExeVolZmapSetStdTool( vVmill, sTool, dLen, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dMaxMat, 0, dCornR, nFlag, bFirst) ;
}
else {
bool bExtra = ( dThick > 0) ;
double dTipLen = abs( dThick) ;
double dTotLen = ( bExtra ? dLen + dTipLen : dLen) ;
double dDelta ;
if ( dSideAng > 0) {
if ( dCornR < EPS_SMALL)
dDelta = 2 * dTipLen * tan( dSideAng * DEGTORAD) ;
else
dDelta = 2 * ( dCornR * cos( dSideAng * DEGTORAD) + ( dTipLen - dCornR + dCornR * sin( dSideAng * DEGTORAD)) * tan( dSideAng * DEGTORAD)) ;
}
else
dDelta = 2 * tan( dSideAng * DEGTORAD) * dTipLen ;
double dStemDiam = ( bExtra ? dDiam : dDiam + dDelta) ;
double dTipDiam = ( bExtra ? dDiam - dDelta : dDiam) ;
ExeVolZmapSetAdvTool( vVmill, sTool, dTotLen, dStemDiam, dTipLen, dTipDiam, dCornR, dMaxMat, nFlag, bFirst) ;
}
// eventuali offset per Vmill (per adattare lo ZeroT macchina con quello di Zmap)
double dVmTdOffs = 0 ;
double dVmAdOffs = 0 ;
if ( nType == TT_MORTISE_STD) {
dVmTdOffs = 0 ;
dVmAdOffs = 0.5 * dThick ;
}
else if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT) {
dVmTdOffs = ( ( dLen <= dThick) ? -dLen + dThick : 0) ;
dVmAdOffs = 0 ;
}
// inserisco in lista utensili per virtual milling
if ( bFirst) {
m_VmTool.resize( 1) ;
m_VmTool[0] = VmTool( sTool, sHead, nExit, dVmTdOffs, dVmAdOffs) ;
}
else
m_VmTool.emplace_back( sTool, sHead, nExit, dVmTdOffs, dVmAdOffs) ;
// ripristino eventuale diverso utensile corrente
if ( sTool != sOldTool)
m_pMchMgr->TdbSetCurrTool( sOldTool) ;
return true ;
}
//----------------------------------------------------------------------------
int
Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// Salvo lo step di simulazione corrente
double dOrigStep = m_dStep ;
// Verifico ci siano assi da muovere
if ( vAxNaEpSt.empty())
return SIM_AXMV_RES_ERR ;
// Numero assi da muovere
int nAxCount = int( vAxNaEpSt.size()) ;
// Posizioni iniziali
DBLVECTOR vPrev( nAxCount) ;
for ( int i = 0 ; i < nAxCount ; ++ i) {
if ( ! m_pMchMgr->GetAxisPos( vAxNaEpSt[i].sName, vPrev[i]))
return SIM_AXMV_RES_ERR ;
}
// Posizione e direzione attuali degli utensili e riferimenti dei pezzi (per Vmill)
bool bExecVmill = (( nMoveType != 0 || ! NeedCollisionCheck()) && ! m_VmTool.empty() && ! m_VmId.empty()) ;
PNTVECTOR vPtNoseI ;
VCT3DVECTOR vVtDirI ;
VCT3DVECTOR vVtAuxI ;
vector<Frame3d> vFrVzmI ;
if ( bExecVmill) {
vPtNoseI.resize( m_VmTool.size()) ;
vVtDirI.resize( m_VmTool.size()) ;
vVtAuxI.resize( m_VmTool.size()) ;
vFrVzmI.resize( m_VmId.size()) ;
bool bOkI = true ;
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i)
bOkI = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, vPtNoseI[i], vVtDirI[i], vVtAuxI[i]) && bOkI ;
for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i)
bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ;
}
// Determino gli step di movimento
static const int STEP_FEED = -1 ;
static const int STEP_RAPID = -2 ;
static const int STEP_RAPROT = -3 ;
static const int STEP_COLLROT = -4 ;
int nStep = 1 ;
for ( int i = 0 ; i < nAxCount ; ++ i) {
double dMove = abs( vAxNaEpSt[i].dEndPos - vPrev[i]) ;
double dStep = vAxNaEpSt[i].dStep ;
if ( dStep < 0) {
if ( abs( dStep - STEP_FEED) < EPS_SMALL)
dStep = m_dStep ;
else if ( abs( dStep - STEP_RAPID) < EPS_SMALL)
dStep = 4 * m_dStep ;
else if ( abs( dStep - STEP_RAPROT) < EPS_SMALL)
dStep = 0.4 * m_dStep ;
else // STEP_COLLROT
dStep = min( 0.4 * m_dStep, 10.) ;
}
dStep = max( dStep, 1.) ;
int nAxStep = int( dMove / dStep) + 1 ;
nStep = max( nStep, nAxStep) ;
}
// Eseguo il movimento
for ( int i = 1 ; i <= nStep ; ++ i) {
// Muovo
bool bMoveOk = true ;
double dCoeff = double( i) / nStep ;
for ( int j = 0 ; j < nAxCount ; ++ j) {
bMoveOk = m_pMchMgr->SetAxisPos( vAxNaEpSt[j].sName, ( 1 - dCoeff) * vPrev[j] + dCoeff * vAxNaEpSt[j].dEndPos) && bMoveOk ;
}
// Eseguo eventuale Vmill
if ( bExecVmill) {
for ( int j = 0 ; j < int( m_VmTool.size()) ; ++ j) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[j].sHead, m_VmTool[j].nExit, ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], j, m_VmTool[j].dTdOffs, m_VmTool[j].dAdOffs,
vPtNoseI[j], vVtDirI[j], vVtAuxI[j], vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// se ultimo utensile, salvo riferimento per prossimo inizio
if ( j == int( m_VmTool.size()) - 1)
vFrVzmI[k] = frVzmF ;
}
// aggiorno prossimo inizio
vPtNoseI[j] = ptNoseF ;
vVtDirI[j] = vtDirF ;
vVtAuxI[j] = vtAuxF ;
}
}
// Aggiorno visualizzazione
ExeDraw() ;
// Verifico collisioni
int nCdInd, nObjInd ;
bool bCollCheck = ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
if ( ! bCollCheck) {
// Richiamo funzione di convalida collisione
int nPrevErr ;
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nPrevErr) ;
int nErr ;
if ( ! OnCollision( nCdInd, nObjInd, nErr) && nErr == ERR_COLLISION) {
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
if ( ExeGetEnableUI()) {
// Box di messaggio : Collisione! AVVERTIMENTO
ExeMessageBox( ExeGetMsg( 5319), ExeGetMsg( 5315), MB_OK | MB_ICONWARNING) ;
// Gestione Pausa
m_nUiStatus = MCH_UISIM_PAUSE ;
while ( m_nUiStatus == MCH_UISIM_PAUSE) {
// -11 notifica al simulatore pausa dopo collisione
ExeProcessEvents( -11, 4) ;
}
}
}
else {
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nPrevErr) ;
}
}
// In caso di errore esco
if ( ! bMoveOk)
return SIM_AXMV_RES_ERR ;
// Gestione aggiornamenti...
if ( ExeGetEnableUI()) {
// Aggiornamento interfaccia
ExeProcessEvents( 0, 4) ;
while ( m_nUiStatus == MCH_UISIM_PAUSE) {
ExeProcessEvents( 0, 4) ;
}
// Gestione Stop
if ( m_nUiStatus == MCH_UISIM_STOP)
return SIM_AXMV_RES_STOP ;
// Se cambia lo step di simulazione in modo significativo ...
if ( abs( m_dStep - dOrigStep) > 10 || abs( ( m_dStep - dOrigStep) / ( m_dStep + dOrigStep)) > 0.2) {
double dRat = m_dStep / dOrigStep ;
for ( int j = 0 ; j < nAxCount ; ++ j) {
if ( vAxNaEpSt[j].dStep > 0)
const_cast<double&>( vAxNaEpSt[j].dStep) *= dRat ;
}
return MoveAxes( nMoveType, vAxNaEpSt) ;
}
}
}
return SIM_AXMV_RES_OK ;
}
+13 -48
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2023
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : Simulator.h Data : 16.01.23 Versione : 2.5a2
// File : Simulator.h Data : 19.10.15 Versione : 1.6j2
// Contenuto : Dichiarazione della classe Simulator.
//
//
@@ -21,22 +21,6 @@ class IGeomDB ;
class Machine ;
class PerformanceCounter ;
//------------------------ Struttura per movimento esterno assi --------------
struct SimAxMv
{
std::string sName ;
double dEndPos ;
double dStep ;
SimAxMv( void) : dEndPos( 0), dStep( 0) { }
SimAxMv( std::string sN, double dE, double dS) : sName( sN), dEndPos( dE), dStep( dS) {}
} ;
typedef std::vector<SimAxMv> SAMVECTOR ;
//------------------------ Risultato movimento esterno assi -------------------
enum SimAxMvRes { SIM_AXMV_RES_STOP = -1,
SIM_AXMV_RES_ERR = 0,
SIM_AXMV_RES_OK = 1} ;
//----------------------------------------------------------------------------
class Simulator
{
@@ -53,11 +37,9 @@ class Simulator
bool GetToolInfo( std::string& sName, double& dSpeed) const ;
bool GetOperationInfo( std::string& sName, int& nType) const ;
bool GetMoveInfo( int& nGmove, double& dFeed) const ;
bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ;
bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ;
bool OnCollision( int nCdInd, int nObjInd, int& nErr) ;
bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
int MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ;
private :
bool UpdateTool( bool bFirst, int& nErr) ;
@@ -78,10 +60,9 @@ class Simulator
bool ManageMove( int& nStatus) ;
bool ManageSingleMove( int& nStatus, double& dMove) ;
int CalcStatusOnError( int nErr) ;
bool GetHeadCurrPosDirAux( const std::string& sHead, int nExit, Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ;
bool ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVmAdOffs,
const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI,
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ;
bool GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ;
bool ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI,
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ;
bool NeedCollisionCheck( void) const
{ return ( ! m_CollObj.empty() && ! m_CdId.empty()) ; }
bool Stopped( void)
@@ -111,30 +92,17 @@ class Simulator
private :
struct CollObj {
int nInd ;
bool bToolOn ;
int nFrameId ;
int nType ;
Vector3d vtMove ;
double dPar1 ;
double dPar2 ;
double dPar3 ;
CollObj( void) : nInd( 0), bToolOn( false), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {}
CollObj( int nI, bool bTOn, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3)
: nInd( nI), bToolOn( bTOn), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {}
CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {}
CollObj( int nI, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3)
: nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {}
} ;
typedef std::vector<CollObj> COBVECTOR ;
struct VmTool
{
std::string sName ;
std::string sHead ;
int nExit ;
double dTdOffs ;
double dAdOffs ;
VmTool( void) : nExit( 0), dTdOffs( 0), dAdOffs( 0) {}
VmTool( std::string sN, std::string sH, int nE, double dT, double dA)
: sName( sN), sHead( sH), nExit( nE), dTdOffs( dT), dAdOffs( dA) {}
} ;
typedef std::vector<VmTool> VMTVECTOR ;
typedef std::vector< CollObj> COBVECTOR ;
private :
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
@@ -160,24 +128,21 @@ class Simulator
double m_dTDiam ; // diametro dell'utensile corrente
INTVECTOR m_VmId ; // vettore identificativi Zmap per Virtual Milling
INTVECTOR m_CdId ; // vettore identificativi Zmap per Collision Detection
VMTVECTOR m_VmTool ; // vettore utensili attivi per virtual milling
double m_dVmTdOffs ; // offset utensile in direzione principale per VM
double m_dVmAdOffs ; // offset utensile in direzione ausiliaria per VM
COBVECTOR m_CollObj ; // vettore oggetti da testare per collisione con grezzo
double m_dSafeDist ; // distanza di sicurezza per verifica collisioni
int m_nAxesMask ; // maschera a bit di abilitazione movimento assi (solo se rapido)
bool m_bEnabAxes ; // flag abilitazione movimento assi attivi
bool m_bShowAxes ; // flag visualizzazione assi attivi
STRVECTOR m_AxesName ; // nomi degli assi macchina attivi
STRVECTOR m_AxesToken ; // token degli assi macchina attivi
BOOLVECTOR m_AxesInvert ; // flag di asse con verso invertito degli assi macchina attivi
DBLVECTOR m_AxesOffset ; // valore di offset delgli assi macchina ttivi
BOOLVECTOR m_AxesInvert ; // flag di asse con verso invertito
BOOLVECTOR m_AxesLinear ; // flag di lineare degli assi macchina attivi
DBLVECTOR m_AxesVal ; // valori degli assi macchina all'inizio del movimento corrente
STRVECTOR m_AuxAxesName ; // nomi degli assi macchina ausiliari abilitati
STRVECTOR m_AuxAxesToken ; // token degli assi macchina ausiliari abilitati
BOOLVECTOR m_AuxAxesInvert ; // flag di asse con verso invertito degli assi macchina ausiliari abilitati
DBLVECTOR m_AuxAxesOffset ; // valore di offset degli assi macchina ausiliari abilitati
BOOLVECTOR m_AuxAxesLinear ; // flag di lineare degli assi macchina ausiliari abilitati
DBLVECTOR m_AuxAxesVal ; // valori degli assi macchina ausiliari all'inizio del movimento corrente
DBLVECTOR m_AuxAxesEnd ; // valori degli assi macchina ausiliari alla fine del movimento corrente
INTVECTOR m_AuxAxesLink ; // indice + 1 asse principale di aggancio (negativo valore opposto, 0 nessuno)
} ;
+2 -16
View File
@@ -24,8 +24,8 @@
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkChainCurves.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EGkOffsetCurveOnX.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EgkOffsetCurveOnX.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EGkCAvToolSurfTm.h"
@@ -88,9 +88,6 @@ SurfFinishing::Clone( void) const
pSrF->m_nPhase = m_nPhase ;
pSrF->m_Params = m_Params ;
pSrF->m_TParams = m_TParams ;
pSrF->m_dTHoldBase = m_dTHoldBase ;
pSrF->m_dTHoldLen = m_dTHoldLen ;
pSrF->m_dTHoldDiam = m_dTHoldDiam ;
pSrF->m_nStatus = m_nStatus ;
pSrF->m_nPaths = m_nPaths ;
}
@@ -204,7 +201,6 @@ SurfFinishing::SurfFinishing( void)
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
m_TParams.m_sHead = "*" ;
m_dTHoldBase = 0 ;
m_dTHoldLen = 0 ;
m_dTHoldDiam = 0 ;
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -501,14 +497,8 @@ SurfFinishing::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nPaths = nCurrPaths ;
LOG_DBG_INFO( GetEMkLogger(), "SurfFinishing apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -538,8 +528,6 @@ SurfFinishing::Apply( bool bRecalc, bool bPostApply)
}
// recupero i dati del portautensile
int nToolId = m_pMchMgr->GetCalcTool() ;
m_dTHoldBase = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_BASE, m_dTHoldBase) ;
m_dTHoldLen = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_LEN, m_dTHoldLen) ;
m_dTHoldDiam = 0 ;
@@ -587,8 +575,6 @@ SurfFinishing::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "SurfFinishing apply done") ;
return true ;
}
-1
View File
@@ -113,7 +113,6 @@ class SurfFinishing : public Machining
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
SurfFinishingData m_Params ; // parametri lavorazione
ToolData m_TParams ; // parametri utensile
double m_dTHoldBase ; // posizione base del porta-utensile
double m_dTHoldLen ; // lunghezza del porta-utensile
double m_dTHoldDiam ; // diametro del porta-utensile
int m_nStatus ; // stato di aggiornamento della lavorazione
+62 -98
View File
@@ -112,19 +112,7 @@ ToolsMgr::Reload( void)
// ciclo di lettura degli utensili
do {
ToolData tData ;
if ( LoadOneTool( TheScanner, nToolSize, tData, bEnd)) {
if ( ! tData.m_sName.empty()) {
// salvo i dati dell'utensile
if ( ! m_utData.emplace( tData.m_Uuid, tData).second ||
! m_suData.emplace( tData.m_sName, tData.m_Uuid).second) {
bOk = false ;
string sOut = "ReloadTools : Error adding tool " + tData.m_sName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
}
}
}
else {
if ( ! LoadOneTool( TheScanner, nToolSize, bEnd)) {
bOk = false ;
string sOut = "ReloadTools : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
@@ -145,7 +133,7 @@ ToolsMgr::Reload( void)
//----------------------------------------------------------------------------
bool
ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd) const
ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd)
{
// leggo la prossima linea
string sLine ;
@@ -188,12 +176,12 @@ ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& n
//----------------------------------------------------------------------------
bool
ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, ToolData& tData, bool& bEnd) const
ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, bool& bEnd)
{
ToolData tData ;
// leggo la prossima linea
string sLine ;
if ( ! TheScanner.GetLine( sLine)) {
tData.m_sName = "" ;
// fine file
bEnd = true ;
return true ;
@@ -225,6 +213,9 @@ ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, ToolData& tData, bool
}
// verifico di aver letto tutti i campi
bOk = bOk && ( Flag.count() == nToolSize) ;
// salvo i dati dell'utensile
bOk = bOk && m_utData.emplace( tData.m_Uuid, tData).second ;
bOk = bOk && m_suData.emplace( tData.m_sName, tData.m_Uuid).second ;
return bOk ;
}
@@ -561,13 +552,12 @@ ToolsMgr::SaveCurrTool( void)
//----------------------------------------------------------------------------
bool
ToolsMgr::UpdateCurrToolHolderData( double dTHoldBase, double dTHoldLen, double dTHoldDiam)
ToolsMgr::UpdateCurrToolHolderData( double dTHoldLen, double dTHoldDiam)
{
// verifico validità utensile corrente
if ( ! m_bCurrTool)
return false ;
// Aggiorno i dati nelle note di sistema
SetValInNotes( TSI_THBASE, dTHoldBase, m_tdCurrTool.m_sSysNotes) ;
SetValInNotes( TSI_THLEN, dTHoldLen, m_tdCurrTool.m_sSysNotes) ;
SetValInNotes( TSI_THDIAM, dTHoldDiam, m_tdCurrTool.m_sSysNotes) ;
return true ;
@@ -680,26 +670,17 @@ ToolsMgr::GetCurrToolMaxDepth( double dSafe, double& dMaxDepth) const
// se fresa
else if ( ( m_tdCurrTool.m_nType & TF_MILL) != 0) {
// recupero le dimensioni del porta utensili
double dTHoldBase = 0 ;
double dTHoldLen = 0 ;
double dTHoldDiam = 0 ;
bool bBaseOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
bool bLenOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
bool bDiamOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
if ( ! bBaseOk || ! bLenOk || ! bDiamOk) {
(const_cast<ToolsMgr*>(this))->UpdateCurrToolHolderData( dTHoldBase, dTHoldLen, dTHoldDiam) ;
if ( ! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ||
! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam)) {
(const_cast<ToolsMgr*>(this))->SaveCurrTool() ;
Save() ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
}
// calcolo il massimo affondamento
dMaxDepth = m_tdCurrTool.m_dLen - dSafe ;
if ( m_tdCurrTool.m_dDiam > dTHoldDiam)
dMaxDepth -= dTHoldBase ;
else
dMaxDepth -= dTHoldLen ;
dMaxDepth = m_tdCurrTool.m_dLen - ( m_tdCurrTool.m_dDiam > dTHoldDiam ? 0 : dTHoldLen) - dSafe ;
return true ;
}
// se mortasatrice o sega a catena
@@ -740,17 +721,12 @@ ToolsMgr::GetCurrToolThDiam( double& dThDiam) const
( m_tdCurrTool.m_nType & TF_MILL) != 0 ||
( m_tdCurrTool.m_nType & TF_CHISEL) != 0) {
// recupero le dimensioni del porta utensili
double dTHoldBase = 0 ;
double dTHoldLen = 0 ;
double dTHoldDiam = 0 ;
bool bBaseOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
bool bLenOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
bool bDiamOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
if ( ! bBaseOk || ! bLenOk || ! bDiamOk) {
(const_cast<ToolsMgr*>(this))->UpdateCurrToolHolderData( dTHoldBase, dTHoldLen, dTHoldDiam) ;
if ( ! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ||
! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam)) {
(const_cast<ToolsMgr*>(this))->SaveCurrTool() ;
Save() ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
}
@@ -781,17 +757,12 @@ ToolsMgr::GetCurrToolThLength( double& dThLen) const
( m_tdCurrTool.m_nType & TF_MILL) != 0 ||
( m_tdCurrTool.m_nType & TF_CHISEL) != 0) {
// recupero le dimensioni del porta utensili
double dTHoldBase = 0 ;
double dTHoldLen = 0 ;
double dTHoldDiam = 0 ;
bool bBaseOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
bool bLenOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
bool bDiamOk = GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
if ( ! bBaseOk || ! bLenOk || ! bDiamOk) {
(const_cast<ToolsMgr*>(this))->UpdateCurrToolHolderData( dTHoldBase, dTHoldLen, dTHoldDiam) ;
if ( ! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ||
! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam)) {
(const_cast<ToolsMgr*>(this))->SaveCurrTool() ;
Save() ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THBASE, dTHoldBase) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
}
@@ -810,7 +781,7 @@ ToolsMgr::GetCurrToolThLength( double& dThLen) const
//----------------------------------------------------------------------------
bool
ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bCompressed) const
ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bCompressed)
{
LOG_INFO( GetEMkLogger(), ( "Export Tools " + sOutFile).c_str()) ;
@@ -874,10 +845,10 @@ ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bC
//----------------------------------------------------------------------------
bool
ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounter, const string& sOutDir) const
ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, const int& nCounter, const string& sOutDir)
{
// se il tool non esiste nel DB lo ignoro
if ( m_suData.find( sToolName) == m_suData.end()) {
if ( m_suData.find( sToolName) == m_suData.end()){
string sOut = "Warning Export Tool : " + sToolName + " not found. Tool is ignored" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return true ;
@@ -885,7 +856,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounte
const ToolData * tData = GetTool( sToolName) ;
string sOut ;
if ( tData == nullptr) {
if ( tData == nullptr){
sOut = "Export Tools : Error exporting " + sToolName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
@@ -905,7 +876,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounte
bOk = ! sOut.empty() && TheWriter.OutText( sOut) ;
}
if ( ! bOk) {
if ( ! bOk){
sOut = "Export Tools : Error exporting " + sToolName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
// visto che non ho salvato correttamente il tool elimino il suo disegno
@@ -918,7 +889,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounte
//----------------------------------------------------------------------------
bool
ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes) const
ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes)
{
Scanner TheScanner ;
if ( ! TheScanner.Init( sFile, ";")) {
@@ -931,7 +902,7 @@ ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR&
int nToolSize = 0 ;
int nTotal = 0 ;
bool bEnd = false ;
if ( ! LoadHeader( TheScanner, nVersion, nToolSize, nTotal, bEnd)) {
if ( ! LoadHeader( TheScanner, nVersion, nToolSize, nTotal, bEnd)){
LOG_ERROR( GetEMkLogger(), "Tools ToBeImported : Error on Header") ;
}
@@ -980,7 +951,7 @@ ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR&
}
// aggiungo ultimo tool se ok
if ( bAdd && bToolType && bToolName) {
if ( bAdd && bToolType && bToolName) {
vsToolsNames.push_back( sName) ;
vToolsTypes.push_back( stoi( sType)) ;
}
@@ -1006,14 +977,14 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
return false ;
}
}
// Verifico che il nome non sia ripetuto nella lista dei vsToolsNames
// Verfico che il nome non sia ripetuto nella lista dei vsToolsNames
if ( i != vsToolsNames.size() - 1 && find( vsToolsNames.begin() + i + 1, vsToolsNames.end(), vsToolsNames[i]) != vsToolsNames.end()) {
LOG_ERROR( GetEMkLogger(), ( " Error : name \"" + vsToolsNames[i] + "\" is already used").c_str()) ;
return false ;
}
}
// File directory
// sFile directory
size_t pos = sFile.rfind( "\\") ;
if ( pos == string::npos)
return false ;
@@ -1038,7 +1009,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
// leggo i tool
string sLine ;
if ( ! TheScanner.GetLine( sLine))
if( ! TheScanner.GetLine( sLine))
return false ;
if ( sLine.front() != '[' || sLine.back() != ']')
return false ;
@@ -1052,7 +1023,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
vector<string>::const_iterator it = find( vsToolsToImport.begin(), vsToolsToImport.end(), tData.m_sName) ;
// Se il tool non deve essere importato proseguo con il successivo
if ( it == vsToolsToImport.end())
if ( it == vsToolsToImport.end())
continue ;
// Se errore nel leggere il tool, proseguo con il successivo
@@ -1105,7 +1076,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
//--------------------------------------------------------------------------
bool
ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, int nToolSize) const
ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, const int& nToolSize) const
{
string sLine ;
TheScanner.GetLine( sLine) ;
@@ -1142,56 +1113,49 @@ ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, int nToolSize) const
//----------------------------------------------------------------------------
bool
ToolsMgr::CopyToolDraw( const string& sDraw, const string& sOutDraw, const string& sToolName) const
ToolsMgr::CopyToolDraw( const string& sDraw, const string& sOutDraw, const string& sToolName)
{
// se il file del disegno esiste lo copio nella nuova cartella
if ( ExistsFile( sDraw)) {
if ( ExistsFile( sDraw)){
if ( ! CopyFileEgt( sDraw, sOutDraw)) {
string sOut = " Error in copying " + sToolName + " draw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
}
else {
// se il file non esiste e non è standard restituisco errore
if ( ! IsUUID( GetFileTitleEgt( sDraw))) {
string sOut = " Error : " + sToolName + " draw not found" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
return true ;
}
// se il file non esiste ma è standard lo ricreo
else {
int nGenCtx = ExeGetCurrentContext() ;
int nToolCtx = ExeInitContext() ;
// se il file non esiste e non è standard restituisco errore
if ( ! IsUUID( GetFileTitleEgt( sDraw))) {
string sOut = " Error : " + sToolName + " draw not found" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
bool bOk = SetCurrTool( sToolName) ; // setto il tool corrente per farne il disegno
if ( ! bOk){
string sOut = " Error in " + sToolName + " draw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
// altrimenti il file non esiste ma è standard lo ricreo
// recupero indice contesto corrente e creo nuovo contesto per disegno utensile
int nGenCtx = ExeGetCurrentContext() ;
int nToolCtx = ExeInitContext() ;
// salvo dati utensile corrente
bool bCurrToolOld = m_bCurrTool ;
ToolData tdCurrToolOld = m_tdCurrTool ;
// imposto utensile da esportare come corrente
bool bOk = true ;
if ( bOk && ! const_cast<ToolsMgr*>(this)->SetCurrTool( sToolName)) {
string sOut = " Error in " + sToolName + " draw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
bOk = false ;
if ( ExeTdbCurrToolDraw( nGenCtx, nToolCtx)) {
string sOut = " Error : " + sToolName + " CurrToolDraw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
if ( ! ExeSaveFile( sOutDraw, GDB_SV_CMPTXT)) {
string sOut = " Error : saving " + sToolName + " tool draw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
ExeSetCurrentContext( nGenCtx) ;
ExeDeleteContext( nToolCtx) ;
}
}
if ( bOk && ExeTdbCurrToolDraw( nGenCtx, nToolCtx) != 0) {
string sOut = " Error : " + sToolName + " CurrToolDraw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
bOk = false ;
}
if ( bOk && ! ExeSaveFile( sOutDraw, GDB_SV_CMPTXT)) {
string sOut = " Error : saving " + sToolName + " tool draw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
bOk = false ;
}
// ripristino utensile corrente
const_cast<ToolsMgr*>(this)->m_bCurrTool = bCurrToolOld ;
const_cast<ToolsMgr*>(this)->m_tdCurrTool = tdCurrToolOld ;
// ripristino contesto corrente e cancello quello creato ad hoc
ExeSetCurrentContext( nGenCtx) ;
ExeDeleteContext( nToolCtx) ;
return bOk ;
return true ;
}
+8 -8
View File
@@ -56,26 +56,26 @@ class ToolsMgr
bool GetCurrToolParam( int nType, double& dVal) const ;
bool GetCurrToolParam( int nType, std::string& sVal) const ;
template <class T> bool GetCurrToolValInNotes( int nType, const std::string& sKey, T& Val) const ;
bool UpdateCurrToolHolderData( double dTHoldBase, double dTHoldLen, double dTHoldDiam) ;
bool UpdateCurrToolHolderData( double dTHoldLen, double dTHoldDiam) ;
bool GetCurrToolMaxDepth( double dSafe, double& dMaxDepth) const ;
bool GetCurrToolThDiam( double& dThDiam) const ;
bool GetCurrToolThLength( double& dThLen) const ;
const ToolData* GetCurrTool(void) const
{ return (m_bCurrTool ? &m_tdCurrTool : nullptr) ; }
bool Export( const STRVECTOR& vsToolsNames, const std::string& sOutFile, bool bCompressed = true) const ;
bool ToBeImported( const std::string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes) const ;
bool Export( const STRVECTOR& vsToolsNames, const std::string& sOutFile, bool bCompressed = true) ;
bool ToBeImported( const std::string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes) ;
bool Import( const std::string& sFile, const STRVECTOR& vsToolsToImport, const STRVECTOR& vsToolsNames, STRVECTOR& vsImported) ;
private :
bool Clear( void) ;
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd) const ;
bool LoadOneTool( Scanner& TheScanner, int nToolSize, ToolData& tData, bool& bEnd) const ;
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd) ;
bool LoadOneTool( Scanner& TheScanner, int nToolSize, bool& bEnd) ;
bool SaveHeader( Writer& TheWriter) const ;
bool SaveOneTool( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
bool VerifyTool( int nFamily, std::string& sName, int& nType) const ;
bool ExportOneTool( const std::string& sToolName, Writer& TheWriter, int nCounter, const std::string& sOutDir) const ;
bool ReadTool( Scanner& TheScanner, ToolData& tData, int nToolSize) const ;
bool CopyToolDraw( const std::string& sDraw, const std::string& sOutDraw, const std::string& sToolName) const ;
bool ExportOneTool( const std::string& sToolName, Writer& TheWriter, const int& nCounter, const std::string& sOutDir) ;
bool ReadTool( Scanner& TheScanner, ToolData& tData, const int& nToolSize) const ;
bool CopyToolDraw( const std::string& sDraw, const std::string& sOutDraw, const std::string& sToolName) ;
private :
typedef std::unordered_map< EgtUUID, ToolData> UUIDTDATA_UMAP ;
+2 -146
View File
@@ -28,9 +28,7 @@
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -91,7 +89,6 @@ WaterJetting::Clone( void) const
pWJ->m_nPhase = m_nPhase ;
pWJ->m_Params = m_Params ;
pWJ->m_TParams = m_TParams ;
pWJ->m_dTHoldBase = m_dTHoldBase ;
pWJ->m_dTHoldLen = m_dTHoldLen ;
pWJ->m_dTHoldDiam = m_dTHoldDiam ;
pWJ->m_dElev = m_dElev ;
@@ -210,7 +207,6 @@ WaterJetting::WaterJetting( void)
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
m_TParams.m_sHead = "*" ;
m_dTHoldBase = 0 ;
m_dTHoldLen = 0 ;
m_dTHoldDiam = 0 ;
m_dElev = 0 ;
@@ -567,8 +563,6 @@ WaterJetting::Preview( bool bRecalc)
}
// recupero i dati del portautensile
int nToolId = m_pMchMgr->GetCalcTool() ;
m_dTHoldBase = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_BASE, m_dTHoldBase) ;
m_dTHoldLen = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_LEN, m_dTHoldLen) ;
m_dTHoldDiam = 0 ;
@@ -631,14 +625,8 @@ WaterJetting::Apply( bool bRecalc, bool bPostApply)
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && ! bToolChanged &&
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
// confermo i percorsi di lavorazione
m_nMills = nCurrMills ;
LOG_DBG_INFO( GetEMkLogger(), "Milling apply skipped : status already ok") ;
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
LOG_DBG_INFO( GetEMkLogger(), "Update done") ;
// esco con successo
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
@@ -668,8 +656,6 @@ WaterJetting::Apply( bool bRecalc, bool bPostApply)
}
// recupero i dati del portautensile
int nToolId = m_pMchMgr->GetCalcTool() ;
m_dTHoldBase = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_BASE, m_dTHoldBase) ;
m_dTHoldLen = 0 ;
m_pGeomDB->GetInfo( nToolId, TTH_LEN, m_dTHoldLen) ;
m_dTHoldDiam = 0 ;
@@ -721,8 +707,6 @@ WaterJetting::Apply( bool bRecalc, bool bPostApply)
// dichiaro successiva da aggiornare
UpdateFollowingOperationsStatus( MCH_ST_OTH_MODIF) ;
LOG_DBG_INFO( GetEMkLogger(), "WaterJetting apply done") ;
return true ;
}
@@ -1185,11 +1169,6 @@ WaterJetting::Chain( int nGrpDestId)
vInds.emplace_back( Id) ;
}
}
// verifico se sono necessarie sistemazioni per collegamenti (bridges)
if ( abs( m_Params.m_dSideAngle) < EPS_ANG_SMALL &&
m_pGeomDB->GetFirstNameInGroup( m_pMchMgr->GetCurrMachGroup(), MACH_BRIDGES_GROUP) != GDB_ID_NULL) {
AdjustCurvesForBridges( vpCrvs, vInds) ;
}
// preparo i dati per il concatenamento
bool bFirst = true ;
Point3d ptNear = ORIG ;
@@ -1276,108 +1255,6 @@ WaterJetting::Chain( int nGrpDestId)
return true ;
}
//----------------------------------------------------------------------------
bool
WaterJetting::AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds)
{
// Gruppo dei collegamenti
struct Bridge {
int nId ;
int nEnt1 ;
int nEnt2 ;
double dWidth ;
Point3d ptP1 ;
Point3d ptP2 ;
Bridge( int nI, int nE1, int nE2, double dW, const Point3d& ptQ1, const Point3d& ptQ2)
: nId( nI), nEnt1( nE1), nEnt2( nE2), dWidth( dW), ptP1( ptQ1), ptP2( ptQ2) {}
} ;
vector<Bridge> vBridges ;
int nBridGrpId = m_pGeomDB->GetFirstNameInGroup( m_pMchMgr->GetCurrMachGroup(), MACH_BRIDGES_GROUP) ;
int nBridgeId = m_pGeomDB->GetFirstInGroup( nBridGrpId) ;
while ( nBridgeId != GDB_ID_NULL) {
int nEnt1, nEnt2 ;
double dWidth ;
Point3d ptP1, ptP2 ;
if ( m_pGeomDB->GetInfo( nBridgeId, "EntStart", nEnt1) &&
m_pGeomDB->GetInfo( nBridgeId, "EntEnd", nEnt2) &&
m_pGeomDB->GetInfo( nBridgeId, "BridgeW", dWidth) &&
ExeStartPoint( nBridgeId, GDB_ID_ROOT, ptP1) &&
ExeEndPoint( nBridgeId, GDB_ID_ROOT, ptP2)) {
vBridges.emplace_back( nBridgeId, nEnt1, nEnt2, dWidth, ptP1, ptP2) ;
}
nBridgeId = m_pGeomDB->GetNext( nBridgeId) ;
}
// Verifico i collegamenti che interessano le geometrie della lavorazione
for ( int i = 0 ; i < int( vBridges.size()) ; ++ i) {
// cerco le due curve interessate dal collegamento
int nI1 = -1 ;
for ( int j = 0 ; j < int( vInds.size()) ; ++ j) {
if ( vInds[j].nId == vBridges[i].nEnt1) {
nI1 = j ;
break ;
}
}
int nI2 = -1 ;
for ( int j = 0 ; j < int( vInds.size()) ; ++ j) {
if ( vInds[j].nId == vBridges[i].nEnt2) {
nI2 = j ;
break ;
}
}
if ( nI1 == -1 || nI2 == -1)
continue ;
// calcolo e verifico la posizione dei punti di collegamento sulle due curve
double const DIST_MAX = 5 ;
double dDist1, dU1, dLenP1, dLen1 ; int nF1 ;
DistPointCurve distPC1( vBridges[i].ptP1, *vpCrvs[nI1]) ;
if ( ! distPC1.GetDist( dDist1) || dDist1 > DIST_MAX ||
! distPC1.GetParamAtMinDistPoint( 0, dU1, nF1) ||
! vpCrvs[nI1]->GetLengthAtParam( dU1, dLenP1) ||
! vpCrvs[nI1]->GetLength( dLen1) ||
dLenP1 < vBridges[i].dWidth + m_TParams.m_dDiam ||
( dLen1 - dLenP1) < vBridges[i].dWidth + m_TParams.m_dDiam)
continue ;
double dDist2, dU2, dLenP2, dLen2 ; int nF2 ;
DistPointCurve distPC2( vBridges[i].ptP2, *vpCrvs[nI2]) ;
if ( ! distPC2.GetDist( dDist2) || dDist2 > DIST_MAX ||
! distPC2.GetParamAtMinDistPoint( 0, dU2, nF2) ||
! vpCrvs[nI2]->GetLengthAtParam( dU2, dLenP2) ||
! vpCrvs[nI2]->GetLength( dLen2) ||
dLenP2 < vBridges[i].dWidth + m_TParams.m_dDiam ||
( dLen2 - dLenP2) < vBridges[i].dWidth + m_TParams.m_dDiam)
continue ;
// spezzo le curve nei punti del collegamento e creo i segmenti di collegamento
PtrOwner<ICurve> pCopy1( vpCrvs[nI1]->Clone()) ;
PtrOwner<ICurve> pCopy2( vpCrvs[nI2]->Clone()) ;
PtrOwner<ICurveLine> pLinkA( CreateCurveLine()) ;
PtrOwner<ICurveLine> pLinkB( CreateCurveLine()) ;
if ( IsNull( pCopy1) || IsNull( pCopy2) || IsNull( pLinkA) || IsNull( pLinkB))
continue ;
vpCrvs[nI1]->TrimEndAtLen( dLenP1 - vBridges[i].dWidth / 2) ;
pCopy1->TrimStartAtLen( dLenP1 + vBridges[i].dWidth / 2) ;
vpCrvs[nI2]->TrimEndAtLen( dLenP2 - vBridges[i].dWidth / 2) ;
pCopy2->TrimStartAtLen( dLenP2 + vBridges[i].dWidth / 2) ;
Point3d ptAs ; vpCrvs[nI1]->GetEndPoint( ptAs) ;
Point3d ptAe ; pCopy2->GetStartPoint( ptAe) ;
pLinkA->Set( ptAs, ptAe) ;
Point3d ptBs ; vpCrvs[nI2]->GetEndPoint( ptBs) ;
Point3d ptBe ; pCopy1->GetStartPoint( ptBe) ;
pLinkB->Set( ptBs, ptBe) ;
// inserisco le nuove curve nel vettore delle curve e aggiorno il vettore degli indici
vpCrvs.emplace_back( Release( pCopy1)) ;
vInds.emplace_back( vInds[nI1]) ;
vpCrvs.emplace_back( Release( pCopy2)) ;
vInds.emplace_back( vInds[nI2]) ;
vpCrvs.emplace_back( Release( pLinkA)) ;
vInds.emplace_back( 0, 0) ;
vpCrvs.emplace_back( Release( pLinkB)) ;
vInds.emplace_back( 0, 0) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
WaterJetting::VerifySideAngle( void)
@@ -1482,10 +1359,8 @@ WaterJetting::ProcessPath( int nPathId, int nPvId, int nClId)
nStart = 2 ;
else if ( sMyNotes.find( "START=YM") != string::npos)
nStart = -2 ;
else if ( sMyNotes.find( "START=") != string::npos)
nStart = 11 ;
// se richiesta sistemazione punto di inizio
if ( nStart != 0 && nStart != 11) {
if ( nStart != 0) {
const double COS_ANG_PERD_TG = cos( 5 * DEGTORAD) ;
const double DIST_SIC_WJ_LIO = 2 ;
double dMinLen = m_Params.m_dOverlap + 2 * DIST_SIC_WJ_LIO ;
@@ -1544,18 +1419,6 @@ WaterJetting::ProcessPath( int nPathId, int nPvId, int nClId)
if ( dMin >= 0)
pCompo->ChangeStartPoint( dMin) ;
}
// se altrimenti suggerito punto di inizio
else if ( nStart == 11) {
ReplaceString( sMyNotes, "(", "") ;
ReplaceString( sMyNotes, ")", "") ;
Point3d ptStart ;
double dPar ;
int nFlag ;
if ( GetValInNotes( sMyNotes, "START", ptStart) &&
DistPointCurve( ptStart, *pCompo).GetParamAtMinDistPoint( 0, dPar, nFlag)) {
pCompo->ChangeStartPoint( dPar) ;
}
}
}
// eventuali allungamenti/accorciamenti per percorso aperto o chiuso senza sovrapposizione
@@ -2899,15 +2762,8 @@ WaterJetting::CalcCorrDir( const ICurveComposite* pCompo, double dU)
bool
WaterJetting::CalcOffset( ICurveComposite* pCompo, double dSignOffs)
{
// determino opzioni di offset
int nFlag = ICurve::OFF_EXTEND ;
if ( pCompo->IsClosed()) {
Vector3d vtStart ; pCompo->GetStartDir( vtStart) ;
Vector3d vtEnd ; pCompo->GetEndDir( vtEnd) ;
if ( ! AreSameVectorEpsilon( vtStart, vtEnd, sin( 5 * DEGTORAD)))
nFlag |= ICurve::OFF_FORCE_OPEN ;
}
// eseguo offset semplice
int nFlag = ICurve::OFF_EXTEND | ICurve::OFF_FORCE_OPEN ;
if ( pCompo->SimpleOffset( dSignOffs, nFlag))
return true ;
// se curva piatta, provo con offset avanzato
-2
View File
@@ -72,7 +72,6 @@ class WaterJetting : public Machining
bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ;
bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ;
bool Chain( int nGrpDestId) ;
bool AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds) ;
bool VerifySideAngle( void) ;
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
bool AdjustPathForInternalAngles( ICurveComposite* pCompo) ;
@@ -122,7 +121,6 @@ class WaterJetting : public Machining
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
WaterJettingData m_Params ; // parametri lavorazione
ToolData m_TParams ; // parametri utensile
double m_dTHoldBase ; // posizione base del porta-utensile
double m_dTHoldLen ; // lunghezza del porta-utensile
double m_dTHoldDiam ; // diametro del porta-utensile
double m_dElev ; // elevazione del percorso tenendo conto dell'angolo di fianco
+1 -1
View File
@@ -33,4 +33,4 @@
#pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtExecutor" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua54" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua53" EGTLIBVER ".lib")