EgtExecutor 1.8j2 :
- aggiunta fiunzione Exe e Lua CreateSurfTmByVolZmap - aggiunte funzioni Exe e Lua CopyVolZmapPart e RemoveVolZmapPart - aggiunte funzioni Exe e Lua SurfArea, SurfVolume, VolZmapVolume e VolZmapPartVolume.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkVolZmap.h"
|
||||
#include "/EgtDev/Include/EgkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLocal.h"
|
||||
@@ -1091,3 +1092,64 @@ ExeCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase)
|
||||
// restituisco il risultato
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero il solido VolZmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// se richiesta superficie di una sola parte
|
||||
PtrOwner<IVolZmap> pPart ;
|
||||
if ( bOk && nPart >= 0) {
|
||||
pPart.Set( pVZM->ClonePart( nPart)) ;
|
||||
bOk = ! IsNull( pPart) ;
|
||||
pVZM = pPart ;
|
||||
}
|
||||
// recupero il riferimento del solido sorgente
|
||||
Frame3d frSou ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nZmapId, frSou) ;
|
||||
// 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
|
||||
INTVECTOR vnModif ;
|
||||
TRIA3DLISTVECTOR vlTria ;
|
||||
int nCount = ( bOk ? pVZM->GetBlockCount() : 0) ;
|
||||
( bOk ? pVZM->GetTriangles( false, vnModif, vlTria) : false) ;
|
||||
for ( int i = 0 ; i < nCount && bOk ; ++ i) {
|
||||
// se blocco non modificato, vado oltre
|
||||
if ( vnModif[i] < 0)
|
||||
continue ;
|
||||
for ( auto& Tria : vlTria[vnModif[i]]) {
|
||||
// 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() ;
|
||||
// inserisco la superficie trimesh nel DB
|
||||
PtrOwner<ISurfTriMesh> pStm( StmFts.GetSurf()) ;
|
||||
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 sLua = "EgtSurfTmByVolZmap(" + IdToString( nParentId) + "," +
|
||||
IdToString( nZmapId) + "," +
|
||||
IdToString( nPart) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,69 @@ ExeExplodeVolume( int nId, int* pnCount)
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCopyVolZmapPart( int nId, int nPart, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero lo Zmap e copio la parte indicata
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pVZM == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il suo riferimento globale
|
||||
Frame3d frVZM ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frVZM))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo di destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// copio la parte connessa
|
||||
PtrOwner<IVolZmap> pPart( pVZM->ClonePart( nPart)) ;
|
||||
if ( IsNull( pPart))
|
||||
return GDB_ID_NULL ;
|
||||
pPart->LocToLoc( frVZM, frDest) ;
|
||||
// inserisco nel DB
|
||||
int nVZMId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nDestGrpId, GDB_LAST_SON, Release( pPart)) ;
|
||||
if ( nVZMId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nVZMId))
|
||||
return GDB_ID_NULL ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "ExeCopyVolZmapPart(" + ToString( nId) + "," +
|
||||
ToString( nPart) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nVZMId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return nVZMId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeRemoveVolZmapPart( int nId, int nPart)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero lo Zmap e rimuovo la parte indicata
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pVZM != nullptr && pVZM->RemovePart( nPart)) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtRemoveVolZmapPart(" + ToString( nId) + "," +
|
||||
ToString( nPart) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapSetStdTool( int nId, const string& sToolName, double dLen, double dDiam, double dCornR)
|
||||
|
||||
@@ -904,6 +904,36 @@ ExeCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfArea( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'area
|
||||
return ( pSurf != nullptr && pSurf->GetArea( dArea)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfVolume( int nId, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'eventuale volume (se è chiusa)
|
||||
return ( pSurf != nullptr && pSurf->GetVolume( dVol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
@@ -1106,6 +1136,21 @@ ExeSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool& bAdjac, Poi
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapVolume( int nId, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero il solido Zmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco il volume
|
||||
return ( pVZM != nullptr && pVZM->GetVolume( dVol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeVolZmapPartCount( int nId)
|
||||
@@ -1120,6 +1165,21 @@ ExeVolZmapPartCount( int nId)
|
||||
return pVZM->GetPartCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapPartVolume( int nId, int nPart, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero il solido Zmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
// restituisco il volume della eventuale parte richiesta
|
||||
return ( pVZM != nullptr && pVZM->GetPartVolume( nPart, dVol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
|
||||
Binary file not shown.
@@ -580,6 +580,29 @@ LuaCreateSurfTmBySewing( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfTmByVolZmap( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : ParentId, ZmapId [, nPart]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nZmapId ;
|
||||
LuaCheckParam( L, 2, nZmapId)
|
||||
int nPart = -1 ;
|
||||
if ( lua_gettop( L) >= 3)
|
||||
LuaCheckParam( L, 3, nPart) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM partendo da solido Zmap
|
||||
int nId = ExeCreateSurfTmByVolZmap( nParentId, nZmapId, nPart) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
@@ -606,5 +629,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,45 @@ LuaExplodeVolume( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopyVolZmapPart( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nPart(0-based), nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// copio la parte indicata nel gruppo specificato
|
||||
int nNewId = ExeCopyVolZmapPart( nId, nPart, nDestGrpId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRemoveVolZmapPart( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nPart(0-based)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
LuaClearStack( L) ;
|
||||
// rimuovo la parte indicata
|
||||
bool bOk = ExeRemoveVolZmapPart( nId, nPart) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapSetStdTool( lua_State* L)
|
||||
@@ -245,6 +284,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyVolZmapPart", LuaCopyVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ;
|
||||
|
||||
@@ -581,6 +581,40 @@ LuaCurveCompoCenter( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area
|
||||
double dArea ;
|
||||
if ( ExeSurfArea( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume (se chiusa)
|
||||
double dVol ;
|
||||
if ( ExeSurfVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrNormVersor( lua_State* L)
|
||||
@@ -805,6 +839,23 @@ LuaSurfTmFacetsContact( lua_State* L)
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartCount( lua_State* L)
|
||||
@@ -822,6 +873,25 @@ LuaVolZmapPartCount( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartVolume( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nPartInd (0-based)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPartInd ;
|
||||
LuaCheckParam( L, 2, nPartInd)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapPartVolume( nId, nPartInd, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextNormVersor( lua_State* L)
|
||||
@@ -875,6 +945,8 @@ LuaInstallGeoSnap( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcDeltaN", LuaArcDeltaN) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcNormVersor", LuaArcNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoCenter", LuaCurveCompoCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfArea", LuaSurfArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfVolume", LuaSurfVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrNormVersor", LuaSurfFrNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkCount", LuaSurfFrChunkCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkSimpleClassify", LuaSurfFrChunkSimpleClassify) ;
|
||||
@@ -885,7 +957,9 @@ LuaInstallGeoSnap( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextNormVersor", LuaTextNormVersor) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user