EgtExecutor 2.5j1 :

- aggiunta funzione Exe e Lua SubtractProjectedFacesOnStmFace
- aggiunta di un parametro opzionale per Exe e Lua GetSilhouette.
This commit is contained in:
Riccardo Elitropi
2023-10-04 12:19:48 +02:00
parent 2b65121551
commit 206f3bdf61
5 changed files with 112 additions and 5 deletions
+5 -3
View File
@@ -834,7 +834,8 @@ ExeExtractSurfTmLoops( int nId, int nDestGrpId, int* pnCount)
//----------------------------------------------------------------------------
int
ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDestGrpId, int nRefType, int* pnCount)
ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDestGrpId, int nRefType,
int* pnCount, bool bAllTria)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -851,7 +852,7 @@ ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDest
Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frSurf) ;
// recupero i loop come polilinee
POLYLINEVECTOR vPL ;
bOk = bOk && pStm->GetSilhouette( vtDirL, dToler, vPL) ;
bOk = bOk && pStm->GetSilhouette( vtDirL, dToler, vPL, bAllTria) ;
// dalle polilinee creo le curve e le inserisco nel DB
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
@@ -879,7 +880,8 @@ ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDest
string sLua = "EgtGetSurfTmSilhouette(" + ToString( nId) + ",{" +
ToString( vtDir) + "}," +
ToString( nDestGrpId) + "," +
RefTypeToString( nRefType) + ")" +
RefTypeToString( nRefType) + "," +
ToString( bAllTria) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
+68
View File
@@ -29,8 +29,10 @@
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkSubtractProjectedFacesOnStmFace.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
@@ -924,3 +926,69 @@ ExeSurfTmCut( int nId, int nCutterId, bool bInVsOut, bool bSaveOnEq)
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExeSubtractProjectedFacesOnStmFace( int nSurfId, int nFaceInd, int nDestGrpId,
INTVECTOR vSurfsId, INTVECTOR vSurfFacesInd, bool bOCFlag,
int& nNewId, bool& bExistProjection, int& nNewFaceNbr)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// controllo dimensione dei vettori passati come parametri
if ( int( vSurfsId.size()) != int( vSurfFacesInd.size()))
return false ;
// recupero la superficie TriMesh su cui proiettare
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ;
if ( pStm == nullptr)
return false ;
// recupero il riferimento della superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( nSurfId, frSurf))
return false ;
// recupero il riferimento del gruppo di destinazione
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return false ;
// costruzione vettori di superfici e indici delle facce per proiezione
ISURFTMPOVECTOR vpStmOthers ;
vector<SurfLocal> vSurfCLoc ;
// recupero le altre superfici e le porto nel sistema di riferimento della prima
for ( int i = 0 ; i < int( vSurfsId.size()) ; ++ i) {
if ( pGeomDB->GetGeoType( vSurfsId[i]) != SRF_TRIMESH)
return false ;
vSurfCLoc.emplace_back( pGeomDB, vSurfsId[i], frSurf) ;
const ISurfTriMesh* pStmCurr = GetSurfTriMesh( vSurfCLoc.back().Get()) ;
vpStmOthers.emplace_back( pStmCurr->Clone()) ;
}
// eseguo la proiezione
ISurfTriMesh* pStmRes = nullptr ;
bool bOk = SubtractProjectedFacesOnStmFace( *pStm, nFaceInd, vpStmOthers, vSurfFacesInd, bOCFlag,
bExistProjection, pStmRes, nNewFaceNbr) ;
if ( ! bOk)
delete( pStmRes) ;
nNewId = GDB_ID_NULL ;
if ( bOk && pStmRes != nullptr) {
// porto nel sistema di riferimento destinazione
pStmRes->LocToLoc( frSurf, frDest) ;
// la inserisco nel DB geometrico
nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pStmRes) ;
if ( nNewId == GDB_ID_NULL)
return false ;
ExeSetModified() ;
}
if ( IsCmdLog()) {
string sLua = "EgtSubtractProjectedFacesOnStmFace(" + ToString( nSurfId) + "," +
ToString( nFaceInd) + "," +
ToString( nDestGrpId) + "," +
ToString( vSurfsId) + "," +
ToString( vSurfFacesInd) + "," +
ToString( bOCFlag) + ")" +
" -- Ok=" + ToString( bOk) + " Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
BIN
View File
Binary file not shown.
+4 -2
View File
@@ -723,7 +723,7 @@ LuaExtractSurfTmLoops( lua_State* L)
static int
LuaGetSurfTmSilhouette( lua_State* L)
{
// 4 o 5 parametri : nId, vtDir, dToler, nDestGrpId [, nRefType]
// 4 o 5 o 6 parametri : nId, vtDir, dToler, nDestGrpId [, nRefType] [, bAllTria]
int nId ;
LuaCheckParam( L, 1, nId)
Vector3d vtDir ;
@@ -734,10 +734,12 @@ LuaGetSurfTmSilhouette( lua_State* L)
LuaCheckParam( L, 4, nDestGrpId)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 5, nRefType) ;
bool bAllTria = false ;
LuaGetParam( L, 6, bAllTria) ;
LuaClearStack( L) ;
// recupero i contorni della superficie
int nCount = 0 ;
int nNewId = ExeGetSurfTmSilhouette( nId, vtDir, dToler, nDestGrpId, nRefType, &nCount) ;
int nNewId = ExeGetSurfTmSilhouette( nId, vtDir, dToler, nDestGrpId, nRefType, &nCount, bAllTria) ;
// restituisco il risultato
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
+35
View File
@@ -388,6 +388,40 @@ LuaSurfTmCut( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSubtractProjectedFacesOnStmFace( lua_State* L)
{
// 3 o 4 o 5 o 6 parametri : nSurfId, nFaceInd, nDestGrpId [, vSurfsId] [, vSurfFacesInd] [, bOCFlag]
int nSurfId ;
LuaCheckParam( L, 1, nSurfId) ;
int nFaceInd ;
LuaCheckParam( L, 2, nFaceInd) ;
int nDestGrpId ;
LuaCheckParam( L, 3, nDestGrpId) ;
INTVECTOR vSurfsId ;
LuaGetParam( L, 4, vSurfsId) ;
INTVECTOR vSurfFacesInd ;
LuaGetParam( L, 5, vSurfFacesInd) ;
bool bOCFlag = true ;
LuaGetParam( L, 6, bOCFlag) ;
LuaClearStack( L) ;
// sottraggo alla faccia scelta la proiezione delle altre
int nNewId = GDB_ID_NULL;
bool bExistProjection = false ;
int nNewFaceNbr = -1 ;
bool bOk = ExeSubtractProjectedFacesOnStmFace( nSurfId, nFaceInd, nDestGrpId, vSurfsId, vSurfFacesInd,
bOCFlag, nNewId, bExistProjection, nNewFaceNbr) ;
LuaSetParam( L, bOk) ;
LuaSetParam( L, bExistProjection) ;
LuaSetParam( L, nNewFaceNbr) ;
if ( nNewId != GDB_ID_NULL)
LuaSetParam( L, nNewId) ;
else
LuaSetParam( L) ;
return 4 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbModifySurf( LuaMgr& luaMgr)
@@ -413,5 +447,6 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmResetTwoColors", LuaSurfTmResetTwoColors) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSplit", LuaSurfTmSplit) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCut", LuaSurfTmCut) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSubtractProjectedFacesOnStmFace", LuaSubtractProjectedFacesOnStmFace) ;
return bOk ;
}