EgtExecutor :

- aggiunte funzioni Exe e Lua VolZmapResolution e VolZmapChangeResolution.
This commit is contained in:
Dario Sassi
2020-09-18 16:18:53 +00:00
parent 1497d61024
commit 04f6923aff
4 changed files with 216 additions and 138 deletions
+172
View File
@@ -16,10 +16,14 @@
#include "EXE.h"
#include "EXE_Const.h"
#include "EXE_Macro.h"
#include "AuxTools.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
@@ -36,6 +40,20 @@ ExeVolZmapVolume( int nId, double& dVol)
return ( pVZM != nullptr && pVZM->GetVolume( dVol)) ;
}
//----------------------------------------------------------------------------
int
ExeVolZmapResolution( int nId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, 0)
// recupero il solido Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
if ( pVZM == nullptr)
return 0 ;
// ne restituisco la risoluzione grafica
return pVZM->GetResolution() ;
}
//----------------------------------------------------------------------------
int
ExeVolZmapPartCount( int nId)
@@ -65,6 +83,38 @@ ExeVolZmapPartVolume( int nId, int nPart, double& dVol)
return ( pVZM != nullptr && pVZM->GetPartVolume( nPart, dVol)) ;
}
//-----------------------------------------------------------------------------
bool
ExeVolZmapGetPartBBox( int nId, int nPart, int nFlag, BBox3d& b3Box)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero lo Zmap
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
if ( pVZM == nullptr)
return false ;
// recupero il bounding box della parte dell'oggetto in locale
return pVZM->GetPartLocalBBox( nPart, b3Box, nFlag) ;
}
//-----------------------------------------------------------------------------
bool
ExeVolZmapGetPartBBoxGlob( int nId, int nPart, int nFlag, BBox3d& b3Box)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero lo Zmap
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
if ( pVZM == nullptr)
return false ;
// recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ;
if ( nId != GDB_ID_ROOT && ! pGeomDB->GetGroupGlobFrame( pGeomDB->GetParentId( nId), frGlob))
return false ;
// recupero il bounding box della parte dell'oggetto in globale
return pVZM->GetPartBBox( nPart, frGlob, b3Box, nFlag) ;
}
//----------------------------------------------------------------------------
bool
ExeVolZmapGetPartMinDist( int nId, const Point3d ptNear, int nRefType, int& nPart)
@@ -88,3 +138,125 @@ ExeVolZmapGetPartMinDist( int nId, const Point3d ptNear, int nRefType, int& nPar
nPart = pVZM->GetPartMinDistFromPoint( ptNearL) ;
return ( nPart >= 0) ;
}
//-------------------------------------------------------------------------------
int
ExeCopyVolZmapPart( int nId, int nPart, int nDestGrpId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero lo Zmap
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
ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType, bool bExact,
double& dInLen, double& dOutLen)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero il riferimento locale
Frame3d frLoc ;
bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto e il vettore
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
Vector3d vtVL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ;
// recupero lo Zmap e calcolo profondità
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pVZM != nullptr && pVZM->GetDepth( ptP, vtDir, dInLen, dOutLen, bExact)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtVolZmapGetDepth(" + IdToString( nId) + ",{" +
ToString( ptP) + "},{" +
ToString( vtDir) + "}," +
( bExact ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) + "," + ToString( dInLen) + "," + ToString( dOutLen) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeVolZmapGetEdges( int nId, int nDestGrpId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero lo Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pVZM != nullptr) ;
// recupero il riferimento del solido
Frame3d frSurf ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ;
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
// ne determino gli spigoli
ICURVEPOVECTOR vpCurve ;
bOk = bOk && pVZM->GetEdges( vpCurve) ;
// inserisco gli spigoli come curve nel DB
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
// lo porto nel riferimento destinazione
bOk = bOk && vpCurve[i]->LocToLoc( frSurf, frDest) ;
// lo inserisco nel DB geometrico
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vpCurve[i])) : GDB_ID_NULL) ;
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
// copio il materiale
bOk = bOk && pGeomDB->CopyMaterial( nId, nNewId) ;
// 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 = "EgtGetSurfTmSilhouette(" + 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 ;
}
+8 -138
View File
@@ -98,7 +98,7 @@ ExeExplodeVolume( int nId, int* pnCount)
//-----------------------------------------------------------------------------
bool
ExeVolZmapGetPartBBox( int nId, int nPart, int nFlag, BBox3d& b3Box)
ExeVolZmapChangeResolution( int nId, int nNewRes)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -106,68 +106,18 @@ ExeVolZmapGetPartBBox( int nId, int nPart, int nFlag, BBox3d& b3Box)
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
if ( pVZM == nullptr)
return false ;
// recupero il bounding box della parte dell'oggetto in locale
return pVZM->GetPartLocalBBox( nPart, b3Box, nFlag) ;
}
//-----------------------------------------------------------------------------
bool
ExeVolZmapGetPartBBoxGlob( int nId, int nPart, int nFlag, BBox3d& b3Box)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero lo Zmap
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
if ( pVZM == nullptr)
return false ;
// recupero il riferimento globale del gruppo cui appartiene
Frame3d frGlob ;
if ( nId != GDB_ID_ROOT && ! pGeomDB->GetGroupGlobFrame( pGeomDB->GetParentId( nId), frGlob))
return false ;
// recupero il bounding box della parte dell'oggetto in globale
return pVZM->GetPartBBox( nPart, frGlob, b3Box, nFlag) ;
}
//-------------------------------------------------------------------------------
int
ExeCopyVolZmapPart( int nId, int nPart, int nDestGrpId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero lo Zmap
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 ;
// cambio la risoluzione (rapporto Voxel/Dexel, valori ammessi 1 e 2)
bool bOk = pVZM->ChangeResolution( nNewRes) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "ExeCopyVolZmapPart(" + ToString( nId) + "," +
ToString( nPart) + "," +
ToString( nDestGrpId) + ")" +
" -- Id=" + ToString( nVZMId) ;
string sLua = "EgtVolZmapChangeResolution(" + ToString( nId) + "," +
ToString( nNewRes) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return nVZMId ;
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
@@ -502,86 +452,6 @@ ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, const
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType, bool bExact,
double& dInLen, double& dOutLen)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero il riferimento locale
Frame3d frLoc ;
bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto e il vettore
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
Vector3d vtVL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ;
// recupero lo Zmap e calcolo profondità
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pVZM != nullptr && pVZM->GetDepth( ptP, vtDir, dInLen, dOutLen, bExact)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtVolZmapGetDepth(" + IdToString( nId) + ",{" +
ToString( ptP) + "},{" +
ToString( vtDir) + "}," +
( bExact ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) + "," + ToString( dInLen) + "," + ToString( dOutLen) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeVolZmapGetEdges( int nId, int nDestGrpId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero lo Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pVZM != nullptr) ;
// recupero il riferimento del solido
Frame3d frSurf ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ;
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
// ne determino gli spigoli
ICURVEPOVECTOR vpCurve ;
bOk = bOk && pVZM->GetEdges( vpCurve) ;
// inserisco gli spigoli come curve nel DB
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
// lo porto nel riferimento destinazione
bOk = bOk && vpCurve[i]->LocToLoc( frSurf, frDest) ;
// lo inserisco nel DB geometrico
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vpCurve[i])) : GDB_ID_NULL) ;
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
// copio il materiale
bOk = bOk && pGeomDB->CopyMaterial( nId, nNewId) ;
// 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 = "EgtGetSurfTmSilhouette(" + 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 ;
}
//-------------------------------------------------------------------------------
bool
ExeCutVolZmapPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, int nRefType)
+18
View File
@@ -36,6 +36,23 @@ LuaVolZmapVolume( lua_State* L)
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaVolZmapResolution( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// recupero la risoluzione grafica del solido Zmap
int nRes = ExeVolZmapResolution( nId) ;
if ( nRes > 0)
LuaSetParam( L, nRes) ;
else
LuaSetParam( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaVolZmapPartCount( lua_State* L)
@@ -225,6 +242,7 @@ LuaInstallGdbGetVol( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapResolution", LuaVolZmapResolution) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetPartBBox", LuaVolZmapGetPartBBox) ;
+18
View File
@@ -39,6 +39,23 @@ LuaExplodeVolume( lua_State* L)
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaVolZmapChangeResolution( lua_State* L)
{
// 2 parametri : Id, nNewRes
int nId ;
LuaCheckParam( L, 1, nId)
int nNewRes ;
LuaCheckParam( L, 2, nNewRes)
LuaClearStack( L) ;
// cambio la risoluzione
bool bOk = ExeVolZmapChangeResolution( nId, nNewRes) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaRemoveVolZmapPart( lua_State* L)
@@ -332,6 +349,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapChangeResolution", LuaVolZmapChangeResolution) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ;