f7a8981491
- aggiunta della funzione SurfBzSwept.
1335 lines
42 KiB
C++
1335 lines
42 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 "EXE_Const.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFrRectangle( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : ParentId, ptIni, ptCross [,nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptIni ;
|
|
LuaCheckParam( L, 2, ptIni)
|
|
Point3d ptCross ;
|
|
LuaCheckParam( L, 3, ptCross)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nId = ExeCreateSurfFrRectangle( nParentId, ptIni, ptCross, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFrRectangle3P( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, ptIni, ptCross, ptDir [,nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptIni ;
|
|
LuaCheckParam( L, 2, ptIni)
|
|
Point3d ptCross ;
|
|
LuaCheckParam( L, 3, ptCross)
|
|
Point3d ptDir ;
|
|
LuaCheckParam( L, 4, ptDir)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nId = ExeCreateSurfFrRectangle3P( nParentId, ptIni, ptCross, ptDir, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFrStadium( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : ParentId, ptIni, ptCross [,nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptIni ;
|
|
LuaCheckParam( L, 2, ptIni)
|
|
Point3d ptCross ;
|
|
LuaCheckParam( L, 3, ptCross)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nId = ExeCreateSurfFrStadium( nParentId, ptIni, ptCross, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFrDisk( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : ParentId, ptOrig, dRad [,nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 2, ptOrig)
|
|
double dRad ;
|
|
LuaCheckParam( L, 3, dRad)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nId = ExeCreateSurfFrDisk( nParentId, ptOrig, dRad, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFlatRegion( lua_State* L)
|
|
{
|
|
// 2 parametri : ParentId, CrvIds
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nCount = 0 ;
|
|
int nId = ExeCreateSurfFlatRegion( nParentId, vCrvIds, &nCount) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
LuaSetParam( L, nCount) ;
|
|
return 2 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfFrFatCurve( lua_State* L)
|
|
{
|
|
// 4 o 5 o 6 parametri : ParentId, nCrvId, dRad, bSquared [, bSquaredMids] [, dLinTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nCrvId ;
|
|
LuaCheckParam( L, 2, nCrvId)
|
|
double dRad ;
|
|
LuaCheckParam( L, 3, dRad)
|
|
bool bSquared ;
|
|
LuaCheckParam( L, 4, bSquared)
|
|
bool bSquaredMids = bSquared ;
|
|
LuaGetParam( L, 5, bSquaredMids) ;
|
|
double dLinTol = 10 * EPS_SMALL ;
|
|
LuaGetParam( L, 6, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo una regione piana
|
|
int nId = ExeCreateSurfFrFatCurve( nParentId, nCrvId, dRad, bSquared, bSquaredMids, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmPlaneInBBox( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, ptP, vtN, BBox3d [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptP ;
|
|
LuaCheckParam( L, 2, ptP)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
BBox3d b3Box ;
|
|
LuaCheckParam( L, 4, b3Box)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM piano in bounding box
|
|
int nId = ExeCreateSurfTmPlaneInBBox( nParentId, ptP,vtN, b3Box, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmConvexHullInBBox( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : ParentId, StmId, BBox3d [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nStmId ;
|
|
LuaCheckParam( L, 2, nStmId)
|
|
BBox3d b3Box ;
|
|
LuaCheckParam( L, 3, b3Box)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM plane hull in bounding box
|
|
int nId = ExeCreateSurfTmConvexHullInBBox( nParentId, nStmId, b3Box, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmBBox( lua_State* L)
|
|
{
|
|
// 2 o 3 o 4 parametri : ParentId, BBox3d [, bRegular] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
BBox3d b3Box ;
|
|
LuaCheckParam( L, 2, b3Box)
|
|
bool bRegular = false ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 3, bRegular))
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 3, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM bounding box
|
|
int nId = ExeCreateSurfTmBBox( nParentId, b3Box, bRegular, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmBox( lua_State* L)
|
|
{
|
|
// 5 o 6 o 7 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptIni ;
|
|
LuaCheckParam( L, 2, ptIni)
|
|
Point3d ptCross ;
|
|
LuaCheckParam( L, 3, ptCross)
|
|
Point3d ptDir ;
|
|
LuaCheckParam( L, 4, ptDir)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 5, dHeight)
|
|
bool bRegular = false ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 6, bRegular))
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM parallelepipedo
|
|
int nId = ExeCreateSurfTmBox( nParentId, ptIni, ptCross, ptDir, dHeight, bRegular, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmPyramid( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptIni ;
|
|
LuaCheckParam( L, 2, ptIni)
|
|
Point3d ptCross ;
|
|
LuaCheckParam( L, 3, ptCross)
|
|
Point3d ptDir ;
|
|
LuaCheckParam( L, 4, ptDir)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 5, dHeight)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM cilindro
|
|
int nId = ExeCreateSurfTmPyramid( nParentId, ptIni, ptCross, ptDir, dHeight, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmCylinder( lua_State* L)
|
|
{
|
|
// 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 2, ptOrig)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
double dRad ;
|
|
LuaCheckParam( L, 4, dRad)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 5, dHeight)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 6, dLinTol))
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM cilindro
|
|
int nId = ExeCreateSurfTmCylinder( nParentId, ptOrig, vtN, dRad, dHeight, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmCone( lua_State* L)
|
|
{
|
|
// 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 2, ptOrig)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
double dRad ;
|
|
LuaCheckParam( L, 4, dRad)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 5, dHeight)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 6, dLinTol))
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM cilindro
|
|
int nId = ExeCreateSurfTmCone( nParentId, ptOrig, vtN, dRad, dHeight, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmSphere( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, PtOrig, dRad [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 2, ptOrig)
|
|
double dRad ;
|
|
LuaCheckParam( L, 3, dRad)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, dLinTol))
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM sfera
|
|
int nId = ExeCreateSurfTmSphere( nParentId, ptOrig, dRad, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmTriangle( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d PtP1 ;
|
|
LuaCheckParam( L, 2, PtP1)
|
|
Point3d PtP2 ;
|
|
LuaCheckParam( L, 3, PtP2)
|
|
Point3d PtP3 ;
|
|
LuaCheckParam( L, 4, PtP3)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM triangolo
|
|
int nId = ExeCreateSurfTmTriangle( nParentId, PtP1, PtP2, PtP3, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmRectangle( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, PtO, PtL, PtT [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptO ;
|
|
LuaCheckParam( L, 2, ptO)
|
|
Point3d ptL ;
|
|
LuaCheckParam( L, 3, ptL)
|
|
Point3d ptT ;
|
|
LuaCheckParam( L, 4, ptT)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM rettangolo
|
|
int nId = ExeCreateSurfTmRectangle( nParentId, ptO, ptL, ptT, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
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_SRF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = ExeCreateSurfTmByFlatContour( nParentId, nCrvId, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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_SRF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo una regione (piana)
|
|
int nId = ExeCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, dLinTol))
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
|
int nId = ExeCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr,
|
|
dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByRegionExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, dLinTol))
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, con aggiunta dei tappi
|
|
int nId = ExeCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByRevolve( lua_State* L)
|
|
{
|
|
// 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)
|
|
bool bCapEnds ;
|
|
LuaCheckParam( L, 5, bCapEnds)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 6, dLinTol))
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
else
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = ExeCreateSurfTmByRevolve( nParentId, nCrvId, ptAx, vtAx, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByScrewing( lua_State* L)
|
|
{
|
|
// 6 o 7 o 8 o 9 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, 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)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 5, dAngRotDeg)
|
|
double dMove ;
|
|
LuaCheckParam( L, 6, dMove)
|
|
int nPar = 7 ;
|
|
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 = ExeCreateSurfTmByScrewing( nParentId, nCrvId, ptAx, vtAx, dAngRotDeg, dMove, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmRectSwept( lua_State* L)
|
|
{
|
|
// 7 o 8 parametri : ParentId, dDimH, dDimV, dBevelH, dBevelV, GuideId, nCapType [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
double dDimH ;
|
|
LuaCheckParam( L, 2, dDimH)
|
|
double dDimV ;
|
|
LuaCheckParam( L, 3, dDimV)
|
|
double dBevelH ;
|
|
LuaCheckParam( L, 4, dBevelH)
|
|
double dBevelV ;
|
|
LuaCheckParam( L, 5, dBevelV)
|
|
int nGuideId ;
|
|
LuaCheckParam( L, 6, nGuideId)
|
|
int nCapType ;
|
|
LuaCheckParam( L, 7, nCapType)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
LuaGetParam( L, 8, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM rectangular swept
|
|
int nId = ExeCreateSurfTmRectSwept( nParentId, dDimH, dDimV, dBevelH, dBevelV, nGuideId, nCapType, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmSwept( lua_State* L)
|
|
{
|
|
// 4, 5, 6 o 7 parametri : ParentId, SectId, GuideId [, vtAx], bCapEnds [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nSectId ;
|
|
LuaCheckParam( L, 2, nSectId)
|
|
int nGuideId ;
|
|
LuaCheckParam( L, 3, nGuideId)
|
|
int nPar = 4 ;
|
|
Vector3d vtAx = V_NULL ;
|
|
if ( LuaGetParam( L, nPar, vtAx))
|
|
++ nPar ;
|
|
bool bCapEnds ;
|
|
LuaCheckParam( 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 swept
|
|
int nId = ExeCreateSurfTmSwept( nParentId, nSectId, nGuideId, vtAx, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmTransSwept( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, SectId, GuideId, bCapEnds [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nSectId ;
|
|
LuaCheckParam( L, 2, nSectId)
|
|
int nGuideId ;
|
|
LuaCheckParam( L, 3, nGuideId)
|
|
bool bCapEnds ;
|
|
LuaCheckParam( L, 4, bCapEnds)
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
LuaGetParam( L, 5, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM swept di traslazione
|
|
int nId = ExeCreateSurfTmTransSwept( nParentId, nSectId, nGuideId, bCapEnds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmRuled( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 parametri : ParentId, PtOrCrvId1, PtOrCrvId2 [, sType] [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nPtOrCrvId1 ;
|
|
LuaCheckParam( L, 2, nPtOrCrvId1)
|
|
int nPtOrCrvId2 ;
|
|
LuaCheckParam( L, 3, nPtOrCrvId2)
|
|
string sType = "IP" ;
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
if ( LuaGetParam( L, 4, sType))
|
|
LuaGetParam( L, 5, dLinTol) ;
|
|
else
|
|
LuaGetParam( L, 4, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nType = RUL_TYPE_ISOPAR ;
|
|
if ( sType == "MD")
|
|
nType = RUL_TYPE_MINDIST ;
|
|
else if ( sType == "IP_SM")
|
|
nType = RUL_TYPE_ISOPAR_SMOOTH ;
|
|
int nId = ExeCreateSurfTmRuled( nParentId, nPtOrCrvId1, nPtOrCrvId2, nType, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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 = ExeCreateSurfTmByTriangles( nParentId, vId, bErase) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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 = ExeCreateSurfTmBySewing( nParentId, vId, bErase) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfTmByVolZmap( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : ParentId, ZmapId [, nPart]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nZmapId ;
|
|
LuaCheckParam( L, 2, nZmapId)
|
|
int nPart = -1 ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, nPart) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM partendo da solido Zmap
|
|
int nId = ExeCreateSurfTmByVolZmap( nParentId, nZmapId, nPart) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBezier( lua_State* L)
|
|
{
|
|
// da 4 a 7 parametri : ParentId, DegreeU, DegreeV [, SpanU, SpanV], CtrlPnts [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nDegU ;
|
|
LuaCheckParam( L, 2, nDegU)
|
|
int nDegV ;
|
|
LuaCheckParam( L, 3, nDegV)
|
|
int nSpanU = 1, nSpanV = 1 ;
|
|
PNTVECTOR vPnt ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, nSpanU)) {
|
|
LuaCheckParam( L, 5, nSpanV)
|
|
LuaCheckParam( L, 6, vPnt)
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
}
|
|
else {
|
|
LuaCheckParam( L, 4, vPnt)
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
}
|
|
LuaClearStack( L) ;
|
|
// creo la superficie
|
|
int nId = ExeCreateSurfBezier( nParentId, nDegU, nDegV, nSpanU, nSpanV, vPnt, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBezierRational( lua_State* L)
|
|
{
|
|
// da 4 a 7 parametri : ParentId, DegreeU, DegreeV [, SpanU, SpanV], CtrlPntWs [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nDegU ;
|
|
LuaCheckParam( L, 2, nDegU)
|
|
int nDegV ;
|
|
LuaCheckParam( L, 3, nDegV)
|
|
int nSpanU = 1, nSpanV = 1 ;
|
|
PNTUVECTOR vPntW ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
if ( LuaGetParam( L, 4, nSpanU)) {
|
|
LuaCheckParam( L, 5, nSpanV)
|
|
LuaCheckParam( L, 6, vPntW)
|
|
LuaGetParam( L, 7, nRefType) ;
|
|
}
|
|
else {
|
|
LuaCheckParam( L, 4, vPntW)
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
}
|
|
LuaClearStack( L) ;
|
|
// creo la superficie
|
|
int nId = ExeCreateSurfBezierRational( nParentId, nDegU, nDegV, nSpanU, nSpanV, vPntW, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBezierLeaves( lua_State* L)
|
|
{
|
|
// 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nSurfBzId ;
|
|
LuaCheckParam( L, 2, nSurfBzId)
|
|
int nTextHeight = 50 ;
|
|
bool bShowTrim = false ;
|
|
if ( LuaGetParam( L, 3, nTextHeight))
|
|
LuaGetParam( L, 4, bShowTrim) ;
|
|
else
|
|
LuaGetParam( L, 3, bShowTrim) ;
|
|
LuaClearStack( L) ;
|
|
// creo la superficie
|
|
int nCount = 0 ;
|
|
int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight, bShowTrim, &nCount) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL) {
|
|
LuaSetParam( L, nId) ;
|
|
LuaSetParam( L, nCount) ;
|
|
}
|
|
else {
|
|
LuaSetParam( L) ;
|
|
LuaSetParam( L) ;
|
|
}
|
|
return 2 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBezierTria2D( lua_State* L)
|
|
{
|
|
// 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nSurfBzId ;
|
|
LuaCheckParam( L, 2, nSurfBzId)
|
|
int nTextHeight = 50 ;
|
|
bool bShowTrim = false ;
|
|
if ( LuaGetParam( L, 3, nTextHeight))
|
|
LuaGetParam( L, 4, bShowTrim) ;
|
|
else
|
|
LuaGetParam( L, 3, bShowTrim) ;
|
|
LuaClearStack( L) ;
|
|
// creo la superficie
|
|
int nCount = 0 ;
|
|
int nId = ExeCreateSurfBezierTria2D( nParentId, nSurfBzId, nTextHeight, bShowTrim, &nCount) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL) {
|
|
LuaSetParam( L, nId) ;
|
|
LuaSetParam( L, nCount) ;
|
|
}
|
|
else {
|
|
LuaSetParam( L) ;
|
|
LuaSetParam( L) ;
|
|
}
|
|
return 2 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateBezierSphere( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : ParentId, ptCenter, dRad [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptCenter ;
|
|
LuaCheckParam( L, 2, ptCenter)
|
|
double dRad ;
|
|
LuaCheckParam( L, 3, dRad)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
// creo la superficie
|
|
int nCount = 0 ;
|
|
int nId = ExeCreateBezierSphere( nParentId, ptCenter, dRad, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL) {
|
|
LuaSetParam( L, nId) ;
|
|
LuaSetParam( L, nCount) ;
|
|
}
|
|
else {
|
|
LuaSetParam( L) ;
|
|
LuaSetParam( L) ;
|
|
}
|
|
return 2 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByFlatContour( 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_SRF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo Sbz piana e la trimmo con il contorno
|
|
int nId = ExeCreateSurfBzByFlatContour( nParentId, nCrvId, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByRegion( 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_SRF ;
|
|
if ( lua_gettop( L) >= 3)
|
|
LuaCheckParam( L, 3, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo una Sbz piana a cui aggiungo le curve come trim
|
|
int nId = ExeCreateSurfBzByRegion( nParentId, vCrvIds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr [, bool bCapEnds] [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nCrvId ;
|
|
LuaCheckParam( L, 2, nCrvId)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
bool bCapEnds = false ;
|
|
int nPar = 4 ;
|
|
if ( LuaGetParam( L, nPar, bCapEnds))
|
|
++ nPar ;
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
if ( LuaGetParam( L, nPar, dLinTol))
|
|
++ nPar ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, nPar, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
|
int nId = ExeCreateSurfBzByExtrusion( nParentId, nCrvId, vtExtr, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByRegionExtrusion( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 o 6 parametri : ParentId, CrvIds, vtExtr [, bool bCapEnds] [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
Vector3d vtExtr ;
|
|
LuaCheckParam( L, 3, vtExtr)
|
|
bool bCapEnds = false ;
|
|
int nPar = 4 ;
|
|
if ( LuaGetParam( L, nPar, bCapEnds))
|
|
++ nPar ;
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
if ( LuaGetParam( L, nPar, dLinTol))
|
|
++ nPar ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, nPar, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
|
int nId = ExeCreateSurfBzByRegionExtrusion( nParentId, vCrvIds, vtExtr, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByScrewing( lua_State* L)
|
|
{
|
|
// 6 o 7 o 8 o 9 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, 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)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 5, dAngRotDeg)
|
|
double dMove ;
|
|
LuaCheckParam( L, 6, dMove)
|
|
int nPar = 7 ;
|
|
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 = ExeCreateSurfBzByScrewing( nParentId, nCrvId, ptAx, vtAx, dAngRotDeg, dMove, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzByPointCurve( 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 ptTop ;
|
|
LuaCheckParam( L, 3, ptTop)
|
|
int nPar = 4 ;
|
|
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 = ExeCreateSurfBzByPointCurve( nParentId, nCrvId, ptTop, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzRuled( lua_State* L)
|
|
{
|
|
// 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nRuledType [, bCapEnds] [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nCrvId1 ;
|
|
LuaCheckParam( L, 2, nCrvId1)
|
|
int nCrvId2 ;
|
|
LuaCheckParam( L, 3, nCrvId2)
|
|
int nRuledType ;
|
|
LuaCheckParam( L, 4, nRuledType)
|
|
bool bCapEnds = false ;
|
|
int nPar = 5 ;
|
|
if( LuaGetParam( L, nPar, bCapEnds))
|
|
++ nPar ;
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
LuaGetParam( L, nPar, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = ExeCreateSurfBzRuled( nParentId, nCrvId1, nCrvId2, nRuledType, bCapEnds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzSkinned( lua_State* L)
|
|
{
|
|
// 2 o 3 o 4 parametri : ParentId, vCrvIds [, bCapEnds] [, dTol]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
INTVECTOR vCrvIds ;
|
|
LuaCheckParam( L, 2, vCrvIds)
|
|
bool bCapEnds = false ;
|
|
int nPar = 3 ;
|
|
if ( LuaGetParam( L, nPar, bCapEnds))
|
|
++ nPar ;
|
|
double dLinTol = LIN_TOL_SRF ;
|
|
LuaGetParam( L, nPar, dLinTol) ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = ExeCreateSurfBzSkinned( nParentId, vCrvIds, bCapEnds, dLinTol) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateSurfBzSwept( lua_State* L)
|
|
{
|
|
// 3 o 4 o 5 o 6 o 7 parametri : ParentId, nSectCrvId, nGuideCrvId [, vtAx] [, bCapEnds] [, dTol] [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
int nSectId ;
|
|
LuaCheckParam( L, 2, nSectId)
|
|
int nGuideId ;
|
|
LuaCheckParam( L, 3, nGuideId)
|
|
Vector3d vtAx = V_NULL ;
|
|
int nPar = 4 ;
|
|
if ( LuaGetParam( L, nPar, vtAx))
|
|
++ nPar ;
|
|
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, dLinTol))
|
|
++ nPar ;
|
|
LuaClearStack( L) ;
|
|
// creo STM riempiendo un contorno piano
|
|
int nId = ExeCreateSurfBzSwept( nParentId, nSectId, nGuideId, vtAx, bCapEnds, dLinTol, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrRectangle", LuaCreateSurfFrRectangle) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrRectangle3P", LuaCreateSurfFrRectangle3P) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrStadium", LuaCreateSurfFrStadium) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrDisk", LuaCreateSurfFrDisk) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrFatCurve", LuaCreateSurfFrFatCurve) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFlatRegion", LuaCreateSurfFlatRegion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPlaneInBBox", LuaCreateSurfTmPlaneInBBox) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmConvexHullInBBox", LuaCreateSurfTmConvexHullInBBox) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBBox", LuaCreateSurfTmBBox) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBox", LuaCreateSurfTmBox) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPyramid", LuaCreateSurfTmPyramid) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCone", LuaCreateSurfTmCone) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSphere", LuaCreateSurfTmSphere) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangle", LuaCreateSurfTmTriangle) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectangle", LuaCreateSurfTmRectangle) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRegionExtrusion", LuaCreateSurfTmByRegionExtrusion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRevolve", LuaCreateSurfTmByRevolve) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByScrewing", LuaCreateSurfTmByScrewing) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectSwept", LuaCreateSurfTmRectSwept) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwept", LuaCreateSurfTmSwept) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTransSwept", LuaCreateSurfTmTransSwept) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierTria2D", LuaCreateSurfBezierTria2D) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSphere", LuaCreateBezierSphere) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByFlatContour", LuaCreateSurfBzByFlatContour) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRegion", LuaCreateSurfBzByRegion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByExtrusion", LuaCreateSurfBzByExtrusion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRegionExtrusion", LuaCreateSurfBzByRegionExtrusion) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByScrewing", LuaCreateSurfBzByScrewing) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRevolve", LuaCreateSurfBzByRevolve) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByPointCurve", LuaCreateSurfBzByPointCurve) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzRuled", LuaCreateSurfBzRuled) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSkinned", LuaCreateSurfBzSkinned) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSwept", LuaCreateSurfBzSwept) ;
|
|
return bOk ;
|
|
}
|