//---------------------------------------------------------------------------- // EgalTech 2014-2015 //---------------------------------------------------------------------------- // File : LUA_GdbCreateSurf.cpp Data : 07.01.15 Versione : 1.6a1 // Contenuto : Funzioni di creazione superfici per LUA. // // // // Modifiche : 07.01.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "LUA.h" #include "API.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkPolyLine.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Extern/Lua/Include/lua.hpp" using namespace std ; //------------------------------------------------------------------------------- static int LuaCreateSurfTriMeshByContour( lua_State* L) { // 2 o 3 parametri : ParentId, CrvId [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) double dLinTol = 0.1 ; if ( lua_gettop( L) >= 3) LuaCheckParam( L, 3, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTriMeshByContour( nParentId, nCrvId, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateSurfTriMeshByExtrusion( lua_State* L) { // 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr, bCapEnds [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) Vector3d vtExtr ; LuaCheckParam( L, 3, vtExtr) bool bCapEnds ; LuaCheckParam( L, 4, bCapEnds) double dLinTol = 0.1 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 5, dLinTol)) LuaGetRefType( L, 6, nRefType) ; else LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, nCrvId, vtExtr.v, ( bCapEnds ? TRUE : FALSE), dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateSurfTriMeshByRevolve( lua_State* L) { // 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, bCapEnds [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) Point3d ptAx ; LuaCheckParam( L, 3, ptAx) Vector3d vtAx ; LuaCheckParam( L, 4, vtAx) bool bCapEnds ; LuaCheckParam( L, 5, bCapEnds) double dLinTol = 0.1 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 6, dLinTol)) LuaGetRefType( L, 7, nRefType) ; else LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTriMeshByRevolve( nParentId, nCrvId, ptAx.v, vtAx.v, bCapEnds, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateSurfTriMeshByScrewing( lua_State* L) { // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) Point3d ptAx ; LuaCheckParam( L, 3, ptAx) Vector3d vtAx ; LuaCheckParam( L, 4, vtAx) double dAngRotDeg ; LuaCheckParam( L, 5, dAngRotDeg) double dMove ; LuaCheckParam( L, 6, dMove) double dLinTol = 0.1 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 7, dLinTol)) LuaGetRefType( L, 8, nRefType) ; else LuaGetRefType( L, 7, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTriMeshByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCreateSurfTriMeshRuled( lua_State* L) { // 3 o 4 parametri : ParentId, CrvId1, CrvId2, [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId1 ; LuaCheckParam( L, 2, nCrvId1) int nCrvId2 ; LuaCheckParam( L, 3, nCrvId2) double dLinTol = 0.1 ; if ( lua_gettop( L) >= 4) LuaCheckParam( L, 4, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTriMeshRuled( nParentId, nCrvId1, nCrvId2, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- bool LuaInstallGdbCreateSurf( lua_State* L) { try { lua_register( L, "EgtSurfTmByContour", LuaCreateSurfTriMeshByContour) ; lua_register( L, "EgtSurfTmByExtrusion", LuaCreateSurfTriMeshByExtrusion) ; lua_register( L, "EgtSurfTmByRevolve", LuaCreateSurfTriMeshByRevolve) ; lua_register( L, "EgtSurfTmByScrewing", LuaCreateSurfTriMeshByScrewing) ; lua_register( L, "EgtSurfTmRuled", LuaCreateSurfTriMeshRuled) ; } catch ( ...) { return false ; } return true ; }