//---------------------------------------------------------------------------- // 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 pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; bOk = bOk && pVZM->Create( 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 = "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 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 pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; bOk = bOk && pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex) ; // 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) { 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 pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex) ; // 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 = "EgtVolZmapFromTriMesh(" + IdToString( nParentId) + "," + ToString( nStmId) + "," + ToString( dPrec) + "," + ( bTriDex ? "true" : "false") + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo della nuova entità return nNewId ; }