EgtExecutor 2.7f2 :

- Aggiunte funzioni per Offset di SurfTriMesh chiuse
- Migliorata la creazione di una TriMesh a partire da uno ZMap (con SaraP).
This commit is contained in:
Riccardo Elitropi
2025-06-16 11:37:23 +02:00
parent 092896750c
commit 362c845ed3
6 changed files with 160 additions and 22 deletions
+6 -22
View File
@@ -1813,28 +1813,12 @@ ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart)
// 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
int nCount = ( bOk ? pVZM->GetBlockCount() : 0) ;
for ( int i = 0 ; i < nCount && bOk ; ++ i) {
// recupero i triangoli del blocco
TRIA3DEXVECTOR vTria ;
pVZM->GetBlockTriangles( i, vTria) ;
for ( auto& Tria : vTria) {
// 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() ;
// chiudo eventuali fessure tra i triangoli
PtrOwner<ISurfTriMesh> pStm( StmFts.GetSurf()) ;
bOk = bOk && pStm->Repair() ;
// Recupero la TriMesh
PtrOwner<ISurfTriMesh> pStm ;
bOk = bOk && pStm.Set( pVZM->GetSurfTriMesh()) ;
bOk = bOk && ( ! IsNull( pStm)) ;
// la porto in locale al frame di destinazione
bOk = bOk && pStm->LocToLoc( frSou, frLoc) ;
// inserisco la superficie trimesh nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ;
ExeSetModified() ;
+52
View File
@@ -188,6 +188,58 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
return nNewId ;
}
//-------------------------------------------------------------------------------
int ExeCreateVolZmapFromSurfTmOffset( int nParentId, const INTVECTOR& vStmId, double dOffs, double dPrec)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
// recupero il riferimento locale
Frame3d frLoc ;
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
return GDB_ID_NULL ;
// definisco il vettore di puntatori esclusivi alle superfici TriMesh
CISURFTMPVECTOR vStm ;
// recupero le superfici
for ( size_t i = 0 ; i < vStmId.size() ; ++ i) {
int nStmId = vStmId[i] ;
// recupero il riferimento della regione
Frame3d frStm ;
if ( ! pGeomDB->GetGlobFrame( nStmId, frStm))
return GDB_ID_NULL ;
// recupero la superficie trimesh
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ;
if ( pStm == nullptr)
return GDB_ID_NULL ;
// ne faccio una copia
PtrOwner<ISurfTriMesh> pCopyStm( pStm->Clone()) ;
if ( IsNull( pCopyStm))
return false ;
// eseguo la trasformazione (viene eseguita solo se i riferimenti sono diversi)
pCopyStm->LocToLoc( frStm, frLoc) ;
// lo assegno al vettore di superfici
vStm.emplace_back( Release( pCopyStm)) ;
}
// creo lo Zmap nel riferimento intrinseco
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
bool bOk = ( ! IsNull( pVZM)) ;
bOk = bOk && pVZM->CreateFromTriMeshOffset( vStm, dOffs, dPrec) ;
// inserisco lo Zmap nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtVolZmapFromTriMesh(" + IdToString( nParentId) + "," +
ToString( vStmId) + "," +
ToString( dOffs) + "," +
ToString( dPrec) + "," ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
bool
ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId)
+56
View File
@@ -916,6 +916,62 @@ ExeSurfTmIntersect( int nId1, int nId2, bool bTwoColors)
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeSurfTmOffset( const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nDestGrpId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// se non ci sono superfici non c'è niente da calcolare
if ( vStmIds.empty())
return GDB_ID_NULL ;
// recupero il riferimento della prima superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( vStmIds[0], frSurf))
return GDB_ID_NULL ;
// recupero il riferimento di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return GDB_ID_NULL ;
// recupero le superfici TriMesh e le porto tutte in locale alla prima
CISURFTMPVECTOR vpStm ; vpStm.reserve( vStmIds.size()) ;
for ( int i = 0 ; i < int( vStmIds.size()) ; ++ i) {
// recupero la superficie TriMesh
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( vStmIds[i]) ;
if ( pGeoObj->GetType() != SRF_TRIMESH)
return GDB_ID_NULL ;
// recupero una copia della superficie TriMesh e la porto il locale
ISurfTriMesh* pStm = CloneSurfTriMesh( GetSurfTriMesh( pGeoObj)) ;
if ( pStm != nullptr) {
pStm->LocToLoc( frSurf, frDest) ;
vpStm.emplace_back( pStm) ;
}
}
// recupero la superficie risultante
int nId = GDB_ID_NULL ;
PtrOwner<ISurfTriMesh> pStmOffs( CreateSurfTriMeshesOffset( vpStm, dOffs, dLinTol)) ;
bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ;
if ( bOk)
nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pStmOffs)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtOffsetSurfTm(" + ToString( vStmIds) + "," +
ToString( dOffs) + "," +
ToString( dLinTol) + "," +
ToString( nDestGrpId) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) {
if ( vpStm[i] != nullptr)
delete vpStm[i] ;
vpStm[i] = nullptr ;
}
return nId ;
}
//----------------------------------------------------------------------------
static ISurfTriMesh*
MyCreateSubSurfTm( const ISurfTriMesh* pStm, const INTVECTOR& vTria, const INTVECTOR& vTria2)
BIN
View File
Binary file not shown.
+25
View File
@@ -140,6 +140,30 @@ LuaCreateVolZmapFromSurfTm( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateVolZmapFromSurfTmOffset( lua_State* L)
{
// 4 parametri : ParentId, StmIds, dOffs, dPrec
int nParentId ;
LuaCheckParam( L, 1, nParentId)
INTVECTOR vStmId ;
LuaCheckParam( L, 2, vStmId)
double dOffs ;
LuaCheckParam( L, 3, dOffs)
double dPrec ;
LuaCheckParam( L, 4, dPrec)
LuaClearStack( L) ;
// creo VZM da offset di superficie trimesh
int nId = ExeCreateVolZmapFromSurfTmOffset( nParentId, vStmId, dOffs, dPrec) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaUpdateVolZmapByAddingSurfTm( lua_State* L)
@@ -180,6 +204,7 @@ LuaInstallGdbCreateVol( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEmpty", LuaCreateVolZmapEmpty) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTmOffset", LuaCreateVolZmapFromSurfTmOffset) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtUniformZmap", LuaUniformVolZmap) ;
return bOk ;
+21
View File
@@ -421,6 +421,26 @@ LuaSurfTmIntersect( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSurfTmOffset( lua_State* L)
{
// 3 parametri : vIds, dOffs, dLinTol, nDestGrpId
INTVECTOR vIds ;
LuaCheckParam( L, 1, vIds)
double dOffs ;
LuaCheckParam( L, 2, dOffs)
double dLinTol ;
LuaGetParam( L, 3, dLinTol) ;
int nDestGrpId ;
LuaGetParam( L, 4, nDestGrpId) ;
LuaClearStack( L) ;
// interseco la prima superficie con la seconda
int nId = ExeSurfTmOffset( vIds, dOffs, dLinTol, nDestGrpId) ;
LuaSetParam( L, nId) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSurfTmSplit( lua_State* L)
@@ -641,6 +661,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmAdd", LuaSurfTmAdd) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtract", LuaSurfTmSubtract) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmIntersect", LuaSurfTmIntersect) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmOffs", LuaSurfTmOffset) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSplit", LuaSurfTmSplit) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCut", LuaSurfTmCut) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtractProjectedFacesOnFace", LuaSurfTmSubtractProjectedFacesOnFace) ;