From 562048fc9a830ac00323617cfbb46b53cdd6e25c Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 31 Dec 2018 09:25:44 +0000 Subject: [PATCH] =?UTF-8?q?EgtExecutor=20:=20-=20funzione=20Exe=20e=20Lua?= =?UTF-8?q?=20CAvGetToolOutline=20con=20parametro=20bApprox=20in=20pi?= =?UTF-8?q?=C3=B9=20-=20aggiunta=20funzione=20Exe=20e=20Lua=20VolZmapGetTo?= =?UTF-8?q?olOutline.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_CAvTool.cpp | 8 ++++---- EXE_GdbModifyVol.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ LUA_CAvTool.cpp | 6 ++++-- LUA_GdbModifyVol.cpp | 23 +++++++++++++++++++++++ 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/EXE_CAvTool.cpp b/EXE_CAvTool.cpp index 9074fb6..6970005 100644 --- a/EXE_CAvTool.cpp +++ b/EXE_CAvTool.cpp @@ -77,7 +77,7 @@ ExeCAvSetGenTool( int nToolSectId) //---------------------------------------------------------------------------- int -ExeCAvGetToolOutline( int nDestGrpId) +ExeCAvGetToolOutline( int nDestGrpId, bool bApprox) { if ( IsNull( s_pCAvTlStm)) return GDB_ID_NULL ; @@ -85,11 +85,11 @@ ExeCAvGetToolOutline( int nDestGrpId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero outline dell'utensile - const ICurveComposite* pCC = s_pCAvTlStm->GetToolOutline() ; - if ( pCC == nullptr || ! pCC->IsValid()) + const ICurveComposite& CC = s_pCAvTlStm->GetToolOutline( bApprox) ; + if ( ! CC.IsValid()) return GDB_ID_NULL ; // ne faccio una copia - PtrOwner pCopy( pCC->Clone()) ; + PtrOwner pCopy( CC.Clone()) ; if ( IsNull( pCopy)) return GDB_ID_NULL ; // inserisco la copia nel DB geometrico diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 5b3a3ed..6763100 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -319,6 +319,49 @@ ExeVolZmapSetChiselTool( int nId, const string& sToolName, return bOk ; } +//---------------------------------------------------------------------------- +int +MyVolZmapGetToolOutline( int nId, int nDestGrpId, bool bApprox) +{ + // verifico DB geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero lo Zmap e recupero il profilo dell'utensile + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + if ( pVZM == nullptr) + return GDB_ID_NULL ; + // recupero outline dell'utensile + const ICurveComposite& CC = pVZM->GetToolOutline( bApprox) ; + if ( ! CC.IsValid()) + return GDB_ID_NULL ; + // ne faccio una copia + PtrOwner pCopy( CC.Clone()) ; + if ( IsNull( pCopy)) + return GDB_ID_NULL ; + // inserisco la copia nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCopy)) ; + return nNewId ; +} + +//---------------------------------------------------------------------------- +int +ExeVolZmapGetToolOutline( int nId, int nDestGrpId, bool bApprox) +{ + int nNewId = MyVolZmapGetToolOutline( nId, nDestGrpId, bApprox) ; + if ( nNewId != GDB_ID_NULL) + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapGetToolOutline(" + IdToString( nId) + "," + + IdToString( nDestGrpId) + "," + + ( bApprox ? "true" : "false") + ")" + + " -- Id=" + IdToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return nNewId ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, diff --git a/LUA_CAvTool.cpp b/LUA_CAvTool.cpp index 3e3cff9..dc07247 100644 --- a/LUA_CAvTool.cpp +++ b/LUA_CAvTool.cpp @@ -105,12 +105,14 @@ LuaCAvSetGenTool( lua_State* L) static int LuaCAvGetToolOutline( lua_State* L) { - // 1 parametro : nDestGrpId + // 1 o 2 parametri : nDestGrpId [, bApprox] int nDestGrpId ; LuaCheckParam( L, 1, nDestGrpId) + bool bApprox = false ; + LuaGetParam( L, 2, bApprox) ; LuaClearStack( L) ; // recupero profilo dell'utensile per Collision Avoidance - int nId = ExeCAvGetToolOutline( nDestGrpId) ; + int nId = ExeCAvGetToolOutline( nDestGrpId, bApprox) ; // restituisco il risultato LuaSetParam( L, nId) ; return 1 ; diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 008adb5..f8508dd 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -234,6 +234,28 @@ LuaVolZmapSetChiselTool( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapGetToolOutline( lua_State* L) +{ + // 2 o 3 parametri : nId, nDestGrpId [, bApprox] + int nId ; + LuaCheckParam( L, 1, nId) + int nDestGrpId ; + LuaCheckParam( L, 2, nDestGrpId) + bool bApprox = false ; + LuaGetParam( L, 3, bApprox) ; + LuaClearStack( L) ; + // recupero il profilo dell'utensile associato a Zmap indicato + int nNewId = ExeVolZmapGetToolOutline( nId, nDestGrpId, bApprox) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaVolZmapMillingStep( lua_State* L) @@ -375,6 +397,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetGenTool", LuaVolZmapSetGenTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ;