4a34b2e45d
- aggiunto controllo sulla dimensione alle funzioni di creazione ZMap per versioni a 32Bit.
227 lines
9.7 KiB
C++
227 lines
9.7 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2016-2016
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_GdbCreateVol.cpp Data : 27.10.16 Versione : 1.6v7
|
|
// Contenuto : Funzioni di creazione solidi del DB geometrico per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 27.10.16 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "AuxTools.h"
|
|
#include "GeoTools.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGkVolZmap.h"
|
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateVolZmap( 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) ;
|
|
if ( bOk) {
|
|
int nError = 0 ;
|
|
bOk = pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ;
|
|
if ( ! bOk) {
|
|
if ( nError == 1)
|
|
ExeOutLog( "EgtVolZmapBox too big for a 32-bit system") ;
|
|
else
|
|
ExeOutLog( "EgtVolZmapBox error number : " + ToString( nError)) ;
|
|
}
|
|
}
|
|
// 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 = "EgtVolZmapBox(" + 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) ;
|
|
if ( bOk) {
|
|
int nError = 0 ;
|
|
bOk = pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ;
|
|
if ( ! bOk) {
|
|
if ( nError == 1)
|
|
ExeOutLog( "EgtVolZmapEmpty too big for a 32-bit system") ;
|
|
else
|
|
ExeOutLog( "EgtVolZmapEmpty error number : " + ToString( nError)) ;
|
|
}
|
|
}
|
|
// 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( 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
|
|
ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, double dPrec, bool bTriDex)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero la regione
|
|
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nSfrId)) ;
|
|
bool bOk = ( pSfr != nullptr) ;
|
|
// recupero il riferimento della regione
|
|
Frame3d frSfr ;
|
|
bOk = bOk && pGeomDB->GetGlobFrame( nSfrId, frSfr) ;
|
|
// recupero il riferimento del gruppo di destinazione
|
|
Frame3d frDest ;
|
|
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
|
|
// creo lo Zmap nel suo riferimento intrinseco
|
|
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
|
bOk = bOk && ! IsNull( pVZM) ;
|
|
if ( bOk) {
|
|
int nError = 0 ;
|
|
bOk = pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex, &nError) ;
|
|
if ( ! bOk) {
|
|
if ( nError == 1)
|
|
ExeOutLog( "EgtVolZmapByRegionExtrusion too big for a 32-bit system") ;
|
|
else
|
|
ExeOutLog( "EgtVolZmapByRegionExtrusion error number : " + ToString( nError)) ;
|
|
}
|
|
}
|
|
// lo porto nel riferimento di destinazione
|
|
bOk = bOk && pVZM->LocToLoc( frSfr, frDest) ;
|
|
// 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 = "EgtVolZmapByRegionExtrusion(" + IdToString( nParentId) + "," +
|
|
ToString( nSfrId) + "," +
|
|
ToString( dDimZ) + "," +
|
|
ToString( dPrec) + "," +
|
|
( bTriDex ? "true" : "false") + ")" +
|
|
" -- Id=" + ToString( nNewId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo della nuova entità
|
|
return nNewId ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
int
|
|
ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDex, double dExtraBox)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
|
nParentId = AdjustId( nParentId) ;
|
|
// recupero la trimesh
|
|
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ;
|
|
bool 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) ;
|
|
// creo lo Zmap nel suo riferimento intrinseco
|
|
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
|
bOk = bOk && ! IsNull( pVZM) ;
|
|
if ( bOk) {
|
|
int nError = 0 ;
|
|
bOk = pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex, dExtraBox, &nError) ;
|
|
if ( ! bOk) {
|
|
if ( nError == 1)
|
|
ExeOutLog( "EgtVolZmapFromSurfTm too big for a 32-bit system") ;
|
|
else
|
|
ExeOutLog( "EgtVolZmapFromSurfTm error number : " + ToString( nError)) ;
|
|
}
|
|
}
|
|
// lo porto nel riferimento di destinazione
|
|
bOk = bOk && pVZM->LocToLoc( frStm, frDest) ;
|
|
// 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 = "EgtVolZmapFromSurfTm(" + IdToString( nParentId) + "," +
|
|
ToString( nStmId) + "," +
|
|
ToString( dPrec) + "," +
|
|
( bTriDex ? "true" : "false") + "," +
|
|
ToString( dExtraBox) + ")" +
|
|
" -- Id=" + ToString( nNewId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco l'identificativo della nuova entità
|
|
return nNewId ;
|
|
}
|