From 20f3f5755f10976882ae405d47fe4138538e5368 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 31 Oct 2016 19:23:34 +0000 Subject: [PATCH] EgtExecutor : - aggiunta a Exe e Lua funzione CreateVolZmapByRegionExtrusion. --- EXE_GdbCreateVol.cpp | 40 +++++++++++++++++++++++++++++++++++++++- LUA_GdbCreateVol.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index df1837f..d1795d9 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -65,4 +65,42 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim } // restituisco l'identificativo della nuova entità return nNewId ; -} \ No newline at end of file +} + +//------------------------------------------------------------------------------- +int +ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, double dPrec) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero la regione + ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nSfrId)) ; + bool bOk = ( pSfr != nullptr) ; + // recupero il riferimento della regione + Frame3d frSfr ; + bOk = bOk && pGeomDB->GetGlobFrame( nSfrId, frSfr) ; + // recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; + // creo lo Zmap nel suo riferimento intrinseco + PtrOwner pVZM( CreateVolZmap()) ; + bOk = bOk && ! IsNull( pVZM) ; + bOk = bOk && pVZM->CreateMapFromFlatRegion( *pSfr, dDimZ, dPrec) ; + // lo porto nel riferimento di destinazione + bOk = bOk && pVZM->LocToLoc( frSfr, frDest) ; + // inserisco lo Zmap nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapByRegionExtrusion(" + IdToString( nParentId) + "," + + ToString( nSfrId) + "," + + ToString( dDimZ) + "," + + ToString( dPrec) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} diff --git a/LUA_GdbCreateVol.cpp b/LUA_GdbCreateVol.cpp index 7adcc0f..024b6bf 100644 --- a/LUA_GdbCreateVol.cpp +++ b/LUA_GdbCreateVol.cpp @@ -50,11 +50,36 @@ LuaCreateVolZmapBox( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateVolZmapByRegionExtrusion( lua_State* L) +{ + // 4 parametri : ParentId, SfrId dDimZ, dPrec + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nSfrId ; + LuaCheckParam( L, 2, nSfrId) + double dDimZ ; + LuaCheckParam( L, 3, dDimZ) + double dPrec ; + LuaCheckParam( L, 4, dPrec) + LuaClearStack( L) ; + // creo VZM per estrusione di flat region + int nId = ExeCreateVolZmapByRegionExtrusion( nParentId, nSfrId, dDimZ, dPrec) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbCreateVol( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ; return bOk ; }