EgtExecutor :

- aggiunte funzioni exe e lua CreateSurfTmPyramidFrustum e CreateSurfTmConeFrustum
- adattata funzione ExeCreateSurfTmPyramid a modifiche di GeomKernel per avere funzionamento da esterno inalterato
- piccole sistemazioni.
This commit is contained in:
Dario Sassi
2025-03-27 15:30:27 +01:00
parent 5f8961860a
commit 034635ae1d
3 changed files with 157 additions and 20 deletions
+66 -4
View File
@@ -747,9 +747,9 @@ ExeCreateSurfTmPyramid( int nParentId, const Point3d& ptIni, const Point3d& ptCr
// creo la piramide nel suo riferimento intrinseco
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshPyramid( abs( dWidth), dLen, dHeight)) ;
bOk = bOk && ! IsNull( pSTM) ;
// eventuale traslazione per larghezza negativa
if ( bOk && dWidth < 0)
pSTM->Translate( Vector3d( dWidth, 0, 0)) ;
// traslazione per riferimento BL e anche per eventuale larghezza negativa
if ( bOk)
pSTM->Translate( Vector3d( dWidth / 2 + min( dWidth, 0.), dLen / 2, 0)) ;
// porto la piramide nel riferimento locale
bOk = bOk && pSTM->ToGlob( frBox) ;
// inserisco la superficie nel DB
@@ -890,6 +890,63 @@ ExeCreateSurfTmSphere( int nParentId, const Point3d& ptOrig,
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfTmPyramidFrustum( int nParentId, double dBaseDimX, double dBaseDimY, double dTopDimX, double dTopDimY, double dHeight)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// creo il tronco di cono
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshPyramidFrustum( dBaseDimX, dBaseDimY, dTopDimX, dTopDimY, dHeight)) ;
bOk = bOk && ! IsNull( pSTM) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfTmPyramidFrustum(" + IdToString( nParentId) + "," +
ToString( dBaseDimX) + "," +
ToString( dBaseDimY) + "," +
ToString( dTopDimX) + "," +
ToString( dTopDimY) + "," +
ToString( dHeight) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfTmConeFrustum( int nParentId, double dBaseRad, double dTopRad, double dHeight, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// creo il tronco di cono
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshConeFrustum( dBaseRad, dTopRad, dHeight, dLinTol)) ;
bOk = bOk && ! IsNull( pSTM) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfTmConeFrustum(" + IdToString( nParentId) + "," +
ToString( dBaseRad) + "," +
ToString( dTopRad) + "," +
ToString( dHeight) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfTmTriangle( int nParentId, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3, int nRefType)
@@ -1478,10 +1535,15 @@ ExeCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, int nType
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sType = "'IP'" ;
if ( nType == ISurfTriMesh::RLT_MINDIST)
sType = "'MD'" ;
else if ( nType == ISurfTriMesh::RLT_ISOPAR_SMOOTH)
sType = "'IP_SM'" ;
string sLua = "EgtSurfTmRuled(" + IdToString( nParentId) + "," +
ToString( nPtOrCrvId1) + "," +
ToString( nPtOrCrvId2) + "," +
( nType == ISurfTriMesh::RLT_MINDIST ? "'MD'" : "'IP'") + "," +
sType + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
+35 -16
View File
@@ -16,6 +16,7 @@
#include "EXE.h"
#include "EXE_Const.h"
#include "EXE_Macro.h"
#include "AuxTools.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EXeExecutor.h"
@@ -31,6 +32,8 @@
#include "/EgtDev/Include/EGkIntersCurves.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
ExeCurveDomain( int nId, double* pdStart, double* pdEnd)
@@ -755,15 +758,15 @@ ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva di bezier
// recupero la curva di Bezier
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ;
if ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO)
return GDB_ID_NULL ;
// recupero il riferimento della curva
// recupero il riferimento della curva
Frame3d frCrv ;
bool bOk = true ;
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
// recupero il riferimento di destinazione
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
if ( ! bOk)
@@ -799,7 +802,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount)
++nCount ;
}
}
// restituisco i risultati
// restituisco i risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
@@ -826,7 +829,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount)
if ( nId != GDB_ID_NULL)
++nCount ;
}
// restituisco i risultati
// restituisco i risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
@@ -841,11 +844,13 @@ ExeCurveMaxOffset( int nId, double& dMaxOffset)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// verifico il parametro
// verifico il parametro
if ( &dMaxOffset == nullptr)
return false ;
// recupero la curva
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCrv == nullptr)
return false ;
return CalcCurveLimitOffset( *pCrv, dMaxOffset) ;
}
@@ -855,15 +860,15 @@ ExeCopyCompoSubCurve( int nCrvId, int nSubCrvToCopy, int nDestGrpId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva compo
// recupero la curva compo
const ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nCrvId)) ;
if ( pCompo == nullptr)
return GDB_ID_NULL ;
// recupero il riferimento della curva
// recupero il riferimento della curva
Frame3d frCrv ;
bool bOk = true ;
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
// recupero il riferimento di destinazione
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
if ( ! bOk)
@@ -873,12 +878,23 @@ ExeCopyCompoSubCurve( int nCrvId, int nSubCrvToCopy, int nDestGrpId)
if ( nSubCrvToCopy > nSubCrvs - 1)
return GDB_ID_NULL ;
// creo una copia e la porto nel frame della destinazione
// creo una copia e la porto nel frame della destinazione
const ICurve* pSubCrv = pCompo->GetCurve( nSubCrvToCopy) ;
ICurve* pSubCrvCopy = pSubCrv->Clone() ;
if ( pSubCrvCopy == nullptr)
return GDB_ID_NULL ;
pSubCrvCopy->LocToLoc( frCrv, frDest) ;
int nSubCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pSubCrvCopy) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCopyCompoSubCurve(" + IdToString( nCrvId) + "," +
ToString( nSubCrvToCopy) + "," +
IdToString( nDestGrpId) + ")" +
" -- Id=" + ToString( nSubCrvId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nSubCrvId ;
}
@@ -888,22 +904,25 @@ ExeCopyParamRange( int nCrvId, double dUStart, double dUEnd, int nDestGrpId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva
// recupero la curva
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
// recupero il riferimento della curva
// recupero il riferimento della curva
Frame3d frCrv ;
bool bOk = true ;
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
// recupero il riferimento di destinazione
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
if ( ! bOk)
return GDB_ID_NULL ;
// creo una copia e la porto nel frame della destinazione
// creo una copia e la porto nel frame della destinazione
ICurve* pSubCrvCopy = pCrv->CopyParamRange( dUStart, dUEnd) ;
if ( pSubCrvCopy == nullptr)
return GDB_ID_NULL ;
pSubCrvCopy->LocToLoc( frCrv, frDest) ;
int nSubCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pSubCrvCopy) ;
ExeSetModified() ;
return nSubCrvId ;
}
+56
View File
@@ -417,6 +417,60 @@ LuaCreateSurfTmSphere( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTmPyramidFrustum( lua_State* L)
{
// 6 parametri : ParentId, dBaseDimX, dBaseDimY, dTopDimX, dTopDimY, dHeight
int nParentId ;
LuaCheckParam( L, 1, nParentId)
double dBaseDimX ;
LuaCheckParam( L, 2, dBaseDimX)
double dBaseDimY ;
LuaCheckParam( L, 3, dBaseDimY)
double dTopDimX ;
LuaCheckParam( L, 4, dTopDimX)
double dTopDimY ;
LuaCheckParam( L, 5, dTopDimY)
double dHeight ;
LuaCheckParam( L, 6, dHeight)
LuaClearStack( L) ;
// creo STM cilindro
int nId = ExeCreateSurfTmPyramidFrustum( nParentId, dBaseDimX, dBaseDimY, dTopDimX, dTopDimY, dHeight) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTmConeFrustum( lua_State* L)
{
// 4 o 5 parametri : ParentId, dBaseRad, dTopRad, dHeight [, dTol]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
double dBaseRad ;
LuaCheckParam( L, 2, dBaseRad)
double dTopRad ;
LuaCheckParam( L, 3, dTopRad)
double dHeight ;
LuaCheckParam( L, 4, dHeight)
double dLinTol = LIN_TOL_SRF ;
LuaGetParam( L, 5, dLinTol) ;
LuaClearStack( L) ;
// creo STM cilindro
int nId = ExeCreateSurfTmConeFrustum( nParentId, dBaseRad, dTopRad, dHeight, dLinTol) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTmTriangle( lua_State* L)
@@ -1317,6 +1371,8 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCone", LuaCreateSurfTmCone) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSphere", LuaCreateSurfTmSphere) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPyramidFrustum", LuaCreateSurfTmPyramidFrustum) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmConeFrustum", LuaCreateSurfTmConeFrustum) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangle", LuaCreateSurfTmTriangle) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectangle", LuaCreateSurfTmRectangle) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ;