From af4a3649752655913dbdafc3888517e8373aa26b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 20 Nov 2017 08:24:02 +0000 Subject: [PATCH] EgtExecutor 1.8k3 : - aggiunta funzione Exe e Lua VolZmapIntersPlane - aggiunta funzione Exe e Lua CopyAttributes. --- EXE_GdbModifyVol.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++ EXE_GdbObjAttribs.cpp | 12 ++++++++ EgtExecutor.rc | Bin 15096 -> 15096 bytes GeoTools.cpp | 12 ++++++++ GeoTools.h | 2 ++ LUA_GdbModifyVol.cpp | 34 +++++++++++++++++++++ LUA_GdbObjAttribs.cpp | 17 +++++++++++ 7 files changed, 145 insertions(+) diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 0af7bc7..bc106f1 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -367,6 +367,74 @@ ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRef return bOk ; } +//---------------------------------------------------------------------------- +int +MyVolZmapIntersPlane( int nId, const Plane3d& plPlane, int nDestGrpId, int nRefType, int* pnCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) + return GDB_ID_NULL ; + // recupero il riferimento destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + // porto in locale il piano + Plane3d plPlaneL = GetPlaneLocal( pGeomDB, plPlane, nRefType, frLoc) ; + // recupero lo Zmap e calcolo l'intersezione + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + POCRVVECTOR vpLoop ; + if ( pVZM == nullptr || ! pVZM->GetPlaneIntersection( plPlaneL, vpLoop)) + return GDB_ID_NULL ; + // inserisco le curve nel gruppo destinazione + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + for ( size_t i = 0 ; i < vpLoop.size() ; ++ i) { + PtrOwner pCrv( Release( vpLoop[i])) ; + if ( IsNull( pCrv)) + continue ; + pCrv->ToLoc( frDest) ; + // inserisco la curva composita nel gruppo destinazione + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, ::Release( pCrv)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCount ; + } + // aggiorno contatore + if ( pnCount != nullptr) + *pnCount = nCount ; + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//---------------------------------------------------------------------------- +int +ExeVolZmapIntersPlane( int nId, const Plane3d& plPlane, int nDestGrpId, int nRefType, int* pnCount) +{ + // eseguo + int nCount = 0 ; + int nFirstId = MyVolZmapIntersPlane( nId, plPlane, nDestGrpId, nRefType, &nCount) ; + if ( pnCount != nullptr) + *pnCount = nCount ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapIntersPlane(" + IdToString( nId) + ",{" + + ToString( ORIG + plPlane.GetVersN() * plPlane.GetDist()) + "},{" + + ToString( plPlane.GetVersN()) + "},{" + + ToString( nDestGrpId) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, int nRefType) diff --git a/EXE_GdbObjAttribs.cpp b/EXE_GdbObjAttribs.cpp index 9959a0c..2a1c056 100644 --- a/EXE_GdbObjAttribs.cpp +++ b/EXE_GdbObjAttribs.cpp @@ -24,6 +24,18 @@ using namespace std ; +//----------------------------------------------------------------------------- +bool +ExeCopyAttributes( int nSouId, int nDestId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // copio gli attributi (compreso il nome) + bool bOk = pGeomDB->CopyAttributes( nSouId, nDestId) ; + ExeSetModified() ; + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeSetLevel( int nId, int nLevel) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 6bc027623b3566e493d5f7de416871defd47af91..0f6049d63ce6f69adeed44eb12af14a524770330 100644 GIT binary patch delta 97 zcmexS`lEEiA2vqg%@@V4Gflq2na5~6Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mn->Y| cF@rU@0x76sKgP|Iq`|@mGetGridFrame(), frLoc) ; + return plPlaneL ; +} + //---------------------------------------------------------------------------- Frame3d GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame3d& frLoc) diff --git a/GeoTools.h b/GeoTools.h index 6feaa01..48e3dc5 100644 --- a/GeoTools.h +++ b/GeoTools.h @@ -25,6 +25,8 @@ int AdjustId( int nId) ; Vector3d GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc) ; // Punto espresso nel riferimento desiderato partendo da punto nel riferimento RefType Point3d GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d& frLoc) ; +// Pianoo espresso nel riferimento desiderato partendo da piano nel riferimento RefType +Plane3d GetPlaneLocal( IGeomDB* pGeomDB, const Plane3d& plPlane, int nRefType, const Frame3d& frLoc) ; // Riferimento espresso nel riferimento desiderato partendo da riferimento nel riferimento RefType Frame3d GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame3d& frLoc) ; // Punto portato dal riferimento di nId a quello di nRefId diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 9e604cc..5786b3f 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -261,6 +261,39 @@ LuaVolZmapGetDepth( lua_State* L) return 2 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapIntersPlane( lua_State* L) +{ + // 4 o 5 parametri : nId, ptP, vtN, nDestGrpId [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptP ; + LuaCheckParam( L, 2, ptP) + Vector3d vtN ; + LuaCheckParam( L, 3, vtN) + int nDestGrpId ; + LuaCheckParam( L, 4, nDestGrpId) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // eseguo calcolo intersezione + Plane3d plPlane ; + plPlane.Set( ptP, vtN) ; + int nCount ; + int nFirstId = ExeVolZmapIntersPlane( nId, plPlane, nDestGrpId, nRefType, &nCount) ; + // restituisco il risultato + if ( nFirstId != GDB_ID_NULL) { + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + //---------------------------------------------------------------------------- static int LuaVolZmapAvoidBox( lua_State* L) @@ -296,6 +329,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapIntersPlane", LuaVolZmapIntersPlane) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ; return bOk ; diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index d545c05..4abffc2 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -22,6 +22,22 @@ using namespace std ; +//------------------------------------------------------------------------------- +static int +LuaCopyAttributes( lua_State* L) +{ + // 2 parametri : nSouId, nDestId + int nSouId ; + LuaCheckParam( L, 1, nSouId) + int nDestId ; + LuaCheckParam( L, 2, nDestId) + // copio gli attributri + bool bOk = ExeCopyAttributes( nSouId, nDestId) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetLevel( lua_State* L) @@ -724,6 +740,7 @@ bool LuaInstallGdbObjAttribs( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCopyAttributes", LuaCopyAttributes) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetLevel", LuaSetLevel) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRevertLevel", LuaRevertLevel) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetLevel", LuaGetLevel) ;