From 55e34f929778d7566aebf6e383df9d30e4b68ead Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 28 Mar 2025 20:21:16 +0100 Subject: [PATCH] EgtExecutor : - aggiunta funzione exe e lua CreateSurfTmByPolygonWithHoles. --- EXE_GdbCreateSurf.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ EgtExecutor.sln | 9 +++++++-- LUA_GdbCreateSurf.cpp | 44 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 6fcd843..ed25f9b 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1079,6 +1079,51 @@ ExeCreateSurfTmByPolygon( int nParentId, const PolyLine& PL, int nRefType) return nNewId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmByPolygonWithHoles( int nParentId, const POLYLINEVECTOR& vPL, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + bool bOk = true ; + // recupero il riferimento del gruppo destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; + // creo la superficie trimesh + PtrOwner pSTM( CreateSurfTriMesh()) ; + bOk = bOk && ! IsNull( pSTM) ; + bOk = bOk && pSTM->CreateByPolygonWithHoles( vPL) ; + // eventuale trasformazione per riferimento di espressione dei punti + if ( bOk && nRefType == RTY_GLOB) + pSTM->ToLoc( frDest) ; + else if ( bOk && nRefType == RTY_GRID) + pSTM->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; + // inserisco la superficie nel DB + 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 sPnt ; + for ( int i = 0 ; i < int( vPL.size()) ; ++ i) { + if ( i > 0) + sPnt += ",{0/0,0/0,0/0}," ; ; + Point3d ptP ; + if ( vPL[i].GetFirstPoint( ptP)) + sPnt += "{" + ToString( ptP) + "}" ; + while ( vPL[i].GetNextPoint( ptP)) + sPnt += ",{" + ToString( ptP) + "}" ; + } + string sLua = "EgtSurfTmByPolygonWithHoles(" + IdToString( nParentId) + ",{" + + sPnt + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- int ExeCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) diff --git a/EgtExecutor.sln b/EgtExecutor.sln index f7f51ae..7df81b6 100644 --- a/EgtExecutor.sln +++ b/EgtExecutor.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35919.96 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtExecutor", "EgtExecutor.vcxproj", "{DF654897-F85B-4108-A621-F2C4AB099A48}" EndProject Global @@ -23,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {30B63942-DD1D-428A-BFD1-E603299B17B6} + EndGlobalSection EndGlobal diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index a113912..4de0ccf 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -535,10 +535,13 @@ LuaCreateSurfTmByPolygon( lua_State* L) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; - PolyLine PL ; // creo una polilinea a partire dai punti - for ( size_t i = 0 ; i < vPnt.size() ; ++ i) + PolyLine PL ; + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { + if ( ! vPnt[i].IsValid()) + break ; PL.AddUPoint( double( i), vPnt[i]) ; + } PL.Close() ; // creo la SurfTriMesh del poligono int nId = ExeCreateSurfTmByPolygon( nParentId, PL, nRefType) ; @@ -550,6 +553,42 @@ LuaCreateSurfTmByPolygon( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmByPolygonWithHoles( lua_State* L) +{ + // 2 o 3 parametri : ParentId, ptPs [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + PNTVECTOR vPnt ; + LuaCheckParam( L, 2, vPnt) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 3, nRefType) ; + LuaClearStack( L) ; + // creo un vettore di polilinee a partire dai punti + POLYLINEVECTOR vPL ; + vPL.push_back( {}) ; + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { + if ( vPnt[i].IsValid()) + vPL.back().AddUPoint( double( i), vPnt[i]) ; + else { + if ( ! vPL.empty()) + vPL.back().Close() ; + vPL.push_back( {}) ; + } + } + if ( ! vPL.empty()) + vPL.back().Close() ; + // creo la SurfTriMesh del poligono + int nId = ExeCreateSurfTmByPolygonWithHoles( nParentId, vPL, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmByFlatContour( lua_State* L) @@ -1403,6 +1442,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangle", LuaCreateSurfTmTriangle) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectangle", LuaCreateSurfTmRectangle) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByPolygon", LuaCreateSurfTmByPolygon) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByPolygonWithHoles", LuaCreateSurfTmByPolygonWithHoles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;