EgtExecutor :

- aggiunta la funzione per il revolve con superfici di Bezier.
This commit is contained in:
Daniele Bariletti
2024-05-22 12:15:06 +02:00
parent c65a29fc2b
commit 2eeb25584c
2 changed files with 75 additions and 0 deletions
+40
View File
@@ -2082,3 +2082,43 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
const Point3d& ptAx, const Vector3d& vtAx,
bool bCapEnds, double dLinTol, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// porto in locale punto e vettore asse
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
// calcolo la superficie
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
ToString( nCrvId) + ",{" +
ToString( ptAx) + "},{" +
ToString( vtAx) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
+35
View File
@@ -1090,6 +1090,40 @@ LuaCreateSurfBzByScrewing( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfBzByRevolve( lua_State* L)
{
// 4 o 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx [, bCapEnds] [, dTol] [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nCrvId ;
LuaCheckParam( L, 2, nCrvId)
Point3d ptAx ;
LuaCheckParam( L, 3, ptAx)
Vector3d vtAx ;
LuaCheckParam( L, 4, vtAx)
int nPar = 5 ;
bool bCapEnds = false ;
if ( LuaGetParam( L, nPar, bCapEnds))
++ nPar ;
double dLinTol = LIN_TOL_SRF ;
if ( LuaGetParam( L, nPar, dLinTol))
++ nPar ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, nPar, nRefType))
++ nPar ;
LuaClearStack( L) ;
// creo STM riempiendo un contorno piano
int nId = ExeCreateSurfBzByRevolve( nParentId, nCrvId, ptAx, vtAx, bCapEnds, dLinTol, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
@@ -1133,5 +1167,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRegion", LuaCreateSurfBzByRegion) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByExtrusion", LuaCreateSurfBzByExtrusion) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByScrewing", LuaCreateSurfBzByScrewing) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRevolve", LuaCreateSurfBzByRevolve) ;
return bOk ;
}