Compare commits
1 Commits
ModelessDialog
...
Zmap
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c8a405478 |
+93
-8
@@ -53,7 +53,50 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim
|
|||||||
ExeSetModified() ;
|
ExeSetModified() ;
|
||||||
// se richiesto, salvo il comando Lua equivalente
|
// se richiesto, salvo il comando Lua equivalente
|
||||||
if ( IsCmdLog()) {
|
if ( IsCmdLog()) {
|
||||||
string sLua = "EgtVolZmapBox(" + IdToString( nParentId) + ",{" +
|
string sLua = "EgtVolZmapEmpty(" + IdToString( nParentId) + ",{" +
|
||||||
|
ToString( ptIni) + "}," +
|
||||||
|
ToString( dDimX) + "," +
|
||||||
|
ToString( dDimY) + "," +
|
||||||
|
ToString( dDimZ) + "," +
|
||||||
|
ToString( dPrec) + "," +
|
||||||
|
( bTriDex ? "true" : "false") + "," +
|
||||||
|
RefTypeToString( nRefType) + ")" +
|
||||||
|
" -- Id=" + ToString( nNewId) ;
|
||||||
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||||
|
}
|
||||||
|
// restituisco l'identificativo della nuova entità
|
||||||
|
return nNewId ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
int ExeCreateVolZmapEmpty( int nParentId, const Point3d& ptIni, double dDimX, double dDimY, double dDimZ,
|
||||||
|
double dPrec, bool bTriDex, int nRefType)
|
||||||
|
{
|
||||||
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||||
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||||
|
nParentId = AdjustId( nParentId) ;
|
||||||
|
// recupero il riferimento locale
|
||||||
|
Frame3d frLoc ;
|
||||||
|
bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||||
|
// porto in locale i punti
|
||||||
|
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||||
|
Point3d ptOnXL = GetPointLocal( pGeomDB, ptIni + X_AX, nRefType, frLoc) ;
|
||||||
|
Point3d ptOnYL = GetPointLocal( pGeomDB, ptIni + Y_AX, nRefType, frLoc) ;
|
||||||
|
// ne ricavo un riferimento intrinseco
|
||||||
|
Frame3d frBox ;
|
||||||
|
bOk = bOk && frBox.Set( ptIniL, ptOnXL, ptOnYL) ;
|
||||||
|
// creo lo Zmap nel suo riferimento intrinseco
|
||||||
|
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||||
|
bOk = bOk && ! IsNull( pVZM) ;
|
||||||
|
bOk = bOk && pVZM->CreateEmptyMap( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ;
|
||||||
|
// lo porto nel riferimento locale
|
||||||
|
bOk = bOk && pVZM->ToGlob( frBox) ;
|
||||||
|
// 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 = "EgtVolZmapEmpty(" + IdToString( nParentId) + ",{" +
|
||||||
ToString( ptIni) + "}," +
|
ToString( ptIni) + "}," +
|
||||||
ToString( dDimX) + "," +
|
ToString( dDimX) + "," +
|
||||||
ToString( dDimY) + "," +
|
ToString( dDimY) + "," +
|
||||||
@@ -118,8 +161,8 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
|
|||||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ;
|
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ;
|
||||||
bool bOk = ( pStm != nullptr) ;
|
bool bOk = ( pStm != nullptr) ;
|
||||||
// recupero il riferimento della trimesh
|
// recupero il riferimento della trimesh
|
||||||
Frame3d frStm ;
|
//Frame3d frStm ;
|
||||||
bOk = bOk && pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
//bOk = bOk && pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||||
// recupero il riferimento del gruppo di destinazione
|
// recupero il riferimento del gruppo di destinazione
|
||||||
Frame3d frDest ;
|
Frame3d frDest ;
|
||||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
|
||||||
@@ -128,19 +171,61 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
|
|||||||
bOk = bOk && ! IsNull( pVZM) ;
|
bOk = bOk && ! IsNull( pVZM) ;
|
||||||
bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex) ;
|
bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex) ;
|
||||||
// lo porto nel riferimento di destinazione
|
// lo porto nel riferimento di destinazione
|
||||||
bOk = bOk && pVZM->LocToLoc( frStm, frDest) ;
|
//bOk = bOk && pVZM->LocToLoc( frStm, frDest) ;
|
||||||
// inserisco lo Zmap nel DB
|
// inserisco lo Zmap nel DB
|
||||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ;
|
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ;
|
||||||
ExeSetModified() ;
|
ExeSetModified() ;
|
||||||
// se richiesto, salvo il comando Lua equivalente
|
// se richiesto, salvo il comando Lua equivalente
|
||||||
if ( IsCmdLog()) {
|
if ( IsCmdLog()) {
|
||||||
string sLua = "EgtVolZmapFromTriMesh(" + IdToString( nParentId) + "," +
|
string sLua = "UpdateVolZmapByAddingSurfTm(" + IdToString( nParentId) + "," +
|
||||||
ToString( nStmId) + "," +
|
IdToString( nStmId) + "," +
|
||||||
ToString( dPrec) + "," +
|
ToString( nStmId) + "," +
|
||||||
( bTriDex ? "true" : "false") + ")" +
|
ToString( dPrec) + "," +
|
||||||
|
( bTriDex ? "true" : "false") + ")" +
|
||||||
" -- Id=" + ToString( nNewId) ;
|
" -- Id=" + ToString( nNewId) ;
|
||||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||||
}
|
}
|
||||||
// restituisco l'identificativo della nuova entità
|
// restituisco l'identificativo della nuova entità
|
||||||
return nNewId ;
|
return nNewId ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
ExeUpdateVolZmapByAddingSurfTm( int nParentId, int nZmapId, int nStmId)
|
||||||
|
{
|
||||||
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||||
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||||
|
nParentId = AdjustId( nParentId) ;
|
||||||
|
// recupero lo Zmap
|
||||||
|
IVolZmap* pVolZmap = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ;
|
||||||
|
bool bOk = pVolZmap != nullptr ;
|
||||||
|
// recupero il riferimento dello Zmap
|
||||||
|
Frame3d frZmap ;
|
||||||
|
bOk = bOk && pGeomDB->GetGlobFrame( nZmapId, frZmap) ;
|
||||||
|
// recupero la trimesh
|
||||||
|
PtrOwner<ISurfTriMesh> pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ;
|
||||||
|
bOk = bOk && ( pStm != nullptr) ;
|
||||||
|
// recupero il riferimento della trimesh
|
||||||
|
Frame3d frStm ;
|
||||||
|
bOk = bOk && pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||||
|
// recupero il riferimento del gruppo di destinazione
|
||||||
|
Frame3d frDest ;
|
||||||
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
|
||||||
|
// porto lo Zmap e la trimesh nel riferimento della destinazione
|
||||||
|
bOk = bOk &&
|
||||||
|
pVolZmap->LocToLoc( frZmap, frDest) &&
|
||||||
|
pStm->LocToLoc( frStm, frDest) ;
|
||||||
|
// aggiorno lo Zmap
|
||||||
|
bOk = bOk && pVolZmap->AddSrfTm( pStm) ;
|
||||||
|
// riporto lo Zmap nel frame originario
|
||||||
|
bOk = bOk && pVolZmap->LocToLoc( frDest, frStm) ;
|
||||||
|
ExeSetModified() ;
|
||||||
|
// se richiesto, salvo il comando Lua equivalente
|
||||||
|
if ( IsCmdLog()) {
|
||||||
|
string sLua = "EgtVolZmapFromTriMesh(" + IdToString( nParentId) + "," +
|
||||||
|
ToString( nStmId) + ")" ;
|
||||||
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||||
|
}
|
||||||
|
// restituisco l'identificativo della nuova entità
|
||||||
|
return bOk ;
|
||||||
|
}
|
||||||
|
|||||||
+55
-1
@@ -54,6 +54,40 @@ LuaCreateVolZmapBox( lua_State* L)
|
|||||||
return 1 ;
|
return 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static int
|
||||||
|
LuaCreateVolZMapEmpty( lua_State* L)
|
||||||
|
{
|
||||||
|
// 6 o 7 o 8 parametri : ParentId, PtIni, dDimX, dDimY, dDimZ, dPrec [, bTriDex] [, nRefType]
|
||||||
|
int nParentId ;
|
||||||
|
LuaCheckParam( L, 1, nParentId)
|
||||||
|
Point3d ptIni ;
|
||||||
|
LuaCheckParam( L, 2, ptIni)
|
||||||
|
double dDimX ;
|
||||||
|
LuaCheckParam( L, 3, dDimX)
|
||||||
|
double dDimY ;
|
||||||
|
LuaCheckParam( L, 4, dDimY)
|
||||||
|
double dDimZ ;
|
||||||
|
LuaCheckParam( L, 5, dDimZ)
|
||||||
|
double dPrec ;
|
||||||
|
LuaCheckParam( L, 6, dPrec)
|
||||||
|
bool bTriDex = true ;
|
||||||
|
int nRefType = RTY_DEFAULT ;
|
||||||
|
if ( ! LuaGetParam( L, 7, bTriDex))
|
||||||
|
LuaGetParam( L, 7, nRefType) ;
|
||||||
|
else
|
||||||
|
LuaGetParam( L, 8, nRefType) ;
|
||||||
|
LuaClearStack( L) ;
|
||||||
|
// creo VZM da superficie trimesh
|
||||||
|
int nId = ExeCreateVolZmapEmpty( nParentId, ptIni, dDimX, dDimY, dDimZ, dPrec, bTriDex, nRefType) ;
|
||||||
|
// restituisco il risultato
|
||||||
|
if ( nId != GDB_ID_NULL)
|
||||||
|
LuaSetParam( L, nId) ;
|
||||||
|
else
|
||||||
|
LuaSetParam( L) ;
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
static int
|
static int
|
||||||
LuaCreateVolZmapByRegionExtrusion( lua_State* L)
|
LuaCreateVolZmapByRegionExtrusion( lua_State* L)
|
||||||
@@ -94,7 +128,7 @@ LuaCreateVolZmapFromSurfTm( lua_State* L)
|
|||||||
bool bTriDex = true ;
|
bool bTriDex = true ;
|
||||||
LuaGetParam( L, 4, bTriDex) ;
|
LuaGetParam( L, 4, bTriDex) ;
|
||||||
LuaClearStack( L) ;
|
LuaClearStack( L) ;
|
||||||
// creo VZM da superficie trimesh
|
// creo VZM da superficie trimesh
|
||||||
int nId = ExeCreateVolZmapFromSurfTm( nParentId, nStmId, dPrec, bTriDex) ;
|
int nId = ExeCreateVolZmapFromSurfTm( nParentId, nStmId, dPrec, bTriDex) ;
|
||||||
// restituisco il risultato
|
// restituisco il risultato
|
||||||
if ( nId != GDB_ID_NULL)
|
if ( nId != GDB_ID_NULL)
|
||||||
@@ -104,13 +138,33 @@ LuaCreateVolZmapFromSurfTm( lua_State* L)
|
|||||||
return 1 ;
|
return 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static int
|
||||||
|
LuaUpdateVolZmapByAddingSurfTm( lua_State* L)
|
||||||
|
{
|
||||||
|
// 3 ParentId, ZmapId, StmId
|
||||||
|
int nParentId ;
|
||||||
|
LuaCheckParam( L, 1, nParentId)
|
||||||
|
int nZmapId ;
|
||||||
|
LuaCheckParam( L, 2, nZmapId)
|
||||||
|
int nStmId ;
|
||||||
|
LuaCheckParam( L, 3, nStmId)
|
||||||
|
LuaClearStack( L) ;
|
||||||
|
// creo VZM da superficie trimesh
|
||||||
|
bool bOk = ExeUpdateVolZmapByAddingSurfTm( nParentId, nZmapId, nStmId) ;
|
||||||
|
LuaSetParam( L, bOk) ;
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
LuaInstallGdbCreateVol( LuaMgr& luaMgr)
|
LuaInstallGdbCreateVol( LuaMgr& luaMgr)
|
||||||
{
|
{
|
||||||
bool bOk = ( &luaMgr != nullptr) ;
|
bool bOk = ( &luaMgr != nullptr) ;
|
||||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ;
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ;
|
||||||
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEmpty", LuaCreateVolZMapEmpty) ;
|
||||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ;
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ;
|
||||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ;
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ;
|
||||||
|
bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm) ;
|
||||||
return bOk ;
|
return bOk ;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user