From 784e53f580a5f802dfafad9d27c53eedbee99316 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 27 Mar 2025 19:19:33 +0100 Subject: [PATCH] EgtExecutor : - aggiunta funzione exe e lua CreateSurfTmByPolygon. --- EXE_GdbCreateSurf.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ LUA_GdbCreateSurf.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 1943cb1..6fcd843 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1038,6 +1038,47 @@ ExeCreateSurfTmRectangle( int nParentId, const Point3d& ptO, const Point3d& ptL, return nNewId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmByPolygon( int nParentId, const PolyLine& PL, 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->CreateByFlatContour( PL) ; + // 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 ; + Point3d ptP ; + if ( PL.GetFirstPoint( ptP)) + sPnt += "{" + ToString( ptP) + "}" ; + while ( PL.GetNextPoint( ptP)) + sPnt += ",{" + ToString( ptP) + "}" ; + string sLua = "EgtSurfTmByPolygon(" + 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/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 14d2542..a113912 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -523,6 +523,33 @@ LuaCreateSurfTmRectangle( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmByPolygon( 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) ; + PolyLine PL ; + // creo una polilinea a partire dai punti + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) + PL.AddUPoint( double( i), vPnt[i]) ; + PL.Close() ; + // creo la SurfTriMesh del poligono + int nId = ExeCreateSurfTmByPolygon( nParentId, PL, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmByFlatContour( lua_State* L) @@ -1375,6 +1402,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmConeFrustum", LuaCreateSurfTmConeFrustum) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangle", LuaCreateSurfTmTriangle) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectangle", LuaCreateSurfTmRectangle) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByPolygon", LuaCreateSurfTmByPolygon) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;