EgtExecutor 1.6w2 :
- aggiunte funzioni Exe e Lua per Zmap - corretta fnzione disegno sfera.
This commit is contained in:
@@ -602,7 +602,7 @@ ExeCreateSurfTmSphere( int nParentId, const Point3d& ptOrig,
|
||||
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshSphere( dRad, dLinTol)) ;
|
||||
bOk = bOk && ! IsNull( pSTM) ;
|
||||
// porto la sfera nella sua origine
|
||||
bOk = bOk && pSTM->Translate( ptOrig - ORIG) ;
|
||||
bOk = bOk && pSTM->Translate( ptOrigL - ORIG) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
|
||||
+40
-3
@@ -45,7 +45,7 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateMap( ORIG, dDimX, dDimY, dDimZ, dPrec) ;
|
||||
bOk = bOk && pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec) ;
|
||||
// lo porto nel riferimento locale
|
||||
bOk = bOk && pVZM->ToGlob( frBox) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -75,7 +75,7 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero la regione
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nSfrId)) ;
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nSfrId)) ;
|
||||
bool bOk = ( pSfr != nullptr) ;
|
||||
// recupero il riferimento della regione
|
||||
Frame3d frSfr ;
|
||||
@@ -86,7 +86,7 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateMapFromFlatRegion( *pSfr, dDimZ, dPrec) ;
|
||||
bOk = bOk && pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec) ;
|
||||
// lo porto nel riferimento di destinazione
|
||||
bOk = bOk && pVZM->LocToLoc( frSfr, frDest) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
@@ -104,3 +104,40 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec)
|
||||
{
|
||||
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) ;
|
||||
bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec) ;
|
||||
// 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) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
@@ -80,4 +80,65 @@ ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs,
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType,
|
||||
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)) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZmapGetDepth(" + IdToString( nId) + ",{" +
|
||||
ToString( ptP) + "},{" +
|
||||
ToString( vtDir) + "}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Ok=" + ToString( bOk) + "," + ToString( dInLen) + "," + ToString( dOutLen) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ;
|
||||
// porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento)
|
||||
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frLoc) ;
|
||||
// recupero lo Zmap e calcolo collisione
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
bOk = bOk && ( pVZM != nullptr && pVZM->AvoidBox( frBoxL, vtDiag)) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZmapAvoidBox(" + IdToString( nId) + ",{" +
|
||||
ToString( frBox.Orig()) + "},{" +
|
||||
ToString( frBox.VersX()) + "},{" +
|
||||
ToString( frBox.VersY()) + "},{" +
|
||||
ToString( frBox.VersZ()) + "}},{" +
|
||||
ToString( vtDiag) + "}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
Binary file not shown.
@@ -58,6 +58,18 @@ GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d
|
||||
return ptPL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Frame3d
|
||||
GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame3d& frLoc)
|
||||
{
|
||||
Frame3d frRefL( frRef) ;
|
||||
if ( nRefType == RTY_GLOB)
|
||||
frRefL.ToLoc( frLoc) ;
|
||||
else if ( nRefType == RTY_GRID)
|
||||
frRefL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
|
||||
return frRefL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP)
|
||||
|
||||
@@ -23,6 +23,8 @@ int AdjustId( int nId) ;
|
||||
Vector3d GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc) ;
|
||||
// Punto espresso nel riferimento desiderato partendo da punto nel riferimento RefType
|
||||
Point3d GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d& frLoc) ;
|
||||
// Riferimento espresso nel riferimento desiderato partendo da riferimento nel riferimento RefType
|
||||
Frame3d GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame3d& frLoc) ;
|
||||
// Punto portato dal riferimento di nId a quello di nRefId
|
||||
bool TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ;
|
||||
// Trasformazione inversa della precedente, dal riferimento di nRefId a quello di nId
|
||||
|
||||
+24
-1
@@ -54,7 +54,7 @@ LuaCreateVolZmapBox( lua_State* L)
|
||||
static int
|
||||
LuaCreateVolZmapByRegionExtrusion( lua_State* L)
|
||||
{
|
||||
// 4 parametri : ParentId, SfrId dDimZ, dPrec
|
||||
// 4 parametri : ParentId, SfrId, dDimZ, dPrec
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nSfrId ;
|
||||
@@ -74,6 +74,28 @@ LuaCreateVolZmapByRegionExtrusion( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateVolZmapFromSurfTm( lua_State* L)
|
||||
{
|
||||
// 4 parametri : ParentId, StmId, dPrec
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nStmId ;
|
||||
LuaCheckParam( L, 2, nStmId)
|
||||
double dPrec ;
|
||||
LuaCheckParam( L, 3, dPrec)
|
||||
LuaClearStack( L) ;
|
||||
// creo VZM da superficie trimesh
|
||||
int nId = ExeCreateVolZmapFromSurfTm( nParentId, nStmId, dPrec) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateVol( LuaMgr& luaMgr)
|
||||
@@ -81,5 +103,6 @@ LuaInstallGdbCreateVol( LuaMgr& luaMgr)
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,56 @@ LuaVolZmapMillingStep( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetDepth( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId, ptP, vtDir [, nRefType]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 2, ptP)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
double dLen1, dLen2 ;
|
||||
bool bOk = ExeVolZmapGetDepth( nId, ptP, vtDir, nRefType, dLen1, dLen2) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, dLen1) ;
|
||||
LuaSetParam( L, dLen2) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapAvoidBox( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId, frBox, vtDiag [, nRefType]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Frame3d frBox ;
|
||||
LuaCheckParam( L, 2, frBox)
|
||||
Vector3d vtDiag ;
|
||||
LuaCheckParam( L, 3, vtDiag)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
bool bOk = ExeVolZmapAvoidBox( nId, frBox, vtDiag, nRefType) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
@@ -75,5 +125,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
Reference in New Issue
Block a user