1e24540dc1
- razionalizzazione - modificati comandi per creazione superfici per gestione piani di regioni con buchi - aggiunta SplitCurve.
242 lines
7.8 KiB
C++
242 lines
7.8 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 "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 const double LIN_TOL_DEF = 0.05 ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTriMeshByFlatContour( 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 = EgtCreateSurfTriMeshByFlatContour( nParentId, nCrvId, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTriMeshByRegion( 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 = EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTriMeshByExtrusion( 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 = EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr,
|
|
dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTriMeshByRegionExtrusion( 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 = EgtCreateSurfTriMeshByRegionExtrusion( nParentId, vCrvIds, vtExtr,
|
|
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 = 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 = 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 = LIN_TOL_DEF ;
|
|
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, "EgtSurfTmByFlatContour", LuaCreateSurfTriMeshByFlatContour) ;
|
|
lua_register( L, "EgtSurfTmByRegion", LuaCreateSurfTriMeshByRegion) ;
|
|
lua_register( L, "EgtSurfTmByExtrusion", LuaCreateSurfTriMeshByExtrusion) ;
|
|
lua_register( L, "EgtSurfTmByRegionExtrusion", LuaCreateSurfTriMeshByRegionExtrusion) ;
|
|
lua_register( L, "EgtSurfTmByRevolve", LuaCreateSurfTriMeshByRevolve) ;
|
|
lua_register( L, "EgtSurfTmByScrewing", LuaCreateSurfTriMeshByScrewing) ;
|
|
lua_register( L, "EgtSurfTmRuled", LuaCreateSurfTriMeshRuled) ;
|
|
}
|
|
catch ( ...) {
|
|
return false ;
|
|
}
|
|
return true ;
|
|
}
|