From 78bc849746af41b839aa0b8a75e7296fdc18b029 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 14 Jan 2021 06:36:35 +0000 Subject: [PATCH] EgtMachKernel 2.3a3 : - corretta lavorazione di finitura con lama per spatolatura per la gestione degli angoli sulla linea guida - allineata AdjustCurveFromSurf alla funzione simile di EgtExecutor - aggiunta funzione lua di macchina EmtGetBackAuxDir - a MachMgr aggiunte funzioni di interfaccia GetCalcHead e GetCalcExit. --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes MachMgr.h | 4 ++++ MachMgrMachines.cpp | 32 ++++++++++++++++++++++++++++++++ Machine.h | 3 +++ MachineCalc.cpp | 29 ++++++++++++++++++++++++++++- MachineLua.cpp | 1 + MachineLuaCL.cpp | 32 +++++++++++++++++++++++++++++--- Operation.cpp | 2 +- SawFinishing.cpp | 5 +---- 9 files changed, 99 insertions(+), 9 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 79d5298e4917959e2f69ea40977e457fff8ba1ee..284c11b0768270150ded8116630e9ef5d9f3b500 100644 GIT binary patch delta 97 zcmewt{V#gMFE&Qw&A-`fnHh~IKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmUD-Bai?9 delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 diff --git a/MachMgr.h b/MachMgr.h index b2d0a0a..3a2d732 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -311,6 +311,8 @@ class MachMgr : public IMachMgr bool SetRotAxisBlock( const std::string& sAxis, double dVal) override ; bool GetRotAxisBlocked( int nInd, std::string& sAxis, double& dVal) const override ; bool GetCalcTool( std::string& sTool) const override ; + bool GetCalcHead( std::string& sHead) const override ; + bool GetCalcExit( int& nExit) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, @@ -422,6 +424,8 @@ class MachMgr : public IMachMgr { m_vAxisBlock.clear() ; } bool IsKinematicRotAxisBlocked( int nInd) const ; int GetCalcTool( void) const ; + int GetCalcHead( void) const ; + int GetCalcExit( void) const ; double GetCalcRot1W( void) const ; bool GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool SetCalcSolCh( int nScc, bool bExact) ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 0f17c74..416c8aa 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -486,6 +486,38 @@ MachMgr::GetCalcTool( void) const return ( ( pMch != nullptr) ? pMch->GetCurrTool() : GDB_ID_NULL) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::GetCalcHead( string& sHead) const +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->GetCurrHead( sHead) : false) ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetCalcHead( void) const +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->GetCurrHead() : GDB_ID_NULL) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetCalcExit( int& nExit) const +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->GetCurrExit( nExit) : false) ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetCalcExit( void) const +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->GetCurrExit() : GDB_ID_NULL) ; +} + //---------------------------------------------------------------------------- double MachMgr::GetCalcRot1W( void) const diff --git a/Machine.h b/Machine.h index 32a9009..cbcb44c 100644 --- a/Machine.h +++ b/Machine.h @@ -97,6 +97,8 @@ class Machine bool GetCurrTool( std::string& sTool) const ; int GetCurrHead( void) const ; bool GetCurrHead( std::string& sHead) const ; + int GetCurrExit( void) const ; + bool GetCurrExit( int& nExit) const ; bool GetCurrHeadCollGroups( INTVECTOR& vIds) const ; double GetCurrRot1W( void) const ; std::string GetKinematicAxis( int nInd) const ; @@ -313,6 +315,7 @@ class Machine static int LuaEmtAddArcMove( lua_State* L) ; static int LuaEmtGetMoveType( lua_State* L) ; static int LuaEmtGetAxesPos( lua_State* L) ; + static int LuaEmtGetBackAuxDir( lua_State* L) ; static int LuaEmtLinkRawPartToGroup( lua_State* L) ; static int LuaEmtUnlinkRawPartFromGroup( lua_State* L) ; static int LuaEmtUnlinkAllRawPartsFromGroups( lua_State* L) ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 3c13a17..af93532 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -344,7 +344,7 @@ Machine::GetCurrHead( void) const // controllo GeomDB if ( m_pGeomDB == nullptr) return GDB_ID_NULL ; - // recupero identificativo dell'utensile + // recupero identificativo della testa return m_nCalcHeadId ; } @@ -359,6 +359,33 @@ Machine::GetCurrHead( string& sHead) const return m_pGeomDB->GetName( m_nCalcHeadId, sHead) ; } +//---------------------------------------------------------------------------- +int +Machine::GetCurrExit( void) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + // recupero identificativo dell'uscita + return m_nCalcExitId ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetCurrExit( int& nExit) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + // recupero nome gruppo dell'uscita + string sExit ; + if ( ! m_pGeomDB->GetName( m_nCalcExitId, sExit)) + return false ; + // recupero indice dell'uscita + TrimLeft( sExit, MCH_EXIT.c_str()) ; + return FromString( sExit, nExit) ; +} + //---------------------------------------------------------------------------- bool Machine::GetCurrHeadCollGroups( INTVECTOR& vIds) const diff --git a/MachineLua.cpp b/MachineLua.cpp index cc9bebf..f642dc6 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -110,6 +110,7 @@ Machine::LuaInit( const string& sMachineName) // registro le funzioni di lettura entità CL per lua m_LuaMgr.RegisterFunction( "EmtGetMoveType", Machine::LuaEmtGetMoveType) ; m_LuaMgr.RegisterFunction( "EmtGetAxesPos", Machine::LuaEmtGetAxesPos) ; + m_LuaMgr.RegisterFunction( "EmtGetBackAuxDir", Machine::LuaEmtGetBackAuxDir) ; // registro le funzioni di scrittura part program per lua m_LuaMgr.RegisterFunction( "EmtWrite", Machine::LuaEmtWrite) ; // registro la funzione per impostare informazioni di outstroke diff --git a/MachineLuaCL.cpp b/MachineLuaCL.cpp index 82c4302..ffeeb57 100644 --- a/MachineLuaCL.cpp +++ b/MachineLuaCL.cpp @@ -267,7 +267,7 @@ Machine::LuaEmtAddArcMove( lua_State* L) int Machine::LuaEmtGetMoveType( lua_State* L) { - // 1 parametri : nClEntId + // 1 parametro : nClEntId int nClEntId ; LuaCheckParam( L, 1, nClEntId) LuaClearStack( L) ; @@ -292,7 +292,7 @@ Machine::LuaEmtGetMoveType( lua_State* L) int Machine::LuaEmtGetAxesPos( lua_State* L) { - // 1 parametri : nClEntId + // 1 parametro : nClEntId int nClEntId ; LuaCheckParam( L, 1, nClEntId) LuaClearStack( L) ; @@ -303,7 +303,7 @@ Machine::LuaEmtGetAxesPos( lua_State* L) // recupero l'oggetto CamData const CamData* pCamData = GetCamData( m_pMchLua->m_pGeomDB->GetUserObj( nClEntId)) ; bool bOk = ( pCamData != nullptr) ; - bOk = bOk && pCamData->GetAxesStatus() == CamData::AS_OK ; + bOk = bOk && ( pCamData->GetAxesStatus() == CamData::AS_OK) ; if ( bOk) { DBLVECTOR AxesVal = pCamData->GetAxesVal() ; LuaSetParam( L, AxesVal) ; @@ -313,3 +313,29 @@ Machine::LuaEmtGetAxesPos( lua_State* L) return 1 ; } + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtGetBackAuxDir( lua_State* L) +{ + // 1 parametro : nClEntId + int nClEntId ; + LuaCheckParam( L, 1, nClEntId) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva valida + if ( m_pMchLua == nullptr || + m_pMchLua->m_pMchMgr == nullptr || m_pMchLua->m_pGeomDB == nullptr) + return luaL_error( L, " Unknown Machine") ; + // recupero l'oggetto CamData + const CamData* pCamData = GetCamData( m_pMchLua->m_pGeomDB->GetUserObj( nClEntId)) ; + bool bOk = ( pCamData != nullptr) ; + bOk = bOk && ( pCamData->GetAxesStatus() == CamData::AS_OK) ; + if ( bOk) { + const Vector3d& vtBackAuxDir = pCamData->GetBackAuxDir() ; + LuaSetParam( L, vtBackAuxDir) ; + } + else + LuaSetParam( L) ; + + return 1 ; +} diff --git a/Operation.cpp b/Operation.cpp index 31b8799..bc6b7b5 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -682,7 +682,7 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF 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 (46deg) - const double COS_ANG_MAX = cos( 46 * DEGTORAD) ; + 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() ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index ad603ef..49bd0a9 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -1562,9 +1562,6 @@ SawFinishing::CalculateCurvedAcrossToolPath( int nAuxId, int nClId) } // La porto in globale PL.ToGlob( frSect) ; - //PL.Translate( vtDeltaSect) ; - //if ( m_Params.m_bInvert) - // PL.Translate( ptGdStart - ptGdEnd) ; // Calcolo eventuale anticipo dell'inizio double dAddStart = 0 ; @@ -2818,7 +2815,7 @@ SawFinishing::AddCornerApproach( const Point3d& ptP, const Vector3d& vtCorr, con Point3d ptP1b = ptP + vtCorr * ( dElev + dAppr) ; Point3d ptP1a = ptP1b + vtCorr * ( dSafeZ - dAppr) ; SetFlag( 0) ; - for ( int i = 1 ; i < nStep ; ++ i) { + for ( int i = 1 ; i <= nStep ; ++ i) { double dCoeff = i / double( nStep) ; Point3d ptOut = Media( ptPrev, ptP1a, dCoeff) ; Vector3d vtOut = Media( vtPrev, vtCorr, dCoeff) ;