From 9d3dc5e537101d015ed0654e8e8702eb60a99f01 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 20 Apr 2015 08:43:10 +0000 Subject: [PATCH] EgtInterface 1.6d3 : - costanti stringa sostituite con costanti numeriche - modificate funzioni API e LUA per scansione pezzi e layer - aggiunta pulizia memoria al caricamento messaggi (necessario al cambio lingua) - migliorie varie a funzioni Lua. --- API.h | 8 +- API_GdbCreateCurve.cpp | 4 +- API_GdbCreateSurf.cpp | 12 +- API_GdbModifyCurve.cpp | 35 ++---- API_GdbModifySurf.cpp | 6 +- API_GdbObjAttribs.cpp | 27 ++--- API_GdbObjects.cpp | 10 +- API_GdbPartLayers.cpp | 64 +++++++--- API_GeoBase.cpp | 17 +++ API_GeoSnap.cpp | 2 +- API_GeoTransform.cpp | 30 +---- API_MachMgr.cpp | 102 ++++++++++++---- API_Messages.cpp | 4 +- AuxTools.cpp | 220 +++++++---------------------------- AuxTools.h | 11 +- EgtInterface.rc | Bin 11718 -> 11718 bytes EgtInterface.vcxproj | 2 - EgtInterface.vcxproj.filters | 6 - LUA_Aux.cpp | 49 -------- LUA_Aux.h | 20 ---- LUA_Exchange.cpp | 2 +- LUA_GdbCreate.cpp | 47 ++++---- LUA_GdbCreateCurve.cpp | 160 ++++++++++++------------- LUA_GdbCreateSurf.cpp | 60 +++++----- LUA_GdbModify.cpp | 22 ++-- LUA_GdbModifyCurve.cpp | 51 ++++---- LUA_GdbModifySurf.cpp | 4 +- LUA_GdbObjAttribs.cpp | 57 ++++----- LUA_GdbObjSelection.cpp | 4 +- LUA_GdbObjects.cpp | 130 ++++++++++++++++----- LUA_GdbPartLayers.cpp | 88 +++++++++----- LUA_General.cpp | 2 +- LUA_GeoBase.cpp | 31 ++++- LUA_GeoSnap.cpp | 57 +++++---- LUA_GeoTransform.cpp | 24 ++-- LUA_GeomDB.cpp | 12 +- LUA_MachMgr.cpp | 173 ++++++++++++++++++++++----- LUA_Scene.cpp | 81 ++++--------- 38 files changed, 810 insertions(+), 824 deletions(-) delete mode 100644 LUA_Aux.cpp delete mode 100644 LUA_Aux.h diff --git a/API.h b/API.h index 71e1a52..e7a8c12 100644 --- a/API.h +++ b/API.h @@ -147,15 +147,21 @@ bool EgtInsertMachMgr( int nInsGrp) ; int EgtAddMachGroup( const std::string& sName, const std::string& sMachineName) ; bool EgtGetMachGroupName( int nId, std::string& sName) ; int EgtGetMachGroupId( const std::string& sName) ; +int EgtGetRawPartNbr( void) ; +int EgtGetFirstRawPart( void) ; +int EgtGetNextRawPart( int nRawId) ; int EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol) ; int EgtAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) ; -bool EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ; bool EgtModifyRawPartHeight( int nRawId, double dHeight) ; bool EgtRemoveRawPart( int nRawId) ; bool EgtTranslateRawPart( int nRawId, const Vector3d& vtMove) ; bool EgtRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; bool EgtMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ; bool EgtMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ; +int EgtGetPartInRawPartNbr( int nRawId) ; +int EgtGetFirstPartInRawPart( int nRawId) ; +int EgtGetNextPartInRawPart( int nPartId) ; +bool EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ; bool EgtRemovePartFromRawPart( int nPartId) ; bool EgtTranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ; bool EgtRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index b01cffe..8900fb1 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -1776,8 +1776,8 @@ __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLi // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCurveCompoByApprox(" + ToString( nParentId) + "," + - ToString( nSouId) + ",'" + - ( bArcsVsLines ? "ARCS" : "LINES") + "'," + + ToString( nSouId) + "," + + ( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," + ToString( dLinTol) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index 87632df..609d286 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -742,12 +742,8 @@ EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; string sLua = "EgtSurfTmByTriangles(" + ToString( nParentId) + ",{" + - sIds + "}," + + IdListToString( vIds) + "}," + ( bErase ? "true" : "false") + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -826,12 +822,8 @@ EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; string sLua = "EgtSurfTmBySewing(" + ToString( nParentId) + ",{" + - sIds + "}," + + IdListToString( vIds) + "}," + ( bErase ? "true" : "false") + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index b4f14df..e2602c0 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -62,11 +62,7 @@ EgtInvertCurve( const INTVECTOR& vIds) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtInvertCurve({" + sIds + "})" + + string sLua = "EgtInvertCurve({" + IdListToString( vIds) + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -88,15 +84,10 @@ __stdcall EgtOffsetCurve( int nId, double dDist, int nType) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; - if ( nType == ICurve::OFF_FILLET) - sLua = "EgtOffsetCurve(" + ToString( nId) + "," + - ToString( dDist) + ")" + - " -- Ok=" + ToString( bOk) ; - else - sLua = "EgtOffsetCurve(" + ToString( nId) + "," + - ToString( dDist) + "," + - ( nType == ICurve::OFF_CHAMFER ? "'CHAMFER'" : "'EXTEND'") + ")" + - " -- Ok=" + ToString( bOk) ; + sLua = "EgtOffsetCurve(" + ToString( nId) + "," + + ToString( dDist) + "," + + OffsTypeToString( nType) + ")" + + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato @@ -277,11 +268,7 @@ EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRef EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtModifyCurveExtrusion({" + sIds + "},{" + + string sLua = "EgtModifyCurveExtrusion({" + IdListToString( vIds) + "},{" + ToString( Vector3d( vtExtr)) + "}," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; @@ -356,11 +343,7 @@ EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtModifyCurveThickness({" + sIds + "}," + + string sLua = "EgtModifyCurveThickness({" + IdListToString( vIds) + "}," + ToString( dThick) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -832,8 +815,8 @@ __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtExplodeCurveBezier(" + ToString( nId) + ",'" + - ( bArcsVsLines ? "ARCS" : "LINES") + "'," + + string sLua = "EgtExplodeCurveBezier(" + ToString( nId) + "," + + ( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," + ToString( dLinTol) + ")" + " -- Id=" + ToString( nCrvId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; diff --git a/API_GdbModifySurf.cpp b/API_GdbModifySurf.cpp index dd4f5c8..24b588e 100644 --- a/API_GdbModifySurf.cpp +++ b/API_GdbModifySurf.cpp @@ -57,11 +57,7 @@ EgtInvertSurface( const INTVECTOR& vIds) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtInvertSurf({" + sIds + "})" + + string sLua = "EgtInvertSurf({" + IdListToString( vIds) + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index e24a946..d10ea21 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnStringConverter.h" @@ -167,21 +168,17 @@ EgtSetStatus( const INTVECTOR& vIds, int nStat) if ( bCurrPartOff) EgtResetCurrPartLayer() ; else if ( bCurrLayerOff) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; // dichiaro progetto modificato EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sStat = "'ON'" ; + string sStat = "GDB_ST.ON" ; if ( nStat == GDB_ST_SEL) - sStat = "'SEL'" ; + sStat = "GDB_ST.SEL" ; else if ( nStat == GDB_ST_OFF) - sStat = "'OFF'" ; - string sLua = "EgtSetStatus({" + sIds + "}," + + sStat = "GDB_ST.OFF" ; + string sLua = "EgtSetStatus({" + IdListToString( vIds) + "}," + sStat + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -383,11 +380,7 @@ EgtSetAlpha( const INTVECTOR& vIds, int nAlpha) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtSetAlpha({" + sIds + "}," + + string sLua = "EgtSetAlpha({" + IdListToString( vIds) + "}," + ToString( nAlpha) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -427,11 +420,7 @@ EgtResetColor( const INTVECTOR& vIds) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtResetColor({" + sIds + "})" + + string sLua = "EgtResetColor({" + IdListToString( vIds) + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 30443a5..df941a5 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -455,15 +455,11 @@ EgtErase( const INTVECTOR& vIds) if ( bErasedCurrPart) EgtResetCurrPartLayer() ; else if ( bErasedCurrLayer) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtErase({" + sIds + "})" + + string sLua = "EgtErase({" + IdListToString( vIds) + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -485,7 +481,7 @@ __stdcall EgtEmptyGroup( int nId) if ( ! pGeomDB->ExistsObj( nCurrPartId)) EgtResetCurrPartLayer() ; else if ( ! pGeomDB->ExistsObj( nCurrLayerId)) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { diff --git a/API_GdbPartLayers.cpp b/API_GdbPartLayers.cpp index 4039831..c4a5a1f 100644 --- a/API_GdbPartLayers.cpp +++ b/API_GdbPartLayers.cpp @@ -22,6 +22,14 @@ using namespace std ; +//------------------------------------------------------------------------------- +static bool +EgtIsUserObj( IGeomDB* pGeomDB, int nId) +{ + int nLev ; + return ( pGeomDB->GetCalcLevel( nId, nLev) && nLev == GDB_LV_USER) ; +} + //------------------------------------------------------------------------------- static bool EgtIsVisibleObj( IGeomDB* pGeomDB, int nId) @@ -32,10 +40,11 @@ EgtIsVisibleObj( IGeomDB* pGeomDB, int nId) //------------------------------------------------------------------------------- static int -EgtVerifyOrNextVisible( IGeomDB* pGeomDB, int nId) +EgtVerifyOrNext( IGeomDB* pGeomDB, int nId, bool bOnlyVisible) { while ( nId != GDB_ID_NULL) { - if ( EgtIsVisibleObj( pGeomDB, nId)) + if ( EgtIsUserObj( pGeomDB, nId) && + ( ! bOnlyVisible || EgtIsVisibleObj( pGeomDB, nId))) return nId ; nId = pGeomDB->GetNextGroup( nId) ; } @@ -114,10 +123,10 @@ __stdcall EgtResetCurrPartLayer( void) pGseCtx->m_nCurrPart = GDB_ID_NULL ; pGseCtx->m_nCurrLayer = GDB_ID_NULL ; // cerco il primo pezzo con un layer visibile - int nPartId = EgtGetFirstVisiblePart() ; + int nPartId = EgtGetFirstPart( true) ; while ( nPartId != GDB_ID_NULL) { // cerco il primo layer visibile del pezzo - int nLayerId = EgtGetFirstVisibleLayer( nPartId) ; + int nLayerId = EgtGetFirstLayer( nPartId, true) ; if ( nLayerId != GDB_ID_NULL) { // assegno il pezzo corrente pGseCtx->m_nCurrPart = nPartId ; @@ -126,11 +135,11 @@ __stdcall EgtResetCurrPartLayer( void) // esco dal ciclo di ricerca break ; } - nPartId = EgtGetNextVisiblePart( nPartId) ; + nPartId = EgtGetNextPart( nPartId, true) ; } // se non ho trovato layer visibile mi accontento del primo pezzo visibile if ( pGseCtx->m_nCurrPart == GDB_ID_NULL) - pGseCtx->m_nCurrPart = EgtGetFirstVisiblePart() ; + pGseCtx->m_nCurrPart = EgtGetFirstPart( true) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtResetCurrPartLayer()" @@ -143,53 +152,70 @@ __stdcall EgtResetCurrPartLayer( void) //------------------------------------------------------------------------------- int -__stdcall EgtGetFirstVisiblePart( void) +__stdcall EgtGetPartNbr( bool bOnlyVisible) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // conto i pezzi, considerando richiesta di visibilità + int nCount = 0 ; + int nPartId = EgtGetFirstPart( bOnlyVisible) ; + while ( nPartId != GDB_ID_NULL) { + ++ nCount ; + nPartId = EgtGetNextPart( nPartId, bOnlyVisible) ; + } + return nCount ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtGetFirstPart( bool bOnlyVisible) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il primo gruppo sotto la radice int nPartId = pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ; - // verifico sia visibile oppure passo al primo successivo visibile - return EgtVerifyOrNextVisible( pGeomDB, nPartId) ; + // verifico oppure passo al primo successivo valido + return EgtVerifyOrNext( pGeomDB, nPartId, bOnlyVisible) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetNextVisiblePart( int nId) +__stdcall EgtGetNextPart( int nId, bool bOnlyVisible) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il successivo gruppo int nPartId = pGeomDB->GetNextGroup( nId) ; - // verifico sia visibile oppure passo al primo successivo visibile - return EgtVerifyOrNextVisible( pGeomDB, nPartId) ; + // verifico oppure passo al primo successivo valido + return EgtVerifyOrNext( pGeomDB, nPartId, bOnlyVisible) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetFirstVisibleLayer( int nPartId) +__stdcall EgtGetFirstLayer( int nPartId, bool bOnlyVisible) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // verifico la visibilità del pezzo - if ( ! EgtIsVisibleObj( pGeomDB, nPartId)) + // verifico il pezzo (livello utente e se richiesto visibile) + if ( ! EgtIsUserObj( pGeomDB, nPartId) || + ( bOnlyVisible && ! EgtIsVisibleObj( pGeomDB, nPartId))) return GDB_ID_NULL ; // recupero il primo layer nel pezzo int nLayerId = pGeomDB->GetFirstGroupInGroup( nPartId) ; - // verifico sia visibile oppure passo al primo successivo visibile - return EgtVerifyOrNextVisible( pGeomDB, nLayerId) ; + // verifico oppure passo al primo successivo valido + return EgtVerifyOrNext( pGeomDB, nLayerId, bOnlyVisible) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetNextVisibleLayer( int nId) +__stdcall EgtGetNextLayer( int nId, bool bOnlyVisible) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il successivo gruppo int nLayerId = pGeomDB->GetNextGroup( nId) ; // verifico sia visibile oppure passo al primo successivo visibile - return EgtVerifyOrNextVisible( pGeomDB, nLayerId) ; + return EgtVerifyOrNext( pGeomDB, nLayerId, bOnlyVisible) ; } //----------------------------------------------------------------------------- diff --git a/API_GeoBase.cpp b/API_GeoBase.cpp index dd508ed..bb0f015 100644 --- a/API_GeoBase.cpp +++ b/API_GeoBase.cpp @@ -478,6 +478,23 @@ __stdcall EgtFrameLocToLoc( double ptOrig[3], double vtX[3], double vtY[3], doub //----------------------------------------------------------------------------- // BBox3d + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtBBoxRotate( double ptMin[3], double ptMax[3], + const double ptAx[3], const double vtAx[3], double dAngRotDeg) +{ + // eseguo la trasformazione + BBox3d b3Temp ; + b3Temp.Set( ptMin, ptMax) ; + if ( ! b3Temp.Rotate( ptAx, vtAx, dAngRotDeg)) + return FALSE ; + // aggiorno i parametri del box + VEC_FROM_3D( ptMin, b3Temp.GetMin()) + VEC_FROM_3D( ptMax, b3Temp.GetMax()) + return TRUE ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtBBoxToGlob( double ptMin[3], double ptMax[3], diff --git a/API_GeoSnap.cpp b/API_GeoSnap.cpp index d882e79..2372197 100644 --- a/API_GeoSnap.cpp +++ b/API_GeoSnap.cpp @@ -688,7 +688,7 @@ EgtAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV) const ICurve* pCrv = GetCurve( pGObj) ; // assegno il lato di approccio ICurve::Side nSide = ICurve::FROM_MINUS ; - if ( nSide >0) + if ( nSide > 0) nSide = ICurve::FROM_PLUS ; // recupero la direzione Point3d ptP ; diff --git a/API_GeoTransform.cpp b/API_GeoTransform.cpp index 9fcc270..651f9a0 100644 --- a/API_GeoTransform.cpp +++ b/API_GeoTransform.cpp @@ -76,11 +76,7 @@ EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtMove({" + sIds + "},{" + + string sLua = "EgtMove({" + IdListToString( vIds) + "},{" + ToString( vtMove) + "}," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; @@ -146,11 +142,7 @@ EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dA EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtRotate({" + sIds + "},{" + + string sLua = "EgtRotate({" + IdListToString( vIds) + "},{" + ToString( ptAx) + "},{" + ToString( vtAx) + "}," + ToString( dAngRotDeg) + "," + @@ -223,11 +215,7 @@ EgtScale( INTVECTOR& vIds, const Frame3d& frRef, EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtScale({" + sIds + "},{{" + + string sLua = "EgtScale({" + IdListToString( vIds) + "},{{" + ToString( frRef.Orig()) + "},{" + ToString( frRef.VersX()) + "},{" + ToString( frRef.VersY()) + "},{" + @@ -299,11 +287,7 @@ EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefTyp EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtMirror({" + sIds + "},{" + + string sLua = "EgtMirror({" + IdListToString( vIds) + "},{" + ToString( ptP) + "},{" + ToString( vtN) + "}," + RefTypeToString( nRefType) + ")" + @@ -374,11 +358,7 @@ EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; - string sLua = "EgtShear({" + sIds + "},{" + + string sLua = "EgtShear({" + IdListToString( vIds) + "},{" + ToString( ptP) + "},{" + ToString( vtN) + "},{" + ToString( vtDir) + "}," + diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index aeeb3b8..0faab3b 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -227,6 +227,36 @@ __stdcall EgtGetCurrMachGroup( void) return pMachMgr->GetCurrMachGroup() ; } +//----------------------------------------------------------------------------- +int +EgtGetRawPartNbr( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero il numero di grezzi nella macchinata corrente + return pGseCtx->m_pMachMgr->GetRawPartNbr() ; +} + +//----------------------------------------------------------------------------- +int +EgtGetFirstRawPart( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero identificativo primo grezzo nella macchinata corrente + return pGseCtx->m_pMachMgr->GetFirstRawPart() ; +} + +//----------------------------------------------------------------------------- +int +EgtGetNextRawPart( int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero identificativo successivo grezzo nella macchinata corrente + return pGseCtx->m_pMachMgr->GetNextRawPart( nRawId) ; +} + //----------------------------------------------------------------------------- int EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol) @@ -272,27 +302,6 @@ EgtAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) return nId ; } -//----------------------------------------------------------------------------- -bool -EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // inserisco pezzo in un grezzo della macchinata corrente - bool bOk = pGseCtx->m_pMachMgr->AddPartToRawPart( nPartId, ptPos, nRawId) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtAddPartToRawPart(" + ToString( nPartId) + ",{" + - ToString( ptPos) + "}," + - ToString( nRawId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - //----------------------------------------------------------------------------- bool EgtModifyRawPartHeight( int nRawId, double dHeight) @@ -415,6 +424,57 @@ EgtMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) return bOk ; } +//----------------------------------------------------------------------------- +int +EgtGetPartInRawPartNbr( int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero il numero di pezzi nel grezzo + return pGseCtx->m_pMachMgr->GetPartInRawPartNbr( nRawId) ; +} + +//----------------------------------------------------------------------------- +int +EgtGetFirstPartInRawPart( int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero identificativo primo pezzo nel grezzo + return pGseCtx->m_pMachMgr->GetFirstPartInRawPart( nRawId) ; +} + +//----------------------------------------------------------------------------- +int +EgtGetNextPartInRawPart( int nPartId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero identificativo successivo pezzo nello stesso grezzo + return pGseCtx->m_pMachMgr->GetNextPartInRawPart( nPartId) ; +} + +//----------------------------------------------------------------------------- +bool +EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // inserisco pezzo in un grezzo della macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->AddPartToRawPart( nPartId, ptPos, nRawId) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddPartToRawPart(" + ToString( nPartId) + ",{" + + ToString( ptPos) + "}," + + ToString( nRawId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool EgtRemovePartFromRawPart( int nPartId) diff --git a/API_Messages.cpp b/API_Messages.cpp index 0429d2f..30e34c7 100644 --- a/API_Messages.cpp +++ b/API_Messages.cpp @@ -37,7 +37,9 @@ __stdcall EgtLoadMessages( const wchar_t* wsMsgFilePath) Scanner scan ; if ( ! scan.Init( sMsgFilePath)) return FALSE ; - + // pulisco la memoria + s_IdStringMap.clear() ; + s_wsMsg.clear() ; // riservo spazio s_IdStringMap.rehash( 1000) ; s_wsMsg.reserve( 128) ; diff --git a/AuxTools.cpp b/AuxTools.cpp index b68eb94..ddf494a 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -27,7 +27,7 @@ IdListToString( const INTVECTOR& vIds) string sIds ; sIds.reserve( 6 * vIds.size()) ; for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID.SEL") + "," ; if ( ! sIds.empty()) sIds.pop_back() ; return sIds ; @@ -38,177 +38,79 @@ const char* NgeTypeToString( int nNgeType) { switch ( nNgeType) { - case GDB_SV_TXT : return "'T'" ; - case GDB_SV_BIN : return "'B'" ; + case GDB_SV_TXT : return "GDB_NT.TXT" ; + case GDB_SV_BIN : return "GDB_NT.BIN" ; default : - case GDB_SV_CMPTXT : return "'CT'" ; + case GDB_SV_CMPTXT : return "GDB_NT.CMPTXT" ; } } -//---------------------------------------------------------------------------- -int -StringToNgeType( const string& sNgeType) -{ - string sTmp = sNgeType ; - ToUpper( sTmp) ; - if ( sTmp == "T") - return GDB_SV_TXT ; - else if ( sTmp == "B") - return GDB_SV_BIN ; - else if ( sTmp == "CT") - return GDB_SV_CMPTXT ; - // default - return GDB_SV_CMPTXT ; -} - //---------------------------------------------------------------------------- const char* SepToString( int nSep) { switch ( nSep) { default : - case SEP_STD : return "'ST'" ; - case SEP_TG : return "'TG'" ; - case SEP_PERP : return "'PR'" ; - case SEP_MINDIST : return "'MD'" ; + case SEP_STD : return "GDB_PT.STD" ; + case SEP_TG : return "GDB_PT.TG" ; + case SEP_PERP : return "GDB_PT.PERP" ; + case SEP_MINDIST : return "GDB_PT.MIND" ; } } -//---------------------------------------------------------------------------- -int -StringToSep( const string& sSep) -{ - string sTmp = sSep ; - ToUpper( sTmp) ; - if ( sTmp == "ST") - return SEP_STD ; - else if ( sTmp == "TG") - return SEP_TG ; - else if ( sTmp == "PR") - return SEP_PERP ; - else if ( sTmp == "MD") - return SEP_MINDIST ; - // default - return SEP_STD ; -} - //---------------------------------------------------------------------------- const char* InsToString( int nIns) { switch ( nIns) { + case GDB_FIRST_SON : return "GDB_IN.FIRST_SON" ; default : - case GDB_LAST_SON : return "'LAST_SON'" ; - case GDB_FIRST_SON : return "'FIRST_SON'" ; - case GDB_BEFORE : return "'BEFORE'" ; - case GDB_AFTER : return "'AFTER'" ; + case GDB_LAST_SON : return "GDB_IN.LAST_SON" ; + case GDB_BEFORE : return "GDB_IN.BEFORE" ; + case GDB_AFTER : return "GDB_IN.AFTER" ; } } -//---------------------------------------------------------------------------- -int -StringToIns( const string& sIns) -{ - string sTmp = sIns ; - ToUpper( sTmp) ; - if ( sTmp == "LAST_SON") - return GDB_LAST_SON ; - else if ( sTmp == "FIRST_SON") - return GDB_FIRST_SON ; - else if ( sTmp == "BEFORE") - return GDB_BEFORE ; - else if ( sTmp == "AFTER") - return GDB_AFTER ; - // default - return GDB_LAST_SON ; -} - //---------------------------------------------------------------------------- const char* RefTypeToString( int nRefType) { switch ( nRefType) { - case RTY_GLOB : return "'GLOB'" ; + case RTY_GLOB : return "GDB_RT.GLOB" ; default : - case RTY_LOC : return "'LOC'" ; - case RTY_GRID : return "'GRID'" ; + case RTY_LOC : return "GDB_RT.LOC" ; + case RTY_GRID : return "GDB_RT.GRID" ; } } -//---------------------------------------------------------------------------- -int -StringToRefType( const string& sRefType) -{ - string sTmp = sRefType ; - ToUpper( sTmp) ; - if ( sTmp == "GLOB") - return RTY_GLOB ; - else if ( sTmp == "LOC") - return RTY_LOC ; - else if ( sTmp == "GRID") - return RTY_GRID ; - // default - return RTY_LOC ; -} - -//---------------------------------------------------------------------------- -int -StringToRefId( const string& sRefId) -{ - string sTmp = sRefId ; - ToUpper( sTmp) ; - if ( sTmp == "GLOB") - return GDB_ID_ROOT ; - else if ( sTmp == "GRID") - return GDB_ID_GRID ; - // default - return GDB_ID_ROOT ; -} - //---------------------------------------------------------------------------- const char* ETxtInsPosToString( int nETxtInsPos) { switch ( nETxtInsPos) { - case ETXT_IPTL : return "'TL'" ; - case ETXT_IPTC : return "'TC'" ; - case ETXT_IPTR : return "'TR'" ; - case ETXT_IPML : return "'ML'" ; - case ETXT_IPMC : return "'MC'" ; - case ETXT_IPMR : return "'MR'" ; - default : - case ETXT_IPBL : return "'BL'" ; - case ETXT_IPBC : return "'BC'" ; - case ETXT_IPBR : return "'BR'" ; + case ETXT_IPTL : return "GDB_TI.TL" ; + case ETXT_IPTC : return "GDB_TI.TC" ; + case ETXT_IPTR : return "GDB_TI.TR" ; + case ETXT_IPML : return "GDB_TI.ML" ; + case ETXT_IPMC : return "GDB_TI.MC" ; + case ETXT_IPMR : return "GDB_TI.MR" ; + default : + case ETXT_IPBL : return "GDB_TI.BL" ; + case ETXT_IPBC : return "GDB_TI.BC" ; + case ETXT_IPBR : return "GDB_TI.BR" ; } } //---------------------------------------------------------------------------- -int -ETxtInsPosToString( const string& sETxtInsPos) +const char* +OffsTypeToString( int nOffsType) { - string sInsPos = sETxtInsPos ; - ToUpper( sInsPos) ; - if ( sInsPos == "TL") - return ETXT_IPTL ; - else if ( sInsPos == "TC") - return ETXT_IPTC ; - else if ( sInsPos == "TR") - return ETXT_IPTR ; - else if ( sInsPos == "ML") - return ETXT_IPML ; - else if ( sInsPos == "MC") - return ETXT_IPMC ; - else if ( sInsPos == "MR") - return ETXT_IPMR ; - else if ( sInsPos == "BL") - return ETXT_IPBL ; - else if ( sInsPos == "BC") - return ETXT_IPBC ; - else if ( sInsPos == "BR") - return ETXT_IPBR ; - // default - return ETXT_IPBL ; + switch ( nOffsType) { + default : + case ICurve::OFF_FILLET : return "GDB_OT.FILLET" ; + case ICurve::OFF_CHAMFER : return "GDB_OT.CHAMFER" ; + case ICurve::OFF_EXTEND : return "GDB_OT.EXTEND" ; + } } //---------------------------------------------------------------------------- @@ -216,62 +118,24 @@ const char* RawPartCornerPosToString( int nFlag) { switch ( nFlag) { - case RPCR_TL : return "'TL'" ; - case RPCR_TR : return "'TR'" ; + case RPCR_TL : return "MCH_CR.TL" ; + case RPCR_TR : return "MCH_CR.TR" ; default : - case RPCR_BL : return "'BL'" ; - case RPCR_BR : return "'BR'" ; + case RPCR_BL : return "MCH_CR.BL" ; + case RPCR_BR : return "MCH_CR.BR" ; } } -//---------------------------------------------------------------------------- -int -StringToRawPartCornerPos( const string& sFlag) -{ - string sTemp = sFlag ; - ToUpper( sTemp) ; - if ( sTemp == "TL") - return RPCR_TL ; - else if ( sTemp == "TR") - return RPCR_TR ; - else if ( sTemp == "BL") - return RPCR_BL ; - else if ( sTemp == "BR") - return RPCR_BR ; - // default - return RPCR_BL ; -} - //---------------------------------------------------------------------------- const char* RawPartCenterPosToString( int nFlag) { switch ( nFlag) { - case RPCE_TC : return "'TC'" ; + case RPCE_TC : return "MCH_CE.TC" ; default : - case RPCE_ML : return "'ML'" ; - case RPCE_MR : return "'MR'" ; - case RPCE_BC : return "'BC'" ; - case RPCE_MC : return "'MC'" ; + case RPCE_ML : return "MCH_CE.ML" ; + case RPCE_MR : return "MCH_CE.MR" ; + case RPCE_BC : return "MCH_CE.BC" ; + case RPCE_MC : return "MCH_CE.MC" ; } } - -//---------------------------------------------------------------------------- -int -StringToRawPartCenterPos( const string& sFlag) -{ - string sTemp = sFlag ; - ToUpper( sTemp) ; - if ( sTemp == "TC") - return RPCE_TC ; - else if ( sTemp == "ML") - return RPCE_ML ; - else if ( sTemp == "MR") - return RPCE_MR ; - else if ( sTemp == "BC") - return RPCE_BC ; - else if ( sTemp == "MC") - return RPCE_MC ; - // default - return RPCE_ML ; -} diff --git a/AuxTools.h b/AuxTools.h index b54ba2f..762f3d0 100644 --- a/AuxTools.h +++ b/AuxTools.h @@ -21,24 +21,17 @@ class IGeomDB ; const std::string IdListToString( const INTVECTOR& vIds) ; // Tipo del file Nge const char* NgeTypeToString( int nNgeType) ; -int StringToNgeType( const std::string& sNgeType) ; // Tipo punto per creazione rette e archi const char* SepToString( int nSep) ; -int StringToSep( const std::string& sSep) ; // Flag per posizione di inserimento nel DB geometrico const char* InsToString( int nIns) ; -int StringToIns( const std::string& sIns) ; // Tipo riferimento in cui sono espressi i dati geometrici const char* RefTypeToString( int nRefType) ; -int StringToRefType( const std::string& sRefType) ; -// Indice equivalente a riferimento in cui restituire il dato geometrico -int StringToRefId( const std::string& sRefId) ; // Posizione inserimento testo const char* ETxtInsPosToString( int nETxtInsPos) ; -int ETxtInsPosToString( const std::string& sETxtInsPos) ; +// tipo di offset di curva +const char* OffsTypeToString( int nOffsType) ; // Flag per posizione corner rispetto a grezzo const char* RawPartCornerPosToString( int nFlag) ; -int StringToRawPartCornerPos( const std::string& sFlag) ; // Flag per posizione center rispetto a grezzo const char* RawPartCenterPosToString( int nFlag) ; -int StringToRawPartCenterPos( const std::string& sFlag) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 2101d35b2ca6f4c6e33c11f2f2e0b211d138f84d..eb013b21c52831a1cfc87170cf2746e2e19f8bdc 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&Qw%^&$rGEF|hS;uHR`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07yS5wg3PC delta 111 zcmX>WeJpyzFE&P_%^&$rGEF|hS;uHJ`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07g?Nt^fc4 diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index c7349fe..7304b1c 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -217,7 +217,6 @@ copy $(TargetPath) \EgtProg\Dll64 - @@ -251,7 +250,6 @@ copy $(TargetPath) \EgtProg\Dll64 - diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 91afdda..aafbb5d 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -57,9 +57,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -140,9 +137,6 @@ File di origine\API - - File di origine\LUA - File di origine\LUA diff --git a/LUA_Aux.cpp b/LUA_Aux.cpp deleted file mode 100644 index e9a104e..0000000 --- a/LUA_Aux.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//---------------------------------------------------------------------------- -// 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_Aux.h" -#include "AuxTools.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -bool -LuaGetRefType( lua_State* L, int nInd, int& nRefType) -{ - // se non c'è il tipo cercato, ritorno - string sRefType ; - if ( ! LuaGetParam( L, nInd, sRefType)) - return false ; - // interpreto il parametro - nRefType = StringToRefType( sRefType) ; - return true ; -} - -//---------------------------------------------------------------------------- -bool -LuaGetRefId( lua_State* L, int nInd, int& nRefId) -{ - // se parametro è numero intero - if ( LuaGetParam( L, nInd, nRefId)) - return true ; - // se parametro è stringa - string sFlag ; - if ( LuaGetParam( L, nInd, sFlag)) { - nRefId = StringToRefId( sFlag) ; - return true ; - } - // non trovato - return false ; -} diff --git a/LUA_Aux.h b/LUA_Aux.h deleted file mode 100644 index b7ce74e..0000000 --- a/LUA_Aux.h +++ /dev/null @@ -1,20 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_Aux.h Data : 21.03.15 Versione : 1.6c6 -// Contenuto : Dichiarazione funzioni ausiliarielocali per LUA. -// -// -// -// Modifiche : 21.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include "/EgtDev/Include/EgkLuaAux.h" - -//---------------------------------------------------------------------------- -bool LuaGetRefType( lua_State* L, int nInd, int& nRefType) ; -bool LuaGetRefId( lua_State* L, int nInd, int& nRefId) ; diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index cde67ee..4c52b3b 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -16,8 +16,8 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EgnStringUtils.h" using namespace std ; diff --git a/LUA_GdbCreate.cpp b/LUA_GdbCreate.cpp index d56c565..f1a5ac3 100644 --- a/LUA_GdbCreate.cpp +++ b/LUA_GdbCreate.cpp @@ -16,12 +16,12 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EGkExtText.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -30,15 +30,15 @@ using namespace std ; static int LuaCreateGroup( lua_State* L) { - // 1 o 2 o 3 parametri : ParentId [, Frame] [, sRefType] + // 1 o 2 o 3 parametri : ParentId [, Frame] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Frame3d frFrame ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 2, frFrame)) - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; else - LuaGetRefType( L, 2, nRefType) ; + LuaGetParam( L, 2, nRefType) ; LuaClearStack( L) ; // creo il gruppo int nId = EgtCreateGroup( nParentId, frFrame.Orig().v, @@ -55,13 +55,13 @@ LuaCreateGroup( lua_State* L) static int LuaCreateGeoPoint( lua_State* L) { - // 2 o 3 parametri : ParentId, PtP [, sRefType] + // 2 o 3 parametri : ParentId, PtP [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; LuaCheckParam( L, 2, ptP) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo il punto int nId = EgtCreateGeoPoint( nParentId, ptP.v, nRefType) ; @@ -77,7 +77,7 @@ LuaCreateGeoPoint( lua_State* L) static int LuaCreateGeoVector( lua_State* L) { - // 2 o 3 o 4 parametri : ParentId, VtV [, PtB] [, sRefType] + // 2 o 3 o 4 parametri : ParentId, VtV [, PtB] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Vector3d vtV ; @@ -85,9 +85,9 @@ LuaCreateGeoVector( lua_State* L) Point3d ptB ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 3, ptB)) - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; else - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo il vettore int nId = EgtCreateGeoVector( nParentId, vtV.v, ptB.v, nRefType) ; @@ -103,13 +103,13 @@ LuaCreateGeoVector( lua_State* L) static int LuaCreateGeoFrame( lua_State* L) { - // 2 o 3 parametri : ParentId, Frame [, sRefType] + // 2 o 3 parametri : ParentId, Frame [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Frame3d frFrame ; LuaCheckParam( L, 2, frFrame) ; int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo il gruppo int nId = EgtCreateGeoFrame( nParentId, frFrame.Orig().v, @@ -126,7 +126,7 @@ LuaCreateGeoFrame( lua_State* L) static int LuaCreateText( lua_State* L) { - // 5 o 6 parametri : ParentId, ptP, AngRotDeg, Text, H [, sRefType] + // 5 o 6 parametri : ParentId, ptP, AngRotDeg, Text, H [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -138,7 +138,7 @@ LuaCreateText( lua_State* L) double dH ; LuaCheckParam( L, 5, dH) ; int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo il testo int nId = EgtCreateText( nParentId, ptP, dAngRotDeg, sText, dH, nRefType) ; @@ -154,7 +154,7 @@ LuaCreateText( lua_State* L) static int LuaCreateTextEx( lua_State* L) { - // 8 o 9 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H [, sRefType] + // 8 o 9 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -174,7 +174,7 @@ LuaCreateTextEx( lua_State* L) double dH ; LuaCheckParam( L, 8, dH) ; int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 9, nRefType) ; + LuaGetParam( L, 9, nRefType) ; LuaClearStack( L) ; // creo il testo in modo esteso int nId = EgtCreateTextEx( nParentId, ptP, vtN, vtD, sText, sFont, bItalic, dH, nRefType) ; @@ -190,7 +190,7 @@ LuaCreateTextEx( lua_State* L) static int LuaCreateTextAdv( lua_State* L) { - // 12 o 13 parametri : ParentId, ptP, vtN, vtD, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos [, sRefType] + // 12 o 13 parametri : ParentId, ptP, vtN, vtD, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -210,16 +210,15 @@ LuaCreateTextAdv( lua_State* L) ToUpper( sItalic) ; bool bItalic = ( sItalic == "I") ; double dH ; - LuaCheckParam( L, 9, dH) ; + LuaCheckParam( L, 9, dH) double dRat ; - LuaCheckParam( L, 10, dRat) ; + LuaCheckParam( L, 10, dRat) double dAddAdv ; - LuaCheckParam( L, 11, dAddAdv) ; - string sInsPos ; - LuaCheckParam( L, 12, sInsPos) ; - int nInsPos = ETxtInsPosToString( sInsPos) ; + LuaCheckParam( L, 11, dAddAdv) + int nInsPos ; + LuaCheckParam( L, 12, nInsPos) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 13, nRefType) ; + LuaGetParam( L, 13, nRefType) ; LuaClearStack( L) ; // creo il testo in modo avanzato int nId = EgtCreateTextAdv( nParentId, ptP, vtN, vtD, diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 45fb779..7cafa3d 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -16,12 +16,12 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkPolyLine.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkPolyLine.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -29,7 +29,7 @@ using namespace std ; static int LuaCreateCurveLine( lua_State* L) { - // 3 o 4 parametri : ParentId, PtIni, PtFin [, sRefType] + // 3 o 4 parametri : ParentId, PtIni, PtFin [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -37,7 +37,7 @@ LuaCreateCurveLine( lua_State* L) Point3d ptFin ; LuaCheckParam( L, 3, ptFin) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = EgtCreateCurveLine( nParentId, ptIni.v, ptFin.v, nRefType) ; @@ -53,28 +53,28 @@ LuaCreateCurveLine( lua_State* L) static int LuaCreateCurveLineEx( lua_State* L) { - // 7 o 8 parametri : ParentId, PtIni, sSepI, nIdI, PtFin, sSEpF, nIdF [, sRefType] + // 7 o 8 parametri : ParentId, PtIni, nSepI, nIdI, PtFin, nSepF, nIdF [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) - string sSepI ; - LuaCheckParam( L, 3, sSepI) + int nSepI ; + LuaCheckParam( L, 3, nSepI) int nIdI ; LuaCheckParam( L, 4, nIdI) Point3d ptFin ; LuaCheckParam( L, 5, ptFin) - string sSepF ; - LuaCheckParam( L, 6, sSepF) + int nSepF ; + LuaCheckParam( L, 6, nSepF) int nIdF ; LuaCheckParam( L, 7, nIdF) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 8, nRefType) ; + LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = EgtCreateCurveLineEx( nParentId, - ptIni.v, StringToSep( sSepI), nIdI, - ptFin.v, StringToSep( sSepF), nIdF, nRefType) ; + ptIni.v, nSepI, nIdI, + ptFin.v, nSepF, nIdF, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -87,7 +87,7 @@ LuaCreateCurveLineEx( lua_State* L) static int LuaCreateCurveLinePVL( lua_State* L) { - // 4 o 5 parametri : ParentId, PtIni, VtDir, dLen [, sRefType] + // 4 o 5 parametri : ParentId, PtIni, VtDir, dLen [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -97,7 +97,7 @@ LuaCreateCurveLinePVL( lua_State* L) double dLen ; LuaCheckParam( L, 4, dLen) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = EgtCreateCurveLinePVL( nParentId, ptIni.v, vtDir.v, dLen, nRefType) ; @@ -113,7 +113,7 @@ LuaCreateCurveLinePVL( lua_State* L) static int LuaCreateCurveLineMinPointCurve( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, PtIni, CrvId [, NearPar] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, PtIni, CrvId [, NearPar] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -123,9 +123,9 @@ LuaCreateCurveLineMinPointCurve( lua_State* L) double dNearPar = 0 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, dNearPar)) - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; else - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta int nId = EgtCreateCurveLineMinPointCurve( nParentId, ptIni.v, nCrvId, dNearPar, nRefType) ; @@ -141,7 +141,7 @@ LuaCreateCurveLineMinPointCurve( lua_State* L) static int LuaCreateCurveCircle( lua_State* L) { - // 4 o 5 parametri : ParentId, PtCen, VtN, Rad [, sRefType] + // 4 o 5 parametri : ParentId, PtCen, VtN, Rad [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -151,7 +151,7 @@ LuaCreateCurveCircle( lua_State* L) double dRad ; LuaCheckParam( L, 4, dRad) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveCircle( nParentId, ptCen.v, vtN.v, dRad, nRefType) ; @@ -167,7 +167,7 @@ LuaCreateCurveCircle( lua_State* L) static int LuaCreateCurveCircleCPN( lua_State* L) { - // 4 o 5 parametri : ParentId, PtCen, PtOn, VtN [, sRefType] + // 4 o 5 parametri : ParentId, PtCen, PtOn, VtN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -177,7 +177,7 @@ LuaCreateCurveCircleCPN( lua_State* L) Vector3d vtN ; LuaCheckParam( L, 4, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveCircleCPN( nParentId, ptCen.v, ptOn.v, vtN.v, nRefType) ; @@ -193,24 +193,24 @@ LuaCreateCurveCircleCPN( lua_State* L) static int LuaCreateCurveCircleCPNEx( lua_State* L) { - // 6 o 7 parametri : ParentId, PtCen, PtOn, sSepO, nIdO, VtN [, sRefType] + // 6 o 7 parametri : ParentId, PtCen, PtOn, nSepO, nIdO, VtN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptOn ; LuaCheckParam( L, 3, ptOn) - string sSepO ; - LuaCheckParam( L, 4, sSepO) + int nSepO ; + LuaCheckParam( L, 4, nSepO) int nIdO ; LuaCheckParam( L, 5, nIdO) Vector3d vtN ; LuaCheckParam( L, 6, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 7, nRefType) ; + LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveCircleCPNEx( nParentId, ptCen.v, ptOn.v, StringToSep( sSepO), nIdO, vtN.v, nRefType) ; + int nId = EgtCreateCurveCircleCPNEx( nParentId, ptCen.v, ptOn.v, nSepO, nIdO, vtN.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -223,7 +223,7 @@ LuaCreateCurveCircleCPNEx( lua_State* L) static int LuaCreateCurveCircle3P( lua_State* L) { - // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, sRefType] + // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; @@ -233,7 +233,7 @@ LuaCreateCurveCircle3P( lua_State* L) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveCircle3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; @@ -249,7 +249,7 @@ LuaCreateCurveCircle3P( lua_State* L) static int LuaCreateCurveArc( lua_State* L) { - // 7 o 8 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN [, sRefType] + // 7 o 8 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -265,7 +265,7 @@ LuaCreateCurveArc( lua_State* L) double dDeltaN ; LuaCheckParam( L, 7, dDeltaN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 8, nRefType) ; + LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveArc( nParentId, ptCen.v, vtN.v, dRad, vtS.v, dAngCenDeg, dDeltaN, nRefType) ; @@ -281,7 +281,7 @@ LuaCreateCurveArc( lua_State* L) static int LuaCreateCurveArcC2PN( lua_State* L) { - // 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, sRefType] + // 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -293,7 +293,7 @@ LuaCreateCurveArcC2PN( lua_State* L) Vector3d vtNorm ; LuaCheckParam( L, 5, vtNorm) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveArcC2PN( nParentId, ptCen.v, ptStart.v, ptNearEnd.v, vtNorm.v, nRefType) ; @@ -309,15 +309,15 @@ LuaCreateCurveArcC2PN( lua_State* L) static int LuaCreateCurveArcC2PNEx( lua_State* L) { - // 7 o 8 parametri : ParentId, PtCen, PtStart, sSepS, nIdS, PtNearEnd, VtNorm [, sRefType] + // 7 o 8 parametri : ParentId, PtCen, PtStart, nSepS, nIdS, PtNearEnd, VtNorm [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; LuaCheckParam( L, 2, ptCen) Point3d ptStart ; LuaCheckParam( L, 3, ptStart) - string sSepS ; - LuaCheckParam( L, 4, sSepS) + int nSepS ; + LuaCheckParam( L, 4, nSepS) int nIdS ; LuaCheckParam( L, 5, nIdS) Point3d ptNearEnd ; @@ -325,10 +325,10 @@ LuaCreateCurveArcC2PNEx( lua_State* L) Vector3d vtNorm ; LuaCheckParam( L, 7, vtNorm) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 8, nRefType) ; + LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArcC2PNEx( nParentId, ptCen.v, ptStart.v, StringToSep( sSepS), nIdS, ptNearEnd.v, vtNorm.v, nRefType) ; + int nId = EgtCreateCurveArcC2PNEx( nParentId, ptCen.v, ptStart.v, nSepS, nIdS, ptNearEnd.v, vtNorm.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -341,7 +341,7 @@ LuaCreateCurveArcC2PNEx( lua_State* L) static int LuaCreateCurveArc3P( lua_State* L) { - // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, sRefType] + // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; @@ -351,7 +351,7 @@ LuaCreateCurveArc3P( lua_State* L) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveArc3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; @@ -367,7 +367,7 @@ LuaCreateCurveArc3P( lua_State* L) static int LuaCreateCurveArc2PVN( lua_State* L) { - // 5 o 6 parametri : ParentId, PtStart, PtEnd, VtDirS, VtNorm [, sRefType] + // 5 o 6 parametri : ParentId, PtStart, PtEnd, VtDirS, VtNorm [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; @@ -379,7 +379,7 @@ LuaCreateCurveArc2PVN( lua_State* L) Vector3d vtNorm ; LuaCheckParam( L, 5, vtNorm) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveArc2PVN( nParentId, ptStart.v, ptEnd.v, vtDirS.v, vtNorm.v, nRefType) ; @@ -395,15 +395,15 @@ LuaCreateCurveArc2PVN( lua_State* L) static int LuaCreateCurveArc2PVNEx( lua_State* L) { - // 7 o 8 parametri : ParentId, PtStart, PtEnd, sSepE, nIdE, VtDirS, VtNorm [, sRefType] + // 7 o 8 parametri : ParentId, PtStart, PtEnd, nSepE, nIdE, VtDirS, VtNorm [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) Point3d ptEnd ; LuaCheckParam( L, 3, ptEnd) - string sSepE ; - LuaCheckParam( L, 4, sSepE) + int nSepE ; + LuaCheckParam( L, 4, nSepE) int nIdE ; LuaCheckParam( L, 5, nIdE) Vector3d vtDirS ; @@ -411,10 +411,10 @@ LuaCreateCurveArc2PVNEx( lua_State* L) Vector3d vtNorm ; LuaCheckParam( L, 7, vtNorm) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 8, nRefType) ; + LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArc2PVNEx( nParentId, ptStart.v, ptEnd.v, StringToSep( sSepE), nIdE, + int nId = EgtCreateCurveArc2PVNEx( nParentId, ptStart.v, ptEnd.v, nSepE, nIdE, vtDirS.v, vtNorm.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) @@ -428,7 +428,7 @@ LuaCreateCurveArc2PVNEx( lua_State* L) static int LuaCreateCurveFillet( lua_State* L) { - // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dRad, bTrim [, sRefType] + // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dRad, bTrim [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrv1 ; @@ -446,7 +446,7 @@ LuaCreateCurveFillet( lua_State* L) bool bTrim ; LuaCheckParam( L, 8, bTrim) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 9, nRefType) ; + LuaGetParam( L, 9, nRefType) ; LuaClearStack( L) ; // creo l'arco di fillet int nId = EgtCreateCurveFillet( nParentId, nCrv1, ptNear1.v, nCrv2, ptNear2.v, @@ -463,7 +463,7 @@ LuaCreateCurveFillet( lua_State* L) static int LuaCreateCurveChamfer( lua_State* L) { - // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dDist, bTrim [, sRefType] + // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dDist, bTrim [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrv1 ; @@ -481,7 +481,7 @@ LuaCreateCurveChamfer( lua_State* L) bool bTrim ; LuaCheckParam( L, 8, bTrim) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 9, nRefType) ; + LuaGetParam( L, 9, nRefType) ; LuaClearStack( L) ; // creo l'arco di fillet int nId = EgtCreateCurveChamfer( nParentId, nCrv1, ptNear1.v, nCrv2, ptNear2.v, @@ -498,7 +498,7 @@ LuaCreateCurveChamfer( lua_State* L) static int LuaCreateCurveBezier( lua_State* L) { - // 3 o 4 parametri : ParentId, Degree, CtrlPnts [, sRefType] + // 3 o 4 parametri : ParentId, Degree, CtrlPnts [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nDegree ; @@ -506,7 +506,7 @@ LuaCreateCurveBezier( lua_State* L) PNTVECTOR vPnt ; LuaCheckParam( L, 3, vPnt) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva int nId = EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; @@ -522,7 +522,7 @@ LuaCreateCurveBezier( lua_State* L) static int LuaCreateCurveBezierRational( lua_State* L) { - // 3 o 4 parametri : ParentId, Degree, CtrlPntWs [, sRefType] + // 3 o 4 parametri : ParentId, Degree, CtrlPntWs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nDegree ; @@ -530,7 +530,7 @@ LuaCreateCurveBezierRational( lua_State* L) PNTUVECTOR vPntW ; LuaCheckParam( L, 3, vPntW) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva int nId = EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; @@ -552,8 +552,7 @@ LuaCreateCurveBezierFromArc( lua_State* L) int nArcId ; LuaCheckParam( L, 2, nArcId) bool bErase = true ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bErase) ; + LuaGetParam( L, 3, bErase) ; LuaClearStack( L) ; // creo la curva int nId = EgtCreateCurveBezierFromArc( nParentId, nArcId, bErase) ; @@ -575,8 +574,7 @@ LuaCreateCurveCompo( lua_State* L) INTVECTOR vIds ; LuaCheckParam( L, 2, vIds) bool bErase = true ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bErase) ; + LuaGetParam( L, 3, bErase) ; LuaClearStack( L) ; // creo la curva composita int nId = EgtCreateCurveCompo( nParentId, vIds, bErase) ; @@ -592,7 +590,7 @@ LuaCreateCurveCompo( lua_State* L) static int LuaCreateCurveCompoByChain( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, nIds, PtNear [, Erase] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, nIds, PtNear [, Erase] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vIds ; @@ -602,9 +600,9 @@ LuaCreateCurveCompoByChain( lua_State* L) bool bErase = true ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, bErase)) - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; else - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva composita int nCount = 0 ; @@ -622,13 +620,13 @@ LuaCreateCurveCompoByChain( lua_State* L) static int LuaCreateCurveCompoFromPoints( lua_State* L) { - // 2 o 3 parametri : ParentId, ptPs [, sRefType] + // 2 o 3 parametri : ParentId, ptPs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTVECTOR vPnt ; LuaCheckParam( L, 2, vPnt) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; PolyLine PL ; // creo una polilinea a partire dai punti @@ -648,13 +646,13 @@ LuaCreateCurveCompoFromPoints( lua_State* L) static int LuaCreateCurveCompoFromPointBulges( lua_State* L) { - // 2 o 3 parametri : ParentId, ptPBs [, sRefType] + // 2 o 3 parametri : ParentId, ptPBs [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) PNTUVECTOR vPntB ; LuaCheckParam( L, 2, vPntB) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo un poliarco a partire dai punti con bulge PolyArc PA ; @@ -674,20 +672,16 @@ LuaCreateCurveCompoFromPointBulges( lua_State* L) static int LuaCreateCurveCompoByApprox( lua_State* L) { - // 3 o 4 parametri : ParentId, nSouId, sType [, dLinTol] + // 3 o 4 parametri : ParentId, nSouId, nArcsVsLines [, dLinTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nSouId ; LuaCheckParam( L, 2, nSouId) - bool bArcsVsLines = true ; - string sTemp ; - LuaCheckParam( L, 3, sTemp) - ToUpper( sTemp) ; - if ( sTemp == "LINES") - bArcsVsLines = false ; + int nTemp ; + LuaCheckParam( L, 3, nTemp) + bool bArcsVsLines = ( nTemp != 0) ; double dLinTol = 0.01 ; - if ( lua_gettop( L) >= 4) - LuaCheckParam( L, 4, dLinTol) + LuaGetParam( L, 4, dLinTol) ; LuaClearStack( L) ; // creo la curva composita int nId = EgtCreateCurveCompoByApprox( nParentId, nSouId, bArcsVsLines, dLinTol) ; @@ -703,7 +697,7 @@ LuaCreateCurveCompoByApprox( lua_State* L) static int LuaCreateRectangle3P( lua_State* L) { - // 4 o 5 parametri : ParentId, PtIni, PtCross, PtDir [, sRefType] + // 4 o 5 parametri : ParentId, PtIni, PtCross, PtDir [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -713,7 +707,7 @@ LuaCreateRectangle3P( lua_State* L) Point3d ptDir ; LuaCheckParam( L, 4, ptDir) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = EgtCreateRectangle3P( nParentId, ptIni.v, ptCross.v, ptDir.v, nRefType) ; @@ -729,7 +723,7 @@ LuaCreateRectangle3P( lua_State* L) static int LuaCreatePolygonFromRadius( lua_State* L) { - // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtCorn, VtN [, sRefType] + // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtCorn, VtN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; @@ -741,7 +735,7 @@ LuaCreatePolygonFromRadius( lua_State* L) Vector3d vtN ; LuaCheckParam( L, 5, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = EgtCreatePolygonFromRadius( nParentId, nNumSides, PtCen.v, PtCorn.v, vtN.v, nRefType) ; @@ -757,7 +751,7 @@ LuaCreatePolygonFromRadius( lua_State* L) static int LuaCreatePolygonFromApothem( lua_State* L) { - // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtMid, VtN [, sRefType] + // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtMid, VtN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; @@ -769,7 +763,7 @@ LuaCreatePolygonFromApothem( lua_State* L) Vector3d vtN ; LuaCheckParam( L, 5, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = EgtCreatePolygonFromApothem( nParentId, nNumSides, PtCen.v, PtMid.v, vtN.v, nRefType) ; @@ -785,7 +779,7 @@ LuaCreatePolygonFromApothem( lua_State* L) static int LuaCreatePolygonFromSide( lua_State* L) { - // 5 o 6 parametri : ParentId, nNumSides, PtIni, PtFin, VtN [, sRefType] + // 5 o 6 parametri : ParentId, nNumSides, PtIni, PtFin, VtN [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; @@ -797,7 +791,7 @@ LuaCreatePolygonFromSide( lua_State* L) Vector3d vtN ; LuaCheckParam( L, 5, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo il poligono int nId = EgtCreatePolygonFromSide( nParentId, nNumSides, ptIni.v, ptFin.v, vtN.v, nRefType) ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 05e16f6..da299be 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -16,11 +16,11 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkPolyLine.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGkPolyLine.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -31,13 +31,13 @@ static const double LIN_TOL_DEF = 0.05 ; static int LuaCreateSurfTmBBox( lua_State* L) { - // 2 o 3 parametri : ParentId, BBox3d [, sRefType] + // 2 o 3 parametri : ParentId, BBox3d [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) BBox3d b3Box ; LuaCheckParam( L, 2, b3Box) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // creo STM bounding box int nId = EgtCreateSurfTmBBox( nParentId, b3Box, nRefType) ; @@ -53,7 +53,7 @@ LuaCreateSurfTmBBox( lua_State* L) static int LuaCreateSurfTmBox( lua_State* L) { - // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, sRefType] + // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -65,7 +65,7 @@ LuaCreateSurfTmBox( lua_State* L) double dHeight ; LuaCheckParam( L, 5, dHeight) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM parallelepipedo int nId = EgtCreateSurfTmBox( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ; @@ -81,7 +81,7 @@ LuaCreateSurfTmBox( lua_State* L) static int LuaCreateSurfTmPyramid( lua_State* L) { - // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, sRefType] + // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -93,7 +93,7 @@ LuaCreateSurfTmPyramid( lua_State* L) double dHeight ; LuaCheckParam( L, 5, dHeight) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM cilindro int nId = EgtCreateSurfTmPyramid( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ; @@ -109,7 +109,7 @@ LuaCreateSurfTmPyramid( lua_State* L) static int LuaCreateSurfTmCylinder( lua_State* L) { - // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, sRefType] + // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptOrig ; @@ -123,9 +123,9 @@ LuaCreateSurfTmCylinder( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 6, dLinTol)) - LuaGetRefType( L, 7, nRefType) ; + LuaGetParam( L, 7, nRefType) ; else - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM cilindro int nId = EgtCreateSurfTmCylinder( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ; @@ -141,7 +141,7 @@ LuaCreateSurfTmCylinder( lua_State* L) static int LuaCreateSurfTmCone( lua_State* L) { - // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, sRefType] + // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptOrig ; @@ -155,9 +155,9 @@ LuaCreateSurfTmCone( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 6, dLinTol)) - LuaGetRefType( L, 7, nRefType) ; + LuaGetParam( L, 7, nRefType) ; else - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM cilindro int nId = EgtCreateSurfTmCone( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ; @@ -173,7 +173,7 @@ LuaCreateSurfTmCone( lua_State* L) static int LuaCreateSurfTmSphere( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, PtOrig, dRad [, dTol] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, PtOrig, dRad [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptOrig ; @@ -183,9 +183,9 @@ LuaCreateSurfTmSphere( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, dLinTol)) - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; else - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo STM cilindro int nId = EgtCreateSurfTmSphere( nParentId, ptOrig.v, dRad, dLinTol, nRefType) ; @@ -247,7 +247,7 @@ LuaCreateSurfTmByRegion( lua_State* L) static int LuaCreateSurfTmByExtrusion( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vCrvIds ; @@ -257,9 +257,9 @@ LuaCreateSurfTmByExtrusion( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, dLinTol)) - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; else - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi int nId = EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, @@ -276,7 +276,7 @@ LuaCreateSurfTmByExtrusion( lua_State* L) static int LuaCreateSurfTmByRegionExtrusion( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vCrvIds ; @@ -286,9 +286,9 @@ LuaCreateSurfTmByRegionExtrusion( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 4, dLinTol)) - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; else - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // creo STM estrudendo uno o più percorsi, con aggiunta dei tappi int nId = EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; @@ -304,7 +304,7 @@ LuaCreateSurfTmByRegionExtrusion( lua_State* L) static int LuaCreateSurfTmByRevolve( lua_State* L) { - // 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, bCapEnds [, dTol] [, sRefType] + // 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, bCapEnds [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; @@ -318,9 +318,9 @@ LuaCreateSurfTmByRevolve( lua_State* L) double dLinTol = 0.1 ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 6, dLinTol)) - LuaGetRefType( L, 7, nRefType) ; + LuaGetParam( L, 7, nRefType) ; else - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTmByRevolve( nParentId, nCrvId, ptAx.v, vtAx.v, bCapEnds, dLinTol, nRefType) ; @@ -336,7 +336,7 @@ LuaCreateSurfTmByRevolve( lua_State* L) static int LuaCreateSurfTmByScrewing( lua_State* L) { - // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, sRefType] + // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; @@ -352,9 +352,9 @@ LuaCreateSurfTmByScrewing( lua_State* L) double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 7, dLinTol)) - LuaGetRefType( L, 8, nRefType) ; + LuaGetParam( L, 8, nRefType) ; else - LuaGetRefType( L, 7, nRefType) ; + LuaGetParam( L, 7, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano int nId = EgtCreateSurfTmByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol, nRefType) ; diff --git a/LUA_GdbModify.cpp b/LUA_GdbModify.cpp index dc13df0..4db3c55 100644 --- a/LUA_GdbModify.cpp +++ b/LUA_GdbModify.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -27,13 +27,13 @@ using namespace std ; static int LuaChangeGroupFrame( lua_State* L) { - // 2 o 3 parametri : Id, frNewRef [, sRefType] + // 2 o 3 parametri : Id, frNewRef [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Frame3d frNewRef ; LuaCheckParam( L, 2, frNewRef) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifica del riferimento bool bOk = ( EgtChangeGroupFrame( nId, frNewRef, nRefType) != FALSE) ; @@ -45,13 +45,13 @@ LuaChangeGroupFrame( lua_State* L) static int LuaChangeVectorBase( lua_State* L) { - // 2 o 3 parametri : Id, ptBase [, sRefType] + // 2 o 3 parametri : Id, ptBase [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Point3d ptBase ; LuaCheckParam( L, 2, ptBase) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifica del punto base bool bOk = ( EgtChangeVectorBase( nId, ptBase.v, nRefType) != FALSE) ; @@ -109,17 +109,11 @@ LuaFlipText( lua_State* L) static int LuaMirrorText( lua_State* L) { - // 1 o 2 parametri : Id [, sOnL] + // 1 o 2 parametri : Id [, bOnL] int nId ; LuaCheckParam( L, 1, nId) bool bOnL = true ; - if ( lua_gettop( L) >= 2) { - string sLorH ; - LuaCheckParam( L, 2, sLorH) ; - ToUpper( sLorH) ; - if ( sLorH == "H") - bOnL = false ; - } + LuaGetParam( L, 2, bOnL) ; LuaClearStack( L) ; // flip del testo bool bOk = ( EgtMirrorText( nId, bOnL) != FALSE) ; diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 396a1f5..4c40d45 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -16,11 +16,11 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EGkCurve.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -49,14 +49,7 @@ LuaOffsetCurve( lua_State* L) double dDist ; LuaCheckParam( L, 2, dDist) int nType = ICurve::OFF_FILLET ; - if ( lua_gettop( L) >= 3) { - string sType ; - LuaCheckParam( L, 3, sType) - if ( sType == "CHAMFER") - nType = ICurve::OFF_CHAMFER ; - else if ( sType == "EXTEND") - nType = ICurve::OFF_EXTEND ; - } + LuaGetParam( L, 3, nType) ; LuaClearStack( L) ; // offset della curva bool bOk = ( EgtOffsetCurve( nId, dDist, nType) != FALSE) ; @@ -68,13 +61,13 @@ LuaOffsetCurve( lua_State* L) static int LuaChangeClosedCurveStartPoint( lua_State* L) { - // 2 o 3 parametri : Id, NewStart [, sRefType] + // 2 o 3 parametri : Id, NewStart [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifico il punto iniziale bool bOk = ( EgtChangeClosedCurveStartPoint( nId, ptStart.v, nRefType) != FALSE) ; @@ -86,13 +79,13 @@ LuaChangeClosedCurveStartPoint( lua_State* L) static int LuaModifyCurveStartPoint( lua_State* L) { - // 2 o 3 parametri : Id, NewStart [, sRefType] + // 2 o 3 parametri : Id, NewStart [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Point3d ptStart ; LuaCheckParam( L, 2, ptStart) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifico il punto iniziale bool bOk = ( EgtModifyCurveStartPoint( nId, ptStart.v, nRefType) != FALSE) ; @@ -104,13 +97,13 @@ LuaModifyCurveStartPoint( lua_State* L) static int LuaModifyCurveEndPoint( lua_State* L) { - // 2 o 3 parametri : Id, NewEnd [, sRefType] + // 2 o 3 parametri : Id, NewEnd [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Point3d ptEnd ; LuaCheckParam( L, 2, ptEnd) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifico il punto finale bool bOk = ( EgtModifyCurveEndPoint( nId, ptEnd.v, nRefType) != FALSE) ; @@ -122,13 +115,13 @@ LuaModifyCurveEndPoint( lua_State* L) static int LuaModifyCurveExtrusion( lua_State* L) { - // 2 o 3 parametri : Id/s, vtExtr [, sRefType] + // 2 o 3 parametri : Id/s, vtExtr [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Vector3d vtExtr ; LuaCheckParam( L, 2, vtExtr) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // modifico il vettore estrusione bool bOk = EgtModifyCurveExtrusion( vId, vtExtr, nRefType) ; @@ -240,7 +233,7 @@ LuaTrimCurveStartEndAtParam( lua_State* L) static int LuaTrimExtendCurveByLen( lua_State* L) { - // 3 o 4 parametri : Id, dLen, ptNear [, sRefType] + // 3 o 4 parametri : Id, dLen, ptNear [, nRefType] int nId ; LuaCheckParam( L, 1, nId) double dLen ; @@ -248,7 +241,7 @@ LuaTrimExtendCurveByLen( lua_State* L) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // taglio o allungo la curva nell'estremo più vicino al punto bool bOk = ( EgtTrimExtendCurveByLen( nId, dLen, ptNear.v, nRefType) != FALSE) ; @@ -279,13 +272,13 @@ LuaSplitCurve( lua_State* L) static int LuaSplitCurveAtPoint( lua_State* L) { - // 2 o 3 parametri : Id, ptOn [, sRefType] + // 2 o 3 parametri : Id, ptOn [, nRefType] int nId ; LuaCheckParam( L, 1, nId) Point3d ptOn ; LuaCheckParam( L, 2, ptOn) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // divido la curva nel punto int nNewId = EgtSplitCurveAtPoint( nId, ptOn.v, nRefType) ; @@ -335,18 +328,14 @@ LuaExplodeCurveCompo( lua_State* L) static int LuaExplodeCurveBezier( lua_State* L) { - // 2 o 3 parametri : Id, bArcsVsLines [, dLinTol] + // 2 o 3 parametri : Id, nArcsVsLines [, dLinTol] int nId ; LuaCheckParam( L, 1, nId) - bool bArcsVsLines ; - string sTemp ; - LuaCheckParam( L, 2, sTemp) - ToUpper( sTemp) ; - if ( sTemp == "LINES") - bArcsVsLines = false ; + int nTemp ; + LuaCheckParam( L, 2, nTemp) + bool bArcsVsLines = ( nTemp != 0) ; double dLinTol = 0.01 ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, dLinTol) + LuaGetParam( L, 3, dLinTol) ; LuaClearStack( L) ; // esplosione della curva composita int nNewId = EgtExplodeCurveBezier( nId, bArcsVsLines, dLinTol) ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index 90a5af2..27072eb 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index 8985118..4a33b81 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -16,9 +16,9 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -26,18 +26,11 @@ using namespace std ; static int LuaSetLevel( lua_State* L) { - // 2 parametri : Id, Livello + // 2 parametri : nId, nLevel 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) ; + int nLevel ; + LuaCheckParam( L, 2, nLevel) // imposto lo stato bool bOk = ( EgtSetLevel( nId, nLevel) != FALSE) ; // restituisco il risultato @@ -49,7 +42,7 @@ LuaSetLevel( lua_State* L) static int LuaRevertLevel( lua_State* L) { - // 1 parametro : Id + // 1 parametro : nId int nId ; LuaCheckParam( L, 1, nId) LuaClearStack( L) ; @@ -64,14 +57,15 @@ LuaRevertLevel( lua_State* L) static int LuaGetLevel( lua_State* L) { - // 1 parametro : Id + // 1 parametro : nId int nId ; LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // recupero il livello int nLevel ; - if ( EgtGetLevel( nId, &nLevel) != FALSE) - // restituisco il risultato + bool bOk = ( EgtGetLevel( nId, &nLevel) != FALSE) ; + // restituisco il risultato + if ( bOk) LuaSetReturn( L, nLevel) ; else LuaSetReturn( L) ; @@ -82,14 +76,15 @@ LuaGetLevel( lua_State* L) static int LuaGetCalcLevel( lua_State* L) { - // 1 parametro : Id + // 1 parametro : nId int nId ; LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // recupero il livello int nLevel ; - if ( EgtGetCalcLevel( nId, &nLevel) != FALSE) - // restituisco il risultato + bool bOk = ( EgtGetCalcLevel( nId, &nLevel) != FALSE) ; + // restituisco il risultato + if ( bOk) LuaSetReturn( L, nLevel) ; else LuaSetReturn( L) ; @@ -100,17 +95,11 @@ LuaGetCalcLevel( lua_State* L) static int LuaSetMode( lua_State* L) { - // 2 parametri : Id, Mode + // 2 parametri : nId, nMode 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 ; + int nMode ; + LuaCheckParam( L, 2, nMode) LuaClearStack( L) ; // imposto il modo bool bOk = ( EgtSetMode( nId, nMode) != FALSE) ; @@ -174,17 +163,11 @@ LuaGetCalcMode( lua_State* L) static int LuaSetStatus( lua_State* L) { - // 2 parametri : Id, Stato + // 2 parametri : Id, nStatus INTVECTOR vId ; LuaCheckParam( L, 1, vId) - 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 ; + int nStatus ; + LuaCheckParam( L, 2, nStatus) LuaClearStack( L) ; // imposto lo stato bool bOk = EgtSetStatus( vId, nStatus) ; diff --git a/LUA_GdbObjSelection.cpp b/LUA_GdbObjSelection.cpp index 0b5e696..615c94a 100644 --- a/LUA_GdbObjSelection.cpp +++ b/LUA_GdbObjSelection.cpp @@ -16,9 +16,9 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 2ad2679..86b716e 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -29,8 +29,8 @@ static int LuaExistsObj( lua_State* L) { // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) + int nId = GDB_ID_NULL ; + LuaGetParam( L, 1, nId) ; LuaClearStack( L) ; // verifico esistenza oggetto bool bOk = ( EgtExistsObj( nId) != FALSE) ; @@ -39,6 +39,21 @@ LuaExistsObj( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetType( lua_State* L) +{ + // 1 parametro : Id + int nId = GDB_ID_NULL ; + LuaGetParam( L, 1, nId) ; + LuaClearStack( L) ; + // recupero tipo dell'oggetto + int nType = EgtGetType( nId) ; + // restituisco il risultato + LuaSetReturn( L, nType) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaGetGroupObjs( lua_State* L) @@ -206,6 +221,78 @@ LuaGetPrevName( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetFirstGroupInGroup( lua_State* L) +{ + // 1 parametro : GroupId + int nGroupId ; + LuaCheckParam( L, 1, nGroupId) + LuaClearStack( L) ; + // recupero il primo oggetto gruppo del gruppo + int nId = EgtGetFirstGroupInGroup( nGroupId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextGroup( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il prossimo oggetto gruppo dello stesso gruppo + int nNewId = EgtGetNextGroup( nId) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetReturn( L, nNewId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetLastGroupInGroup( lua_State* L) +{ + // 1 parametro : GroupId + int nGroupId ; + LuaCheckParam( L, 1, nGroupId) + LuaClearStack( L) ; + // recupero l'ultimo oggetto gruppo del gruppo + int nId = EgtGetLastGroupInGroup( nGroupId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetPrevGroup( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il precedenteo oggetto gruppo dello stesso gruppo + int nNewId = EgtGetPrevGroup( nId) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetReturn( L, nNewId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaGetBBox( lua_State* L) @@ -275,17 +362,13 @@ LuaGetBBoxRef( lua_State* L) static int LuaCopy( lua_State* L) { - // 2 o 3 parametri : SouId, RefId [, SonBeforeAfter] + // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] int nSouId ; LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) int nSonBeforeAfter = GDB_LAST_SON ; - if ( lua_gettop( L) >= 3) { - string sSonBeforeAfter ; - LuaCheckParam( L, 3, sSonBeforeAfter) ; - nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; - } + LuaGetParam( L, 3, nSonBeforeAfter) ; LuaClearStack( L) ; // eseguo la copia int nNewId = EgtCopy( nSouId, nRefId, nSonBeforeAfter) ; @@ -301,17 +384,13 @@ LuaCopy( lua_State* L) static int LuaCopyGlob( lua_State* L) { - // 2 o 3 parametri : SouId, RefId [, SonBeforeAfter] + // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] int nSouId ; LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) int nSonBeforeAfter = GDB_LAST_SON ; - if ( lua_gettop( L) >= 3) { - string sSonBeforeAfter ; - LuaCheckParam( L, 3, sSonBeforeAfter) ; - nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; - } + LuaGetParam( L, 3, nSonBeforeAfter) ; LuaClearStack( L) ; // eseguo la copia int nNewId = EgtCopyGlob( nSouId, nRefId, nSonBeforeAfter) ; @@ -327,17 +406,13 @@ LuaCopyGlob( lua_State* L) static int LuaRelocate( lua_State* L) { - // 2 o 3 parametri : SouId, RefId [, SonBeforeAfter] + // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] int nSouId ; LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) int nSonBeforeAfter = GDB_LAST_SON ; - if ( lua_gettop( L) >= 3) { - string sSonBeforeAfter ; - LuaCheckParam( L, 3, sSonBeforeAfter) ; - nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; - } + LuaGetParam( L, 3, nSonBeforeAfter) ; LuaClearStack( L) ; // eseguo la rilocazione bool bOk = ( EgtRelocate( nSouId, nRefId, nSonBeforeAfter) != FALSE) ; @@ -356,11 +431,7 @@ LuaRelocateGlob( lua_State* L) int nRefId ; LuaCheckParam( L, 2, nRefId) int nSonBeforeAfter = GDB_LAST_SON ; - if ( lua_gettop( L) >= 3) { - string sSonBeforeAfter ; - LuaCheckParam( L, 3, sSonBeforeAfter) ; - nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; - } + LuaGetParam( L, 3, nSonBeforeAfter) ; LuaClearStack( L) ; // eseguo la rilocazione bool bOk = ( EgtRelocateGlob( nSouId, nRefId, nSonBeforeAfter) != FALSE) ; @@ -422,6 +493,7 @@ LuaInstallGdbObjects( void) { bool bOk = true ; bOk = bOk && LuaRegisterFunction( "EgtExistsObj", LuaExistsObj) ; + bOk = bOk && LuaRegisterFunction( "EgtGetType", LuaGetType) ; bOk = bOk && LuaRegisterFunction( "EgtGetGroupObjs", LuaGetGroupObjs) ; bOk = bOk && LuaRegisterFunction( "EgtGetFirstInGroup", LuaGetFirstInGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetNext", LuaGetNext) ; @@ -431,6 +503,10 @@ LuaInstallGdbObjects( void) bOk = bOk && LuaRegisterFunction( "EgtGetNextName", LuaGetNextName) ; bOk = bOk && LuaRegisterFunction( "EgtGetLastNameInGroup", LuaGetLastNameInGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetPrevName", LuaGetPrevName) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstGroupInGroup", LuaGetFirstGroupInGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextGroup", LuaGetNextGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetLastGroupInGroup", LuaGetLastGroupInGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetPrevGroup", LuaGetPrevGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetBBox", LuaGetBBox) ; bOk = bOk && LuaRegisterFunction( "EgtGetBBoxGlob", LuaGetBBoxGlob) ; bOk = bOk && LuaRegisterFunction( "EgtGetBBoxRef", LuaGetBBoxRef) ; diff --git a/LUA_GdbPartLayers.cpp b/LUA_GdbPartLayers.cpp index 0a735ca..be740a2 100644 --- a/LUA_GdbPartLayers.cpp +++ b/LUA_GdbPartLayers.cpp @@ -16,9 +16,9 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -80,59 +80,94 @@ LuaResetCurrPartLayer( lua_State* L) //------------------------------------------------------------------------------- static int -LuaGetFirstVisiblePart( lua_State* L) +LuaGetPartNbr( lua_State* L) { - // nessun parametro + // nessuno o 1 parametro : [bOnlyVisible] + bool bOnlyVisible = false ; + LuaGetParam( L, 1, bOnlyVisible) ; LuaClearStack( L) ; - // cerco primo pezzo e layer validi per essere dichiarati correnti - int nId = EgtGetFirstVisiblePart() ; + // recupero numero pezzi + int nNbr = EgtGetPartNbr( bOnlyVisible) ; // restituisco il risultato - LuaSetReturn( L, nId) ; + LuaSetReturn( L, nNbr) ; return 1 ; } //------------------------------------------------------------------------------- static int -LuaGetNextVisiblePart( lua_State* L) +LuaGetFirstPart( lua_State* L) { - // 1 parametro : nPartId + // nessuno o 1 parametro : [bOnlyVisible] + bool bOnlyVisible = false ; + LuaGetParam( L, 1, bOnlyVisible) ; + LuaClearStack( L) ; + // cerco primo pezzo + int nId = EgtGetFirstPart( bOnlyVisible) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextPart( lua_State* L) +{ + // 1 o 2 parametri : nPartId [, bOnlyVisible] int nPartId ; LuaCheckParam( L, 1, nPartId) + bool bOnlyVisible = false ; + LuaGetParam( L, 2, bOnlyVisible) ; LuaClearStack( L) ; - // cerco primo pezzo e layer validi per essere dichiarati correnti - int nId = EgtGetNextVisiblePart( nPartId) ; + // cerco pezzo successivo + int nId = EgtGetNextPart( nPartId, bOnlyVisible) ; // restituisco il risultato - LuaSetReturn( L, nId) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int -LuaGetFirstVisibleLayer( lua_State* L) +LuaGetFirstLayer( lua_State* L) { - // 1 parametro : nPartId + // 1 o 2 parametri : nPartId [, bOnlyVisible] int nPartId ; LuaCheckParam( L, 1, nPartId) + bool bOnlyVisible = false ; + LuaGetParam( L, 2, bOnlyVisible) ; LuaClearStack( L) ; - // cerco il primo layer visibile del pezzo - int nId = EgtGetFirstVisibleLayer( nPartId) ; + // cerco il primo layer del pezzo + int nId = EgtGetFirstLayer( nPartId, bOnlyVisible) ; // restituisco il risultato - LuaSetReturn( L, nId) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; return 1 ; } //------------------------------------------------------------------------------- static int -LuaGetNextVisibleLayer( lua_State* L) +LuaGetNextLayer( lua_State* L) { - // 1 parametro : nLayerId + // 1 o 2 parametri : nLayerId [, bOnlyVisible] int nLayerId ; LuaCheckParam( L, 1, nLayerId) + bool bOnlyVisible = false ; + LuaGetParam( L, 2, bOnlyVisible) ; LuaClearStack( L) ; - // cerco il prossimo layer visibile (ovviamente dello stesso pezzo) - int nId = EgtGetNextVisibleLayer( nLayerId) ; + // cerco il prossimo layer (ovviamente dello stesso pezzo) + int nId = EgtGetNextLayer( nLayerId, bOnlyVisible) ; // restituisco il risultato - LuaSetReturn( L, nId) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; return 1 ; } @@ -222,10 +257,11 @@ LuaInstallGdbPartLayer( void) bOk = bOk && LuaRegisterFunction( "EgtGetCurrLayer", LuaGetCurrLayer) ; bOk = bOk && LuaRegisterFunction( "EgtSetCurrPartLayer", LuaSetCurrPartLayer) ; bOk = bOk && LuaRegisterFunction( "EgtResetCurrPartLayer", LuaResetCurrPartLayer) ; - bOk = bOk && LuaRegisterFunction( "EgtGetFirstVisiblePart", LuaGetFirstVisiblePart) ; - bOk = bOk && LuaRegisterFunction( "EgtGetNextVisiblePart", LuaGetNextVisiblePart) ; - bOk = bOk && LuaRegisterFunction( "EgtGetFirstVisibleLayer", LuaGetFirstVisibleLayer) ; - bOk = bOk && LuaRegisterFunction( "EgtGetNextVisibleLayer", LuaGetNextVisibleLayer) ; + bOk = bOk && LuaRegisterFunction( "EgtGetPartNbr", LuaGetPartNbr) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstPart", LuaGetFirstPart) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextPart", LuaGetNextPart) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstLayer", LuaGetFirstLayer) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextLayer", LuaGetNextLayer) ; bOk = bOk && LuaRegisterFunction( "EgtSelectPartObjs", LuaSelectPartObjs) ; bOk = bOk && LuaRegisterFunction( "EgtDeselectPartObjs", LuaDeselectPartObjs) ; bOk = bOk && LuaRegisterFunction( "EgtSelectLayerObjs", LuaSelectLayerObjs) ; diff --git a/LUA_General.cpp b/LUA_General.cpp index b4d39b0..af1da78 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -16,7 +16,7 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" +#include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EGnFileUtils.h" diff --git a/LUA_GeoBase.cpp b/LUA_GeoBase.cpp index d590f8e..c717900 100644 --- a/LUA_GeoBase.cpp +++ b/LUA_GeoBase.cpp @@ -16,9 +16,9 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -351,6 +351,32 @@ LuaFrameLocToLoc( lua_State* L) } } +//------------------------------------------------------------------------------- +static int +LuaBBoxRotate( lua_State* L) +{ + // 4 parametri : bbox, PtAsse, VtAsse, AngRot in gradi + BBox3d b3Box ; + LuaCheckParam( L, 1, b3Box) + Point3d ptAx ; + LuaCheckParam( L, 2, ptAx) + Vector3d vtAx ; + LuaCheckParam( L, 3, vtAx) + double dAngRotDeg ; + LuaCheckParam( L, 4, dAngRotDeg) + LuaClearStack( L) ; + // eseguo la rotazione + if ( b3Box.Rotate( ptAx, vtAx, dAngRotDeg)) { + LuaSetReturn( L, true) ; + LuaSetReturn( L, b3Box) ; + return 2 ; + } + else { + LuaSetReturn( L, false) ; + return 1 ; + } +} + //------------------------------------------------------------------------------- static int LuaBBoxToGlob( lua_State* L) @@ -438,6 +464,7 @@ LuaInstallGeoBase( void) bOk = bOk && LuaRegisterFunction( "EgtFrameToGlob", LuaFrameToGlob) ; bOk = bOk && LuaRegisterFunction( "EgtFrameToLoc", LuaFrameToLoc) ; bOk = bOk && LuaRegisterFunction( "EgtFrameLocToLoc", LuaFrameLocToLoc) ; + bOk = bOk && LuaRegisterFunction( "EgtBBoxRotate", LuaBBoxRotate) ; bOk = bOk && LuaRegisterFunction( "EgtBBoxToGlob", LuaBBoxToGlob) ; bOk = bOk && LuaRegisterFunction( "EgtBBoxToLoc", LuaBBoxToLoc) ; bOk = bOk && LuaRegisterFunction( "EgtBBoxLocToLoc", LuaBBoxLocToLoc) ; diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index e46ef0c..96bda4a 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -16,9 +16,9 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -31,7 +31,7 @@ LuaStartPoint( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il punto iniziale dell'entità Point3d ptP ; @@ -50,7 +50,7 @@ LuaEndPoint( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il punto finale dell'entità Point3d ptP ; @@ -69,7 +69,7 @@ LuaMidPoint( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il punto centrale dell'entità Point3d ptP ; @@ -88,7 +88,7 @@ LuaCenterPoint( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il punto centrale dell'entità Point3d ptP ; @@ -107,7 +107,7 @@ LuaCentroid( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il centro geometrico dell'entità Point3d ptP ; @@ -128,7 +128,7 @@ LuaAtParamPoint( lua_State* L) double dU ; LuaCheckParam( L, 2, dU) int nRefId = nId ; - LuaGetRefId( L, 3, nRefId) ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero il punto in posizione parametrica U della curva Point3d ptP ; @@ -149,7 +149,7 @@ LuaNearPoint( lua_State* L) Point3d ptNear ; LuaCheckParam( L, 2, ptNear) int nRefId = nId ; - LuaGetRefId( L, 3, nRefId) ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero il punto di intersezione tra le curve più vicino al punto passato Point3d ptP ; @@ -172,7 +172,7 @@ LuaIntersectionPoint( lua_State* L) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) int nRefId = nId1 ; - LuaGetRefId( L, 4, nRefId) ; + LuaGetParam( L, 4, nRefId) ; LuaClearStack( L) ; // recupero il punto di intersezione tra le curve più vicino al punto passato Point3d ptP ; @@ -191,7 +191,7 @@ LuaStartVector( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il vettore tangente all'inizio della curva Vector3d vtV ; @@ -210,7 +210,7 @@ LuaEndVector( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il vettore tangente alla fine della curva Vector3d vtV ; @@ -229,7 +229,7 @@ LuaMidVector( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il vettore tangente nel punto medio della curva Vector3d vtV ; @@ -244,18 +244,15 @@ LuaMidVector( lua_State* L) static int LuaAtParamVector( lua_State* L) { - // 2, 3 o 4 parametri : Id, U, sSide [, nRefId] + // 2, 3 o 4 parametri : Id, U, nSide [, nRefId] int nId ; LuaCheckParam( L, 1, nId) double dU ; LuaCheckParam( L, 2, dU) - int nSide = + 1 ; - string sSide ; - LuaCheckParam( L, 3, sSide) ; - if ( sSide == "-") - nSide = - 1 ; + int nSide ; + LuaCheckParam( L, 3, nSide) ; int nRefId = nId ; - LuaGetRefId( L, 4, nRefId) ; + LuaGetParam( L, 4, nRefId) ; LuaClearStack( L) ; // recupero il punto in posizione parametrica U della curva Vector3d vtV ; @@ -274,7 +271,7 @@ LuaFrame( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il frame Frame3d frFrame ; @@ -310,7 +307,7 @@ LuaCurveExtrusion( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il versore Vector3d vtExtr ; @@ -346,7 +343,7 @@ LuaExtrusionByThickness( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il versore e lo spessore Vector3d vtExtr ; @@ -385,7 +382,7 @@ LuaCurveArcNormVersor( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il versore Vector3d vtNorm ; @@ -406,7 +403,7 @@ LuaCurveCompoCenter( lua_State* L) int nCrv ; LuaCheckParam( L, 2, nCrv) int nRefId = nId ; - LuaGetRefId( L, 3, nRefId) ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero il centro della curva semplice indicizzata Point3d ptCen ; @@ -443,7 +440,7 @@ LuaSurfTmFacetNearestEndPoint( lua_State* L) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) int nRefId = nId ; - LuaGetRefId( L, 4, nRefId) ; + LuaGetParam( L, 4, nRefId) ; LuaClearStack( L) ; // recupero il punto End più vicino della faccia della superficie trimesh Point3d ptEnd ; @@ -471,7 +468,7 @@ LuaSurfTmFacetNearestMidPoint( lua_State* L) Point3d ptNear ; LuaCheckParam( L, 3, ptNear) int nRefId = nId ; - LuaGetRefId( L, 4, nRefId) ; + LuaGetParam( L, 4, nRefId) ; LuaClearStack( L) ; // recupero il punto Mid più vicino della faccia della superficie trimesh Point3d ptMid ; @@ -497,7 +494,7 @@ LuaSurfTmFacetCenter( lua_State* L) int nFacet ; LuaCheckParam( L, 2, nFacet) int nRefId = nId ; - LuaGetRefId( L, 3, nRefId) ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero il centro della faccia della superficie trimesh Point3d ptCen ; @@ -523,7 +520,7 @@ LuaSurfTmFacetNormVersor( lua_State* L) int nFacet ; LuaCheckParam( L, 2, nFacet) int nRefId = nId ; - LuaGetRefId( L, 3, nRefId) ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero la normale della faccia della superficie trimesh Vector3d vtNorm ; @@ -542,7 +539,7 @@ LuaExtTextNormVersor( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; - LuaGetRefId( L, 2, nRefId) ; + LuaGetParam( L, 2, nRefId) ; LuaClearStack( L) ; // recupero il versore Vector3d vtNorm ; diff --git a/LUA_GeoTransform.cpp b/LUA_GeoTransform.cpp index f9d14e1..7919494 100644 --- a/LUA_GeoTransform.cpp +++ b/LUA_GeoTransform.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -27,13 +27,13 @@ using namespace std ; static int LuaMove( lua_State* L) { - // 2 o 3 parametri : Id/s, VtMove [, sRefType] + // 2 o 3 parametri : Id/s, VtMove [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Vector3d vtMove ; LuaCheckParam( L, 2, vtMove) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 3, nRefType) ; + LuaGetParam( L, 3, nRefType) ; LuaClearStack( L) ; // eseguo traslazione bool bOk = EgtMove( vId, vtMove, nRefType) ; @@ -46,7 +46,7 @@ LuaMove( lua_State* L) static int LuaRotate( lua_State* L) { - // 4 o 5 parametri : Id/s, PtAx, VtAx, dAngRotDeg [, sRefType] + // 4 o 5 parametri : Id/s, PtAx, VtAx, dAngRotDeg [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Point3d ptAx ; @@ -56,7 +56,7 @@ LuaRotate( lua_State* L) double dAngRotDeg ; LuaCheckParam( L, 4, dAngRotDeg) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 5, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // eseguo rotazione bool bOk = EgtRotate( vId, ptAx, vtAx, dAngRotDeg, nRefType) ; @@ -69,7 +69,7 @@ LuaRotate( lua_State* L) static int LuaScale( lua_State* L) { - // 5 o 6 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ [, sRefType] + // 5 o 6 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Frame3d frRef ; @@ -81,7 +81,7 @@ LuaScale( lua_State* L) double dCoeffZ ; LuaCheckParam( L, 5, dCoeffZ) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // eseguo scalatura bool bOk = EgtScale( vId, frRef, dCoeffX, dCoeffY, dCoeffZ, nRefType) ; @@ -94,7 +94,7 @@ LuaScale( lua_State* L) static int LuaMirror( lua_State* L) { - // 3 o 4 parametri : Id/s, PtOn, VtN [, sRefType] + // 3 o 4 parametri : Id/s, PtOn, VtN [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Point3d ptOn ; @@ -102,7 +102,7 @@ LuaMirror( lua_State* L) Vector3d vtN ; LuaCheckParam( L, 3, vtN) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 4, nRefType) ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // eseguo riflessione bool bOk = EgtMirror( vId, ptOn, vtN, nRefType) ; @@ -115,7 +115,7 @@ LuaMirror( lua_State* L) static int LuaShear( lua_State* L) { - // 5 o 6 parametri : Id, PtOn, VtN, VtDir, Coeff [, sRefType] + // 5 o 6 parametri : Id, PtOn, VtN, VtDir, Coeff [, nRefType] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Point3d ptOn ; @@ -127,7 +127,7 @@ LuaShear( lua_State* L) double dCoeff ; LuaCheckParam( L, 5, dCoeff) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // eseguo stiramento bool bOk = EgtShear( vId, ptOn, vtN, vtDir, dCoeff, nRefType) ; diff --git a/LUA_GeomDB.cpp b/LUA_GeomDB.cpp index 2df8470..d9a9428 100644 --- a/LUA_GeomDB.cpp +++ b/LUA_GeomDB.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -139,15 +139,11 @@ LuaInsertFile( lua_State* L) static int LuaSaveFile( lua_State* L) { - // 1 o 2 parametri : path del file [, flag("T","B","CT")] + // 1 o 2 parametri : path del file [, flag] string sFilePath ; LuaCheckParam( L, 1, sFilePath) int nFlag = GDB_SV_CMPTXT ; - if ( lua_gettop( L) >= 2) { - string sFlag ; - LuaCheckParam( L, 2, sFlag) ; - nFlag = StringToNgeType( sFlag) ; - } + LuaGetParam( L, 2, nFlag) ; LuaClearStack( L) ; // salvo il file bool bOk = EgtSaveFile( sFilePath, nFlag) ; diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 0faca18..d0b6976 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -16,10 +16,10 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; @@ -45,7 +45,10 @@ LuaGetFirstMachGroup( lua_State* L) // recupero l'identificativo della prima macchinata int nId = EgtGetFirstMachGroup() ; // restituisco il risultato - LuaSetReturn( L, nId) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; return 1 ; } @@ -60,7 +63,10 @@ LuaGetNextMachGroup( lua_State* L) // recupero l'identificativo della successiva macchinata int nNextId = EgtGetNextMachGroup( nId) ; // restituisco il risultato - LuaSetReturn( L, nNextId) ; + if ( nNextId != GDB_ID_NULL) + LuaSetReturn( L, nNextId) ; + else + LuaSetReturn( L) ; return 1 ; } @@ -177,6 +183,52 @@ LuaGetCurrMachGroup( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetRawPartNbr( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero il numero di grezzi nella macchinata corrente + int nCount = EgtGetRawPartNbr() ; + // restituisco il risultato + LuaSetReturn( L, nCount) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetFirstRawPart( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero identificativo primo grezzo nella macchinata corrente + int nId = EgtGetFirstRawPart() ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextRawPart( lua_State* L) +{ + // 1 parametro : nRawId + int nRawId ; + LuaCheckParam( L, 1, nRawId) + LuaClearStack( L) ; + // recupero identificativo successivo grezzo nella macchinata corrente + int nId = EgtGetNextRawPart( nRawId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} //------------------------------------------------------------------------------- static int LuaAddRawPart( lua_State* L) @@ -210,8 +262,8 @@ LuaAddRawPartWithPart( lua_State* L) // 4 parametri : nPartId, nCrvId, dOverMat, Color int nPartId ; LuaCheckParam( L, 1, nPartId) - int nCrvId ; - LuaCheckParamDef( L, 2, nCrvId, GDB_ID_NULL) + int nCrvId = GDB_ID_NULL ; + LuaGetParam( L, 2, nCrvId) ; double dOverMat ; LuaCheckParam( L, 3, dOverMat) Color cCol ; @@ -227,25 +279,6 @@ LuaAddRawPartWithPart( lua_State* L) return 1 ; } -//------------------------------------------------------------------------------- -static int -LuaAddPartToRawPart( lua_State* L) -{ - // 3 parametri : nPartId, ptPos, nRawId - int nPartId ; - LuaCheckParam( L, 1, nPartId) - Point3d ptPos ; - LuaCheckParam( L, 2, ptPos) - int nRawId ; - LuaCheckParam( L, 3, nRawId) - LuaClearStack( L) ; - // inserisco il grezzo nella macchinata corrente - bool bOk = EgtAddPartToRawPart( nPartId, ptPos, nRawId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - //------------------------------------------------------------------------------- static int LuaModifyRawPartHeight( lua_State* L) @@ -323,11 +356,11 @@ LuaMoveToCornerRawPart( lua_State* L) LuaCheckParam( L, 1, nRawId) Point3d ptCorner ; LuaCheckParam( L, 2, ptCorner) - string sFlag ; - LuaCheckParam( L, 3, sFlag) + int nFlag ; + LuaCheckParam( L, 3, nFlag) LuaClearStack( L) ; // sposto il grezzo nel corner - bool bOk = EgtMoveToCornerRawPart( nRawId, ptCorner, StringToRawPartCornerPos( sFlag)) ; + bool bOk = EgtMoveToCornerRawPart( nRawId, ptCorner, nFlag) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -342,11 +375,81 @@ LuaMoveToCenterRawPart( lua_State* L) LuaCheckParam( L, 1, nRawId) Point3d ptCenter ; LuaCheckParam( L, 2, ptCenter) - string sFlag ; - LuaCheckParam( L, 3, sFlag) + int nFlag ; + LuaCheckParam( L, 3, nFlag) LuaClearStack( L) ; // sposto il grezzo nel corner - bool bOk = EgtMoveToCenterRawPart( nRawId, ptCenter, StringToRawPartCenterPos( sFlag)) ; + bool bOk = EgtMoveToCenterRawPart( nRawId, ptCenter, nFlag) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetPartInRawPartNbr( lua_State* L) +{ + // 1 parametro : nRawId + int nRawId ; + LuaCheckParam( L, 1, nRawId) + LuaClearStack( L) ; + // recupero il numero di pezzi nel grezzo + int nCount = EgtGetPartInRawPartNbr( nRawId) ; + // restituisco il risultato + LuaSetReturn( L, nCount) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetFirstPartInRawPart( lua_State* L) +{ + // 1 parametro : nRawId + int nRawId ; + LuaCheckParam( L, 1, nRawId) + LuaClearStack( L) ; + // recupero identificativo primo pezzo nel grezzo + int nId = EgtGetFirstPartInRawPart( nRawId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextPartInRawPart( lua_State* L) +{ + // 1 parametro : nPartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // recupero identificativo successivo pezzo nello stesso grezzo + int nId = EgtGetNextPartInRawPart( nPartId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAddPartToRawPart( lua_State* L) +{ + // 3 parametri : nPartId, ptPos, nRawId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + Point3d ptPos ; + LuaCheckParam( L, 2, ptPos) + int nRawId ; + LuaCheckParam( L, 3, nRawId) + LuaClearStack( L) ; + // inserisco il grezzo nella macchinata corrente + bool bOk = EgtAddPartToRawPart( nPartId, ptPos, nRawId) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -418,15 +521,21 @@ LuaInstallMachMgr( void) bOk = bOk && LuaRegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetRawPartNbr", LuaGetRawPartNbr) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstRawPart", LuaGetFirstRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextRawPart", LuaGetNextRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtAddRawPart", LuaAddRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ; - bOk = bOk && LuaRegisterFunction( "EgtAddPartToRawPart", LuaAddPartToRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ; bOk = bOk && LuaRegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtMoveRawPart", LuaTranslateRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtMoveToCenterRawPart", LuaMoveToCenterRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtGetPartInRawPartNbr", LuaGetPartInRawPartNbr) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstPartInRawPart", LuaGetFirstPartInRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextPartInRawPart", LuaGetNextPartInRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtAddPartToRawPart", LuaAddPartToRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ; bOk = bOk && LuaRegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ; diff --git a/LUA_Scene.cpp b/LUA_Scene.cpp index f7ab436..562ae31 100644 --- a/LUA_Scene.cpp +++ b/LUA_Scene.cpp @@ -16,13 +16,12 @@ #include "API.h" #include "LUA.h" #include "LUA_Base.h" -#include "LUA_Aux.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; - //------------------------------------------------------------------------------- static int LuaSetBackground( lua_State* L) @@ -33,8 +32,7 @@ LuaSetBackground( lua_State* L) Color colBot ; LuaCheckParam( L, 2, colBot) bool bRedraw ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bRedraw) + LuaGetParam( L, 3, bRedraw) ; LuaClearStack( L) ; // imposto lo sfondo bool bOk = ( EgtSetBackground( colTop, colBot, bRedraw) != FALSE) ; @@ -60,18 +58,11 @@ LuaDraw( lua_State* L) static int LuaSetShowMode( lua_State* L) { - // 1 o 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 ; + // 1 o 2 parametri : nShowMode [, flag ridisegna] + int nShowMode ; + LuaCheckParam( L, 1, nShowMode) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) ; LuaClearStack( L) ; // imposto il modo di visualizzazione bool bOk = ( EgtSetShowMode( nShowMode, bRedraw) != FALSE) ; @@ -84,12 +75,11 @@ LuaSetShowMode( lua_State* L) static int LuaSetShowCurveDirection( lua_State* L) { - // 1 o 2 parametri : flag ShowCrvDir [, flag ridisegna] + // 1 o 2 parametri : bool bShowCrvDir [, flag ridisegna] bool bShowCrvDir ; LuaCheckParam( L, 1, bShowCrvDir) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) ; LuaClearStack( L) ; // imposto visualizzazione direzione curve bool bOk = ( EgtSetShowCurveDirection( bShowCrvDir, bRedraw) != FALSE) ; @@ -106,8 +96,7 @@ LuaSetShowTriaAdv( lua_State* L) bool bAdvanced ; LuaCheckParam( L, 1, bAdvanced) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) , LuaClearStack( L) ; // imposto visualizzazione direzione curve bool bOk = ( EgtSetShowTriaAdv( bAdvanced, bRedraw) != FALSE) ; @@ -120,18 +109,11 @@ LuaSetShowTriaAdv( lua_State* L) static int LuaZoom( lua_State* L) { - // 1 o 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 ; + // 1 o 2 parametri : nZoomType [, flag ridisegna] + int nZoomType ; + LuaCheckParam( L, 1, nZoomType) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) ; LuaClearStack( L) ; // imposto zoom bool bOk = ( EgtZoom( nZoomType, bRedraw) != FALSE) ; @@ -144,32 +126,11 @@ LuaZoom( lua_State* L) static int LuaSetView( lua_State* L) { - // 1 o 2 parametri : ViewDir ("T","F","R","B","L","BO","SW","SE","NE","NW","GRID") [, 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 == "SW") - nViewDir = CT_ISO_SW ; - else if ( sViewDir == "SE") - nViewDir = CT_ISO_SE ; - else if ( sViewDir == "NE") - nViewDir = CT_ISO_NE ; - else if ( sViewDir == "NW") - nViewDir = CT_ISO_NW ; - else if ( sViewDir == "GRID") - nViewDir = CT_CPLANE ; + // 1 o 2 parametri : nViewDir [, flag ridisegna] + int nViewDir ; + LuaCheckParam( L, 1, nViewDir) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) ; LuaClearStack( L) ; // imposto direzione di vista bool bOk = ( EgtSetView( nViewDir, bRedraw) != FALSE) ; @@ -188,8 +149,7 @@ LuaSetGenericView( lua_State* L) double dAngHorizDeg ; LuaCheckParam( L, 2, dAngHorizDeg) bool bRedraw = true ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bRedraw) + LuaGetParam( L, 3, bRedraw) ; LuaClearStack( L) ; // imposto direzione di vista bool bOk = ( EgtSetGenericView( dAngVertDeg, dAngHorizDeg, bRedraw) != FALSE) ; @@ -206,8 +166,7 @@ LuaSetViewCenter( lua_State* L) Point3d ptCen ; LuaCheckParam( L, 1, ptCen) bool bRedraw = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bRedraw) + LuaGetParam( L, 2, bRedraw) ; LuaClearStack( L) ; // imposto centro di vista bool bOk = ( EgtSetViewCenter( ptCen.v, bRedraw) != FALSE) ;