0966f86f9d
- utilizzato gestore lua di EgtGeneral.
286 lines
9.2 KiB
C++
286 lines
9.2 KiB
C++
//----------------------------------------------------------------------------
|
|
// 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 "API.h"
|
|
#include "LUA.h"
|
|
#include "LUA_Base.h"
|
|
#include "LUA_Aux.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EInConst.h"
|
|
#include "/EgtDev/Include/EgkPolyLine.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static const double LIN_TOL_DEF = 0.05 ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByFlatContour( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : ParentId, CrvId [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nCrvId ;
|
|
LuaCheckParam( L, 2, nCrvId)
|
|
double dLinTol = LIN_TOL_DEF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = EgtCreateSurfTmByFlatContour( nParentId, nCrvId, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByRegion( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : ParentId, CrvIds [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
double dLinTol = LIN_TOL_DEF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo una regione (piana)
|
|
int nId = EgtCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
double dLinTol = LIN_TOL_DEF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, dLinTol))
|
|
LuaGetRefType( L, 5, nRefType) ;
|
|
else
|
|
LuaGetRefType( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
|
int nId = EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr,
|
|
dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByRegionExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
double dLinTol = LIN_TOL_DEF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, dLinTol))
|
|
LuaGetRefType( L, 5, nRefType) ;
|
|
else
|
|
LuaGetRefType( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, con aggiunta dei tappi
|
|
int nId = EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByRevolve( 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 = EgtCreateSurfTmByRevolve( 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
|
|
LuaCreateSurfTmByScrewing( 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 = LIN_TOL_DEF ;
|
|
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 = EgtCreateSurfTmByScrewing( 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
|
|
LuaCreateSurfTmRuled( 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 = LIN_TOL_DEF ;
|
|
if ( lua_gettop( L) >= 4)
|
|
LuaCheckParam( L, 4, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = EgtCreateSurfTmRuled( nParentId, nCrvId1, nCrvId2, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByTriangles( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : ParentId, Id/s [, bErase]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 2, vId)
|
|
bool bErase = true ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, bErase) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM mediante cucitura di superfici
|
|
int nId = EgtCreateSurfTmByTriangles( nParentId, vId, bErase) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmBySewing( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : ParentId, Id/s [, bErase]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 2, vId)
|
|
bool bErase = true ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, bErase) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM mediante cucitura di superfici
|
|
int nId = EgtCreateSurfTmBySewing( nParentId, vId, bErase) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallGdbCreateSurf( void)
|
|
{
|
|
bool bOk = true ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRegionExtrusion", LuaCreateSurfTmByRegionExtrusion) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRevolve", LuaCreateSurfTmByRevolve) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByScrewing", LuaCreateSurfTmByScrewing) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ;
|
|
return bOk ;
|
|
}
|