diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index eb3f15f..41ca0f9 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -186,7 +186,7 @@ ExeImportCsf( const string& sFilePath) //----------------------------------------------------------------------------- bool -ExeImportBtl( const string& sFilePath, bool bFlatPos) +ExeImportBtl( const string& sFilePath, bool bFlatPos, bool bSpecialTrim) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) @@ -196,14 +196,15 @@ ExeImportBtl( const string& sFilePath, bool bFlatPos) PtrOwner pImpBtl( MyCreateImportBtl()) ; bOk = bOk && ! IsNull( pImpBtl) ; // eseguo l'importazione (direttamente nella radice) - bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, bFlatPos) ; + bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, bFlatPos, bSpecialTrim) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "'," + - ( bFlatPos ? "true" : "false") + ")" + + ( bFlatPos ? "true" : "false") + "," + + ( bSpecialTrim ? "true" : "false") + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index 9ea5d52..d84cda1 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -367,6 +367,59 @@ ExeExtractSurfFrChunkLoops( int nId, int nChunk, int nDestGrpId, int* pnCount) return nFirstId ; } +//---------------------------------------------------------------------------- +int +ExeExtractSurfTmLoops( int nId, int nDestGrpId, int* pnCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la superficie TriMesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pStm != nullptr) ; + // recupero il riferimento della superficie + Frame3d frSurf ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ; + // recupero il riferimento di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ; + // recupero i loop come polilinee + POLYLINEVECTOR vPL ; + bOk = bOk && pStm->GetLoops( vPL) ; + // dalle polilinee creo le curve e le inserisco nel DB + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + for ( size_t i = 0 ; i < vPL.size() ; ++ i) { + // creo la curva + PtrOwner pCrvCompo( CreateCurveComposite()) ; + bOk = bOk && pCrvCompo->FromPolyLine( vPL[i]) ; + // la porto nel riferimento destinazione + bOk = bOk && pCrvCompo->LocToLoc( frSurf, frDest) ; + // la inserisco nel DB geometrico + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) : GDB_ID_NULL) ; + bOk = bOk && ( nNewId != GDB_ID_NULL) ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( bOk && nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + if ( bOk) + ++ nCount ; + } + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtExtractSurfTmLoops(" + ToString( nId) + "," + + ToString( nDestGrpId) + ")" + + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; +} + //---------------------------------------------------------------------------- int ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 02b2b02..421fb0b 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index 79ccc2e..966f098 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -89,14 +89,16 @@ LuaImportCsf( lua_State* L) static int LuaImportBtl( lua_State* L) { - // 1 o 2 parametri : path del file da importare, falg per mettere di piatto + // 1,2 o 3 parametri : path del file da importare, flag per mettere di piatto, flag per trim speciale pareti string sFilePath ; LuaCheckParam( L, 1, sFilePath) bool bFlatPos = false ; LuaGetParam( L, 2, bFlatPos) ; + bool bSpecialTrim = false ; + LuaGetParam( L, 3, bSpecialTrim) ; LuaClearStack( L) ; // apro il file - bool bOk = ExeImportBtl( sFilePath, bFlatPos) ; + bool bOk = ExeImportBtl( sFilePath, bFlatPos, bSpecialTrim) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index e6b0571..16ed63a 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -147,6 +147,28 @@ LuaExtractSurfFrChunkLoops( lua_State* L) return 2 ; } +//---------------------------------------------------------------------------- +static int +LuaExtractSurfTmLoops( lua_State* L) +{ + // 2 parametri : nId2, nDestGrpId + int nId ; + LuaCheckParam( L, 1, nId) + int nDestGrpId ; + LuaCheckParam( L, 2, nDestGrpId) + LuaClearStack( L) ; + // recupero i contorni della superficie + int nCount ; + int nNewId = ExeExtractSurfTmLoops( nId, nDestGrpId, &nCount) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nCount) ; + return 2 ; +} + //---------------------------------------------------------------------------- static int LuaExtractSurfTmFacetLoops( lua_State* L) @@ -159,7 +181,7 @@ LuaExtractSurfTmFacetLoops( lua_State* L) int nDestGrpId ; LuaCheckParam( L, 3, nDestGrpId) LuaClearStack( L) ; - // eseguo inversione superfici + // recupero i contorni della faccetta della superficie int nCount ; int nNewId = ExeExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, &nCount) ; // restituisco il risultato @@ -183,6 +205,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfFrChunkLoops", LuaExtractSurfFrChunkLoops) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmLoops", LuaExtractSurfTmLoops) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ; return bOk ; }