diff --git a/Drilling.cpp b/Drilling.cpp index 9af43fa..0abc01f 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -475,7 +475,7 @@ Drilling::Apply( bool bRecalc) if ( ! AdjustStartEndMovements()) return false ; - // esecuzione eventuale personalizzazioni + // esecuzione eventuali personalizzazioni if ( ! PostApply()) return false ; diff --git a/Machine.h b/Machine.h index 6eb1667..6b1ed08 100644 --- a/Machine.h +++ b/Machine.h @@ -247,6 +247,7 @@ class Machine static int LuaEmtAddRapidStart( lua_State* L) ; static int LuaEmtAddRapidMove( lua_State* L) ; static int LuaEmtAddLinearMove( lua_State* L) ; + static int LuaEmtAddArcMove( lua_State* L) ; static int LuaEmtGetAxesPos( lua_State* L) ; static int LuaEmtLinkRawPartToGroup( lua_State* L) ; static int LuaEmtUnlinkRawPartFromGroup( lua_State* L) ; diff --git a/MachineLua.cpp b/MachineLua.cpp index 8926f8c..cfbf1f7 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -95,6 +95,7 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtAddRapidStart", Machine::LuaEmtAddRapidStart) ; m_LuaMgr.RegisterFunction( "EmtAddRapidMove", Machine::LuaEmtAddRapidMove) ; m_LuaMgr.RegisterFunction( "EmtAddLinearMove", Machine::LuaEmtAddLinearMove) ; + m_LuaMgr.RegisterFunction( "EmtAddArcMove", Machine::LuaEmtAddArcMove) ; // registro le funzioni di lettura entità CL per lua m_LuaMgr.RegisterFunction( "EmtGetAxesPos", Machine::LuaEmtGetAxesPos) ; // registro le funzioni di scrittura part program per lua diff --git a/MachineLuaCL.cpp b/MachineLuaCL.cpp index cbb1129..34f27cc 100644 --- a/MachineLuaCL.cpp +++ b/MachineLuaCL.cpp @@ -18,6 +18,7 @@ #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EGnStringUtils.h" @@ -191,6 +192,77 @@ Machine::LuaEmtAddLinearMove( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +int +Machine::LuaEmtAddArcMove( lua_State* L) +{ + // 11 parametri : nPathId, ptIni, ptFin, ptCen, dAngCen, vtN, vtTool, vtCorr, vtAux, dFeed, nFlag + int nPathId ; + LuaCheckParam( L, 1, nPathId) + Point3d ptIni ; + LuaCheckParam( L, 2, ptIni) + Point3d ptFin ; + LuaCheckParam( L, 3, ptFin) + Point3d ptCen ; + LuaCheckParam( L, 4, ptCen) + double dAngCen ; + LuaCheckParam( L, 5, dAngCen) + Vector3d vtN ; + LuaCheckParam( L, 6, vtN) + Vector3d vtTool ; + LuaCheckParam( L, 7, vtTool) + Vector3d vtCorr ; + LuaCheckParam( L, 8, vtCorr) + Vector3d vtAux ; + LuaCheckParam( L, 9, vtAux) + double dFeed ; + LuaCheckParam( L, 10, dFeed) + int nFlag ; + LuaCheckParam( L, 11, nFlag) + 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") ; + // creo oggetto arco per DB geometrico + PtrOwner pArc( CreateCurveArc()) ; + bool bOk = ! IsNull( pArc) ; + // assegno i dati dell'arco + double dDeltaZ = ( ptFin - ptIni) * vtN ; + bOk = bOk && ( ! pArc->SetCPAN( ptCen, ptIni, dAngCen, dDeltaZ, vtN)) ; + Point3d ptCalcFin ; + bOk = bOk && ( ! pArc->GetEndPoint( ptCalcFin) || ! AreSamePointApprox( ptCalcFin, ptFin)) ; + int nMove = ( dAngCen > 0 ? 3 : 2) ; + // inserisco l'oggetto nel DB geometrico + int nId = ( bOk ? m_pMchLua->m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pArc)) : GDB_ID_NULL) ; + bOk = bOk && ( nId != GDB_ID_NULL) ; + // creo oggetto dati Cam + PtrOwner pCam( new( nothrow) CamData) ; + bOk = bOk && ! IsNull( pCam) ; + if ( bOk) { + // assegno valori + pCam->SetMoveType( nMove) ; + pCam->SetToolDir( vtTool) ; + pCam->SetCorrDir( vtCorr) ; + pCam->SetAuxDir( vtAux) ; + pCam->SetEndPoint( ptFin) ; + pCam->SetCenter( ptCen) ; + pCam->SetAngCen( dAngCen) ; + pCam->SetDeltaN( dDeltaZ) ; + pCam->SetNormDir( vtN) ; + pCam->SetFeed( dFeed) ; + pCam->SetFlag( nFlag) ; + // associo questo oggetto a quello geometrico + m_pMchLua->m_pGeomDB->SetUserObj( nId, Release( pCam)) ; + } + // assegno risultato + if ( bOk) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- int Machine::LuaEmtGetAxesPos( lua_State* L) diff --git a/Milling.cpp b/Milling.cpp index acc6033..9a4cfb3 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -520,7 +520,7 @@ Milling::Apply( bool bRecalc) if ( ! AdjustStartEndMovements()) return false ; - // esecuzione eventuale personalizzazioni + // esecuzione eventuali personalizzazioni if ( ! PostApply()) return false ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 26e7e6f..d74fbfe 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -451,7 +451,7 @@ SawFinishing::Apply( bool bRecalc) if ( ! AdjustStartEndMovements()) return false ; - // esecuzione eventuale personalizzazioni + // esecuzione eventuali personalizzazioni if ( ! PostApply()) return false ; diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 6555acf..ea952dc 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -430,7 +430,7 @@ SawRoughing::Apply( bool bRecalc) if ( ! AdjustStartEndMovements()) return false ; - // esecuzione eventuale personalizzazioni + // esecuzione eventuali personalizzazioni if ( ! PostApply()) return false ; diff --git a/Sawing.cpp b/Sawing.cpp index 6601692..b0de965 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -537,7 +537,7 @@ Sawing::Apply( bool bRecalc) if ( ! AdjustStartEndMovements()) return false ; - // esecuzione eventuale personalizzazioni + // esecuzione eventuali personalizzazioni if ( ! PostApply()) return false ;