EgtInterface 1.5i5 :
- aggiunto interprete Lua - portate in interfaccia API molte funzioni di base.
This commit is contained in:
@@ -14,7 +14,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "GseContext.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
#include "/EgtDev/Include/EGkPolyArc.h"
|
||||
#include "/EgtDev/Include/EgtILogger.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ILogger* GetLogger( void) ;
|
||||
|
||||
//--------------------------- GeomDB -----------------------------------------
|
||||
BOOL __stdcall EgtOpenFile( int nGseCtx, const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtSaveFile( int nGseCtx, const std::string& sFilePath, int nFlag) ;
|
||||
|
||||
//--------------------------- GeomDB Create ----------------------------------
|
||||
int __stdcall EgtCreateCurveBezier( int nGseCtx, int nParentId, int nDegree, const PNTVECTOR& vPnt) ;
|
||||
int __stdcall EgtCreateCurveBezierRational( int nGseCtx, int nParentId, int nDegree, const PNTUVECTOR& vPntW) ;
|
||||
int __stdcall EgtCreateCurveCompo( int nGseCtx, int nParentId, const INTVECTOR& vIds, bool bErase) ;
|
||||
int __stdcall EgtCreateCurveCompoFromPoints( int nGseCtx, int nParentId, const PolyLine& PL) ;
|
||||
int __stdcall EgtCreateCurveCompoFromPointBulges( int nGseCtx, int nParentId, const PolyArc& PA) ;
|
||||
int __stdcall EgtCreateText( int nGseCtx, int nParentId, const std::string& sText,
|
||||
const Point3d& ptP, double dAngRotDeg, double dH) ;
|
||||
int __stdcall EgtCreateTextEx( int nGseCtx, int nParentId, const std::string& sText,
|
||||
const Point3d& ptP, double dAngRotDeg, const std::string& sFont,
|
||||
int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos) ;
|
||||
|
||||
//--------------------------- GdbModify --------------------------------------
|
||||
BOOL __stdcall EgtModifyText( int nGseCtx, int nId, const std::string& sNewText) ;
|
||||
BOOL __stdcall EgtChangeTextFont( int nGseCtx, int nId, const std::string& sNewFont) ;
|
||||
|
||||
//--------------------------- GdbObjAttribs ----------------------------------
|
||||
BOOL __stdcall EgtStdColor( const std::string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha) ;
|
||||
BOOL __stdcall EgtSetName( int nGseCtx, int nId, const std::string& sName) ;
|
||||
BOOL __stdcall EgtGetName( int nGseCtx, int nId, std::string& sName) ;
|
||||
BOOL __stdcall EgtSetInfo( int nGseCtx, int nId, const std::string& sKey, const std::string& sInfo) ;
|
||||
BOOL __stdcall EgtGetInfo( int nGseCtx, int nId, const std::string& sKey, std::string& sInfo) ;
|
||||
BOOL __stdcall EgtExistsInfo( int nGseCtx, int nId, const std::string& sKey) ;
|
||||
BOOL __stdcall EgtRemoveInfo( int nGseCtx, int nId, const std::string& sKey) ;
|
||||
|
||||
//--------------------------- GeoSnap ----------------------------------------
|
||||
BOOL __stdcall EgtFrame( int nGseCtx, int nId, Frame3d& frFrame) ;
|
||||
|
||||
//--------------------------- Exchange ---------------------------------------
|
||||
int __stdcall EgtGetFileType( const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtImportDxf( int nGseCtx, const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtImportStl( int nGseCtx, const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtImportCnc( int nGseCtx, const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtExportDxf( int nGseCtx, int nId, const std::string& sFilePath) ;
|
||||
BOOL __stdcall EgtExportStl( int nGseCtx, int nId, const std::string& sFilePath) ;
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_CurveModif.cpp Data : 03.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di modifica delle curve per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 03.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtInvertCurve( int nGseCtx, int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// la inverto
|
||||
return ( pCurve->Invert() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveStartPoint( int nGseCtx, int nId, const double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// ne modifico il punto iniziale
|
||||
return ( pCurve->ModifyStart( Point3d( ptP)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveEndPoint( int nGseCtx, int nId, const double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// ne modifico il punto finale
|
||||
return ( pCurve->ModifyEnd( Point3d( ptP)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveExtrusion( int nGseCtx, int nId, const double vtExtr[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// ne modifico il vettore estrusione
|
||||
return ( pCurve->SetExtrusion( Vector3d( vtExtr)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveThickness( int nGseCtx, int nId, double dThick)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// ne modifico lo spessore
|
||||
return ( pCurve->SetThickness( dThick) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveStartAtLen( int nGseCtx, int nId, double dLen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// taglio la curva all'inizio
|
||||
return ( pCurve->TrimStartAtLen( dLen) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveEndAtLen( int nGseCtx, int nId, double dLen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// taglio la curva alla fine
|
||||
return ( pCurve->TrimEndAtLen( dLen) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveStartAtParam( int nGseCtx, int nId, double dPar)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// taglio la curva all'inizio
|
||||
return ( pCurve->TrimStartAtParam( dPar) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveEndAtParam( int nGseCtx, int nId, double dPar)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// taglio la curva all'inizio
|
||||
return ( pCurve->TrimEndAtParam( dPar) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveStartEndAtParam( int nGseCtx, int nId, double dParS, double dParE)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// taglio la curva all'inizio
|
||||
return ( pCurve->TrimStartEndAtParam( dParS, dParE) ? TRUE : FALSE) ;
|
||||
}
|
||||
+48
-6
@@ -30,10 +30,17 @@ using namespace std ;
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetFileType( const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtGetFileType( wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetFileType( const string& sFilePath)
|
||||
{
|
||||
// divido in nome e direttorio
|
||||
string sFileDir, sFileName ;
|
||||
SplitLast( wstrztoA( wsFilePath), "\\", sFileDir, sFileName) ;
|
||||
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
||||
|
||||
// recupero l'estensione
|
||||
string sFileTitle, sFileExt ;
|
||||
@@ -61,6 +68,13 @@ __stdcall EgtGetFileType( const wchar_t* wsFilePath)
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportDxf( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtImportDxf( nGseCtx, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportDxf( int nGseCtx, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
@@ -71,12 +85,19 @@ __stdcall EgtImportDxf( int nGseCtx, const wchar_t* wsFilePath)
|
||||
PtrOwner<IImportDxf> pImpDxf( CreateImportDxf()) ;
|
||||
VERIFY_NULL( Get( pImpDxf), "Error in CreateImportDxf", FALSE)
|
||||
// eseguo l'importazione
|
||||
return ( pImpDxf->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ;
|
||||
return ( pImpDxf->Import( sFilePath, pGeomDB, nPartId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportStl( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtImportStl( nGseCtx, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportStl( int nGseCtx, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
@@ -88,12 +109,19 @@ __stdcall EgtImportStl( int nGseCtx, const wchar_t* wsFilePath)
|
||||
PtrOwner<IImportStl> pImpStl( CreateImportStl()) ;
|
||||
VERIFY_NULL( Get( pImpStl), "Error in CreateImportStl", FALSE)
|
||||
// eseguo l'importazione
|
||||
return ( pImpStl->Import( wstrztoA( wsFilePath), pGeomDB, nLayerId) ? TRUE : FALSE) ;
|
||||
return ( pImpStl->Import( sFilePath, pGeomDB, nLayerId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportCnc( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtImportCnc( nGseCtx, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportCnc( int nGseCtx, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
@@ -104,12 +132,19 @@ __stdcall EgtImportCnc( int nGseCtx, const wchar_t* wsFilePath)
|
||||
PtrOwner<IImportCnc> pImpCnc( CreateImportCnc()) ;
|
||||
VERIFY_NULL( Get( pImpCnc), "Error in CreateImportCnc", FALSE)
|
||||
// eseguo l'importazione
|
||||
return ( pImpCnc->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ;
|
||||
return ( pImpCnc->Import( sFilePath, pGeomDB, nPartId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportDxf( int nGseCtx, int nId, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtExportDxf( nGseCtx, nId, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportDxf( int nGseCtx, int nId, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
@@ -118,12 +153,19 @@ __stdcall EgtExportDxf( int nGseCtx, int nId, const wchar_t* wsFilePath)
|
||||
PtrOwner<IExportDxf> pExpDxf( CreateExportDxf()) ;
|
||||
VERIFY_NULL( Get( pExpDxf), "Error in CreateExportDxf", FALSE)
|
||||
// eseguo l'esportazione
|
||||
return ( pExpDxf->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
return ( pExpDxf->Export( pGeomDB, nId, sFilePath) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportStl( int nGseCtx, int nId, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtExportStl( nGseCtx, nId, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportStl( int nGseCtx, int nId, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
@@ -132,5 +174,5 @@ __stdcall EgtExportStl( int nGseCtx, int nId, const wchar_t* wsFilePath)
|
||||
PtrOwner<IExportStl> pExpStl( CreateExportStl()) ;
|
||||
VERIFY_NULL( Get( pExpStl), "Error in CreateExportStl", FALSE)
|
||||
// eseguo l'esportazione
|
||||
return ( pExpStl->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
return ( pExpStl->Export( pGeomDB, nId, sFilePath) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,657 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_GdbCreate.cpp Data : 30.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di creazione oggetti del DB geometrico per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool GetPolyLineFromCurve( IGeomDB* pGeomDB, int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL) ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateGroup( int nGseCtx, int nParentId, const double ptOrig[3],
|
||||
const double vX[3], const double vY[3], const double vZ[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// costruisco il riferimento
|
||||
Frame3d frFrame ;
|
||||
if ( ! frFrame.Set( Point3d( ptOrig), Vector3d( vX), Vector3d( vY), Vector3d( vZ)))
|
||||
return GDB_ID_NULL ;
|
||||
// creo il gruppo
|
||||
return pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrame) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateGeoPoint( int nGseCtx, int nParentId, const double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo il punto
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
if ( IsNull( pGeoPnt))
|
||||
return GDB_ID_NULL ;
|
||||
// setto il punto
|
||||
if ( ! pGeoPnt->Set( Point3d( ptP)))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il punto nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateGeoVector( int nGseCtx, int nParentId, const double vtV[3], const double ptB[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo il vettore
|
||||
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
|
||||
if ( IsNull( pGeoVct))
|
||||
return GDB_ID_NULL ;
|
||||
// setto il vettore (con il punto base)
|
||||
if ( ! pGeoVct->Set( Vector3d( vtV), Point3d( ptB)))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il vettore nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateGeoFrame( int nGseCtx, int nParentId, const double ptOrig[3],
|
||||
const double vX[3], const double vY[3], const double vZ[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo il riferimento
|
||||
PtrOwner<IGeoFrame3d> pGeoFrm( CreateGeoFrame3d()) ;
|
||||
if ( IsNull( pGeoFrm))
|
||||
return GDB_ID_NULL ;
|
||||
// setto il riferimento
|
||||
if ( ! pGeoFrm->Set( Point3d( ptOrig), Vector3d( vX), Vector3d( vY), Vector3d( vZ)))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il vettore nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveLine( int nGseCtx, int nParentId,
|
||||
const double ptIni[3], const double ptFin[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la linea
|
||||
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pCrvLine))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la linea
|
||||
if ( ! pCrvLine->Set( Point3d( ptIni), Point3d( ptFin)))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la linea nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveLineMinPointCurve( int nGseCtx, int nParentId,
|
||||
const double ptStart[3], int nCrvId, double dNearPar)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frPoint ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frPoint))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCurve ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCrvId, frCurve))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero la curva
|
||||
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// porto il punto nel riferimento della curva
|
||||
Point3d ptSloc = ptStart ;
|
||||
ptSloc.LocToLoc( frPoint, frCurve) ;
|
||||
// calcolo il punto a minima distanza
|
||||
int nFlag ;
|
||||
Point3d ptEnd ;
|
||||
DistPointCurve dstPtCurve( ptSloc, *pCurve) ;
|
||||
if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEnd, nFlag))
|
||||
return GDB_ID_NULL ;
|
||||
// porto il punto finale nel riferimento di creazione
|
||||
ptEnd.LocToLoc( frCurve, frPoint) ;
|
||||
// creo la linea
|
||||
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pCrvLine))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la linea
|
||||
if ( ! pCrvLine->Set( Point3d( ptStart), ptEnd))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la linea nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCircle( int nGseCtx, int nParentId,
|
||||
const double ptCen[3], const double vtN[3], double dRad)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la circonferenza
|
||||
if ( ! pCrvArc->Set( Point3d( ptCen), Vector3d( vtN), dRad))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCircleXY( int nGseCtx, int nParentId,
|
||||
const double ptCen[3], double dRad)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la circonferenza
|
||||
if ( ! pCrvArc->SetXY( Point3d( ptCen), dRad))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCircle3P( int nGseCtx, int nParentId,
|
||||
const double ptP1[3], const double ptP2[3], const double ptP3[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->Set3P( Point3d( ptP1), Point3d( ptP2), Point3d( ptP3), true))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveArc( int nGseCtx, int nParentId,
|
||||
const double ptCen[3], const double vtN[3], double dRad,
|
||||
const double vtS[3], double dAngCenDeg, double dDeltaN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->Set( Point3d( ptCen), Vector3d( vtN), dRad, Vector3d( vtS), dAngCenDeg, dDeltaN))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveArcXY( int nGseCtx, int nParentId,
|
||||
const double ptCen[3], double dRad,
|
||||
double dAngStartDeg, double dAngCenDeg, double dDeltaZ)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->SetXY( Point3d( ptCen), dRad, dAngStartDeg, dAngCenDeg, dDeltaZ))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveArc3P( int nGseCtx, int nParentId,
|
||||
const double ptP1[3], const double ptP2[3], const double ptP3[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// setto l'arco
|
||||
if ( ! pCrvArc->Set3P( Point3d( ptP1), Point3d( ptP2), Point3d( ptP3), false))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco l'arco nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveBezier( int nGseCtx, int nParentId, int nDegree, const double ptCtrls[])
|
||||
{
|
||||
PNTVECTOR vPnt ;
|
||||
vPnt.reserve( nDegree + 1) ;
|
||||
for ( int i = 0 ; i <= nDegree ; ++i) {
|
||||
vPnt.push_back( Point3d( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2])) ;
|
||||
}
|
||||
return EgtCreateCurveBezier( nGseCtx, nParentId, nDegree, vPnt) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveBezier( int nGseCtx, int nParentId, int nDegree, const PNTVECTOR& vPnt)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// il numero dei punti deve essere pari al grado + 1
|
||||
if ( vPnt.size() != nDegree + 1)
|
||||
return GDB_ID_NULL ;
|
||||
// creo la curva di Bezier
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return GDB_ID_NULL ;
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDegree, false))
|
||||
return GDB_ID_NULL ;
|
||||
// setto i punti di controllo
|
||||
for ( int i = 0 ; i <= nDegree ; ++ i) {
|
||||
if ( ! pCrvBez->SetControlPoint( i, vPnt[i]))
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
// se curva nulla (ovvero ridotta a punto), errore
|
||||
if ( pCrvBez->IsAPoint())
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveBezierRational( int nGseCtx, int nParentId, int nDegree, const double ptCtrlWs[])
|
||||
{
|
||||
PNTUVECTOR vPntW ;
|
||||
vPntW.reserve( nDegree + 1) ;
|
||||
for ( int i = 0 ; i <= nDegree ; ++i) {
|
||||
vPntW.push_back( make_pair( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3])) ;
|
||||
}
|
||||
return EgtCreateCurveBezierRational( nGseCtx, nParentId, nDegree, vPntW) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveBezierRational( int nGseCtx, int nParentId, int nDegree, const PNTUVECTOR& vPntW)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// il numero dei punti deve essere pari al grado + 1
|
||||
if ( vPntW.size() != nDegree + 1)
|
||||
return GDB_ID_NULL ;
|
||||
// creo la curva di Bezier
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return GDB_ID_NULL ;
|
||||
// inizializzo la curva di Bezier
|
||||
if ( ! pCrvBez->Init( nDegree, true))
|
||||
return GDB_ID_NULL ;
|
||||
// setto i punti di controllo
|
||||
for ( int i = 0 ; i <= nDegree ; ++ i) {
|
||||
if ( ! pCrvBez->SetControlPoint( i, vPntW[i].first, vPntW[i].second))
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
// se curva nulla (ovvero ridotta a punto), errore
|
||||
if ( pCrvBez->IsAPoint())
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveBezierFromArc( int nGseCtx, int nParentId, int nArcId, BOOL bErase)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la curva di Bezier
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero l'arco
|
||||
const ICurveArc* pCrvArc = GetCurveArc( pGeomDB->GetGeoObj( nArcId)) ;
|
||||
if ( pCrvArc == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// ne deduco la curva di Bezier
|
||||
if ( ! pCrvBez->FromArc( *pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento dell'arco
|
||||
Frame3d frSou ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nArcId, frSou))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// porto la curva di Bezier dal riferimento dell'arco a quello di inserimento
|
||||
if ( ! AreSameFrame( frSou, frDest)) {
|
||||
pCrvBez->ToGlob( frSou) ;
|
||||
pCrvBez->ToLoc( frDest) ;
|
||||
}
|
||||
// se curva nulla (ovvero ridotta a punto), errore
|
||||
if ( pCrvBez->IsAPoint())
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
// se richiesto, cancello l'arco originale
|
||||
if ( bErase) {
|
||||
if ( ! pGeomDB->Erase( nArcId))
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
}
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompo( int nGseCtx, int nParentId, int nNumId, const int nIds[], BOOL bErase)
|
||||
{
|
||||
INTVECTOR vIds ;
|
||||
vIds.reserve( nNumId) ;
|
||||
for ( int i = 0 ; i < nNumId ; ++i) {
|
||||
vIds.push_back( nIds[i]) ;
|
||||
}
|
||||
return EgtCreateCurveCompo( nGseCtx, nParentId, vIds, ( bErase != FALSE)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompo( int nGseCtx, int nParentId, const INTVECTOR& vIds, bool bErase)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
|
||||
return false ;
|
||||
// esecuzione
|
||||
INTVECTOR::const_iterator Iter ;
|
||||
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
|
||||
// recupero la curva
|
||||
int nIdCrv = *Iter ;
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nIdCrv)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frSou ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nIdCrv, frSou))
|
||||
return false ;
|
||||
// se i riferimenti sono uguali
|
||||
if ( AreSameFrame( frSou, frDest)) {
|
||||
// aggiungo direttamente questa curva
|
||||
if ( ! pCrvCompo->AddCurve( *pCrv))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti devo prima trasformare la curva
|
||||
else {
|
||||
// creo una copia della curva
|
||||
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
|
||||
if ( IsNull( pModCrv))
|
||||
return false ;
|
||||
// eseguo la trasformazione
|
||||
pModCrv->LocToLoc( frSou, frDest) ;
|
||||
// aggiungo la curva modificata
|
||||
if ( ! pCrvCompo->AddCurve( Release( pModCrv)))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// inserisco la curva composita nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
|
||||
if ( ! pGeomDB->Erase( *Iter))
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompoFromPoints( int nGseCtx, int nParentId, int nP, const double ptPs[])
|
||||
{
|
||||
PolyLine PL ;
|
||||
for ( int i = 0 ; i < nP ; ++i) {
|
||||
PL.AddUPoint( 0, Point3d( ptPs[3*i], ptPs[3*i+1], ptPs[3*i+2])) ;
|
||||
}
|
||||
return EgtCreateCurveCompoFromPoints( nGseCtx, nParentId, PL) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompoFromPoints( int nGseCtx, int nParentId, const PolyLine& PL)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco i segmenti che uniscono i punti
|
||||
if ( ! pCrvCompo->FromPolyLine( PL))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva composita nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompoFromPointBulges( int nGseCtx, int nParentId, int nPB, const double ptPBs[])
|
||||
{
|
||||
PolyArc PA ;
|
||||
for ( int i = 0 ; i < nPB ; ++i) {
|
||||
PA.AddUPoint( 0, Point3d( ptPBs[4*i], ptPBs[4*i+1], ptPBs[4*i+2]), ptPBs[4*i+3]) ;
|
||||
}
|
||||
return EgtCreateCurveCompoFromPointBulges( nGseCtx, nParentId, PA) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompoFromPointBulges( int nGseCtx, int nParentId, const PolyArc& PA)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco i segmenti e gli archi che uniscono i punti
|
||||
if ( ! pCrvCompo->FromPolyArc( PA))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva composita nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateCurveCompoFromPolygonSide( int nGseCtx, int nParentId, int nNumSides,
|
||||
const double ptIni[3], const double ptFin[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo la curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la curva
|
||||
if ( ! pCrvCompo->PolygonSide( nNumSides, Point3d( ptIni), Point3d( ptFin)))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la curva nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateSurfTriMeshByContour( int nGseCtx, int nParentId, int nCrvId, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! GetPolyLineFromCurve( pGeomDB, nCrvId, frDest, dLinTol, PL))
|
||||
return GDB_ID_NULL ;
|
||||
// creo la superficie trimesh
|
||||
PtrOwner<ISurfTriMesh> pSTM( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pSTM))
|
||||
return GDB_ID_NULL ;
|
||||
// setto la superficie
|
||||
if ( ! pSTM->CreateByFlatContour( PL))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco la superficie nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateText( int nGseCtx, int nParentId, const wchar_t* wsText,
|
||||
const double ptP[3], double dAngRotDeg, double dH)
|
||||
{
|
||||
return EgtCreateText( nGseCtx, nParentId, wstrztoA( wsText), Point3d( ptP), dAngRotDeg, dH) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateText( int nGseCtx, int nParentId, const string& sText,
|
||||
const Point3d& ptP, double dAngRotDeg, double dH)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo il testo
|
||||
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
||||
if ( IsNull( pTXT))
|
||||
return GDB_ID_NULL ;
|
||||
// lo riempio
|
||||
if ( ! pTXT->Set( sText, ptP, dAngRotDeg, dH))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il testo nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateTextEx( int nGseCtx, int nParentId, const wchar_t* wsText,
|
||||
const double ptP[3], double dAngRotDeg, const wchar_t* wsFont,
|
||||
int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos)
|
||||
{
|
||||
return EgtCreateTextEx( nGseCtx, nParentId, wstrztoA( wsText), Point3d( ptP), dAngRotDeg,
|
||||
wstrztoA( wsFont), nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCreateTextEx( int nGseCtx, int nParentId, const string& sText,
|
||||
const Point3d& ptP, double dAngRotDeg, const string& sFont,
|
||||
int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// creo il testo
|
||||
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
||||
if ( IsNull( pTXT))
|
||||
return GDB_ID_NULL ;
|
||||
// lo riempio
|
||||
if ( ! pTXT->Set( sText, ptP, dAngRotDeg, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il testo nel DB
|
||||
return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetPolyLineFromCurve( IGeomDB* pGeomDB, int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL)
|
||||
{
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
|
||||
return false ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
// se i riferimenti sono uguali
|
||||
if ( AreSameFrame( frCrv, frDest)) {
|
||||
// ricavo l'approssimazione
|
||||
if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti devo prima trasformare la curva
|
||||
else {
|
||||
// creo una copia della curva (da buttare alla fine)
|
||||
PtrOwner<ICurve> pModCrv( pCrv->Clone()) ;
|
||||
if ( IsNull( pModCrv))
|
||||
return false ;
|
||||
// eseguo la trasformazione
|
||||
pModCrv->LocToLoc( frCrv, frDest) ;
|
||||
// ricavo l'approssimazione
|
||||
if ( ! pModCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_GdbModify.cpp Data : 06.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di modifica geometrica per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtChangeVectorBase( int nGseCtx, int nId, const double ptB[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il vettore
|
||||
IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pGVect == nullptr)
|
||||
return FALSE ;
|
||||
// imposto il nuovo punto di base
|
||||
return ( pGVect->ChangeBase( Point3d( ptB)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyText( int nGseCtx, int nId, const wchar_t* wsNewText)
|
||||
{
|
||||
return EgtModifyText( nGseCtx, nId, wstrztoA( wsNewText)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyText( int nGseCtx, int nId, const string& sNewText)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// eseguo l'operazione
|
||||
return ( pTXT->ModifyText( sNewText) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtChangeTextFont( int nGseCtx, int nId, const wchar_t* wsNewFont)
|
||||
{
|
||||
return EgtChangeTextFont( nGseCtx, nId, wstrztoA( wsNewFont)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtChangeTextFont( int nGseCtx, int nId, const string& sNewFont)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// eseguo l'operazione
|
||||
return ( pTXT->ChangeFont( sNewFont) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtFlipText( int nGseCtx, int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// eseguo l'operazione
|
||||
return ( pTXT->Flip() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMirrorText( int nGseCtx, int nId, BOOL bOnL)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// eseguo l'operazione
|
||||
return ( pTXT->Mir( ( bOnL ? true : false)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTextToOutline( int nGseCtx, int nId, int nDestGroupId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// recupero il riferimento del testo
|
||||
Frame3d frTXT ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frTXT))
|
||||
return FALSE ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGroupId, frDest))
|
||||
return FALSE ;
|
||||
// recupero l'outline del testo
|
||||
ICURVEPLIST lstPCRV ;
|
||||
pTXT->GetOutline( lstPCRV) ;
|
||||
// inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento
|
||||
bool bOk = true ;
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
(*iIter)->LocToLoc( frTXT, frDest) ;
|
||||
if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGroupId, (*iIter)) == GDB_ID_NULL) {
|
||||
delete (*iIter) ;
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSplitText( int nGseCtx, int nId, int nDestGroupId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return FALSE ;
|
||||
// recupero il riferimento del testo
|
||||
Frame3d frTXT ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frTXT))
|
||||
return FALSE ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGroupId, frDest))
|
||||
return FALSE ;
|
||||
// recupero l'esplosione del testo in linee singole
|
||||
IEXTTEXTPVECTOR vTxt ;
|
||||
pTXT->SplitOnLineBreak( vTxt) ;
|
||||
// inserisco i nuovi testi nel gruppo destinazione dopo aver sistemato il cambio di riferimento
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) {
|
||||
vTxt[i]->LocToLoc( frTXT, frDest) ;
|
||||
if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGroupId, vTxt[i]) == GDB_ID_NULL) {
|
||||
delete vTxt[i] ;
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
+128
-13
@@ -177,7 +177,7 @@ __stdcall EgtResetMark( int nGseCtx, int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// imposto l'evidenziazione
|
||||
// cancello l'evidenziazione
|
||||
return ( pGeomDB->ResetMark( nId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
@@ -207,30 +207,117 @@ __stdcall EgtGetCalcMark( int nGseCtx, int nId, BOOL* pbMark)
|
||||
return ( pGeomDB->GetCalcMark( nId, *pbMark) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtStdColor( const wchar_t* wsName, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
||||
{
|
||||
return EgtStdColor( wstrztoA( wsName), nRed, nGreen, nBlue, nAlpha) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtStdColor( const string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
||||
{
|
||||
// recupero il colore standard
|
||||
Color cCol ;
|
||||
if ( GetStdColor( sName, cCol)) {
|
||||
nRed = cCol.GetIntRed() ;
|
||||
nGreen = cCol.GetIntGreen() ;
|
||||
nBlue = cCol.GetIntBlue() ;
|
||||
nAlpha = cCol.GetIntAlpha() ;
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetColor( int nGseCtx, int nId, int nRed, int nGreen, int nBlue, int nAlpha)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// assegno il colore
|
||||
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
||||
return ( pGeomDB->SetMaterial( nId, cCol) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetColor( int nGseCtx, int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il colore
|
||||
Color cCol ;
|
||||
if ( pGeomDB->GetMaterial( nId, cCol)) {
|
||||
nRed = cCol.GetIntRed() ;
|
||||
nGreen = cCol.GetIntGreen() ;
|
||||
nBlue = cCol.GetIntBlue() ;
|
||||
nAlpha = cCol.GetIntAlpha() ;
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetCalcColor( int nGseCtx, int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il colore
|
||||
Color cCol ;
|
||||
if ( pGeomDB->GetCalcMaterial( nId, cCol)) {
|
||||
nRed = cCol.GetIntRed() ;
|
||||
nGreen = cCol.GetIntGreen() ;
|
||||
nBlue = cCol.GetIntBlue() ;
|
||||
nAlpha = cCol.GetIntAlpha() ;
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetName( int nGseCtx, int nId, const wchar_t* wsName)
|
||||
{
|
||||
return EgtSetName( nGseCtx, nId, wstrztoA( wsName)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetName( int nGseCtx, int nId, const string& sName)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// assegno il nome
|
||||
return ( pGeomDB->SetName( nId, wstrztoA( wsName)) ? TRUE : FALSE) ;
|
||||
return ( pGeomDB->SetName( nId, sName) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetName( int nGseCtx, int nId, wchar_t*& wsName)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il nome
|
||||
string sName ;
|
||||
if ( ! pGeomDB->GetName( nId, sName))
|
||||
if ( ! EgtGetName( nGseCtx, nId, sName))
|
||||
return FALSE ;
|
||||
wsName = _wcsdup( stringtoW( sName)) ;
|
||||
return (( wsName == nullptr) ? FALSE : TRUE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetName( int nGseCtx, int nId, string& sName)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero il nome
|
||||
return pGeomDB->GetName( nId, sName) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExistsName( int nGseCtx, int nId)
|
||||
@@ -254,43 +341,71 @@ __stdcall EgtRemoveName( int nGseCtx, int nId)
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetInfo( int nGseCtx, int nId, const wchar_t* wsKey, const wchar_t* wsInfo)
|
||||
{
|
||||
return EgtSetInfo( nGseCtx, nId, wstrztoA( wsKey), wstrztoA( wsInfo)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetInfo( int nGseCtx, int nId, const string& sKey, const string& sInfo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// assegno la info
|
||||
return ( pGeomDB->SetInfo( nId, wstrztoA( wsKey), string( wstrztoA( wsInfo))) ? TRUE : FALSE) ;
|
||||
return ( pGeomDB->SetInfo( nId, sKey, sInfo) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetInfo( int nGseCtx, int nId, const wchar_t* wsKey, wchar_t*& wsInfo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero la info
|
||||
string sInfo ;
|
||||
if ( ! pGeomDB->GetInfo( nId, wstrztoA( wsKey), sInfo))
|
||||
if ( ! EgtGetInfo( nGseCtx, nId, wstrztoA( wsKey), sInfo))
|
||||
return FALSE ;
|
||||
wsInfo = _wcsdup( stringtoW( sInfo)) ;
|
||||
return (( wsInfo == nullptr) ? FALSE : TRUE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetInfo( int nGseCtx, int nId, const string& sKey, string& sInfo)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero la info
|
||||
return pGeomDB->GetInfo( nId, sKey, sInfo) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExistsInfo( int nGseCtx, int nId, const wchar_t* wsKey)
|
||||
{
|
||||
return EgtExistsInfo( nGseCtx, nId, wstrztoA( wsKey)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExistsInfo( int nGseCtx, int nId, const string& sKey)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// verifico esistenza info
|
||||
return ( pGeomDB->ExistsInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ;
|
||||
return ( pGeomDB->ExistsInfo( nId, sKey) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRemoveInfo( int nGseCtx, int nId, const wchar_t* wsKey)
|
||||
{
|
||||
return EgtRemoveInfo( nGseCtx, nId, wstrztoA( wsKey)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRemoveInfo( int nGseCtx, int nId, const string& sKey)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// rimuovo la info
|
||||
return ( pGeomDB->RemoveInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ;
|
||||
return ( pGeomDB->RemoveInfo( nId, sKey) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
+53
-3
@@ -28,8 +28,8 @@ BOOL
|
||||
__stdcall EgtExistsObj( int nGseCtx, int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero il primo oggetto nel gruppo
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// verifico se esiste l'oggetto
|
||||
return ( pGeomDB->ExistsObj( nId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ int
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero il primo oggetto nel gruppo
|
||||
// recupero il numero di oggetti nel gruppo
|
||||
return ( pGeomDB->GetGroupObjs( nId)) ;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,56 @@ __stdcall EgtGetPrev( int nGseCtx, int nId)
|
||||
return pGeomDB->GetPrev( nId) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCopy( int nGseCtx, int nSouId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// eseguo la copia
|
||||
return pGeomDB->Copy( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtCopyGlob( int nGseCtx, int nSouId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// eseguo la copia mantenendo la posizione in globale
|
||||
return pGeomDB->CopyGlob( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRelocate( int nGseCtx, int nSouId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// eseguo la rilocazione
|
||||
return ( pGeomDB->Relocate( nSouId, nRefId, nSonBeforeAfter) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRelocateGlob( int nGseCtx, int nSouId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// eseguo la rilocazione mantenendo la posizione in globale
|
||||
return ( pGeomDB->RelocateGlob( nSouId, nRefId, nSonBeforeAfter) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtErase( int nGseCtx, int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// eseguo la cancellazione
|
||||
return ( pGeomDB->Erase( nId) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetType( int nGseCtx, int nId)
|
||||
|
||||
+10
-2
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInDllMain.h"
|
||||
#include "/EgtDev/Include/EGkDllMain.h"
|
||||
@@ -64,6 +65,9 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile)
|
||||
LOG_INFO( s_pLogGen, GetEExVersion())
|
||||
LOG_INFO( s_pLogGen, GetEGrVersion())
|
||||
|
||||
// inizializzo l'interprete LUA
|
||||
LuaInit() ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -71,11 +75,15 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile)
|
||||
BOOL
|
||||
__stdcall EgtExit( void)
|
||||
{
|
||||
// cancello tutti i contesti
|
||||
ClearAllGseContexts() ;
|
||||
|
||||
// termino l'interprete LUA
|
||||
LuaExit() ;
|
||||
|
||||
// fine programma
|
||||
LOG_DATETIME( s_pLogGen, " Exit")
|
||||
|
||||
// cancello tutti i contesti
|
||||
ClearAllGseContexts() ;
|
||||
// cancello il logger
|
||||
if ( s_pLogGen != nullptr) {
|
||||
delete s_pLogGen ;
|
||||
|
||||
+406
@@ -0,0 +1,406 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_GeoSnap.cpp Data : 02.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di snap ad oggetti del DB geometrico per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtStartPoint( int nGseCtx, int nId, double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se punto
|
||||
if ( pGObj->GetType() == GEO_PNT3D) {
|
||||
// recupero il geo-punto
|
||||
const IGeoPoint3d* pGP = GetGeoPoint3d( pGObj) ;
|
||||
Point3d ptStart = pGP->GetPoint() ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se vettore
|
||||
else if ( pGObj->GetType() == GEO_VECT3D) {
|
||||
// recupero il geo-vettore
|
||||
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
|
||||
Point3d ptStart = pGV->GetBase() ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se frame
|
||||
else if ( pGObj->GetType() == GEO_FRAME3D) {
|
||||
// recupero il frame
|
||||
const IGeoFrame3d* pGF = GetGeoFrame3d( pGObj) ;
|
||||
Point3d ptStart = pGF->GetFrame().Orig() ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se curva
|
||||
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Point3d ptStart ;
|
||||
if ( ! pCrv->GetStartPoint( ptStart))
|
||||
return FALSE ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
Point3d ptStart ;
|
||||
if ( ! pTxt->GetStartPoint( ptStart))
|
||||
return false ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtEndPoint( int nGseCtx, int nId, double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pCrv->GetEndPoint( ptEnd))
|
||||
return FALSE ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pTxt->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMidPoint( int nGseCtx, int nId, double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pCrv->GetMidPoint( ptEnd))
|
||||
return FALSE ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pTxt->GetMidPoint( ptEnd))
|
||||
return false ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtCenterPoint( int nGseCtx, int nId, double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pCrv->GetCenterPoint( ptEnd))
|
||||
return FALSE ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
Point3d ptEnd ;
|
||||
if ( ! pTxt->GetCenterPoint( ptEnd))
|
||||
return false ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptEnd.x ;
|
||||
ptP[1] = ptEnd.y ;
|
||||
ptP[2] = ptEnd.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtAtParamPoint( int nGseCtx, int nId, double dU, double ptP[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Point3d ptStart ;
|
||||
if ( ! pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptStart))
|
||||
return FALSE ;
|
||||
// assegno il punto
|
||||
ptP[0] = ptStart.x ;
|
||||
ptP[1] = ptStart.y ;
|
||||
ptP[2] = ptStart.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtStartVector( int nGseCtx, int nId, double vtV[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se vettore
|
||||
if ( pGObj->GetType() == GEO_VECT3D) {
|
||||
// recupero il geo-vettore
|
||||
const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ;
|
||||
Vector3d vtDir = pGV->GetVector() ;
|
||||
// assegno il vettore
|
||||
vtV[0] = vtDir.x ;
|
||||
vtV[1] = vtDir.y ;
|
||||
vtV[2] = vtDir.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
// se curva
|
||||
else if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrv->GetStartDir( vtDir))
|
||||
return FALSE ;
|
||||
// assegno il vettore
|
||||
vtV[0] = vtDir.x ;
|
||||
vtV[1] = vtDir.y ;
|
||||
vtV[2] = vtDir.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtEndVector( int nGseCtx, int nId, double vtV[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrv->GetEndDir( vtDir))
|
||||
return FALSE ;
|
||||
// assegno il vettore
|
||||
vtV[0] = vtDir.x ;
|
||||
vtV[1] = vtDir.y ;
|
||||
vtV[2] = vtDir.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMidVector( int nGseCtx, int nId, double vtV[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrv->GetMidDir( vtDir))
|
||||
return FALSE ;
|
||||
// assegno il vettore
|
||||
vtV[0] = vtDir.x ;
|
||||
vtV[1] = vtDir.y ;
|
||||
vtV[2] = vtDir.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtAtParamVector( int nGseCtx, int nId, double dU, int nSide, double vtV[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return FALSE ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
// assegno il lato di approccio
|
||||
ICurve::Side nSide = ICurve::FROM_MINUS ;
|
||||
if ( nSide >0)
|
||||
nSide = ICurve::FROM_PLUS ;
|
||||
// recupero la direzione
|
||||
Vector3d vtDir ;
|
||||
Point3d ptP ;
|
||||
if ( ! pCrv->GetPointTang( dU, nSide, ptP, vtDir))
|
||||
return false ;
|
||||
// assegno il vettore
|
||||
vtV[0] = vtDir.x ;
|
||||
vtV[1] = vtDir.y ;
|
||||
vtV[2] = vtDir.z ;
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtFrame( int nGseCtx, int nId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3])
|
||||
{
|
||||
// recupero il frame
|
||||
Frame3d frFrame ;
|
||||
if ( ! EgtFrame( nGseCtx, nId, frFrame))
|
||||
return FALSE ;
|
||||
// assegno l'origine
|
||||
ptOrig[0] = frFrame.Orig().x ;
|
||||
ptOrig[1] = frFrame.Orig().y ;
|
||||
ptOrig[2] = frFrame.Orig().z ;
|
||||
// assegno il versore X
|
||||
vtX[0] = frFrame.VersX().x ;
|
||||
vtX[1] = frFrame.VersX().y ;
|
||||
vtX[2] = frFrame.VersX().z ;
|
||||
// assegno il versore Y
|
||||
vtY[0] = frFrame.VersY().x ;
|
||||
vtY[1] = frFrame.VersY().y ;
|
||||
vtY[2] = frFrame.VersY().z ;
|
||||
// assegno il versore Z
|
||||
vtZ[0] = frFrame.VersZ().x ;
|
||||
vtZ[1] = frFrame.VersZ().y ;
|
||||
vtZ[2] = frFrame.VersZ().z ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtFrame( int nGseCtx, int nId, Frame3d& frFrame)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// se gruppo
|
||||
if ( pGeomDB->GetGroupFrame( nId, frFrame))
|
||||
return TRUE ;
|
||||
// se geo frame
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) != nullptr &&
|
||||
pGObj->GetType() == GEO_FRAME3D) {
|
||||
frFrame = GetGeoFrame3d( pGObj)->GetFrame() ;
|
||||
return TRUE ;
|
||||
}
|
||||
// altrimenti errore
|
||||
return FALSE ;
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_GeoTransform.cpp Data : 30.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di trasformazione geometrica per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMove( int nGseCtx, int nId, double vVtMove[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo traslazione
|
||||
return ( pGeomDB->Translate( nId, Vector3d( vVtMove)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMoveGlob( int nGseCtx, int nId, double vVtMove[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo traslazione
|
||||
return ( pGeomDB->TranslateGlob( nId, Vector3d( vVtMove)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMoveGroup( int nGseCtx, int nId, double vVtMove[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo traslazione
|
||||
return ( pGeomDB->TranslateGroup( nId, Vector3d( vVtMove)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRotate( int nGseCtx, int nId, double vPtAx[3], double vVtAx[3], double dAngRotDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
return ( pGeomDB->Rotate( nId, Point3d( vPtAx), Vector3d( vVtAx), dAngRotDeg) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRotateGlob( int nGseCtx, int nId, double vPtAx[3], double vVtAx[3], double dAngRotDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
return ( pGeomDB->RotateGlob( nId, Point3d( vPtAx), Vector3d( vVtAx), dAngRotDeg) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtRotateGroup( int nGseCtx, int nId, double vPtAx[3], double vVtAx[3], double dAngRotDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
return ( pGeomDB->RotateGroup( nId, Point3d( vPtAx), Vector3d( vVtAx), dAngRotDeg) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtScale( int nGseCtx, int nId, const double vOrig[3],
|
||||
const double vX[3], const double vY[3], const double vZ[3],
|
||||
double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
Frame3d frFrame ;
|
||||
if ( ! frFrame.Set( Point3d( vOrig), Vector3d( vX), Vector3d( vY), Vector3d( vZ)))
|
||||
return FALSE ;
|
||||
return ( pGeomDB->Scale( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtScaleGlob( int nGseCtx, int nId, const double vOrig[3],
|
||||
const double vX[3], const double vY[3], const double vZ[3],
|
||||
double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
Frame3d frFrame ;
|
||||
if ( ! frFrame.Set( Point3d( vOrig), Vector3d( vX), Vector3d( vY), Vector3d( vZ)))
|
||||
return FALSE ;
|
||||
return ( pGeomDB->ScaleGlob( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtScaleGroup( int nGseCtx, int nId, const double vOrig[3],
|
||||
const double vX[3], const double vY[3], const double vZ[3],
|
||||
double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo rotazione
|
||||
Frame3d frFrame ;
|
||||
if ( ! frFrame.Set( Point3d( vOrig), Vector3d( vX), Vector3d( vY), Vector3d( vZ)))
|
||||
return FALSE ;
|
||||
return ( pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMirror( int nGseCtx, int nId, const double vPnt[3], const double vN[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo specularità
|
||||
return ( pGeomDB->Mirror( nId, Point3d( vPnt), Vector3d( vN)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMirrorGlob( int nGseCtx, int nId, const double vPnt[3], const double vN[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo specularità
|
||||
return ( pGeomDB->MirrorGlob( nId, Point3d( vPnt), Vector3d( vN)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtMirrorGroup( int nGseCtx, int nId, const double vPnt[3], const double vN[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo specularità
|
||||
return ( pGeomDB->MirrorGroup( nId, Point3d( vPnt), Vector3d( vN)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtShear( int nGseCtx, int nId, const double vPnt[3], const double vN[3],
|
||||
const double vDir[3], double dCoeff)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo stiramento
|
||||
return ( pGeomDB->Shear( nId, Point3d( vPnt), Vector3d( vN), Vector3d( vDir), dCoeff) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtShearGlob( int nGseCtx, int nId, const double vPnt[3], const double vN[3],
|
||||
const double vDir[3], double dCoeff)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo stiramento
|
||||
return ( pGeomDB->ShearGlob( nId, Point3d( vPnt), Vector3d( vN), Vector3d( vDir), dCoeff) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtShearGroup( int nGseCtx, int nId, const double vPnt[3], const double vN[3],
|
||||
const double vDir[3], double dCoeff)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// eseguo stiramento
|
||||
return ( pGeomDB->ShearGroup( nId, Point3d( vPnt), Vector3d( vN), Vector3d( vDir), dCoeff) ? TRUE : FALSE) ;
|
||||
}
|
||||
+16
-2
@@ -74,20 +74,34 @@ __stdcall EgtNewFile( int nGseCtx)
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtOpenFile( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtOpenFile( nGseCtx, wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtOpenFile( int nGseCtx, const string& sFilePath)
|
||||
{
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
if ( ! EgtNewFile( nGseCtx))
|
||||
return FALSE ;
|
||||
// carico il file
|
||||
return ( GetGeomDB( nGseCtx)->Load( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
return ( GetGeomDB( nGseCtx)->Load( sFilePath) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSaveFile( int nGseCtx, const wchar_t* wsFilePath, int nFlag)
|
||||
{
|
||||
return EgtSaveFile( nGseCtx, wstrztoA( wsFilePath), nFlag) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSaveFile( int nGseCtx, const string& sFilePath, int nFlag)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// salvo il file
|
||||
return ( pGeomDB->Save( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ;
|
||||
return ( pGeomDB->Save( sFilePath, nFlag) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_LUA.cpp Data : 28.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni esecuzione LUA per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 28.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtLuaSetContext( int nGseCtx)
|
||||
{
|
||||
return ( LuaSetGseContext( nGseCtx) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtLuaExecLine( const wchar_t* wsLine)
|
||||
{
|
||||
// eseguo il comando
|
||||
return ( LuaExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtLuaExecFile( const wchar_t* wsFilePath)
|
||||
{
|
||||
// converto nome file
|
||||
string sFilePath = wstrztoA( wsFilePath) ;
|
||||
// emetto info
|
||||
string sInfo = "Exec File = " + sFilePath ;
|
||||
LOG_INFO( GetLogger(), sInfo.c_str())
|
||||
|
||||
// esecuzione script
|
||||
return ( LuaExecFile( sFilePath) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtLuaGetLastError( wchar_t*& wsError)
|
||||
{
|
||||
wsError = _wcsdup( stringtoW( LuaGetLastError())) ;
|
||||
return (( wsError == nullptr) ? FALSE : TRUE) ;
|
||||
}
|
||||
+39
-13
@@ -64,7 +64,7 @@ __stdcall EgtSetBackground( int nGseCtx, int nTopRed, int nTopGreen, int nTopBlu
|
||||
pGseCtx->m_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue),
|
||||
Color( nBottomRed, nBottomGreen, nBottomBlue)) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ __stdcall EgtSetShowMode( int nGseCtx, int nShowMode, BOOL bRedraw)
|
||||
if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) {
|
||||
pGseCtx->m_pScene->SetShowMode( nShowMode) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
@@ -119,7 +119,7 @@ __stdcall EgtSetShowCurveDirection( int nGseCtx, int nShow, BOOL bRedraw)
|
||||
// imposto stato
|
||||
pGseCtx->m_pScene->SetShowCurveDirection( nShow != 0) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -137,19 +137,19 @@ __stdcall EgtZoom( int nGseCtx, int nZoom, BOOL bRedraw)
|
||||
case 1 :
|
||||
pGseCtx->m_pScene->ZoomAll() ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
break ;
|
||||
case 2 :
|
||||
pGseCtx->m_pScene->ZoomChange( COEFF_IN) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
break ;
|
||||
case 3 :
|
||||
pGseCtx->m_pScene->ZoomChange( COEFF_OUT) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
break ;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ __stdcall EgtZoomOnPoint( int nGseCtx, int nWinX, int nWinY, double dCoeff, BOOL
|
||||
// eseguo zoom
|
||||
pGseCtx->m_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ __stdcall EgtSetWinRect( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nC
|
||||
// disegno finestra per zoom
|
||||
pGseCtx->m_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ __stdcall EgtResetWinRect( int nGseCtx, BOOL bRedraw)
|
||||
// cancello finestra per zoom
|
||||
pGseCtx->m_pScene->ResetWinRect() ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ __stdcall EgtZoomWin( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurr
|
||||
// eseguo zoom su finestra
|
||||
pGseCtx->m_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -219,13 +219,39 @@ __stdcall EgtSetView( int nGseCtx, int nView, BOOL bRedraw)
|
||||
if ( nView >= CT_TOP && nView <= CT_ISO_NW) {
|
||||
pGseCtx->m_pScene->SetCamera( nView) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetGenericView( int nGseCtx, double dAngVertDeg, double dAngHorizDeg, BOOL bRedraw)
|
||||
{
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
VERIFY_CTX_SCENE( pGseCtx, FALSE)
|
||||
// imposto vista
|
||||
pGseCtx->m_pScene->SetCamera( dAngVertDeg, dAngHorizDeg, 0) ;
|
||||
if ( bRedraw)
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetViewCenter( int nGseCtx, double ptP[3], BOOL bRedraw)
|
||||
{
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
VERIFY_CTX_SCENE( pGseCtx, FALSE)
|
||||
// imposto vista
|
||||
pGseCtx->m_pScene->SetCenter( Point3d( ptP[0], ptP[1], ptP[2])) ;
|
||||
if ( bRedraw)
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw)
|
||||
@@ -235,7 +261,7 @@ __stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCu
|
||||
// eseguo panoramica
|
||||
pGseCtx->m_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
@@ -248,7 +274,7 @@ __stdcall EgtRotateCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int
|
||||
// eseguo rotazione camera
|
||||
pGseCtx->m_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
if ( bRedraw)
|
||||
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
|
||||
pGseCtx->m_pScene->RedrawWindow() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ __stdcall EgtInitTscExec( int nGseCtx)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTscFileExec( int nGseCtx, const wchar_t* wsFilePath)
|
||||
__stdcall EgtTscExecFile( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
ICmdParser* pTscExec = GetTscExecutor( nGseCtx) ;
|
||||
VERIFY_TSCEXEC( pTscExec, FALSE)
|
||||
@@ -94,7 +94,7 @@ __stdcall EgtTscFileExec( int nGseCtx, const wchar_t* wsFilePath)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTscLineExec( int nGseCtx, const wchar_t* wsLine)
|
||||
__stdcall EgtTscExecLine( int nGseCtx, const wchar_t* wsLine)
|
||||
{
|
||||
ICmdParser* pTscExec = GetTscExecutor( nGseCtx) ;
|
||||
VERIFY_TSCEXEC( pTscExec, FALSE)
|
||||
|
||||
Binary file not shown.
+20
-1
@@ -120,7 +120,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<GenerateMapFile>true</GenerateMapFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\
|
||||
@@ -190,19 +190,38 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="API.h" />
|
||||
<ClInclude Include="API_Macro.h" />
|
||||
<ClInclude Include="GseContext.h" />
|
||||
<ClInclude Include="LUA.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="API_CurveModif.cpp" />
|
||||
<ClCompile Include="API_Exchange.cpp" />
|
||||
<ClCompile Include="API_GdbModify.cpp" />
|
||||
<ClCompile Include="API_GdbObjAttribs.cpp" />
|
||||
<ClCompile Include="API_GdbObjects.cpp" />
|
||||
<ClCompile Include="API_General.cpp" />
|
||||
<ClCompile Include="API_GdbCreate.cpp" />
|
||||
<ClCompile Include="API_GeomDB.cpp" />
|
||||
<ClCompile Include="API_GeoSnap.cpp" />
|
||||
<ClCompile Include="API_GeoTransform.cpp" />
|
||||
<ClCompile Include="API_Lua.cpp" />
|
||||
<ClCompile Include="API_Scene.cpp" />
|
||||
<ClCompile Include="API_TscExec.cpp" />
|
||||
<ClCompile Include="EInDllMain.cpp" />
|
||||
<ClCompile Include="GseContext.cpp" />
|
||||
<ClCompile Include="LUA_Aux.cpp" />
|
||||
<ClCompile Include="LUA_CurveModif.cpp" />
|
||||
<ClCompile Include="LUA_Exchange.cpp" />
|
||||
<ClCompile Include="LUA_GdbModify.cpp" />
|
||||
<ClCompile Include="LUA_GdbObjAttribs.cpp" />
|
||||
<ClCompile Include="LUA_GdbObjects.cpp" />
|
||||
<ClCompile Include="LUA_General.cpp" />
|
||||
<ClCompile Include="LUA_GdbCreate.cpp" />
|
||||
<ClCompile Include="LUA_GeomDB.cpp" />
|
||||
<ClCompile Include="LUA_GeoSnap.cpp" />
|
||||
<ClCompile Include="LUA_GeoTransform.cpp" />
|
||||
<ClCompile Include="LUA_Scene.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
<ClInclude Include="API_Macro.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LUA.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -68,6 +71,60 @@
|
||||
<ClCompile Include="API_Exchange.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_General.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_LUA.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GeomDB.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_Aux.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_Exchange.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_Scene.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GeoTransform.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_GdbCreate.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbCreate.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_GeoTransform.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbObjAttribs.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbObjects.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_GeoSnap.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GeoSnap.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_CurveModif.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_CurveModif.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="API_GdbModify.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbModify.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtInterface.rc">
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA.h Data : 27.09.14 Versione : 1.5i5
|
||||
// Contenuto : Dichiarazioni locali per moduli LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "/EgtDev/Include/EgkGeoCollection.h"
|
||||
|
||||
struct lua_State ;
|
||||
class Vector3d ;
|
||||
class Point3d ;
|
||||
class Frame3d ;
|
||||
class Color ;
|
||||
|
||||
//-------------------------- General -----------------------------------------
|
||||
bool LuaInit( void) ;
|
||||
bool LuaExit( void) ;
|
||||
bool LuaSetGseContext( int nGseContext) ;
|
||||
int LuaGetGseContext( void) ;
|
||||
bool LuaExecLine( const std::string& sLine) ;
|
||||
bool LuaExecFile( const std::string& sFile) ;
|
||||
const std::string& LuaGetLastError( void) ;
|
||||
bool LuaInstallGeneral( lua_State* L) ;
|
||||
|
||||
//-------------------------- Aux ---------------------------------------------
|
||||
#define LuaCheckParam(L,I,P) { if ( ! LuaGetParam(L,I,P)) return luaL_error( L, " Invalid Parameter # " #I) ;}
|
||||
bool LuaGetParam( lua_State* L, int nInd, bool& bPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, int& nPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, double& dPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, std::string& sPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, Vector3d& vtPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, Point3d& ptPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, POINTU& ptParW) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, Frame3d& frPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, Color& colPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, INTVECTOR& vPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, PNTVECTOR& vPar) ;
|
||||
bool LuaGetParam( lua_State* L, int nInd, PNTUVECTOR& vParW) ;
|
||||
bool LuaClearStack( lua_State* L) ;
|
||||
//
|
||||
bool LuaSetReturn( lua_State* L /* nil */) ;
|
||||
bool LuaSetReturn( lua_State* L, bool bPar) ;
|
||||
bool LuaSetReturn( lua_State* L, int nPar) ;
|
||||
bool LuaSetReturn( lua_State* L, double dPar) ;
|
||||
bool LuaSetReturn( lua_State* L, const std::string& sPar) ;
|
||||
bool LuaSetReturn( lua_State* L, const Vector3d& vtPar) ;
|
||||
bool LuaSetReturn( lua_State* L, const Point3d& ptPar) ;
|
||||
bool LuaSetReturn( lua_State* L, const Frame3d& frPar) ;
|
||||
bool LuaSetReturn( lua_State* L, const Color& colPar) ;
|
||||
|
||||
//-------------------------- GeomDB ------------------------------------------
|
||||
bool LuaInstallGeomDB( lua_State* L) ;
|
||||
|
||||
//-------------------------- GdbCreate ---------------------------------------
|
||||
bool LuaInstallGdbCreate( lua_State* L) ;
|
||||
|
||||
//-------------------------- GdbModify ---------------------------------------
|
||||
bool LuaInstallGdbModify( lua_State* L) ;
|
||||
|
||||
//-------------------------- GdbObjects --------------------------------------
|
||||
bool LuaInstallGdbObjects( lua_State* L) ;
|
||||
|
||||
//-------------------------- GdbObjAttribs -----------------------------------
|
||||
bool LuaInstallGdbObjAttribs( lua_State* L) ;
|
||||
|
||||
//-------------------------- CurveModif --------------------------------------
|
||||
bool LuaInstallCurveModif( lua_State* L) ;
|
||||
|
||||
//-------------------------- GeoSnap -----------------------------------------
|
||||
bool LuaInstallGeoSnap( lua_State* L) ;
|
||||
|
||||
//-------------------------- GeoTransform ------------------------------------
|
||||
bool LuaInstallGeoTransform( lua_State* L) ;
|
||||
|
||||
//-------------------------- Scene -------------------------------------------
|
||||
bool LuaInstallScene( lua_State* L) ;
|
||||
|
||||
//-------------------------- Exchange ----------------------------------------
|
||||
bool LuaInstallExchange( lua_State* L) ;
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_Aux.cpp Data : 29.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni ausiliarie per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 29.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EgkFrame3d.h"
|
||||
#include "/EgtDev/Include/EgkColor.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, bool& bPar)
|
||||
{
|
||||
if ( ! lua_isboolean( L, nInd))
|
||||
return false ;
|
||||
bPar = ( lua_toboolean( L, nInd) != 0) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, int& nPar)
|
||||
{
|
||||
if ( ! lua_isnumber( L, nInd))
|
||||
return false ;
|
||||
nPar = int( lua_tointeger( L, nInd)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, double& dPar)
|
||||
{
|
||||
if ( ! lua_isnumber( L, nInd))
|
||||
return false ;
|
||||
dPar = lua_tonumber( L, nInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, string& sPar)
|
||||
{
|
||||
if ( ! lua_isstring( L, nInd))
|
||||
return false ;
|
||||
sPar = lua_tostring( L, nInd) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, Vector3d& vtPar)
|
||||
{
|
||||
if ( ! lua_istable( L, nInd))
|
||||
return false ;
|
||||
for ( int i = 1 ; i <= 3 ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
vtPar.v[i-1] = lua_tonumber( L, -1) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, Point3d& ptPar)
|
||||
{
|
||||
if ( ! lua_istable( L, nInd))
|
||||
return false ;
|
||||
for ( int i = 1 ; i <= 3 ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
ptPar.v[i-1] = lua_tonumber( L, -1) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, POINTU& ptParW)
|
||||
{
|
||||
if ( ! lua_istable( L, nInd))
|
||||
return false ;
|
||||
for ( int i = 1 ; i <= 4 ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
if ( i <= 3)
|
||||
ptParW.first.v[i-1] = lua_tonumber( L, -1) ;
|
||||
else
|
||||
ptParW.second = lua_tonumber( L, -1) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, Frame3d& frPar)
|
||||
{
|
||||
if ( ! lua_istable( L, nInd))
|
||||
return false ;
|
||||
// recupero l'origine
|
||||
lua_rawgeti( L, nInd, 1) ;
|
||||
Point3d ptOrig ;
|
||||
if ( ! LuaGetParam( L, -1, ptOrig))
|
||||
return false ;
|
||||
lua_pop( L, 1) ;
|
||||
// recupero il versore X
|
||||
lua_rawgeti( L, nInd, 2) ;
|
||||
Vector3d vtDirX ;
|
||||
if ( ! LuaGetParam( L, -1, vtDirX))
|
||||
return false ;
|
||||
lua_pop( L, 1) ;
|
||||
// recupero il versore Y
|
||||
lua_rawgeti( L, nInd, 3) ;
|
||||
Vector3d vtDirY ;
|
||||
if ( ! LuaGetParam( L, -1, vtDirY))
|
||||
return false ;
|
||||
lua_pop( L, 1) ;
|
||||
// recupero il versore Z
|
||||
lua_rawgeti( L, nInd, 4) ;
|
||||
Vector3d vtDirZ ;
|
||||
if ( ! LuaGetParam( L, -1, vtDirZ))
|
||||
return false ;
|
||||
lua_pop( L, 1) ;
|
||||
// assegno il riferimento
|
||||
return frPar.Set( ptOrig, vtDirX, vtDirY, vtDirZ) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, Color& colPar)
|
||||
{
|
||||
if ( ! lua_istable( L, nInd))
|
||||
return false ;
|
||||
int nCol[4] ;
|
||||
// red, gree, blue
|
||||
for ( int i = 1 ; i <= 3 ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
nCol[i-1] = int( lua_tointeger( L, -1)) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
// alpha opzionale
|
||||
lua_rawgeti( L, nInd, 4) ;
|
||||
if ( lua_isnumber( L, -1))
|
||||
nCol[3] = int( lua_tointeger( L, -1)) ;
|
||||
else
|
||||
nCol[3] = 100 ;
|
||||
lua_pop( L, 1) ;
|
||||
// assegno il colore
|
||||
colPar.Set( nCol[0], nCol[1], nCol[2], nCol[3]) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, INTVECTOR& vPar)
|
||||
{
|
||||
vPar.clear() ;
|
||||
if ( lua_isnumber( L, nInd)) {
|
||||
int nVal = int( lua_tointeger( L, nInd)) ;
|
||||
vPar.push_back( nVal) ;
|
||||
return true ;
|
||||
}
|
||||
else if ( lua_istable( L, nInd)) {
|
||||
// lunghezza della tavola
|
||||
lua_len( L, nInd) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
int nLen = int( lua_tointeger( L, -1)) ;
|
||||
lua_pop( L, 1) ;
|
||||
vPar.reserve( nLen) ;
|
||||
for ( int i = 1 ; i <= nLen ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
int nVal = int( lua_tointeger( L, -1)) ;
|
||||
vPar.push_back( nVal) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, PNTVECTOR& vPar)
|
||||
{
|
||||
vPar.clear() ;
|
||||
Point3d ptP ;
|
||||
if ( LuaGetParam( L, nInd, ptP)) {
|
||||
vPar.push_back( ptP) ;
|
||||
return true ;
|
||||
}
|
||||
else if ( lua_istable( L, nInd)) {
|
||||
// lunghezza della tavola
|
||||
lua_len( L, nInd) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
int nLen = int( lua_tointeger( L, -1)) ;
|
||||
lua_pop( L, 1) ;
|
||||
vPar.reserve( nLen) ;
|
||||
for ( int i = 1 ; i <= nLen ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
Point3d ptP ;
|
||||
if ( ! LuaGetParam( L, -1, ptP))
|
||||
return false ;
|
||||
vPar.push_back( ptP) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaGetParam( lua_State* L, int nInd, PNTUVECTOR& vParW)
|
||||
{
|
||||
vParW.clear() ;
|
||||
POINTU ptPW ;
|
||||
if ( LuaGetParam( L, nInd, ptPW)) {
|
||||
vParW.push_back( ptPW) ;
|
||||
return true ;
|
||||
}
|
||||
else if ( lua_istable( L, nInd)) {
|
||||
// lunghezza della tavola
|
||||
lua_len( L, nInd) ;
|
||||
if ( ! lua_isnumber( L, -1))
|
||||
return false ;
|
||||
int nLen = int( lua_tointeger( L, -1)) ;
|
||||
lua_pop( L, 1) ;
|
||||
vParW.reserve( nLen) ;
|
||||
for ( int i = 1 ; i <= nLen ; ++ i) {
|
||||
lua_rawgeti( L, nInd, i) ;
|
||||
POINTU ptPW ;
|
||||
if ( ! LuaGetParam( L, -1, ptPW))
|
||||
return false ;
|
||||
vParW.push_back( ptPW) ;
|
||||
lua_pop( L, 1) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaClearStack( lua_State* L)
|
||||
{
|
||||
int n = lua_gettop( L) ;
|
||||
if ( n > 0)
|
||||
lua_pop( L, n) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_pushnil( L) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, bool bPar)
|
||||
{
|
||||
try {
|
||||
lua_pushboolean( L, ( bPar ? 1 : 0)) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, int nPar)
|
||||
{
|
||||
try {
|
||||
lua_pushinteger( L, nPar) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, double dPar)
|
||||
{
|
||||
try {
|
||||
lua_pushnumber( L, dPar) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, const string& sPar)
|
||||
{
|
||||
try {
|
||||
lua_pushstring( L, sPar.c_str()) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, const Vector3d& vtPar)
|
||||
{
|
||||
try {
|
||||
lua_createtable( L, 3, 0) ;
|
||||
for ( int i = 1 ; i <= 3 ; ++ i) {
|
||||
lua_pushnumber( L, vtPar.v[i-1]) ;
|
||||
lua_rawseti( L, -2, i) ;
|
||||
}
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, const Point3d& ptPar)
|
||||
{
|
||||
try {
|
||||
lua_createtable( L, 3, 0) ;
|
||||
for ( int i = 1 ; i <= 3 ; ++ i) {
|
||||
lua_pushnumber( L, ptPar.v[i-1]) ;
|
||||
lua_rawseti( L, -2, i) ;
|
||||
}
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, const Frame3d& frPar)
|
||||
{
|
||||
try {
|
||||
// creo tavola per frame
|
||||
lua_createtable( L, 4, 0) ;
|
||||
// creo tavola per origine
|
||||
lua_createtable( L, 3, 0) ;
|
||||
lua_pushnumber( L, frPar.Orig().x) ;
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
lua_pushnumber( L, frPar.Orig().y) ;
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
lua_pushnumber( L, frPar.Orig().z) ;
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
// la metto nel frame
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
// creo tavola per versore X
|
||||
lua_createtable( L, 3, 0) ;
|
||||
lua_pushnumber( L, frPar.VersX().x) ;
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
lua_pushnumber( L, frPar.VersX().y) ;
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
lua_pushnumber( L, frPar.VersX().z) ;
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
// la metto nel frame
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
// creo tavola per versore Y
|
||||
lua_createtable( L, 3, 0) ;
|
||||
lua_pushnumber( L, frPar.VersY().x) ;
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
lua_pushnumber( L, frPar.VersY().y) ;
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
lua_pushnumber( L, frPar.VersY().z) ;
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
// la metto nel frame
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
// creo tavola per versore Z
|
||||
lua_createtable( L, 3, 0) ;
|
||||
lua_pushnumber( L, frPar.VersZ().x) ;
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
lua_pushnumber( L, frPar.VersZ().y) ;
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
lua_pushnumber( L, frPar.VersZ().z) ;
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
// la metto nel frame
|
||||
lua_rawseti( L, -2, 4) ;
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetReturn( lua_State* L, const Color& colPar)
|
||||
{
|
||||
try {
|
||||
lua_createtable( L, 4, 0) ;
|
||||
lua_pushinteger( L, colPar.GetIntRed()) ;
|
||||
lua_rawseti( L, -2, 1) ;
|
||||
lua_pushinteger( L, colPar.GetIntGreen()) ;
|
||||
lua_rawseti( L, -2, 2) ;
|
||||
lua_pushinteger( L, colPar.GetIntBlue()) ;
|
||||
lua_rawseti( L, -2, 3) ;
|
||||
lua_pushinteger( L, colPar.GetIntAlpha()) ;
|
||||
lua_rawseti( L, -2, 4) ;
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_CurveModif.cpp Data : 03.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di modifica delle curve per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 03.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaInvertCurve( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// inverto la curva
|
||||
bool bOk = ( EgtInvertCurve( LuaGetGseContext(), nId) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyCurveStartPoint( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, NewStart
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptStart ;
|
||||
LuaCheckParam( L, 2, ptStart)
|
||||
LuaClearStack( L) ;
|
||||
// modifico il punto iniziale
|
||||
bool bOk = ( EgtModifyCurveStartPoint( LuaGetGseContext(), nId, ptStart.v) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyCurveEndPoint( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, NewEnd
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptEnd ;
|
||||
LuaCheckParam( L, 2, ptEnd)
|
||||
LuaClearStack( L) ;
|
||||
// modifico il punto finale
|
||||
bool bOk = ( EgtModifyCurveEndPoint( LuaGetGseContext(), nId, ptEnd.v) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyCurveExtrusion( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, vtExtr
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Vector3d vtExtr ;
|
||||
LuaCheckParam( L, 2, vtExtr)
|
||||
LuaClearStack( L) ;
|
||||
// modifico il vettore estrusione
|
||||
bool bOk = ( EgtModifyCurveExtrusion( LuaGetGseContext(), nId, vtExtr.v) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyCurveThickness( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Thick
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dThick ;
|
||||
LuaCheckParam( L, 2, dThick)
|
||||
LuaClearStack( L) ;
|
||||
// modifico il vettore estrusione
|
||||
bool bOk = ( EgtModifyCurveThickness( LuaGetGseContext(), nId, dThick) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimCurveStartAtLen( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dLen
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dLen ;
|
||||
LuaCheckParam( L, 2, dLen)
|
||||
LuaClearStack( L) ;
|
||||
// taglio la curva all'inizio
|
||||
bool bOk = ( EgtTrimCurveStartAtLen( LuaGetGseContext(), nId, dLen) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimCurveEndAtLen( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dLen
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dLen ;
|
||||
LuaCheckParam( L, 2, dLen)
|
||||
LuaClearStack( L) ;
|
||||
// taglio la curva alla fine
|
||||
bool bOk = ( EgtTrimCurveEndAtLen( LuaGetGseContext(), nId, dLen) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimCurveStartAtParam( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dPar
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dPar ;
|
||||
LuaCheckParam( L, 2, dPar)
|
||||
LuaClearStack( L) ;
|
||||
// taglio la curva all' inizio
|
||||
bool bOk = ( EgtTrimCurveStartAtParam( LuaGetGseContext(), nId, dPar) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimCurveEndAtParam( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dPar
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dPar ;
|
||||
LuaCheckParam( L, 2, dPar)
|
||||
LuaClearStack( L) ;
|
||||
// taglio la curva alla fine
|
||||
bool bOk = ( EgtTrimCurveEndAtParam( LuaGetGseContext(), nId, dPar) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimCurveStartEndAtParam( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, dParS, dParE
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dParS ;
|
||||
LuaCheckParam( L, 2, dParS)
|
||||
double dParE ;
|
||||
LuaCheckParam( L, 3, dParE)
|
||||
LuaClearStack( L) ;
|
||||
// taglio la curva alla fine
|
||||
bool bOk = ( EgtTrimCurveStartEndAtParam( LuaGetGseContext(), nId, dParS, dParE) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallCurveModif( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtInvertCurve", LuaInvertCurve) ;
|
||||
lua_register( L, "EgtModifyCurveStartPoint", LuaModifyCurveStartPoint) ;
|
||||
lua_register( L, "EgtModifyCurveEndPoint", LuaModifyCurveEndPoint) ;
|
||||
lua_register( L, "EgtModifyCurveExtrusion", LuaModifyCurveExtrusion) ;
|
||||
lua_register( L, "EgtModifyCurveThickness", LuaModifyCurveThickness) ;
|
||||
lua_register( L, "EgtTrimCurveStartAtLen", LuaTrimCurveStartAtLen) ;
|
||||
lua_register( L, "EgtTrimCurveEndAtLen", LuaTrimCurveEndAtLen) ;
|
||||
lua_register( L, "EgtTrimCurveStartAtParam", LuaTrimCurveStartAtParam) ;
|
||||
lua_register( L, "EgtTrimCurveEndAtParam", LuaTrimCurveEndAtParam) ;
|
||||
lua_register( L, "EgtTrimCurveStartEndAtParam", LuaTrimCurveStartEndAtParam) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_Exchange.cpp Data : 29.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni generali per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 29.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaImportDxf( lua_State* L)
|
||||
{
|
||||
// 1 parametro : path del file da importare
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 1, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtImportDxf( LuaGetGseContext(), sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaImportStl( lua_State* L)
|
||||
{
|
||||
// 1 parametro : path del file da importare
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 1, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtImportStl( LuaGetGseContext(), sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaImportCnc( lua_State* L)
|
||||
{
|
||||
// 1 parametro : path del file da importare
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 1, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtImportCnc( LuaGetGseContext(), sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExportDxf( lua_State* L)
|
||||
{
|
||||
// 2 parametri, GroupId e path del file da esportare
|
||||
int nGroupId ;
|
||||
LuaCheckParam( L, 1, nGroupId)
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 2, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtExportDxf( LuaGetGseContext(), nGroupId, sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExportStl( lua_State* L)
|
||||
{
|
||||
// 2 parametri, GroupId e path del file da esportare
|
||||
int nGroupId ;
|
||||
LuaCheckParam( L, 1, nGroupId)
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 2, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtExportStl( LuaGetGseContext(), nGroupId, sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallExchange( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtImportDxf", LuaImportDxf) ;
|
||||
lua_register( L, "EgtImportStl", LuaImportStl) ;
|
||||
lua_register( L, "EgtImportCnc", LuaImportCnc) ;
|
||||
lua_register( L, "EgtExportDxf", LuaExportDxf) ;
|
||||
lua_register( L, "EgtExportStl", LuaExportStl) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbCreate.cpp Data : 30.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di creazione geometrica per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateGroup( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : ParentId [, Frame]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Frame3d frFrame ;
|
||||
LuaGetParam( L, 2, frFrame) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il gruppo
|
||||
int nId = EgtCreateGroup( LuaGetGseContext(), nParentId, frFrame.Orig().v,
|
||||
frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateGeoPoint( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ParentId, PtP
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 2, ptP)
|
||||
LuaClearStack( L) ;
|
||||
// creo il segmento di retta
|
||||
int nId = EgtCreateGeoPoint( LuaGetGseContext(), nParentId, ptP.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateGeoVector( lua_State* L)
|
||||
{
|
||||
// 2 o 3 o 4 parametri : ParentId, VtV [, PtB [, Scale]]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Vector3d vtV ;
|
||||
LuaCheckParam( L, 2, vtV)
|
||||
Point3d ptB ;
|
||||
LuaGetParam( L, 3, ptB) ;
|
||||
double dScale = 1 ;
|
||||
LuaGetParam( L, 4, dScale) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il segmento di retta
|
||||
vtV *= dScale ;
|
||||
int nId = EgtCreateGeoVector( LuaGetGseContext(), nParentId, vtV.v, ptB.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateGeoFrame( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ParentId, Frame
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Frame3d frFrame ;
|
||||
LuaCheckParam( L, 2, frFrame) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il gruppo
|
||||
int nId = EgtCreateGeoFrame( LuaGetGseContext(), nParentId, frFrame.Orig().v,
|
||||
frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveLine( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, PtIni, PtFin
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 2, ptIni)
|
||||
Point3d ptFin ;
|
||||
LuaCheckParam( L, 3, ptFin)
|
||||
LuaClearStack( L) ;
|
||||
// creo il segmento di retta
|
||||
int nId = EgtCreateCurveLine( LuaGetGseContext(), nParentId, ptIni.v, ptFin.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveLineMinPointCurve( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : ParentId, PtIni, CrvId [, NearPar]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 2, ptIni)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 3, nCrvId)
|
||||
double dNearPar = 0 ;
|
||||
LuaGetParam( L, 4, dNearPar) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il segmento di retta
|
||||
int nId = EgtCreateCurveLineMinPointCurve( LuaGetGseContext(), nParentId, ptIni.v, nCrvId, dNearPar) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCircle( lua_State* L)
|
||||
{
|
||||
// 4 parametri : ParentId, PtCen, VtN, Rad
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 2, ptCen)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveCircle( LuaGetGseContext(), nParentId, ptCen.v, vtN.v, dRad) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCircleXY( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, PtCen, Rad
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 2, ptCen)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 3, dRad)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveCircleXY( LuaGetGseContext(), nParentId, ptCen.v, dRad) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCircle3P( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, PtP1, PtP2, PtP3
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1)
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2)
|
||||
Point3d ptP3 ;
|
||||
LuaCheckParam( L, 4, ptP3)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveCircle3P( LuaGetGseContext(), nParentId, ptP1.v, ptP2.v, ptP3.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveArc( lua_State* L)
|
||||
{
|
||||
// 7 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 2, ptCen)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
Vector3d vtS ;
|
||||
LuaCheckParam( L, 5, vtS)
|
||||
double dAngCenDeg ;
|
||||
LuaCheckParam( L, 6, dAngCenDeg)
|
||||
double dDeltaN ;
|
||||
LuaCheckParam( L, 7, dDeltaN)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveArc( LuaGetGseContext(), nParentId, ptCen.v, vtN.v, dRad, vtS.v, dAngCenDeg, dDeltaN) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveArcXY( lua_State* L)
|
||||
{
|
||||
// 6 parametri : ParentId, PtCen, Rad, AngStartDeg, AngCenDeg, DeltaN
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 2, ptCen)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 3, dRad)
|
||||
double dAngStartDeg ;
|
||||
LuaCheckParam( L, 4, dAngStartDeg)
|
||||
double dAngCenDeg ;
|
||||
LuaCheckParam( L, 5, dAngCenDeg)
|
||||
double dDeltaZ ;
|
||||
LuaCheckParam( L, 6, dDeltaZ)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveArcXY( LuaGetGseContext(), nParentId, ptCen.v, dRad, dAngStartDeg, dAngCenDeg, dDeltaZ) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveArc3P( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, PtP1, PtP2, PtP3
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1)
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2)
|
||||
Point3d ptP3 ;
|
||||
LuaCheckParam( L, 4, ptP3)
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = EgtCreateCurveArc3P( LuaGetGseContext(), nParentId, ptP1.v, ptP2.v, ptP3.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveBezier( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, Degree, CtrlPnts
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nDegree ;
|
||||
LuaCheckParam( L, 2, nDegree)
|
||||
PNTVECTOR vPnt ;
|
||||
LuaCheckParam( L, 3, vPnt)
|
||||
LuaClearStack( L) ;
|
||||
// il numero dei punti deve essere pari al grado + 1
|
||||
if ( vPnt.size() != nDegree + 1)
|
||||
return luaL_error( L, "Wrong Control Points Number") ;
|
||||
// creo la curva
|
||||
int nId = EgtCreateCurveBezier( LuaGetGseContext(), nParentId, nDegree, vPnt) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveBezierRational( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, Degree, CtrlPntWs
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nDegree ;
|
||||
LuaCheckParam( L, 2, nDegree)
|
||||
PNTUVECTOR vPntW ;
|
||||
LuaCheckParam( L, 3, vPntW)
|
||||
LuaClearStack( L) ;
|
||||
// il numero dei punti deve essere pari al grado + 1
|
||||
if ( vPntW.size() != nDegree + 1)
|
||||
return luaL_error( L, "Wrong Control Points Number") ;
|
||||
// creo la curva
|
||||
int nId = EgtCreateCurveBezierRational( LuaGetGseContext(), nParentId, nDegree, vPntW) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveBezierFromArc( lua_State* L)
|
||||
{
|
||||
// 3 parametri : ParentId, ArcId[ , Erase]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nArcId ;
|
||||
LuaCheckParam( L, 2, nArcId)
|
||||
bool bErase = true ;
|
||||
LuaGetParam( L, 3, bErase) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la curva
|
||||
int nId = EgtCreateCurveBezierFromArc( LuaGetGseContext(), nParentId, nArcId, bErase) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCompo( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : ParentId, nIds [, Erase]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 2, vIds)
|
||||
bool bErase = true ;
|
||||
LuaGetParam( L, 3, bErase) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la curva composita
|
||||
int nId = EgtCreateCurveCompo( LuaGetGseContext(), nParentId, vIds, ( bErase ? TRUE : FALSE)) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCompoFromPoints( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ParentId, ptPs
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
PNTVECTOR vPnt ;
|
||||
LuaCheckParam( L, 2, vPnt)
|
||||
LuaClearStack( L) ;
|
||||
PolyLine PL ;
|
||||
for ( size_t i = 0 ; i < vPnt.size() ; ++ i)
|
||||
PL.AddUPoint( 0, vPnt[i]) ;
|
||||
// creo la curva composita
|
||||
int nId = EgtCreateCurveCompoFromPoints( LuaGetGseContext(), nParentId, PL) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCompoFromPointBulges( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ParentId, ptPBs
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
PNTUVECTOR vPntB ;
|
||||
LuaCheckParam( L, 2, vPntB)
|
||||
LuaClearStack( L) ;
|
||||
PolyArc PA ;
|
||||
for ( size_t i = 0 ; i < vPntB.size() ; ++ i)
|
||||
PA.AddUPoint( 0, vPntB[i].first, vPntB[i].second) ;
|
||||
// creo la curva composita
|
||||
int nId = EgtCreateCurveCompoFromPointBulges( LuaGetGseContext(), nParentId, PA) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveCompoFromPolygonSide( lua_State* L)
|
||||
{
|
||||
// 4 parametri : ParentId, nNumSides, PtIni, PtFin
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nNumSides ;
|
||||
LuaCheckParam( L, 2, nNumSides)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 3, ptIni)
|
||||
Point3d ptFin ;
|
||||
LuaCheckParam( L, 4, ptFin)
|
||||
LuaClearStack( L) ;
|
||||
// creo il poligono
|
||||
int nId = EgtCreateCurveCompoFromPolygonSide( LuaGetGseContext(), nParentId, nNumSides, ptIni.v, ptFin.v) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
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 ;
|
||||
LuaGetParam( L, 3, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = EgtCreateSurfTriMeshByContour( LuaGetGseContext(), nParentId, nCrvId, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateText( lua_State* L)
|
||||
{
|
||||
// 5 parametri : ParentId, Text, ptP, AngRotDeg, H
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
string sText ;
|
||||
LuaCheckParam( L, 2, sText)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 3, ptP) ;
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 4, dAngRotDeg) ;
|
||||
double dH ;
|
||||
LuaCheckParam( L, 5, dH) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il testo
|
||||
int nId = EgtCreateText( LuaGetGseContext(), nParentId, sText, ptP, dAngRotDeg, dH) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateTextEx( lua_State* L)
|
||||
{
|
||||
// 11 parametri : ParentId, Text, ptP, AngRotDeg, Font, W, sItalic, H, Rat, AddAdv, InsPos
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
string sText ;
|
||||
LuaCheckParam( L, 2, sText)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 3, ptP) ;
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 4, dAngRotDeg) ;
|
||||
string sFont ;
|
||||
LuaCheckParam( L, 5, sFont)
|
||||
int nW ;
|
||||
LuaCheckParam( L, 6, nW)
|
||||
string sItalic ;
|
||||
LuaCheckParam( L, 7, sItalic)
|
||||
ToUpper( sItalic) ;
|
||||
bool bItalic = ( sItalic == "I") ;
|
||||
double dH ;
|
||||
LuaCheckParam( L, 8, dH) ;
|
||||
double dRat ;
|
||||
LuaCheckParam( L, 9, dRat) ;
|
||||
double dAddAdv ;
|
||||
LuaCheckParam( L, 10, dAddAdv) ;
|
||||
string sInsPos ;
|
||||
LuaCheckParam( L, 11, sInsPos) ;
|
||||
int nInsPos = ETXT_IPBL ;
|
||||
ToUpper( sInsPos) ;
|
||||
if ( sInsPos == "TL")
|
||||
nInsPos = ETXT_IPTL ;
|
||||
else if ( sInsPos == "TC")
|
||||
nInsPos = ETXT_IPTC ;
|
||||
else if ( sInsPos == "TR")
|
||||
nInsPos = ETXT_IPTR ;
|
||||
else if ( sInsPos == "ML")
|
||||
nInsPos = ETXT_IPML ;
|
||||
else if ( sInsPos == "MC")
|
||||
nInsPos = ETXT_IPMC ;
|
||||
else if ( sInsPos == "MR")
|
||||
nInsPos = ETXT_IPMR ;
|
||||
else if ( sInsPos == "BL")
|
||||
nInsPos = ETXT_IPBL ;
|
||||
else if ( sInsPos == "BC")
|
||||
nInsPos = ETXT_IPBC ;
|
||||
else if ( sInsPos == "BR")
|
||||
nInsPos = ETXT_IPBR ;
|
||||
LuaClearStack( L) ;
|
||||
// creo il testo in modo esteso
|
||||
int nId = EgtCreateTextEx( LuaGetGseContext(), nParentId, sText, ptP, dAngRotDeg,
|
||||
sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreate( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtGroup", LuaCreateGroup) ;
|
||||
lua_register( L, "EgtPoint", LuaCreateGeoPoint) ;
|
||||
lua_register( L, "EgtVector", LuaCreateGeoVector) ;
|
||||
lua_register( L, "EgtFrame", LuaCreateGeoFrame) ;
|
||||
lua_register( L, "EgtLine", LuaCreateCurveLine) ;
|
||||
lua_register( L, "EgtLineMinPointCurve", LuaCreateCurveLineMinPointCurve) ;
|
||||
lua_register( L, "EgtCircle", LuaCreateCurveCircle) ;
|
||||
lua_register( L, "EgtCircleXY", LuaCreateCurveCircleXY) ;
|
||||
lua_register( L, "EgtCircle3P", LuaCreateCurveCircle3P) ;
|
||||
lua_register( L, "EgtArc", LuaCreateCurveArc) ;
|
||||
lua_register( L, "EgtArcXY", LuaCreateCurveArcXY) ;
|
||||
lua_register( L, "EgtArc3P", LuaCreateCurveArc3P) ;
|
||||
lua_register( L, "EgtCurveBezier", LuaCreateCurveBezier) ;
|
||||
lua_register( L, "EgtCurveBezierRat", LuaCreateCurveBezierRational) ;
|
||||
lua_register( L, "EgtCurveBezierFromArc", LuaCreateCurveBezierFromArc) ;
|
||||
lua_register( L, "EgtCurveCompo", LuaCreateCurveCompo) ;
|
||||
lua_register( L, "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ;
|
||||
lua_register( L, "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ;
|
||||
lua_register( L, "EgtCurveCompoFromPolygonSide", LuaCreateCurveCompoFromPolygonSide) ;
|
||||
lua_register( L, "EgtSurfTmByContour", LuaCreateSurfTriMeshByContour) ;
|
||||
lua_register( L, "EgtText", LuaCreateText) ;
|
||||
lua_register( L, "EgtTextEx", LuaCreateTextEx) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbModify.cpp Data : 06.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di modifica geometrica per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaChangeVectorBase( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, ptBase
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptBase ;
|
||||
LuaCheckParam( L, 2, ptBase)
|
||||
LuaClearStack( L) ;
|
||||
// modifica del testo
|
||||
bool bOk = ( EgtChangeVectorBase( LuaGetGseContext(), nId, ptBase.v) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyText( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, sNewText
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sNewText ;
|
||||
LuaCheckParam( L, 2, sNewText)
|
||||
LuaClearStack( L) ;
|
||||
// modifica del testo
|
||||
bool bOk = ( EgtModifyText( LuaGetGseContext(), nId, sNewText) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaChangeTextFont( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, sNewFont
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sNewFont ;
|
||||
LuaCheckParam( L, 2, sNewFont)
|
||||
LuaClearStack( L) ;
|
||||
// modifica del testo
|
||||
bool bOk = ( EgtChangeTextFont( LuaGetGseContext(), nId, sNewFont) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaFlipText( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// flip del testo
|
||||
bool bOk = ( EgtFlipText( LuaGetGseContext(), nId) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMirrorText( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, sOnL]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
bool bOnL = true ;
|
||||
string sLorH ;
|
||||
if ( LuaGetParam( L, 2, sLorH)) {
|
||||
ToUpper( sLorH) ;
|
||||
if ( sLorH == "H")
|
||||
bOnL = false ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// flip del testo
|
||||
bool bOk = ( EgtMirrorText( LuaGetGseContext(), nId, bOnL) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextToOutline( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, IdGroupDest
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nIdGroupDest ;
|
||||
LuaCheckParam( L, 2, nIdGroupDest)
|
||||
LuaClearStack( L) ;
|
||||
// esplosione del testo in outline
|
||||
bool bOk = ( EgtTextToOutline( LuaGetGseContext(), nId, nIdGroupDest) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSplitText( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, IdGroupDest
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nIdGroupDest ;
|
||||
LuaCheckParam( L, 2, nIdGroupDest)
|
||||
LuaClearStack( L) ;
|
||||
// esplosione del testo in più testi, uno per riga
|
||||
bool bOk = ( EgtSplitText( LuaGetGseContext(), nId, nIdGroupDest) ? true : false) ;
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbModify( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtChangeVectorBase", LuaChangeVectorBase) ;
|
||||
lua_register( L, "EgtModifyText", LuaModifyText) ;
|
||||
lua_register( L, "EgtChangeTextFont", LuaChangeTextFont) ;
|
||||
lua_register( L, "EgtFlipText", LuaFlipText) ;
|
||||
lua_register( L, "EgtMirrorText", LuaMirrorText) ;
|
||||
lua_register( L, "EgtTextToOutline", LuaTextToOutline) ;
|
||||
lua_register( L, "EgtSplitText", LuaSplitText) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbObjAttribs.cpp Data : 30.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di trasformazione geometrica per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetLevel( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Livello
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sLevel ;
|
||||
LuaCheckParam( L, 2, sLevel)
|
||||
ToUpper( sLevel) ;
|
||||
int nLevel = GDB_LV_USER ;
|
||||
if ( sLevel == "SYSTEM")
|
||||
nLevel = GDB_LV_SYSTEM ;
|
||||
else if ( sLevel == "TEMP")
|
||||
nLevel = GDB_LV_TEMP ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto lo stato
|
||||
bool bOk = ( EgtSetLevel( LuaGetGseContext(), nId, nLevel) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRevertLevel( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// porto il livello al valore precedente
|
||||
bool bOk = ( EgtRevertLevel( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetLevel( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il livello
|
||||
int nLevel ;
|
||||
if ( EgtGetLevel( LuaGetGseContext(), nId, &nLevel))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nLevel) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcLevel( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il livello
|
||||
int nLevel ;
|
||||
if ( EgtGetCalcLevel( LuaGetGseContext(), nId, &nLevel))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nLevel) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetMode( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Mode
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sMode ;
|
||||
LuaCheckParam( L, 2, sMode)
|
||||
ToUpper( sMode) ;
|
||||
int nMode = GDB_MD_STD ;
|
||||
if ( sMode == "LOCKED")
|
||||
nMode = GDB_MD_LOCKED ;
|
||||
else if ( sMode == "HIDDEN")
|
||||
nMode = GDB_MD_HIDDEN ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto il modo
|
||||
bool bOk = ( EgtSetMode( LuaGetGseContext(), nId, nMode) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRevertMode( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// porto il modo al valore precedente
|
||||
bool bOk = ( EgtRevertMode( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetMode( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il modo
|
||||
int nMode ;
|
||||
if ( EgtGetMode( LuaGetGseContext(), nId, &nMode))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nMode) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcMode( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il modo calcolato (ovvero proprio ed ereditato)
|
||||
int nMode ;
|
||||
if ( EgtGetCalcMode( LuaGetGseContext(), nId, &nMode))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nMode) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetStatus( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Stato
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sStatus ;
|
||||
LuaCheckParam( L, 2, sStatus)
|
||||
ToUpper( sStatus) ;
|
||||
int nStatus = GDB_ST_ON ;
|
||||
if ( sStatus == "OFF")
|
||||
nStatus = GDB_ST_OFF ;
|
||||
else if ( sStatus == "SEL")
|
||||
nStatus = GDB_ST_SEL ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto lo stato
|
||||
bool bOk = ( EgtSetStatus( LuaGetGseContext(), nId, nStatus) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRevertStatus( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// porto lo stato al valore precedente
|
||||
bool bOk = ( EgtRevertStatus( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetStatus( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo stato
|
||||
int nStatus ;
|
||||
if ( EgtGetStatus( LuaGetGseContext(), nId, &nStatus))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nStatus) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcStatus( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo stato
|
||||
int nStatus ;
|
||||
if ( EgtGetCalcStatus( LuaGetGseContext(), nId, &nStatus))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nStatus) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetMark( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// imposto l'evidenziazione
|
||||
bool bOk = ( EgtSetMark( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaResetMark( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// cancello l'evidenziazione
|
||||
bool bOk = ( EgtResetMark( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetMark( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo stato di evidenziazione
|
||||
BOOL nMark ;
|
||||
if ( EgtGetMark( LuaGetGseContext(), nId, &nMark))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, ( nMark != FALSE)) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcMark( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo stato calcolato di evidenziazione
|
||||
BOOL nMark ;
|
||||
if ( EgtGetCalcMark( LuaGetGseContext(), nId, &nMark))
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, ( nMark != FALSE)) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStdColor( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Nome
|
||||
string sName ;
|
||||
LuaCheckParam( L, 1, sName)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il colore con il nome indicato
|
||||
int nRed, nGreen, nBlue, nAlpha ;
|
||||
if ( EgtStdColor( sName, nRed, nGreen, nBlue, nAlpha)) {
|
||||
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, cCol) ;
|
||||
}
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetColor( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id/s, Colore
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Color cCol ;
|
||||
LuaCheckParam( L, 2, cCol)
|
||||
LuaClearStack( L) ;
|
||||
// assegno il colore
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtSetColor( LuaGetGseContext(), vId[i], cCol.GetIntRed(),
|
||||
cCol.GetIntGreen(), cCol.GetIntBlue(), cCol.GetIntAlpha()))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetColor( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il colore
|
||||
int nRed, nGreen, nBlue, nAlpha ;
|
||||
if ( EgtGetColor( LuaGetGseContext(), nId, nRed, nGreen, nBlue, nAlpha)) {
|
||||
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, cCol) ;
|
||||
}
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCalcColor( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il colore
|
||||
int nRed, nGreen, nBlue, nAlpha ;
|
||||
if ( EgtGetCalcColor( LuaGetGseContext(), nId, nRed, nGreen, nBlue, nAlpha)) {
|
||||
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, cCol) ;
|
||||
}
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetName( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Name
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sName ;
|
||||
LuaCheckParam( L, 2, sName)
|
||||
LuaClearStack( L) ;
|
||||
// assegno il nome
|
||||
bool bOk = ( EgtSetName( LuaGetGseContext(), nId, sName) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetName( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il nome
|
||||
string sName ;
|
||||
bool bOk = ( EgtGetName( LuaGetGseContext(), nId, sName) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetReturn( L, sName) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExistsName( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico esistenza nome
|
||||
bool bOk = ( EgtExistsName( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRemoveName( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico esistenza nome
|
||||
bool bOk = ( EgtRemoveName( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetInfo( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, Key, Info
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
string sInfo ;
|
||||
LuaCheckParam( L, 3, sInfo)
|
||||
LuaClearStack( L) ;
|
||||
// assegno la info
|
||||
bool bOk = ( EgtSetInfo( LuaGetGseContext(), nId, sKey, sInfo) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetInfo( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Key
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'info
|
||||
string sInfo ;
|
||||
bool bOk = ( EgtGetInfo( LuaGetGseContext(), nId, sKey, sInfo) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetReturn( L, sInfo) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExistsInfo( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Key
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
LuaClearStack( L) ;
|
||||
// verifico esistenza info
|
||||
bool bOk = ( EgtExistsInfo( LuaGetGseContext(), nId, sKey) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRemoveInfo( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, Key
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
LuaClearStack( L) ;
|
||||
// rimuovo info
|
||||
bool bOk = ( EgtRemoveInfo( LuaGetGseContext(), nId, sKey) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbObjAttribs( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtSetLevel", LuaSetLevel) ;
|
||||
lua_register( L, "EgtRevertLevel", LuaRevertLevel) ;
|
||||
lua_register( L, "EgtGetLevel", LuaGetLevel) ;
|
||||
lua_register( L, "EgtGetCalcLevel", LuaGetCalcLevel) ;
|
||||
lua_register( L, "EgtSetMode", LuaSetMode) ;
|
||||
lua_register( L, "EgtRevertMode", LuaRevertMode) ;
|
||||
lua_register( L, "EgtGetMode", LuaGetMode) ;
|
||||
lua_register( L, "EgtGetCalcMode", LuaGetCalcMode) ;
|
||||
lua_register( L, "EgtSetStatus", LuaSetStatus) ;
|
||||
lua_register( L, "EgtRevertStatus", LuaRevertStatus) ;
|
||||
lua_register( L, "EgtGetStatus", LuaGetStatus) ;
|
||||
lua_register( L, "EgtGetCalcStatus", LuaGetCalcStatus) ;
|
||||
lua_register( L, "EgtSetMark", LuaSetMark) ;
|
||||
lua_register( L, "EgtResetMark", LuaResetMark) ;
|
||||
lua_register( L, "EgtGetMark", LuaGetMark) ;
|
||||
lua_register( L, "EgtGetCalcMark", LuaGetCalcMark) ;
|
||||
lua_register( L, "EgtStdColor", LuaStdColor) ;
|
||||
lua_register( L, "EgtSetColor", LuaSetColor) ;
|
||||
lua_register( L, "EgtGetColor", LuaGetColor) ;
|
||||
lua_register( L, "EgtGetCalcColor", LuaGetCalcColor) ;
|
||||
lua_register( L, "EgtSetName", LuaSetName) ;
|
||||
lua_register( L, "EgtGetName", LuaGetName) ;
|
||||
lua_register( L, "EgtExistsName", LuaExistsName) ;
|
||||
lua_register( L, "EgtRemoveName", LuaRemoveName) ;
|
||||
lua_register( L, "EgtSetInfo", LuaSetInfo) ;
|
||||
lua_register( L, "EgtGetInfo", LuaGetInfo) ;
|
||||
lua_register( L, "EgtExistsInfo", LuaExistsInfo) ;
|
||||
lua_register( L, "EgtRemoveInfo", LuaRemoveInfo) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbObjects.cpp Data : 30.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di iterazione di DB geometrico per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 30.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExistsObj( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico esistenza oggetto
|
||||
bool bOk = ( EgtExistsObj( LuaGetGseContext(), nId) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetGroupObjs( lua_State* L)
|
||||
{
|
||||
// 1 parametro : GroupId
|
||||
int nGroupId ;
|
||||
LuaCheckParam( L, 1, nGroupId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico esistenza oggetto
|
||||
int nObjs = EgtGetGroupObjs( LuaGetGseContext(), nGroupId) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, nObjs) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetFirstInGroup( lua_State* L)
|
||||
{
|
||||
// 1 parametro : GroupId
|
||||
int nGroupId ;
|
||||
LuaCheckParam( L, 1, nGroupId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il primo oggetto del gruppo
|
||||
int nId = EgtGetFirstInGroup( LuaGetGseContext(), nGroupId) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetNext( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il prossimo oggetto nello stesso gruppo
|
||||
int nNextId = EgtGetNext( LuaGetGseContext(), nId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNextId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nNextId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetLastInGroup( lua_State* L)
|
||||
{
|
||||
// 1 parametro : GroupId
|
||||
int nGroupId ;
|
||||
LuaCheckParam( L, 1, nGroupId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'ultimo oggetto del gruppo
|
||||
int nId = EgtGetLastInGroup( LuaGetGseContext(), nGroupId) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetPrev( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il precedente oggetto nello stesso gruppo
|
||||
int nPrevId = EgtGetPrev( LuaGetGseContext(), nId) ;
|
||||
// restituisco il risultato
|
||||
if ( nPrevId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nPrevId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopy( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : SouId, RefId [, SonBeforeAfter]
|
||||
int nSouId ;
|
||||
LuaCheckParam( L, 1, nSouId)
|
||||
int nRefId ;
|
||||
LuaCheckParam( L, 2, nRefId)
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
string sSonBeforeAfter ;
|
||||
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
|
||||
ToUpper( sSonBeforeAfter) ;
|
||||
if ( sSonBeforeAfter == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sSonBeforeAfter == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la copia
|
||||
int nNewId = EgtCopy( LuaGetGseContext(), nSouId, nRefId, nSonBeforeAfter) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nNewId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopyGlob( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : SouId, RefId [, SonBeforeAfter]
|
||||
int nSouId ;
|
||||
LuaCheckParam( L, 1, nSouId)
|
||||
int nRefId ;
|
||||
LuaCheckParam( L, 2, nRefId)
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
string sSonBeforeAfter ;
|
||||
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
|
||||
ToUpper( sSonBeforeAfter) ;
|
||||
if ( sSonBeforeAfter == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sSonBeforeAfter == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la copia
|
||||
int nNewId = EgtCopyGlob( LuaGetGseContext(), nSouId, nRefId, nSonBeforeAfter) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetReturn( L, nNewId) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRelocate( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : SouId, RefId [, SonBeforeAfter]
|
||||
int nSouId ;
|
||||
LuaCheckParam( L, 1, nSouId)
|
||||
int nRefId ;
|
||||
LuaCheckParam( L, 2, nRefId)
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
string sSonBeforeAfter ;
|
||||
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
|
||||
ToUpper( sSonBeforeAfter) ;
|
||||
if ( sSonBeforeAfter == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sSonBeforeAfter == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la rilocazione
|
||||
bool bOk = ( EgtRelocate( LuaGetGseContext(), nSouId, nRefId, nSonBeforeAfter) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRelocateGlob( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : SouId, RefId [, SonBeforeAfter]
|
||||
int nSouId ;
|
||||
LuaCheckParam( L, 1, nSouId)
|
||||
int nRefId ;
|
||||
LuaCheckParam( L, 2, nRefId)
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
string sSonBeforeAfter ;
|
||||
if ( LuaGetParam( L, 3, sSonBeforeAfter)) {
|
||||
ToUpper( sSonBeforeAfter) ;
|
||||
if ( sSonBeforeAfter == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sSonBeforeAfter == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la rilocazione
|
||||
bool bOk = ( EgtRelocateGlob( LuaGetGseContext(), nSouId, nRefId, nSonBeforeAfter) ? true : false) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaErase( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id/s
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
// eseguo la cancellazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtErase( LuaGetGseContext(), vId[i]))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbObjects( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtExistsObj", LuaExistsObj) ;
|
||||
lua_register( L, "EgtGetGroupObjs", LuaGetGroupObjs) ;
|
||||
lua_register( L, "EgtGetFirstInGroup", LuaGetFirstInGroup) ;
|
||||
lua_register( L, "EgtGetNext", LuaGetNext) ;
|
||||
lua_register( L, "EgtGetLastInGroup", LuaGetLastInGroup) ;
|
||||
lua_register( L, "EgtGetPrev", LuaGetPrev) ;
|
||||
lua_register( L, "EgtCopy", LuaCopy) ;
|
||||
lua_register( L, "EgtCopyGlob", LuaCopyGlob) ;
|
||||
lua_register( L, "EgtRelocate", LuaRelocate) ;
|
||||
lua_register( L, "EgtRelocateGlob", LuaRelocateGlob) ;
|
||||
lua_register( L, "EgtErase", LuaErase) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni generali per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static lua_State* s_L = nullptr ;
|
||||
static int s_nCurrGseCtx = 1 ;
|
||||
static string s_LastError ;
|
||||
static PerformanceCounter s_Counter ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInit( void)
|
||||
{
|
||||
// se già aperto, lo fermo per riavviarlo
|
||||
if ( s_L != nullptr) {
|
||||
lua_close( s_L) ;
|
||||
s_L = nullptr ;
|
||||
}
|
||||
// inizializzo Lua
|
||||
s_L = luaL_newstate() ;
|
||||
if ( s_L == nullptr) {
|
||||
LOG_ERROR( GetLogger(), "Error in Lua interpreter starting (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
// carico le librerie standard
|
||||
luaL_openlibs( s_L) ;
|
||||
// carico le funzioni speciali
|
||||
if ( ! LuaInstallGeneral( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGeneral (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGeomDB( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGeomDB (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbCreate( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreate (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbModify( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModify (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbObjects( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjects (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbObjAttribs( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjAttribs (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallCurveModif( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallCurveModif (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGeoSnap( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGeoSnap (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGeoTransform( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGeoTransform (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallScene( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallScene (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallExchange( s_L)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallExchange (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
|
||||
LOG_INFO( GetLogger(), "Lua interpreter started")
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaExit( void)
|
||||
{
|
||||
if ( s_L == nullptr)
|
||||
return false ;
|
||||
// termino Lua
|
||||
lua_close( s_L) ;
|
||||
s_L = nullptr ;
|
||||
LOG_INFO( GetLogger(), "Lua interpreter closed")
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaSetGseContext( int nGseCtx)
|
||||
{
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
s_nCurrGseCtx = nGseCtx ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
LuaGetGseContext( void)
|
||||
{
|
||||
return s_nCurrGseCtx ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaExecLine( const string& sLine)
|
||||
{
|
||||
// eseguo la linea
|
||||
int nErr = luaL_loadstring( s_L, sLine.c_str()) || lua_pcall( s_L, 0, LUA_MULTRET, 0) ;
|
||||
// senza errori
|
||||
if ( nErr == 0) {
|
||||
s_LastError.clear() ;
|
||||
return true ;
|
||||
}
|
||||
// altrimenti, errore
|
||||
else {
|
||||
// recupero il messaggio di errore
|
||||
const char* szErr = lua_tostring( s_L, -1) ;
|
||||
s_LastError = ( szErr != nullptr) ? szErr : "Error unknown" ;
|
||||
lua_pop( s_L, 1) ;
|
||||
// lo scrivo nel log
|
||||
LOG_ERROR( GetLogger(), s_LastError.c_str())
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
LuaExecFile( const string& sFile)
|
||||
{
|
||||
// eseguo la linea
|
||||
int nErr = luaL_loadfile( s_L, sFile.c_str()) || lua_pcall( s_L, 0, LUA_MULTRET, 0) ;
|
||||
// senza errori
|
||||
if ( nErr == 0) {
|
||||
s_LastError.clear() ;
|
||||
return true ;
|
||||
}
|
||||
// in caso di errore
|
||||
else {
|
||||
// recupero il messaggio di errore
|
||||
const char* szErr = lua_tostring( s_L, -1) ;
|
||||
s_LastError = ( szErr != nullptr) ? szErr : "Error unknown" ;
|
||||
lua_pop( s_L, 1) ;
|
||||
// lo scrivo nel log
|
||||
LOG_ERROR( GetLogger(), s_LastError.c_str())
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string&
|
||||
LuaGetLastError( void)
|
||||
{
|
||||
return s_LastError ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyPrint( lua_State* L)
|
||||
{
|
||||
string sOut ;
|
||||
int n = lua_gettop( L) ; /* number of arguments */
|
||||
lua_getglobal( L, "tostring") ;
|
||||
for ( int i = 1 ; i <= n ; ++ i) {
|
||||
const char* s ;
|
||||
lua_pushvalue( L, -1) ; /* function to be called */
|
||||
lua_pushvalue( L, i) ; /* value to print */
|
||||
lua_call( L, 1, 1) ;
|
||||
s = lua_tostring( L, -1) ; /* get result */
|
||||
if ( s == nullptr)
|
||||
return luaL_error( L,
|
||||
LUA_QL("tostring") " must return a string to " LUA_QL("print")) ;
|
||||
if ( i > 1)
|
||||
sOut += "\t" ;
|
||||
sOut += s ;
|
||||
lua_pop( L, 1) ; /* pop result */
|
||||
}
|
||||
if ( ! sOut.empty())
|
||||
LOG_INFO( GetLogger(), sOut.c_str())
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
SetContext( lua_State* L)
|
||||
{
|
||||
// un solo parametro intero
|
||||
int nGseCtx ;
|
||||
LuaCheckParam( L, 1, nGseCtx)
|
||||
LuaClearStack( L) ;
|
||||
// imposto il contesto
|
||||
bool bOk = LuaSetGseContext( nGseCtx) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
GetContext( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// restituisco l'indice del contesto
|
||||
LuaSetReturn( L, s_nCurrGseCtx) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaPause( lua_State* L)
|
||||
{
|
||||
// 1 parametro : numero di millisecondi
|
||||
int nTime ;
|
||||
LuaCheckParam( L, 1, nTime)
|
||||
LuaClearStack( L) ;
|
||||
// controllo la durata della pausa e la eseguo
|
||||
const int MIN_TIME = 0 ;
|
||||
const int MAX_TIME = 10000 ;
|
||||
if ( nTime < MIN_TIME)
|
||||
nTime = MIN_TIME ;
|
||||
else if ( nTime > MAX_TIME)
|
||||
nTime = MAX_TIME ;
|
||||
Sleep( nTime) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, true) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStartCounter( lua_State* L)
|
||||
{
|
||||
s_Counter.Start() ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStopCounter( lua_State* L)
|
||||
{
|
||||
double dTime = s_Counter.Stop() ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, dTime) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeneral( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "print", MyPrint) ;
|
||||
lua_register( L, "EgtSetContext", SetContext) ;
|
||||
lua_register( L, "EgtGetContext", GetContext) ;
|
||||
lua_register( L, "EgtPause", LuaPause) ;
|
||||
lua_register( L, "EgtStartCounter", LuaStartCounter) ;
|
||||
lua_register( L, "EgtStopCounter", LuaStopCounter) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GeoSnap.cpp Data : 02.10.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di snap ad oggetti del DB geometrico per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.10.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStartPoint( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto iniziale dell'entità
|
||||
Point3d ptP ;
|
||||
if ( EgtStartPoint( LuaGetGseContext(), nId, ptP.v))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaEndPoint( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto finale dell'entità
|
||||
Point3d ptP ;
|
||||
if ( EgtEndPoint( LuaGetGseContext(), nId, ptP.v))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMidPoint( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto centrale dell'entità
|
||||
Point3d ptP ;
|
||||
if ( EgtMidPoint( LuaGetGseContext(), nId, ptP.v))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCenterPoint( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto centrale dell'entità
|
||||
Point3d ptP ;
|
||||
if ( EgtCenterPoint( LuaGetGseContext(), nId, ptP.v))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaAtParamPoint( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, U
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2, dU)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto in posizione parametrica U della curva
|
||||
Point3d ptP ;
|
||||
if ( EgtAtParamPoint( LuaGetGseContext(), nId, dU, ptP.v))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStartVector( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il vettore tangente all'inizio della curva
|
||||
Vector3d vtV ;
|
||||
if ( EgtStartVector( LuaGetGseContext(), nId, vtV.v))
|
||||
LuaSetReturn( L, vtV) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaEndVector( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il vettore tangente alla fine della curva
|
||||
Vector3d vtV ;
|
||||
if ( EgtEndVector( LuaGetGseContext(), nId, vtV.v))
|
||||
LuaSetReturn( L, vtV) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMidVector( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il vettore tangente nel punto medio della curva
|
||||
Vector3d vtV ;
|
||||
if ( EgtMidVector( LuaGetGseContext(), nId, vtV.v))
|
||||
LuaSetReturn( L, vtV) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaAtParamVector( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, U [, sSide]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2, dU)
|
||||
int nSide = + 1 ;
|
||||
string sSide ;
|
||||
if ( LuaGetParam( L, 3, sSide) && sSide == "-")
|
||||
nSide = - 1 ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto in posizione parametrica U della curva
|
||||
Vector3d vtV ;
|
||||
if ( EgtAtParamVector( LuaGetGseContext(), nId, dU, nSide, vtV.v))
|
||||
LuaSetReturn( L, vtV) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaFrame( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il frame
|
||||
Frame3d frFrame ;
|
||||
if ( EgtFrame( LuaGetGseContext(), nId, frFrame))
|
||||
LuaSetReturn( L, frFrame) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeoSnap( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtSP", LuaStartPoint) ;
|
||||
lua_register( L, "EgtEP", LuaEndPoint) ;
|
||||
lua_register( L, "EgtMP", LuaMidPoint) ;
|
||||
lua_register( L, "EgtCP", LuaCenterPoint) ;
|
||||
lua_register( L, "EgtUP", LuaAtParamPoint) ;
|
||||
lua_register( L, "EgtSV", LuaStartVector) ;
|
||||
lua_register( L, "EgtEV", LuaEndVector) ;
|
||||
lua_register( L, "EgtMV", LuaMidVector) ;
|
||||
lua_register( L, "EgtUV", LuaAtParamVector) ;
|
||||
lua_register( L, "EgtFR", LuaFrame) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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 "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMove( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id/s, VtMove
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Vector3d vtMove ;
|
||||
LuaCheckParam( L, 2, vtMove)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo traslazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMove( LuaGetGseContext(), vId[i], vtMove.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMoveGlob( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id/s, VtMove
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Vector3d vtMove ;
|
||||
LuaCheckParam( L, 2, vtMove)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo traslazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMoveGlob( LuaGetGseContext(), vId[i], vtMove.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMoveGroup( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id/s, VtMove
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Vector3d vtMove ;
|
||||
LuaCheckParam( L, 2, vtMove)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo traslazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMoveGroup( LuaGetGseContext(), vId[i], vtMove.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRotate( lua_State* L)
|
||||
{
|
||||
// 4 parametri : Id/s, PtAx, VtAx, dAngRotDeg
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptAx ;
|
||||
LuaCheckParam( L, 2, ptAx)
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 3, vtAx)
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 4, dAngRotDeg)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo rotazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtRotate( LuaGetGseContext(), vId[i], ptAx.v, vtAx.v, dAngRotDeg))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRotateGlob( lua_State* L)
|
||||
{
|
||||
// 4 parametri : Id/s, PtAx, VtAx, dAngRotDeg
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptAx ;
|
||||
LuaCheckParam( L, 2, ptAx)
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 3, vtAx)
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 4, dAngRotDeg)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo rotazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtRotateGlob( LuaGetGseContext(), vId[i], ptAx.v, vtAx.v, dAngRotDeg))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRotateGroup( lua_State* L)
|
||||
{
|
||||
// 4 parametri : Id/s, PtAx, VtAx, dAngRotDeg
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptAx ;
|
||||
LuaCheckParam( L, 2, ptAx)
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 3, vtAx)
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 4, dAngRotDeg)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo rotazione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtRotateGroup( LuaGetGseContext(), vId[i], ptAx.v, vtAx.v, dAngRotDeg))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaScale( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtScale( LuaGetGseContext(), vId[i], frRef.Orig().v,
|
||||
frRef.VersX().v, frRef.VersY().v, frRef.VersZ().v,
|
||||
dCoeffX, dCoeffY, dCoeffZ))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaScaleGlob( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtScaleGlob( LuaGetGseContext(), vId[i], frRef.Orig().v,
|
||||
frRef.VersX().v, frRef.VersY().v, frRef.VersZ().v,
|
||||
dCoeffX, dCoeffY, dCoeffZ))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaScaleGroup( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtScaleGroup( LuaGetGseContext(), vId[i], frRef.Orig().v,
|
||||
frRef.VersX().v, frRef.VersY().v, frRef.VersZ().v,
|
||||
dCoeffX, dCoeffY, dCoeffZ))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMirror( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id/s, PtOn, VtN
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptOn ;
|
||||
LuaCheckParam( L, 2, ptOn)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMirror( LuaGetGseContext(), vId[i], ptOn.v, vtN.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMirrorGlob( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id/s, PtOn, VtN
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptOn ;
|
||||
LuaCheckParam( L, 2, ptOn)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMirrorGlob( LuaGetGseContext(), vId[i], ptOn.v, vtN.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMirrorGroup( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id/s, PtOn, VtN
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Point3d ptOn ;
|
||||
LuaCheckParam( L, 2, ptOn)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtMirrorGroup( LuaGetGseContext(), vId[i], ptOn.v, vtN.v))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShear( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id, PtOn, VtN, VtDir, Coeff
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtShear( LuaGetGseContext(), vId[i], ptOn.v, vtN.v, vtDir.v, dCoeff))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShearGlob( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id, PtOn, VtN, VtDir, Coeff
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtShearGlob( LuaGetGseContext(), vId[i], ptOn.v, vtN.v, vtDir.v, dCoeff))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShearGroup( lua_State* L)
|
||||
{
|
||||
// 5 parametri : Id, PtOn, VtN, VtDir, Coeff
|
||||
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)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo scalatura
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( ! EgtShearGroup( LuaGetGseContext(), vId[i], ptOn.v, vtN.v, vtDir.v, dCoeff))
|
||||
bOk = false ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeoTransform( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtMove", LuaMove) ;
|
||||
lua_register( L, "EgtMoveGlob", LuaMoveGlob) ;
|
||||
lua_register( L, "EgtMoveGroup", LuaMoveGroup) ;
|
||||
lua_register( L, "EgtRotate", LuaRotate) ;
|
||||
lua_register( L, "EgtRotateGlob", LuaRotateGlob) ;
|
||||
lua_register( L, "EgtRotateGroup", LuaRotateGroup) ;
|
||||
lua_register( L, "EgtScale", LuaScale) ;
|
||||
lua_register( L, "EgtScaleGlob", LuaScaleGlob) ;
|
||||
lua_register( L, "EgtScaleGroup", LuaScaleGroup) ;
|
||||
lua_register( L, "EgtMirror", LuaMirror) ;
|
||||
lua_register( L, "EgtMirrorGlob", LuaMirrorGlob) ;
|
||||
lua_register( L, "EgtMirrorGroup", LuaMirrorGroup) ;
|
||||
lua_register( L, "EgtShear", LuaShear) ;
|
||||
lua_register( L, "EgtShearGlob", LuaShearGlob) ;
|
||||
lua_register( L, "EgtShearGroup", LuaShearGroup) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni generali per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetDefaultMaterial( lua_State* L)
|
||||
{
|
||||
// un solo parametro, il colore
|
||||
Color colDef ;
|
||||
if ( ! LuaGetParam( L, 1, colDef))
|
||||
return luaL_error( L, "Invalide first parameter") ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto il colore di default
|
||||
bool bOk = ( EgtSetDefaultMaterial( LuaGetGseContext(), colDef.GetIntRed(),
|
||||
colDef.GetIntGreen(), colDef.GetIntBlue()) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaNewFile( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// nuovo progetto
|
||||
bool bOk = ( EgtNewFile( LuaGetGseContext()) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaOpenFile( lua_State* L)
|
||||
{
|
||||
// 1 parametro : path del file da aprire
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 1, sFilePath)
|
||||
LuaClearStack( L) ;
|
||||
// apro il file
|
||||
bool bOk = ( EgtOpenFile( LuaGetGseContext(), sFilePath) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSaveFile( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : path del file [, flag("T","B","CT")]
|
||||
string sFilePath ;
|
||||
LuaCheckParam( L, 1, sFilePath)
|
||||
int nFlag = GDB_SV_CMPTXT ;
|
||||
string sFlag ;
|
||||
if ( LuaGetParam( L, 2, sFlag)) {
|
||||
ToUpper( sFlag) ;
|
||||
if ( sFlag == "T")
|
||||
nFlag = GDB_SV_TXT ;
|
||||
else if ( sFlag == "B")
|
||||
nFlag = GDB_SV_BIN ;
|
||||
LuaClearStack( L) ;
|
||||
}
|
||||
// salvo il file
|
||||
bool bOk = ( EgtSaveFile( LuaGetGseContext(), sFilePath, nFlag) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeomDB( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtSetDefaultMaterial", LuaSetDefaultMaterial) ;
|
||||
lua_register( L, "EgtNewFile", LuaNewFile) ;
|
||||
lua_register( L, "EgtOpenFile", LuaOpenFile) ;
|
||||
lua_register( L, "EgtSaveFile", LuaSaveFile) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_Scene.cpp Data : 29.09.14 Versione : 1.5i5
|
||||
// Contenuto : Funzioni di visualizzazione per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 29.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetBackground( lua_State* L)
|
||||
{
|
||||
// 3 parametri : colore top, colore bottom, flag ridisegna
|
||||
Color colTop ;
|
||||
LuaCheckParam( L, 1, colTop)
|
||||
Color colBot ;
|
||||
LuaCheckParam( L, 2, colBot)
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 3, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto lo sfondo
|
||||
bool bOk = ( EgtSetBackground( LuaGetGseContext(), colTop.GetIntRed(), colTop.GetIntGreen(), colTop.GetIntBlue(),
|
||||
colBot.GetIntRed(), colBot.GetIntGreen(), colBot.GetIntBlue(), bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaDraw( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// eseguo ridisegno
|
||||
bool bOk = ( EgtDraw( LuaGetGseContext()) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetShowMode( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ShowMode ("WF","HL","SH"), flag ridisegna
|
||||
string sShowMode ;
|
||||
LuaCheckParam( L, 1, sShowMode)
|
||||
int nShowMode = SM_SHADING ;
|
||||
ToUpper( sShowMode) ;
|
||||
if ( sShowMode == "WF")
|
||||
nShowMode = SM_WIREFRAME ;
|
||||
else if ( sShowMode == "HL")
|
||||
nShowMode = SM_HIDDENLINE ;
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 2, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto il modo di visualizzazione
|
||||
bool bOk = ( EgtSetShowMode( LuaGetGseContext(), nShowMode, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetShowCurveDirection( lua_State* L)
|
||||
{
|
||||
// 2 parametri : flag ShowCrvDir, flag ridisegna
|
||||
bool bShowCrvDir ;
|
||||
LuaCheckParam( L, 1, bShowCrvDir)
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 2, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto visualizzazione direzione curve
|
||||
bool bOk = ( EgtSetShowCurveDirection( LuaGetGseContext(), bShowCrvDir, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaZoom( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ZoomType ("ALL","IN","OUT"), flag ridisegna
|
||||
string sZoomType ;
|
||||
LuaCheckParam( L, 1, sZoomType)
|
||||
int nZoomType = 1 ;
|
||||
ToUpper( sZoomType) ;
|
||||
if ( sZoomType == "IN")
|
||||
nZoomType = 2 ;
|
||||
else if ( sZoomType == "OUT")
|
||||
nZoomType = 3 ;
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 2, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto zoom
|
||||
bool bOk = ( EgtZoom( LuaGetGseContext(), nZoomType, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetView( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ViewDir ("T","F","R","B","L","BO","SWI","SEI","NEI","NWI"), flag ridisegna
|
||||
string sViewDir ;
|
||||
LuaCheckParam( L, 1, sViewDir)
|
||||
int nViewDir = CT_TOP ;
|
||||
ToUpper( sViewDir) ;
|
||||
if ( sViewDir == "F")
|
||||
nViewDir = CT_FRONT ;
|
||||
else if ( sViewDir == "R")
|
||||
nViewDir = CT_RIGHT ;
|
||||
else if ( sViewDir == "B")
|
||||
nViewDir = CT_BACK ;
|
||||
else if ( sViewDir == "L")
|
||||
nViewDir = CT_LEFT ;
|
||||
else if ( sViewDir == "SWI")
|
||||
nViewDir = CT_ISO_SW ;
|
||||
else if ( sViewDir == "SEI")
|
||||
nViewDir = CT_ISO_SE ;
|
||||
else if ( sViewDir == "NEI")
|
||||
nViewDir = CT_ISO_NE ;
|
||||
else if ( sViewDir == "NWI")
|
||||
nViewDir = CT_ISO_NW ;
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 2, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto direzione di vista
|
||||
bool bOk = ( EgtSetView( LuaGetGseContext(), nViewDir, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetGenericView( lua_State* L)
|
||||
{
|
||||
// 3 parametri : dAngVertDeg, dAngHorizDeg, flag ridisegna
|
||||
double dAngVertDeg ;
|
||||
LuaCheckParam( L, 1, dAngVertDeg)
|
||||
double dAngHorizDeg ;
|
||||
LuaCheckParam( L, 2, dAngHorizDeg)
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 3, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto direzione di vista
|
||||
bool bOk = ( EgtSetGenericView( LuaGetGseContext(), dAngVertDeg, dAngHorizDeg, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetViewCenter( lua_State* L)
|
||||
{
|
||||
// 2 parametri : ptCen, flag ridisegna
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 1, ptCen)
|
||||
bool bRedraw ;
|
||||
LuaCheckParam( L, 2, bRedraw)
|
||||
LuaClearStack( L) ;
|
||||
// imposto centro di vista
|
||||
bool bOk = ( EgtSetViewCenter( LuaGetGseContext(), ptCen.v, bRedraw) != FALSE) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallScene( lua_State* L)
|
||||
{
|
||||
try {
|
||||
lua_register( L, "EgtSetBackground", LuaSetBackground) ;
|
||||
lua_register( L, "EgtDraw", LuaDraw) ;
|
||||
lua_register( L, "EgtSetShowMode", LuaSetShowMode) ;
|
||||
lua_register( L, "EgtSetShowCurveDirection", LuaSetShowCurveDirection) ;
|
||||
lua_register( L, "EgtZoom", LuaZoom) ;
|
||||
lua_register( L, "EgtSetView", LuaSetView) ;
|
||||
lua_register( L, "EgtSetGenericView", LuaSetGenericView) ;
|
||||
lua_register( L, "EgtSetViewCenter", LuaSetViewCenter) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user