From ac5772a654883c6d0c46f650fdd7e13df18974df Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 6 Oct 2017 07:54:48 +0000 Subject: [PATCH] EgtExecutor 1.8j2 : - aggiunta fiunzione Exe e Lua CreateSurfTmByVolZmap - aggiunte funzioni Exe e Lua CopyVolZmapPart e RemoveVolZmapPart - aggiunte funzioni Exe e Lua SurfArea, SurfVolume, VolZmapVolume e VolZmapPartVolume. --- EXE_GdbCreateSurf.cpp | 62 +++++++++++++++++++++++++++++++++++ EXE_GdbModifyVol.cpp | 63 +++++++++++++++++++++++++++++++++++ EXE_GeoSnap.cpp | 60 ++++++++++++++++++++++++++++++++++ EgtExecutor.rc | Bin 15096 -> 15096 bytes LUA_GdbCreateSurf.cpp | 24 ++++++++++++++ LUA_GdbModifyVol.cpp | 41 +++++++++++++++++++++++ LUA_GeoSnap.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 324 insertions(+) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 5437f15..c8546f2 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" +#include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EgkStringUtils3d.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkCurveLocal.h" @@ -1091,3 +1092,64 @@ ExeCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) // restituisco il risultato return nNewId ; } + +//---------------------------------------------------------------------------- +int +ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il solido VolZmap + const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ; + bool bOk = ( pVZM != nullptr) ; + // se richiesta superficie di una sola parte + PtrOwner pPart ; + if ( bOk && nPart >= 0) { + pPart.Set( pVZM->ClonePart( nPart)) ; + bOk = ! IsNull( pPart) ; + pVZM = pPart ; + } + // recupero il riferimento del solido sorgente + Frame3d frSou ; + bOk = bOk && pGeomDB->GetGlobFrame( nZmapId, frSou) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // Costruttore di trimesh da insieme disordinato di triangoli + StmFromTriangleSoup StmFts ; + bOk = bOk && StmFts.Start() ; + // recupero i triangoli del bordo dello Zmap + INTVECTOR vnModif ; + TRIA3DLISTVECTOR vlTria ; + int nCount = ( bOk ? pVZM->GetBlockCount() : 0) ; + ( bOk ? pVZM->GetTriangles( false, vnModif, vlTria) : false) ; + for ( int i = 0 ; i < nCount && bOk ; ++ i) { + // se blocco non modificato, vado oltre + if ( vnModif[i] < 0) + continue ; + for ( auto& Tria : vlTria[vnModif[i]]) { + // aggiusto per i sistemi di riferimento + Tria.LocToLoc( frSou, frLoc) ; + // inserisco il triangolo nella nuova superficie + if ( ! StmFts.AddTriangle( Tria)) + bOk = false ; + } + } + // valido la superficie e calcolo le adiacenze + bOk = bOk && StmFts.End() ; + // inserisco la superficie trimesh nel DB + PtrOwner pStm( StmFts.GetSurf()) ; + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmByVolZmap(" + IdToString( nParentId) + "," + + IdToString( nZmapId) + "," + + IdToString( nPart) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nNewId ; +} diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 964e749..1e9ddc1 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -96,6 +96,69 @@ ExeExplodeVolume( int nId, int* pnCount) return nFirstId ; } +//------------------------------------------------------------------------------- +int +ExeCopyVolZmapPart( int nId, int nPart, int nDestGrpId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero lo Zmap e copio la parte indicata + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + if ( pVZM == nullptr) + return GDB_ID_NULL ; + // recupero il suo riferimento globale + Frame3d frVZM ; + if ( ! pGeomDB->GetGlobFrame( nId, frVZM)) + return GDB_ID_NULL ; + // recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + // copio la parte connessa + PtrOwner pPart( pVZM->ClonePart( nPart)) ; + if ( IsNull( pPart)) + return GDB_ID_NULL ; + pPart->LocToLoc( frVZM, frDest) ; + // inserisco nel DB + int nVZMId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nDestGrpId, GDB_LAST_SON, Release( pPart)) ; + if ( nVZMId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio gli attributi + if ( ! pGeomDB->CopyAttributes( nId, nVZMId)) + return GDB_ID_NULL ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "ExeCopyVolZmapPart(" + ToString( nId) + "," + + ToString( nPart) + "," + + ToString( nDestGrpId) + ")" + + " -- Id=" + ToString( nVZMId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return nVZMId ; +} + +//------------------------------------------------------------------------------- +bool +ExeRemoveVolZmapPart( int nId, int nPart) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap e rimuovo la parte indicata + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pVZM != nullptr && pVZM->RemovePart( nPart)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRemoveVolZmapPart(" + ToString( nId) + "," + + ToString( nPart) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapSetStdTool( int nId, const string& sToolName, double dLen, double dDiam, double dCornR) diff --git a/EXE_GeoSnap.cpp b/EXE_GeoSnap.cpp index 33a5d18..23779b5 100644 --- a/EXE_GeoSnap.cpp +++ b/EXE_GeoSnap.cpp @@ -904,6 +904,36 @@ ExeCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ; } +//---------------------------------------------------------------------------- +bool +ExeSurfArea( int nId, double& dArea) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // verifico il parametro + if ( &dArea == nullptr) + return false ; + // recupero la superficie + ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; + // ne restituisco l'area + return ( pSurf != nullptr && pSurf->GetArea( dArea)) ; +} + +//---------------------------------------------------------------------------- +bool +ExeSurfVolume( int nId, double& dVol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // verifico il parametro + if ( &dVol == nullptr) + return false ; + // recupero la superficie + ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; + // ne restituisco l'eventuale volume (se è chiusa) + return ( pSurf != nullptr && pSurf->GetVolume( dVol)) ; +} + //---------------------------------------------------------------------------- bool ExeSurfFrNormVersor( int nId, int nRefId, Vector3d& vtNorm) @@ -1106,6 +1136,21 @@ ExeSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool& bAdjac, Poi return true ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapVolume( int nId, double& dVol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // verifico il parametro + if ( &dVol == nullptr) + return false ; + // recupero il solido Zmap + const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + // ne restituisco il volume + return ( pVZM != nullptr && pVZM->GetVolume( dVol)) ; +} + //---------------------------------------------------------------------------- int ExeVolZmapPartCount( int nId) @@ -1120,6 +1165,21 @@ ExeVolZmapPartCount( int nId) return pVZM->GetPartCount() ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapPartVolume( int nId, int nPart, double& dVol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // verifico il parametro + if ( &dVol == nullptr) + return false ; + // recupero il solido Zmap + const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + // restituisco il volume della eventuale parte richiesta + return ( pVZM != nullptr && pVZM->GetPartVolume( nPart, dVol)) ; +} + //---------------------------------------------------------------------------- bool ExeTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 3bd6bed8e0261a38f5400761b05e42c4655e7431..dcc29120315998b0aecc40b90983bc9ad667259c 100644 GIT binary patch delta 97 zcmexS`lEEiA2vp#%@@V4Gflq2na5}}Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mn->Y| cF@rU@0x76sKgP|Iq`|@m= 3) + LuaCheckParam( L, 3, nPart) ; + LuaClearStack( L) ; + // creo STM partendo da solido Zmap + int nId = ExeCreateSurfTmByVolZmap( nParentId, nZmapId, nPart) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbCreateSurf( LuaMgr& luaMgr) @@ -606,5 +629,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ; return bOk ; } diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 8a1d8a4..d53b27e 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -39,6 +39,45 @@ LuaExplodeVolume( lua_State* L) return 2 ; } +//---------------------------------------------------------------------------- +static int +LuaCopyVolZmapPart( lua_State* L) +{ + // 3 parametri : Id, nPart(0-based), nDestGrpId + int nId ; + LuaCheckParam( L, 1, nId) + int nPart ; + LuaCheckParam( L, 2, nPart) + int nDestGrpId ; + LuaCheckParam( L, 3, nDestGrpId) + LuaClearStack( L) ; + // copio la parte indicata nel gruppo specificato + int nNewId = ExeCopyVolZmapPart( nId, nPart, nDestGrpId) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaRemoveVolZmapPart( lua_State* L) +{ + // 2 parametri : Id, nPart(0-based) + int nId ; + LuaCheckParam( L, 1, nId) + int nPart ; + LuaCheckParam( L, 2, nPart) + LuaClearStack( L) ; + // rimuovo la parte indicata + bool bOk = ExeRemoveVolZmapPart( nId, nPart) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaVolZmapSetStdTool( lua_State* L) @@ -245,6 +284,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCopyVolZmapPart", LuaCopyVolZmapPart) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ; diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index 5f26f1e..8961821 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -581,6 +581,40 @@ LuaCurveCompoCenter( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfArea( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero la sua area + double dArea ; + if ( ExeSurfArea( nId, dArea)) + LuaSetParam( L, dArea) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfVolume( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il suo eventuale volume (se chiusa) + double dVol ; + if ( ExeSurfVolume( nId, dVol)) + LuaSetParam( L, dVol) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSurfFrNormVersor( lua_State* L) @@ -805,6 +839,23 @@ LuaSurfTmFacetsContact( lua_State* L) return 4 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapVolume( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il suo volume + double dVol ; + if ( ExeVolZmapVolume( nId, dVol)) + LuaSetParam( L, dVol) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaVolZmapPartCount( lua_State* L) @@ -822,6 +873,25 @@ LuaVolZmapPartCount( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapPartVolume( lua_State* L) +{ + // 2 parametri : Id, nPartInd (0-based) + int nId ; + LuaCheckParam( L, 1, nId) + int nPartInd ; + LuaCheckParam( L, 2, nPartInd) + LuaClearStack( L) ; + // recupero il suo eventuale volume + double dVol ; + if ( ExeVolZmapPartVolume( nId, nPartInd, dVol)) + LuaSetParam( L, dVol) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaTextNormVersor( lua_State* L) @@ -875,6 +945,8 @@ LuaInstallGeoSnap( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtArcDeltaN", LuaArcDeltaN) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArcNormVersor", LuaArcNormVersor) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoCenter", LuaCurveCompoCenter) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfArea", LuaSurfArea) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfVolume", LuaSurfVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrNormVersor", LuaSurfFrNormVersor) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkCount", LuaSurfFrChunkCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkSimpleClassify", LuaSurfFrChunkSimpleClassify) ; @@ -885,7 +957,9 @@ LuaInstallGeoSnap( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtTextNormVersor", LuaTextNormVersor) ; return bOk ; }