Files
EgtInterface/LUA_GeoTransform.cpp
T
Dario Sassi 9d3dc5e537 EgtInterface 1.6d3 :
- costanti stringa sostituite con costanti numeriche
- modificate funzioni API e LUA per scansione pezzi e layer
- aggiunta pulizia memoria al caricamento messaggi (necessario al cambio lingua)
- migliorie varie a funzioni Lua.
2015-04-20 08:43:10 +00:00

261 lines
7.6 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_GeoTransform.cpp Data : 29.09.14 Versione : 1.5i5
// Contenuto : Funzioni di trasformazione geometrica per LUA.
//
//
//
// Modifiche : 29.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "LUA.h"
#include "LUA_Base.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGnStringUtils.h"
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaMove( lua_State* L)
{
// 2 o 3 parametri : Id/s, VtMove [, nRefType]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
Vector3d vtMove ;
LuaCheckParam( L, 2, vtMove)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// eseguo traslazione
bool bOk = EgtMove( vId, vtMove, nRefType) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaRotate( lua_State* L)
{
// 4 o 5 parametri : Id/s, PtAx, VtAx, dAngRotDeg [, nRefType]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
Point3d ptAx ;
LuaCheckParam( L, 2, ptAx)
Vector3d vtAx ;
LuaCheckParam( L, 3, vtAx)
double dAngRotDeg ;
LuaCheckParam( L, 4, dAngRotDeg)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 5, nRefType) ;
LuaClearStack( L) ;
// eseguo rotazione
bool bOk = EgtRotate( vId, ptAx, vtAx, dAngRotDeg, nRefType) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaScale( lua_State* L)
{
// 5 o 6 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ [, nRefType]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
Frame3d frRef ;
LuaCheckParam( L, 2, frRef)
double dCoeffX ;
LuaCheckParam( L, 3, dCoeffX)
double dCoeffY ;
LuaCheckParam( L, 4, dCoeffY)
double dCoeffZ ;
LuaCheckParam( L, 5, dCoeffZ)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 6, nRefType) ;
LuaClearStack( L) ;
// eseguo scalatura
bool bOk = EgtScale( vId, frRef, dCoeffX, dCoeffY, dCoeffZ, nRefType) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaMirror( lua_State* L)
{
// 3 o 4 parametri : Id/s, PtOn, VtN [, nRefType]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
Point3d ptOn ;
LuaCheckParam( L, 2, ptOn)
Vector3d vtN ;
LuaCheckParam( L, 3, vtN)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 4, nRefType) ;
LuaClearStack( L) ;
// eseguo riflessione
bool bOk = EgtMirror( vId, ptOn, vtN, nRefType) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaShear( lua_State* L)
{
// 5 o 6 parametri : Id, PtOn, VtN, VtDir, Coeff [, nRefType]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
Point3d ptOn ;
LuaCheckParam( L, 2, ptOn)
Vector3d vtN ;
LuaCheckParam( L, 3, vtN)
Vector3d vtDir ;
LuaCheckParam( L, 4, vtDir)
double dCoeff ;
LuaCheckParam( L, 5, dCoeff)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 6, nRefType) ;
LuaClearStack( L) ;
// eseguo stiramento
bool bOk = EgtShear( vId, ptOn, vtN, vtDir, dCoeff, nRefType) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaMoveGroup( lua_State* L)
{
// 2 parametri : Id, VtMove
int nId ;
LuaCheckParam( L, 1, nId)
Vector3d vtMove ;
LuaCheckParam( L, 2, vtMove)
LuaClearStack( L) ;
// eseguo traslazione
bool bOk = ( EgtMoveGroup( nId, vtMove.v) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaRotateGroup( lua_State* L)
{
// 4 parametri : Id, PtAx, VtAx, dAngRotDeg
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptAx ;
LuaCheckParam( L, 2, ptAx)
Vector3d vtAx ;
LuaCheckParam( L, 3, vtAx)
double dAngRotDeg ;
LuaCheckParam( L, 4, dAngRotDeg)
LuaClearStack( L) ;
// eseguo rotazione
bool bOk = ( EgtRotateGroup( nId, ptAx.v, vtAx.v, dAngRotDeg) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaScaleGroup( lua_State* L)
{
// 5 parametri : Id, Frame, CoeffX, CoeffY, CoeffZ
int nId ;
LuaCheckParam( L, 1, nId)
Frame3d frRef ;
LuaCheckParam( L, 2, frRef)
double dCoeffX ;
LuaCheckParam( L, 3, dCoeffX)
double dCoeffY ;
LuaCheckParam( L, 4, dCoeffY)
double dCoeffZ ;
LuaCheckParam( L, 5, dCoeffZ)
LuaClearStack( L) ;
// eseguo scalatura
bool bOk = ( EgtScaleGroup( nId, frRef.Orig().v,
frRef.VersX().v, frRef.VersY().v, frRef.VersZ().v,
dCoeffX, dCoeffY, dCoeffZ) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaMirrorGroup( lua_State* L)
{
// 3 parametri : Id, PtOn, VtN
int sId ;
LuaCheckParam( L, 1, sId)
Point3d ptOn ;
LuaCheckParam( L, 2, ptOn)
Vector3d vtN ;
LuaCheckParam( L, 3, vtN)
LuaClearStack( L) ;
// eseguo scalatura
bool bOk = ( EgtMirrorGroup( sId, ptOn.v, vtN.v) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaShearGroup( lua_State* L)
{
// 5 parametri : Id, PtOn, VtN, VtDir, Coeff
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptOn ;
LuaCheckParam( L, 2, ptOn)
Vector3d vtN ;
LuaCheckParam( L, 3, vtN)
Vector3d vtDir ;
LuaCheckParam( L, 4, vtDir)
double dCoeff ;
LuaCheckParam( L, 5, dCoeff)
LuaClearStack( L) ;
// eseguo scalatura
bool bOk = ( EgtShearGroup( nId, ptOn.v, vtN.v, vtDir.v, dCoeff) != FALSE) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGeoTransform( void)
{
bool bOk = true ;
bOk = bOk && LuaRegisterFunction( "EgtMove", LuaMove) ;
bOk = bOk && LuaRegisterFunction( "EgtRotate", LuaRotate) ;
bOk = bOk && LuaRegisterFunction( "EgtScale", LuaScale) ;
bOk = bOk && LuaRegisterFunction( "EgtMirror", LuaMirror) ;
bOk = bOk && LuaRegisterFunction( "EgtShear", LuaShear) ;
bOk = bOk && LuaRegisterFunction( "EgtMoveGroup", LuaMoveGroup) ;
bOk = bOk && LuaRegisterFunction( "EgtRotateGroup", LuaRotateGroup) ;
bOk = bOk && LuaRegisterFunction( "EgtScaleGroup", LuaScaleGroup) ;
bOk = bOk && LuaRegisterFunction( "EgtMirrorGroup", LuaMirrorGroup) ;
bOk = bOk && LuaRegisterFunction( "EgtShearGroup", LuaShearGroup) ;
return bOk ;
}