From 8bc0e986b243bf5e3df2e5ae029975b43891bc69 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 5 May 2015 22:14:56 +0000 Subject: [PATCH] EgtInterface 1.6e2 : - esecutore e lua scorporato in EgtExecutor. --- API.h | 180 +--- API_Exchange.cpp | 202 +--- API_GdbCreate.cpp | 280 +----- API_GdbCreateCurve.cpp | 1780 +--------------------------------- API_GdbCreateSurf.cpp | 697 +------------ API_GdbModify.cpp | 209 +--- API_GdbModifyCurve.cpp | 709 +------------- API_GdbModifySurf.cpp | 126 +-- API_GdbObjAttribs.cpp | 442 +-------- API_GdbObjSelection.cpp | 142 +-- API_GdbObjects.cpp | 407 +------- API_GdbPartLayers.cpp | 369 +------ API_General.cpp | 233 +---- API_GeoBase.cpp | 5 +- API_GeoSnap.cpp | 962 +----------------- API_GeoTransform.cpp | 356 +------ API_GeomDB.cpp | 321 +----- API_Lua.cpp | 75 +- API_MachMgr.cpp | 459 +-------- API_Macro.h | 54 -- API_Messages.cpp | 64 +- API_Scene.cpp | 458 ++------- API_TscExec.cpp | 80 +- AuxTools.cpp | 141 --- AuxTools.h | 37 - DllExchange.cpp | 213 ---- DllExchange.h | 38 - DllGraphics.cpp | 149 --- DllGraphics.h | 30 - DllMachKernel.cpp | 133 --- DllMachKernel.h | 28 - EgtInterface.rc | Bin 11718 -> 11718 bytes EgtInterface.vcxproj | 37 - EgtInterface.vcxproj.filters | 120 --- GeoTools.cpp | 90 -- GeoTools.h | 26 - GseContext.cpp | 166 ---- GseContext.h | 90 -- LUA.h | 68 -- LUA_Base.cpp | 181 ---- LUA_Base.h | 32 - LUA_Exchange.cpp | 120 --- LUA_GdbCreate.cpp | 247 ----- LUA_GdbCreateCurve.cpp | 840 ---------------- LUA_GdbCreateSurf.cpp | 461 --------- LUA_GdbModify.cpp | 176 ---- LUA_GdbModifyCurve.cpp | 393 -------- LUA_GdbModifySurf.cpp | 94 -- LUA_GdbObjAttribs.cpp | 582 ----------- LUA_GdbObjSelection.cpp | 223 ----- LUA_GdbObjects.cpp | 521 ---------- LUA_GdbPartLayers.cpp | 303 ------ LUA_General.cpp | 321 ------ LUA_GeoBase.cpp | 472 --------- LUA_GeoSnap.cpp | 585 ----------- LUA_GeoTransform.cpp | 260 ----- LUA_GeomDB.cpp | 189 ---- LUA_MachMgr.cpp | 544 ----------- LUA_Scene.cpp | 193 ---- stdafx.h | 1 + 60 files changed, 454 insertions(+), 16260 deletions(-) delete mode 100644 API_Macro.h delete mode 100644 AuxTools.cpp delete mode 100644 AuxTools.h delete mode 100644 DllExchange.cpp delete mode 100644 DllExchange.h delete mode 100644 DllGraphics.cpp delete mode 100644 DllGraphics.h delete mode 100644 DllMachKernel.cpp delete mode 100644 DllMachKernel.h delete mode 100644 GeoTools.cpp delete mode 100644 GeoTools.h delete mode 100644 GseContext.cpp delete mode 100644 GseContext.h delete mode 100644 LUA.h delete mode 100644 LUA_Base.cpp delete mode 100644 LUA_Base.h delete mode 100644 LUA_Exchange.cpp delete mode 100644 LUA_GdbCreate.cpp delete mode 100644 LUA_GdbCreateCurve.cpp delete mode 100644 LUA_GdbCreateSurf.cpp delete mode 100644 LUA_GdbModify.cpp delete mode 100644 LUA_GdbModifyCurve.cpp delete mode 100644 LUA_GdbModifySurf.cpp delete mode 100644 LUA_GdbObjAttribs.cpp delete mode 100644 LUA_GdbObjSelection.cpp delete mode 100644 LUA_GdbObjects.cpp delete mode 100644 LUA_GdbPartLayers.cpp delete mode 100644 LUA_General.cpp delete mode 100644 LUA_GeoBase.cpp delete mode 100644 LUA_GeoSnap.cpp delete mode 100644 LUA_GeoTransform.cpp delete mode 100644 LUA_GeomDB.cpp delete mode 100644 LUA_MachMgr.cpp delete mode 100644 LUA_Scene.cpp diff --git a/API.h b/API.h index 798359d..f62fb6c 100644 --- a/API.h +++ b/API.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2014-2014 +// EgalTech 2014-2015 //---------------------------------------------------------------------------- -// File : API.h Data : 01.09.14 Versione : 1.5l1 +// File : API.h Data : 01.09.14 Versione : 1.6e1 // Contenuto : Dichiarazioni locali per moduli API. // // @@ -13,175 +13,9 @@ #pragma once -#include "GseContext.h" -#include "/EgtDev/Include/EGkGeoCollection.h" -#include "/EgtDev/Include/EGkPolyArc.h" -#include "/EgtDev/Include/EgtILogger.h" +//----------------------------------------------------------------------------- +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkPoint3d.h" -//---------------------------------------------------------------------------- -ILogger* GetLogger( void) ; -ILogger* GetCmdLogger( void) ; -bool SetCmdLog( bool bVal) ; -bool IsCmdLog( void) ; - -//--------------------------- General ---------------------------------------- -bool EgtGetVersionInfo( std::string& sVer, const char* szNewLine) ; - -//--------------------------- GeomDB ----------------------------------------- -bool EgtSetGridFrame( const Frame3d& frFrame) ; -bool EgtGetGridFrame( int nRefId, Frame3d& frFrame) ; -bool EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) ; -bool EgtSetCurrFilePath( const std::string& sFilePath) ; -bool EgtGetCurrFilePath( std::string& sFilePath) ; -bool EgtOpenFile( const std::string& sFilePath) ; -bool EgtInsertFile( const std::string& sFilePath) ; -bool EgtSaveFile( const std::string& sFilePath, int nFlag) ; -bool EgtSaveObjToFile( int nId, const std::string& sFilePath, int nFlag) ; - -//--------------------------- GeomDBCreate ----------------------------------- -int EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, - const std::string& sText, double dH, int nRefType) ; -int EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const std::string& sText, const std::string& sFont, bool bItalic, double dH, int nRefType) ; -int EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const std::string& sText, const std::string& sFont, - int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) ; - -//--------------------------- GeomDBCreateCurve ------------------------------ -int EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, int nRefType) ; -int EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW, int nRefType) ; -int EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) ; -int EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) ; -int EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) ; -int EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType) ; - -//--------------------------- GeomDBCreateSurface ---------------------------- -int EgtCreateSurfTmBBox( int nParentId, const BBox3d& b3Box, int nRefType) ; -int EgtCreateSurfTmByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) ; -int EgtCreateSurfTmByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) ; -int EgtCreateSurfTmByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) ; -int EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) ; -int EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) ; - -//--------------------------- GdbModify -------------------------------------- -bool EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) ; -bool EgtModifyText( int nId, const std::string& sNewText) ; -bool EgtChangeTextFont( int nId, const std::string& sNewFont) ; - -//--------------------------- GdbModifyCurve --------------------------------- -bool EgtInvertCurve( const INTVECTOR& vIds) ; -bool EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) ; -bool EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) ; -bool EgtExplodeCurveCompo( int nId, int& nFirstId, int& nCount) ; - -//--------------------------- GdbModifySurf ---------------------------------- -bool EgtInvertSurface( const INTVECTOR& vIds) ; - -//--------------------------- GdbObjects ------------------------------------- -int EgtGetFirstNameInGroup( int nGroupId, const std::string& sName) ; -int EgtGetNextName( int nId, const std::string& sName) ; -int EgtGetLastNameInGroup( int nGroupId, const std::string& sName) ; -int EgtGetPrevName( int nId, const std::string& sName) ; -bool EgtGetBBox( int nId, int nFlag, BBox3d& b3Box) ; -bool EgtGetBBoxGlob( int nId, int nFlag, BBox3d& b3Box) ; -bool EgtGetBBoxRef( int nId, int nFlag, const Frame3d& frRef, BBox3d& b3Box) ; -bool EgtErase( const INTVECTOR& vIds) ; - -//--------------------------- GdbObjAttribs ---------------------------------- -bool EgtSetStatus( const INTVECTOR& vIds, int nStat) ; -bool EgtSetColor( const INTVECTOR& vIds, const Color& cCol, bool bSetAlpha) ; -bool EgtSetAlpha( const INTVECTOR& vIds, int nAlpha) ; -bool EgtResetColor( const INTVECTOR& vIds) ; -bool EgtSetName( int nId, const std::string& sName) ; -bool EgtGetName( int nId, std::string& sName) ; -bool EgtSetInfo( int nId, const std::string& sKey, const std::string& sInfo) ; -bool EgtSetInfo( int nId, const std::string& sKey, int nInfo) ; -bool EgtGetInfo( int nId, const std::string& sKey, std::string& sInfo) ; -bool EgtGetInfo( int nId, const std::string& sKey, int& nInfo) ; -bool EgtExistsInfo( int nId, const std::string& sKey) ; -bool EgtRemoveInfo( int nId, const std::string& sKey) ; - -//--------------------------- GeoSnap ---------------------------------------- -bool EgtStartPoint( int nId, int nRefId, Point3d& ptP) ; -bool EgtEndPoint( int nId, int nRefId, Point3d& ptP) ; -bool EgtMidPoint( int nId, int nRefId, Point3d& ptP) ; -bool EgtCenterPoint( int nId, int nRefId, Point3d& ptP) ; -bool EgtCentroid( int nId, int nRefId, Point3d& ptP) ; -bool EgtAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP) ; -bool EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) ; -bool EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Point3d& ptP) ; -bool EgtStartVector( int nId, int nRefId, Vector3d& vtV) ; -bool EgtEndVector( int nId, int nRefId, Vector3d& vtV) ; -bool EgtMidVector( int nId, int nRefId, Vector3d& vtV) ; -bool EgtAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV) ; -bool EgtFrame( int nId, int nRefId, Frame3d& frFrame) ; -bool EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) ; -// EgtCurveThickness vedi EinAPI.h -bool EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) ; -bool EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) ; -bool EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, - Point3d& ptEnd, Vector3d& vtN) ; -bool EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, - Point3d& ptMid, Vector3d& vtN) ; -bool EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN) ; -bool EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm) ; -bool EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) ; -bool EgtPointToIdGlob( Point3d& ptP, int nId) ; -bool EgtPointToIdLoc( Point3d& ptP, int nId) ; -bool EgtVectorToIdGlob( Vector3d& vtV, int nId) ; -bool EgtVectorToIdLoc( Vector3d& vtV, int nId) ; - -//--------------------------- GeoTransform ----------------------------------- -bool EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) ; -bool EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, int nRefType) ; -bool EgtScale( INTVECTOR& vIds, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ, int nRefType) ; -bool EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefType) ; -bool EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, - const Vector3d& vtDir, double dCoeff, int nRefType) ; - -//--------------------------- Machining -------------------------------------- -bool EgtUpdateMachMgr( void) ; -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 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) ; - -//--------------------------- Scene ------------------------------------------ -bool EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ; -bool EgtSetMarkAttribs( Color MarkCol) ; -bool EgtSetSelSurfAttribs( Color SelSurfCol) ; -bool EgtSetGeoLineAttribs( Color GlCol) ; -bool EgtSetGeoTriaAttribs( Color GtCol) ; -bool EgtSetWinRectAttribs( bool bOutline, Color WrCol) ; - -//--------------------------- Exchange --------------------------------------- -int EgtGetFileType( const std::string& sFilePath) ; -bool EgtImportDxf( const std::string& sFilePath, double dScaleFactor) ; -bool EgtImportStl( const std::string& sFilePath, double dScaleFactor) ; -bool EgtImportCnc( const std::string& sFilePath) ; -bool EgtExportDxf( int nId, const std::string& sFilePath) ; -bool EgtExportStl( int nId, const std::string& sFilePath) ; - -//--------------------------- TscExec ---------------------------------------- -bool EgtTscExecFile( const std::string& sFilePath) ; +//----------------------------------------------------------------------------- +#define VEC_FROM_3D( D, S) { (D)[0] = (S).x ; (D)[1] = (S).y ; (D)[2] = (S).z ; } diff --git a/API_Exchange.cpp b/API_Exchange.cpp index e7d6b55..debd167 100644 --- a/API_Exchange.cpp +++ b/API_Exchange.cpp @@ -14,17 +14,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "DllExchange.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EExImportStl.h" -#include "/EgtDev/Include/EExImportDxf.h" -#include "/EgtDev/Include/EExImportCnc.h" -#include "/EgtDev/Include/EExExportStl.h" -#include "/EgtDev/Include/EExExportDxf.h" -#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -32,220 +24,40 @@ using namespace std ; int __stdcall EgtGetFileType( const wchar_t* wsFilePath) { - return EgtGetFileType( wstrztoA( wsFilePath)) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetFileType( const string& sFilePath) -{ - // divido in nome e direttorio - string sFileDir, sFileName ; - SplitLast( sFilePath, "\\", sFileDir, sFileName) ; - - // recupero l'estensione - string sFileTitle, sFileExt ; - SplitLast( sFileName, ".", sFileTitle, sFileExt) ; - ToUpper( sFileExt) ; - - if ( sFileExt == "NGE") - return 1 ; - else if ( sFileExt == "NFE") - return 2 ; - else if ( sFileExt == "DXF") - return 11 ; - else if ( sFileExt == "STL") - return 12 ; - else if ( sFileExt == "CNC") - return 13 ; - else if ( sFileExt == "TSC") - return 101 ; - else if ( sFileExt == "LUA") - return 102 ; - else { - // emetto info - string sInfo = "File type (" + sFileExt + ") not recognized" ; - LOG_INFO( GetLogger(), sInfo.c_str()) - return 0 ; - } + return ExeGetFileType( wstrztoA( wsFilePath)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtImportDxf( const wchar_t* wsFilePath, double dScaleFactor) { - return ( EgtImportDxf( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtImportDxf( const string& sFilePath, double dScaleFactor) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - bool bOk = true ; - // importo il file DXF - // aggiungo un gruppo pezzo - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpDxf( MyCreateImportDxf()) ; - bOk = bOk && ! IsNull( pImpDxf) ; - // eseguo l'importazione - bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtImportDxf('" + sLuaPath + "'," + - ToString( dScaleFactor) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeImportDxf( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtImportStl( const wchar_t* wsFilePath, double dScaleFactor) { - return ( EgtImportStl( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtImportStl( const string& sFilePath, double dScaleFactor) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - bool bOk = true ; - // importo il file STL - // aggiungo un gruppo pezzo e un gruppo layer - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpStl( MyCreateImportStl()) ; - bOk = bOk && ! IsNull( pImpStl) ; - // eseguo l'importazione - bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtImportStl('" + sLuaPath + "'," + - ToString( dScaleFactor) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeImportStl( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtImportCnc( const wchar_t* wsFilePath) { - return ( EgtImportCnc( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtImportCnc( const string& sFilePath) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - bool bOk = true ; - // importo il file CNC - // aggiungo un gruppo pezzo - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpCnc( MyCreateImportCnc()) ; - bOk = bOk && ! IsNull( pImpCnc) ; - // eseguo l'importazione - bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtImportCnc('" + sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeImportCnc( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExportDxf( int nId, const wchar_t* wsFilePath) { - return ( EgtExportDxf( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtExportDxf( int nId, const string& sFilePath) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // esporto il file DXF - // preparo l'esportatore - PtrOwner pExpDxf( MyCreateExportDxf()) ; - bOk = bOk && ! IsNull( pExpDxf) ; - // eseguo l'esportazione - bOk = bOk && pExpDxf->Export( pGeomDB, nId, sFilePath) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtExportDxf(" + ToString( nId) + ",'" + - sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeExportDxf( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExportStl( int nId, const wchar_t* wsFilePath) { - return ( EgtExportStl( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtExportStl( int nId, const string& sFilePath) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // esporto il file STL - // preparo l'esportatore - PtrOwner pExpStl( MyCreateExportStl()) ; - bOk = bOk && ! IsNull( pExpStl) ; - // eseguo l'esportazione - bOk = bOk && pExpStl->Export( pGeomDB, nId, sFilePath) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtExportStl(" + ToString( nId) + ",'" + - sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeExportStl( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } diff --git a/API_GdbCreate.cpp b/API_GdbCreate.cpp index 089ce92..ed48874 100644 --- a/API_GdbCreate.cpp +++ b/API_GdbCreate.cpp @@ -14,17 +14,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkGeoPoint3d.h" -#include "/EgtDev/Include/EgkGeoVector3d.h" -#include "/EgtDev/Include/EgkExtText.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -33,118 +25,24 @@ int __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3], const double vX[3], const double vY[3], const double vZ[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale l'origine e i versori - Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; ; - Vector3d vtXL = GetVectorLocal( pGeomDB, vX, nRefType, frLoc) ; ; - Vector3d vtYL = GetVectorLocal( pGeomDB, vY, nRefType, frLoc) ; ; - Vector3d vtZL = GetVectorLocal( pGeomDB, vZ, nRefType, frLoc) ; ; - // costruisco il riferimento - Frame3d frFrameL ; - bOk = bOk && frFrameL.Set( ptOrigL, vtXL, vtYL, vtZL) ; - // creo il gruppo - int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrameL) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( AreSamePointApprox( ORIG, ptOrig) && - AreSameVectorExact( X_AX, vX) && - AreSameVectorExact( Y_AX, vY) && - AreSameVectorExact( Z_AX, vZ)) - sLua = "EgtGroup(" + ToString( nParentId) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - else - sLua = "EgtGroup(" + ToString( nParentId) + ",{{" + - ToString( Point3d( ptOrig)) + "},{" + - ToString( Vector3d( vX)) + "},{" + - ToString( Vector3d( vY)) + "},{" + - ToString( Vector3d( vZ)) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del nuovo gruppo - return nId ; + Frame3d frFrame ; + if ( ! frFrame.Set( ptOrig, vX, vY, vZ)) + return GDB_ID_NULL ; + return ExeCreateGroup( nParentId, frFrame, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale il punto - Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; ; - // creo il punto - PtrOwner pGeoPnt( CreateGeoPoint3d()) ; - bOk = bOk && ! IsNull( pGeoPnt) ; - // setto il punto - bOk = bOk && pGeoPnt->Set( ptPL) ; - // inserisco il punto nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtPoint(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptP)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateGeoPoint( nParentId, ptP, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double ptB[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale il vettore e il punto - Vector3d vtVL = GetVectorLocal( pGeomDB, vtV, nRefType, frLoc) ; ; - Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ; ; - // creo il vettore - PtrOwner pGeoVct( CreateGeoVector3d()) ; - bOk = bOk && ! IsNull( pGeoVct) ; - // setto il vettore (con il punto base) - bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; - // inserisco il vettore nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( Point3d( ptB).IsSmall()) - sLua = "EgtVector(" + ToString( nParentId) + ",{" + - ToString( Vector3d( vtV)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - else - sLua = "EgtVector(" + ToString( nParentId) + ",{" + - ToString( Vector3d( vtV)) + "},{" + - ToString( Point3d( ptB)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateGeoVector( nParentId, vtV, ptB, nRefType) ; } //------------------------------------------------------------------------------- @@ -152,37 +50,10 @@ int __stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3], const double vX[3], const double vY[3], const double vZ[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale l'origine e i versori - Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; ; - Vector3d vtXL = GetVectorLocal( pGeomDB, vX, nRefType, frLoc) ; ; - Vector3d vtYL = GetVectorLocal( pGeomDB, vY, nRefType, frLoc) ; ; - Vector3d vtZL = GetVectorLocal( pGeomDB, vZ, nRefType, frLoc) ; ; - // creo e setto il riferimento - PtrOwner pGeoFrm( CreateGeoFrame3d()) ; - bOk = bOk & ! IsNull( pGeoFrm) ; - bOk = bOk & pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ; - // inserisco il riferimento nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtFrame(" + ToString( nParentId) + ",{{" + - ToString( Point3d( ptOrig)) + "},{" + - ToString( Vector3d( vX)) + "},{" + - ToString( Vector3d( vY)) + "},{" + - ToString( Vector3d( vZ)) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del nuovo gruppo - return nId ; + Frame3d frFrame ; + if ( ! frFrame.Set( ptOrig, vX, vY, vZ)) + return GDB_ID_NULL ; + return ExeCreateGeoFrame( nParentId, frFrame, nRefType) ; } //------------------------------------------------------------------------------- @@ -190,44 +61,7 @@ int __stdcall EgtCreateText( int nParentId, const double ptP[3], double dAngRotDeg, const wchar_t* wsText, double dH, int nRefType) { - return EgtCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, - const string& sText, double dH, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale l'origine e i versori - Point3d ptPL = GetPointLocal( pGeomDB, ptP.v, nRefType, frLoc) ; ; - Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; ; - Vector3d vtDL = GetVectorLocal( pGeomDB, X_AX.v, nRefType, frLoc) ; ; - // creo il testo e lo riempio - PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; - bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, "", false, dH) ; - // inserisco il testo nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtText(" + ToString( nParentId) + ",{" + - ToString( ptP) + "}," + - ToString( dAngRotDeg) + ",'" + - sText + "','" + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del oggetto - return nId ; + return ExeCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH, nRefType) ; } //------------------------------------------------------------------------------- @@ -235,102 +69,18 @@ int __stdcall EgtCreateTextEx( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3], const wchar_t* wsText, const wchar_t* wsFont, BOOL bItalic, double dH, int nRefType) { - return EgtCreateTextEx( nParentId, ptP, vtN, vtD, + return ExeCreateTextEx( nParentId, ptP, vtN, vtD, wstrztoA( wsText), wstrztoA( wsFont), (bItalic != FALSE), dH, nRefType) ; } -//------------------------------------------------------------------------------- -int -EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const string& sText, const string& sFont, bool bItalic, double dH, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale l'origine e i versori - Point3d ptPL = GetPointLocal( pGeomDB, ptP.v, nRefType, frLoc) ; ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN.v, nRefType, frLoc) ; ; - Vector3d vtDL = GetVectorLocal( pGeomDB, vtD.v, nRefType, frLoc) ; ; - // creo il testo e lo riempio - PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; - bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, bItalic, dH) ; - // inserisco il testo nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtTextEx(" + ToString( nParentId) + ",{" + - ToString( ptP) + "},{" + - ToString( vtN) + "},{" + - ToString( vtD) + "},'" + - sText + "','" + - sFont + "'," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del oggetto - return nId ; -} - //------------------------------------------------------------------------------- int __stdcall EgtCreateTextAdv( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3], const wchar_t* wsText, const wchar_t* wsFont, int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) { - return EgtCreateTextAdv( nParentId, ptP, vtN, vtD, + return ExeCreateTextAdv( nParentId, ptP, vtN, vtD, wstrztoA( wsText), wstrztoA( wsFont), nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos, nRefType) ; } - -//------------------------------------------------------------------------------- -int -EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const string& sText, const string& sFont, - int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale l'origine e i versori - Point3d ptPL = GetPointLocal( pGeomDB, ptP.v, nRefType, frLoc) ; ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN.v, nRefType, frLoc) ; ; - Vector3d vtDL = GetVectorLocal( pGeomDB, vtD.v, nRefType, frLoc) ; ; - // creo il testo e lo imposto - PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; - bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ; - // inserisco il testo nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtTextAdv(" + ToString( nParentId) + ",{" + - ToString( ptP) + "},{" + - ToString( vtN) + "},{" + - ToString( vtD) + "},'" + - sText + "','" + - sFont + "'," + - ToString( nW) + "," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - ToString( dRat) + "," + - ToString( dAddAdv) + "," + - ETxtInsPosToString( nInsPos) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo del oggetto - return nId ; -} + diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index 8900fb1..b415443 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -14,88 +14,16 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkCurveLine.h" -#include "/EgtDev/Include/EGkLinePntTgCurve.h" -#include "/EgtDev/Include/EGkLinePntPerpCurve.h" -#include "/EgtDev/Include/EGkLinePntMinDistCurve.h" -#include "/EgtDev/Include/EGkLineTgTwoCurves.h" -#include "/EgtDev/Include/EGkLinePerpTwoCurves.h" -#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h" -#include "/EgtDev/Include/EgkCurveArc.h" -#include "/EgtDev/Include/EgkCircleCenTgCurve.h" -#include "/EgtDev/Include/EgkArcSpecial.h" -#include "/EgtDev/Include/EgkArcPntDirTgCurve.h" -#include "/EgtDev/Include/EgkArcCenTgCurvePnt.h" -#include "/EgtDev/Include/EgkFilletChamfer.h" -#include "/EgtDev/Include/EgkCurveBezier.h" -#include "/EgtDev/Include/EgkCurveComposite.h" -#include "/EgtDev/Include/EgkChainCurves.h" -#include "/EgtDev/Include/EgkSurfTriMesh.h" -#include "/EgtDev/Include/EGkDistPointCurve.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EGkCurveLocal.h" -#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; -//------------------------------------------------------------------------------- -static ICurveLine* CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) ; -static ICurveLine* CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) ; -static ICurveLine* CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) ; -static ICurveLine* CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ; -static ICurveLine* CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ; -static ICurveLine* CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) ; -static Vector3d CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType) ; - - //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo la linea - PtrOwner pCrvLine( CreateCurveLine()) ; - if ( IsNull( pCrvLine)) - return GDB_ID_NULL ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti e il versore estrusione - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptFinL = GetPointLocal( pGeomDB, ptFin, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto la linea - if ( ! pCrvLine->Set( ptIniL, ptFinL)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvLine->SetExtrusion( vtExtrL) ; - // inserisco la linea nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtLine(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptFin)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveLine( nParentId, ptIni, ptFin, nRefType) ; } //------------------------------------------------------------------------------- @@ -103,373 +31,7 @@ int __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, int nIdI, const double ptFin[3], int nSepF, int nIdF, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // puntatore alla linea - PtrOwner pCrvLine ; - // recupero il riferimento locale - Frame3d frLoc ; - bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti e il versore estrusione - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptFinL = GetPointLocal( pGeomDB, ptFin, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // 1 - se punti entrambi definiti - if ( nSepI == SEP_STD && nSepF == SEP_STD) { - pCrvLine.Set( CreateCurveLine()) ; - bOk = bOk && ! IsNull( pCrvLine) ; - bOk = bOk && pCrvLine->Set( ptIniL, ptFinL) ; - } - // 2 - se primo punto definito e secondo a minima distanza - else if ( nSepI == SEP_STD && nSepF == SEP_MINDIST) { - pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 3 - se primo punto a minima distanza e secondo definito - else if ( nSepI == SEP_MINDIST && nSepF == SEP_STD) { - pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - bOk = bOk && pCrvLine->Invert() ; - } - // 4 - se primo punto definito e secondo tangente - else if ( nSepI == SEP_STD && nSepF == SEP_TG) { - pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 5 - se primo punto tangente e secondo definito - else if ( nSepI == SEP_TG && nSepF == SEP_STD) { - // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - bOk = bOk && pCrvLine->Invert() ; - } - // 6 - se entrambi i punti tangenti - else if ( nSepI == SEP_TG && nSepF == SEP_TG) { - pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 7 - se primo punto definito e secondo perpendicolare - else if ( nSepI == SEP_STD && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 8 - se primo punto perpendicolare e secondo definito - else if ( nSepI == SEP_PERP && nSepF == SEP_STD) { - // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - bOk = bOk && pCrvLine->Invert() ; - } - // 9 - se entrambi i punti perpendicolari - else if ( nSepI == SEP_PERP && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 10 - se primo punto tangente e secondo perpendicolare - else if ( nSepI == SEP_TG && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - } - // 11 - se primo punto perpendicolare e secondo tangente - else if ( nSepI == SEP_PERP && nSepF == SEP_TG) { - // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptFinL, nIdF, ptIniL, nIdI)) ; - bOk = bOk && ! IsNull( pCrvLine) ; - bOk = bOk && pCrvLine->Invert() ; - } - // errore - else { - bOk = false ; - } - // assegno il versore estrusione - bOk = bOk && pCrvLine->SetExtrusion( vtExtrL) ; - // inserisco la linea nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( nSepI == SEP_STD && nSepF == SEP_STD) - sLua = "EgtLine(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptFin)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - else - sLua = "EgtLineEx(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "}," + - SepToString( nSepI) + "," + - ToString( nIdI) + ",{" + - ToString( Point3d( ptFin)) + "}," + - SepToString( nSepF) + "," + - ToString( nIdF) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLinePointTgCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curva - if ( nIdF == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della curva - Frame3d frCurve ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve)) - return nullptr ; - // porto il punto iniziale nel riferimento della curva - Point3d ptSloc( ptIni) ; - ptSloc.LocToLoc( frDest, frCurve) ; - // porto il punto vicino al finale nel riferimento della curva - Point3d ptNloc( ptFin) ; - ptNloc.LocToLoc( frDest, frCurve) ; - // recupero la curva - const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCurve == nullptr) - return false ; - // calcolo la retta tangente alla curva - PtrOwner pCrvLine ; - pCrvLine.Set( GetLinePointTgCurve( ptSloc, *pCurve, ptNloc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCurve, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLinePointPerpCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curva - if ( nIdF == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della curva - Frame3d frCurve ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve)) - return nullptr ; - // porto il punto iniziale nel riferimento della curva - Point3d ptSloc( ptIni) ; - ptSloc.LocToLoc( frDest, frCurve) ; - // porto il punto vicino al finale nel riferimento della curva - Point3d ptNloc( ptFin) ; - ptNloc.LocToLoc( frDest, frCurve) ; - // recupero la curva - const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCurve == nullptr) - return nullptr ; - // calcolo la retta perpendicolare alla curva - PtrOwner pCrvLine ; - pCrvLine.Set( GetLinePointPerpCurve( ptSloc, *pCurve, ptNloc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCurve, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLinePointMinDistCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curva - if ( nIdF == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della curva - Frame3d frCurve ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCurve)) - return nullptr ; - // porto il punto iniziale nel riferimento della curva - Point3d ptSloc( ptIni) ; - ptSloc.LocToLoc( frDest, frCurve) ; - // porto il punto vicino al finale nel riferimento della curva - Point3d ptNloc( ptFin) ; - ptNloc.LocToLoc( frDest, frCurve) ; - // recupero la curva - const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCurve == nullptr) - return nullptr ; - // calcolo la retta perpendicolare alla curva - PtrOwner pCrvLine ; - pCrvLine.Set( GetLinePointMinDistCurve( ptSloc, *pCurve, ptNloc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCurve, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLineTgTwoCurves( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curve - if ( nIdF == GDB_ID_NULL || nIdI == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della prima curva - Frame3d frCrv1 ; - if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1)) - return nullptr ; - // recupero la prima curva - const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ; - if ( pCrv1 == nullptr) - return nullptr ; - // porto il punto vicino a iniziale nel riferimento della prima curva - Point3d ptN1loc( ptIni) ; - ptN1loc.LocToLoc( frDest, frCrv1) ; - // recupero il riferimento della seconda curva - Frame3d frCrv2 ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2)) - return nullptr ; - // recupero la seconda curva - const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCrv2 == nullptr) - return false ; - // porto la seconda curva nel riferimento della prima - PtrOwner pCrv2Loc( pCrv2->Clone()) ; - if ( IsNull( pCrv2Loc)) - return nullptr ; - pCrv2Loc->LocToLoc( frCrv2, frCrv1) ; - // porto il punto vicino al finale nel riferimento della prima curva - Point3d ptN2loc( ptFin) ; - ptN2loc.LocToLoc( frDest, frCrv1) ; - // calcolo la retta tangente alle due curve - PtrOwner pCrvLine ; - pCrvLine.Set( GetLineTgTwoCurves( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCrv1, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLinePerpTwoCurves( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curve - if ( nIdI == GDB_ID_NULL || nIdF == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della prima curva - Frame3d frCrv1 ; - if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1)) - return nullptr ; - // recupero la prima curva - const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ; - if ( pCrv1 == nullptr) - return nullptr ; - // porto il punto vicino a iniziale nel riferimento della prima curva - Point3d ptN1loc( ptIni) ; - ptN1loc.LocToLoc( frDest, frCrv1) ; - // recupero il riferimento della seconda curva - Frame3d frCrv2 ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2)) - return nullptr ; - // recupero la seconda curva - const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCrv2 == nullptr) - return nullptr ; - // porto la seconda curva nel riferimento della prima - PtrOwner pCrv2Loc( pCrv2->Clone()) ; - if ( IsNull( pCrv2Loc)) - return nullptr ; - pCrv2Loc->LocToLoc( frCrv2, frCrv1) ; - // porto il punto vicino al finale nel riferimento della prima curva - Point3d ptN2loc( ptFin) ; - ptN2loc.LocToLoc( frDest, frCrv1) ; - // calcolo la retta perpendicolare alle due curve - PtrOwner pCrvLine ; - pCrvLine.Set( GetLinePerpTwoCurves( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCrv1, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; -} - -//------------------------------------------------------------------------------- -ICurveLine* -CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId, - const Point3d& ptIni, int nIdI, const Point3d& ptFin, int nIdF) -{ - // verifica preliminare Id curve - if ( nIdI == GDB_ID_NULL || nIdF == GDB_ID_NULL) - return nullptr ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return nullptr ; - // recupero il riferimento della prima curva - Frame3d frCrv1 ; - if ( ! pGeomDB->GetGlobFrame( nIdI, frCrv1)) - return nullptr ; - // recupero la prima curva - const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nIdI)) ; - if ( pCrv1 == nullptr) - return nullptr ; - // porto il punto vicino a iniziale nel riferimento della prima curva - Point3d ptN1loc( ptIni) ; - ptN1loc.LocToLoc( frDest, frCrv1) ; - // recupero il riferimento della seconda curva - Frame3d frCrv2 ; - if ( ! pGeomDB->GetGlobFrame( nIdF, frCrv2)) - return nullptr ; - // recupero la seconda curva - const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nIdF)) ; - if ( pCrv2 == nullptr) - return nullptr ; - // porto la seconda curva nel riferimento della prima - PtrOwner pCrv2Loc( pCrv2->Clone()) ; - if ( IsNull( pCrv2Loc)) - return nullptr ; - pCrv2Loc->LocToLoc( frCrv2, frCrv1) ; - // porto il punto vicino al finale nel riferimento della prima curva - Point3d ptN2loc( ptFin) ; - ptN2loc.LocToLoc( frDest, frCrv1) ; - // calcolo la retta perpendicolare alle due curve - PtrOwner pCrvLine ; - pCrvLine.Set( GetLineTgCurvePerpCurve( *pCrv1, ptN1loc, *pCrv2, ptN2loc)) ; - if ( IsNull( pCrvLine)) - return nullptr ; - // porto la linea nel riferimento del gruppo destinazione - pCrvLine->LocToLoc( frCrv1, frDest) ; - // restituisco la linea - return Release( pCrvLine) ; + return ExeCreateCurveLineEx( nParentId, ptIni, nSepI, nIdI, ptFin, nSepF, nIdF, nRefType) ; } //------------------------------------------------------------------------------- @@ -477,40 +39,7 @@ int __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const double vtDir[3], double dLen, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale il punto e i versori - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // creo la linea - PtrOwner pCrvLine( CreateCurveLine()) ; - if ( IsNull( pCrvLine)) - return GDB_ID_NULL ; - // setto la linea - if ( ! pCrvLine->SetPVL( ptIniL, vtDirL, dLen)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvLine->SetExtrusion( vtExtrL) ; - // inserisco la linea nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtLinePVL(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Vector3d( vtDir)) + "}," + - ToString( dLen) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveLinePVL( nParentId, ptIni, vtDir, dLen, nRefType) ; } //------------------------------------------------------------------------------- @@ -518,58 +47,7 @@ int __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, const double ptStart[3], int nCrvId, double dNearPar, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale il punto e il versore estrusione - Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // recupero il riferimento della curva - Frame3d frCurve ; - if ( ! pGeomDB->GetGlobFrame( nCrvId, frCurve)) - return GDB_ID_NULL ; - // recupero la curva - const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ; - if ( pCurve == nullptr) - return GDB_ID_NULL ; - // porto il punto nel riferimento della curva - Point3d ptStartC = ptStart ; - ptStartC.LocToLoc( frLoc, frCurve) ; - // calcolo il punto a minima distanza - int nFlag ; - Point3d ptEndL ; - DistPointCurve dstPtCurve( ptStartC, *pCurve) ; - if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEndL, nFlag)) - return GDB_ID_NULL ; - // porto il punto finale nel riferimento di creazione - ptEndL.LocToLoc( frCurve, frLoc) ; - // creo la linea - PtrOwner pCrvLine( CreateCurveLine()) ; - if ( IsNull( pCrvLine)) - return GDB_ID_NULL ; - // setto la linea - if ( ! pCrvLine->Set( ptStartL, ptEndL)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvLine->SetExtrusion( vtExtrL) ; - // inserisco la linea nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptStart)) + "}," + - ToString( nCrvId) + "," + - ToString( dNearPar) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveLineMinPointCurve( nParentId, ptStart, nCrvId, dNearPar, nRefType) ; } //------------------------------------------------------------------------------- @@ -577,81 +55,16 @@ int __stdcall EgtCreateCurveCircle( int nParentId, const double ptCen[3], const double vtN[3], double dRad, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti e i versori - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto la circonferenza - if ( ! pCrvArc->Set( ptCenL, vtNL, dRad)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCircle(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - ToString( dRad) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCircle( nParentId, ptCen, vtN, dRad, nRefType) ; } + //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3], const double ptOn[3], const double vtN[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - bool bOk = ! IsNull( pCrvArc) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti e i versori - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // calcolo il raggio - double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ; - // setto la circonferenza - bOk = bOk && pCrvArc->Set( ptCenL, vtNL, dRad) ; - // assegno il versore estrusione - bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCircleCPN(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptOn)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCircleCPN( nParentId, ptCen, ptOn, vtN, nRefType) ; } //------------------------------------------------------------------------------- @@ -659,58 +72,7 @@ int __stdcall EgtCreateCurveCircleCPNEx( int nParentId, const double ptCen[3], const double ptOn[3], int nSepO, int nIdO, const double vtN[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti e i versori - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // se punto standard - if ( nSepO == SEP_STD) { - pCrvArc.Set( CreateCurveArc()) ; - bOk = bOk && ! IsNull( pCrvArc) ; - // calcolo il raggio - double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ; - // setto la circonferenza - bOk = bOk && pCrvArc->Set( ptCenL, vtNL, dRad) ; - } - // se punto di tangenza, determino il vero punto di passaggio - else if ( nSepO == SEP_TG) { - // recupero la curva di tangenza in locale - CurveLocal CrvTgLoc( pGeomDB, nIdO, frLoc) ; - // calcolo la circonferenza tangente a questa curva - pCrvArc.Set( GetCircleCenTgCurve( ptCenL, vtNL, *CrvTgLoc.Get(), ptOnL)) ; - bOk = bOk && ! IsNull( pCrvArc) ; - } - // altrimenti errore - else - bOk = false ; - // assegno il versore estrusione - bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCircleCPNEx(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptOn)) + "}," + - SepToString( nSepO) + "," + - ToString( nIdO) + ",{" + - ToString( Vector3d( vtN)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateCurveCircleCPNEx( nParentId, ptCen, ptOn, nSepO, nIdO, vtN, nRefType) ; } //------------------------------------------------------------------------------- @@ -718,41 +80,7 @@ int __stdcall EgtCreateCurveCircle3P( int nParentId, const double ptP1[3], const double ptP2[3], const double ptP3[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti e il versore estrusione - Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; - Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ; - Point3d ptP3L = GetPointLocal( pGeomDB, ptP3, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto l'arco - if ( ! pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, true)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCircle3P(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptP1)) + "},{" + - ToString( Point3d( ptP2)) + "},{" + - ToString( Point3d( ptP3)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCircle3P( nParentId, ptP1, ptP2, ptP3, nRefType) ; } //------------------------------------------------------------------------------- @@ -761,44 +89,7 @@ __stdcall EgtCreateCurveArc( int nParentId, const double ptCen[3], const double vtN[3], double dRad, const double vtS[3], double dAngCenDeg, double dDeltaN, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtSL = GetVectorLocal( pGeomDB, vtS, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto l'arco - if ( ! pCrvArc->Set( ptCenL, vtNL, dRad, vtSL, dAngCenDeg, dDeltaN)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArc(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - ToString( dRad) + ",{" + - ToString( Vector3d( vtS)) + "}," + - ToString( dAngCenDeg) + "," + - ToString( dDeltaN) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveArc( nParentId, ptCen, vtN, dRad, vtS, dAngCenDeg, dDeltaN, nRefType) ; } //------------------------------------------------------------------------------- @@ -806,104 +97,14 @@ int __stdcall EgtCreateCurveArcC2PN( int nParentId, const double ptCen[3], const double ptStart[3], const double ptNearEnd[3], const double vtNorm[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; - Point3d ptNearEndL = GetPointLocal( pGeomDB, ptNearEnd, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto l'arco - if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL)) - return GDB_ID_NULL ; - // assegno il versore estrusione - pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArcC2PN(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptStart)) + "},{" + - ToString( Point3d( ptNearEnd)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveArcC2PN( nParentId, ptCen, ptStart, ptNearEnd, vtNorm, nRefType) ; } - -//------------------------------------------------------------------------------- int __stdcall EgtCreateCurveArcC2PNEx( int nParentId, const double ptCen[3], const double ptStart[3], int nSepS, int nIdS, const double ptNearEnd[3], const double vtNorm[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; - Point3d ptNearEndL = GetPointLocal( pGeomDB, ptNearEnd, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // se punto standard - if ( nSepS == SEP_STD) { - pCrvArc.Set( CreateCurveArc()) ; - bOk = bOk && ! IsNull( pCrvArc) ; - // setto l'arco - if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL)) - return GDB_ID_NULL ; - } - // se punto di tangenza, determino il vero punto di passaggio - else if ( nSepS == SEP_TG) { - // recupero la curva di tangenza in locale - CurveLocal CrvTgLoc( pGeomDB, nIdS, frLoc) ; - // calcolo l'arco tangente a questa curva - pCrvArc.Set( GetArcCenTgCurvePnt( ptCenL, *CrvTgLoc.Get(), ptStartL, ptNearEndL, vtNormL)) ; - bOk = bOk && ! IsNull( pCrvArc) ; - } - // altrimenti errore - else - bOk = false ; - // assegno il versore estrusione - bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArcC2PNEx(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptStart)) + "},{" + - SepToString( nSepS) + "," + - ToString( nIdS) + ",{" + - ToString( Point3d( ptNearEnd)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateCurveArcC2PNEx( nParentId, ptCen, ptStart, nSepS, nIdS, ptNearEnd, vtNorm, nRefType) ; } //------------------------------------------------------------------------------- @@ -911,39 +112,7 @@ int __stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3], const double ptP2[3], const double ptP3[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrv ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti e il versore estrusione - Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; - Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ; - Point3d ptP3L = GetPointLocal( pGeomDB, ptP3, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto l'arco - pCrv.Set( GetArc3P( ptP1L, ptP2L, ptP3L, false)) ; - bOk = bOk && ! ( IsNull( pCrv)) ; - // assegno il versore estrusione - bOk = bOk && pCrv->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptP1)) + "},{" + - ToString( Point3d( ptP2)) + "},{" + - ToString( Point3d( ptP3)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveArc3P( nParentId, ptP1, ptP2, ptP3, nRefType) ; } //------------------------------------------------------------------------------- @@ -951,41 +120,7 @@ int __stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const double ptEnd[3], const double vtDirS[3], const double vtNorm[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco (in casi particolari retta) - PtrOwner pCrv ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; - Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ; - Vector3d vtDirSL = GetVectorLocal( pGeomDB, vtDirS, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // setto l'arco - pCrv.Set( GetArc2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) ; - bOk = bOk && ! IsNull( pCrv) ; - // assegno il versore estrusione - bOk = bOk && pCrv->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArc2PVN(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptStart)) + "},{" + - ToString( Point3d( ptEnd)) + "},{" + - ToString( Vector3d( vtDirS)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveArc2PVN( nParentId, ptStart, ptEnd, vtDirS, vtNorm, nRefType) ; } //------------------------------------------------------------------------------- @@ -994,72 +129,7 @@ __stdcall EgtCreateCurveArc2PVNEx( int nParentId, const double ptStart[3], const double ptEnd[3], int nSep, int nId, const double vtDirS[3], const double vtNorm[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo la curva ( in casi particolari potrebbe essere una retta) - PtrOwner pCrv ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; - Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ; - Vector3d vtDirSL = GetVectorLocal( pGeomDB, vtDirS, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // se punto standard - if ( nSep == SEP_STD) { - // creo l'arco - pCrv.Set( CreateCurveArc()) ; - bOk = bOk && ! IsNull( pCrv) ; - if ( bOk) { - // imposto l'arco - if ( (dynamic_cast(Get(pCrv)))->Set2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) - ; - // non riuscito, provo se risulta essere una retta - else if ( ( ptEndL - ptStartL) * vtDirSL > EPS_ZERO) { - // creo e setto la retta - pCrv.Set( CreateCurveLine()) ; - bOk = bOk && ! IsNull( pCrv) ; - bOk = bOk && (dynamic_cast(Get(pCrv)))->Set( ptStartL, ptEndL) ; - } - // impossibile - else - bOk = false ; - } - } - // se punto di tangenza, determino il vero punto di passaggio - else if ( nSep == SEP_TG) { - // recupero la curva di tangenza in locale - CurveLocal CrvTgLoc( pGeomDB, nId, frLoc) ; - // calcolo l'arco tangente a questa curva - pCrv.Set( GetArcPntDirTgCurve( ptStartL, vtDirSL, *CrvTgLoc.Get(), ptEndL, vtNormL)) ; - bOk = bOk && ! IsNull( pCrv) ; - } - // altrimenti errore - else - bOk = false ; - // assegno il versore estrusione - bOk = bOk && pCrv->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArc2PVNEx(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptStart)) + "},{" + - ToString( Point3d( ptEnd)) + "}," + - SepToString( nSep) + "," + - ToString( nId) + ",{" + - ToString( Vector3d( vtDirS)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateCurveArc2PVNEx( nParentId, ptStart, ptEnd, nSep, nId, vtDirS, vtNorm, nRefType) ; } //------------------------------------------------------------------------------- @@ -1068,61 +138,7 @@ __stdcall EgtCreateCurveFillet( int nParentId, int nCrv1, const double ptNear1[3 int nCrv2, const double ptNear2[3], const double vtNorm[3], double dRad, BOOL bTrim, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pArc ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptNear1L = GetPointLocal( pGeomDB, ptNear1, nRefType, frLoc) ; - Point3d ptNear2L = GetPointLocal( pGeomDB, ptNear2, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // recupero la copia locale delle curve - CurveLocal CrvLoc1( pGeomDB, nCrv1, frLoc) ; - CurveLocal CrvLoc2( pGeomDB, nCrv2, frLoc) ; - // calcolo il raccordo - double dTrim1, dTrim2 ; - pArc.Set( CreateFillet( *CrvLoc1.Get(), ptNear1L, *CrvLoc2.Get(), ptNear2L, vtNormL, dRad, dTrim1, dTrim2)) ; - bOk = bOk && ! IsNull( pArc) ; - // assegno il versore estrusione - bOk = bOk && pArc->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pArc)) : GDB_ID_NULL) ; - // se richiesto trim - if ( nNewId != GDB_ID_NULL && bTrim) { - // recupero e aggiusto la prima curva - ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nCrv1)) ; - if ( dTrim1 > EPS_ZERO) - pCrv1->TrimStartAtParam( dTrim1) ; - else if ( dTrim1 < - EPS_ZERO) - pCrv1->TrimEndAtParam( fabs( dTrim1)) ; - // recupero e aggiusto la seconda curva - ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nCrv2)) ; - if ( dTrim2 > EPS_ZERO) - pCrv2->TrimStartAtParam( dTrim2) ; - else if ( dTrim2 < - EPS_ZERO) - pCrv2->TrimEndAtParam( fabs( dTrim2)) ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveFillet(" + ToString( nParentId) + "," + - ToString( nCrv1) + ",{" + - ToString( Point3d( ptNear1)) + "}," + - ToString( nCrv2) + ",{" + - ToString( Point3d( ptNear2)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - ToString( dRad) + "," + - ( bTrim ? "true" : "false") + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return nNewId ; + return ExeCreateCurveFillet( nParentId, nCrv1, ptNear1, nCrv2, ptNear2, vtNorm, dRad, ( bTrim != FALSE), nRefType) ; } //------------------------------------------------------------------------------- @@ -1131,61 +147,7 @@ __stdcall EgtCreateCurveChamfer( int nParentId, int nCrv1, const double ptNear1[ int nCrv2, const double ptNear2[3], const double vtNorm[3], double dDist, BOOL bTrim, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo la linea - PtrOwner pLine ; - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptNear1L = GetPointLocal( pGeomDB, ptNear1, nRefType, frLoc) ; - Point3d ptNear2L = GetPointLocal( pGeomDB, ptNear2, nRefType, frLoc) ; - Vector3d vtNormL = GetVectorLocal( pGeomDB, vtNorm, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // recupero la copia locale delle curve - CurveLocal CrvLoc1( pGeomDB, nCrv1, frLoc) ; - CurveLocal CrvLoc2( pGeomDB, nCrv2, frLoc) ; - // calcolo lo smusso - double dTrim1, dTrim2 ; - pLine.Set( CreateChamfer( *CrvLoc1.Get(), ptNear1L, *CrvLoc2.Get(), ptNear2L, vtNormL, dDist, dTrim1, dTrim2)) ; - bOk = bOk && ! IsNull( pLine) ; - // assegno il versore estrusione - bOk = bOk && pLine->SetExtrusion( vtExtrL) ; - // inserisco l'arco nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) : GDB_ID_NULL) ; - // se richiesto trim - if ( nNewId != GDB_ID_NULL && bTrim) { - // recupero e aggiusto la prima curva - ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nCrv1)) ; - if ( dTrim1 > EPS_ZERO) - pCrv1->TrimStartAtParam( dTrim1) ; - else if ( dTrim1 < - EPS_ZERO) - pCrv1->TrimEndAtParam( fabs( dTrim1)) ; - // recupero e aggiusto la seconda curva - ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nCrv2)) ; - if ( dTrim2 > EPS_ZERO) - pCrv2->TrimStartAtParam( dTrim2) ; - else if ( dTrim2 < - EPS_ZERO) - pCrv2->TrimEndAtParam( fabs( dTrim2)) ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveChamfer(" + ToString( nParentId) + "," + - ToString( nCrv1) + ",{" + - ToString( Point3d( ptNear1)) + "}," + - ToString( nCrv2) + ",{" + - ToString( Point3d( ptNear2)) + "},{" + - ToString( Vector3d( vtNorm)) + "}," + - ToString( dDist) + "," + - ( bTrim ? "true" : "false") + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return nNewId ; + return ExeCreateCurveChamfer( nParentId, nCrv1, ptNear1, nCrv2, ptNear2, vtNorm, dDist, ( bTrim != FALSE), nRefType) ; } //------------------------------------------------------------------------------- @@ -1197,59 +159,7 @@ __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls for ( int i = 0 ; i <= nDegree ; ++i) { vPnt.emplace_back( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2]) ; } - return EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // il numero dei punti deve essere pari al grado + 1 - bOk = bOk && ( vPnt.size() == nDegree + 1) ; - // recupero il riferimento di immersione della curva - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // creo la curva di Bezier - PtrOwner pCrvBez( CreateCurveBezier()) ; - bOk = bOk && ! IsNull( pCrvBez) ; - // inizializzo la curva di Bezier - bOk = bOk && pCrvBez->Init( nDegree, false) ; - // setto i punti di controllo - for ( int i = 0 ; i <= nDegree && bOk ; ++ i) { - // eventuale trasformazione del punto nel riferimento locale - Point3d ptCtrl = GetPointLocal( pGeomDB, vPnt[i].v, nRefType, frLoc) ; - // inserimento del punto di controllo - if ( ! pCrvBez->SetControlPoint( i, ptCtrl)) - bOk = false ; - } - // se curva nulla (ovvero ridotta a punto), errore - bOk = bOk && ! pCrvBez->IsAPoint() ; - // assegno il versore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - pCrvBez->SetExtrusion( vtExtrL) ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sPC ; - for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { - if ( i > 0) - sPC += "," ; - sPC += "{" + ToString( vPnt[i]) + "}" ; - } - string sLua = "EgtCurveBezier(" + ToString( nParentId) + "," + - ToString( nDegree) + ",{" + - sPC + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; } //------------------------------------------------------------------------------- @@ -1261,107 +171,14 @@ __stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double for ( int i = 0 ; i <= nDegree ; ++i) { vPntW.emplace_back( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3]) ; } - return EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // il numero dei punti deve essere pari al grado + 1 - bOk = bOk && ( vPntW.size() == nDegree + 1) ; - // recupero il riferimento di immersione della curva - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // creo la curva di Bezier - PtrOwner pCrvBez( CreateCurveBezier()) ; - bOk = bOk && ! IsNull( pCrvBez) ; - // inizializzo la curva di Bezier - bOk = bOk && pCrvBez->Init( nDegree, true) ; - // setto i punti di controllo - for ( int i = 0 ; i <= nDegree && bOk ; ++ i) { - // eventuale trasformazione del punto nel riferimento locale - Point3d ptCtrl = GetPointLocal( pGeomDB, vPntW[i].first.v, nRefType, frLoc) ; - // inserimento del punto di controllo con peso - if ( ! pCrvBez->SetControlPoint( i, ptCtrl, vPntW[i].second)) - return GDB_ID_NULL ; - } - // se curva nulla (ovvero ridotta a punto), errore - bOk = bOk && ! pCrvBez->IsAPoint() ; - // assegno il versore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - pCrvBez->SetExtrusion( vtExtrL) ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sPC ; - for ( size_t i = 0 ; i < vPntW.size() ; ++ i) { - if ( i > 0) - sPC += "," ; - sPC += "{" + ToString( vPntW[i].first, vPntW[i].second) + "}" ; - } - string sLua = "EgtCurveBezierRat(" + ToString( nParentId) + "," + - ToString( nDegree) + ",{" + - sPC + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveBezierFromArc( int nParentId, int nArcId, BOOL bErase) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // creo la curva di Bezier - PtrOwner pCrvBez( CreateCurveBezier()) ; - bOk = bOk && ! IsNull( pCrvBez) ; - // recupero l'arco - const ICurveArc* pCrvArc = GetCurveArc( pGeomDB->GetGeoObj( nArcId)) ; - bOk = bOk && ( pCrvArc != nullptr) ; - // ne deduco la curva di Bezier - bOk = bOk && pCrvBez->FromArc( *pCrvArc) ; - // recupero il riferimento dell'arco - Frame3d frSou ; - bOk = bOk && pGeomDB->GetGlobFrame( nArcId, frSou) ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; - // porto la curva di Bezier dal riferimento dell'arco a quello di inserimento - if ( bOk && ! AreSameFrame( frSou, frDest)) - pCrvBez->LocToLoc( frSou, frDest) ; - // se curva nulla (ovvero ridotta a punto), errore - bOk = bOk && ! pCrvBez->IsAPoint() ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) : GDB_ID_NULL) ; - if ( nId != GDB_ID_NULL) { - // se richiesto, cancello l'arco originale - if ( bErase) { - if ( ! pGeomDB->Erase( nArcId)) - return GDB_ID_NULL ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveBezierFromArc(" + ToString( nParentId) + "," + - ToString( nArcId) + "," + - ( bErase ? "true" : "false") + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveBezierFromArc( nParentId, nArcId, ( bErase != FALSE)) ; } //------------------------------------------------------------------------------- @@ -1373,90 +190,7 @@ __stdcall EgtCreateCurveCompo( int nParentId, int nNumId, const int nIds[], BOOL for ( int i = 0 ; i < nNumId ; ++i) { vIds.push_back( nIds[i]) ; } - return EgtCreateCurveCompo( nParentId, vIds, ( bErase != FALSE)) ; -} - -//------------------------------------------------------------------------------- -static int -MyCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return GDB_ID_NULL ; - // estrusione e spessore - Vector3d vtExtr = CalcExtrusion( pGeomDB, nParentId, RTY_GRID) ; - double dThick = 0 ; - // esecuzione - INTVECTOR::const_iterator Iter ; - for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) { - // recupero la curva - int nIdCrv = *Iter ; - const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nIdCrv)) ; - if ( pCrv == nullptr) - return GDB_ID_NULL ; - // recupero il riferimento della curva - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nIdCrv, frSou)) - return GDB_ID_NULL ; - // creo una copia della curva - PtrOwner pCopCrv( pCrv->Clone()) ; - if ( IsNull( pCopCrv)) - return GDB_ID_NULL ; - // se i riferimenti sono diversi, eseguo la trasformazione - if ( ! AreSameFrame( frSou, frDest)) - pCopCrv->LocToLoc( frSou, frDest) ; - // recupero eventuali estrusione (già nel riferimento destinazione) e spessore - Vector3d vtTemp ; - if ( pCopCrv->GetExtrusion( vtTemp)) { - vtExtr = vtTemp ; - double dTemp ; - if ( pCopCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick)) - dThick = dTemp ; - } - // aggiungo alla composita - if ( ! pCrvCompo->AddCurve( Release( pCopCrv))) - return GDB_ID_NULL ; - } - // imposto estrusione e spessore - pCrvCompo->SetExtrusion( vtExtr) ; - pCrvCompo->SetThickness( dThick) ; - // inserisco la curva composita nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ; - EgtSetModified() ; - // se ok e richiesto, cancello le curve originali - if ( nId != GDB_ID_NULL && bErase) { - for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) { - if ( ! pGeomDB->Erase( *Iter)) - return GDB_ID_NULL ; - } - } - // restituisco l'identificativo della nuova entità - return nId ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) -{ - // eseguo - int nId = MyCreateCurveCompo( nParentId, vIds, bErase) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveCompo(" + ToString( nParentId) + ",{" + - IdListToString( vIds) + "}," + - ( bErase ? "true" : "false") + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCompo( nParentId, vIds, ( bErase != FALSE)) ; } //------------------------------------------------------------------------------- @@ -1469,155 +203,7 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, int nNumId, const int nIds[ for ( int i = 0 ; i < nNumId ; ++i) { vIds.push_back( nIds[i]) ; } - return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE), nRefType, nullptr) ; -} - -//------------------------------------------------------------------------------- -static int -MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - return GDB_ID_NULL ; - // preparo i dati per il concatenamento - double dToler = 10 * EPS_SMALL ; - ChainCurves chainC ; - chainC.Init( true, dToler, int( vIds.size())) ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // recupero la curva e il suo riferimento - ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCrv == nullptr) - return GDB_ID_NULL ; - Frame3d frCrv ; - if ( ! pGeomDB->GetGlobFrame( nId, frCrv)) - return GDB_ID_NULL ; - // recupero i dati della curva necessari al concatenamento e li assegno - Point3d ptStart, ptEnd ; - Vector3d vtStart, vtEnd ; - if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) || - ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd)) - return GDB_ID_NULL ; - ptStart.LocToLoc( frCrv, frDest) ; - vtStart.LocToLoc( frCrv, frDest) ; - ptEnd.LocToLoc( frCrv, frDest) ; - vtEnd.LocToLoc( frCrv, frDest) ; - if ( ! chainC.AddCurve( nId, ptStart, vtStart, ptEnd, vtEnd)) - return GDB_ID_NULL ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - // recupero i percorsi concatenati - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - Point3d ptNearL = GetPointLocal( pGeomDB, ptNear.v, nRefType, frDest) ; - INTVECTOR vId2s ; - while ( chainC.GetChainFromNear( ptNearL, false, vId2s)) { - // creo una curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; - // estrusione e spessore - Vector3d vtExtr = CalcExtrusion( pGeomDB, nParentId, nRefType) ; - double dThick = 0 ; - // recupero le curve semplici e le inserisco nella curva composita - for ( size_t i = 0 ; i < vId2s.size() ; ++ i) { - int nId = abs( vId2s[i]) ; - bool bInvert = ( vId2s[i] < 0) ; - // recupero la curva e il suo riferimento - ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCrv == nullptr) - return GDB_ID_NULL ; - Frame3d frCrv ; - if ( ! pGeomDB->GetGlobFrame( nId, frCrv)) - return GDB_ID_NULL ; - // copio la curva - PtrOwner pCopCrv( pCrv->Clone()) ; - if ( IsNull( pCopCrv)) - return GDB_ID_NULL ; - // se necessario, la inverto - if ( bInvert) - pCopCrv->Invert() ; - // la sistemo per i riferimenti - pCopCrv->LocToLoc( frCrv, frDest) ; - // recupero eventuali estrusione (già nel riferimento destinazione) e spessore - Vector3d vtTemp ; - if ( pCopCrv->GetExtrusion( vtTemp)) { - vtExtr = vtTemp ; - double dTemp ; - if ( pCopCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick)) - dThick = dTemp ; - } - // la aggiungo alla curva composta - if ( ! pCrvCompo->AddCurve( ::Release( pCopCrv), true, dToler)) - return GDB_ID_NULL ; - } - // se non sono state inserite curve, vado oltre - if ( pCrvCompo->GetCurveNumber() == 0) - continue ; - // imposto estrusione e spessore - pCrvCompo->SetExtrusion( vtExtr) ; - pCrvCompo->SetThickness( dThick) ; - // aggiorno il nuovo punto vicino - pCrvCompo->GetEndPoint( ptNearL) ; - // inserisco la curva composita nel gruppo destinazione - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, ::Release( pCrvCompo)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nCount ; - } - // se richiesto e ok, cancello le curve originali - if ( bErase && nFirstId != GDB_ID_NULL) { - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - pGeomDB->Erase( nId) ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; - } - } - } - // restituisco l'identificativo della prima nuova entità - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) -{ - // eseguo - int nCount = 0 ; - int nFirstId = MyCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType, &nCount) ; - if ( pnCount != nullptr) - *pnCount = nCount ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" + - IdListToString( vIds) + "},{" + - ToString( ptNear) + "}," + - ( bErase ? "true" : "false") + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della prima nuova entità - return nFirstId ; + return ExeCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE), nRefType, nullptr) ; } //------------------------------------------------------------------------------- @@ -1628,50 +214,7 @@ __stdcall EgtCreateCurveCompoFromPoints( int nParentId, int nP, const double ptP for ( int i = 0 ; i < nP ; ++i) { PL.AddUPoint( 0, Point3d( ptPs[3*i], ptPs[3*i+1], ptPs[3*i+2])) ; } - return EgtCreateCurveCompoFromPoints( nParentId, PL, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCrvCompo) ; - // inserisco i segmenti che uniscono i punti - bOk = bOk && pCrvCompo->FromPolyLine( PL) ; - // assegno il versore estrusione - bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ; - // eventuale trasformazione per riferimento di espressione dei punti - if ( bOk && nRefType == RTY_GLOB) - pCrvCompo->ToLoc( frDest) ; - else if ( bOk && nRefType == RTY_GRID) - pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; - // inserisco la curva composita nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sPnt ; - Point3d ptP ; - if ( PL.GetFirstPoint( ptP)) - sPnt += "{" + ToString( ptP) + "}" ; - while ( PL.GetNextPoint( ptP)) - sPnt += ",{" + ToString( ptP) + "}" ; - string sLua = "EgtCurveCompoFromPoints(" + ToString( nParentId) + ",{" + - sPnt + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCompoFromPoints( nParentId, PL, nRefType) ; } //------------------------------------------------------------------------------- @@ -1682,108 +225,14 @@ __stdcall EgtCreateCurveCompoFromPointBulges( int nParentId, int nPB, const doub for ( int i = 0 ; i < nPB ; ++i) { PA.AddUPoint( 0, Point3d( ptPBs[4*i], ptPBs[4*i+1], ptPBs[4*i+2]), ptPBs[4*i+3]) ; } - return EgtCreateCurveCompoFromPointBulges( nParentId, PA, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCrvCompo) ; - // inserisco i segmenti e gli archi che uniscono i punti - bOk = bOk && pCrvCompo->FromPolyArc( PA) ; - // assegno il versore estrusione - bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ; - // eventuale trasformazione per riferimento di espressione dei punti - if ( bOk && nRefType == RTY_GLOB) - pCrvCompo->ToLoc( frDest) ; - else if ( bOk && nRefType == RTY_GRID) - pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; - // inserisco la curva composita nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sPnt ; - double dB ; - Point3d ptP ; - if ( PA.GetFirstPoint( ptP, dB)) - sPnt += "{" + ToString( ptP) + "," + ToString( dB) + "}" ; - while ( PA.GetNextPoint( ptP, dB)) - sPnt += ",{" + ToString( ptP) + "," + ToString( dB) + "}" ; - string sLua = "EgtCurveCompoFromPointBulges(" + ToString( nParentId) + ",{" + - sPnt + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCompoFromPointBulges( nParentId, PA, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLines, double dLinTol) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento di inserimento - Frame3d frEnt ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frEnt) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nSouId, frEnt) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // eseguo l'approssimazione - PtrOwner pCC( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCC) ; - const double ANG_TOL_STD_DEG = 15 ; - if ( ! bArcsVsLines) { // con linee - PolyLine PL ; - bOk = bOk && CrvLoc.Get()->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ; - } - else { // con bi-archi - PolyArc PA ; - bOk = bOk && CrvLoc.Get()->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) && pCC->FromPolyArc( PA) ; - } - // copio estrusione e spessore della curva sorgente - const ICurve* pSouCrv = GetCurve( pGeomDB->GetGeoObj( nSouId)) ; - if ( bOk && pSouCrv != nullptr) { - // recupero estrusione e spessore - Vector3d vtExtr ; - pSouCrv->GetExtrusion( vtExtr) ; - double dThick ; - pSouCrv->GetThickness( dThick) ; - // sistemo per eventuale cambio di riferimento - Frame3d frSou ; - bOk = bOk && pGeomDB->GetGlobFrame( nSouId, frSou) ; - vtExtr.LocToLoc( frSou, frEnt) ; - // assegno - pCC->SetExtrusion( vtExtr) ; - pCC->SetThickness( dThick) ; - } - // inserisco la curva composita nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCurveCompoByApprox(" + ToString( nParentId) + "," + - ToString( nSouId) + "," + - ( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateCurveCompoByApprox( nParentId, nSouId, ( bArcsVsLines != FALSE), dLinTol) ; } //------------------------------------------------------------------------------- @@ -1791,54 +240,7 @@ int __stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3], const double ptCross[3], const double ptDir[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, i versori e il versore estrusione - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ; - Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // calcolo il lato X - Vector3d vtDirX = ptDirL - ptIniL ; - bOk = bOk && vtDirX.Normalize() ; - Vector3d vtLatoX = bOk ? (( ptCrossL - ptIniL) * vtDirX) * vtDirX : V_NULL ; - // creo la polilinea con i punti - int nId = GDB_ID_NULL ; - if ( bOk) { - PolyLine PL ; - PL.AddUPoint( 0, ptIniL) ; - PL.AddUPoint( 1, Point3d( ptIniL) + vtLatoX) ; - PL.AddUPoint( 2, ptCrossL) ; - PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ; - PL.AddUPoint( 4, ptIniL) ; - // disabilito log dei comandi e salvo stato precedente - bool bPrevCmdLog = SetCmdLog( false) ; - // creo la curva e la inserisco nel GDB - nId = EgtCreateCurveCompoFromPoints( nParentId, PL, RTY_LOC) ; - // ripristino precedente stato dei comandi - SetCmdLog( bPrevCmdLog) ; - // ne sistemo il vettore estrusione - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve != nullptr) - pCurve->SetExtrusion( vtExtrL) ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRectangle3P(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptCross)) + "},{" + - ToString( Point3d( ptDir)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreateRectangle3P( nParentId, ptIni, ptCross, ptDir, nRefType) ; } //------------------------------------------------------------------------------- @@ -1846,41 +248,7 @@ int __stdcall EgtCreatePolygonFromRadius( int nParentId, int nNumSides, const double ptCen[3], const double ptCorn[3], const double vtN[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, la normale e il versore estrusione - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptCornL = GetPointLocal( pGeomDB, ptCorn, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCrvCompo) ; - // setto la curva - bOk = bOk && pCrvCompo->PolygonCenterCorner( nNumSides, ptCenL, ptCornL, vtNL) ; - // assegno il versore estrusione - bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtPolygonFromRadius(" + ToString( nParentId) + "," + - ToString( nNumSides) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptCorn)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreatePolygonFromRadius( nParentId, nNumSides, ptCen, ptCorn, vtN, nRefType) ; } //------------------------------------------------------------------------------- @@ -1888,41 +256,7 @@ int __stdcall EgtCreatePolygonFromApothem( int nParentId, int nNumSides, const double ptCen[3], const double ptMid[3], const double vtN[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, la normale e il versore estrusione - Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; - Point3d ptMidL = GetPointLocal( pGeomDB, ptMid, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCrvCompo) ; - // setto la curva - bOk = bOk && pCrvCompo->PolygonCenterMidSide( nNumSides, ptCenL, ptMidL, vtNL) ; - // assegno il versore estrusione - bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtPolygonFromApothem(" + ToString( nParentId) + "," + - ToString( nNumSides) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Point3d( ptMid)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; + return ExeCreatePolygonFromApothem( nParentId, nNumSides, ptCen, ptMid, vtN, nRefType) ; } //------------------------------------------------------------------------------- @@ -1930,59 +264,5 @@ int __stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, const double ptIni[3], const double ptFin[3], const double vtN[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, la normale e il versore estrusione - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptFinL = GetPointLocal( pGeomDB, ptFin, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX.v, nRefType, frLoc) ; - // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCrvCompo) ; - // setto la curva - bOk = bOk && pCrvCompo->PolygonSide( nNumSides, ptIniL, ptFinL, vtNL) ; - // assegno il versore estrusione - bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ; - // inserisco la curva nel DB - int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtPolygonFromSide(" + ToString( nParentId) + "," + - ToString( nNumSides) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptFin)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nId ; -} - -//------------------------------------------------------------------------------- -Vector3d -CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType) -{ - // verifica sul parametro - if ( pGeomDB == nullptr) - return Z_AX ; - // riferimento dell'entità - Frame3d frEnt ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt)) - return false ; - // versore estrusione - Vector3d vtExtr = Z_AX ; - if ( nRefType == RTY_GLOB) - vtExtr.ToLoc( frEnt) ; - else if ( nRefType == RTY_GRID) - vtExtr.LocToLoc( pGeomDB->GetGridFrame(), frEnt) ; - return vtExtr ; + return ExeCreatePolygonFromSide( nParentId, nNumSides, ptIni, ptFin, vtN, nRefType) ; } diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index 609d286..53e6cf3 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -14,18 +14,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkStmStandard.h" -#include "/EgtDev/Include/EGkStmFromCurves.h" -#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" -#include "/EgtDev/Include/EgkStringUtils3d.h" -#include "/EgtDev/Include/EgkGeoPoint3d.h" -#include "/EgtDev/Include/EgkCurveLocal.h" -#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; @@ -40,54 +30,7 @@ __stdcall EgtCreateSurfTmBBox( int nParentId, const double ptMin[3], const doubl ptMin[2] < ( ptMax[2] + EPS_SMALL)) b3Box.Set( ptMin, ptMax) ; // eseguo - return EgtCreateSurfTmBBox( nParentId, b3Box, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateSurfTmBBox( int nParentId, const BBox3d& b3Box, int nRefType) -{ - // bounding box orientato come gli assi del riferimento - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il riferimento locale - Frame3d frLoc ; - bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // ricavo i punti standard e le dimensioni - Point3d ptIni ; - double dWidth = 0, dLen = 0, dHeight = 0 ; - bOk = bOk && b3Box.GetMinDim( ptIni, dWidth, dLen, dHeight) ; - dWidth = max( dWidth, 10 * EPS_SMALL) ; - dLen = max( dLen, 10 * EPS_SMALL) ; - dHeight = max( dHeight, 10 * EPS_SMALL) ; - Point3d ptCross = ptIni + Vector3d( dWidth, dLen) ; - Point3d ptDir = ptIni + Vector3d( dWidth, 0) ; - // porto in locale i punti - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni.v, nRefType, frLoc) ; - Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross.v, nRefType, frLoc) ; - Point3d ptDirL = GetPointLocal( pGeomDB, ptDir.v, nRefType, frLoc) ; - // ne ricavo un riferimento intrinseco - Frame3d frBox ; - bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ; - // creo il box nel suo riferimento intrinseco - PtrOwner pSTM( GetSurfTriMeshBox( dWidth, dLen, dHeight)) ; - bOk = bOk && ! IsNull( pSTM) ; - // porto il box nel riferimento locale - bOk = bOk && pSTM->ToGlob( frBox) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmBBox(" + ToString( nParentId) + ",{{" + - ToString( b3Box.GetMin()) + "},{" + - ToString( b3Box.GetMax()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmBBox( nParentId, b3Box, nRefType) ; } //------------------------------------------------------------------------------- @@ -95,47 +38,7 @@ int __stdcall EgtCreateSurfTmBox( int nParentId, const double ptIni[3], const double ptCross[3], const double ptDir[3], double dHeight, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il riferimento locale - Frame3d frLoc ; - bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale i punti - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ; - Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ; - // ne ricavo un riferimento intrinseco - Frame3d frBox ; - bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ; - // ricavo le dimensioni della base - Point3d ptCrossI = ptCrossL ; - ptCrossI.ToLoc( frBox) ; - double dWidth = ptCrossI.x ; - double dLen = ptCrossI.y ; - // creo il box nel suo riferimento intrinseco - PtrOwner pSTM( GetSurfTriMeshBox( fabs( dWidth), dLen, dHeight)) ; - bOk = bOk && ! IsNull( pSTM) ; - // eventuale traslazione per larghezza negativa - if ( dWidth < 0) - pSTM->Translate( Vector3d( dWidth, 0, 0)) ; - // porto il box nel riferimento locale - bOk = bOk && pSTM->ToGlob( frBox) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmBox(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptCross)) + "},{" + - ToString( Point3d( ptDir)) + "}," + - ToString( dHeight) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmBox( nParentId, ptIni, ptCross, ptDir, dHeight, nRefType) ; } //------------------------------------------------------------------------------- @@ -143,49 +46,7 @@ int __stdcall EgtCreateSurfTmPyramid( int nParentId, const double ptIni[3], const double ptCross[3], const double ptDir[3], double dHeight, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti - Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; - Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ; - Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ; - // ne ricavo un riferimento intrinseco - Frame3d frBox ; - bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ; - // ricavo le dimensioni della base - Point3d ptCrossI = ptCrossL ; - ptCrossI.ToLoc( frBox) ; - double dWidth = ptCrossI.x ; - double dLen = ptCrossI.y ; - // creo la piramide nel suo riferimento intrinseco - PtrOwner pSTM( GetSurfTriMeshPyramid( fabs( dWidth), dLen, dHeight)) ; - bOk = bOk && ! IsNull( pSTM) ; - // eventuale traslazione per larghezza negativa - if ( dWidth < 0) - pSTM->Translate( Vector3d( dWidth, 0, 0)) ; - // porto la piramide nel riferimento locale - bOk = bOk && pSTM->ToGlob( frBox) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmPyramid(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptCross)) + "},{" + - ToString( Point3d( ptDir)) + "}," + - ToString( dHeight) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmPyramid( nParentId, ptIni, ptCross, ptDir, dHeight, nRefType) ; } //------------------------------------------------------------------------------- @@ -193,40 +54,7 @@ int __stdcall EgtCreateSurfTmCylinder( int nParentId, const double ptOrig[3], const double vtN[3], double dRad, double dHeight, double dLinTol, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale il punto e il versore - Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - // calcolo riferimento OCS a partire da questo punto e versore - Frame3d frCyl ; - bOk = bOk && frCyl.Set( ptOrigL, vtNL) ; - // creo il cilindro nel suo riferimento intrinseco - PtrOwner pSTM( GetSurfTriMeshCylinder( dRad, dHeight, dLinTol)) ; - bOk = bOk && ! IsNull( pSTM) ; - // porto il cilindro nel riferimento locale - bOk = bOk && pSTM->ToGlob( frCyl) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmCylinder(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptOrig)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - ToString( dRad) + "," + - ToString( dHeight) + "," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmCylinder( nParentId, ptOrig, vtN, dRad, dHeight, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- @@ -234,40 +62,7 @@ int __stdcall EgtCreateSurfTmCone( int nParentId, const double ptOrig[3], const double vtN[3], double dRad, double dHeight, double dLinTol, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale il punto e il versore - Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - // calcolo riferimento OCS a partire da questo punto e versore - Frame3d frCyl ; - bOk = bOk && frCyl.Set( ptOrigL, vtNL) ; - // creo il cono nel suo riferimento intrinseco - PtrOwner pSTM( GetSurfTriMeshCone( dRad, dHeight, dLinTol)) ; - bOk = bOk && ! IsNull( pSTM) ; - // porto il cono nel riferimento locale - bOk = bOk && pSTM->ToGlob( frCyl) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmCone(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptOrig)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - ToString( dRad) + "," + - ToString( dHeight) + "," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmCone( nParentId, ptOrig, vtN, dRad, dHeight, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- @@ -275,64 +70,14 @@ int __stdcall EgtCreateSurfTmSphere( int nParentId, const double ptOrig[3], double dRad, double dLinTol, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // porto in locale il punto - Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; - // creo la sfera - PtrOwner pSTM( GetSurfTriMeshSphere( dRad, dLinTol)) ; - bOk = bOk && ! IsNull( pSTM) ; - // porto la sfera nella sua origine - bOk = bOk && pSTM->Translate( ptOrig - ORIG) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmSphere(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptOrig)) + "}," + - ToString( dRad) + "," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmSphere( nParentId, ptOrig, dRad, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByFlatContour( CrvLoc.Get(), dLinTol) : nullptr) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmByFlatContour(" + ToString( nParentId) + "," + - ToString( nCrvId) + "," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmByFlatContour( nParentId, nCrvId, dLinTol) ; } //------------------------------------------------------------------------------- @@ -344,51 +89,7 @@ __stdcall EgtCreateSurfTmByRegion( int nParentId, int nNumId, const int nCrvIds[ for ( int i = 0 ; i < nNumId ; ++i) { vCrvIds.push_back( nCrvIds[i]) ; } - return EgtCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateSurfTmByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero le curve in locale - CURVELOCALVECTOR vCrvLoc ; - vCrvLoc.reserve( vCrvIds.size()) ; - ICURVEPVECTOR vCrvP ; - vCrvP.reserve( vCrvIds.size()) ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { - vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; - vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; - bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; - } - // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegion( vCrvP, dLinTol) : nullptr) ; - bOk = bOk && ( pSTM != nullptr) ; - // elimino punti ripetuti - bOk = bOk && pSTM->DoCompacting() ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) - sIds += ToString( vCrvIds[i]) + "," ; - sIds.pop_back() ; - string sLua = "EgtSurfTmByRegion(" + ToString( nParentId) + ",{" + - sIds + "}," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ; } //------------------------------------------------------------------------------- @@ -401,60 +102,7 @@ __stdcall EgtCreateSurfTmByExtrusion( int nParentId, int nNumId, const int nCrvI for ( int i = 0 ; i < nNumId ; ++i) { vCrvIds.push_back( nCrvIds[i]) ; } - return EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateSurfTmByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero le curve in locale - CURVELOCALVECTOR vCrvLoc ; - vCrvLoc.reserve( vCrvIds.size()) ; - ICURVEPVECTOR vCrvP ; - vCrvP.reserve( vCrvIds.size()) ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { - vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; - vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; - bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; - } - // porto in locale il vettore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ; - // creo le superfici e le inserisco nel DB - int nFirstId = GDB_ID_NULL ; - for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) { - // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( vCrvP[i], vtExtrL, false, dLinTol) : nullptr) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - bOk = bOk && ( nNewId != GDB_ID_NULL) ; - if ( bOk && nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) - sIds += ToString( vCrvIds[i]) + "," ; - sIds.pop_back() ; - string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + ",{" + - sIds + "},{" + - ToString( Vector3d( vtExtr)) + "}," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nFirstId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nFirstId ; + return ExeCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- @@ -467,54 +115,7 @@ __stdcall EgtCreateSurfTmByRegionExtrusion( int nParentId, int nNumId, const int for ( int i = 0 ; i < nNumId ; ++i) { vCrvIds.push_back( nCrvIds[i]) ; } - return EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; -} - -//------------------------------------------------------------------------------- -int -EgtCreateSurfTmByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero le curve in locale - CURVELOCALVECTOR vCrvLoc ; - vCrvLoc.reserve( vCrvIds.size()) ; - ICURVEPVECTOR vCrvP ; - vCrvP.reserve( vCrvIds.size()) ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { - vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; - vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; - bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; - } - // porto in locale il vettore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ; - int nNewId = GDB_ID_NULL ; - // creo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegionExtrusion( vCrvP, vtExtrL, dLinTol) : nullptr) ; - // inserisco la superficie nel DB - nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) - sIds += ToString( vCrvIds[i]) + "," ; - sIds.pop_back() ; - string sLua = "EgtSurfTmByRegionExtrusion(" + ToString( nParentId) + ",{" + - sIds + "},{" + - ToString( Vector3d( vtExtr)) + "}," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- @@ -523,37 +124,7 @@ __stdcall EgtCreateSurfTmByRevolve( int nParentId, int nCrvId, const double ptAx[3], const double vtAx[3], BOOL bCapEnds, double dLinTol, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // porto in locale punto e vettore asse - Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ; - Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; - // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmByRevolve(" + ToString( nParentId) + "," + - ToString( nCrvId) + ",{" + - ToString( Point3d( ptAx)) + "},{" + - ToString( Vector3d( vtAx)) + "}," + - ( bCapEnds ? "true" : "false") + "," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmByRevolve( nParentId, nCrvId, ptAx, vtAx, ( bCapEnds != FALSE), dLinTol, nRefType) ; } //------------------------------------------------------------------------------- @@ -562,113 +133,14 @@ __stdcall EgtCreateSurfTmByScrewing( int nParentId, int nCrvId, const double ptAx[3], const double vtAx[3], double dAngRotDeg, double dMove, double dLinTol, int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // porto in locale punto e vettore asse - Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ; - Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; - // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ; - // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmByScrewing(" + ToString( nParentId) + "," + - ToString( nCrvId) + ",{" + - ToString( Point3d( ptAx)) + "},{" + - ToString( Vector3d( vtAx)) + "}," + - ToString( dAngRotDeg) + "," + - ToString( dMove) + "," + - ToString( dLinTol) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmByScrewing( nParentId, nCrvId, ptAx, vtAx, dAngRotDeg, dMove, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, double dLinTol) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // creo la superficie trimesh - ISurfTriMesh* pSTM = nullptr ; - // se la prima entità è un punto e la seconda una curva - if ( pGeomDB->GetGeoType( nPtOrCrvId1) == GEO_PNT3D && - ( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) { - // recupero il punto in locale - // recupero riferimento del punto - Frame3d frPnt ; - bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId1, frPnt) ; - // porto il punto in locale - Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId1))->GetPoint() ; - bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nPtOrCrvId2, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // calcolo la superficie - pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ; - } - // se la prima entità è una curva e la seconda un punto - else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 && - pGeomDB->GetGeoType( nPtOrCrvId2) == GEO_PNT3D) { - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nPtOrCrvId1, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // recupero il punto in locale - // recupero riferimento del punto - Frame3d frPnt ; - bOk = bOk && pGeomDB->GetGlobFrame( nPtOrCrvId2, frPnt) ; - // porto il punto in locale - Point3d ptP = GetGeoPoint3d( pGeomDB->GetGeoObj( nPtOrCrvId2))->GetPoint() ; - bOk = bOk && ptP.LocToLoc( frPnt, frLoc) ; - // calcolo la superficie - pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc.Get(), dLinTol) : nullptr) ; - } - // se entrambe curve - else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 && - ( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) { - // recupero la prima curva in locale - CurveLocal CrvLoc1( pGeomDB, nPtOrCrvId1, frLoc) ; - bOk = bOk && ( CrvLoc1.Get() != nullptr) ; - // recupero la seconda curva in locale - CurveLocal CrvLoc2( pGeomDB, nPtOrCrvId2, frLoc) ; - bOk = bOk && ( CrvLoc2.Get() != nullptr) ; - // calcolo la superficie - pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ; - } - // altrimenti errore - else - bOk = false ; - // inserisco la superficie trimesh nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmRuled(" + ToString( nParentId) + "," + - ToString( nPtOrCrvId1) + "," + - ToString( nPtOrCrvId2) + "," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; + return ExeCreateSurfTmRuled( nParentId, nPtOrCrvId1, nPtOrCrvId2, dLinTol) ; } //---------------------------------------------------------------------------- @@ -680,76 +152,7 @@ __stdcall EgtCreateSurfTmByTriangles( int nParentId, int nNumId, const int nIds[ for ( int i = 0 ; i < nNumId ; ++i) { vIds.push_back( nIds[i]) ; } - return EgtCreateSurfTmByTriangles( nParentId, vIds, ( bErase != FALSE)) ; -} - -//---------------------------------------------------------------------------- -int -EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // almeno un oggetto nell'elenco - bool bOk = ( vIds.size() > 0) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // Costruttore di trimesh da insieme disordinato di triangoli - StmFromTriangleSoup StmFts ; - bOk = bOk && StmFts.Start() ; - // Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // recupero la superficie sorgente - const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pStmS != nullptr) ; - // recupero il riferimento della superficie sorgente - Frame3d frSou ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frSou) ; - // recupero tutti i triangoli - Triangle3d Tria ; - int nT = ( bOk ? pStmS->GetFirstTriangle( Tria) : SVT_NULL) ; - while ( nT != SVT_NULL) { - // aggiusto per i sistemi di riferimento - Tria.LocToLoc( frSou, frLoc) ; - // inserisco il triangolo nella nuova superficie - if ( ! StmFts.AddTriangle( Tria)) - return false ; - // passo al triangolo successivo - nT = pStmS->GetNextTriangle( nT, Tria) ; - } - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - // valido la superficie e calcolo le adiacenze - bOk = bOk && StmFts.End() ; - // inserisco la superficie trimesh nel DB - PtrOwner pStm( StmFts.GetSurf()) ; - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; - // se richiesto, cancello le superfici originali - if ( nNewId != GDB_ID_NULL && bErase) { - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - pGeomDB->Erase( nId) ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmByTriangles(" + ToString( nParentId) + ",{" + - IdListToString( vIds) + "}," + - ( bErase ? "true" : "false") + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return nNewId ; + return ExeCreateSurfTmByTriangles( nParentId, vIds, ( bErase != FALSE)) ; } //---------------------------------------------------------------------------- @@ -761,73 +164,5 @@ __stdcall EgtCreateSurfTmBySewing( int nParentId, int nNumId, const int nIds[], for ( int i = 0 ; i < nNumId ; ++i) { vIds.push_back( nIds[i]) ; } - return EgtCreateSurfTmBySewing( nParentId, vIds, ( bErase != FALSE)) ; -} - -//---------------------------------------------------------------------------- -int -EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // almeno un oggetto nell'elenco - bool bOk = ( vIds.size() > 0) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // puntatore alla nuova superficie - PtrOwner pStm( CreateSurfTriMesh()) ; - bOk = bOk && ! IsNull( pStm) ; - // esecuzione - bool bFirst = true ; - for ( size_t i = 0 ; bOk && i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // recupero la superficie da cucire - const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pStmS != nullptr) ; - // recupero il riferimento - Frame3d frStmS ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frStmS) ; - // lo esprimo rispetto a quello della prima superficie - frStmS.ToLoc( frLoc) ; - // se è la prima, copio - if ( bFirst) { - bOk = bOk && pStm->CopyFrom( pStmS) ; - bOk = bOk && pStm->ToGlob( frStmS) ; - bFirst = false ; - } - // altrimenti eseguo la cucitura - else - bOk = bOk && pStm->DoSewing( *pStmS, frStmS) ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - // compatto - bOk = bOk && pStm->DoCompacting() ; - // inserisco la superficie trimesh nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; - // se richiesto, cancello le superfici originali - if ( nNewId != GDB_ID_NULL && bErase) { - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - pGeomDB->Erase( nId) ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmBySewing(" + ToString( nParentId) + ",{" + - IdListToString( vIds) + "}," + - ( bErase ? "true" : "false") + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return nNewId ; + return ExeCreateSurfTmBySewing( nParentId, vIds, ( bErase != FALSE)) ; } diff --git a/API_GdbModify.cpp b/API_GdbModify.cpp index 180604c..599c4bc 100644 --- a/API_GdbModify.cpp +++ b/API_GdbModify.cpp @@ -15,17 +15,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkGeoPoint3d.h" -#include "/EgtDev/Include/EgkGeoVector3d.h" -#include "/EgtDev/Include/EgkExtText.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -39,237 +31,54 @@ __stdcall EgtChangeGroupFrame( int nId, double ptOrig[3], if ( ! frFrame.Set( ptOrig, vtX, vtY, vtZ)) return FALSE ; // eseguo - return ( EgtChangeGroupFrame( nId, frFrame, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // recupero il riferimento del gruppo - Frame3d* pFrame = pGeomDB->GetGroupFrame( nId) ; - bOk = bOk && ( pFrame != nullptr) ; - // porto il nuovo riferimento in locale - Frame3d frNewL = frNewRef ; - if ( nRefType != RTY_LOC) { - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - if ( nRefType == RTY_GLOB) - frNewL.ToLoc( frLoc) ; - else /* RTY_GRID */ - frNewL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; - } - // aggiorno il gruppo - if ( bOk) - *pFrame = frNewL ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtChangeGroupFrame(" + ToString( nId) + ",{{" + - ToString( frNewRef.Orig()) + "},{" + - ToString( frNewRef.VersX()) + "},{" + - ToString( frNewRef.VersY()) + "},{" + - ToString( frNewRef.VersZ()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeChangeGroupFrame( nId, frFrame, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeVectorBase( int nId, const double ptB[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // recupero il vettore - IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pGVect != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto il nuovo punto base in locale - Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ; - // imposto il nuovo punto di base - bOk = bOk && pGVect->ChangeBase( ptBL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtChangeVectorBase(" + ToString( nId) + ",{" + - ToString( Point3d( ptB)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeChangeVectorBase( nId, ptB, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyText( int nId, const wchar_t* wsNewText) { - return ( EgtModifyText( nId, wstrztoA( wsNewText)) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtModifyText( int nId, const string& sNewText) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - return false ; - // eseguo l'operazione - return pTXT->ModifyText( sNewText) ; + return ( ExeModifyText( nId, wstrztoA( wsNewText)) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtChangeTextFont( int nId, const wchar_t* wsNewFont) { - return ( EgtChangeTextFont( nId, wstrztoA( wsNewFont)) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtChangeTextFont( int nId, const string& sNewFont) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - return false ; - // eseguo l'operazione - return pTXT->ChangeFont( sNewFont) ; + return ( ExeChangeTextFont( nId, wstrztoA( wsNewFont)) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtFlipText( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - return FALSE ; - // eseguo l'operazione - return ( pTXT->Flip() ? TRUE : FALSE) ; + return ( ExeFlipText( nId) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtMirrorText( int nId, BOOL bOnL) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - return FALSE ; - // eseguo l'operazione - return ( pTXT->Mir( ( bOnL ? true : false)) ? TRUE : FALSE) ; + return ( ExeMirrorText( nId, ( bOnL != FALSE)) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- int __stdcall EgtExplodeText( int nId, int* pnCount) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pTXT != nullptr) ; - // recupero l'outline del testo - ICURVEPLIST lstPCRV ; - bOk = bOk && pTXT->GetOutline( lstPCRV) ; - // inserisco le curve nella stessa posizione del testo - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - for ( ICURVEPLIST::iterator iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { - // inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB - int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, (*iIter)) ; - bOk = bOk && ( nCrvId != GDB_ID_NULL) ; - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; - // aggiorno contatori - if ( bOk) { - if ( nFirstId == GDB_ID_NULL) - nFirstId = nCrvId ; - ++ nCount ; - } - } - nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; - // elimino il testo originale - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtExplodeText(" + ToString( nId) + ")" + - " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultati - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; + return ExeExplodeText( nId, pnCount) ; } //------------------------------------------------------------------------------- int __stdcall EgtSplitText( int nId, int* pnCount) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il testo - IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pTXT != nullptr) ; - // recupero l'esplosione del testo in linee singole - IEXTTEXTPVECTOR vTxt ; - bOk = bOk && pTXT->SplitOnLineBreak( vTxt) ; - // inserisco i nuovi testi nella stessa posizione del testo - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) { - // inserimento - int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, vTxt[i]) : GDB_ID_NULL) ; - if ( nCrvId != GDB_ID_NULL) { - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; - // aggiorno contatori - if ( bOk) { - if ( nFirstId == GDB_ID_NULL) - nFirstId = nCrvId ; - ++ nCount ; - } - } - else { - bOk = false ; - delete vTxt[i] ; - } - } - nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; - // elimino il testo originale - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSplitText(" + ToString( nId) + ")" + - " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultati - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; + return ExeSplitText( nId, pnCount) ; } diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 99c7644..75b997c 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -14,20 +14,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkCurve.h" -#include "/EgtDev/Include/EGkCurveArc.h" -#include "/EgtDev/Include/EGkCurveBezier.h" -#include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkDistPointCurve.h" -#include "/EgtDev/Include/EGkExtTExt.h" -#include "/EgtDev/Include/EGkGdbIterator.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; @@ -37,196 +25,35 @@ __stdcall EgtInvertCurve( int nId) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtInvertCurve( vIds) ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -bool -EgtInvertCurve( const INTVECTOR& vIds) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // eseguo inversione - bool bOk = true ; - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL && bOk) { - // recupero la curva e la inverto - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve != nullptr && ! pCurve->Invert()) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtInvertCurve({" + IdListToString( vIds) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeInvertCurve( vIds) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtOffsetCurve( int nId, double dDist, int nType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - // eseguo l'offset - bool bOk = ( pCurve != nullptr) && pCurve->SimpleOffset( dDist, nType) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - sLua = "EgtOffsetCurve(" + ToString( nId) + "," + - ToString( dDist) + "," + - OffsTypeToString( nType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeOffsetCurve( nId, dDist, nType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtChangeClosedCurveStartPoint( int nId, const double ptP[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pCurve != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il punto vicino ad iniziale - Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; - // recupero la posizione parametrica della proiezione di questo punto sulla curva - DistPointCurve distPC( ptPL, *pCurve) ; - double dPar ; - int nFlag ; - bOk = bOk && distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) ; - // cambio il punto iniziale - if ( bOk && pCurve->GetType() == CRV_ARC) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; - else if ( bOk && pCurve->GetType() == CRV_COMPO) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; - else - bOk = false ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtChangeClosedCurveStartPoint(" + ToString( nId) + ",{" + - ToString( Point3d( ptP)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeChangeClosedCurveStartPoint( nId, ptP, nRefType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveStartPoint( int nId, const double ptP[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pCurve != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il nuovo punto iniziale - Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; - // ne modifico il punto iniziale - bOk = bOk && pCurve->ModifyStart( ptPL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtModifyCurveStartPoint(" + ToString( nId) + ",{" + - ToString( Point3d( ptP)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeModifyCurveStartPoint( nId, ptP, nRefType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveEndPoint( int nId, const double ptP[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bOk = bOk && ( pCurve != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il nuovo punto finale - Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; - // ne modifico il punto finale - bOk = bOk && pCurve->ModifyEnd( ptPL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtModifyCurveEndPoint(" + ToString( nId) + ",{" + - ToString( Point3d( ptP)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -static bool -ModifyOneCurveExtrusion( IGeomDB* pGeomDB, int nId, const Vector3d& vtExtr, int nRefType) -{ - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frLoc) && - ! pGeomDB->GetGlobFrame( nId, frLoc)) - return false ; - // porto in locale il versore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ; - // se gruppo, agisco sulle sole curve componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) { - PtrOwner pIter( CreateGdbIterator( pGeomDB)) ; - if ( IsNull( pIter)) - return false ; - for ( bool bFound = pIter->GoToFirstInGroup( nId) ; - bFound ; - bFound = pIter->GoToNext()) { - // recupero la curva e ne modifico il vettore estrusione - ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ; - if ( pCurve != nullptr && ! pCurve->SetExtrusion( vtExtrL)) - return false ; - } - return true ; - } - // se oggetto geometrico - else { - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - // ne modifico il vettore estrusione - return ( pCurve == nullptr || pCurve->SetExtrusion( vtExtrL)) ; - } + return ( ExeModifyCurveEndPoint( nId, ptP, nRefType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -235,76 +62,7 @@ __stdcall EgtModifyCurveExtrusion( int nId, const double vtExtr[3], int nRefType { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtModifyCurveExtrusion( vIds, vtExtr, nRefType) ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -bool -EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // se estrusione espressa in locale, verifico che tutte le curve siano nello stesso riferimento - if ( nRefType == RTY_LOC) - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // impostazione estrusione singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = bOk && ModifyOneCurveExtrusion( pGeomDB, vIds[i], vtExtr, nRefType) ; - } - // impostazione estrusione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! ModifyOneCurveExtrusion( pGeomDB, nI, vtExtr, nRefType)) - bOk = false ; - // passo alla successiva - nI = pGeomDB->GetNextSelectedObj() ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtModifyCurveExtrusion({" + IdListToString( vIds) + "},{" + - ToString( Vector3d( vtExtr)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; -} - -//---------------------------------------------------------------------------- -static bool -ModifyOneCurveThickness( IGeomDB* pGeomDB, int nId, double dThick) -{ - // se gruppo, agisco sulle sole curve componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) { - PtrOwner pIter( CreateGdbIterator( pGeomDB)) ; - if ( IsNull( pIter)) - return false ; - bool bOk = true ; - for ( bool bFound = pIter->GoToFirstInGroup( nId) ; - bFound ; - bFound = pIter->GoToNext()) { - // recupero la curva e ne modifico lo spessore - ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ; - if ( pCurve != nullptr && ! pCurve->SetThickness( dThick)) - bOk = false ; - } - return bOk ; - } - // se oggetto geometrico - else { - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - // ne modifico lo spessore, se curva - return ( pCurve == nullptr || pCurve->SetThickness( dThick)) ; - } + return ( ExeModifyCurveExtrusion( vIds, vtExtr, nRefType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -313,537 +71,124 @@ __stdcall EgtModifyCurveThickness( int nId, double dThick) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtModifyCurveThickness( vIds, dThick) ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -bool -EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo impostazione spessore singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = bOk && ModifyOneCurveThickness( pGeomDB, vIds[i], dThick) ; - } - // eseguo impostazione spessore dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! ModifyOneCurveThickness( pGeomDB, nI, dThick)) - bOk = false ; - // passo alla successiva - nI = pGeomDB->GetNextSelectedObj() ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtModifyCurveThickness({" + IdListToString( vIds) + "}," + - ToString( dThick) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeModifyCurveThickness( vIds, dThick) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimCurveStartAtLen( int nId, double dLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // taglio la curva all'inizio - bool bOk = pCurve->TrimStartAtLen( dLen) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimCurveStartAtLen( nId, dLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimCurveEndAtLen( int nId, double dLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // taglio la curva alla fine - bool bOk = pCurve->TrimEndAtLen( dLen) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimCurveEndAtLen( nId, dLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimCurveStartAtParam( int nId, double dPar) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // taglio la curva all'inizio - bool bOk = pCurve->TrimStartAtParam( dPar) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimCurveStartAtParam( nId, dPar) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimCurveEndAtParam( int nId, double dPar) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // taglio la curva alla fine - bool bOk = pCurve->TrimEndAtParam( dPar) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimCurveEndAtParam( nId, dPar) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimCurveStartEndAtParam( int nId, double dParS, double dParE) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // taglio la curva agli estremi - bool bOk = pCurve->TrimStartEndAtParam( dParS, dParE) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimCurveStartEndAtParam( nId, dParS, dParE) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtExtendCurveStartByLen( int nId, double dLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // estendo la curva all'inizio - bool bOk = pCurve->ExtendStartByLen( dLen) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeExtendCurveStartByLen( nId, dLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtExtendCurveEndByLen( int nId, double dLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // estendo la curva alla fine - bool bOk = pCurve->ExtendEndByLen( dLen) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeExtendCurveEndByLen( nId, dLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pCurve != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il punto - Point3d ptNearL = GetPointLocal( pGeomDB, ptNear, nRefType, frLoc) ; - // cerco l'estremo più vicino al punto passato - Point3d ptStart, ptEnd ; - if ( bOk && pCurve->GetStartPoint( ptStart) && pCurve->GetEndPoint( ptEnd)) { - if ( SqDist( ptStart, ptNearL) < SqDist( ptEnd, ptNearL)) { - if ( dLen < - EPS_SMALL) - bOk = pCurve->TrimStartAtLen( - dLen) ; - else if ( dLen > EPS_SMALL) - bOk = pCurve->ExtendStartByLen( dLen) ; - } - else { - if ( dLen < - EPS_SMALL) { - double dCrvLen ; - bOk = pCurve->GetLength( dCrvLen) && pCurve->TrimEndAtLen( dCrvLen + dLen) ; - } - else if ( dLen > EPS_SMALL) - bOk = pCurve->ExtendEndByLen( dLen) ; - } - } - else - bOk = false ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtTrimExtendCurveByLen(" + ToString( nId) + "," + - ToString( dLen) + ",{" + - ToString( Point3d( ptNear)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeTrimExtendCurveByLen( nId, dLen, ptNear, nRefType) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- int __stdcall EgtSplitCurve( int nId, int nParts) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pCurve != nullptr) ; - // il numero di parti non può essere inferiore a 1 - nParts = max( nParts, 1) ; - // lunghezza totale della curva - double dLenTot = 0 ; - bOk = bOk && pCurve->GetLength( dLenTot) ; - // lunghezza di una parte - double dLen = dLenTot / nParts ; - // eseguo la divisione - int nFirstId = GDB_ID_NULL ; - int nCurrId = nId ; - for ( int i = 1; i < nParts ; ++ i) { - // copio la curva - int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ; - ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ; - bOk = bOk && ( pCopyCrv != nullptr) ; - // tengo la prima parte dell'originale e la seconda parte della copia - bOk = bOk && pCurve->TrimEndAtLen( dLen) ; - bOk = bOk && pCopyCrv->TrimStartAtLen( dLen) ; - // la copia diventa il nuovo corrente - nCurrId = nCopyId ; - pCurve = pCopyCrv ; - // salvo identificativo prima copia - if ( nFirstId == GDB_ID_NULL) - nFirstId = nCopyId ; - } - nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSplitCurve(" + ToString( nId) + "," + - ToString( nParts) + ")" + - " -- Id1=" + ToString( nFirstId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nFirstId ; + return ExeSplitCurve( nId, nParts) ; } //---------------------------------------------------------------------------- int -__stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) +__stdcall EgtSplitCurveAtPoint( int nId, const double ptOn[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pCurve != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il punto - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; - // determino la posizione parametrica del punto sulla curva (con tolleranza) - double dU = 0 ; - if ( bOk) { - DistPointCurve dstPC( ptOnL, *pCurve) ; - int nFlag ; - if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL) - bOk = false ; - } - // verifico che il punto di taglio sia interno alla curva - bool bIsInside = false ; - if ( bOk) { - Point3d ptStart ; - Point3d ptEnd ; - Point3d ptBreak ; - if ( pCurve->GetStartPoint( ptStart) && - pCurve->GetEndPoint( ptEnd) && - pCurve->GetPointD1D2( dU, ICurve::FROM_MINUS, ptBreak)) { - bIsInside = ! AreSamePointApprox( ptBreak, ptStart) && - ! AreSamePointApprox( ptBreak, ptEnd) ; - } - } - // se il punto di taglio è interno, devo realmente tagliare - int nNewId = GDB_ID_NULL ; - if ( bIsInside) { - // copio la curva - nNewId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ; - ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; - bOk = bOk && ( pCopyCrv != nullptr) ; - // tengo la prima parte dell'originale e la seconda parte della copia - bOk = bOk && pCurve->TrimEndAtParam( dU) ; - bOk = bOk && pCopyCrv->TrimStartAtParam( dU) ; - } - nNewId = ( bOk ? nNewId : GDB_ID_NULL) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSplitCurveAtPoint(" + ToString( nId) + ",{" + - ToString( Point3d( ptOn)) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nNewId ; + return ExeSplitCurveAtPoint( nId, ptOn, nRefType) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveCircleCPN( int nId, const double ptOn[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'arco e i suoi dati - ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return FALSE ; - Point3d ptCen = pArc->GetCenter() ; - Vector3d vtN = pArc->GetNormVersor() ; - double dOldRad = pArc->GetRadius() ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) - return FALSE ; - // porto in locale il nuovo punto - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; - // calcolo il nuovo raggio - double dRad = (( ptOnL - ptCen) ^ vtN).Len() ; - // imposto il nuovo raggio - if ( pArc->Set( ptCen, vtN, dRad)) - return TRUE ; - // in caso di errore, ripristino i vecchi dati - else { - pArc->Set( ptCen, vtN, dOldRad) ; - return FALSE ; - } + return ( ExeModifyCurveCircleCPN( nId, ptOn, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveArcRadius( int nId, double dRad) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'arco e i suoi dati - ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return FALSE ; - double dOldRad = pArc->GetRadius() ; - // imposto il nuovo raggio - if ( pArc->ChangeRadius( dRad)) - return TRUE ; - // in caso di errore, ripristino i vecchi dati - else { - pArc->ChangeRadius( dOldRad) ; - return FALSE ; - } + return ( ExeModifyCurveArcRadius( nId, dRad) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveArcC2PN( int nId, const double ptEnd[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'arco e i suoi dati - ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return FALSE ; - Point3d ptCen = pArc->GetCenter() ; - Vector3d vtN = pArc->GetNormVersor() ; - Point3d ptStart, ptOldEnd ; - if ( ! pArc->GetStartPoint( ptStart) || ! pArc->GetEndPoint( ptOldEnd)) - return FALSE ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) - return FALSE ; - // porto in locale il nuovo punto finale - Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ; - // imposto il nuovo punto finale - if ( pArc->SetC2PN( ptCen, ptStart, ptEndL, vtN)) - return TRUE ; - // in caso di errore, ripristino i vecchi dati - else { - pArc->SetC2PN( ptCen, ptStart, ptOldEnd, vtN) ; - return FALSE ; - } + return ( ExeModifyCurveArcC2PN( nId, ptEnd, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveArc3P( int nId, const double ptMid[3], int nRefType) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'arco e i suoi punti notevoli - ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return FALSE ; - Point3d ptStart, ptOldMid, ptEnd ; - if ( ! pArc->GetStartPoint( ptStart) || ! pArc->GetMidPoint( ptOldMid) || ! pArc->GetEndPoint( ptEnd)) - return FALSE ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) - return FALSE ; - // porto in locale il nuovo punto medio - Point3d ptMidL = GetPointLocal( pGeomDB, ptMid, nRefType, frLoc) ; - // imposto il nuovo punto medio - if ( pArc->Set3P( ptStart, ptMidL, ptEnd)) - return TRUE ; - // in caso di errore, ripristino i vecchi dati - else { - pArc->Set3P( ptStart, ptOldMid, ptEnd) ; - return FALSE ; - } + return ( ExeModifyCurveArc3P( nId, ptMid, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- int __stdcall EgtExplodeCurveCompo( int nId, int* pnCount) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva composita - ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pCompo != nullptr) ; - // estraggo tutte le curve - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - ICurve* pCrv ; - while ( bOk && ( pCrv = pCompo->RemoveFirstOrLastCurve( false)) != nullptr) { - // inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB - int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pCrv) ; - bOk = bOk && ( nCrvId != GDB_ID_NULL) ; - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; - // aggiorno contatori - if ( bOk) { - if ( nFirstId == GDB_ID_NULL) - nFirstId = nCrvId ; - ++ nCount ; - } - } - nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; - // elimino la curva composita ormai vuota - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtExplodeCurveCompo(" + ToString( nId) + ")" + - " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultati - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; + return ExeExplodeCurveCompo( nId, pnCount) ; } //------------------------------------------------------------------------------- int __stdcall EgtApproxCurveArc( int nId, double dLinTol) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero l'arco - ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pArc != nullptr) ; - // eseguo l'approssimazione con segmenti di linea - const double ANG_TOL_STD_DEG = 15 ; - PtrOwner pCC( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCC) ; - PolyLine PL ; - bOk = bOk && pArc->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ; - // inserisco la curva composita nello stesso posto del GeomDB - int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) : GDB_ID_NULL) ; - bOk = bOk && ( nCrvId != GDB_ID_NULL) ; - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; - // elimino l'arco - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtApproxCurveArc(" + ToString( nId) + "," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nCrvId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nCrvId ; + return ExeApproxCurveArc( nId, dLinTol) ; } //------------------------------------------------------------------------------- int __stdcall EgtApproxCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la curva di Bezier - ICurveBezier* pCBezier = GetCurveBezier( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pCBezier != nullptr) ; - // eseguo l'approssimazione - const double ANG_TOL_STD_DEG = 15 ; - PtrOwner pCC( CreateCurveComposite()) ; - bOk = bOk && ! IsNull( pCC) ; - if ( bArcsVsLines) { // con bi-archi - PolyArc PA ; - bOk = bOk && pCBezier->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) && pCC->FromPolyArc( PA) ; - } - else { // con linee - PolyLine PL ; - bOk = bOk && pCBezier->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ; - } - // inserisco la curva composita nello stesso posto del GeomDB - int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) : GDB_ID_NULL) ; - bOk = bOk && ( nCrvId != GDB_ID_NULL) ; - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; - // elimino la curva di Bezier - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtApproxCurveBezier(" + ToString( nId) + "," + - ( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," + - ToString( dLinTol) + ")" + - " -- Id=" + ToString( nCrvId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nCrvId ; -} \ No newline at end of file + return ExeApproxCurveBezier( nId, ( bArcsVsLines != FALSE), dLinTol) ; +} diff --git a/API_GdbModifySurf.cpp b/API_GdbModifySurf.cpp index 1e51cef..c40054a 100644 --- a/API_GdbModifySurf.cpp +++ b/API_GdbModifySurf.cpp @@ -14,15 +14,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EgkCurveComposite.h" -#include "/EgtDev/Include/EgkSurfTriMesh.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; @@ -32,130 +25,19 @@ __stdcall EgtInvertSurface( int nId) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtInvertSurface( vIds) ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -bool -EgtInvertSurface( const INTVECTOR& vIds) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // eseguo inversione - bool bOk = true ; - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL && bOk) { - // recupero la superficie e la inverto - ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; - if ( pSurf != nullptr && ! pSurf->Invert()) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtInvertSurf({" + IdListToString( vIds) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeInvertSurface( vIds) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- int __stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la superficie TriMesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pStm != nullptr) ; - // recupero il riferimento della superficie - Frame3d frSurf ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ; - // recupero il riferimento di destinazione - Frame3d frDest ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ; - // recupero i loop come polilinee - POLYLINEVECTOR vPL ; - bOk = bOk && pStm->GetFacetLoops( nFacet, vPL) ; - // dalle polilinee creo le curve e le inserisco nel DB - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - for ( size_t i = 0 ; i < vPL.size() ; ++ i) { - // creo la curva - PtrOwner pCrvCompo( CreateCurveComposite()) ; - bOk = bOk && pCrvCompo->FromPolyLine( vPL[i]) ; - // la porto nel riferimento destinazione - bOk = bOk && pCrvCompo->LocToLoc( frSurf, frDest) ; - // la inserisco nel DB geometrico - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) : GDB_ID_NULL) ; - bOk = bOk && ( nNewId != GDB_ID_NULL) ; - if ( bOk && nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - if ( bOk) - ++ nCount ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtExtractSurfTmFacetLoops(" + ToString( nId) + ",{" + - ToString( nFacet) + "," + - ToString( nDestGrpId) + ")" + - " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultati - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; + return ExeExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, pnCount) ; } //------------------------------------------------------------------------------- int __stdcall EgtExplodeSurfTm( int nId, int* pnCount) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la superficie TriMesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pStm != nullptr) ; - // copio tutte le facce - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - int nFacet = pStm->GetFacetNum() ; - for ( int i = 0 ; i < nFacet ; ++ i) { - ISurfTriMesh* pFac = pStm->CloneFacet( i) ; - if ( pFac == nullptr) - continue ; - // inserisco la superficie nello stesso gruppo e nello stesso posto del GeomDB - int nFacId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pFac) ; - bOk = bOk && ( nFacId != GDB_ID_NULL) ; - // copio gli attributi - bOk = bOk && pGeomDB->CopyAttributes( nId, nFacId) ; - // aggiorno contatori - if ( bOk) { - if ( nFirstId == GDB_ID_NULL) - nFirstId = nFacId ; - ++ nCount ; - } - } - nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; - // elimino la superficie - bOk = bOk && pGeomDB->Erase( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtExplodeSurfTm(" + ToString( nId) + ")" + - " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultati - if ( pnCount != nullptr) - *pnCount = nCount ; - return nFirstId ; + return ExeExplodeSurfTm( nId, pnCount) ; } diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index d10ea21..8c98aef 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -14,114 +14,66 @@ //--------------------------- Include ---------------------------------------- #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/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; - //----------------------------------------------------------------------------- BOOL __stdcall EgtSetLevel( int nId, int nLevel) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // imposto il livello - bool bOk = pGeomDB->SetLevel( nId, nLevel) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeSetLevel( nId, nLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertLevel( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // porto il livello allo stato precedente - bool bOk = pGeomDB->RevertLevel( nId) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeRevertLevel( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetLevel( int nId, int* pnLevel) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnLevel == nullptr) - return FALSE ; - // recupero il livello - return ( pGeomDB->GetLevel( nId, *pnLevel) ? TRUE : FALSE) ; + return ( ExeGetLevel( nId, pnLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcLevel( int nId, int* pnLevel) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnLevel == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetCalcLevel( nId, *pnLevel) ? TRUE : FALSE) ; + return ( ExeGetCalcLevel( nId, pnLevel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMode( int nId, int nMode) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // imposto il modo - bool bOk = pGeomDB->SetMode( nId, nMode) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeSetMode( nId, nMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertMode( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // porto il modo allo stato precedente - bool bOk = pGeomDB->RevertMode( nId) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeRevertMode( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetMode( int nId, int* pnMode) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnMode == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetMode( nId, *pnMode) ? TRUE : FALSE) ; + return ( ExeGetMode( nId, pnMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcMode( int nId, int* pnMode) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnMode == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetCalcMode( nId, *pnMode) ? TRUE : FALSE) ; + return ( ExeGetCalcMode( nId, pnMode) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -130,149 +82,56 @@ __stdcall EgtSetStatus( int nId, int nStat) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtSetStatus( vIds, nStat) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetStatus( const INTVECTOR& vIds, int nStat) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero pezzo e layer correnti - bool bCurrPartOff = false ; - bool bCurrLayerOff = false ; - int nCurrPartId = EgtGetCurrPart() ; - int nCurrLayerId = EgtGetCurrLayer() ; - // ciclo sul vettore degli identificativi - bool bOk = true ; - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // impostazione stato - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // imposto il modo - if ( ! pGeomDB->SetStatus( nId, nStat)) - bOk = false ; - // se nascosto pezzo corrente o layer corrente - if ( nStat == GDB_ST_OFF) { - if ( nId == nCurrPartId) - bCurrPartOff = true ; - else if ( nId == nCurrLayerId) - bCurrLayerOff = true ; - } - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - // se pezzo o layer correnti da rideterminare - if ( bCurrPartOff) - EgtResetCurrPartLayer() ; - else if ( bCurrLayerOff) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; - // dichiaro progetto modificato - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sStat = "GDB_ST.ON" ; - if ( nStat == GDB_ST_SEL) - sStat = "GDB_ST.SEL" ; - else if ( nStat == GDB_ST_OFF) - sStat = "GDB_ST.OFF" ; - string sLua = "EgtSetStatus({" + IdListToString( vIds) + "}," + - sStat + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeSetStatus( vIds, nStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRevertStatus( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // porto lo stato al valore precedente - bool bOk = pGeomDB->RevertStatus( nId) ; - EgtSetModified() ; - return ( bOk ? TRUE : FALSE) ; + return ( ExeRevertStatus( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetStatus( int nId, int* pnStat) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnStat == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetStatus( nId, *pnStat) ? TRUE : FALSE) ; + return ( ExeGetStatus( nId, pnStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcStatus( int nId, int* pnStat) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pnStat == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetCalcStatus( nId, *pnStat) ? TRUE : FALSE) ; + return ( ExeGetCalcStatus( nId, pnStat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMark( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // imposto l'evidenziazione - bool bOk = pGeomDB->SetMark( nId) ; - // non produce modifica perchè mark ignorato in salvataggio - return ( bOk ? TRUE : FALSE) ; + return ( ExeSetMark( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetMark( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // cancello l'evidenziazione - bool bOk = pGeomDB->ResetMark( nId) ; - // non produce modifica perchè mark ignorato in salvataggio - return ( bOk ? TRUE : FALSE) ; + return ( ExeResetMark( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetMark( int nId, BOOL* pbMark) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pbMark == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetMark( nId, *pbMark) ? TRUE : FALSE) ; + return ( ExeGetMark( nId, pbMark) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetCalcMark( int nId, BOOL* pbMark) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pbMark == nullptr) - return FALSE ; - // recupero il modo - return ( pGeomDB->GetCalcMark( nId, *pbMark) ? TRUE : FALSE) ; + return ( ExeGetCalcMark( nId, pbMark) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -280,7 +139,7 @@ BOOL __stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4]) { Color ColStd ; - if ( GetStdColor( wstrztoA( wsName), ColStd)) { + if ( ExeStdColor( wstrztoA( wsName), ColStd)) { StdCol[0] = ColStd.GetIntRed() ; StdCol[1] = ColStd.GetIntGreen() ; StdCol[2] = ColStd.GetIntBlue() ; @@ -300,49 +159,7 @@ __stdcall EgtSetColor( int nId, const int ObjCol[4], BOOL bSetAlpha) // sistemo il colore Color cCol( ObjCol) ; // eseguo - return ( EgtSetColor( vIds, cCol, (bSetAlpha != FALSE)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetColor( const INTVECTOR& vIds, const Color& cCol, bool bSetAlpha) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // assegno il colore - bool bOk = true ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - Color cNew = cCol ; - // se richiesto, recupero alpha originale - if ( ! bSetAlpha) { - Color cOri ; - if ( pGeomDB->GetCalcMaterial( nId, cOri)) - cNew.SetAlpha( cOri.GetIntAlpha()) ; - } - // eseguo assegnazione - if ( ! pGeomDB->SetMaterial( nId, cNew)) - bOk = false ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - 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 = "EgtSetColor({" + sIds + "},{" + - ToString( cCol) + "}," + - ( bSetAlpha ? "true" : "false") + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeSetColor( vIds, cCol, (bSetAlpha != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -353,40 +170,7 @@ __stdcall EgtSetAlpha( int nId, int nAlpha) INTVECTOR vIds ; vIds.push_back( nId) ; // eseguo - return ( EgtSetAlpha( vIds, nAlpha) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetAlpha( const INTVECTOR& vIds, int nAlpha) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // assegno la trasparenza - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // recupero il colore originale - Color cCol ; - bOk = bOk && pGeomDB->GetCalcMaterial( nId, cCol) ; - cCol.SetAlpha( nAlpha) ; - // eseguo assegnazione - bOk = bOk && pGeomDB->SetMaterial( nId, cCol) ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetAlpha({" + IdListToString( vIds) + "}," + - ToString( nAlpha) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeSetAlpha( vIds, nAlpha) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -397,46 +181,16 @@ __stdcall EgtResetColor( int nId) INTVECTOR vIds ; vIds.push_back( nId) ; // eseguo - return ( EgtResetColor( vIds) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtResetColor( const INTVECTOR& vIds) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // tolgo il colore - bool bOk = true ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - if ( ! pGeomDB->SetMaterial( nId, GDB_MT_PARENT)) - bOk = false ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtResetColor({" + IdListToString( vIds) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeResetColor( vIds) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetColor( int nId, int ObjCol[4]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; - if ( pGeomDB->GetMaterial( nId, cCol)) { + if ( ExeGetColor( nId, cCol)) { ObjCol[0] = cCol.GetIntRed() ; ObjCol[1] = cCol.GetIntGreen() ; ObjCol[2] = cCol.GetIntBlue() ; @@ -451,11 +205,9 @@ __stdcall EgtGetColor( int nId, int ObjCol[4]) BOOL __stdcall EgtGetCalcColor( int nId, int ObjCol[4]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il colore Color cCol ; - if ( pGeomDB->GetCalcMaterial( nId, cCol)) { + if ( ExeGetCalcColor( nId, cCol)) { ObjCol[0] = cCol.GetIntRed() ; ObjCol[1] = cCol.GetIntGreen() ; ObjCol[2] = cCol.GetIntBlue() ; @@ -470,27 +222,7 @@ __stdcall EgtGetCalcColor( int nId, int ObjCol[4]) BOOL __stdcall EgtSetName( int nId, const wchar_t* wsName) { - return ( EgtSetName( nId, wstrztoA( wsName)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetName( int nId, const string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // assegno il nome - bool bOk = pGeomDB->SetName( nId, sName) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetName(" + ToString( nId) + ",'" + - sName + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeSetName( nId, wstrztoA( wsName)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -500,96 +232,38 @@ __stdcall EgtGetName( int nId, wchar_t*& wsName) if ( &wsName == nullptr) return FALSE ; string sName ; - if ( ! EgtGetName( nId, sName)) + if ( ! ExeGetName( nId, sName)) return FALSE ; wsName = _wcsdup( stringtoW( sName)) ; return (( wsName == nullptr) ? FALSE : TRUE) ; } -//----------------------------------------------------------------------------- -bool -EgtGetName( int nId, string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il nome - return pGeomDB->GetName( nId, sName) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtExistsName( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico esistenza del nome - return ( pGeomDB->ExistsName( nId) ? TRUE : FALSE) ; + return ( ExeExistsName( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveName( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // rimuovo il nome - bool bOk = pGeomDB->RemoveName( nId) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRemoveName(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeRemoveName( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetInfo( int nId, const wchar_t* wsKey, const wchar_t* wsInfo) { - return ( EgtSetInfo( nId, wstrztoA( wsKey), wstrztoA( wsInfo)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetInfo( int nId, const string& sKey, const string& sInfo) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // assegno la info - bool bOk = pGeomDB->SetInfo( nId, sKey, sInfo) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetInfo(" + ToString( nId) + ",'" + - sKey + "','" + - sInfo + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeSetInfo( nId, wstrztoA( wsKey), wstrztoA( wsInfo)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetInfoInt( int nId, const wchar_t* wsKey, int nInfo) { - return ( EgtSetInfo( nId, wstrztoA( wsKey), nInfo) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetInfo( int nId, const string& sKey, int nInfo) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // assegno la info - bool bOk = pGeomDB->SetInfo( nId, sKey, nInfo) ; - EgtSetModified() ; - return bOk ; + return ( ExeSetInfo( nId, wstrztoA( wsKey), nInfo) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -597,22 +271,12 @@ BOOL __stdcall EgtGetInfo( int nId, const wchar_t* wsKey, wchar_t*& wsInfo) { string sInfo ; - if ( ! EgtGetInfo( nId, wstrztoA( wsKey), sInfo)) + if ( ! ExeGetInfo( nId, wstrztoA( wsKey), sInfo)) return FALSE ; wsInfo = _wcsdup( stringtoW( sInfo)) ; return (( wsInfo == nullptr) ? FALSE : TRUE) ; } -//----------------------------------------------------------------------------- -bool -EgtGetInfo( int nId, const string& sKey, string& sInfo) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero info - return pGeomDB->GetInfo( nId, sKey, sInfo) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtGetInfoInt( int nId, const wchar_t* wsKey, int* pnInfo) @@ -621,59 +285,19 @@ __stdcall EgtGetInfoInt( int nId, const wchar_t* wsKey, int* pnInfo) if ( pnInfo == nullptr) return FALSE ; // recupero info - return ( EgtGetInfo( nId, wstrztoA( wsKey), *pnInfo) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtGetInfo( int nId, const string& sKey, int& nInfo) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero la info - return pGeomDB->GetInfo( nId, sKey, nInfo) ; + return ( ExeGetInfo( nId, wstrztoA( wsKey), *pnInfo) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExistsInfo( int nId, const wchar_t* wsKey) { - return ( EgtExistsInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtExistsInfo( int nId, const string& sKey) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico esistenza info - return pGeomDB->ExistsInfo( nId, sKey) ; + return ( ExeExistsInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveInfo( int nId, const wchar_t* wsKey) { - return ( EgtRemoveInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtRemoveInfo( int nId, const string& sKey) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // rimuovo la info - bool bOk = pGeomDB->RemoveInfo( nId, sKey) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRemoveInfo(" + ToString( nId) + ",'" + - sKey + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeRemoveInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; } diff --git a/API_GdbObjSelection.cpp b/API_GdbObjSelection.cpp index 885a1d1..b40294a 100644 --- a/API_GdbObjSelection.cpp +++ b/API_GdbObjSelection.cpp @@ -14,205 +14,91 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; - //----------------------------------------------------------------------------- BOOL __stdcall EgtSelectObj( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // seleziono l'oggetto - bool bOk = pGeomDB->SelectObj( nId) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectObj(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSelectObj( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDeselectObj( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // deseleziono l'oggetto - bool bOk = pGeomDB->DeselectObj( nId) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectObj(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeDeselectObj( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSelectAll( bool bOnlyIfVisible) +__stdcall EgtSelectAll( BOOL bOnlyIfVisible) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // seleziono tutto - int nId1 = EgtGetFirstPart( bOnlyIfVisible) ; - while ( nId1 != GDB_ID_NULL) { - // ciclo sugli oggetti del pezzo - int nId2 = pGeomDB->GetFirstInGroup( nId1) ; - while ( nId2 != GDB_ID_NULL) { - // se è gruppo seleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId2) == GDB_TY_GROUP) - pGeomDB->SelectGroupObjs( nId2, 0, bOnlyIfVisible) ; - // altrimenti lo seleziono direttamente - else - pGeomDB->SelectObj( nId2, bOnlyIfVisible) ; - // passo al successivo - nId2 = pGeomDB->GetNext( nId2) ; - } - // passo al successivo - nId1 = EgtGetNextPart( nId1, bOnlyIfVisible) ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectAll(" + string( bOnlyIfVisible ? "true" : "false") + ")" + - " -- bOk=1" ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return TRUE ; + return ( ExeSelectAll( ( bOnlyIfVisible != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDeselectAll( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // deseleziono tutto - bool bOk = pGeomDB->ClearSelection() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectAll()" - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeDeselectAll() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelectGroupObjs( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia un gruppo - if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { - bOk = pGeomDB->SelectGroupObjs( nGroupId) ; - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectGroupObjs(" + ToString( nGroupId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSelectGroupObjs( nGroupId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDeselectGroupObjs( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia un gruppo - if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { - bOk = pGeomDB->DeselectGroupObjs( nGroupId) ; - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectGroupObjs(" + ToString( nGroupId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeDeselectGroupObjs( nGroupId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtIsSelectedObj( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico se l'oggetto è selezionato - return ( pGeomDB->IsSelectedObj( nId) ? TRUE : FALSE) ; + return ( ExeIsSelectedObj( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetSelectedObjNbr( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, 0) - // restituisco il numero di oggetti selezionati - return pGeomDB->GetSelectedObjNbr() ; + return ExeGetSelectedObjNbr() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetFirstSelectedObj( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il primo oggetto selezionato - return pGeomDB->GetFirstSelectedObj() ; + return ExeGetFirstSelectedObj() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNextSelectedObj( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il successivo oggetto selezionato - return pGeomDB->GetNextSelectedObj() ; + return ExeGetNextSelectedObj() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetLastSelectedObj( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero l'ultimo oggetto selezionato - return pGeomDB->GetLastSelectedObj() ; + return ExeGetLastSelectedObj() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetPrevSelectedObj( void) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il precedente oggetto selezionato - return pGeomDB->GetPrevSelectedObj() ; + return ExeGetPrevSelectedObj() ; } diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 6b16553..edf837c 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -14,45 +14,33 @@ //--------------------------- Include ---------------------------------------- #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/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; - //----------------------------------------------------------------------------- BOOL - __stdcall EgtExistsObj( int nId) - { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico se esiste l'oggetto - return ( pGeomDB->ExistsObj( nId) ? TRUE : FALSE) ; - } +__stdcall EgtExistsObj( int nId) +{ + return ( ExeExistsObj( nId) ? TRUE : FALSE) ; +} //----------------------------------------------------------------------------- int __stdcall EgtGetParent( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // verifico se esiste l'oggetto - return pGeomDB->GetParentId( nId) ; + return ExeGetParent( nId) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetGroupGlobFrame( int nId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) // recupero il riferimento globale del gruppo Frame3d frGlob ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frGlob)) + if ( ! ExeGetGroupGlobFrame( nId, frGlob)) return FALSE ; // aggiorno i parametri del frame VEC_FROM_3D( ptOrig, frGlob.Orig()) @@ -64,132 +52,65 @@ __stdcall EgtGetGroupGlobFrame( int nId, double ptOrig[3], double vtX[3], double //----------------------------------------------------------------------------- int - __stdcall EgtGetGroupObjs( int nId) - { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il numero di oggetti nel gruppo - return pGeomDB->GetGroupObjs( nId) ; - } +__stdcall EgtGetGroupObjs( int nId) +{ + return ExeGetGroupObjs( nId) ; +} //----------------------------------------------------------------------------- int __stdcall EgtGetFirstInGroup( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il primo oggetto nel gruppo - return pGeomDB->GetFirstInGroup( nGroupId) ; + return ExeGetFirstInGroup( nGroupId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNext( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il prossimo oggetto nello stesso gruppo - return pGeomDB->GetNext( nId) ; + return ExeGetNext( nId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetLastInGroup( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero l'ultimo oggetto nel gruppo - return pGeomDB->GetLastInGroup( nGroupId) ; + return ExeGetLastInGroup( nGroupId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetPrev( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il precedente oggetto nello stesso gruppo - return pGeomDB->GetPrev( nId) ; + return ExeGetPrev( nId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetFirstGroupInGroup( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il primo gruppo nel gruppo - return pGeomDB->GetFirstGroupInGroup( nGroupId) ; + return ExeGetFirstGroupInGroup( nGroupId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNextGroup( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il prossimo gruppo nello stesso gruppo - return pGeomDB->GetNextGroup( nId) ; + return ExeGetNextGroup( nId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetLastGroupInGroup( int nGroupId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero l'ultimo gruppo nel gruppo - return pGeomDB->GetLastGroupInGroup( nGroupId) ; + return ExeGetLastGroupInGroup( nGroupId) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetPrevGroup( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il precedente gruppo nello stesso gruppo - return pGeomDB->GetPrevGroup( nId) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetFirstNameInGroup( int nGroupId, const string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il primo oggetto con il nome desiderato nel gruppo - return pGeomDB->GetFirstNameInGroup( nGroupId, sName) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetNextName( int nId, const string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il prossimo oggetto nello stesso gruppo con il nome voluto - return pGeomDB->GetNextName( nId, sName) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetLastNameInGroup( int nGroupId, const string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero l'ultimo oggetto con il nome desiderato nel gruppo - return pGeomDB->GetLastNameInGroup( nGroupId, sName) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetPrevName( int nId, const string& sName) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il precedente oggetto nello stesso gruppo con il nome voluto - return pGeomDB->GetPrevName( nId, sName) ; + return ExeGetPrevGroup( nId) ; } //----------------------------------------------------------------------------- @@ -198,7 +119,7 @@ __stdcall EgtGetBBox( int nId, int nFlag, double ptMin[3], double ptMax[3]) { // recupero il bounding box dell'oggetto in locale BBox3d b3Box ; - if ( ! EgtGetBBox( nId, nFlag, b3Box)) + if ( ! ExeGetBBox( nId, nFlag, b3Box)) return FALSE ; ptMin[0] = b3Box.GetMin().x ; ptMin[1] = b3Box.GetMin().y ; @@ -209,23 +130,13 @@ __stdcall EgtGetBBox( int nId, int nFlag, double ptMin[3], double ptMax[3]) return TRUE ; } -//----------------------------------------------------------------------------- -bool -EgtGetBBox( int nId, int nFlag, BBox3d& b3Box) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il bounding box dell'oggetto in locale - return pGeomDB->GetLocalBBox( nId, b3Box, nFlag) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtGetBBoxGlob( int nId, int nFlag, double ptMin[3], double ptMax[3]) { // recupero il bounding box dell'oggetto in globale BBox3d b3Box ; - if ( ! EgtGetBBoxGlob( nId, nFlag, b3Box)) + if ( ! ExeGetBBoxGlob( nId, nFlag, b3Box)) return FALSE ; // converto il risultato ptMin[0] = b3Box.GetMin().x ; @@ -237,16 +148,6 @@ __stdcall EgtGetBBoxGlob( int nId, int nFlag, double ptMin[3], double ptMax[3]) return TRUE ; } -//----------------------------------------------------------------------------- -bool -EgtGetBBoxGlob( int nId, int nFlag, BBox3d& b3Box) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il bounding box dell'oggetto in globale - return pGeomDB->GetGlobalBBox( nId, b3Box, nFlag) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtGetBBoxRef( int nId, int nFlag, const double ptOrig[3], @@ -259,7 +160,7 @@ __stdcall EgtGetBBoxRef( int nId, int nFlag, const double ptOrig[3], return FALSE ; // recupero il bounding box dell'oggetto nel riferimento BBox3d b3Box ; - if ( ! EgtGetBBoxRef( nId, nFlag, frRef, b3Box)) + if ( ! ExeGetBBoxRef( nId, nFlag, frRef, b3Box)) return FALSE ; // converto il risultato ptMin[0] = b3Box.GetMin().x ; @@ -271,148 +172,39 @@ __stdcall EgtGetBBoxRef( int nId, int nFlag, const double ptOrig[3], return TRUE ; } -//----------------------------------------------------------------------------- -bool -EgtGetBBoxRef( int nId, int nFlag, const Frame3d& frRef, BBox3d& b3Box) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il bounding box dell'oggetto nel riferimento - return pGeomDB->GetRefBBox( nId, frRef, b3Box, nFlag) ; -} - //----------------------------------------------------------------------------- int __stdcall EgtCopy( int nSouId, int nRefId, int nSonBeforeAfter) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // eseguo la copia - int nNewId = pGeomDB->Copy( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtCopy(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + - " -- Id=" + ToString( nNewId) ; - else - sLua = "EgtCopy(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nNewId ; + return ExeCopy( nSouId, nRefId, nSonBeforeAfter) ; } //----------------------------------------------------------------------------- int __stdcall EgtCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // eseguo la copia mantenendo la posizione in globale - int nNewId = pGeomDB->CopyGlob( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + - " -- Id=" + ToString( nNewId) ; - else - sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return nNewId ; + return ExeCopyGlob( nSouId, nRefId, nSonBeforeAfter) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRelocate( int nSouId, int nRefId, int nSonBeforeAfter) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo la rilocazione - bool bOk = pGeomDB->Relocate( nSouId, nRefId, nSonBeforeAfter) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtRelocate(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + - " -- Ok=" + ToString( bOk) ; - else - sLua = "EgtRelocate(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeRelocate( nSouId, nRefId, nSonBeforeAfter) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo la rilocazione mantenendo la posizione in globale - bool bOk = pGeomDB->RelocateGlob( nSouId, nRefId, nSonBeforeAfter) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + - " -- Ok=" + ToString( bOk) ; - else - sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeRelocateGlob( nSouId, nRefId, nSonBeforeAfter) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtChangeId( int nId, int nNewId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo cambio di Id - bool bOk = pGeomDB->ChangeId( nId, nNewId) ; - // se pezzo corrente o layer corrente - if ( bOk) { - if ( nId == EgtGetCurrPart()) - EgtSetCurrPartLayer( nNewId, EgtGetCurrLayer()) ; - else if ( nId == EgtGetCurrLayer()) - EgtSetCurrPartLayer( EgtGetCurrPart(), nNewId) ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtChangeId(" + ToString( nId) + "," + - ToString( nNewId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return ( bOk ? TRUE : FALSE) ; + return ( ExeChangeId( nId, nNewId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -421,112 +213,33 @@ __stdcall EgtErase( int nId) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtErase( vIds) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtErase( const INTVECTOR& vIds) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // eseguo cancellazione - bool bOk = true ; - bool bErasedCurrPart = false ; - bool bErasedCurrLayer = false ; - int nCurrPartId = EgtGetCurrPart() ; - int nCurrLayerId = EgtGetCurrLayer() ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // cancello - if ( ! pGeomDB->Erase( nId)) - bOk = false ; - // verifico se cancellato pezzo corrente o layer corrente - if ( nId == nCurrPartId) - bErasedCurrPart = true ; - else if ( nId == nCurrLayerId) - bErasedCurrLayer = true ; - // passo al successivo - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtErase({" + IdListToString( vIds) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // se cancellato pezzo corrente o layer corrente (va qui perchè salva altro comando che è successivo) - if ( bErasedCurrPart) - EgtResetCurrPartLayer() ; - else if ( bErasedCurrLayer) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; - // restituisco risultato - return bOk ; + return ( ExeErase( vIds) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtEmptyGroup( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // svuoto il gruppo - bool bOk = pGeomDB->EmptyGroup( nId) ; - // se cancellato pezzo corrente o layer corrente - int nCurrPartId = EgtGetCurrPart() ; - int nCurrLayerId = EgtGetCurrLayer() ; - if ( ! pGeomDB->ExistsObj( nCurrPartId)) - EgtResetCurrPartLayer() ; - else if ( ! pGeomDB->ExistsObj( nCurrLayerId)) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstLayer( nCurrPartId, true)) ; - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtEmptyGroup(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeEmptyGroup( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetType( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_TY_NONE) - // recupero il tipo GDB - int nType = pGeomDB->GetGdbType( nId) ; - if ( nType == GDB_TY_GEO) { - // recupero il tipo Geo - const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; - if ( pGeoObj == nullptr) - return GDB_TY_NONE ; - else - return pGeoObj->GetType() ; - } - else if ( nType == GDB_TY_GROUP) - return GDB_TY_GROUP ; - else - return GDB_TY_NONE ; + return ExeGetType( nId) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetTitle( int nId, wchar_t*& wsTitle) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'oggetto geometrico - const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; - if ( pGeoObj == nullptr) - return FALSE ; // recupero la stringa del titolo - wsTitle = _wcsdup( stringtoW( pGeoObj->GetTitle())) ; + string sTitle ; + if ( ! ExeGetTitle( nId, sTitle)) + return FALSE ; + // alloco buffer di ritorno ed eseguo copia + wsTitle = _wcsdup( stringtoW( sTitle)) ; return (( wsTitle == nullptr) ? FALSE : TRUE) ; } @@ -534,37 +247,10 @@ __stdcall EgtGetTitle( int nId, wchar_t*& wsTitle) BOOL __stdcall EgtGroupDump( int nId, wchar_t*& wsDump) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // preparo l'intestazione - string sDump = "Group " + ToString( nId) + "\r\n" ; - // preparo gli attributi - pGeomDB->DumpAttributes( nId, sDump, "\r\n") ; - // numero di nodi (figli) - int nNodes = pGeomDB->GetGroupObjs( nId) ; - sDump += "Nodes : " + ToString( nNodes) + "\r\n" ; - // riferimento in globale - Frame3d frGlob ; - if ( pGeomDB->GetGroupGlobFrame( nId, frGlob)) { - sDump += "GlobFrame :\r\n" ; - sDump += " O(" + ToString( frGlob.Orig()) + ")\r\n" ; - sDump += " X(" + ToString( frGlob.VersX()) + ")\r\n" ; - sDump += " Y(" + ToString( frGlob.VersY()) + ")\r\n" ; - sDump += " Z(" + ToString( frGlob.VersZ()) + ")\r\n" ; - } - // ingombro in globale - BBox3d b3Glob ; - if ( pGeomDB->GetGlobalBBox( nId, b3Glob, BBF_EXACT)) { - sDump += "GlobBBox :\r\n" ; - Point3d ptMin, ptMax ; - if ( b3Glob.GetMinMax( ptMin, ptMax)) { - sDump += " m(" + ToString( ptMin) + ")\r\n" ; - sDump += " M(" + ToString( ptMax) + ")\r\n" ; - } - else { - sDump += " Empty\r\n" ; - } - } + // recupero la stringa di dump + string sDump ; + if ( ! ExeGroupDump( nId, sDump)) + return FALSE ; // alloco buffer di ritorno ed eseguo copia wsDump = _wcsdup( stringtoW( sDump)) ; return (( wsDump == nullptr) ? FALSE : TRUE) ; @@ -574,18 +260,9 @@ __stdcall EgtGroupDump( int nId, wchar_t*& wsDump) BOOL __stdcall EgtGeoObjDump( int nId, wchar_t*& wsDump) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'oggetto geometrico - const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; - if ( pGeoObj == nullptr) - return FALSE ; - // preparo l'intestazione - string sDump = pGeoObj->GetTitle() + " " + ToString( nId) + "\r\n" ; - // preparo gli attributi - pGeomDB->DumpAttributes( nId, sDump, "\r\n") ; - // recupero i dati geometrici - if ( ! pGeoObj->Dump( sDump, "\r\n")) + // recupero la stringa di dump + string sDump ; + if ( ! ExeGeoObjDump( nId, sDump)) return FALSE ; // alloco buffer di ritorno ed eseguo copia wsDump = _wcsdup( stringtoW( sDump)) ; diff --git a/API_GdbPartLayers.cpp b/API_GdbPartLayers.cpp index 473c833..1f196b3 100644 --- a/API_GdbPartLayers.cpp +++ b/API_GdbPartLayers.cpp @@ -14,438 +14,119 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgkCurve.h" -#include "/EgtDev/Include/EgkChainCurves.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EXeExecutor.h" 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) -{ - int nStat ; - return ( pGeomDB->GetCalcStatus( nId, nStat) && nStat != GDB_ST_OFF) ; -} - -//------------------------------------------------------------------------------- -static int -EgtVerifyOrNext( IGeomDB* pGeomDB, int nId, bool bOnlyVisible) -{ - while ( nId != GDB_ID_NULL) { - if ( EgtIsUserObj( pGeomDB, nId) && - ( ! bOnlyVisible || EgtIsVisibleObj( pGeomDB, nId))) - return nId ; - nId = pGeomDB->GetNextGroup( nId) ; - } - return GDB_ID_NULL ; -} - -//------------------------------------------------------------------------------- -int +BOOL __stdcall EgtIsPart( int nPartId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // verifico sia un pezzo (gruppo sotto la radice con livello utente) - if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && - pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && - EgtIsUserObj( pGeomDB, nPartId)) - return TRUE ; - else - return FALSE ; + return ( ExeIsPart( nPartId) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- -int +BOOL __stdcall EgtIsLayer( int nLayerId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // verifico sia un layer (gruppo sotto un pezzo con livello utente) - if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && - EgtIsPart( pGeomDB->GetParentId( nLayerId)) != FALSE && - EgtIsUserObj( pGeomDB, nLayerId)) - return TRUE ; - else - return FALSE ; + return ( ExeIsLayer( nLayerId) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- int __stdcall EgtGetCurrPart( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, GDB_ID_NULL) - // recupero il pezzo corrente - return pGseCtx->m_nCurrPart ; + return ExeGetCurrPart() ; } //------------------------------------------------------------------------------- int __stdcall EgtGetCurrLayer( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, GDB_ID_NULL) - // recupero il pezzo corrente - return pGseCtx->m_nCurrLayer ; + return ExeGetCurrLayer() ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtSetCurrPartLayer( int nPartId, int nLayerId) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; - bool bOk = true ; - // verifico validità e visibilità pezzo - if ( pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && - EgtIsUserObj( pGeomDB, nPartId) && - EgtIsVisibleObj( pGeomDB, nPartId)) { - if ( nPartId != pGseCtx->m_nCurrPart) - pGseCtx->m_nCurrLayer = GDB_ID_NULL ; - pGseCtx->m_nCurrPart = nPartId ; - } - else { - if ( nPartId == pGseCtx->m_nCurrPart || nPartId == GDB_ID_NULL) { - pGseCtx->m_nCurrPart = GDB_ID_NULL ; - pGseCtx->m_nCurrLayer = GDB_ID_NULL ; - } - bOk = false ; - } - // verifico validità e visibilità layer - if ( pGeomDB->GetParentId( nLayerId) == nPartId && - EgtIsUserObj( pGeomDB, nLayerId) && - EgtIsVisibleObj( pGeomDB, nLayerId)) { - pGseCtx->m_nCurrLayer = nLayerId ; - } - else { - if ( nLayerId == pGseCtx->m_nCurrLayer || nLayerId == GDB_ID_NULL) - pGseCtx->m_nCurrLayer = GDB_ID_NULL ; - bOk = false ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetCurrPartLayer(" + ToString( nPartId) + "," + - ToString( nLayerId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSetCurrPartLayer( nPartId, nLayerId) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtResetCurrPartLayer( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; - // reset - pGseCtx->m_nCurrPart = GDB_ID_NULL ; - pGseCtx->m_nCurrLayer = GDB_ID_NULL ; - // cerco il primo pezzo con un layer visibile - int nPartId = EgtGetFirstPart( true) ; - while ( nPartId != GDB_ID_NULL) { - // cerco il primo layer visibile del pezzo - int nLayerId = EgtGetFirstLayer( nPartId, true) ; - if ( nLayerId != GDB_ID_NULL) { - // assegno il pezzo corrente - pGseCtx->m_nCurrPart = nPartId ; - // assegno il layer corrente - pGseCtx->m_nCurrLayer = nLayerId ; - // esco dal ciclo di ricerca - break ; - } - 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 = EgtGetFirstPart( true) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtResetCurrPartLayer()" - " -- Ids=" + ToString( pGseCtx->m_nCurrPart) + "," + ToString( pGseCtx->m_nCurrLayer) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return TRUE ; + return ( ExeResetCurrPartLayer() ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetPartNbr( bool bOnlyVisible) +__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 ; + return ExeGetPartNbr( ( bOnlyVisible != FALSE)) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetFirstPart( bool bOnlyVisible) +__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 oppure passo al primo successivo valido - return EgtVerifyOrNext( pGeomDB, nPartId, bOnlyVisible) ; + return ExeGetFirstPart( ( bOnlyVisible != FALSE)) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetNextPart( int nId, bool bOnlyVisible) +__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 oppure passo al primo successivo valido - return EgtVerifyOrNext( pGeomDB, nPartId, bOnlyVisible) ; + return ExeGetNextPart( nId, ( bOnlyVisible != FALSE)) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetFirstLayer( int nPartId, bool bOnlyVisible) +__stdcall EgtGetFirstLayer( int nPartId, BOOL bOnlyVisible) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // 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 oppure passo al primo successivo valido - return EgtVerifyOrNext( pGeomDB, nLayerId, bOnlyVisible) ; + return ExeGetFirstLayer( nPartId, ( bOnlyVisible != FALSE)) ; } //------------------------------------------------------------------------------- int -__stdcall EgtGetNextLayer( int nId, bool bOnlyVisible) +__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 EgtVerifyOrNext( pGeomDB, nLayerId, bOnlyVisible) ; + return ExeGetNextLayer( nId, ( bOnlyVisible != FALSE)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelectPartObjs( int nPartId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un pezzo - if ( EgtIsPart( nPartId) != FALSE) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo seleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) - pGeomDB->SelectGroupObjs( nId) ; - // altrimenti lo seleziono direttamente - else - pGeomDB->SelectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectPartObjs(" + ToString( nPartId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSelectPartObjs( nPartId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDeselectPartObjs( int nPartId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un pezzo - if ( EgtIsPart( nPartId) != FALSE) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo deseleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) - pGeomDB->DeselectGroupObjs( nId) ; - // altrimenti lo deseleziono direttamente - else - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectPartObjs(" + ToString( nPartId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeDeselectPartObjs( nPartId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelectLayerObjs( int nLayerId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un layer - if ( EgtIsLayer( nLayerId) != FALSE) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // seleziono - pGeomDB->SelectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectLayerObjs(" + ToString( nLayerId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSelectLayerObjs( nLayerId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDeselectLayerObjs( int nLayerId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; - // verifico sia veramente un layer - if ( EgtIsLayer( nLayerId) != FALSE) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // deseleziono - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtDeselectLayerObjs(" + ToString( nLayerId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeDeselectLayerObjs( nLayerId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelectPathObjs( int nId, BOOL bHaltOnFork) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // verifico appartenga ad un layer - int nIdLayer = pGeomDB->GetParentId( nId) ; - int nIdPart = pGeomDB->GetParentId( nIdLayer) ; - bool bOk = ( nIdLayer != GDB_ID_NULL && nIdPart != GDB_ID_NULL && ( EgtIsLayer( nIdLayer) != FALSE)) ; - // seleziono percorso a partire da entità indicata usando tutte le curve del pezzo - const int CHAIN_SIZE = 1000 ; - const double CHAIN_TOLER = 10 * EPS_SMALL ; - Point3d ptNear ; - ChainCurves chainC ; - bOk = bOk && chainC.Init( true, CHAIN_TOLER, CHAIN_SIZE) ; - // ciclo sui layer del pezzo - for ( int nLayId = pGeomDB->GetFirstGroupInGroup( nIdPart) ; - nLayId != GDB_ID_NULL ; - nLayId = pGeomDB->GetNextGroup( nLayId)) { - // ciclo sulle entità del layer - for ( int nEntId = pGeomDB->GetFirstInGroup( nLayId) ; - nEntId != GDB_ID_NULL ; - nEntId = pGeomDB->GetNext( nEntId)) { - // non deve essere nascosta - int nEntStat ; - pGeomDB->GetCalcStatus( nEntId, nEntStat) ; - if ( nEntStat == GDB_ST_OFF) - continue ; - // recupero la curva e il suo riferimento - ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nEntId)) ; - if ( pCrv == nullptr) - continue ; - Frame3d frCrv ; - if ( ! pGeomDB->GetGlobFrame( nEntId, frCrv)) - continue ; - // recupero i dati della curva necessari al concatenamento e li assegno - Point3d ptStart, ptEnd ; - Vector3d vtStart, vtEnd ; - if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) || - ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd)) - return GDB_ID_NULL ; - ptStart.ToGlob( frCrv) ; - vtStart.ToGlob( frCrv) ; - ptEnd.ToGlob( frCrv) ; - vtEnd.ToGlob( frCrv) ; - if ( nEntId == nId) - ptNear = ptStart + vtStart ; - if ( ! chainC.AddCurve( nEntId, ptStart, vtStart, ptEnd, vtEnd)) - continue ; - } - } - // recupero il primo percorso concatenato - int nFirstId = GDB_ID_NULL ; - INTVECTOR vId2s ; - bOk = bOk && chainC.GetChainFromNear( ptNear, ( bHaltOnFork != FALSE), vId2s) ; - for ( size_t i = 0 ; i < vId2s.size() ; ++i) { - pGeomDB->SetStatus( abs( vId2s[i]), GDB_ST_SEL) ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSelectPathObjs(" + ToString( nId) + "," + - ( bHaltOnFork ? "true" : "false") + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; -} \ No newline at end of file + return ( ExeSelectPathObjs( nId, ( bHaltOnFork != FALSE)) ? TRUE : FALSE) ; +} diff --git a/API_General.cpp b/API_General.cpp index b476a9f..2b72420 100644 --- a/API_General.cpp +++ b/API_General.cpp @@ -14,134 +14,44 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "LUA_Base.h" -#include "DllGraphics.h" -#include "DllExchange.h" -#include "DllMachKernel.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInDllMain.h" -#include "/EgtDev/Include/EGnDllMain.h" -#include "/EgtDev/Include/ENkDllMain.h" -#include "/EgtDev/Include/EGkDllMain.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EGnPcInfo.h" -#include "/EgtDev/Include/EgtLogger.h" -#include using namespace std ; -using namespace egtlogger ; - -//---------------------------------------------------------------------------- -static Logger* s_pGenLog = nullptr ; -static Logger* s_pCmdLog = nullptr ; -static bool s_bCmdLog = false ; //----------------------------------------------------------------------------- BOOL -__stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg) +__stdcall EgtInit( int nDebug, const wchar_t* wsLogFile, const wchar_t* wsLogMsg) { - // cancello eventuali vecchi contesti - ClearAllGseContexts() ; - // cancello eventuale vecchio logger - if ( s_pGenLog != nullptr) - delete s_pGenLog ; - - // creo il logger generale - s_pGenLog = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ; - if ( s_pGenLog == nullptr) - return FALSE ; - // assegno il file - s_pGenLog->AddOutputStream( new ofstream( sLogFile), true) ; - // lo passo alle DLL - SetEGnLogger( s_pGenLog) ; - SetENkLogger( s_pGenLog) ; - SetEGkLogger( s_pGenLog) ; - - // carico librerie opzionali - LoadGraphicsDll() ; - MySetEGrLogger( s_pGenLog) ; - LoadExchangeDll() ; - MySetEExLogger( s_pGenLog) ; - LoadMachKernelDll() ; - MySetEMkLogger( s_pGenLog) ; - - // dichiaro inizio programma - LOG_DATETIME( s_pGenLog, " Init") - // eventuale messaggio dall'applicazione - if ( sLogMsg != nullptr && sLogMsg[0] != L'\0') - LOG_INFO( s_pGenLog, LPSTR( WtoA( sLogMsg))) - // versione di interfaccia e componenti - string sVer ; - EgtGetVersionInfo( sVer, "\n") ; - LOG_INFO( s_pGenLog, sVer.c_str()) - // Info sul sistema - string sTmp ; - if ( GetOsInfo( sTmp)) - LOG_INFO( s_pGenLog, sTmp.c_str()) - if ( GetCpuInfo( sTmp)) - LOG_INFO( s_pGenLog, sTmp.c_str()) - if ( GetMemoryInfo( sTmp)) - LOG_INFO( s_pGenLog, sTmp.c_str()) - - // inizializzo l'interprete LUA - LuaInit() ; - - return TRUE ; + string sLogMsg = wstrztoA( wsLogMsg) ; + sLogMsg += "\n" ; + sLogMsg += GetEInVersion() ; + return ( ExeInit( nDebug, wstrztoA( wsLogFile), sLogMsg) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExit( void) { - // cancello tutti i contesti - ClearAllGseContexts() ; - - // termino l'interprete LUA - LuaExit() ; - - // libero le librerie opzionali - FreeMachKernelDll() ; - FreeExchangeDll() ; - FreeGraphicsDll() ; - - // fine programma - LOG_DATETIME( s_pGenLog, " Exit") - - // cancello il logger dei comandi - if ( s_pCmdLog != nullptr) { - delete s_pCmdLog ; - s_pCmdLog = nullptr ; - } - - // cancello il logger generale - if ( s_pGenLog != nullptr) { - delete s_pGenLog ; - s_pGenLog = nullptr ; - } - - return TRUE ; + return ( ExeExit() ? TRUE : FALSE) ; } + //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetKey( const wchar_t* swKey) +__stdcall EgtSetKey( const wchar_t* wsKey) { - string sKey = WtoA( swKey) ; - SetEGkKey( sKey) ; - MySetEGrKey( sKey) ; - MySetEExKey( sKey) ; - MySetEMkKey( sKey) ; - return TRUE ; + return ( ExeSetKey( wstrztoA( wsKey)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetFont( const wchar_t* wsNfeFontDir, const wchar_t* wsDefaultFont) { - // inizializzazioni gestore font Nfe - InitFontManager( LPSTR( WtoA( wsNfeFontDir)), LPSTR( WtoA( wsDefaultFont))) ; - return TRUE ; + return ( ExeSetFont( wstrztoA( wsNfeFontDir), wstrztoA( wsDefaultFont)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -149,9 +59,10 @@ BOOL __stdcall EgtGetNfeFontDir( wchar_t*& wsNfeFontDir) { if ( &wsNfeFontDir == nullptr) - return false ; - // recupero il nome del font di default - string sNfeFontDir = GetNfeFontDir() ; + return FALSE ; + // recupero il nome del direttorio dei font Nfe + string sNfeFontDir ; + ExeGetNfeFontDir( sNfeFontDir) ; wsNfeFontDir = _wcsdup( stringtoW( sNfeFontDir)) ; return (( wsNfeFontDir == nullptr) ? FALSE : TRUE) ; } @@ -163,56 +74,37 @@ __stdcall EgtGetDefaultFont( wchar_t*& wsDefaultFont) if ( &wsDefaultFont == nullptr) return false ; // recupero il nome del font di default - string sDefaultFont = GetDefaultFont() ; + string sDefaultFont ; + ExeGetDefaultFont( sDefaultFont) ; wsDefaultFont = _wcsdup( stringtoW( sDefaultFont)) ; return (( wsDefaultFont == nullptr) ? FALSE : TRUE) ; } - //----------------------------------------------------------------------------- BOOL __stdcall EgtSetLuaLibs( const wchar_t* wsLuaLibsDir) { - if ( LuaSetLuaLibsDir( LPSTR( WtoA( wsLuaLibsDir)))) - return TRUE ; - else - return FALSE ; + return ( ExeSetLuaLibs( wstrztoA( wsLuaLibsDir)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetCommandLogger( const wchar_t* sLogFile) +__stdcall EgtSetCommandLogger( const wchar_t* wsLogFile) { - // cancello eventuale vecchio logger e disabilito output - if ( s_pCmdLog != nullptr) - delete s_pCmdLog ; - s_bCmdLog = false ; - // creo il logger dei comandi - s_pCmdLog = new Logger( LL_INFO, "EgtCommandLog") ; - if ( s_pCmdLog == nullptr) - return FALSE ; - // assegno il file - ofstream* pLogFile = new ofstream( sLogFile) ; - if ( pLogFile == nullptr || pLogFile->bad()) - return FALSE ; - s_pCmdLog->AddOutputStream( pLogFile, true) ; - // scrivo intestazione - string sOut = "-- " + CurrDateTime() + " EgtCommandLog" ; - LOG_INFO( s_pCmdLog, sOut.c_str()) - return TRUE ; + return ( ExeSetCommandLogger( wstrztoA( wsLogFile)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- void __stdcall EgtEnableCommandLogger( void) { - SetCmdLog( true) ; + ExeEnableCommandLogger() ; } //----------------------------------------------------------------------------- void __stdcall EgtDisableCommandLogger( void) { - SetCmdLog( false) ; + ExeDisableCommandLogger() ; } //----------------------------------------------------------------------------- @@ -221,52 +113,21 @@ __stdcall EgtGetVersionInfo( wchar_t*& wsVer) { // recupero le informazioni sulle DLL string sVer ; - if ( ! EgtGetVersionInfo( sVer, "\r\n")) + sVer = GetEInVersion() ; + sVer += "\r\n" ; + if ( ! ExeGetVersionInfo( sVer, "\r\n")) return FALSE ; wsVer = _wcsdup( stringtoW( sVer)) ; return (( wsVer == nullptr) ? FALSE : TRUE) ; } -//----------------------------------------------------------------------------- -bool -EgtGetVersionInfo( string& sVer, const char* szNewLine) -{ - // verifico il parametro - if ( &sVer == nullptr) - return false ; - // recupero le informazioni sulle DLL sempre presenti - sVer += GetEInVersion() ; - sVer += szNewLine ; - sVer += GetEGnVersion() ; - sVer += szNewLine ; - sVer += GetENkVersion() ; - sVer += szNewLine ; - sVer += GetEGkVersion() ; - // recupero le informazioni sulle DLL opzionali - if ( IsLoadedGraphicsDll()) { - sVer += szNewLine ; - sVer += MyGetEGrVersion() ; - } - if ( IsLoadedExchangeDll()) { - sVer += szNewLine ; - sVer += MyGetEExVersion() ; - } - string sEMkVer = MyGetEMkVersion() ; - if ( ! sEMkVer.empty()) { - sVer += szNewLine ; - sVer += sEMkVer ; - } - - return true ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtGetOsInfo( wchar_t*& wsOs) { // recupero le informazioni sul sistema operativo string sOs ; - if ( ! GetOsInfo( sOs)) + if ( ! ExeGetOsInfo( sOs)) return FALSE ; wsOs = _wcsdup( stringtoW( sOs)) ; return (( wsOs == nullptr) ? FALSE : TRUE) ; @@ -278,7 +139,7 @@ __stdcall EgtGetCpuInfo( wchar_t*& wsCpu) { // recupero le informazioni sulla Cpu string sCpu ; - if ( ! GetCpuInfo( sCpu)) + if ( ! ExeGetCpuInfo( sCpu)) return FALSE ; wsCpu = _wcsdup( stringtoW( sCpu)) ; return (( wsCpu == nullptr) ? FALSE : TRUE) ; @@ -290,7 +151,7 @@ __stdcall EgtGetMemoryInfo( wchar_t*& wsMem) { // recupero le informazioni sulla memoria presente string sMem ; - if ( ! GetMemoryInfo( sMem)) + if ( ! ExeGetMemoryInfo( sMem)) return FALSE ; wsMem = _wcsdup( stringtoW( sMem)) ; return (( wsMem == nullptr) ? FALSE : TRUE) ; @@ -305,41 +166,3 @@ __stdcall EgtFreeMemory( void* pMem) free( pMem) ; return TRUE ; } - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtOutLog( const wchar_t* sMsg) -{ - LOG_INFO( s_pGenLog, LPSTR( WtoA( sMsg))) - return ( s_pGenLog != nullptr) ; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -ILogger* -GetLogger( void) -{ - return s_pGenLog ; -} - -//----------------------------------------------------------------------------- -ILogger* -GetCmdLogger( void) -{ - return s_pCmdLog ; -} - -//----------------------------------------------------------------------------- -bool -SetCmdLog( bool bVal) -{ - swap( bVal, s_bCmdLog) ; - return bVal ; -} - -//----------------------------------------------------------------------------- -bool -IsCmdLog( void) -{ - return s_bCmdLog ; -} diff --git a/API_GeoBase.cpp b/API_GeoBase.cpp index bb0f015..505cd71 100644 --- a/API_GeoBase.cpp +++ b/API_GeoBase.cpp @@ -14,9 +14,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EGkBBox3d.h" using namespace std ; @@ -27,6 +27,9 @@ BOOL __stdcall EgtVectorNormalize( double* pdX, double* pdY, double* pdZ, double dEps) { + // verifico i parametri + if ( pdX == nullptr || pdY == nullptr || pdZ == nullptr) + return FALSE ; // eseguo la trasformazione Vector3d vtTemp( *pdX, *pdY, *pdZ) ; if ( ! vtTemp.Normalize( dEps)) diff --git a/API_GeoSnap.cpp b/API_GeoSnap.cpp index 2372197..910ef3e 100644 --- a/API_GeoSnap.cpp +++ b/API_GeoSnap.cpp @@ -14,132 +14,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EgkGeoPoint3d.h" -#include "/EgtDev/Include/EgkGeoVector3d.h" -#include "/EgtDev/Include/EgkCurve.h" -#include "/EgtDev/Include/EgkCurveArc.h" -#include "/EgtDev/Include/EgkCurveComposite.h" -#include "/EgtDev/Include/EgkSurf.h" -#include "/EgtDev/Include/EgkSurfTriMesh.h" -#include "/EgtDev/Include/EgkExtText.h" -#include "/EgtDev/Include/EgkDistPointCurve.h" -#include "/EgtDev/Include/EgkIntersCurveCurve.h" -#include "/EgtDev/Include/EgtPointerOwner.h" - - -//---------------------------------------------------------------------------- -static bool -TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return ptP.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return ptP.LocToLoc( frSou, frDest) ; -} - -//---------------------------------------------------------------------------- -static bool -InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui va espresso il punto (quello dell'entità a cui va riferito) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se viene da globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return ptP.ToLoc( frSou) ; - // recupero il riferimento da cui proviene - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione inversa - return ptP.LocToLoc( frDest, frSou) ; -} - -//---------------------------------------------------------------------------- -static bool -TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return vtV.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return vtV.LocToLoc( frSou, frDest) ; -} - -//---------------------------------------------------------------------------- -static bool -TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return frF.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return frF.LocToLoc( frSou, frDest) ; -} +#include "/EgtDev/Include/EXeExecutor.h" //---------------------------------------------------------------------------- BOOL @@ -147,567 +23,163 @@ __stdcall EgtStartPoint( int nId, int nRefId, double ptP[3]) { // recupero il punto Point3d ptStart ; - if ( ! EgtStartPoint( nId, nRefId, ptStart)) + if ( ! ExeStartPoint( nId, nRefId, ptStart)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptStart) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtStartPoint( int nId, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se punto - if ( pGObj->GetType() == GEO_PNT3D) { - // recupero il geo-punto - const IGeoPoint3d* pGP = GetGeoPoint3d( pGObj) ; - // assegno il punto - ptP = pGP->GetPoint() ; - } - // se vettore - else if ( pGObj->GetType() == GEO_VECT3D) { - // recupero il geo-vettore - const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ; - // assegno il punto - ptP = pGV->GetBase() ; - } - // se frame - else if ( pGObj->GetType() == GEO_FRAME3D) { - // recupero il frame - const IGeoFrame3d* pGF = GetGeoFrame3d( pGObj) ; - // assegno il punto - ptP = pGF->GetFrame().Orig() ; - } - // se curva - else if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il punto - if ( pCrv == nullptr || ! pCrv->GetStartPoint( ptP)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - // assegno il punto - if ( pTxt == nullptr || ! pTxt->GetStartPoint( ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtEndPoint( int nId, int nRefId, double ptP[3]) { // recupero il punto Point3d ptEnd ; - if ( ! EgtEndPoint( nId, nRefId, ptEnd)) + if ( ! ExeEndPoint( nId, nRefId, ptEnd)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptEnd) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtEndPoint( int nId, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - if ( pCrv == nullptr || ! pCrv->GetEndPoint( ptP)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - if ( pTxt == nullptr || ! pTxt->GetEndPoint( ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtMidPoint( int nId, int nRefId, double ptP[3]) { // recupero il punto Point3d ptMid ; - if ( ! EgtMidPoint( nId, nRefId, ptMid)) + if ( ! ExeMidPoint( nId, nRefId, ptMid)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptMid) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtMidPoint( int nId, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il punto - if ( pCrv == nullptr || ! pCrv->GetMidPoint( ptP)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - // assegno il punto - if ( pTxt == nullptr || ! pTxt->GetMidPoint( ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtCenterPoint( int nId, int nRefId, double ptP[3]) { // recupero il punto Point3d ptCent ; - if ( ! EgtCenterPoint( nId, nRefId, ptCent)) + if ( ! ExeCenterPoint( nId, nRefId, ptCent)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptCent) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtCenterPoint( int nId, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il punto - if ( pCrv == nullptr || ! pCrv->GetCenterPoint( ptP)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - // assegno il punto - if ( pTxt == nullptr || ! pTxt->GetCenterPoint( ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtCentroid( int nId, int nRefId, double ptP[3]) { // recupero il punto Point3d ptCent ; - if ( ! EgtCentroid( nId, nRefId, ptCent)) + if ( ! ExeCentroid( nId, nRefId, ptCent)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptCent) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtCentroid( int nId, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il punto - if ( pCrv == nullptr || ! pCrv->GetCentroid( ptP)) - return false ; - } - // se superficie - else if ( ( pGObj->GetType() & GEO_SURF) != 0) { - // recupero la superficie - const ISurf* pSrf = GetSurf( pGObj) ; - // assegno il punto - if ( pSrf == nullptr || ! pSrf->GetCentroid( ptP)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - // assegno il punto - if ( pTxt == nullptr || ! pTxt->GetCenterPoint( ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtAtParamPoint( int nId, double dU, int nRefId, double ptP[3]) { // recupero il punto Point3d ptAtPar ; - if ( ! EgtAtParamPoint( nId, dU, nRefId, ptAtPar)) + if ( ! ExeAtParamPoint( nId, dU, nRefId, ptAtPar)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptAtPar) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - if ( pCrv == nullptr || ! pCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtNearPoint( int nId, const double ptNear[3], int nRefId, double ptP[3]) { // recupero il punto Point3d ptInt ; - if ( ! EgtNearPoint( nId, ptNear, nRefId, ptInt)) + if ( ! ExeNearPoint( nId, ptNear, nRefId, ptInt)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptInt) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ; - if ( pGObj == nullptr) - return false ; - // porto il punto near nel riferimento dell'entità - Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // calcolo il punto della curva più vicino al punto di riferimento - DistPointCurve dstPC( ptNearL, *pCrv) ; - int nFlag ; - if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtIntersectionPoint( int nId1, int nId2, const double ptNear[3], int nRefId, double ptP[3]) { // recupero il punto Point3d ptInt ; - if ( ! EgtIntersectionPoint( nId1, nId2, ptNear, nRefId, ptInt)) + if ( ! ExeIntersectionPoint( nId1, nId2, ptNear, nRefId, ptInt)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptInt) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Point3d& ptP) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // devono essere entità geometriche - const IGeoObj* pGObj1 ; - if ( ( pGObj1 = pGeomDB->GetGeoObj( nId1)) == nullptr) - return false ; - const IGeoObj* pGObj2 ; - if ( ( pGObj2 = pGeomDB->GetGeoObj( nId2)) == nullptr) - return false ; - // se curve - if ( ( pGObj1->GetType() & GEO_CURVE) != 0 && ( pGObj2->GetType() & GEO_CURVE) != 0) { - // recupero le curve - const ICurve* pCrv1 = GetCurve( pGObj1) ; - const ICurve* pCrv2 = GetCurve( pGObj2) ; - // recupero i riferimenti in cui sono immerse - Frame3d frEnt1 ; - if ( ! pGeomDB->GetGlobFrame( nId1, frEnt1)) - return false ; - Frame3d frEnt2 ; - if ( ! pGeomDB->GetGlobFrame( nId2, frEnt2)) - return false ; - // se il riferimento della seconda curva è diverso da quello della prima entità, devo trasformarla - PtrOwner crvTrans( nullptr) ; - if ( ! AreSameFrame( frEnt1, frEnt2)) { - crvTrans.Set( pCrv2->Clone()) ; - if ( IsNull( crvTrans)) - return false ; - crvTrans->LocToLoc( frEnt2, frEnt1) ; - pCrv2 = ::Get( crvTrans) ; - } - // porto il punto Near nel riferimento della prima entità - Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId1, nRefId, ptNearL)) - return false ; - // calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento - IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ; - if ( ! intCC.GetIntersPointNearTo( 0, ptNearL, ptP)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId1, nRefId, ptP) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtStartVector( int nId, int nRefId, double vtV[3]) { // recupero il vettore Vector3d vtStart ; - if ( ! EgtStartVector( nId, nRefId, vtStart)) + if ( ! ExeStartVector( nId, nRefId, vtStart)) return FALSE ; // ritorno il vettore VEC_FROM_3D( vtV, vtStart) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtStartVector( int nId, int nRefId, Vector3d& vtV) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ; - if ( pGObj == nullptr) - return false ; - // se vettore - if ( pGObj->GetType() == GEO_VECT3D) { - // recupero il geo-vettore - const IGeoVector3d* pGV = GetGeoVector3d( pGObj) ; - // assegno il vettore - vtV = pGV->GetVector() ; - } - // se curva - else if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il vettore - if ( ! pCrv->GetStartDir( vtV)) - return false ; - } - // se testo - else if ( pGObj->GetType() == EXT_TEXT) { - // recupero il testo - const IExtText* pTxt = GetExtText( pGObj) ; - // assegno il vettore - vtV = pTxt->GetDirVersor() ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtEndVector( int nId, int nRefId, double vtV[3]) { // recupero il vettore Vector3d vtEnd ; - if ( ! EgtEndVector( nId, nRefId, vtEnd)) + if ( ! ExeEndVector( nId, nRefId, vtEnd)) return FALSE ; // ritorno il vettore VEC_FROM_3D( vtV, vtEnd) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtEndVector( int nId, int nRefId, Vector3d& vtV) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ; - if ( pGObj == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il vettore - if ( ! pCrv->GetEndDir( vtV)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtMidVector( int nId, int nRefId, double vtV[3]) { // recupero il vettore Vector3d vtMid ; - if ( ! EgtMidVector( nId, nRefId, vtMid)) + if ( ! ExeMidVector( nId, nRefId, vtMid)) return FALSE ; // ritorno il vettore VEC_FROM_3D( vtV, vtMid) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtMidVector( int nId, int nRefId, Vector3d& vtV) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il vettore - if ( ! pCrv->GetMidDir( vtV)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtAtParamVector( int nId, double dU, int nSide, int nRefId, double vtV[3]) { // recupero il vettore Vector3d vtAtPar ; - if ( ! EgtAtParamVector( nId, dU, nSide, nRefId, vtAtPar)) + if ( ! ExeAtParamVector( nId, dU, nSide, nRefId, vtAtPar)) return FALSE ; // ritorno il vettore VEC_FROM_3D( vtV, vtAtPar) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se non è entità geometrica - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr) - return false ; - // se curva - if ( ( pGObj->GetType() & GEO_CURVE) != 0) { - // recupero la curva - const ICurve* pCrv = GetCurve( pGObj) ; - // assegno il lato di approccio - ICurve::Side nSide = ICurve::FROM_MINUS ; - if ( nSide > 0) - nSide = ICurve::FROM_PLUS ; - // recupero la direzione - Point3d ptP ; - if ( ! pCrv->GetPointTang( dU, nSide, ptP, vtV)) - return false ; - } - else - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtFrame( int nId, int nRefId, double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3]) { // recupero il frame Frame3d frFrame ; - if ( ! EgtFrame( nId, nRefId, frFrame)) + if ( ! ExeFrame( nId, nRefId, frFrame)) return FALSE ; // assegno l'origine VEC_FROM_3D( ptOrig, frFrame.Orig()) @@ -720,87 +192,18 @@ __stdcall EgtFrame( int nId, int nRefId, double ptOrig[3], double vtX[3], double return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtFrame( int nId, int nRefId, Frame3d& frFrame) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se gruppo - if ( pGeomDB->GetGroupFrame( nId, frFrame)) - // gestione trasformazione ( eventuale) - return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ; - // se geo frame - const IGeoObj* pGObj ; - if ( ( pGObj = pGeomDB->GetGeoObj( nId)) != nullptr && - pGObj->GetType() == GEO_FRAME3D) { - frFrame = GetGeoFrame3d( pGObj)->GetFrame() ; - // gestione trasformazione ( eventuale) - return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ; - } - // errore - return false ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtCurveLength( int nId, double* pdLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pdLen == nullptr) - return FALSE ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // recupero la lunghezza - return ( pCurve->GetLength( *pdLen) ? TRUE : FALSE) ; + return ( ExeCurveLength( nId, pdLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL -__stdcall EgtCurveLengthAtPoint( int nId, double ptOn[3], double dExtend, double* pdLen) +__stdcall EgtCurveLengthAtPoint( int nId, const double ptOn[3], double dExtend, double* pdLen) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pdLen == nullptr) - return FALSE ; - // recupero la curva - const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // determino la posizione parametrica del punto sulla curva (con tolleranza) - int nFlag ; - double dU ; - if ( ! DistPointCurve( ptOn, *pCurve).GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL) - return FALSE ; - // se non richiesta estensione o punto interno alla curva, recupero la lunghezza alla posizione parametrica - if ( dExtend < EPS_SMALL || - ( ! pCurve->IsStartParam( dU) && ! pCurve->IsEndParam( dU))) - return ( pCurve->GetLengthAtParam( dU, *pdLen) ? TRUE : FALSE) ; - // allungo la curva dalla parte del punto - PtrOwner pCopy( pCurve->Clone()) ; - if ( IsNull( pCopy)) - return FALSE ; - double dDeltaIni ; - if ( pCopy->IsStartParam( dU)) { - pCopy->ExtendStartByLen( dExtend) ; - dDeltaIni = dExtend ; - } - else { - pCopy->ExtendEndByLen( dExtend) ; - dDeltaIni = 0 ; - } - if ( ! DistPointCurve( ptOn, *pCopy).GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL) - return FALSE ; - if ( pCopy->GetLengthAtParam( dU, *pdLen)) { - *pdLen -= dDeltaIni ; - return TRUE ; - } - return FALSE ; + return ( ExeCurveLengthAtPoint( nId, ptOn, dExtend, pdLen) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -809,89 +212,38 @@ __stdcall EgtCurveExtrusion( int nId, int nRefId, double vtExtr[3]) { // recupero il vettore estrusione Vector3d vtTmp ; - if ( ! EgtCurveExtrusion( nId, nRefId, vtTmp)) + if ( ! ExeCurveExtrusion( nId, nRefId, vtTmp)) return FALSE ; // lo assegno VEC_FROM_3D( vtExtr, vtTmp) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - // ne ricavo il vettore estrusione - if ( pCurve == nullptr || ! pCurve->GetExtrusion( vtExtr)) - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtExtr) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtCurveThickness( int nId, double* pdThick) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico il parametro - if ( pdThick == nullptr) - return FALSE ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // recupero lo spessore - return ( pCurve->GetThickness( *pdThick) ? TRUE : FALSE) ; + return ( ExeCurveThickness( nId, pdThick) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtGetMinDistPointCurve( const double ptP[3], int nId, double* pdDist) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico i parametri - if ( pdDist == nullptr) - return FALSE ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // calcolo la minima distanza - DistPointCurve distPC( ptP, *pCurve) ; - return ( ( distPC.GetDist( *pdDist)) ? TRUE : FALSE) ; + return ( ExeGetMinDistPointCurve( ptP, nId, pdDist) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL -__stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], int nId, double vtN[3], +__stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], int nId, const double vtN[3], double* pdDist, double ptMin[3], int* pnSide) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // verifico i parametri - if ( pdDist == nullptr || pnSide == nullptr || ptMin == nullptr) + if ( pdDist == nullptr || ptMin == nullptr || pnSide == nullptr) return FALSE ; - // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve == nullptr) - return FALSE ; - // calcolo la minima distanza - DistPointCurve distPC( ptP, *pCurve) ; - // recupero i risultati - if ( ! distPC.GetDist( *pdDist)) - return FALSE ; - int nFlag ; - Point3d ptQ ; - if ( ! distPC.GetMinDistPoint( 0, ptQ, nFlag)) - return FALSE ; - VEC_FROM_3D( ptMin, ptQ) - if ( ! distPC.GetSideAtMinDistPoint( 0, vtN, *pnSide)) + Point3d ptTmp ; + if ( ! ExeGetMinDistPntSidePointCurve( ptP, nId, vtN, pdDist, ptTmp, pnSide)) return FALSE ; + VEC_FROM_3D( ptMin, ptTmp) return TRUE ; } @@ -899,17 +251,7 @@ __stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], int nId, double v BOOL __stdcall EgtCurveArcRadius( int nId, double* pdRad) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // recupero l'arco - const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return FALSE ; - // recupero il raggio - if ( pdRad == nullptr) - return FALSE ; - *pdRad = pArc->GetRadius() ; - return TRUE ; + return ( ExeCurveArcRadius( nId, pdRad) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- @@ -918,89 +260,38 @@ __stdcall EgtCurveArcNormVersor( int nId, int nRefId, double vtNorm[3]) { // recupero il vettore normale Vector3d vtTmp ; - if ( ! EgtCurveArcNormVersor( nId, nRefId, vtTmp)) + if ( ! ExeCurveArcNormVersor( nId, nRefId, vtTmp)) return FALSE ; // lo assegno VEC_FROM_3D( vtNorm, vtTmp) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero l'arco - const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ; - if ( pArc == nullptr) - return false ; - // recupero la normale - vtNorm = pArc->GetNormVersor() ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3]) { // recupero il centro Point3d ptTmp ; - if ( ! EgtCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp)) + if ( ! ExeCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp)) return FALSE ; // lo assegno VEC_FROM_3D( ptCen, ptTmp) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la curva composita - const ICurveComposite* pCompoCrv = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; - if ( pCompoCrv == nullptr) - return false ; - // recupero la curva semplice di indice richiesto - const ICurve* pSimpCrv = pCompoCrv->GetCurve( nSimpCrv) ; - if ( pSimpCrv == nullptr) - return false ; - // recupero il centro - if ( ! pSimpCrv->GetCenterPoint( ptCen)) - return false ; - // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ; -} - //---------------------------------------------------------------------------- int __stdcall EgtSurfTmFacetNbr( int nId) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, 0) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return 0 ; - // recupero il numero delle facce - return pStm->GetFacetNum() ; + return ExeSurfTmFacetNbr( nId) ; } //---------------------------------------------------------------------------- int __stdcall EgtSurfTmFacetFromTria( int nId, int nT) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, SVT_NULL) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return SVT_NULL ; - // recupero il numero della faccia da quello di un suo triangolo - return pStm->GetFacetFromTria( nT) ; + return ExeSurfTmFacetFromTria( nId, nT) ; } //---------------------------------------------------------------------------- @@ -1011,7 +302,7 @@ __stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNea // recupero il punto e la normale Point3d ptTmp ; Vector3d vtN ; - if ( ! EgtSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) + if ( ! ExeSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) return FALSE ; // li assegno VEC_FROM_3D( ptEnd, ptTmp) @@ -1019,48 +310,6 @@ __stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNea return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptEnd, Vector3d& vtN) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return false ; - // porto il punto Near nel riferimento dell'entità - Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) - return false ; - // recupero il punto End più vicino della faccia - if ( ! pStm->GetFacetNearestEndPoint( nFacet, ptNearL, ptEnd, vtN)) - return false ; - // gestione trasformazioni ( eventuali) - return TrasformPoint( pGeomDB, nId, nRefId, ptEnd) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; -} - -//---------------------------------------------------------------------------- -bool -EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptMid, Vector3d& vtN) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return false ; - // porto il punto Near nel riferimento dell'entità - Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) - return false ; - // recupero il punto Mid più vicino della faccia - if ( ! pStm->GetFacetNearestMidPoint( nFacet, ptNearL, ptMid, vtN)) - return false ; - // gestione trasformazioni ( eventuali) - return TrasformPoint( pGeomDB, nId, nRefId, ptMid) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNear[3], int nRefId, @@ -1069,7 +318,7 @@ __stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNea // recupero il punto e la normale Point3d ptTmp ; Vector3d vtN ; - if ( ! EgtSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) + if ( ! ExeSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) return FALSE ; // li assegno VEC_FROM_3D( ptMid, ptTmp) @@ -1084,7 +333,7 @@ __stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3] // recupero il centro e la normale Point3d ptTmp ; Vector3d vtN ; - if ( ! EgtSurfTmFacetCenter( nId, nFacet, nRefId, ptTmp, vtN)) + if ( ! ExeSurfTmFacetCenter( nId, nFacet, nRefId, ptTmp, vtN)) return FALSE ; // li assegno VEC_FROM_3D( ptCen, ptTmp) @@ -1092,213 +341,80 @@ __stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3] return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return false ; - // recupero il centro della faccia - if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN)) - return false ; - // gestione trasformazioni ( eventuali) - return TrasformPoint( pGeomDB, nId, nRefId, ptCen) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, double vtNorm[3]) { // recupero il vettore normale Vector3d vtTmp ; - if ( ! EgtSurfTmFacetNormVersor( nId, nFacet, nRefId, vtTmp)) + if ( ! ExeSurfTmFacetNormVersor( nId, nFacet, nRefId, vtTmp)) return FALSE ; // lo assegno VEC_FROM_3D( vtNorm, vtTmp) return TRUE ; } -//---------------------------------------------------------------------------- -bool -EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie trimesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return false ; - // recupero il centro della faccia - if ( ! pStm->GetFacetNormal( nFacet, vtNorm)) - return false ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; -} - //---------------------------------------------------------------------------- BOOL __stdcall EgtExtTextNormVersor( int nId, int nRefId, double vtNorm[3]) { // recupero il vettore normale Vector3d vtTmp ; - if ( ! EgtExtTextNormVersor( nId, nRefId, vtTmp)) + if ( ! ExeExtTextNormVersor( nId, nRefId, vtTmp)) return FALSE ; // lo assegno VEC_FROM_3D( vtNorm, vtTmp) return TRUE ; } - -//---------------------------------------------------------------------------- -bool -EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il testo - const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTxt == nullptr) - return false ; - // recupero la normale - vtNorm = pTxt->GetNormVersor() ; - // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; -} - - -//------------------------------------------------------------------------------- -// Geo Transforms //------------------------------------------------------------------------------- BOOL __stdcall EgtPointToIdGlob( double ptP[3], int nId) { // trasformo il punto Point3d ptTmp( ptP) ; - if ( ! EgtPointToIdGlob( ptTmp, nId)) + if ( ! ExePointToIdGlob( ptTmp, nId)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptTmp) return TRUE ; } -//------------------------------------------------------------------------------- -bool -EgtPointToIdGlob( Point3d& ptP, int nId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se griglia - if ( nId == GDB_ID_GRID) - return ptP.ToGlob( pGeomDB->GetGridFrame()) ; - // recupero il riferimento - // se gruppo -> il suo proprio espresso in globale - // se oggetto -> quello del gruppo cui appartiene in globale - Frame3d frRef ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && - ! pGeomDB->GetGlobFrame( nId, frRef)) - return false ; - // eseguo la trasformazione - return ptP.ToGlob( frRef) ; -} - //------------------------------------------------------------------------------- BOOL __stdcall EgtPointToIdLoc( double ptP[3], int nId) { // trasformo il punto Point3d ptTmp( ptP) ; - if ( ! EgtPointToIdLoc( ptTmp, nId)) + if ( ! ExePointToIdLoc( ptTmp, nId)) return FALSE ; // ritorno il punto VEC_FROM_3D( ptP, ptTmp) return TRUE ; } -//------------------------------------------------------------------------------- -bool -EgtPointToIdLoc( Point3d& ptP, int nId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se griglia - if ( nId == GDB_ID_GRID) - return ptP.ToLoc( pGeomDB->GetGridFrame()) ; - // recupero il riferimento - // se gruppo -> il suo proprio espresso in globale - // se oggetto -> quello del gruppo cui appartiene in globale - Frame3d frRef ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && - ! pGeomDB->GetGlobFrame( nId, frRef)) - return false ; - // eseguo la trasformazione - return ptP.ToLoc( frRef) ; -} - //------------------------------------------------------------------------------- BOOL __stdcall EgtVectorToIdGlob( double vtV[3], int nId) { // trasformo il vettore Vector3d vtTmp( vtV) ; - if ( ! EgtVectorToIdGlob( vtTmp, nId)) + if ( ! ExeVectorToIdGlob( vtTmp, nId)) return FALSE ; // ritorno il punto VEC_FROM_3D( vtV, vtTmp) return TRUE ; } -//------------------------------------------------------------------------------- -bool -EgtVectorToIdGlob( Vector3d& vtV, int nId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se griglia - if ( nId == GDB_ID_GRID) - return vtV.ToGlob( pGeomDB->GetGridFrame()) ; - // recupero il riferimento - // se gruppo -> il suo proprio espresso in globale - // se oggetto -> quello del gruppo cui appartiene in globale - Frame3d frRef ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && - ! pGeomDB->GetGlobFrame( nId, frRef)) - return false ; - // eseguo la trasformazione - return vtV.ToGlob( frRef) ; -} - //------------------------------------------------------------------------------- BOOL __stdcall EgtVectorToIdLoc( double vtV[3], int nId) { // trasformo il vettore Vector3d vtTmp( vtV) ; - if ( ! EgtVectorToIdLoc( vtTmp, nId)) + if ( ! ExeVectorToIdLoc( vtTmp, nId)) return FALSE ; // ritorno il punto VEC_FROM_3D( vtV, vtTmp) return TRUE ; } -//------------------------------------------------------------------------------- -bool -EgtVectorToIdLoc( Vector3d& vtV, int nId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se griglia - if ( nId == GDB_ID_GRID) - return vtV.ToLoc( pGeomDB->GetGridFrame()) ; - // recupero il riferimento - // se gruppo -> il suo proprio espresso in globale - // se oggetto -> quello del gruppo cui appartiene in globale - Frame3d frRef ; - if ( ! pGeomDB->GetGroupGlobFrame( nId, frRef) && - ! pGeomDB->GetGlobFrame( nId, frRef)) - return false ; - // eseguo la trasformazione - return vtV.ToLoc( frRef) ; -} diff --git a/API_GeoTransform.cpp b/API_GeoTransform.cpp index 651f9a0..8f3c0bf 100644 --- a/API_GeoTransform.cpp +++ b/API_GeoTransform.cpp @@ -14,12 +14,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "GeoTools.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EXeExecutor.h" using namespace std ; @@ -29,61 +25,7 @@ __stdcall EgtMove( int nId, double vVtMove[3], int nRefType) { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtMove( vIds, vVtMove, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // se traslazione espressa in locale - if ( nRefType == RTY_LOC) { - // verifico che tutti gli oggetti siano nello stesso riferimento - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo traslazione - if ( ! pGeomDB->Translate( nId, vtMove)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - // altrimenti in globale o in griglia - else { - Vector3d vtMoveG = vtMove ; - // se griglia, porto il vettore in globale - if ( nRefType == RTY_GRID) - vtMoveG.ToGlob( pGeomDB->GetGridFrame()) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo traslazione - if ( ! pGeomDB->TranslateGlob( nId, vtMoveG)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMove({" + IdListToString( vIds) + "},{" + - ToString( vtMove) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeMove( vIds, vVtMove, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- @@ -92,66 +34,7 @@ __stdcall EgtRotate( int nId, double vPtAx[3], double vVtAx[3], double dAngRotDe { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtRotate( vIds, vPtAx, vVtAx, dAngRotDeg, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // se rotazione espressa in locale - if ( nRefType == RTY_LOC) { - // verifico che tutti gli oggetti siano nello stesso riferimento - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo rotazione - if ( ! pGeomDB->Rotate( nId, ptAx, vtAx, dAngRotDeg)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - // altrimenti in globale o in griglia - else { - Point3d ptAxG = ptAx ; - Vector3d vtAxG = vtAx ; - // se griglia, porto punto e vettore in globale - if ( nRefType == RTY_GRID) { - ptAxG.ToGlob( pGeomDB->GetGridFrame()) ; - vtAxG.ToGlob( pGeomDB->GetGridFrame()) ; - } - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo rotazione - if ( ! pGeomDB->RotateGlob( nId, ptAxG, vtAxG, dAngRotDeg)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRotate({" + IdListToString( vIds) + "},{" + - ToString( ptAx) + "},{" + - ToString( vtAx) + "}," + - ToString( dAngRotDeg) + "," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeRotate( vIds, vPtAx, vVtAx, dAngRotDeg, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- @@ -167,68 +50,7 @@ __stdcall EgtScale( int nId, const double vOrig[3], if ( ! frFrame.Set( vOrig, vX, vY, vZ)) return FALSE ; // eseguo - return ( EgtScale( vIds, frFrame, dCoeffX, dCoeffY, dCoeffZ, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtScale( INTVECTOR& vIds, const Frame3d& frRef, - double dCoeffX, double dCoeffY, double dCoeffZ, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // se scalatura espressa in locale - if ( nRefType == RTY_LOC) { - // verifico che tutti gli oggetti siano nello stesso riferimento - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo scalature - if ( ! pGeomDB->Scale( nId, frRef, dCoeffX, dCoeffY, dCoeffZ)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - // altrimenti in globale o in griglia - else { - Frame3d frRefG = frRef ; - // se griglia, porto riferimento in globale - if ( nRefType == RTY_GRID) - frRefG.ToGlob( pGeomDB->GetGridFrame()) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo scalature - if ( ! pGeomDB->ScaleGlob( nId, frRefG, dCoeffX, dCoeffY, dCoeffZ)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtScale({" + IdListToString( vIds) + "},{{" + - ToString( frRef.Orig()) + "},{" + - ToString( frRef.VersX()) + "},{" + - ToString( frRef.VersY()) + "},{" + - ToString( frRef.VersZ()) + "}}," + - ToString( dCoeffX) + "," + - ToString( dCoeffY) + "," + - ToString( dCoeffZ) + "," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeScale( vIds, frFrame, dCoeffX, dCoeffY, dCoeffZ, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- @@ -237,65 +59,7 @@ __stdcall EgtMirror( int nId, const double vPnt[3], const double vN[3], int nRef { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtMirror( vIds, vPnt, vN, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // se specularità espressa in locale - if ( nRefType == RTY_LOC) { - // verifico che tutti gli oggetti siano nello stesso riferimento - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo riflessione - if ( ! pGeomDB->Mirror( nId, ptP, vtN)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - // altrimenti in globale o in griglia - else { - Point3d ptPG = ptP ; - Vector3d vtNG = vtN ; - // se griglia, porto riferimento in globale - if ( nRefType == RTY_GRID) { - ptPG.ToGlob( pGeomDB->GetGridFrame()) ; - vtNG.ToGlob( pGeomDB->GetGridFrame()) ; - } - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo riflessione - if ( ! pGeomDB->MirrorGlob( nId, ptPG, vtNG)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMirror({" + IdListToString( vIds) + "},{" + - ToString( ptP) + "},{" + - ToString( vtN) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; + return ( ExeMirror( vIds, vPnt, vN, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- @@ -305,96 +69,21 @@ __stdcall EgtShear( int nId, const double vPnt[3], const double vN[3], { INTVECTOR vIds ; vIds.push_back( nId) ; - return ( EgtShear( vIds, vPnt, vN, vDir, dCoeff, nRefType) ? TRUE : FALSE) ; -} - -//------------------------------------------------------------------------------- -bool -EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, - const Vector3d& vtDir, double dCoeff, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // se stiramento espresso in locale - if ( nRefType == RTY_LOC) { - // verifico che tutti gli oggetti siano nello stesso riferimento - bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo stiramento - if ( ! pGeomDB->Shear( nId, ptP, vtN, vtDir, dCoeff)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - // altrimenti in globale o in griglia - else { - Point3d ptPG = ptP ; - Vector3d vtNG = vtN ; - Vector3d vtDirG = vtDir ; - // se griglia, porto riferimento in globale - if ( nRefType == RTY_GRID) { - ptPG.ToGlob( pGeomDB->GetGridFrame()) ; - vtNG.ToGlob( pGeomDB->GetGridFrame()) ; - vtDirG.ToGlob( pGeomDB->GetGridFrame()) ; - } - // ciclo sul vettore degli identificativi - for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; - while ( nId != GDB_ID_NULL) { - // eseguo stiramento - if ( ! pGeomDB->ShearGlob( nId, ptPG, vtNG, vtDirG, dCoeff)) - bOk = false ; - // passo alla successiva - nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; - } - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtShear({" + IdListToString( vIds) + "},{" + - ToString( ptP) + "},{" + - ToString( vtN) + "},{" + - ToString( vtDir) + "}," + - ToString( dCoeff) + "," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeShear( vIds, vPnt, vN, vDir, dCoeff, nRefType) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtMoveGroup( int nId, double vVtMove[3]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo traslazione ( solo singola) - bool bOk = pGeomDB->TranslateGroup( nId, vVtMove) ; - EgtSetModified() ; - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeMoveGroup( nId, vVtMove) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtRotateGroup( int nId, double vPtAx[3], double vVtAx[3], double dAngRotDeg) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo rotazione ( solo singola) - bool bOk = pGeomDB->RotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ; - EgtSetModified() ; - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeRotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- @@ -403,43 +92,26 @@ __stdcall EgtScaleGroup( int nId, const double vOrig[3], const double vX[3], const double vY[3], const double vZ[3], double dCoeffX, double dCoeffY, double dCoeffZ) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; // costruisco il riferimento di scalatura Frame3d frFrame ; if ( ! frFrame.Set( vOrig, vX, vY, vZ)) - bOk = false ; - // eseguo scalatura ( solo singola) - bOk = bOk && pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ; - EgtSetModified() ; - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return FALSE ; + // eseguo + return ( ExeScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ? TRUE : FALSE) ; } //------------------------------------------------------------------------------- BOOL __stdcall EgtMirrorGroup( int nId, const double vPnt[3], const double vN[3]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo riflessione ( solo singola) - bool bOk = pGeomDB->MirrorGroup( nId, vPnt, vN) ; - EgtSetModified() ; - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeMirrorGroup( nId, vPnt, vN) ? TRUE : FALSE) ; } + //------------------------------------------------------------------------------- BOOL __stdcall EgtShearGroup( int nId, const double vPnt[3], const double vN[3], const double vDir[3], double dCoeff) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // eseguo stiramento ( solo singolo) - bool bOk = pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ; - EgtSetModified() ; - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeShearGroup( nId, vPnt, vN, vDir, dCoeff) ? TRUE : FALSE) ; } diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 57e1f8a..03f9c0c 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -14,12 +14,9 @@ //--------------------------- Include ---------------------------------------- #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/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -27,61 +24,35 @@ using namespace std ; int __stdcall EgtInitGeomDB( void) { - // creo e recupero un contesto libero - int nGseCtx = CreateGseContext() ; - if ( nGseCtx == 0) { - ResetCurrGseContext() ; - LOG_ERROR( GetLogger(), "Error in CreateGseContext (" __FUNCTION__ ")") - return 0 ; - } - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - // inizializzazioni DB geometrico - PtrOwner pGeomDB( CreateGeomDB()) ; - VERIFY_NULL( Get( pGeomDB), "Error in CreateGeomDB", nGseCtx) - // inserisco il GeomDB nel contesto - pGseCtx->m_pGeomDB = Release( pGeomDB) ; - pGseCtx->m_pGeomDB->Init() ; - pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; - // rendo corrente il contesto - SetCurrGseContext( nGseCtx) ; - // log avvio DB geometrico - string sLog = "GeomDB started " + ToString( nGseCtx) ; - LOG_INFO( GetLogger(), sLog.c_str()) - - return nGseCtx ; + return ExeInitGeomDB() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetCurrentContext( int nGseCtx) { - return ( SetCurrGseContext( nGseCtx) ? TRUE : FALSE) ; + return ( ExeSetCurrentContext( nGseCtx) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetCurrentContext( void) { - return ( ResetCurrGseContext() ? TRUE : FALSE) ; + return ( ExeResetCurrentContext() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetCurrentContext( void) { - return GetIndCurrGseContext() ; + return ExeGetCurrentContext() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetDefaultMaterial( const int vCol[4]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // imposto il materiale di default - pGseCtx->m_colDef.Set( vCol) ; - pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; - return TRUE ; + return ( ExeSetDefaultMaterial( vCol) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -93,27 +64,7 @@ __stdcall EgtSetGridFrame( const double ptOrig[3], const double vX[3], const dou if ( ! frFrame.Set( ptOrig, vX, vY, vZ)) return FALSE ; // imposto il riferimento della griglia - return ( EgtSetGridFrame( frFrame) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetGridFrame( const Frame3d& frFrame) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // imposto il riferimento della griglia - bool bOk = pGeomDB->SetGridFrame( frFrame) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetGridFrame({{" + ToString( frFrame.Orig()) + "},{" + - ToString( frFrame.VersX()) + "},{" + - ToString( frFrame.VersY()) + "},{" + - ToString( frFrame.VersZ()) + "}})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return bOk ; + return ( ExeSetGridFrame( frFrame) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -122,7 +73,7 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double { // recupero il riferimento della griglia Frame3d frGrid ; - if ( EgtGetGridFrame( GDB_ID_ROOT, frGrid)) { + if ( ExeGetGridFrame( GDB_ID_ROOT, frGrid)) { // assegno i valori di ritorno VEC_FROM_3D( ptOrig, frGrid.Orig()) VEC_FROM_3D( vX, frGrid.VersX()) @@ -134,62 +85,11 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double return FALSE ; } -//----------------------------------------------------------------------------- -bool -EgtGetGridFrame( int nRefId, Frame3d& frFrame) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il riferimento della griglia - frFrame = pGeomDB->GetGridFrame() ; - // se richiesto nel riferimento globale, esco subito - if ( nRefId == GDB_ID_ROOT) - return true ; - // recupero il riferimento destinazione (nRefId può essere un gruppo o una entità) - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - // eseguo la trasformazione - return frFrame.ToLoc( frDest) ; -} - -//----------------------------------------------------------------------------- -bool -EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il versore Z della griglia - vtVersZ = pGeomDB->GetGridFrame().VersZ() ; - // se richiesto nel riferimento globale, esco subito - if ( nRefId == GDB_ID_ROOT) - return true ; - // recupero il riferimento destinazione (nRefId può essere un gruppo o una entità) - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - // eseguo la trasformazione - return vtVersZ.ToLoc( frDest) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtSetCurrFilePath( const wchar_t* wsFilePath) { - return ( EgtSetCurrFilePath( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetCurrFilePath( const string& sFilePath) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - // assegno la path - pGseCtx->m_sFilePath = sFilePath ; - return true ; + return ( ExeSetCurrFilePath( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -199,259 +99,78 @@ __stdcall EgtGetCurrFilePath( wchar_t*& wsFilePath) if ( &wsFilePath == nullptr) return false ; string sFilePath ; - if ( ! EgtGetCurrFilePath( sFilePath)) + if ( ! ExeGetCurrFilePath( sFilePath)) return FALSE ; wsFilePath = _wcsdup( stringtoW( sFilePath)) ; return (( wsFilePath == nullptr) ? FALSE : TRUE) ; } -//----------------------------------------------------------------------------- -bool -EgtGetCurrFilePath( string& sFilePath) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - // restituisco la path - sFilePath = pGseCtx->m_sFilePath ; - return ( ! sFilePath.empty()) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtEnableModified( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // abilito possibilità di alterare il flag di modifica - pGseCtx->m_bEnableModified = true ; - return TRUE ; + return ( ExeEnableModified() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDisableModified( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // disabilito possibilità di alterare il flag di modifica - pGseCtx->m_bEnableModified = false ; - return TRUE ; + return ( ExeDisableModified() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetModified( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // se consentito, imposto il flag - if ( pGseCtx->m_bEnableModified) - pGseCtx->m_bModified = true ; - return TRUE ; + return ( ExeSetModified() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetModified( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // se consentito, cancello il flag - if ( pGseCtx->m_bEnableModified) - pGseCtx->m_bModified = false ; - return TRUE ; + return ( ExeResetModified() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetModified( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - // imposto il flag - return ( pGseCtx->m_bModified ? TRUE : FALSE) ; + return ( ExeGetModified() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtNewFile( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - bool bOk = true ; - // reinizializzazione (con pulizia) del DB geometrico - bOk = bOk && pGseCtx->m_pGeomDB->Init() ; - bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath.clear() ; - pGseCtx->m_bModified = false ; - // aggiornamento gestore lavorazioni - EgtUpdateMachMgr() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtNewFile()" - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeNewFile() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtOpenFile( const wchar_t* wsFilePath) { - return ( EgtOpenFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtOpenFile( const string& sFilePath) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - bool bOk = true ; - // reinizializzazione (con pulizia) del DB geometrico - bOk = bOk && pGseCtx->m_pGeomDB->Init() ; - bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; - // carico il file - bOk = bOk && pGseCtx->m_pGeomDB->Load( sFilePath) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; - pGseCtx->m_bModified = false ; - // aggiornamento gestore lavorazioni - EgtUpdateMachMgr() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtOpenFile('" + sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeOpenFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtInsertFile( const wchar_t* wsFilePath) { - return ( EgtInsertFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtInsertFile( const string& sFilePath) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; - // creo gruppo temporaneo di parcheggio - int nGrp = pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ; - bool bOk = ( nGrp != GDB_ID_NULL) ; - bOk = bOk && pGeomDB->SetLevel( nGrp, GDB_LV_TEMP) ; - // carico il file - bOk = bOk && pGeomDB->Load( sFilePath, nGrp) ; - // sposto i pezzi sotto la radice - int nId = pGeomDB->GetFirstGroupInGroup( nGrp) ; - while ( bOk && nId != GDB_ID_NULL) { - // prossimo gruppo - int nNextId = pGeomDB->GetNextGroup( nId) ; - // se il gruppo corrente è un pezzo, lo sposto - int nLevel ; - if ( ! pGeomDB->GetLevel( nId, nLevel) || nLevel == GDB_LV_USER) - bOk = pGeomDB->Relocate( nId, GDB_ID_ROOT, GDB_LAST_SON) ; - // passo al prossimo - nId = nNextId ; - } - // sistemo le lavorazioni - bOk = bOk && EgtInsertMachMgr( nGrp) ; - // cancello il gruppo temporaneo - pGeomDB->Erase( nGrp) ; - // aggiorno stato file corrente - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtInsertFile('" + sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeInsertFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSaveFile( const wchar_t* wsFilePath, int nFlag) { - return ( EgtSaveFile( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSaveFile( const string& sFilePath, int nFlag) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - // se ero in CAM, esco - int nCurrMachGroup = EgtGetCurrMachGroup() ; - EgtResetCurrMachGroup() ; - // salvo il file - bool bOk = pGseCtx->m_pGeomDB->Save( GDB_ID_ROOT, sFilePath, nFlag) ; - // eventuale ripristino precedente CAM - if ( nCurrMachGroup != GDB_ID_NULL) - EgtSetCurrMachGroup( nCurrMachGroup) ; - // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; - if ( bOk) - pGseCtx->m_bModified = false ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtSaveFile('" + sLuaPath + "'," + - NgeTypeToString( nFlag) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeSaveFile( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSaveObjToFile( int nId, const wchar_t* wsFilePath, int nFlag) { - return ( EgtSaveObjToFile( nId, wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSaveObjToFile( int nId, const string& sFilePath, int nFlag) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // se ero in CAM, esco - int nCurrMachGroup = EgtGetCurrMachGroup() ; - EgtResetCurrMachGroup() ; - // copio l'oggetto nel file - bool bOk = pGeomDB->Save( nId, sFilePath, nFlag) ; - // ripristino eventuale precedente CAM - if ( nCurrMachGroup != GDB_ID_NULL) - EgtSetCurrMachGroup( nCurrMachGroup) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtSaveObjToFile('" + sLuaPath + "'," + - ToString( nId) + "," + - NgeTypeToString( nFlag) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ( ExeSaveObjToFile( nId, wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; } diff --git a/API_Lua.cpp b/API_Lua.cpp index be9438b..4c1b06d 100644 --- a/API_Lua.cpp +++ b/API_Lua.cpp @@ -14,23 +14,17 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "LUA_Base.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" using namespace std ; - //----------------------------------------------------------------------------- BOOL __stdcall EgtLuaEvalNumExpr( const wchar_t* wsExpr, double* pdVal) { - // verifico parametro di ritorno - if ( pdVal == nullptr) - return FALSE ; - // valuto l'espressione - return ( LuaEvalNumExpr( wstrztoA( wsExpr), *pdVal) ? TRUE : FALSE) ; + return ( ExeLuaEvalNumExpr( wstrztoA( wsExpr), pdVal) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -39,11 +33,12 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal) { // verifico parametro di ritorno if ( &wsVal == nullptr) - return false ; + return FALSE ; // valuto l'espressione string sVal ; - if ( ! LuaEvalStringExpr( wstrztoA( wsExpr), sVal)) + if ( ! ExeLuaEvalStringExpr( wstrztoA( wsExpr), sVal)) return FALSE ; + // alloco buffer di ritorno ed eseguo copia wsVal = _wcsdup( stringtoW( sVal)) ; return (( wsVal == nullptr) ? FALSE : TRUE) ; } @@ -52,69 +47,35 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal) BOOL __stdcall EgtLuaExecLine( const wchar_t* wsLine) { - // disabilito log dei comandi e salvo stato precedente - bool bPrevCmdLog = SetCmdLog( false) ; - // eseguo il comando - string sLine = wstrztoA( wsLine) ; - bool bOk = LuaExecLine( sLine) ; - // ripristino lo stato originale del log dei comandi - SetCmdLog( bPrevCmdLog) ; - // se richiesto, salvo il comando Lua - if ( IsCmdLog()) { - string sLua = sLine + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeLuaExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtLuaExecFile( const wchar_t* wsFilePath) { - // converto nome file - string sFilePath = wstrztoA( wsFilePath) ; - // emetto info - string sInfo = "Exec File = " + sFilePath ; - LOG_INFO( GetLogger(), sInfo.c_str()) - // disabilito il log dei comandi - bool bPrevCmdLog = IsCmdLog() ; - EgtDisableCommandLogger() ; - // esecuzione script - bool bOk = LuaExecFile( sFilePath) ; - // ripristino lo stato originale del log dei comandi - if ( bPrevCmdLog) - EgtEnableCommandLogger() ; - // se richiesto, salvo il comando Lua - if ( IsCmdLog()) { - string sLuaPath = sFilePath ; - ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "dofile('" + sLuaPath + "')" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeLuaExecFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtLuaRequire( const wchar_t* wsFilePath) { - // converto nome file - string sFilePath = wstrztoA( wsFilePath) ; - // emetto info - string sInfo = "Require Library = " + sFilePath ; - LOG_INFO( GetLogger(), sInfo.c_str()) - // eseguo il comando - return ( LuaRequire( sFilePath) ? TRUE : FALSE) ; + return ( ExeLuaRequire( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtLuaGetLastError( wchar_t*& wsError) { - wsError = _wcsdup( stringtoW( LuaGetLastError())) ; + // verifico parametro di ritorno + if ( &wsError == nullptr) + return FALSE ; + // recupero l'errore + string sError ; + if ( ! ExeLuaGetLastError( sError)) + return FALSE ; + // alloco buffer di ritorno ed eseguo copia + wsError = _wcsdup( stringtoW( sError)) ; return (( wsError == nullptr) ? FALSE : TRUE) ; -} \ No newline at end of file +} diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index d438c99..1b59e72 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -14,13 +14,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "AuxTools.h" -#include "DllMachKernel.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -28,117 +24,42 @@ using namespace std ; BOOL __stdcall EgtInitMachMgr( const wchar_t* wsMachinesDir) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX( pGseCtx, FALSE) - // inizializzazione gestore lavorazioni - PtrOwner pMachMgr( MyCreateMachMgr()) ; - VERIFY_NULL( Get( pMachMgr), "Error in CreateMachMgr", FALSE) - string sMachinesDir = wstrztoA( wsMachinesDir) ; - bool bOk = pMachMgr->Init( pGseCtx->m_pGeomDB, sMachinesDir) ; - // assegno il gestore al contesto - pGseCtx->m_pMachMgr = ( bOk ? Release( pMachMgr) : nullptr) ; - // log avvio Machining Manager - string sLog = "MachMgr " ; - sLog += ( bOk ? " started" : " error") ; - sLog += " (" + sMachinesDir + ")" ; - LOG_INFO( GetLogger(), sLog.c_str()) - return ( bOk ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtUpdateMachMgr( void) -{ - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, false) - // aggiornamento gestore lavorazioni - return pMachMgr->Update() ; -} - -//----------------------------------------------------------------------------- -bool -EgtInsertMachMgr( int nInsGrp) -{ - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, false) - // sposto le macchinate dal gruppo di inserimento alla base macchinate - return pMachMgr->Insert( nInsGrp) ; + return ( ExeInitMachMgr( wstrztoA( wsMachinesDir)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetMachGroupNbr( void) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, 0) - // recupero il numero di macchinate - return pMachMgr->GetMachGroupNbr() ; + return ExeGetMachGroupNbr() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetFirstMachGroup( void) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) - // recupero la prima macchinata - return pMachMgr->GetFirstMachGroup() ; + return ExeGetFirstMachGroup() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNextMachGroup( int nId) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) - // recupero la successiva macchinata - return pMachMgr->GetNextMachGroup( nId) ; + return ExeGetNextMachGroup( nId) ; } //----------------------------------------------------------------------------- int __stdcall EgtAddMachGroup( const wchar_t* wsName, const wchar_t* wsMachineName) { - return EgtAddMachGroup( wstrztoA( wsName), wstrztoA( wsMachineName)) ; -} - -//----------------------------------------------------------------------------- -int -EgtAddMachGroup( const string& sName, const string& sMachineName) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) - // aggiungo la macchinata (gruppo di lavorazione) - int nId = pGseCtx->m_pMachMgr->AddMachGroup( sName, sMachineName) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtAddMachGroup('" + sName + "','" + - sMachineName + "')" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return nId ; + return ExeAddMachGroup( wstrztoA( wsName), wstrztoA( wsMachineName)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRemoveMachGroup( int nMGroupId) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) - // rimuovo la macchinata (gruppo di lavorazione) - bool bOk = pGseCtx->m_pMachMgr->RemoveMachGroup( nMGroupId) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRemoveMachGroup(" + ToString( nMGroupId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeRemoveMachGroup( nMGroupId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -148,392 +69,36 @@ __stdcall EgtGetMachGroupName( int nMGroupInd, wchar_t*& wsName) if ( &wsName == nullptr) return FALSE ; string sName ; - if ( ! EgtGetMachGroupName( nMGroupInd, sName)) + if ( ! ExeGetMachGroupName( nMGroupInd, sName)) return FALSE ; wsName = _wcsdup( stringtoW( sName)) ; return (( wsName == nullptr) ? FALSE : TRUE) ; } -//----------------------------------------------------------------------------- -bool -EgtGetMachGroupName( int nId, string& sName) -{ - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, false) - // recupero il nome della macchinata - sName = pMachMgr->GetMachGroupName( nId) ; - return ( ! sName.empty()) ; -} - //----------------------------------------------------------------------------- BOOL __stdcall EgtGetMachGroupId( const wchar_t* wsName) { - return EgtGetMachGroupId( wstrztoA( wsName)) ; -} - -//----------------------------------------------------------------------------- -int -EgtGetMachGroupId( const string& sName) -{ - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, false) - // recupero l'indice della macchinata - return pMachMgr->GetMachGroupId( sName) ; + return ExeGetMachGroupId( wstrztoA( wsName)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetCurrMachGroup( int nMGroupId) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, FALSE) - // imposto la macchinata corrente - bool bOk = pGseCtx->m_pMachMgr->SetCurrMachGroup( nMGroupId) ; - // non cambia lo stato di modificato del progetto - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSetCurrMachGroup(" + ToString( nMGroupId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeSetCurrMachGroup( nMGroupId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetCurrMachGroup( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, FALSE) - // reset macchinata corrente - bool bOk = pGseCtx->m_pMachMgr->ResetCurrMachGroup() ; - // non cambia lo stato di modificato del progetto - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtResetCurrMachGroup()" - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return ( bOk ? TRUE : FALSE) ; + return ( ExeResetCurrMachGroup() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetCurrMachGroup( void) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) - // restituisco identificativo macchinata corrente - 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) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) - // inserisco grezzo nella macchinata corrente - int nId = pGseCtx->m_pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtAddRawPart({" + ToString( ptOrig) + "}," + - ToString( dWidth) + "," + - ToString( dLength) + "," + - ToString( dHeight) + ",{" + - ToString( cCol) + "})" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return nId ; -} - -//----------------------------------------------------------------------------- -int -EgtAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) - // inserisco grezzo con pezzo nella macchinata corrente - int nId = pGseCtx->m_pMachMgr->AddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtAddRawPartWithPart(" + ToString( nPartId) + "," + - ToString( nCrvId) + "," + - ToString( dOverMat) + ",{" + - ToString( cCol) + "})" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return nId ; -} - -//----------------------------------------------------------------------------- -bool -EgtModifyRawPartHeight( int nRawId, double dHeight) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // modifico lo spessore del grezzo - bool bOk = pGseCtx->m_pMachMgr->ModifyRawPartHeight( nRawId, dHeight) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtModifyRawPartHeight(" + ToString( nRawId) + "," + - ToString( dHeight) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtRemoveRawPart( int nRawId) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // elimino grezzo dalla macchinata corrente - bool bOk = pGseCtx->m_pMachMgr->RemoveRawPart( nRawId) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRemoveRawPart(" + ToString( nRawId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtTranslateRawPart( int nRawId, const Vector3d& vtMove) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // traslo il grezzo - bool bOk = pGseCtx->m_pMachMgr->TranslateRawPart( nRawId, vtMove) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMoveRawPart(" + ToString( nRawId) + ",{" + - ToString( vtMove) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // ruoto il grezzo - bool bOk = pGseCtx->m_pMachMgr->RotateRawPart( nRawId, vtAx, dAngRotDeg) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRotateRawPart(" + ToString( nRawId) + ",{" + - ToString( vtAx) + "}," + - ToString( dAngRotDeg) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // mando il grezzo nel corner - bool bOk = pGseCtx->m_pMachMgr->MoveToCornerRawPart( nRawId, ptCorner, nFlag) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMoveToCornerRawPart(" + ToString( nRawId) + ",{" + - ToString( ptCorner) + "}," + - RawPartCornerPosToString( nFlag) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // mando il grezzo nel corner - bool bOk = pGseCtx->m_pMachMgr->MoveToCenterRawPart( nRawId, ptCenter, nFlag) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMoveToCenterRawPart(" + ToString( nRawId) + ",{" + - ToString( ptCenter) + "}," + - RawPartCenterPosToString( nFlag) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - 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) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // elimino pezzo da grezzo della macchinata corrente - bool bOk = pGseCtx->m_pMachMgr->RemovePartFromRawPart( nPartId) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRemovePartFromRawPart(" + ToString( nPartId) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtTranslatePartInRawPart( int nPartId, const Vector3d& vtMove) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // traslo il pezzo nel grezzo - bool bOk = pGseCtx->m_pMachMgr->TranslatePartInRawPart( nPartId, vtMove) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtMovePartInRawPart(" + ToString( nPartId) + ",{" + - ToString( vtMove) + "})" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -EgtRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_MACHMGR( pGseCtx, false) - // ruoto il pezzo nel grezzo - bool bOk = pGseCtx->m_pMachMgr->RotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ; - pGseCtx->m_bModified = true ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtRotatePartInRawPart(" + ToString( nPartId) + ",{" + - ToString( vtAx) + "}," + - ToString( dAngRotDeg) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; + return ExeGetCurrMachGroup() ; } diff --git a/API_Macro.h b/API_Macro.h deleted file mode 100644 index 5dd8470..0000000 --- a/API_Macro.h +++ /dev/null @@ -1,54 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : API_Macro Data : 03.09.14 Versione : 1.5i1 -// Contenuto : Macro locali per moduli API. -// -// -// -// Modifiche : 03.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - - -//----------------------------------------------------------------------------- -#define VERIFY_NULL( pO, Msg, Ret) if ( pO == nullptr) { \ - LOG_ERROR( GetLogger(), Msg " (" __FUNCTION__ ")") \ - return Ret ; \ - } - -//----------------------------------------------------------------------------- -#define VERIFY_2NULL( pO, pQ, Msg, Ret) if ( pO == nullptr || pQ == nullptr) { \ - LOG_ERROR( GetLogger(), Msg " (" __FUNCTION__ ")") \ - return Ret ; \ - } - -//----------------------------------------------------------------------------- -#define VERIFY_CTX( pC, Ret) VERIFY_NULL( pC, "Context invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_GEOMDB( pG, Ret) VERIFY_NULL( pG, "GeomDB invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_CTX_GEOMDB( pC, Ret) VERIFY_2NULL( pC, pC->m_pGeomDB, "Context or GeomDB invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_MACHMGR( pM, Ret) VERIFY_NULL( pM, "MachMgr invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_CTX_MACHMGR( pC, Ret) VERIFY_2NULL( pC, pC->m_pMachMgr, "Context or MachMgr invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_SCENE( pS, Ret) VERIFY_NULL( pS, "Scene invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_CTX_SCENE( pC, Ret) VERIFY_2NULL( pC, pC->m_pScene, "Context or Scene invalid", Ret) - -//----------------------------------------------------------------------------- -#define VERIFY_TSCEXEC( pT, Ret) VERIFY_NULL( pT, "TscExecutor invalid", Ret) - -//----------------------------------------------------------------------------- -#define VEC_FROM_3D( D, S) { (D)[0] = (S).x ; (D)[1] = (S).y ; (D)[2] = (S).z ; } diff --git a/API_Messages.cpp b/API_Messages.cpp index 30e34c7..e0b415c 100644 --- a/API_Messages.cpp +++ b/API_Messages.cpp @@ -15,81 +15,27 @@ #include "stdafx.h" #include "API.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDEv/Include/EGnScan.h" -#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDEv/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtLogger.h" -#include using namespace std ; //---------------------------------------------------------------------------- -typedef unordered_map< int, string> INTSTR_UMAP ; -INTSTR_UMAP s_IdStringMap ; -wstring s_wsMsg ; +static wstring s_wsMsg ; //---------------------------------------------------------------------------- BOOL __stdcall EgtLoadMessages( const wchar_t* wsMsgFilePath) { - // inizializzo lo scanner - string sMsgFilePath = wstrztoA( 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) ; - // leggo le linee - string sLine ; - sLine.reserve( 128) ; - string sNum ; - sNum.reserve( 16) ; - string sMsg ; - sMsg.reserve( 128) ; - int nNum ; - int nCurrNum = - 1 ; - while ( scan.GetLine( sLine)) { - // divido la linea in due parti sul token '=' - Split( sLine, "=", true, sNum, sMsg) ; - // la prima parte deve essere numerica - if ( sNum.empty() || ! FromString( sNum, nNum)) { - string sOut ; - sOut = "Problem in " + sMsgFilePath + " at line " + ToString( scan.GetCurrLineNbr()) + " : " + sLine ; - LOG_WARN( GetLogger(), sOut.c_str()) - continue ; - } - // la numerazione deve essere crescente - if ( nNum <= nCurrNum) { - string sOut ; - sOut = "Error in " + sMsgFilePath + " at message " + sNum + " : " + sLine ; - LOG_ERROR( GetLogger(), sOut.c_str()) - return FALSE ; - } - nCurrNum = nNum ; - // converto i caratteri speciali - ReplaceString( sMsg, "
", "\n") ; - // inserisco il messaggio in tabella - if ( ! s_IdStringMap.emplace( nNum, sMsg).second) - return FALSE ; - } - - // termino lo scanner - return ( scan.Terminate() ? TRUE :FALSE) ; + return ( ExeLoadMessages( wstrztoA( wsMsgFilePath)) ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- const wchar_t* __stdcall EgtGetMsg( int nMsg) { - // recupero il messaggio - INTSTR_UMAP::iterator Iter = s_IdStringMap.find( nMsg) ; - if ( Iter != s_IdStringMap.end()) - s_wsMsg = stringtoW( Iter->second) ; - else - s_wsMsg = stringtoW( ( "Msg" + ToString( nMsg))) ; + s_wsMsg = stringtoW( ExeGetMsg( nMsg)) ; return s_wsMsg.c_str() ; -} \ No newline at end of file +} diff --git a/API_Scene.cpp b/API_Scene.cpp index b05ae14..ddd3028 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -14,60 +14,31 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "DllGraphics.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; - //----------------------------------------------------------------------------- BOOL -__stdcall EgtInitScene( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits) +__stdcall EgtInitScene( HWND hWnd, int nDriver, BOOL b2Buff, int nColorBits, int nDepthBits) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX( pGseCtx, FALSE) - // inizializzazione scena OpenGL - PtrOwner pScene( MyCreateEGrScene()) ; - VERIFY_NULL( Get( pScene), "Error in CreateEGrScene", FALSE) - HDC hdc = GetDC( hWnd) ; - if ( ! pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits)) - return FALSE ; - pScene->SetBackground( WHITE, WHITE) ; - pScene->SetShowMode( SM_SHADING) ; - pScene->SetShowCurveDirection( false) ; - pScene->SetCamera( CT_TOP) ; - pScene->ZoomAll() ; - pScene->SetWinRectAttribs( true, BLACK) ; - pScene->SetMark( YELLOW) ; - pScene->Init( pGseCtx->m_pGeomDB) ; - // assegno la scena al contesto - pGseCtx->m_hWnd = hWnd ; - pGseCtx->m_pScene = Release( pScene) ; - // log con info sulla scena - string sSceneInfo = pGseCtx->m_pScene->GetOpenGLInfo() + '\n' + - pGseCtx->m_pScene->GetGLSLInfo() + '\n' + - pGseCtx->m_pScene->GetPixelFormatInfo() ; - LOG_INFO( GetLogger(), sSceneInfo.c_str()) - - return TRUE ; + return ( ExeInitScene( hWnd, nDriver, ( b2Buff != FALSE), nColorBits, nDepthBits) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetSceneInfo( wchar_t*& wsInfo) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // recupero le informazioni sulla scena + // verifico parametro di ritorno + if ( &wsInfo == nullptr) + return FALSE ; + // recupero le informazioni string sInfo ; - sInfo += pGseCtx->m_pScene->GetOpenGLInfo() ; - sInfo += "\r\n" ; - sInfo += pGseCtx->m_pScene->GetGLSLInfo() ; - sInfo += "\r\n" ; - sInfo += pGseCtx->m_pScene->GetPixelFormatInfo() ; + if ( ! ExeGetSceneInfo( sInfo)) + return FALSE ; + // alloco buffer di ritorno ed eseguo copia wsInfo = _wcsdup( stringtoW( sInfo)) ; return (( wsInfo == nullptr) ? FALSE : TRUE) ; } @@ -76,254 +47,145 @@ __stdcall EgtGetSceneInfo( wchar_t*& wsInfo) BOOL __stdcall EgtSetBackground( const int TopCol[4], const int BottomCol[4], BOOL bRedraw) { - return ( EgtSetBackground( Color( TopCol), Color( BottomCol), ( bRedraw != FALSE)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto lo sfondo - pGseCtx->m_pScene->SetBackground( TopCol, BottomCol) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return true ; + return ( ExeSetBackground( Color( TopCol), Color( BottomCol), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMarkAttribs( const int MarkCol[4]) { - return ( EgtSetMarkAttribs( Color( MarkCol)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetMarkAttribs( Color MarkCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto il colore del Mark - return pGseCtx->m_pScene->SetMark( MarkCol) ; + return ( ExeSetMarkAttribs( Color( MarkCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetSelSurfAttribs( const int SelSurfCol[4]) { - return ( EgtSetSelSurfAttribs( Color( SelSurfCol)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetSelSurfAttribs( Color SelSurfCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto il colore del Mark - return pGseCtx->m_pScene->SetSelSurf( SelSurfCol) ; + return ( ExeSetSelSurfAttribs( Color( SelSurfCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoLineAttribs( const int GlCol[4]) { - return ( EgtSetGeoLineAttribs( Color( GlCol)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetGeoLineAttribs( Color GlCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto il colore della linea geometrica gestita direttamente dalla scena - return pGseCtx->m_pScene->SetGeoLineAttribs( GlCol) ; + return ( ExeSetGeoLineAttribs( Color( GlCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoTriaAttribs( const int GtCol[4]) { - return ( EgtSetGeoTriaAttribs( Color( GtCol)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetGeoTriaAttribs( Color GtCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto il colore del triangolo immediato - return pGseCtx->m_pScene->SetGeoTriaAttribs( GtCol) ; + return ( ExeSetGeoTriaAttribs( Color( GtCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRectAttribs( BOOL bOutline, const int WrCol[4]) { - return ( EgtSetWinRectAttribs( ( bOutline != FALSE), Color( WrCol)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtSetWinRectAttribs( bool bOutline, Color WrCol) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, false) - // imposto il colore della linea geometrica gestita direttamente dalla scena - return pGseCtx->m_pScene->SetWinRectAttribs( bOutline, WrCol) ; + return ( ExeSetWinRectAttribs( ( bOutline != FALSE), Color( WrCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGlobFrameShow( BOOL bShow) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto stato visualizzazione griglia - return ( pGseCtx->m_pScene->SetGlobFrameShow( ( bShow != FALSE)) ? TRUE : FALSE) ; + return ( ExeSetGlobFrameShow( ( bShow != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridShow( BOOL bShowGrid, BOOL bShowFrame) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto stato visualizzazione griglia - return ( pGseCtx->m_pScene->SetGridShow( ( bShowGrid != FALSE), ( bShowFrame != FALSE)) ? TRUE : FALSE) ; + return ( ExeSetGridShow( ( bShowGrid != FALSE), ( bShowFrame != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto i parametri geometrici di griglia - return ( pGseCtx->m_pScene->SetGridGeo( dSnapStep, nMinLineSstep, nMajLineSstep, nExtSstep) ? TRUE : FALSE) ; + return ( ExeSetGridGeo( dSnapStep, nMinLineSstep, nMajLineSstep, nExtSstep) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridColor( const int nMinCol[4], const int nMajCol[4]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto i colori di griglia - Color colMin( nMinCol) ; - Color colMaj( nMajCol) ; - return ( pGseCtx->m_pScene->SetGridColor( colMin, colMaj) ? TRUE : FALSE) ; + return ( ExeSetGridColor( Color( nMinCol), Color( nMajCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResize( int nW, int nH) { - IEGrScene* pScene = GetCurrScene() ; - VERIFY_SCENE( pScene, FALSE) - // eseguo resize - pScene->Resize( nW, nH) ; - return TRUE ; + return ( ExeResize( nW, nH) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDraw( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo disegno - pGseCtx->m_pScene->Draw() ; - // valido la finestra disegnata - ValidateRgn( pGseCtx->m_hWnd, NULL) ; - - return TRUE ; + return ( ExeDraw() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelect( int nWinX, int nWinY, int nSelW, int nSelH, int* pnSel) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo la selezione - return ( pGseCtx->m_pScene->Select( Point3d( nWinX, nWinY), nSelW, nSelH, *pnSel) ? TRUE : FALSE) ; + return ( ExeSelect( nWinX, nWinY, nSelW, nSelH, pnSel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetObjFilterForSelect( BOOL bZerodim, BOOL bCurve, BOOL bSurf, BOOL bVolume, BOOL bExtra) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto il filtro - return ( pGseCtx->m_pScene->SetObjFilterForSelect( ( bZerodim != FALSE), ( bCurve != FALSE), ( bSurf != FALSE), - ( bVolume != FALSE), ( bExtra != FALSE)) ? TRUE : FALSE) ; + return ( ExeSetObjFilterForSelect( ( bZerodim != FALSE), ( bCurve != FALSE), ( bSurf != FALSE), + ( bVolume != FALSE), ( bExtra != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableRemove( int nId) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // tolgo dai non selezionabili - return pGseCtx->m_pScene->UnselectableRemove( nId) ; + return ( ExeUnselectableRemove( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableAdd( int nId) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // aggiungo ai non selezionabili - return pGseCtx->m_pScene->UnselectableAdd( nId) ; + return ( ExeUnselectableAdd( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableClearAll( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // cancello tutti i non selezionabili - return pGseCtx->m_pScene->UnselectableClearAll() ; + return ( ExeUnselectableClearAll() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetFirstObjInSelWin( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // restituisco il primo oggetto selezionato - return pGseCtx->m_pScene->GetFirstSelectedObj() ; + return ExeGetFirstObjInSelWin() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNextObjInSelWin( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // restituisco il successivo oggetto selezionato - return pGseCtx->m_pScene->GetNextSelectedObj() ; + return ExeGetNextObjInSelWin() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3], int* pnAux) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // trovo il punto usato in selezione + // verifico parametri di ritorno + if ( ptSel == nullptr || pnAux == nullptr) + return FALSE ; Point3d ptTmp ; - if ( ! pGseCtx->m_pScene->GetPointFromSelect( nSelId, Point3d( nWinX, nWinY), ptTmp, *pnAux)) + if ( ! ExeGetPointFromSelect( nSelId, nWinX, nWinY, ptTmp, pnAux)) return FALSE ; VEC_FROM_3D( ptSel, ptTmp) return TRUE ; @@ -331,14 +193,13 @@ __stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[ //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, - double ptP[3]) +__stdcall EgtGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, double ptP[3]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // trovo il punto snap da selezione + // verifico parametro di ritorno + if ( ptP == nullptr) + return FALSE ; Point3d ptSnap ; - if ( ! pGseCtx->m_pScene->GetGraphicSnapPoint( nSnap, Point3d( nWinX, nWinY), nSelW, nSelH, ptSnap)) + if ( ! ExeGetGraphicSnapPoint( nSnap, nWinX, nWinY, nSelW, nSelH, ptSnap)) return FALSE ; VEC_FROM_3D( ptP, ptSnap) return TRUE ; @@ -349,11 +210,11 @@ BOOL __stdcall EgtGetGridSnapPointZ( BOOL bSketch, int nWinX, int nWinY, const double ptGrid[3], double ptP[3]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // trovo il punto snap da selezione + // verifico parametro di ritorno + if ( ptP == nullptr) + return FALSE ; Point3d ptSnap ; - if ( ! pGseCtx->m_pScene->GetGridSnapPointZ( ( bSketch != FALSE), Point3d( nWinX, nWinY), ptGrid, ptSnap)) + if ( ! ExeGetGridSnapPointZ( ( bSketch != FALSE), nWinX, nWinY, ptGrid, ptSnap)) return FALSE ; VEC_FROM_3D( ptP, ptSnap) return TRUE ; @@ -363,343 +224,185 @@ __stdcall EgtGetGridSnapPointZ( BOOL bSketch, int nWinX, int nWinY, const double int __stdcall EgtGetLastSnapId( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // restituisco Id di ultima entità generatrice di punto snap - return pGseCtx->m_pScene->GetLastSnapId() ; + return ExeGetLastSnapId() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetLastSnapDir( double vtV[3]) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // restituisco, se definita, direzione associata ad ultimo punto di snap - Vector3d vtDir ; - if ( pGseCtx->m_pScene->GetLastSnapDir( vtDir)) { - VEC_FROM_3D( vtV, vtDir) - return TRUE ; - } - else + // verifico parametro di ritorno + if ( vtV == nullptr) return FALSE ; + Vector3d vtDir ; + if ( ! ExeGetLastSnapDir( vtDir)) + return FALSE ; + VEC_FROM_3D( vtV, vtDir) + return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowMode( int nShowMode, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto il modo di visualizzazione - if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) { - pGseCtx->m_pScene->SetShowMode( nShowMode) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; - } - else - return FALSE ; + return ( ExeSetShowMode( nShowMode, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetShowMode( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // recupero il modo di visualizzazione - return pGseCtx->m_pScene->GetShowMode() ; + return ExeGetShowMode() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowCurveDirection( BOOL bShow, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto stato - pGseCtx->m_pScene->SetShowCurveDirection( bShow != FALSE) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetShowCurveDirection( ( bShow != FALSE), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetShowCurveDirection( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // recupero lo stato - return pGseCtx->m_pScene->GetShowCurveDirection() ; + return ( ExeGetShowCurveDirection() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowTriaAdv( BOOL bAdvanced, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto stato - pGseCtx->m_pScene->SetShowTriaAdvanced( bAdvanced != FALSE) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetShowTriaAdv( ( bAdvanced != FALSE), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetShowTriaAdv( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // recupero lo stato - return pGseCtx->m_pScene->GetShowTriaAdvanced() ; + return ( ExeGetShowTriaAdv() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoom( int nZoom, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - - const double COEFF_IN = 0.9 ; - const double COEFF_OUT = 1 / COEFF_IN ; - - switch ( nZoom) { - case 1 : - pGseCtx->m_pScene->ZoomAll() ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; - break ; - case 2 : - pGseCtx->m_pScene->ZoomChange( COEFF_IN) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; - break ; - case 3 : - pGseCtx->m_pScene->ZoomChange( COEFF_OUT) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; - break ; - } - - return FALSE ; + return ( ExeZoom( nZoom, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomOnPoint( int nWinX, int nWinY, double dCoeff, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo zoom - pGseCtx->m_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeZoomOnPoint( nWinX, nWinY, dCoeff, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoLine( const double ptP1[3], const double ptP2[3], BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // disegno linea per distanza o similari - pGseCtx->m_pScene->SetGeoLine( ptP1, ptP2) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetGeoLine( ptP1, ptP2, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetGeoLine( BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // cancello linea per distanza o similari - pGseCtx->m_pScene->ResetGeoLine() ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeResetGeoLine( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoTria( const double ptP1[3], const double ptP2[3], const double ptP3[3], BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // disegno triangolo immediato - pGseCtx->m_pScene->SetGeoTria( ptP1, ptP2, ptP3) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetGeoTria( ptP1, ptP2, ptP3, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetGeoTria( BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // cancello triangolo immediato - pGseCtx->m_pScene->ResetGeoTria() ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeResetGeoTria( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // disegno finestra per zoom - pGseCtx->m_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetWinRect( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetWinRect( BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // cancello finestra per zoom - pGseCtx->m_pScene->ResetWinRect() ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeResetWinRect( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo zoom su finestra - pGseCtx->m_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeZoomWin( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetView( int nDir, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto vista - if ( nDir >= CT_TOP && nDir <= CT_CPLANE) { - pGseCtx->m_pScene->SetCamera( nDir) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; - } - else - return FALSE ; + return ( ExeSetView( nDir, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGenericView( double dAngVertDeg, double dAngHorizDeg, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto vista - pGseCtx->m_pScene->SetCamera( dAngVertDeg, dAngHorizDeg, 0) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetGenericView( dAngVertDeg, dAngHorizDeg, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetViewCenter( const double ptP[3], BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto vista - pGseCtx->m_pScene->SetCenter( ptP) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeSetViewCenter( ptP, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtPanView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo panoramica - pGseCtx->m_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExePanView( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRotateView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // eseguo rotazione camera - pGseCtx->m_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; - if ( bRedraw) - pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return ( ExeRotateView( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetView( int* pnDir) { - IEGrScene* pScene = GetCurrScene() ; - VERIFY_SCENE( pScene, FALSE) - // recupero direzione di vista - if ( pnDir == nullptr) - return FALSE ; - *pnDir = pScene->GetCameraDir() ; - return TRUE ; + return ( ExeGetView( pnDir) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetGenericView( double* pdAngVertDeg, double* pdAngHorizDeg) { - IEGrScene* pScene = GetCurrScene() ; - VERIFY_SCENE( pScene, FALSE) - // recupero direzione di vista - if ( pdAngVertDeg == nullptr || pdAngHorizDeg == nullptr) - return FALSE ; - pScene->GetCamera( pdAngVertDeg, pdAngHorizDeg) ; - return TRUE ; + return ( ExeGetGenericView( pdAngVertDeg, pdAngHorizDeg) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtProjectPoint( const double ptP[3], double ptWin[3]) { - IEGrScene* pScene = GetCurrScene() ; - VERIFY_SCENE( pScene, FALSE) - // eseguo la proiezione + if ( ptWin == nullptr) + return FALSE ; Point3d ptView ; - if ( ! pScene->Project( ptP, ptView)) + if ( ! ExeProjectPoint( ptP, ptView)) return FALSE ; VEC_FROM_3D( ptWin, ptView) return TRUE ; @@ -709,13 +412,12 @@ __stdcall EgtProjectPoint( const double ptP[3], double ptWin[3]) BOOL __stdcall EgtUnProjectPoint( int nWinX, int nWinY, double ptP[3]) { - IEGrScene* pScene = GetCurrScene() ; - VERIFY_SCENE( pScene, FALSE) - // eseguo l'inverso della proiezione (considero Z punto su centro) - Point3d ptView( nWinX, nWinY, pScene->GetProjectedCenter().z) ; + if ( ptP == nullptr) + return FALSE ; Point3d ptWorld ; - if ( ! pScene->UnProject( ptView, ptWorld)) + if ( ! ExeUnProjectPoint( nWinX, nWinY, ptWorld)) return FALSE ; VEC_FROM_3D( ptP, ptWorld) return TRUE ; } + diff --git a/API_TscExec.cpp b/API_TscExec.cpp index f5f117b..21b5cf8 100644 --- a/API_TscExec.cpp +++ b/API_TscExec.cpp @@ -14,17 +14,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" -#include "API_Macro.h" -#include "DllGraphics.h" -#include "DllExchange.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkGdbExecutor.h" -#include "/EgtDev/Include/EExExcExecutor.h" -#include "/EgtDev/Include/EGrSceExecutor.h" -#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" -#include using namespace std ; @@ -32,83 +24,19 @@ using namespace std ; BOOL __stdcall EgtInitTscExec( void) { - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, FALSE) - - // eventuale pulizia esecutore e suoi oggetti - if ( pGseCtx->m_pTscExec != nullptr) { - delete pGseCtx->m_pTscExec ; - pGseCtx->m_pTscExec = nullptr ; - } - - // creo esecutore - PtrOwner pCmdParser( CreateCmdParser()) ; - VERIFY_NULL( Get( pCmdParser), "Error in CreateCmdParser", FALSE) - - // creo oggetto per esecuzione funzioni di GeomKernel - PtrOwner pGdbExec( CreateGdbExecutor()) ; - VERIFY_NULL( Get( pGdbExec), "Error in CreateGdbExecutor", FALSE) - pGdbExec->SetGeomDB( pGseCtx->m_pGeomDB) ; - pCmdParser->SetExecutor( Release( pGdbExec)) ; - - // eventuale creazione oggetto per esecuzione funzioni di Scene - if ( pGseCtx->m_pScene != nullptr && IsLoadedGraphicsDll()) { - PtrOwner pSceExec( MyCreateSceExecutor()) ; - VERIFY_NULL( Get( pSceExec), "Error in CreateSceExecutor", FALSE) - pSceExec->SetScene( pGseCtx->m_pScene) ; - pCmdParser->AddExecutor( Release( pSceExec)) ; - } - - // eventuale creazione oggetto per esecuzione funzioni di Exchange - if ( IsLoadedExchangeDll()) { - PtrOwner pExcExec( MyCreateExcExecutor()) ; - VERIFY_NULL( Get( pExcExec), "Error in CreateExcExecutor", FALSE) - pExcExec->SetGeomDB( pGseCtx->m_pGeomDB) ; - pCmdParser->AddExecutor( Release( pExcExec)) ; - } - - // completo inizializzazioni - pCmdParser->Init() ; - pGseCtx->m_pTscExec = Release( pCmdParser) ; - - return TRUE ; + return ( ExeInitTscExec() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtTscExecFile( const wchar_t* wsFilePath) { - // converto nome file - string sFilePath = wstrztoA( wsFilePath) ; - // emetto info - string sInfo = "Exec File = " + sFilePath ; - LOG_INFO( GetLogger(), sInfo.c_str()) - // eseguo - return ( EgtTscExecFile( sFilePath) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -bool -EgtTscExecFile( const string& sFilePath) -{ - ICmdParser* pTscExec = GetCurrTscExecutor() ; - VERIFY_TSCEXEC( pTscExec, FALSE) - - // imposto il direttorio dello script - string sFileDir, sFileName ; - SplitLast( sFilePath, "\\", sFileDir, sFileName) ; - pTscExec->SetDirReplace( "", sFileDir) ; - - // esecuzione script - return pTscExec->Run( sFilePath) ; + return ( ExeTscExecFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtTscExecLine( const wchar_t* wsLine) { - ICmdParser* pTscExec = GetCurrTscExecutor() ; - VERIFY_TSCEXEC( pTscExec, FALSE) - // eseguo il comando - return ( pTscExec->ExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ; + return ( ExeTscExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ; } diff --git a/AuxTools.cpp b/AuxTools.cpp deleted file mode 100644 index ddf494a..0000000 --- a/AuxTools.cpp +++ /dev/null @@ -1,141 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2015 -//---------------------------------------------------------------------------- -// File : AuxTools.cpp Data : 07.01.15 Versione : 1.6a1 -// Contenuto : Funzioni ausiliarie. -// -// -// -// Modifiche : 07.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#include "stdafx.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EGkExtText.h" -#include "/EgtDev/Include/EMkMachMgr.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -const string -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") + "," ; - if ( ! sIds.empty()) - sIds.pop_back() ; - return sIds ; -} - -//---------------------------------------------------------------------------- -const char* -NgeTypeToString( int nNgeType) -{ - switch ( nNgeType) { - case GDB_SV_TXT : return "GDB_NT.TXT" ; - case GDB_SV_BIN : return "GDB_NT.BIN" ; - default : - case GDB_SV_CMPTXT : return "GDB_NT.CMPTXT" ; - } -} - -//---------------------------------------------------------------------------- -const char* -SepToString( int nSep) -{ - switch ( nSep) { - default : - 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" ; - } -} - -//---------------------------------------------------------------------------- -const char* -InsToString( int nIns) -{ - switch ( nIns) { - case GDB_FIRST_SON : return "GDB_IN.FIRST_SON" ; - default : - case GDB_LAST_SON : return "GDB_IN.LAST_SON" ; - case GDB_BEFORE : return "GDB_IN.BEFORE" ; - case GDB_AFTER : return "GDB_IN.AFTER" ; - } -} - -//---------------------------------------------------------------------------- -const char* -RefTypeToString( int nRefType) -{ - switch ( nRefType) { - case RTY_GLOB : return "GDB_RT.GLOB" ; - default : - case RTY_LOC : return "GDB_RT.LOC" ; - case RTY_GRID : return "GDB_RT.GRID" ; - } -} - -//---------------------------------------------------------------------------- -const char* -ETxtInsPosToString( int nETxtInsPos) -{ - switch ( nETxtInsPos) { - 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" ; - } -} - -//---------------------------------------------------------------------------- -const char* -OffsTypeToString( int nOffsType) -{ - 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" ; - } -} - -//---------------------------------------------------------------------------- -const char* -RawPartCornerPosToString( int nFlag) -{ - switch ( nFlag) { - case RPCR_TL : return "MCH_CR.TL" ; - case RPCR_TR : return "MCH_CR.TR" ; - default : - case RPCR_BL : return "MCH_CR.BL" ; - case RPCR_BR : return "MCH_CR.BR" ; - } -} - -//---------------------------------------------------------------------------- -const char* -RawPartCenterPosToString( int nFlag) -{ - switch ( nFlag) { - case RPCE_TC : return "MCH_CE.TC" ; - default : - 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" ; - } -} diff --git a/AuxTools.h b/AuxTools.h deleted file mode 100644 index 762f3d0..0000000 --- a/AuxTools.h +++ /dev/null @@ -1,37 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2015 -//---------------------------------------------------------------------------- -// File : AuxTools.h Data : 07.01.15 Versione : 1.6a1 -// Contenuto : Prototipi funzioni ausiliarie. -// -// -// -// Modifiche : 07.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#include "/EgtDev/Include/EgtNumCollection.h" -#include - -class IGeomDB ; - -//---------------------------------------------------------------------------- -// Lista di Id completa (parametro per lua) -const std::string IdListToString( const INTVECTOR& vIds) ; -// Tipo del file Nge -const char* NgeTypeToString( int nNgeType) ; -// Tipo punto per creazione rette e archi -const char* SepToString( int nSep) ; -// Flag per posizione di inserimento nel DB geometrico -const char* InsToString( int nIns) ; -// Tipo riferimento in cui sono espressi i dati geometrici -const char* RefTypeToString( int nRefType) ; -// Posizione inserimento testo -const char* ETxtInsPosToString( int nETxtInsPos) ; -// tipo di offset di curva -const char* OffsTypeToString( int nOffsType) ; -// Flag per posizione corner rispetto a grezzo -const char* RawPartCornerPosToString( int nFlag) ; -// Flag per posizione center rispetto a grezzo -const char* RawPartCenterPosToString( int nFlag) ; diff --git a/DllExchange.cpp b/DllExchange.cpp deleted file mode 100644 index f191239..0000000 --- a/DllExchange.cpp +++ /dev/null @@ -1,213 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllExchange.cpp Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Funzioni di gestione della libreria opzionale EgtExchange. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "DllExchange.h" -#define NOMINMAX -#include - -using namespace std ; - -//----------------------------------------------------------------------------- -// Nome della libreria -#if defined( _WIN64) && defined( _DEBUG) - static const wchar_t* EEX_NAME = L"EgtExchangeD64.dll" ; -#elif defined( _WIN64) - static const wchar_t* EEX_NAME = L"EgtExchangeR64.dll" ; -#elif defined( _WIN32) && defined( _DEBUG) - static const wchar_t* EEX_NAME = L"EgtExchangeD32.dll" ; -#else - static const wchar_t* EEX_NAME = L"EgtExchangeR32.dll" ; -#endif -// Nome delle funzioni caricate -static const char* EEX_SETEEXLOGGER = "SetEExLogger" ; -static const char* EEX_GETEEXVERSION = "GetEExVersion" ; -static const char* EEX_SETEEXKEY = "SetEExKey" ; -static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ; -static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; -static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; -static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; -static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; -static const char* EEX_CREATEEEXEXECUTOR = "CreateExcExecutor" ; - - -//----------------------------------------------------------------------------- -HMODULE s_hEEx = nullptr ; - -//----------------------------------------------------------------------------- -bool -LoadExchangeDll( void) -{ - // se già caricata - if ( s_hEEx != nullptr) - return true ; - // carico la libreria EgtExchange - s_hEEx = LoadLibrary( EEX_NAME) ; - return ( s_hEEx != nullptr) ; -} - -//----------------------------------------------------------------------------- -bool -FreeExchangeDll( void) -{ - // se non è già caricata - if ( s_hEEx == nullptr) - return true ; - // libero la libreria EgtExchange - FreeLibrary( s_hEEx) ; - s_hEEx = nullptr ; - return true ; -} - -//----------------------------------------------------------------------------- -bool -IsLoadedExchangeDll( void) -{ - return ( s_hEEx != nullptr) ; -} - -//----------------------------------------------------------------------------- -void -MySetEExLogger( ILogger* pLogger) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return ; - // recupero funzione che imposta il logger - typedef void (* PF_SetEExLogger) ( ILogger* pLogger) ; - PF_SetEExLogger pFun = (PF_SetEExLogger)GetProcAddress( s_hEEx, EEX_SETEEXLOGGER) ; - if ( pFun == nullptr) - return ; - pFun( pLogger) ; -} - -//----------------------------------------------------------------------------- -const char* -MyGetEExVersion( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return "" ; - // recupero funzione che restituisce la versione della libreria - typedef const char* (* PF_GetEExVersion) ( void) ; - PF_GetEExVersion pFun = (PF_GetEExVersion)GetProcAddress( s_hEEx, EEX_GETEEXVERSION) ; - if ( pFun == nullptr) - return "" ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -void -MySetEExKey( const string& sKey) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return ; - // recupero funzione che imposta i codici di protezione - typedef void (* PF_SetEExKey) ( const string& sKey) ; - PF_SetEExKey pFun = (PF_SetEExKey)GetProcAddress( s_hEEx, EEX_SETEEXKEY) ; - if ( pFun == nullptr) - return ; - pFun( sKey) ; -} - -//----------------------------------------------------------------------------- -IImportCnc* -MyCreateImportCnc( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IImportCnc* (* PF_CreateImportCnc) ( void) ; - PF_CreateImportCnc pFun = (PF_CreateImportCnc)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCNC) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -IImportDxf* -MyCreateImportDxf( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IImportDxf* (* PF_CreateImportDxf) ( void) ; - PF_CreateImportDxf pFun = (PF_CreateImportDxf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTDXF) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -IImportStl* -MyCreateImportStl( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IImportStl* (* PF_CreateImportStl) ( void) ; - PF_CreateImportStl pFun = (PF_CreateImportStl)GetProcAddress( s_hEEx, EEX_CREATEIMPORTSTL) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -IExportDxf* -MyCreateExportDxf( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IExportDxf* (* PF_CreateExportDxf) ( void) ; - PF_CreateExportDxf pFun = (PF_CreateExportDxf)GetProcAddress( s_hEEx, EEX_CREATEEXPORTDXF) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -IExportStl* -MyCreateExportStl( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IExportStl* (* PF_CreateExportStl) ( void) ; - PF_CreateExportStl pFun = (PF_CreateExportStl)GetProcAddress( s_hEEx, EEX_CREATEEXPORTSTL) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -IExcExecutor* -MyCreateExcExecutor( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IExcExecutor* (* PF_CreateExcExecutor) ( void) ; - PF_CreateExcExecutor pFun = (PF_CreateExcExecutor)GetProcAddress( s_hEEx, EEX_CREATEEEXEXECUTOR) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} diff --git a/DllExchange.h b/DllExchange.h deleted file mode 100644 index 130f20f..0000000 --- a/DllExchange.h +++ /dev/null @@ -1,38 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllGraphics.h Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtGraphics. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include - -class ILogger ; -class IImportCnc ; -class IImportDxf ; -class IImportStl ; -class IExportDxf ; -class IExportStl ; -class IExcExecutor ; - -//---------------------------------------------------------------------------- -bool LoadExchangeDll( void) ; -bool FreeExchangeDll( void) ; -bool IsLoadedExchangeDll( void) ; -void MySetEExLogger( ILogger* pLogger) ; -void MySetEExKey( const std::string& sKey) ; -const char* MyGetEExVersion( void) ; -IImportCnc* MyCreateImportCnc( void) ; -IImportDxf* MyCreateImportDxf( void) ; -IImportStl* MyCreateImportStl( void) ; -IExportDxf* MyCreateExportDxf( void) ; -IExportStl* MyCreateExportStl( void) ; -IExcExecutor* MyCreateExcExecutor(void) ; diff --git a/DllGraphics.cpp b/DllGraphics.cpp deleted file mode 100644 index 9573156..0000000 --- a/DllGraphics.cpp +++ /dev/null @@ -1,149 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllGraphics.cpp Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Funzioni di gestione della libreria opzionale EgtGraphics. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "DllGraphics.h" -#define NOMINMAX -#include - -using namespace std ; - -//----------------------------------------------------------------------------- -// Nome della libreria -#if defined( _WIN64) && defined( _DEBUG) - static const wchar_t* EGR_NAME = L"EgtGraphicsD64.dll" ; -#elif defined( _WIN64) - static const wchar_t* EGR_NAME = L"EgtGraphicsR64.dll" ; -#elif defined( _WIN32) && defined( _DEBUG) - static const wchar_t* EGR_NAME = L"EgtGraphicsD32.dll" ; -#else - static const wchar_t* EGR_NAME = L"EgtGraphicsR32.dll" ; -#endif -// Nome delle funzioni caricate -static const char* EGR_SETEGRLOGGER = "SetEGrLogger" ; -static const char* EGR_GETEGRVERSION = "GetEGrVersion" ; -static const char* EGR_SETEGRKEY = "SetEGrKey" ; -static const char* EGR_CREATEEGRSCENE = "CreateEGrScene" ; -static const char* EGR_CREATESCEEXECUTOR = "CreateSceExecutor" ; - - -//----------------------------------------------------------------------------- -HMODULE s_hEGr = nullptr ; - -//----------------------------------------------------------------------------- -bool -LoadGraphicsDll( void) -{ - // se già caricata - if ( s_hEGr != nullptr) - return true ; - // carico la libreria EgtGraphics - s_hEGr = LoadLibrary( EGR_NAME) ; - return ( s_hEGr != nullptr) ; -} - -//----------------------------------------------------------------------------- -bool -FreeGraphicsDll( void) -{ - // se non è già caricata - if ( s_hEGr == nullptr) - return true ; - // libero la libreria EgtGraphics - FreeLibrary( s_hEGr) ; - s_hEGr = nullptr ; - return true ; -} - -//----------------------------------------------------------------------------- -bool -IsLoadedGraphicsDll( void) -{ - return ( s_hEGr != nullptr) ; -} - -//----------------------------------------------------------------------------- -void -MySetEGrLogger( ILogger* pLogger) -{ - // verifico caricamento libreria MachMgr - if ( s_hEGr == nullptr) - return ; - // recupero funzione che imposta il logger - typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ; - PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEGr, EGR_SETEGRLOGGER) ; - if ( pFun == nullptr) - return ; - pFun( pLogger) ; -} - -//----------------------------------------------------------------------------- -const char* -MyGetEGrVersion( void) -{ - // verifico caricamento libreria MachMgr - if ( s_hEGr == nullptr) - return "" ; - // recupero funzione che restituisce la versione della libreria - typedef const char* (* PF_GetEGrVersion) ( void) ; - PF_GetEGrVersion pFun = (PF_GetEGrVersion)GetProcAddress( s_hEGr, EGR_GETEGRVERSION) ; - if ( pFun == nullptr) - return "" ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -void -MySetEGrKey( const string& sKey) -{ - // verifico caricamento libreria MachMgr - if ( s_hEGr == nullptr) - return ; - // recupero funzione che imposta i codici di protezione - typedef void (* PF_SetEGrKey) ( const string& sKey) ; - PF_SetEGrKey pFun = (PF_SetEGrKey)GetProcAddress( s_hEGr, EGR_SETEGRKEY) ; - if ( pFun == nullptr) - return ; - pFun( sKey) ; -} - -//----------------------------------------------------------------------------- -IEGrScene* -MyCreateEGrScene( void) -{ - // verifico caricamento libreria MachMgr - if ( s_hEGr == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IEGrScene* (* PF_CreateEGrScene) ( void) ; - PF_CreateEGrScene pFun = (PF_CreateEGrScene)GetProcAddress( s_hEGr, EGR_CREATEEGRSCENE) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -ISceExecutor* -MyCreateSceExecutor( void) -{ - // verifico caricamento libreria MachMgr - if ( s_hEGr == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef ISceExecutor* (* PF_CreateSceExecutor) ( void) ; - PF_CreateSceExecutor pFun = (PF_CreateSceExecutor)GetProcAddress( s_hEGr, EGR_CREATESCEEXECUTOR) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} diff --git a/DllGraphics.h b/DllGraphics.h deleted file mode 100644 index 237950e..0000000 --- a/DllGraphics.h +++ /dev/null @@ -1,30 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllGraphics.h Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtGraphics. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include - -class ILogger ; -class IEGrScene ; -class ISceExecutor ; - -//---------------------------------------------------------------------------- -bool LoadGraphicsDll( void) ; -bool FreeGraphicsDll( void) ; -bool IsLoadedGraphicsDll( void) ; -void MySetEGrLogger( ILogger* pLogger) ; -void MySetEGrKey( const std::string& sKey) ; -const char* MyGetEGrVersion( void) ; -IEGrScene* MyCreateEGrScene( void) ; -ISceExecutor* MyCreateSceExecutor(void) ; diff --git a/DllMachKernel.cpp b/DllMachKernel.cpp deleted file mode 100644 index fd14329..0000000 --- a/DllMachKernel.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllMachKernel.cpp Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Funzioni di gestione della libreria opzionale EgtMachKernel. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "DllMachKernel.h" -#define NOMINMAX -#include - -using namespace std ; - -//----------------------------------------------------------------------------- -// Nome della libreria -#if defined( _WIN64) && defined( _DEBUG) - static const wchar_t* EMK_NAME = L"EgtMachKernelD64.dll" ; -#elif defined( _WIN64) - static const wchar_t* EMK_NAME = L"EgtMachKernelR64.dll" ; -#elif defined( _WIN32) && defined( _DEBUG) - static const wchar_t* EMK_NAME = L"EgtMachKernelD32.dll" ; -#else - static const wchar_t* EMK_NAME = L"EgtMachKernelR32.dll" ; -#endif -// Nome delle funzioni caricate -static const char* EMK_SETEMKLOGGER = "SetEMkLogger" ; -static const char* EMK_GETEMKVERSION = "GetEMkVersion" ; -static const char* EMK_SETEMKKEY = "SetEMkKey" ; -static const char* EMK_CREATEMACHMGR = "CreateMachMgr" ; - - -//----------------------------------------------------------------------------- -HMODULE s_hEMk = nullptr ; - -//----------------------------------------------------------------------------- -bool -LoadMachKernelDll( void) -{ - // se già caricata - if ( s_hEMk != nullptr) - return true ; - // carico la libreria EgtMachKernel - s_hEMk = LoadLibrary( EMK_NAME) ; - return ( s_hEMk != nullptr) ; -} - -//----------------------------------------------------------------------------- -bool -FreeMachKernelDll( void) -{ - // se non è già caricata - if ( s_hEMk == nullptr) - return true ; - // libero la libreria EgtMachKernel - FreeLibrary( s_hEMk) ; - s_hEMk = nullptr ; - return true ; -} - -//----------------------------------------------------------------------------- -bool -IsLoadedMachKernelDll( void) -{ - return ( s_hEMk != nullptr) ; -} - -//----------------------------------------------------------------------------- -void -MySetEMkLogger( ILogger* pLogger) -{ - // verifico caricamento libreria MachMgr - if ( s_hEMk == nullptr) - return ; - // recupero funzione che imposta il logger - typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ; - PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEMk, EMK_SETEMKLOGGER) ; - if ( pFun == nullptr) - return ; - pFun( pLogger) ; -} - -//----------------------------------------------------------------------------- -const char* -MyGetEMkVersion( void) -{ - // verifico caricamento libreria MachMgr - if ( s_hEMk == nullptr) - return "" ; - // recupero funzione che restituisce la versione della libreria - typedef const char* (* PF_GetEMkVersion) ( void) ; - PF_GetEMkVersion pFun = (PF_GetEMkVersion)GetProcAddress( s_hEMk, EMK_GETEMKVERSION) ; - if ( pFun == nullptr) - return "" ; - return pFun() ; -} - -//----------------------------------------------------------------------------- -void -MySetEMkKey( const string& sKey) -{ - // verifico caricamento libreria MachMgr - if ( s_hEMk == nullptr) - return ; - // recupero funzione che imposta i codici di protezione - typedef void (* PF_SetEMkKey) ( const string& sKey) ; - PF_SetEMkKey pFun = (PF_SetEMkKey)GetProcAddress( s_hEMk, EMK_SETEMKKEY) ; - if ( pFun == nullptr) - return ; - pFun( sKey) ; -} - -//----------------------------------------------------------------------------- -IMachMgr* -MyCreateMachMgr( void) -{ - // verifico caricamento libreria MachMgr - if ( s_hEMk == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IMachMgr* (* PF_CreateMachMgr) ( void) ; - PF_CreateMachMgr pFun = (PF_CreateMachMgr)GetProcAddress( s_hEMk, EMK_CREATEMACHMGR) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} diff --git a/DllMachKernel.h b/DllMachKernel.h deleted file mode 100644 index babe4ac..0000000 --- a/DllMachKernel.h +++ /dev/null @@ -1,28 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : DllMachKernel.h Data : 27.03.15 Versione : 1.6c9 -// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtMachKernel. -// -// -// -// Modifiche : 27.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include - -class ILogger ; -class IMachMgr ; - -//---------------------------------------------------------------------------- -bool LoadMachKernelDll( void) ; -bool FreeMachKernelDll( void) ; -bool IsLoadedMachKernelDll( void) ; -void MySetEMkLogger( ILogger* pLogger) ; -void MySetEMkKey( const std::string& sKey) ; -const char* MyGetEMkVersion( void) ; -IMachMgr* MyCreateMachMgr( void) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 583cb115a8739e9609a815a603a8afdb7c174294..b23ceac04cf6585b6b49dc0e891c50b6ddf73b23 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&P_%^&$rGEF|hS;uHJ`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07g?Nt^fc4 delta 111 zcmX>WeJpyzFE&QQ%^&$rGEF|hS;uHN`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07PdfrT_o{ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index 7304b1c..90332a5 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -203,21 +203,9 @@ copy $(TargetPath) \EgtProg\Dll64 - - - - - - - - - - - - @@ -243,32 +231,7 @@ copy $(TargetPath) \EgtProg\Dll64 - - - - - - - - - - - - - - - - - - - - - - - - - Create Create diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index aafbb5d..cbfa9b6 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -16,18 +16,9 @@ {77e59e94-e3d5-4510-8bcb-d1360cf74848} - - {8d45f54c-e32b-4568-a8c6-6d9074ed565f} - {58650c7e-f303-498a-b85b-7bee0f52fa88} - - {51194dc4-ffc1-435f-aa51-523e8d34f02a} - - - {d42d96c4-e8e4-4bcf-a6de-65b5f0492a14} - {85a1c0e1-b6e3-4b5c-be4a-75dc9570c4db} @@ -39,51 +30,15 @@ File di intestazione - - File di intestazione - File di intestazione - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione\Include - - - File di intestazione\Include - File di intestazione\Include - - File di intestazione\Include - File di intestazione\Include - - File di intestazione - - - File di intestazione - - - File di intestazione - @@ -137,99 +92,24 @@ File di origine\API - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - File di origine\General File di origine\General - - File di origine\LUA - - - File di origine\LUA - - - File di origine\LUA - - - File di origine\Global - - - File di origine\Global - - - File di origine\LUA - - - File di origine\LUA - File di origine\API - - File di origine\Global - File di origine\API File di origine\API - - File di origine\LUA - - - File di origine\LUA - File di origine\API - - File di origine\LUA - - - File di origine\Optional Dll - - - File di origine\Optional Dll - - - File di origine\Optional Dll - diff --git a/GeoTools.cpp b/GeoTools.cpp deleted file mode 100644 index 225b966..0000000 --- a/GeoTools.cpp +++ /dev/null @@ -1,90 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : GeoTools.cpp Data : 01.02.15 Versione : 1.6b1 -// Contenuto : Funzioni geometriche ausiliarie. -// -// -// -// Modifiche : 01.02.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#include "stdafx.h" -#include "GeoTools.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkGeomDB.h" - -//---------------------------------------------------------------------------- -Vector3d -GetVectorLocal( IGeomDB* pGeomDB, const double vtV[3], int nRefType, const Frame3d& frLoc) -{ - Vector3d vtVL( vtV) ; - if ( nRefType == RTY_GLOB) - vtVL.ToLoc( frLoc) ; - else if ( nRefType == RTY_GRID) - vtVL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; - return vtVL ; -} - -//---------------------------------------------------------------------------- -Point3d -GetPointLocal( IGeomDB* pGeomDB, const double ptP[3], int nRefType, const Frame3d& frLoc) -{ - Point3d ptPL( ptP) ; - if ( nRefType == RTY_GLOB) - ptPL.ToLoc( frLoc) ; - else if ( nRefType == RTY_GRID) - ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; - return ptPL ; -} - -//---------------------------------------------------------------------------- -bool -VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) -{ - // verifico puntatore a GeomDB - if ( pGeomDB == nullptr) - return false ; - // ciclo sul vettore degli identificativi - bool bFirst = true ; - Frame3d frFirst ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - // se si deve agire su un singolo oggetto ( gruppo o entità) - if ( vIds[i] != GDB_ID_SEL) { - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( vIds[i], frLoc) && - ! pGeomDB->GetGlobFrame( vIds[i], frLoc)) - return false ; - if ( bFirst) { - frFirst = frLoc ; - bFirst = false ; - } - else { - if ( ! AreSameFrame( frFirst, frLoc)) - return false ; - } - } - // altrimenti si deve agire sugli oggetti selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL) { - Frame3d frLoc ; - if ( ! pGeomDB->GetGlobFrame( nI, frLoc)) - return false ; - if ( bFirst) { - frFirst = frLoc ; - bFirst = false ; - } - else { - if ( ! AreSameFrame( frFirst, frLoc)) - return false ; - } - // passo alla successiva - nI = pGeomDB->GetNextSelectedObj() ; - } - } - } - return true ; -} \ No newline at end of file diff --git a/GeoTools.h b/GeoTools.h deleted file mode 100644 index 3e1afef..0000000 --- a/GeoTools.h +++ /dev/null @@ -1,26 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : GeoTools.h Data : 01.02.15 Versione : 1.6b1 -// Contenuto : Prototipi funzioni geometriche ausiliarie. -// -// -// -// Modifiche : 01.02.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#include "/EgtDev/Include/EGkPoint3d.h" -#include "/EgtDev/Include/EgtNumCollection.h" - -class IGeomDB ; - -//---------------------------------------------------------------------------- -// Vettore espresso nel riferimento desiderato partendo da vettore nel riferimento RefType -Vector3d GetVectorLocal( IGeomDB* pGeomDB, const double vtV[3], int nRefType, const Frame3d& frLoc) ; -// Punto espresso nel riferimento desiderato partendo da punto nel riferimento RefType -Point3d GetPointLocal( IGeomDB* pGeomDB, const double ptP[3], int nRefType, const Frame3d& frLoc) ; -// Verifica che tutti gli oggetti dell'insieme abbiano lo stesso riferimento -bool VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) ; - diff --git a/GseContext.cpp b/GseContext.cpp deleted file mode 100644 index 3392f37..0000000 --- a/GseContext.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : GseContext.cpp Data : 01.09.14 Versione : 1.5i1 -// Contenuto : Gestione contesti GSE ( Geometria, Scena, Esecuzione). -// -// -// -// Modifiche : 01.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#include "stdafx.h" -#include "GseContext.h" - -//---------------------------------------------------------------------------- -static int s_nCurrGseCtx = 0 ; -static const int MAX_CTX = 10 ; -static bool s_GseOn[MAX_CTX] = { false, false, false, false, false, false, false, false, false, false} ; -static GseContext s_GseCtx[MAX_CTX] ; - -//---------------------------------------------------------------------------- -int -CreateGseContext( void) -{ - for ( int i = 0 ; i < MAX_CTX ; ++ i) { - if ( ! s_GseOn[i]) { - s_GseCtx[i].Clear() ; - s_GseOn[i] = true ; - return ( i + 1) ; - } - } - return 0 ; -} - -//---------------------------------------------------------------------------- -bool -DeleteGseContext( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX) - return false ; - s_GseOn[nInd-1] = false ; - s_GseCtx[nInd-1].Clear() ; - return true ; -} - -//---------------------------------------------------------------------------- -bool -ClearAllGseContexts( void) -{ - for ( int i = 0 ; i < MAX_CTX ; ++ i) { - s_GseOn[i] = false ; - s_GseCtx[i].Clear() ; - } - return true ; -} - -//---------------------------------------------------------------------------- -GseContext* -GetGseContext( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) - return nullptr ; - return &(s_GseCtx[nInd-1]) ; -} - -//---------------------------------------------------------------------------- -IGeomDB* -GetGeomDB( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) - return nullptr ; - return ( s_GseCtx[nInd-1].m_pGeomDB) ; -} - -//---------------------------------------------------------------------------- -IEGrScene* -GetScene( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) - return nullptr ; - return ( s_GseCtx[nInd-1].m_pScene) ; -} - -//---------------------------------------------------------------------------- -ICmdParser* -GetTscExecutor( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) - return nullptr ; - return ( s_GseCtx[nInd-1].m_pTscExec) ; -} - -//---------------------------------------------------------------------------- -bool -SetCurrGseContext( int nInd) -{ - if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) { - s_nCurrGseCtx = 0 ; - return false ; - } - s_nCurrGseCtx = nInd ; - return true ; -} - -//---------------------------------------------------------------------------- -bool -ResetCurrGseContext( void) -{ - s_nCurrGseCtx = 0 ; - return true ; -} - -//---------------------------------------------------------------------------- -int -GetIndCurrGseContext( void) -{ - return s_nCurrGseCtx ; -} - -//---------------------------------------------------------------------------- -GseContext* -GetCurrGseContext( void) -{ - if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) - return nullptr ; - return &(s_GseCtx[s_nCurrGseCtx-1]) ; -} - -//---------------------------------------------------------------------------- -IGeomDB* -GetCurrGeomDB( void) -{ - if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) - return nullptr ; - return ( s_GseCtx[s_nCurrGseCtx-1].m_pGeomDB) ; -} - -//---------------------------------------------------------------------------- -IMachMgr* -GetCurrMachMgr( void) -{ - if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) - return nullptr ; - return ( s_GseCtx[s_nCurrGseCtx-1].m_pMachMgr) ; -} - -//---------------------------------------------------------------------------- -IEGrScene* -GetCurrScene( void) -{ - if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) - return nullptr ; - return ( s_GseCtx[s_nCurrGseCtx-1].m_pScene) ; -} - -//---------------------------------------------------------------------------- -ICmdParser* -GetCurrTscExecutor( void) -{ - if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) - return nullptr ; - return ( s_GseCtx[s_nCurrGseCtx-1].m_pTscExec) ; -} - diff --git a/GseContext.h b/GseContext.h deleted file mode 100644 index 704d466..0000000 --- a/GseContext.h +++ /dev/null @@ -1,90 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : GseContext.h Data : 01.09.14 Versione : 1.5i1 -// Contenuto : Dichiarazioni per contesti GSE ( Geometria, Scena, Esecuzione). -// -// -// -// Modifiche : 01.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include "/EgtDev/Include/EGkGeomDB.h" -#include "/EgtDev/Include/EGrScene.h" -#include "/EgtDev/Include/EGnCmdParser.h" -#include "/EgtDev/Include/EMkMachMgr.h" -#define NOMINMAX -#include - -//---------------------------------------------------------------------------- -class GseContext -{ - public : - IGeomDB* m_pGeomDB ; - Color m_colDef ; - IMachMgr* m_pMachMgr ; - HWND m_hWnd ; - IEGrScene* m_pScene ; - ICmdParser* m_pTscExec ; - std::string m_sFilePath ; - bool m_bEnableModified ; - bool m_bModified ; - int m_nCurrPart ; - int m_nCurrLayer ; - - public : - GseContext( void) - : m_pGeomDB( nullptr), m_colDef( GRAY), m_pMachMgr( nullptr), m_hWnd( nullptr), m_pScene( nullptr), - m_pTscExec( nullptr), m_sFilePath(), m_bEnableModified( true), m_bModified( false), - m_nCurrPart( GDB_ID_NULL), m_nCurrLayer( GDB_ID_NULL) - {} - ~GseContext( void) - { Clear() ; } - void Clear( void) - { - if ( m_pTscExec != nullptr) { - delete m_pTscExec ; - m_pTscExec = nullptr ; - } - if ( m_pScene != nullptr) { - m_pScene->Destroy() ; - delete m_pScene ; - m_pScene = nullptr ; - } - m_hWnd = nullptr ; - if ( m_pMachMgr != nullptr) { - delete m_pMachMgr ; - m_pMachMgr = nullptr ; - } - if ( m_pGeomDB != nullptr) { - delete m_pGeomDB ; - m_pGeomDB = nullptr ; - } - m_sFilePath.clear() ; - m_bEnableModified = true ; - m_bModified = false ; - m_nCurrPart = GDB_ID_NULL ; - m_nCurrLayer = GDB_ID_NULL ; - } -} ; - -//---------------------------------------------------------------------------- -int CreateGseContext( void) ; -bool DeleteGseContext( int nInd) ; -bool ClearAllGseContexts( void) ; -GseContext* GetGseContext( int nInd) ; -IGeomDB* GetGeomDB( int nInd) ; -IEGrScene* GetScene( int nInd) ; -ICmdParser* GetTscExecutor( int nInd) ; -bool SetCurrGseContext( int nInd) ; -bool ResetCurrGseContext( void) ; -int GetIndCurrGseContext( void) ; -GseContext* GetCurrGseContext( void) ; -IGeomDB* GetCurrGeomDB( void) ; -IMachMgr* GetCurrMachMgr( void) ; -IEGrScene* GetCurrScene( void) ; -ICmdParser* GetCurrTscExecutor( void) ; diff --git a/LUA.h b/LUA.h deleted file mode 100644 index 34d7ad4..0000000 --- a/LUA.h +++ /dev/null @@ -1,68 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2015 -//---------------------------------------------------------------------------- -// File : LUA.h Data : 16.01.15 Versione : 1.6a3 -// Contenuto : Dichiarazioni locali per moduli LUA. -// -// -// -// Modifiche : 27.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -//-------------------------- General ----------------------------------------- -bool LuaInstallGeneral( void) ; - -//-------------------------- GeoBase ----------------------------------------- -bool LuaInstallGeoBase( void) ; - -//-------------------------- GeomDB ------------------------------------------ -bool LuaInstallGeomDB( void) ; - -//-------------------------- GdbCreate --------------------------------------- -bool LuaInstallGdbCreate( void) ; - -//-------------------------- GdbCreateCurve ---------------------------------- -bool LuaInstallGdbCreateCurve( void) ; - -//-------------------------- GdbCreateSurf ----------------------------------- -bool LuaInstallGdbCreateSurf( void) ; - -//-------------------------- GdbModify --------------------------------------- -bool LuaInstallGdbModify( void) ; - -//-------------------------- GdbModifyCurve ---------------------------------- -bool LuaInstallGdbModifyCurve( void) ; - -//-------------------------- GdbModifySurf ----------------------------------- -bool LuaInstallGdbModifySurf( void) ; - -//-------------------------- GdbPartLayer ------------------------------------ -bool LuaInstallGdbPartLayer( void) ; - -//-------------------------- GdbObjects -------------------------------------- -bool LuaInstallGdbObjects( void) ; - -//-------------------------- GdbObjSelection --------------------------------- -bool LuaInstallGdbObjSelection( void) ; - -//-------------------------- GdbObjAttribs ----------------------------------- -bool LuaInstallGdbObjAttribs( void) ; - -//-------------------------- GeoSnap ----------------------------------------- -bool LuaInstallGeoSnap( void) ; - -//-------------------------- GeoTransform ------------------------------------ -bool LuaInstallGeoTransform( void) ; - -//-------------------------- MachMgr ----------------------------------------- -bool LuaInstallMachMgr( void) ; - -//-------------------------- Scene ------------------------------------------- -bool LuaInstallScene( void) ; - -//-------------------------- Exchange ---------------------------------------- -bool LuaInstallExchange( void) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp deleted file mode 100644 index 434af6d..0000000 --- a/LUA_Base.cpp +++ /dev/null @@ -1,181 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5 -// Contenuto : Funzioni generali per LUA. -// -// -// -// Modifiche : 27.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EGnLuaMgr.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -static LuaMgr s_LuaMgr ; - -//---------------------------------------------------------------------------- -bool -LuaInit( void) -{ - // inizializzo l'interprete lua - if ( ! s_LuaMgr.Init()) - return false ; - - // carico le funzioni speciali - if ( ! LuaInstallGeneral()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGeneral (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGeoBase()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGeoBase (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGeomDB()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGeomDB (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbCreate()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreate (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbCreateCurve()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreateCurve (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbCreateSurf()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreateSurf (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbModify()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModify (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbModifyCurve()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyCurve (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbModifySurf()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifySurf (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbPartLayer()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbPartLayer (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbObjects()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjects (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbObjSelection()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjSelection (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGdbObjAttribs()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGdbObjAttribs (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGeoSnap()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGeoSnap (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallGeoTransform()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallGeoTransform (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallMachMgr()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallMachMgr (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallScene()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallScene (" __FUNCTION__ ")") - return false ; - } - if ( ! LuaInstallExchange()) { - LOG_ERROR( GetLogger(), "Error in LuaInstallExchange (" __FUNCTION__ ")") - return false ; - } - - // recupero la versione di Lua - string sLua ; - if ( s_LuaMgr.GetVersion( sLua)) - sLua += " interpreter started" ; - else - sLua = "Lua *.* interpreter started" ; - LOG_INFO( GetLogger(), sLua.c_str()) - return true ; -} - -//---------------------------------------------------------------------------- -bool -LuaExit( void) -{ - s_LuaMgr.Exit() ; - LOG_INFO( GetLogger(), "Lua interpreter closed") - return true ; -} - -//---------------------------------------------------------------------------- -bool -LuaSetLuaLibsDir( const string& sDir) -{ - return s_LuaMgr.SetLuaLibsDir( sDir) ; -} - -//---------------------------------------------------------------------------- -bool -LuaRequire( const string& sFile) -{ - return s_LuaMgr.Require( sFile) ; -} - -//---------------------------------------------------------------------------- -bool -LuaRegisterFunction( const std::string& sFunName, PFLUA pFun) -{ - return s_LuaMgr.RegisterFunction( sFunName, pFun) ; -} - -//---------------------------------------------------------------------------- -bool -LuaEvalNumExpr( const string& sExpr, double& dVal) -{ - return s_LuaMgr.EvalNumExpr( sExpr, dVal) ; -} - -//---------------------------------------------------------------------------- -bool -LuaEvalStringExpr( const string& sExpr, string& sVal) -{ - return s_LuaMgr.EvalStringExpr( sExpr, sVal) ; -} - -//---------------------------------------------------------------------------- -bool -LuaExecLine( const string& sLine) -{ - return s_LuaMgr.ExecLine( sLine) ; -} - -//---------------------------------------------------------------------------- -bool -LuaExecFile( const string& sFile) -{ - return s_LuaMgr.ExecFile( sFile) ; -} - -//---------------------------------------------------------------------------- -const string& -LuaGetLastError( void) -{ - return s_LuaMgr.GetLastError() ; -} diff --git a/LUA_Base.h b/LUA_Base.h deleted file mode 100644 index a097336..0000000 --- a/LUA_Base.h +++ /dev/null @@ -1,32 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_Base.h Data : 21.03.15 Versione : 1.6c6 -// Contenuto : Dichiarazioni per funzioni di base gestione LUA. -// -// -// -// Modifiche : 21.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -#pragma once - -#include - -//---------------------------------------------------------------------------- -struct lua_State ; -typedef int(*PFLUA) ( lua_State*) ; - -//---------------------------------------------------------------------------- -bool LuaInit( void) ; -bool LuaExit( void) ; -bool LuaSetLuaLibsDir( const std::string& sDir) ; -bool LuaRequire( const std::string& sFile) ; -bool LuaRegisterFunction( const std::string& sFunName, PFLUA pFun) ; -bool LuaEvalNumExpr( const std::string& sExpr, double& dVal) ; -bool LuaEvalStringExpr( const std::string& sExpr, std::string& sVal) ; -bool LuaExecLine( const std::string& sLine) ; -bool LuaExecFile( const std::string& sFile) ; -const std::string& LuaGetLastError( void) ; diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp deleted file mode 100644 index c1788ff..0000000 --- a/LUA_Exchange.cpp +++ /dev/null @@ -1,120 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_Exchange.cpp Data : 29.09.14 Versione : 1.5i5 -// Contenuto : Funzioni generali per LUA. -// -// -// -// Modifiche : 29.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EgnStringUtils.h" - -using namespace std ; - - -//------------------------------------------------------------------------------- -static int -LuaImportDxf( lua_State* L) -{ - // 1 o 2 parametri : path del file da importare [, Fattore di scala] - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - double dScaleFactor = 1.0 ; - LuaGetParam( L, 2, dScaleFactor) ; - LuaClearStack( L) ; - // apro il file - bool bOk = EgtImportDxf( sFilePath, dScaleFactor) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaImportStl( lua_State* L) -{ - // 1 o 2 parametri : path del file da importare [, Fattore di scala] - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - double dScaleFactor = 1.0 ; - LuaGetParam( L, 2, dScaleFactor) ; - LuaClearStack( L) ; - // apro il file - bool bOk = EgtImportStl( sFilePath, dScaleFactor) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaImportCnc( lua_State* L) -{ - // 1 parametro : path del file da importare - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - LuaClearStack( L) ; - // apro il file - bool bOk = EgtImportCnc( sFilePath) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExportDxf( lua_State* L) -{ - // 2 parametri, GroupId e path del file da esportare - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - string sFilePath ; - LuaCheckParam( L, 2, sFilePath) - LuaClearStack( L) ; - // apro il file - bool bOk = EgtExportDxf( nGroupId, sFilePath) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExportStl( lua_State* L) -{ - // 2 parametri, GroupId e path del file da esportare - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - string sFilePath ; - LuaCheckParam( L, 2, sFilePath) - LuaClearStack( L) ; - // apro il file - bool bOk = EgtExportStl( nGroupId, sFilePath) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallExchange( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtImportDxf", LuaImportDxf) ; - bOk = bOk && LuaRegisterFunction( "EgtImportStl", LuaImportStl) ; - bOk = bOk && LuaRegisterFunction( "EgtImportCnc", LuaImportCnc) ; - bOk = bOk && LuaRegisterFunction( "EgtExportDxf", LuaExportDxf) ; - bOk = bOk && LuaRegisterFunction( "EgtExportStl", LuaExportStl) ; - return bOk ; -} diff --git a/LUA_GdbCreate.cpp b/LUA_GdbCreate.cpp deleted file mode 100644 index f1a5ac3..0000000 --- a/LUA_GdbCreate.cpp +++ /dev/null @@ -1,247 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbCreate.cpp Data : 30.09.14 Versione : 1.5i5 -// Contenuto : Funzioni di creazione geometrica per LUA. -// -// -// -// Modifiche : 30.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkExtText.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//------------------------------------------------------------------------------- -static int -LuaCreateGroup( lua_State* L) -{ - // 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)) - LuaGetParam( L, 3, nRefType) ; - else - LuaGetParam( L, 2, nRefType) ; - LuaClearStack( L) ; - // creo il gruppo - int nId = EgtCreateGroup( nParentId, frFrame.Orig().v, - frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateGeoPoint( lua_State* L) -{ - // 2 o 3 parametri : ParentId, PtP [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptP ; - LuaCheckParam( L, 2, ptP) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // creo il punto - int nId = EgtCreateGeoPoint( nParentId, ptP.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateGeoVector( lua_State* L) -{ - // 2 o 3 o 4 parametri : ParentId, VtV [, PtB] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Vector3d vtV ; - LuaCheckParam( L, 2, vtV) - Point3d ptB ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 3, ptB)) - LuaGetParam( L, 4, nRefType) ; - else - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // creo il vettore - int nId = EgtCreateGeoVector( nParentId, vtV.v, ptB.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateGeoFrame( lua_State* L) -{ - // 2 o 3 parametri : ParentId, Frame [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Frame3d frFrame ; - LuaCheckParam( L, 2, frFrame) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // creo il gruppo - int nId = EgtCreateGeoFrame( nParentId, frFrame.Orig().v, - frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateText( lua_State* L) -{ - // 5 o 6 parametri : ParentId, ptP, AngRotDeg, Text, H [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptP ; - LuaCheckParam( L, 2, ptP) ; - double dAngRotDeg ; - LuaCheckParam( L, 3, dAngRotDeg) ; - string sText ; - LuaCheckParam( L, 4, sText) - double dH ; - LuaCheckParam( L, 5, dH) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo il testo - int nId = EgtCreateText( nParentId, ptP, dAngRotDeg, sText, dH, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateTextEx( lua_State* L) -{ - // 8 o 9 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptP ; - LuaCheckParam( L, 2, ptP) ; - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) ; - Vector3d vtD ; - LuaCheckParam( L, 4, vtD) ; - string sText ; - LuaCheckParam( L, 5, sText) - string sFont ; - LuaCheckParam( L, 6, sFont) ; - string sItalic ; - LuaCheckParam( L, 7, sItalic) - ToUpper( sItalic) ; - bool bItalic = ( sItalic == "I") ; - double dH ; - LuaCheckParam( L, 8, dH) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 9, nRefType) ; - LuaClearStack( L) ; - // creo il testo in modo esteso - int nId = EgtCreateTextEx( nParentId, ptP, vtN, vtD, sText, sFont, bItalic, dH, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateTextAdv( lua_State* L) -{ - // 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 ; - LuaCheckParam( L, 2, ptP) ; - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) ; - Vector3d vtD ; - LuaCheckParam( L, 4, vtD) ; - string sText ; - LuaCheckParam( L, 5, sText) - string sFont ; - LuaCheckParam( L, 6, sFont) - int nW ; - LuaCheckParam( L, 7, nW) - string sItalic ; - LuaCheckParam( L, 8, sItalic) - ToUpper( sItalic) ; - bool bItalic = ( sItalic == "I") ; - double dH ; - LuaCheckParam( L, 9, dH) - double dRat ; - LuaCheckParam( L, 10, dRat) - double dAddAdv ; - LuaCheckParam( L, 11, dAddAdv) - int nInsPos ; - LuaCheckParam( L, 12, nInsPos) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 13, nRefType) ; - LuaClearStack( L) ; - // creo il testo in modo avanzato - int nId = EgtCreateTextAdv( nParentId, ptP, vtN, vtD, - sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbCreate( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtGroup", LuaCreateGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtPoint", LuaCreateGeoPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtVector", LuaCreateGeoVector) ; - bOk = bOk && LuaRegisterFunction( "EgtFrame", LuaCreateGeoFrame) ; - bOk = bOk && LuaRegisterFunction( "EgtText", LuaCreateText) ; - bOk = bOk && LuaRegisterFunction( "EgtTextEx", LuaCreateTextEx) ; - bOk = bOk && LuaRegisterFunction( "EgtTextAdv", LuaCreateTextAdv) ; - return bOk ; -} diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp deleted file mode 100644 index 7cafa3d..0000000 --- a/LUA_GdbCreateCurve.cpp +++ /dev/null @@ -1,840 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbCreateCurve.cpp Data : 07.01.15 Versione : 1.6a1 -// Contenuto : Funzioni di creazione curve per LUA. -// -// -// -// Modifiche : 07.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkPolyLine.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveLine( lua_State* L) -{ - // 3 o 4 parametri : ParentId, PtIni, PtFin [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - Point3d ptFin ; - LuaCheckParam( L, 3, ptFin) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo il segmento di retta - int nId = EgtCreateCurveLine( nParentId, ptIni.v, ptFin.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveLineEx( lua_State* L) -{ - // 7 o 8 parametri : ParentId, PtIni, nSepI, nIdI, PtFin, nSepF, nIdF [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - int nSepI ; - LuaCheckParam( L, 3, nSepI) - int nIdI ; - LuaCheckParam( L, 4, nIdI) - Point3d ptFin ; - LuaCheckParam( L, 5, ptFin) - int nSepF ; - LuaCheckParam( L, 6, nSepF) - int nIdF ; - LuaCheckParam( L, 7, nIdF) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 8, nRefType) ; - LuaClearStack( L) ; - // creo il segmento di retta - int nId = EgtCreateCurveLineEx( nParentId, - ptIni.v, nSepI, nIdI, - ptFin.v, nSepF, nIdF, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveLinePVL( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtIni, VtDir, dLen [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - Vector3d vtDir ; - LuaCheckParam( L, 3, vtDir) - double dLen ; - LuaCheckParam( L, 4, dLen) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo il segmento di retta - int nId = EgtCreateCurveLinePVL( nParentId, ptIni.v, vtDir.v, dLen, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveLineMinPointCurve( lua_State* L) -{ - // 3 o 4 o 5 parametri : ParentId, PtIni, CrvId [, NearPar] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - int nCrvId ; - LuaCheckParam( L, 3, nCrvId) - double dNearPar = 0 ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, dNearPar)) - LuaGetParam( L, 5, nRefType) ; - else - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo il segmento di retta - int nId = EgtCreateCurveLineMinPointCurve( nParentId, ptIni.v, nCrvId, dNearPar, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCircle( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtCen, VtN, Rad [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - double dRad ; - LuaCheckParam( L, 4, dRad) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveCircle( nParentId, ptCen.v, vtN.v, dRad, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCircleCPN( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtCen, PtOn, VtN [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - Point3d ptOn ; - LuaCheckParam( L, 3, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 4, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveCircleCPN( nParentId, ptCen.v, ptOn.v, vtN.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCircleCPNEx( lua_State* L) -{ - // 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) - int nSepO ; - LuaCheckParam( L, 4, nSepO) - int nIdO ; - LuaCheckParam( L, 5, nIdO) - Vector3d vtN ; - LuaCheckParam( L, 6, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 7, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveCircleCPNEx( nParentId, ptCen.v, ptOn.v, nSepO, nIdO, vtN.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCircle3P( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptP1 ; - LuaCheckParam( L, 2, ptP1) - Point3d ptP2 ; - LuaCheckParam( L, 3, ptP2) - Point3d ptP3 ; - LuaCheckParam( L, 4, ptP3) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveCircle3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArc( lua_State* L) -{ - // 7 o 8 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - double dRad ; - LuaCheckParam( L, 4, dRad) - Vector3d vtS ; - LuaCheckParam( L, 5, vtS) - double dAngCenDeg ; - LuaCheckParam( L, 6, dAngCenDeg) - double dDeltaN ; - LuaCheckParam( L, 7, dDeltaN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 8, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArc( nParentId, ptCen.v, vtN.v, dRad, vtS.v, dAngCenDeg, dDeltaN, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArcC2PN( lua_State* L) -{ - // 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - Point3d ptStart ; - LuaCheckParam( L, 3, ptStart) - Point3d ptNearEnd ; - LuaCheckParam( L, 4, ptNearEnd) - Vector3d vtNorm ; - LuaCheckParam( L, 5, vtNorm) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArcC2PN( nParentId, ptCen.v, ptStart.v, ptNearEnd.v, vtNorm.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArcC2PNEx( lua_State* L) -{ - // 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) - int nSepS ; - LuaCheckParam( L, 4, nSepS) - int nIdS ; - LuaCheckParam( L, 5, nIdS) - Point3d ptNearEnd ; - LuaCheckParam( L, 6, ptNearEnd) - Vector3d vtNorm ; - LuaCheckParam( L, 7, vtNorm) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 8, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - 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) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArc3P( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptP1 ; - LuaCheckParam( L, 2, ptP1) - Point3d ptP2 ; - LuaCheckParam( L, 3, ptP2) - Point3d ptP3 ; - LuaCheckParam( L, 4, ptP3) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArc3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArc2PVN( lua_State* L) -{ - // 5 o 6 parametri : ParentId, PtStart, PtEnd, VtDirS, VtNorm [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptStart ; - LuaCheckParam( L, 2, ptStart) - Point3d ptEnd ; - LuaCheckParam( L, 3, ptEnd) - Vector3d vtDirS ; - LuaCheckParam( L, 4, vtDirS) - Vector3d vtNorm ; - LuaCheckParam( L, 5, vtNorm) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArc2PVN( nParentId, ptStart.v, ptEnd.v, vtDirS.v, vtNorm.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArc2PVNEx( lua_State* L) -{ - // 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) - int nSepE ; - LuaCheckParam( L, 4, nSepE) - int nIdE ; - LuaCheckParam( L, 5, nIdE) - Vector3d vtDirS ; - LuaCheckParam( L, 6, vtDirS) - Vector3d vtNorm ; - LuaCheckParam( L, 7, vtNorm) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 8, nRefType) ; - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArc2PVNEx( nParentId, ptStart.v, ptEnd.v, nSepE, nIdE, - vtDirS.v, vtNorm.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveFillet( lua_State* L) -{ - // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dRad, bTrim [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrv1 ; - LuaCheckParam( L, 2, nCrv1) - Point3d ptNear1 ; - LuaCheckParam( L, 3, ptNear1) - int nCrv2 ; - LuaCheckParam( L, 4, nCrv2) - Point3d ptNear2 ; - LuaCheckParam( L, 5, ptNear2) - Vector3d vtNorm ; - LuaCheckParam( L, 6, vtNorm) - double dRad ; - LuaCheckParam( L, 7, dRad) - bool bTrim ; - LuaCheckParam( L, 8, bTrim) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 9, nRefType) ; - LuaClearStack( L) ; - // creo l'arco di fillet - int nId = EgtCreateCurveFillet( nParentId, nCrv1, ptNear1.v, nCrv2, ptNear2.v, - vtNorm.v, dRad, bTrim, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveChamfer( lua_State* L) -{ - // 8 o 9 parametri : ParentId, nCrv1, PtNear1, nCrv2, PtNear2, VtNorm, dDist, bTrim [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrv1 ; - LuaCheckParam( L, 2, nCrv1) - Point3d ptNear1 ; - LuaCheckParam( L, 3, ptNear1) - int nCrv2 ; - LuaCheckParam( L, 4, nCrv2) - Point3d ptNear2 ; - LuaCheckParam( L, 5, ptNear2) - Vector3d vtNorm ; - LuaCheckParam( L, 6, vtNorm) - double dDist ; - LuaCheckParam( L, 7, dDist) - bool bTrim ; - LuaCheckParam( L, 8, bTrim) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 9, nRefType) ; - LuaClearStack( L) ; - // creo l'arco di fillet - int nId = EgtCreateCurveChamfer( nParentId, nCrv1, ptNear1.v, nCrv2, ptNear2.v, - vtNorm.v, dDist, bTrim, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveBezier( lua_State* L) -{ - // 3 o 4 parametri : ParentId, Degree, CtrlPnts [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nDegree ; - LuaCheckParam( L, 2, nDegree) - PNTVECTOR vPnt ; - LuaCheckParam( L, 3, vPnt) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo la curva - int nId = EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveBezierRational( lua_State* L) -{ - // 3 o 4 parametri : ParentId, Degree, CtrlPntWs [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nDegree ; - LuaCheckParam( L, 2, nDegree) - PNTUVECTOR vPntW ; - LuaCheckParam( L, 3, vPntW) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo la curva - int nId = EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveBezierFromArc( lua_State* L) -{ - // 2 o 3 parametri : ParentId, ArcId[ , Erase] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nArcId ; - LuaCheckParam( L, 2, nArcId) - bool bErase = true ; - LuaGetParam( L, 3, bErase) ; - LuaClearStack( L) ; - // creo la curva - int nId = EgtCreateCurveBezierFromArc( nParentId, nArcId, bErase) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCompo( lua_State* L) -{ - // 2 o 3 parametri : ParentId, nIds [, Erase] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vIds ; - LuaCheckParam( L, 2, vIds) - bool bErase = true ; - LuaGetParam( L, 3, bErase) ; - LuaClearStack( L) ; - // creo la curva composita - int nId = EgtCreateCurveCompo( nParentId, vIds, bErase) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCompoByChain( lua_State* L) -{ - // 3 o 4 o 5 parametri : ParentId, nIds, PtNear [, Erase] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vIds ; - LuaCheckParam( L, 2, vIds) - Point3d ptNear ; - LuaCheckParam( L, 3, ptNear) - bool bErase = true ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, bErase)) - LuaGetParam( L, 5, nRefType) ; - else - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo la curva composita - int nCount = 0 ; - int nId = EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType, &nCount) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCompoFromPoints( lua_State* L) -{ - // 2 o 3 parametri : ParentId, ptPs [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - PNTVECTOR vPnt ; - LuaCheckParam( L, 2, vPnt) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - PolyLine PL ; - // creo una polilinea a partire dai punti - for ( size_t i = 0 ; i < vPnt.size() ; ++ i) - PL.AddUPoint( 0, vPnt[i]) ; - // creo la curva composita - int nId = EgtCreateCurveCompoFromPoints( nParentId, PL, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCompoFromPointBulges( lua_State* L) -{ - // 2 o 3 parametri : ParentId, ptPBs [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - PNTUVECTOR vPntB ; - LuaCheckParam( L, 2, vPntB) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // creo un poliarco a partire dai punti con bulge - PolyArc PA ; - for ( size_t i = 0 ; i < vPntB.size() ; ++ i) - PA.AddUPoint( 0, vPntB[i].first, vPntB[i].second) ; - // creo la curva composita - int nId = EgtCreateCurveCompoFromPointBulges( nParentId, PA, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCompoByApprox( lua_State* L) -{ - // 3 o 4 parametri : ParentId, nSouId, nArcsVsLines [, dLinTol] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nSouId ; - LuaCheckParam( L, 2, nSouId) - int nTemp ; - LuaCheckParam( L, 3, nTemp) - bool bArcsVsLines = ( nTemp != 0) ; - double dLinTol = 0.01 ; - LuaGetParam( L, 4, dLinTol) ; - LuaClearStack( L) ; - // creo la curva composita - int nId = EgtCreateCurveCompoByApprox( nParentId, nSouId, bArcsVsLines, dLinTol) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateRectangle3P( lua_State* L) -{ - // 4 o 5 parametri : ParentId, PtIni, PtCross, PtDir [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - Point3d ptCross ; - LuaCheckParam( L, 3, ptCross) - Point3d ptDir ; - LuaCheckParam( L, 4, ptDir) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // creo il poligono - int nId = EgtCreateRectangle3P( nParentId, ptIni.v, ptCross.v, ptDir.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreatePolygonFromRadius( lua_State* L) -{ - // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtCorn, VtN [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nNumSides ; - LuaCheckParam( L, 2, nNumSides) - Point3d PtCen ; - LuaCheckParam( L, 3, PtCen) - Point3d PtCorn ; - LuaCheckParam( L, 4, PtCorn) - Vector3d vtN ; - LuaCheckParam( L, 5, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo il poligono - int nId = EgtCreatePolygonFromRadius( nParentId, nNumSides, PtCen.v, PtCorn.v, vtN.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreatePolygonFromApothem( lua_State* L) -{ - // 5 o 6 parametri : ParentId, nNumSides, PtCen, PtMid, VtN [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nNumSides ; - LuaCheckParam( L, 2, nNumSides) - Point3d PtCen ; - LuaCheckParam( L, 3, PtCen) - Point3d PtMid ; - LuaCheckParam( L, 4, PtMid) - Vector3d vtN ; - LuaCheckParam( L, 5, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo il poligono - int nId = EgtCreatePolygonFromApothem( nParentId, nNumSides, PtCen.v, PtMid.v, vtN.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreatePolygonFromSide( lua_State* L) -{ - // 5 o 6 parametri : ParentId, nNumSides, PtIni, PtFin, VtN [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nNumSides ; - LuaCheckParam( L, 2, nNumSides) - Point3d ptIni ; - LuaCheckParam( L, 3, ptIni) - Point3d ptFin ; - LuaCheckParam( L, 4, ptFin) - Vector3d vtN ; - LuaCheckParam( L, 5, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo il poligono - int nId = EgtCreatePolygonFromSide( nParentId, nNumSides, ptIni.v, ptFin.v, vtN.v, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbCreateCurve( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtLine", LuaCreateCurveLine) ; - bOk = bOk && LuaRegisterFunction( "EgtLineEx", LuaCreateCurveLineEx) ; - bOk = bOk && LuaRegisterFunction( "EgtLinePVL", LuaCreateCurveLinePVL) ; - bOk = bOk && LuaRegisterFunction( "EgtLineMinPointCurve", LuaCreateCurveLineMinPointCurve) ; - bOk = bOk && LuaRegisterFunction( "EgtCircle", LuaCreateCurveCircle) ; - bOk = bOk && LuaRegisterFunction( "EgtCircleCPN", LuaCreateCurveCircleCPN) ; - bOk = bOk && LuaRegisterFunction( "EgtCircleCPNEx", LuaCreateCurveCircleCPNEx) ; - bOk = bOk && LuaRegisterFunction( "EgtCircle3P", LuaCreateCurveCircle3P) ; - bOk = bOk && LuaRegisterFunction( "EgtArc", LuaCreateCurveArc) ; - bOk = bOk && LuaRegisterFunction( "EgtArcC2PN", LuaCreateCurveArcC2PN) ; - bOk = bOk && LuaRegisterFunction( "EgtArcC2PNEx", LuaCreateCurveArcC2PNEx) ; - bOk = bOk && LuaRegisterFunction( "EgtArc3P", LuaCreateCurveArc3P) ; - bOk = bOk && LuaRegisterFunction( "EgtArc2PVN", LuaCreateCurveArc2PVN) ; - bOk = bOk && LuaRegisterFunction( "EgtArc2PVNEx", LuaCreateCurveArc2PVNEx) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveFillet", LuaCreateCurveFillet) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveChamfer", LuaCreateCurveChamfer) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveBezier", LuaCreateCurveBezier) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveBezierRat", LuaCreateCurveBezierRational) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveBezierFromArc", LuaCreateCurveBezierFromArc) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompo", LuaCreateCurveCompo) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompoByChain", LuaCreateCurveCompoByChain) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompoByApprox", LuaCreateCurveCompoByApprox) ; - bOk = bOk && LuaRegisterFunction( "EgtRectangle3P", LuaCreateRectangle3P) ; - bOk = bOk && LuaRegisterFunction( "EgtPolygonFromRadius", LuaCreatePolygonFromRadius) ; - bOk = bOk && LuaRegisterFunction( "EgtPolygonFromApothem", LuaCreatePolygonFromApothem) ; - bOk = bOk && LuaRegisterFunction( "EgtPolygonFromSide", LuaCreatePolygonFromSide) ; - return bOk ; -} diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp deleted file mode 100644 index da299be..0000000 --- a/LUA_GdbCreateSurf.cpp +++ /dev/null @@ -1,461 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2015 -//---------------------------------------------------------------------------- -// File : LUA_GdbCreateSurf.cpp Data : 07.01.15 Versione : 1.6a1 -// Contenuto : Funzioni di creazione superfici per LUA. -// -// -// -// Modifiche : 07.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGkPolyLine.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static const double LIN_TOL_DEF = 0.05 ; - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmBBox( lua_State* L) -{ - // 2 o 3 parametri : ParentId, BBox3d [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - BBox3d b3Box ; - LuaCheckParam( L, 2, b3Box) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // creo STM bounding box - int nId = EgtCreateSurfTmBBox( nParentId, b3Box, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmBox( lua_State* L) -{ - // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - Point3d ptCross ; - LuaCheckParam( L, 3, ptCross) - Point3d ptDir ; - LuaCheckParam( L, 4, ptDir) - double dHeight ; - LuaCheckParam( L, 5, dHeight) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo STM parallelepipedo - int nId = EgtCreateSurfTmBox( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmPyramid( lua_State* L) -{ - // 5 o 6 parametri : ParentId, PtIni, PtCross, PtDir, dHeight [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptIni ; - LuaCheckParam( L, 2, ptIni) - Point3d ptCross ; - LuaCheckParam( L, 3, ptCross) - Point3d ptDir ; - LuaCheckParam( L, 4, ptDir) - double dHeight ; - LuaCheckParam( L, 5, dHeight) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo STM cilindro - int nId = EgtCreateSurfTmPyramid( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmCylinder( lua_State* L) -{ - // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptOrig ; - LuaCheckParam( L, 2, ptOrig) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - double dRad ; - LuaCheckParam( L, 4, dRad) - double dHeight ; - LuaCheckParam( L, 5, dHeight) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 6, dLinTol)) - LuaGetParam( L, 7, nRefType) ; - else - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo STM cilindro - int nId = EgtCreateSurfTmCylinder( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmCone( lua_State* L) -{ - // 5 o 6 o 7 parametri : ParentId, PtOrig, vtN, dRad, dHeight [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptOrig ; - LuaCheckParam( L, 2, ptOrig) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - double dRad ; - LuaCheckParam( L, 4, dRad) - double dHeight ; - LuaCheckParam( L, 5, dHeight) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 6, dLinTol)) - LuaGetParam( L, 7, nRefType) ; - else - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo STM cilindro - int nId = EgtCreateSurfTmCone( nParentId, ptOrig.v, vtN.v, dRad, dHeight, dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmSphere( lua_State* L) -{ - // 3 o 4 o 5 parametri : ParentId, PtOrig, dRad [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptOrig ; - LuaCheckParam( L, 2, ptOrig) - double dRad ; - LuaCheckParam( L, 3, dRad) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, dLinTol)) - LuaGetParam( L, 5, nRefType) ; - else - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo STM cilindro - int nId = EgtCreateSurfTmSphere( nParentId, ptOrig.v, dRad, dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByFlatContour( lua_State* L) -{ - // 2 o 3 parametri : ParentId, CrvId [, dTol] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) - double dLinTol = LIN_TOL_DEF ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, dLinTol) ; - LuaClearStack( L) ; - // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTmByFlatContour( nParentId, nCrvId, dLinTol) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByRegion( lua_State* L) -{ - // 2 o 3 parametri : ParentId, CrvIds [, dTol] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vCrvIds ; - LuaCheckParam( L, 2, vCrvIds) - double dLinTol = LIN_TOL_DEF ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, dLinTol) ; - LuaClearStack( L) ; - // creo STM riempiendo una regione (piana) - int nId = EgtCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByExtrusion( lua_State* L) -{ - // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vCrvIds ; - LuaCheckParam( L, 2, vCrvIds) - Vector3d vtExtr ; - LuaCheckParam( L, 3, vtExtr) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, dLinTol)) - LuaGetParam( L, 5, nRefType) ; - else - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi - int nId = EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, - dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByRegionExtrusion( lua_State* L) -{ - // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vCrvIds ; - LuaCheckParam( L, 2, vCrvIds) - Vector3d vtExtr ; - LuaCheckParam( L, 3, vtExtr) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, dLinTol)) - LuaGetParam( L, 5, nRefType) ; - else - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // creo STM estrudendo uno o più percorsi, con aggiunta dei tappi - int nId = EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByRevolve( lua_State* L) -{ - // 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, bCapEnds [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) - Point3d ptAx ; - LuaCheckParam( L, 3, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 4, vtAx) - bool bCapEnds ; - LuaCheckParam( L, 5, bCapEnds) - double dLinTol = 0.1 ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 6, dLinTol)) - LuaGetParam( L, 7, nRefType) ; - else - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTmByRevolve( nParentId, nCrvId, ptAx.v, vtAx.v, bCapEnds, dLinTol, nRefType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmByScrewing( lua_State* L) -{ - // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, nRefType] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) - Point3d ptAx ; - LuaCheckParam( L, 3, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 4, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 5, dAngRotDeg) - double dMove ; - LuaCheckParam( L, 6, dMove) - double dLinTol = LIN_TOL_DEF ; - int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 7, dLinTol)) - LuaGetParam( L, 8, nRefType) ; - else - 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) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateSurfTmRuled( lua_State* L) -{ - // 3 o 4 parametri : ParentId, PtOrCrvId1, PtOrCrvId2, [, dTol] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - int nPtOrCrvId1 ; - LuaCheckParam( L, 2, nPtOrCrvId1) - int nPtOrCrvId2 ; - LuaCheckParam( L, 3, nPtOrCrvId2) - double dLinTol = LIN_TOL_DEF ; - if ( lua_gettop( L) >= 4) - LuaCheckParam( L, 4, dLinTol) ; - LuaClearStack( L) ; - // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTmRuled( nParentId, nPtOrCrvId1, nPtOrCrvId2, dLinTol) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCreateSurfTmByTriangles( lua_State* L) -{ - // 2 o 3 parametri : ParentId, Id/s [, bErase] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vId ; - LuaCheckParam( L, 2, vId) - bool bErase = true ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bErase) ; - LuaClearStack( L) ; - // creo STM mediante cucitura di superfici - int nId = EgtCreateSurfTmByTriangles( nParentId, vId, bErase) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCreateSurfTmBySewing( lua_State* L) -{ - // 2 o 3 parametri : ParentId, Id/s [, bErase] - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vId ; - LuaCheckParam( L, 2, vId) - bool bErase = true ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, bErase) ; - LuaClearStack( L) ; - // creo STM mediante cucitura di superfici - int nId = EgtCreateSurfTmBySewing( nParentId, vId, bErase) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbCreateSurf( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmBBox", LuaCreateSurfTmBBox) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmBox", LuaCreateSurfTmBox) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmPyramid", LuaCreateSurfTmPyramid) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmCone", LuaCreateSurfTmCone) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmSphere", LuaCreateSurfTmSphere) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRegionExtrusion", LuaCreateSurfTmByRegionExtrusion) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByRevolve", LuaCreateSurfTmByRevolve) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByScrewing", LuaCreateSurfTmByScrewing) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ; - return bOk ; -} diff --git a/LUA_GdbModify.cpp b/LUA_GdbModify.cpp deleted file mode 100644 index 4db3c55..0000000 --- a/LUA_GdbModify.cpp +++ /dev/null @@ -1,176 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbModify.cpp Data : 06.10.14 Versione : 1.5i5 -// Contenuto : Funzioni di modifica geometrica per LUA. -// -// -// -// Modifiche : 06.10.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaChangeGroupFrame( lua_State* L) -{ - // 2 o 3 parametri : Id, frNewRef [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Frame3d frNewRef ; - LuaCheckParam( L, 2, frNewRef) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifica del riferimento - bool bOk = ( EgtChangeGroupFrame( nId, frNewRef, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaChangeVectorBase( lua_State* L) -{ - // 2 o 3 parametri : Id, ptBase [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptBase ; - LuaCheckParam( L, 2, ptBase) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifica del punto base - bool bOk = ( EgtChangeVectorBase( nId, ptBase.v, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaModifyText( lua_State* L) -{ - // 2 parametri : Id, sNewText - int nId ; - LuaCheckParam( L, 1, nId) - string sNewText ; - LuaCheckParam( L, 2, sNewText) - LuaClearStack( L) ; - // modifica del testo - bool bOk = EgtModifyText( nId, sNewText) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaChangeTextFont( lua_State* L) -{ - // 2 parametri : Id, sNewFont - int nId ; - LuaCheckParam( L, 1, nId) - string sNewFont ; - LuaCheckParam( L, 2, sNewFont) - LuaClearStack( L) ; - // modifica del testo - bool bOk = EgtChangeTextFont( nId, sNewFont) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaFlipText( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // flip del testo - bool bOk = ( EgtFlipText( nId) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMirrorText( lua_State* L) -{ - // 1 o 2 parametri : Id [, bOnL] - int nId ; - LuaCheckParam( L, 1, nId) - bool bOnL = true ; - LuaGetParam( L, 2, bOnL) ; - LuaClearStack( L) ; - // flip del testo - bool bOk = ( EgtMirrorText( nId, bOnL) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExplodeText( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // esplosione del testo in contorni - int nCount ; - int nFirstId = EgtExplodeText( nId, &nCount) ; - if ( nFirstId != GDB_ID_NULL) - LuaSetReturn( L, nFirstId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSplitText( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // esplosione del testo in più testi, uno per riga - int nCount ; - int nFirstId = EgtSplitText( nId, &nCount) ; - if ( nFirstId != GDB_ID_NULL) - LuaSetReturn( L, nFirstId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbModify( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtChangeGroupFrame", LuaChangeGroupFrame) ; - bOk = bOk && LuaRegisterFunction( "EgtChangeVectorBase", LuaChangeVectorBase) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyText", LuaModifyText) ; - bOk = bOk && LuaRegisterFunction( "EgtChangeTextFont", LuaChangeTextFont) ; - bOk = bOk && LuaRegisterFunction( "EgtFlipText", LuaFlipText) ; - bOk = bOk && LuaRegisterFunction( "EgtMirrorText", LuaMirrorText) ; - bOk = bOk && LuaRegisterFunction( "EgtExplodeText", LuaExplodeText) ; - bOk = bOk && LuaRegisterFunction( "EgtSplitText", LuaSplitText) ; - return bOk ; -} diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp deleted file mode 100644 index 3f2becf..0000000 --- a/LUA_GdbModifyCurve.cpp +++ /dev/null @@ -1,393 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbModifyCurve.cpp Data : 28.12.14 Versione : 1.5l2 -// Contenuto : Funzioni di modifica delle curve per LUA. -// -// -// -// Modifiche : 03.10.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkCurve.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -static int -LuaInvertCurve( lua_State* L) -{ - // 1 parametro : Id/s - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - LuaClearStack( L) ; - // eseguo inversione curve - bool bOk = EgtInvertCurve( vId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaOffsetCurve( lua_State* L) -{ - // 2 o 3 parametri : Id, dDist [, nType] - int nId ; - LuaCheckParam( L, 1, nId) - double dDist ; - LuaCheckParam( L, 2, dDist) - int nType = ICurve::OFF_FILLET ; - LuaGetParam( L, 3, nType) ; - LuaClearStack( L) ; - // offset della curva - bool bOk = ( EgtOffsetCurve( nId, dDist, nType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaChangeClosedCurveStartPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, NewStart [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptStart ; - LuaCheckParam( L, 2, ptStart) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifico il punto iniziale - bool bOk = ( EgtChangeClosedCurveStartPoint( nId, ptStart.v, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaModifyCurveStartPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, NewStart [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptStart ; - LuaCheckParam( L, 2, ptStart) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifico il punto iniziale - bool bOk = ( EgtModifyCurveStartPoint( nId, ptStart.v, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaModifyCurveEndPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, NewEnd [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptEnd ; - LuaCheckParam( L, 2, ptEnd) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifico il punto finale - bool bOk = ( EgtModifyCurveEndPoint( nId, ptEnd.v, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaModifyCurveExtrusion( lua_State* L) -{ - // 2 o 3 parametri : Id/s, vtExtr [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Vector3d vtExtr ; - LuaCheckParam( L, 2, vtExtr) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // modifico il vettore estrusione - bool bOk = EgtModifyCurveExtrusion( vId, vtExtr, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaModifyCurveThickness( lua_State* L) -{ - // 2 parametri : Id/s, Thick - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - double dThick ; - LuaCheckParam( L, 2, dThick) - LuaClearStack( L) ; - // modifico lo spessore di estrusione - bool bOk = EgtModifyCurveThickness( vId, dThick) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimCurveStartAtLen( lua_State* L) -{ - // 2 parametri : Id, dLen - int nId ; - LuaCheckParam( L, 1, nId) - double dLen ; - LuaCheckParam( L, 2, dLen) - LuaClearStack( L) ; - // taglio la curva all'inizio - bool bOk = ( EgtTrimCurveStartAtLen( nId, dLen) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimCurveEndAtLen( lua_State* L) -{ - // 2 parametri : Id, dLen - int nId ; - LuaCheckParam( L, 1, nId) - double dLen ; - LuaCheckParam( L, 2, dLen) - LuaClearStack( L) ; - // taglio la curva alla fine - bool bOk = ( EgtTrimCurveEndAtLen( nId, dLen) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimCurveStartAtParam( lua_State* L) -{ - // 2 parametri : Id, dPar - int nId ; - LuaCheckParam( L, 1, nId) - double dPar ; - LuaCheckParam( L, 2, dPar) - LuaClearStack( L) ; - // taglio la curva all' inizio - bool bOk = ( EgtTrimCurveStartAtParam( nId, dPar) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimCurveEndAtParam( lua_State* L) -{ - // 2 parametri : Id, dPar - int nId ; - LuaCheckParam( L, 1, nId) - double dPar ; - LuaCheckParam( L, 2, dPar) - LuaClearStack( L) ; - // taglio la curva alla fine - bool bOk = ( EgtTrimCurveEndAtParam( nId, dPar) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimCurveStartEndAtParam( lua_State* L) -{ - // 3 parametri : Id, dParS, dParE - int nId ; - LuaCheckParam( L, 1, nId) - double dParS ; - LuaCheckParam( L, 2, dParS) - double dParE ; - LuaCheckParam( L, 3, dParE) - LuaClearStack( L) ; - // taglio la curva alla fine - bool bOk = ( EgtTrimCurveStartEndAtParam( nId, dParS, dParE) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaTrimExtendCurveByLen( lua_State* L) -{ - // 3 o 4 parametri : Id, dLen, ptNear [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - double dLen ; - LuaCheckParam( L, 2, dLen) - Point3d ptNear ; - LuaCheckParam( L, 3, ptNear) - int nRefType = RTY_DEFAULT ; - 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) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSplitCurve( lua_State* L) -{ - // 2 parametri : Id, nParts - int nId ; - LuaCheckParam( L, 1, nId) - int nParts ; - LuaCheckParam( L, 2, nParts) - LuaClearStack( L) ; - // divido la curva nel punto - int nFirstId = EgtSplitCurve( nId, nParts) ; - if ( nFirstId != GDB_ID_NULL) - LuaSetReturn( L, nFirstId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSplitCurveAtPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, ptOn [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // divido la curva nel punto - int nNewId = EgtSplitCurveAtPoint( nId, ptOn.v, nRefType) ; - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaModifyCurveArcRadius( lua_State* L) -{ - // 2 parametri : Id, dNewRad - int nId ; - LuaCheckParam( L, 1, nId) - double dNewRad ; - LuaCheckParam( L, 2, dNewRad) - LuaClearStack( L) ; - // modifica del raggio - bool bOk = ( EgtModifyCurveArcRadius( nId, dNewRad) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExplodeCurveCompo( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // esplosione della curva composita - int nCount ; - int nFirstId = EgtExplodeCurveCompo( nId, &nCount) ; - if ( nFirstId != GDB_ID_NULL) - LuaSetReturn( L, nFirstId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -static int -LuaApproxCurveArc( lua_State* L) -{ - // 1 o 2 parametri : Id [, dLinTol] - int nId ; - LuaCheckParam( L, 1, nId) - double dLinTol = 0.01 ; - LuaGetParam( L, 2, dLinTol) ; - LuaClearStack( L) ; - // approssimazione dell'arco con rette - int nNewId = EgtApproxCurveArc( nId, dLinTol) ; - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaApproxCurveBezier( lua_State* L) -{ - // 2 o 3 parametri : Id, nArcsVsLines [, dLinTol] - int nId ; - LuaCheckParam( L, 1, nId) - int nTemp ; - LuaCheckParam( L, 2, nTemp) - bool bArcsVsLines = ( nTemp != 0) ; - double dLinTol = 0.01 ; - LuaGetParam( L, 3, dLinTol) ; - LuaClearStack( L) ; - // approssimazione della curva di Bezier con archi o rette - int nNewId = EgtApproxCurveBezier( nId, bArcsVsLines, dLinTol) ; - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbModifyCurve( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtInvertCurve", LuaInvertCurve) ; - bOk = bOk && LuaRegisterFunction( "EgtOffsetCurve", LuaOffsetCurve) ; - bOk = bOk && LuaRegisterFunction( "EgtChangeClosedCurveStartPoint", LuaChangeClosedCurveStartPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyCurveStartPoint", LuaModifyCurveStartPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyCurveEndPoint", LuaModifyCurveEndPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyCurveExtrusion", LuaModifyCurveExtrusion) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyCurveThickness", LuaModifyCurveThickness) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimCurveStartAtLen", LuaTrimCurveStartAtLen) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimCurveEndAtLen", LuaTrimCurveEndAtLen) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimCurveStartAtParam", LuaTrimCurveStartAtParam) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimCurveEndAtParam", LuaTrimCurveEndAtParam) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimCurveStartEndAtParam", LuaTrimCurveStartEndAtParam) ; - bOk = bOk && LuaRegisterFunction( "EgtTrimExtendCurveByLen", LuaTrimExtendCurveByLen) ; - bOk = bOk && LuaRegisterFunction( "EgtSplitCurve", LuaSplitCurve) ; - bOk = bOk && LuaRegisterFunction( "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtModifyCurveArcRadius", LuaModifyCurveArcRadius) ; - bOk = bOk && LuaRegisterFunction( "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ; - bOk = bOk && LuaRegisterFunction( "EgtApproxCurveArc", LuaApproxCurveArc) ; - bOk = bOk && LuaRegisterFunction( "EgtApproxCurveBezier", LuaApproxCurveBezier) ; - return bOk ; -} diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp deleted file mode 100644 index 391ccd0..0000000 --- a/LUA_GdbModifySurf.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_GdbModifySurf.cpp Data : 09.03.15 Versione : 1.6b6 -// Contenuto : Funzioni di modifica delle superfici per LUA. -// -// -// -// Modifiche : 09.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//---------------------------------------------------------------------------- -static int -LuaInvertSurf( lua_State* L) -{ - // 1 parametro : Id/s - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - LuaClearStack( L) ; - // eseguo inversione superfici - bool bOk = EgtInvertSurface( vId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaExtractSurfTmFacetLoops( lua_State* L) -{ - // 3 parametri : nId, nFacet, nDestGrpId - int nId ; - LuaCheckParam( L, 1, nId) - int nFacet ; - LuaCheckParam( L, 2, nFacet) - int nDestGrpId ; - LuaCheckParam( L, 3, nDestGrpId) - LuaClearStack( L) ; - // eseguo inversione superfici - int nCount ; - int nNewId = EgtExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, &nCount) ; - // restituisco il risultato - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExplodeSurfTm( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // esplosione della superficie trimesh - int nCount ; - int nFirstId = EgtExplodeSurfTm( nId, &nCount) ; - if ( nFirstId != GDB_ID_NULL) - LuaSetReturn( L, nFirstId) ; - else - LuaSetReturn( L) ; - LuaSetReturn( L, nCount) ; - return 2 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbModifySurf( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtInvertSurf", LuaInvertSurf) ; - bOk = bOk && LuaRegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ; - bOk = bOk && LuaRegisterFunction( "EgtExplodeSurfTm", LuaExplodeSurfTm) ; - return bOk ; -} diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp deleted file mode 100644 index 4a33b81..0000000 --- a/LUA_GdbObjAttribs.cpp +++ /dev/null @@ -1,582 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbObjAttribs.cpp Data : 30.09.14 Versione : 1.5i5 -// Contenuto : Funzioni di trasformazione geometrica per LUA. -// -// -// -// Modifiche : 30.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaSetLevel( lua_State* L) -{ - // 2 parametri : nId, nLevel - int nId ; - LuaCheckParam( L, 1, nId) - int nLevel ; - LuaCheckParam( L, 2, nLevel) - // imposto lo stato - bool bOk = ( EgtSetLevel( nId, nLevel) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRevertLevel( lua_State* L) -{ - // 1 parametro : nId - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // porto il livello al valore precedente - bool bOk = ( EgtRevertLevel( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetLevel( lua_State* L) -{ - // 1 parametro : nId - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il livello - int nLevel ; - bool bOk = ( EgtGetLevel( nId, &nLevel) != FALSE) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, nLevel) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCalcLevel( lua_State* L) -{ - // 1 parametro : nId - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il livello - int nLevel ; - bool bOk = ( EgtGetCalcLevel( nId, &nLevel) != FALSE) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, nLevel) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetMode( lua_State* L) -{ - // 2 parametri : nId, nMode - int nId ; - LuaCheckParam( L, 1, nId) - int nMode ; - LuaCheckParam( L, 2, nMode) - LuaClearStack( L) ; - // imposto il modo - bool bOk = ( EgtSetMode( nId, nMode) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRevertMode( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // porto il modo al valore precedente - bool bOk = ( EgtRevertMode( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetMode( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il modo - int nMode ; - if ( EgtGetMode( nId, &nMode) != FALSE) - // restituisco il risultato - LuaSetReturn( L, nMode) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCalcMode( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il modo calcolato (ovvero proprio ed ereditato) - int nMode ; - if ( EgtGetCalcMode( nId, &nMode) != FALSE) - // restituisco il risultato - LuaSetReturn( L, nMode) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetStatus( lua_State* L) -{ - // 2 parametri : Id, nStatus - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - int nStatus ; - LuaCheckParam( L, 2, nStatus) - LuaClearStack( L) ; - // imposto lo stato - bool bOk = EgtSetStatus( vId, nStatus) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRevertStatus( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // porto lo stato al valore precedente - bool bOk = ( EgtRevertStatus( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetStatus( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero lo stato - int nStatus ; - if ( EgtGetStatus( nId, &nStatus) != FALSE) - // restituisco il risultato - LuaSetReturn( L, nStatus) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCalcStatus( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero lo stato - int nStatus ; - if ( EgtGetCalcStatus( nId, &nStatus) != FALSE) - // restituisco il risultato - LuaSetReturn( L, nStatus) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetMark( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // imposto l'evidenziazione - bool bOk = ( EgtSetMark( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaResetMark( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // cancello l'evidenziazione - bool bOk = ( EgtResetMark( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetMark( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero lo stato di evidenziazione - BOOL nMark ; - if ( EgtGetMark( nId, &nMark) != FALSE) - // restituisco il risultato - LuaSetReturn( L, ( nMark != FALSE)) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCalcMark( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero lo stato calcolato di evidenziazione - BOOL nMark ; - if ( EgtGetCalcMark( nId, &nMark) != FALSE) - // restituisco il risultato - LuaSetReturn( L, ( nMark != FALSE)) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaStdColor( lua_State* L) -{ - // 1 parametro : Nome - string sName ; - LuaCheckParam( L, 1, sName) - LuaClearStack( L) ; - // recupero il colore con il nome indicato - Color cCol ; - if ( GetStdColor( sName, cCol)) { - // restituisco il risultato - LuaSetReturn( L, cCol) ; - } - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetColor( lua_State* L) -{ - // 2 o 3 parametri : Id/s, Colore [, bSetAlpha] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Color cCol ; - LuaCheckParam( L, 2, cCol) - bool bSetAlpha = true ; - LuaGetParam( L, 3, bSetAlpha) ; - LuaClearStack( L) ; - // assegno il colore - bool bOk = EgtSetColor( vId, cCol, bSetAlpha) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetAlpha( lua_State* L) -{ - // 2 : Id/s, nAlpha - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - int nAlpha ; - LuaCheckParam( L, 2, nAlpha) - LuaClearStack( L) ; - // assegno la trasparenza - bool bOk = EgtSetAlpha( vId, nAlpha) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaResetColor( lua_State* L) -{ - // 1 parametro : Id/s - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - LuaClearStack( L) ; - // tolgo il colore - bool bOk = EgtResetColor( vId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetColor( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il colore - int vCol[4] ; - if ( EgtGetColor( nId, vCol) != FALSE) { - Color cCol( vCol) ; - // restituisco il risultato - LuaSetReturn( L, cCol) ; - } - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCalcColor( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il colore - int vCol[4] ; - if ( EgtGetCalcColor( nId, vCol) != FALSE) { - Color cCol( vCol) ; - // restituisco il risultato - LuaSetReturn( L, cCol) ; - } - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetName( lua_State* L) -{ - // 2 parametri : Id, Name - int nId ; - LuaCheckParam( L, 1, nId) - string sName ; - LuaCheckParam( L, 2, sName) - LuaClearStack( L) ; - // assegno il nome - bool bOk = EgtSetName( nId, sName) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetName( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il nome - string sName ; - bool bOk = EgtGetName( nId, sName) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, sName) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExistsName( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // verifico esistenza nome - bool bOk = ( EgtExistsName( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRemoveName( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // verifico esistenza nome - bool bOk = ( EgtRemoveName( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetInfo( lua_State* L) -{ - // 3 parametri : Id, Key, Info - int nId ; - LuaCheckParam( L, 1, nId) - string sKey ; - LuaCheckParam( L, 2, sKey) - string sInfo ; - LuaCheckParam( L, 3, sInfo) - LuaClearStack( L) ; - // assegno la info - bool bOk = EgtSetInfo( nId, sKey, sInfo) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetInfo( lua_State* L) -{ - // 2 parametri : Id, Key - int nId ; - LuaCheckParam( L, 1, nId) - string sKey ; - LuaCheckParam( L, 2, sKey) - LuaClearStack( L) ; - // recupero l'info - string sInfo ; - bool bOk = EgtGetInfo( nId, sKey, sInfo) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, sInfo) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExistsInfo( lua_State* L) -{ - // 2 parametri : Id, Key - int nId ; - LuaCheckParam( L, 1, nId) - string sKey ; - LuaCheckParam( L, 2, sKey) - LuaClearStack( L) ; - // verifico esistenza info - bool bOk = EgtExistsInfo( nId, sKey) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRemoveInfo( lua_State* L) -{ - // 2 parametri : Id, Key - int nId ; - LuaCheckParam( L, 1, nId) - string sKey ; - LuaCheckParam( L, 2, sKey) - LuaClearStack( L) ; - // rimuovo info - bool bOk = EgtRemoveInfo( nId, sKey) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbObjAttribs( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSetLevel", LuaSetLevel) ; - bOk = bOk && LuaRegisterFunction( "EgtRevertLevel", LuaRevertLevel) ; - bOk = bOk && LuaRegisterFunction( "EgtGetLevel", LuaGetLevel) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCalcLevel", LuaGetCalcLevel) ; - bOk = bOk && LuaRegisterFunction( "EgtSetMode", LuaSetMode) ; - bOk = bOk && LuaRegisterFunction( "EgtRevertMode", LuaRevertMode) ; - bOk = bOk && LuaRegisterFunction( "EgtGetMode", LuaGetMode) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCalcMode", LuaGetCalcMode) ; - bOk = bOk && LuaRegisterFunction( "EgtSetStatus", LuaSetStatus) ; - bOk = bOk && LuaRegisterFunction( "EgtRevertStatus", LuaRevertStatus) ; - bOk = bOk && LuaRegisterFunction( "EgtGetStatus", LuaGetStatus) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCalcStatus", LuaGetCalcStatus) ; - bOk = bOk && LuaRegisterFunction( "EgtSetMark", LuaSetMark) ; - bOk = bOk && LuaRegisterFunction( "EgtResetMark", LuaResetMark) ; - bOk = bOk && LuaRegisterFunction( "EgtGetMark", LuaGetMark) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCalcMark", LuaGetCalcMark) ; - bOk = bOk && LuaRegisterFunction( "EgtStdColor", LuaStdColor) ; - bOk = bOk && LuaRegisterFunction( "EgtSetColor", LuaSetColor) ; - bOk = bOk && LuaRegisterFunction( "EgtSetAlpha", LuaSetAlpha) ; - bOk = bOk && LuaRegisterFunction( "EgtResetColor", LuaResetColor) ; - bOk = bOk && LuaRegisterFunction( "EgtGetColor", LuaGetColor) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCalcColor", LuaGetCalcColor) ; - bOk = bOk && LuaRegisterFunction( "EgtSetName", LuaSetName) ; - bOk = bOk && LuaRegisterFunction( "EgtGetName", LuaGetName) ; - bOk = bOk && LuaRegisterFunction( "EgtExistsName", LuaExistsName) ; - bOk = bOk && LuaRegisterFunction( "EgtRemoveName", LuaRemoveName) ; - bOk = bOk && LuaRegisterFunction( "EgtSetInfo", LuaSetInfo) ; - bOk = bOk && LuaRegisterFunction( "EgtGetInfo", LuaGetInfo) ; - bOk = bOk && LuaRegisterFunction( "EgtExistsInfo", LuaExistsInfo) ; - bOk = bOk && LuaRegisterFunction( "EgtRemoveInfo", LuaRemoveInfo) ; - return bOk ; -} diff --git a/LUA_GdbObjSelection.cpp b/LUA_GdbObjSelection.cpp deleted file mode 100644 index 615c94a..0000000 --- a/LUA_GdbObjSelection.cpp +++ /dev/null @@ -1,223 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_GdbObjSelection.cpp Data : 08.01.15 Versione : 1.6a1 -// Contenuto : Funzioni di selezione oggetti del DB geometrico per LUA. -// -// -// -// Modifiche : 08.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaSelectObj( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectObj( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectObj( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectObj( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectAll( lua_State* L) -{ - // 1 parametro : bOnlyIfVisible - bool bOnlyIfVisible ; - LuaCheckParam( L, 1, bOnlyIfVisible) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectAll( bOnlyIfVisible) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectAll( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectAll() != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectGroupObjs( lua_State* L) -{ - // 1 parametro : GroupId - int GroupId ; - LuaCheckParam( L, 1, GroupId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectGroupObjs( GroupId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectGroupObjs( lua_State* L) -{ - // 1 parametro : GroupId - int GroupId ; - LuaCheckParam( L, 1, GroupId) - LuaClearStack( L) ; - // eseguo la deselezione - bool bOk = ( EgtDeselectGroupObjs( GroupId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaIsSelectedObj( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtIsSelectedObj( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetSelectedObjNbr( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // eseguo la selezione - int nNbr = EgtGetSelectedObjNbr() ; - // restituisco il risultato - LuaSetReturn( L, nNbr) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstSelectedObj( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il primo oggetto selezionato - int nId = EgtGetFirstSelectedObj() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetNextSelectedObj( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il successivo oggetto selezionato - int nId = EgtGetNextSelectedObj() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetLastSelectedObj( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero l'ultimo oggetto selezionato - int nId = EgtGetLastSelectedObj() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetPrevSelectedObj( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il precedente oggetto selezionato - int nId = EgtGetPrevSelectedObj() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbObjSelection( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSelectObj", LuaSelectObj) ; - bOk = bOk && LuaRegisterFunction( "EgtDeselectObj", LuaDeselectObj) ; - bOk = bOk && LuaRegisterFunction( "EgtSelectAll", LuaSelectAll) ; - bOk = bOk && LuaRegisterFunction( "EgtDeselectAll", LuaDeselectAll) ; - bOk = bOk && LuaRegisterFunction( "EgtSelectGroupObjs", LuaSelectGroupObjs) ; - bOk = bOk && LuaRegisterFunction( "EgtDeselectGroupObjs", LuaDeselectGroupObjs) ; - bOk = bOk && LuaRegisterFunction( "EgtIsSelectedObj", LuaIsSelectedObj) ; - bOk = bOk && LuaRegisterFunction( "EgtGetSelectedObjNbr", LuaGetSelectedObjNbr) ; - bOk = bOk && LuaRegisterFunction( "EgtGetFirstSelectedObj", LuaGetFirstSelectedObj) ; - bOk = bOk && LuaRegisterFunction( "EgtGetNextSelectedObj", LuaGetNextSelectedObj) ; - bOk = bOk && LuaRegisterFunction( "EgtGetLastSelectedObj", LuaGetLastSelectedObj) ; - bOk = bOk && LuaRegisterFunction( "EgtGetPrevSelectedObj", LuaGetPrevSelectedObj) ; - return bOk ; -} diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp deleted file mode 100644 index 86b716e..0000000 --- a/LUA_GdbObjects.cpp +++ /dev/null @@ -1,521 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GdbObjects.cpp Data : 30.09.14 Versione : 1.5i5 -// Contenuto : Funzioni di iterazione di DB geometrico per LUA. -// -// -// -// Modifiche : 30.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//------------------------------------------------------------------------------- -static int -LuaExistsObj( lua_State* L) -{ - // 1 parametro : Id - int nId = GDB_ID_NULL ; - LuaGetParam( L, 1, nId) ; - LuaClearStack( L) ; - // verifico esistenza oggetto - bool bOk = ( EgtExistsObj( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - 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) -{ - // 1 parametro : GroupId - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - LuaClearStack( L) ; - // determino il numero di oggetti nel gruppo - int nObjs = EgtGetGroupObjs( nGroupId) ; - // restituisco il risultato - LuaSetReturn( L, nObjs) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstInGroup( lua_State* L) -{ - // 1 parametro : GroupId - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - LuaClearStack( L) ; - // recupero il primo oggetto del gruppo - int nId = EgtGetFirstInGroup( nGroupId) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetNext( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il prossimo oggetto nello stesso gruppo - int nNextId = EgtGetNext( nId) ; - // restituisco il risultato - if ( nNextId != GDB_ID_NULL) - LuaSetReturn( L, nNextId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetLastInGroup( lua_State* L) -{ - // 1 parametro : GroupId - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - LuaClearStack( L) ; - // recupero l'ultimo oggetto del gruppo - int nId = EgtGetLastInGroup( nGroupId) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetPrev( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il precedente oggetto nello stesso gruppo - int nPrevId = EgtGetPrev( nId) ; - // restituisco il risultato - if ( nPrevId != GDB_ID_NULL) - LuaSetReturn( L, nPrevId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstNameInGroup( lua_State* L) -{ - // 2 parametri : GroupId, sName - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - string sName ; - LuaCheckParam( L, 2, sName) - LuaClearStack( L) ; - // recupero il primo oggetto del gruppo con il nome desiderato - int nId = EgtGetFirstNameInGroup( nGroupId, sName) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetNextName( lua_State* L) -{ - // 2 parametri : Id, sName - int nId ; - LuaCheckParam( L, 1, nId) - string sName ; - LuaCheckParam( L, 2, sName) - LuaClearStack( L) ; - // recupero il prossimo oggetto nello stesso gruppo con il nome desiderato - int nNextId = EgtGetNextName( nId, sName) ; - // restituisco il risultato - if ( nNextId != GDB_ID_NULL) - LuaSetReturn( L, nNextId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetLastNameInGroup( lua_State* L) -{ - // 2 parametri : GroupId, sName - int nGroupId ; - LuaCheckParam( L, 1, nGroupId) - string sName ; - LuaCheckParam( L, 2, sName) - LuaClearStack( L) ; - // recupero l'ultimo oggetto del gruppo con il nome desiderato - int nId = EgtGetLastNameInGroup( nGroupId, sName) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetPrevName( lua_State* L) -{ - // 2 parametri : Id, sName - int nId ; - LuaCheckParam( L, 1, nId) - string sName ; - LuaCheckParam( L, 2, sName) - LuaClearStack( L) ; - // recupero il precedente oggetto nello stesso gruppo con il nome desiderato - int nPrevId = EgtGetPrevName( nId, sName) ; - // restituisco il risultato - if ( nPrevId != GDB_ID_NULL) - LuaSetReturn( L, nPrevId) ; - else - LuaSetReturn( 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) -{ - // 2 parametri : Id, nFlag - int nId ; - LuaCheckParam( L, 1, nId) - int nFlag ; - LuaCheckParam( L, 2, nFlag) - LuaClearStack( L) ; - // recupero il bounding box dell'oggetto in locale - BBox3d b3Box ; - bool bOk = EgtGetBBox( nId, nFlag, b3Box) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, b3Box) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetBBoxGlob( lua_State* L) -{ - // 2 parametri : Id, nFlag - int nId ; - LuaCheckParam( L, 1, nId) - int nFlag ; - LuaCheckParam( L, 2, nFlag) - LuaClearStack( L) ; - // recupero il bounding box dell'oggetto in globale - BBox3d b3Box ; - bool bOk = EgtGetBBoxGlob( nId, nFlag, b3Box) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, b3Box) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetBBoxRef( lua_State* L) -{ - // 3 parametri : Id, nFlag, Ref - int nId ; - LuaCheckParam( L, 1, nId) - int nFlag ; - LuaCheckParam( L, 2, nFlag) - Frame3d frRef ; - LuaCheckParam( L, 3, frRef) - LuaClearStack( L) ; - // recupero il bounding box dell'oggetto in globale - BBox3d b3Box ; - bool bOk = EgtGetBBoxRef( nId, nFlag, frRef, b3Box) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, b3Box) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCopy( lua_State* L) -{ - // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] - int nSouId ; - LuaCheckParam( L, 1, nSouId) - int nRefId ; - LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_LAST_SON ; - LuaGetParam( L, 3, nSonBeforeAfter) ; - LuaClearStack( L) ; - // eseguo la copia - int nNewId = EgtCopy( nSouId, nRefId, nSonBeforeAfter) ; - // restituisco il risultato - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCopyGlob( lua_State* L) -{ - // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] - int nSouId ; - LuaCheckParam( L, 1, nSouId) - int nRefId ; - LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_LAST_SON ; - LuaGetParam( L, 3, nSonBeforeAfter) ; - LuaClearStack( L) ; - // eseguo la copia - int nNewId = EgtCopyGlob( nSouId, nRefId, nSonBeforeAfter) ; - // restituisco il risultato - if ( nNewId != GDB_ID_NULL) - LuaSetReturn( L, nNewId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRelocate( lua_State* L) -{ - // 2 o 3 parametri : SouId, RefId [, nSonBeforeAfter] - int nSouId ; - LuaCheckParam( L, 1, nSouId) - int nRefId ; - LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_LAST_SON ; - LuaGetParam( L, 3, nSonBeforeAfter) ; - LuaClearStack( L) ; - // eseguo la rilocazione - bool bOk = ( EgtRelocate( nSouId, nRefId, nSonBeforeAfter) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRelocateGlob( lua_State* L) -{ - // 2 o 3 parametri : SouId, RefId [, SonBeforeAfter] - int nSouId ; - LuaCheckParam( L, 1, nSouId) - int nRefId ; - LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_LAST_SON ; - LuaGetParam( L, 3, nSonBeforeAfter) ; - LuaClearStack( L) ; - // eseguo la rilocazione - bool bOk = ( EgtRelocateGlob( nSouId, nRefId, nSonBeforeAfter) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaChangeId( lua_State* L) -{ - // 2 parametri : Id, nNewId - int nId ; - LuaCheckParam( L, 1, nId) - int nNewId ; - LuaCheckParam( L, 2, nNewId) - LuaClearStack( L) ; - // eseguo il cambio di identificativo - bool bOk = ( EgtChangeId( nId, nNewId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaErase( lua_State* L) -{ - // 1 parametro : Id/s - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - LuaClearStack( L) ; - // eseguo la cancellazione - bool bOk = EgtErase( vId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaEmptyGroup( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // eseguo la cancellazione - bool bOk = ( EgtEmptyGroup( nId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -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) ; - bOk = bOk && LuaRegisterFunction( "EgtGetLastInGroup", LuaGetLastInGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtGetPrev", LuaGetPrev) ; - bOk = bOk && LuaRegisterFunction( "EgtGetFirstNameInGroup", LuaGetFirstNameInGroup) ; - 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) ; - bOk = bOk && LuaRegisterFunction( "EgtCopy", LuaCopy) ; - bOk = bOk && LuaRegisterFunction( "EgtCopyGlob", LuaCopyGlob) ; - bOk = bOk && LuaRegisterFunction( "EgtRelocate", LuaRelocate) ; - bOk = bOk && LuaRegisterFunction( "EgtRelocateGlob", LuaRelocateGlob) ; - bOk = bOk && LuaRegisterFunction( "EgtChangeId", LuaChangeId) ; - bOk = bOk && LuaRegisterFunction( "EgtErase", LuaErase) ; - bOk = bOk && LuaRegisterFunction( "EgtEmptyGroup", LuaEmptyGroup) ; - return bOk ; -} diff --git a/LUA_GdbPartLayers.cpp b/LUA_GdbPartLayers.cpp deleted file mode 100644 index afa0289..0000000 --- a/LUA_GdbPartLayers.cpp +++ /dev/null @@ -1,303 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_GdbPartLayers.cpp Data : 29.01.15 Versione : 1.6a7 -// Contenuto : Funzioni di gestione pezzi e layer relativi per LUA. -// -// -// -// Modifiche : 29.01.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaIsPart( lua_State* L) -{ - // 1 parametro : nIdPart - int nIdPart ; - LuaCheckParam( L, 1, nIdPart) - LuaClearStack( L) ; - // verifico sia un pezzo - bool bOk = ( EgtIsPart( nIdPart) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaIsLayer( lua_State* L) -{ - // 1 parametro : nIdLayer - int nIdLayer ; - LuaCheckParam( L, 1, nIdLayer) - LuaClearStack( L) ; - // verifico sia un layer - bool bOk = ( EgtIsPart( nIdLayer) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCurrPart( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il pezzo corrente - int nId = EgtGetCurrPart() ; - // restituisco il risultato - LuaSetReturn( L, nId) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCurrLayer( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il layer corrente - int nId = EgtGetCurrLayer() ; - // restituisco il risultato - LuaSetReturn( L, nId) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetCurrPartLayer( lua_State* L) -{ - // 2 parametri : nPartId, nLayerId - int nPartId ; - LuaCheckParam( L, 1, nPartId) - int nLayerId ; - LuaCheckParam( L, 2, nLayerId) - LuaClearStack( L) ; - // imposto pezzo e layer correnti - bool bOk = ( EgtSetCurrPartLayer( nPartId, nLayerId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaResetCurrPartLayer( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // cerco primo pezzo e layer validi per essere dichiarati correnti - bool bOk = ( EgtResetCurrPartLayer() != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetPartNbr( lua_State* L) -{ - // nessuno o 1 parametro : [bOnlyVisible] - bool bOnlyVisible = false ; - LuaGetParam( L, 1, bOnlyVisible) ; - LuaClearStack( L) ; - // recupero numero pezzi - int nNbr = EgtGetPartNbr( bOnlyVisible) ; - // restituisco il risultato - LuaSetReturn( L, nNbr) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstPart( lua_State* L) -{ - // 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 pezzo successivo - int nId = EgtGetNextPart( nPartId, bOnlyVisible) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstLayer( 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 il primo layer del pezzo - int nId = EgtGetFirstLayer( nPartId, bOnlyVisible) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetNextLayer( lua_State* L) -{ - // 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 (ovviamente dello stesso pezzo) - int nId = EgtGetNextLayer( nLayerId, bOnlyVisible) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectPartObjs( lua_State* L) -{ - // 1 parametro : PartId - int nPartId ; - LuaCheckParam( L, 1, nPartId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectPartObjs( nPartId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectPartObjs( lua_State* L) -{ - // 1 parametro : PartId - int nPartId ; - LuaCheckParam( L, 1, nPartId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectPartObjs( nPartId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectLayerObjs( lua_State* L) -{ - // 1 parametro : LayerId - int nLayerId ; - LuaCheckParam( L, 1, nLayerId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectLayerObjs( nLayerId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDeselectLayerObjs( lua_State* L) -{ - // 1 parametro : LayerId - int nLayerId ; - LuaCheckParam( L, 1, nLayerId) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtDeselectLayerObjs( nLayerId) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSelectPathObjs( lua_State* L) -{ - // 2 parametri : nId, bHaltOnFork - int nId ; - LuaCheckParam( L, 1, nId) - bool bHaltOnFork ; - LuaCheckParam( L, 2, bHaltOnFork) - LuaClearStack( L) ; - // eseguo la selezione - bool bOk = ( EgtSelectPathObjs( nId, bHaltOnFork) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGdbPartLayer( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtGetCurrPart", LuaGetCurrPart) ; - bOk = bOk && LuaRegisterFunction( "EgtIsPart", LuaIsPart) ; - bOk = bOk && LuaRegisterFunction( "EgtIsLayer", LuaIsLayer) ; - bOk = bOk && LuaRegisterFunction( "EgtGetCurrLayer", LuaGetCurrLayer) ; - bOk = bOk && LuaRegisterFunction( "EgtSetCurrPartLayer", LuaSetCurrPartLayer) ; - bOk = bOk && LuaRegisterFunction( "EgtResetCurrPartLayer", LuaResetCurrPartLayer) ; - 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) ; - bOk = bOk && LuaRegisterFunction( "EgtDeselectLayerObjs", LuaDeselectLayerObjs) ; - bOk = bOk && LuaRegisterFunction( "EgtSelectPathObjs", LuaSelectPathObjs) ; - return bOk ; -} diff --git a/LUA_General.cpp b/LUA_General.cpp deleted file mode 100644 index af1da78..0000000 --- a/LUA_General.cpp +++ /dev/null @@ -1,321 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5 -// Contenuto : Funzioni generali per LUA. -// -// -// -// Modifiche : 27.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/EGnStringConverter.h" -#include "/EgtDev/Include/EGnFileUtils.h" -#include "/EgtDev/Include/EGnFileCompare.h" -#include "/EgtDev/Include/EgtPerfCounter.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -static PerformanceCounter s_Counter ; - -//------------------------------------------------------------------------------- -static int -MyPrint( lua_State* L) -{ - string sOut ; - int n = lua_gettop( L) ; /* number of arguments */ - lua_getglobal( L, "tostring") ; - for ( int i = 1 ; i <= n ; ++ i) { - const char* s ; - lua_pushvalue( L, -1) ; /* function to be called */ - lua_pushvalue( L, i) ; /* value to print */ - lua_call( L, 1, 1) ; - s = lua_tostring( L, -1) ; /* get result */ - if ( s == nullptr) - return luaL_error( L, - LUA_QL("tostring") " must return a string to " LUA_QL("print")) ; - if ( i > 1) - sOut += "\t" ; - sOut += s ; - lua_pop( L, 1) ; /* pop result */ - } - if ( ! sOut.empty()) - LOG_INFO( GetLogger(), sOut.c_str()) - - return 0 ; -} - -//------------------------------------------------------------------------------- -static int -SetContext( lua_State* L) -{ - // un solo parametro intero - int nGseCtx ; - LuaCheckParam( L, 1, nGseCtx) - LuaClearStack( L) ; - // imposto il contesto - bool bOk = SetCurrGseContext( nGseCtx) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -GetContext( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // restituisco l'indice del contesto - LuaSetReturn( L, GetIndCurrGseContext()) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaPause( lua_State* L) -{ - // 1 parametro : numero di millisecondi - int nTime ; - LuaCheckParam( L, 1, nTime) - LuaClearStack( L) ; - // controllo la durata della pausa e la eseguo - const int MIN_TIME = 0 ; - const int MAX_TIME = 10000 ; - if ( nTime < MIN_TIME) - nTime = MIN_TIME ; - else if ( nTime > MAX_TIME) - nTime = MAX_TIME ; - Sleep( nTime) ; - // restituisco il risultato - LuaSetReturn( L, true) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaStartCounter( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // avvio il contatore - s_Counter.Start() ; - return 0 ; -} - -//------------------------------------------------------------------------------- -static int -LuaStopCounter( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // fermo il contatore - double dTime = s_Counter.Stop() ; - // restituisco il risultato - LuaSetReturn( L, dTime) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaNumToString( lua_State* L) -{ - // 2 parametri : dVal, nDec - double dVal ; - LuaCheckParam( L, 1, dVal) - int nDec ; - LuaCheckParam( L, 2, nDec) - LuaClearStack( L) ; - // costruisco la stringa - string sVal = ToString( dVal, nDec) ; - // ritorno il risultato - LuaSetReturn( L, sVal) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaExecTsc( lua_State* L) -{ - // 1 parametro : file - string sFile ; - LuaCheckParam( L, 1, sFile) - LuaClearStack( L) ; - // eseguo lo script TSC - bool bOk = EgtTscExecFile( sFile) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaOutLog( lua_State* L) -{ - // 1 parametro : stringa da emettere - string sOut ; - LuaCheckParam( L, 1, sOut) - LuaClearStack( L) ; - // accodo il messaggio nel file di log - LOG_INFO( GetLogger(), sOut.c_str()) - // non c'è risultato - return 0 ; -} - -//------------------------------------------------------------------------------- -static int -LuaOutBox( lua_State* L) -{ - // 3 parametri : stringa, titolo, icona - string sOut ; - LuaCheckParam( L, 1, sOut) - string sTitle ; - LuaCheckParam( L, 2, sTitle) - string sIcon ; - LuaCheckParam( L, 3, sIcon) - int nIcon = MB_ICONINFORMATION ; - ToUpper( sIcon) ; - if ( sIcon == "ERROR") - nIcon = MB_ICONERROR ; - else if ( sIcon == "WARNING") - nIcon = MB_ICONWARNING ; - LuaClearStack( L) ; - // accodo il messaggio nel file di log - int nRes = MessageBox( nullptr, stringtoW( sOut), stringtoW( sTitle), MB_OKCANCEL | nIcon | MB_TASKMODAL) ; - // risultato (Ok->true, Cancel->false) - LuaSetReturn( L, ( nRes == IDOK)) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaEraseFile( lua_State* L) -{ - // 1 parametro : file - string sFile ; - LuaCheckParam( L, 1, sFile) - LuaClearStack( L) ; - // svuoto il direttorio - bool bOk = EraseFile( sFile) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaEmptyDirectory( lua_State* L) -{ - // 1 parametro : dir - string sDir ; - LuaCheckParam( L, 1, sDir) - LuaClearStack( L) ; - // svuoto il direttorio - bool bOk = EmptyDirectory( sDir) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaTextFileCompare( lua_State* L) -{ - // 4 parametri : file1, file2, inizio commento, file diff - string sFile1 ; - LuaCheckParam( L, 1, sFile1) - string sFile2 ; - LuaCheckParam( L, 2, sFile2) - string sRemStart ; - LuaCheckParam( L, 3, sRemStart) - string sFileDiff ; - LuaCheckParam( L, 4, sFileDiff) - LuaClearStack( L) ; - // eseguo il confronto - bool bOk = TextFileCompare( sFile1, sFile2, sRemStart, sFileDiff) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaBinaryFileCompare( lua_State* L) -{ - // 3 parametri : file1, file2, file diff - string sFile1 ; - LuaCheckParam( L, 1, sFile1) - string sFile2 ; - LuaCheckParam( L, 2, sFile2) - string sFileDiff ; - LuaCheckParam( L, 3, sFileDiff) - LuaClearStack( L) ; - // eseguo il confronto - bool bOk = BinaryFileCompare( sFile1, sFile2, sFileDiff) ; - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetVersion( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // costruisco la stringa con le versioni - string sVer ; - if ( ! EgtGetVersionInfo( sVer, "\n")) - sVer = "VersionInfo error" ; - // restituisco il risultato - LuaSetReturn( L, sVer) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaIs64bit( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // restituisco il risultato -#if defined( _WIN64) - bool bRes = true ; -#elif defined( _WIN32) - bool bRes = false ; -#endif - LuaSetReturn( L, bRes) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGeneral( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "print", MyPrint) ; - bOk = bOk && LuaRegisterFunction( "EgtSetContext", SetContext) ; - bOk = bOk && LuaRegisterFunction( "EgtGetContext", GetContext) ; - bOk = bOk && LuaRegisterFunction( "EgtPause", LuaPause) ; - bOk = bOk && LuaRegisterFunction( "EgtStartCounter", LuaStartCounter) ; - bOk = bOk && LuaRegisterFunction( "EgtStopCounter", LuaStopCounter) ; - bOk = bOk && LuaRegisterFunction( "EgtNumToString", LuaNumToString) ; - bOk = bOk && LuaRegisterFunction( "EgtExecTsc", LuaExecTsc) ; - bOk = bOk && LuaRegisterFunction( "EgtOutLog", LuaOutLog) ; - bOk = bOk && LuaRegisterFunction( "EgtOutBox", LuaOutBox) ; - bOk = bOk && LuaRegisterFunction( "EgtEraseFile", LuaEraseFile) ; - bOk = bOk && LuaRegisterFunction( "EgtEmptyDirectory", LuaEmptyDirectory) ; - bOk = bOk && LuaRegisterFunction( "EgtTextFileCompare", LuaTextFileCompare) ; - bOk = bOk && LuaRegisterFunction( "EgtBinaryFileCompare", LuaBinaryFileCompare) ; - bOk = bOk && LuaRegisterFunction( "EgtGetVersion", LuaGetVersion) ; - bOk = bOk && LuaRegisterFunction( "EgtIs64bit", LuaIs64bit) ; - return bOk ; -} diff --git a/LUA_GeoBase.cpp b/LUA_GeoBase.cpp deleted file mode 100644 index c717900..0000000 --- a/LUA_GeoBase.cpp +++ /dev/null @@ -1,472 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GeoBasel.cpp Data : 20.12.14 Versione : 1.5l2 -// Contenuto : Funzioni generali per LUA. -// -// -// -// Modifiche : 27.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//------------------------------------------------------------------------------- -static int -LuaVectorRotate( lua_State* L) -{ - // 3 parametri : Vector, VtAsse, AngRot in gradi - Vector3d vtV ; - LuaCheckParam( L, 1, vtV) - Vector3d vtAx ; - LuaCheckParam( L, 2, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 3, dAngRotDeg) - LuaClearStack( L) ; - // eseguo la rotazione - if ( vtV.Rotate( vtAx, dAngRotDeg)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, vtV) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaVectorToGlob( lua_State* L) -{ - // 2 parametri : Vector, frame di trasformazione - Vector3d vtV ; - LuaCheckParam( L, 1, vtV) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( vtV.ToGlob( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, vtV) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaVectorToLoc( lua_State* L) -{ - // 2 parametri : Vector, frame di trasformazione - Vector3d vtV ; - LuaCheckParam( L, 1, vtV) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( vtV.ToLoc( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, vtV) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaVectorLocToLoc( lua_State* L) -{ - // 3 parametri : Vector, frame origine, frame destinazione - Vector3d vtV ; - LuaCheckParam( L, 1, vtV) - Frame3d frOri ; - LuaCheckParam( L, 2, frOri) - Frame3d frDest ; - LuaCheckParam( L, 3, frDest) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( vtV.LocToLoc( frOri, frDest)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, vtV) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaPointRotate( lua_State* L) -{ - // 4 parametri : Point, PtAsse, VtAsse, AngRot in gradi - Point3d ptP ; - LuaCheckParam( L, 1, ptP) - Point3d ptAx ; - LuaCheckParam( L, 2, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 3, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 4, dAngRotDeg) - LuaClearStack( L) ; - // eseguo la rotazione - if ( ptP.Rotate( ptAx, vtAx, dAngRotDeg)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, ptP) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaPointToGlob( lua_State* L) -{ - // 2 parametri : Point, frame di trasformazione - Point3d ptP ; - LuaCheckParam( L, 1, ptP) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( ptP.ToGlob( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, ptP) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaPointToLoc( lua_State* L) -{ - // 2 parametri : Point, frame di trasformazione - Point3d ptP ; - LuaCheckParam( L, 1, ptP) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( ptP.ToLoc( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, ptP) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaPointLocToLoc( lua_State* L) -{ - // 3 parametri : Point, frame origine, frame destinazione - Point3d ptP ; - LuaCheckParam( L, 1, ptP) - Frame3d frOri ; - LuaCheckParam( L, 2, frOri) - Frame3d frDest ; - LuaCheckParam( L, 3, frDest) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( ptP.LocToLoc( frOri, frDest)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, ptP) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameFrom3Points( lua_State* L) -{ - // 3 parametri : origine, punto su X, punto vicino a Y - Point3d ptOrig ; - LuaCheckParam( L, 1, ptOrig) - Point3d ptOnX ; - LuaCheckParam( L, 2, ptOnX) - Point3d ptNearY ; - LuaCheckParam( L, 3, ptNearY) - LuaClearStack( L) ; - // calcolo il riferimento e restituisco il risultato : bOk, Frame - Frame3d frTemp ; - if ( frTemp.Set( ptOrig, ptOnX, ptNearY)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frTemp) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameOCS( lua_State* L) -{ - // 2 parametri : origine, asse Z - Point3d ptOrig ; - LuaCheckParam( L, 1, ptOrig) - Vector3d vtDirZ ; - LuaCheckParam( L, 2, vtDirZ) - LuaClearStack( L) ; - // calcolo il riferimento e restituisco il risultato : bOk, Frame - Frame3d frTemp ; - if ( frTemp.Set( ptOrig, vtDirZ)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frTemp) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameRotate( lua_State* L) -{ - // 4 parametri : Frame, PtAsse, VtAsse, AngRot in gradi - Frame3d frFrame ; - LuaCheckParam( L, 1, frFrame) - Point3d ptAx ; - LuaCheckParam( L, 2, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 3, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 4, dAngRotDeg) - LuaClearStack( L) ; - // eseguo la rotazione - if ( frFrame.Rotate( ptAx, vtAx, dAngRotDeg)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frFrame) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameToGlob( lua_State* L) -{ - // 2 parametri : frame, frame di trasformazione - Frame3d frFrame ; - LuaCheckParam( L, 1, frFrame) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( frFrame.ToGlob( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frFrame) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameToLoc( lua_State* L) -{ - // 2 parametri : frame, frame di trasformazione - Frame3d frFrame ; - LuaCheckParam( L, 1, frFrame) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( frFrame.ToLoc( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frFrame) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaFrameLocToLoc( lua_State* L) -{ - // 3 parametri : frame, frame origine, frame destinazione - Frame3d frFrame ; - LuaCheckParam( L, 1, frFrame) - Frame3d frOri ; - LuaCheckParam( L, 2, frOri) - Frame3d frDest ; - LuaCheckParam( L, 3, frDest) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( frFrame.LocToLoc( frOri, frDest)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, frFrame) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -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) -{ - // 2 parametri : bbox, frame di trasformazione - BBox3d b3Box ; - LuaCheckParam( L, 1, b3Box) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( b3Box.ToGlob( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, b3Box) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaBBoxToLoc( lua_State* L) -{ - // 2 parametri : bbox, frame di trasformazione - BBox3d b3Box ; - LuaCheckParam( L, 1, b3Box) - Frame3d frTool ; - LuaCheckParam( L, 2, frTool) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( b3Box.ToLoc( frTool)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, b3Box) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -static int -LuaBBoxLocToLoc( lua_State* L) -{ - // 3 parametri : bbox, frame origine, frame destinazione - BBox3d b3Box ; - LuaCheckParam( L, 1, b3Box) - Frame3d frOri ; - LuaCheckParam( L, 2, frOri) - Frame3d frDest ; - LuaCheckParam( L, 3, frDest) - LuaClearStack( L) ; - // eseguo la trasformazione - if ( b3Box.LocToLoc( frOri, frDest)) { - LuaSetReturn( L, true) ; - LuaSetReturn( L, b3Box) ; - return 2 ; - } - else { - LuaSetReturn( L, false) ; - return 1 ; - } -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGeoBase( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtVectorRotate", LuaVectorRotate) ; - bOk = bOk && LuaRegisterFunction( "EgtVectorToGlob", LuaVectorToGlob) ; - bOk = bOk && LuaRegisterFunction( "EgtVectorToLoc", LuaVectorToLoc) ; - bOk = bOk && LuaRegisterFunction( "EgtVectorLocToLoc", LuaVectorLocToLoc) ; - bOk = bOk && LuaRegisterFunction( "EgtPointRotate", LuaPointRotate) ; - bOk = bOk && LuaRegisterFunction( "EgtPointToGlob", LuaPointToGlob) ; - bOk = bOk && LuaRegisterFunction( "EgtPointToLoc", LuaPointToLoc) ; - bOk = bOk && LuaRegisterFunction( "EgtPointLocToLoc", LuaPointLocToLoc) ; - bOk = bOk && LuaRegisterFunction( "EgtFrameFrom3Points", LuaFrameFrom3Points) ; - bOk = bOk && LuaRegisterFunction( "EgtFrameOCS", LuaFrameOCS) ; - bOk = bOk && LuaRegisterFunction( "EgtFrameRotate", LuaFrameRotate) ; - 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) ; - return bOk ; -} diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp deleted file mode 100644 index 96bda4a..0000000 --- a/LUA_GeoSnap.cpp +++ /dev/null @@ -1,585 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GeoSnap.cpp Data : 02.10.14 Versione : 1.5i5 -// Contenuto : Funzioni di snap ad oggetti del DB geometrico per LUA. -// -// -// -// Modifiche : 02.10.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//---------------------------------------------------------------------------- -static int -LuaStartPoint( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il punto iniziale dell'entità - Point3d ptP ; - if ( EgtStartPoint( nId, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaEndPoint( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il punto finale dell'entità - Point3d ptP ; - if ( EgtEndPoint( nId, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaMidPoint( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il punto centrale dell'entità - Point3d ptP ; - if ( EgtMidPoint( nId, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCenterPoint( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il punto centrale dell'entità - Point3d ptP ; - if ( EgtCenterPoint( nId, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCentroid( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il centro geometrico dell'entità - Point3d ptP ; - if ( EgtCentroid( nId, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaAtParamPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, U [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - double dU ; - LuaCheckParam( L, 2, dU) - int nRefId = nId ; - LuaGetParam( L, 3, nRefId) ; - LuaClearStack( L) ; - // recupero il punto in posizione parametrica U della curva - Point3d ptP ; - if ( EgtAtParamPoint( nId, dU, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaNearPoint( lua_State* L) -{ - // 2 o 3 parametri : Id, ptNear [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptNear ; - LuaCheckParam( L, 2, ptNear) - int nRefId = nId ; - LuaGetParam( L, 3, nRefId) ; - LuaClearStack( L) ; - // recupero il punto di intersezione tra le curve più vicino al punto passato - Point3d ptP ; - if ( EgtNearPoint( nId, ptNear, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaIntersectionPoint( lua_State* L) -{ - // 3 o 4 parametri : Id1, Id2, ptNear [, nRefId] - int nId1 ; - LuaCheckParam( L, 1, nId1) - int nId2 ; - LuaCheckParam( L, 2, nId2) - Point3d ptNear ; - LuaCheckParam( L, 3, ptNear) - int nRefId = nId1 ; - LuaGetParam( L, 4, nRefId) ; - LuaClearStack( L) ; - // recupero il punto di intersezione tra le curve più vicino al punto passato - Point3d ptP ; - if ( EgtIntersectionPoint( nId1, nId2, ptNear, nRefId, ptP)) - LuaSetReturn( L, ptP) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaStartVector( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il vettore tangente all'inizio della curva - Vector3d vtV ; - if ( EgtStartVector( nId, nRefId, vtV)) - LuaSetReturn( L, vtV) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaEndVector( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il vettore tangente alla fine della curva - Vector3d vtV ; - if ( EgtEndVector( nId, nRefId, vtV)) - LuaSetReturn( L, vtV) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaMidVector( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il vettore tangente nel punto medio della curva - Vector3d vtV ; - if ( EgtMidVector( nId, nRefId, vtV)) - LuaSetReturn( L, vtV) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaAtParamVector( lua_State* L) -{ - // 2, 3 o 4 parametri : Id, U, nSide [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - double dU ; - LuaCheckParam( L, 2, dU) - int nSide ; - LuaCheckParam( L, 3, nSide) ; - int nRefId = nId ; - LuaGetParam( L, 4, nRefId) ; - LuaClearStack( L) ; - // recupero il punto in posizione parametrica U della curva - Vector3d vtV ; - if ( EgtAtParamVector( nId, dU, nSide, nRefId, vtV)) - LuaSetReturn( L, vtV) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaFrame( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il frame - Frame3d frFrame ; - if ( EgtFrame( nId, nRefId, frFrame)) - LuaSetReturn( L, frFrame) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveLength( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero la lunghezza della curva - double dLen ; - if ( EgtCurveLength( nId, &dLen) != FALSE) - LuaSetReturn( L, dLen) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveExtrusion( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il versore - Vector3d vtExtr ; - if ( EgtCurveExtrusion( nId, nRefId, vtExtr)) - LuaSetReturn( L, vtExtr) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveThickness( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero lo spessore - double dThick ; - if ( EgtCurveThickness( nId, &dThick) != FALSE) - LuaSetReturn( L, dThick) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaExtrusionByThickness( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il versore e lo spessore - Vector3d vtExtr ; - double dThick ; - if ( EgtCurveExtrusion( nId, nRefId, vtExtr) && ! vtExtr.IsSmall() && - EgtCurveThickness( nId, &dThick) && fabs( dThick) > EPS_SMALL) - vtExtr *= dThick ; - else - vtExtr = V_NULL ; - LuaSetReturn( L, vtExtr) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveArcRadius( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il raggio - double dRad ; - if ( EgtCurveArcRadius( nId, &dRad) != FALSE) - LuaSetReturn( L, dRad) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveArcNormVersor( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il versore - Vector3d vtNorm ; - if ( EgtCurveArcNormVersor( nId, nRefId, vtNorm)) - LuaSetReturn( L, vtNorm) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaCurveCompoCenter( lua_State* L) -{ - // 2 o 3 parametri : Id, nCrv [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nCrv ; - LuaCheckParam( L, 2, nCrv) - int nRefId = nId ; - LuaGetParam( L, 3, nRefId) ; - LuaClearStack( L) ; - // recupero il centro della curva semplice indicizzata - Point3d ptCen ; - if ( EgtCurveCompoCenter( nId, nCrv, nRefId, ptCen)) - LuaSetReturn( L, ptCen) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmFacetNbr( lua_State* L) -{ - // 1 parametro : Id - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero il numero di facce della superficie trimesh - int nNbr = EgtSurfTmFacetNbr( nId) ; - LuaSetReturn( L, nNbr) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmFacetNearestEndPoint( lua_State* L) -{ - // 3 o 4 parametri : Id, nFacet, ptNear [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nFacet ; - LuaCheckParam( L, 2, nFacet) - Point3d ptNear ; - LuaCheckParam( L, 3, ptNear) - int nRefId = nId ; - LuaGetParam( L, 4, nRefId) ; - LuaClearStack( L) ; - // recupero il punto End più vicino della faccia della superficie trimesh - Point3d ptEnd ; - Vector3d vtN ; - if ( EgtSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptEnd, vtN)) { - LuaSetReturn( L, ptEnd) ; - LuaSetReturn( L, vtN) ; - } - else { - LuaSetReturn( L) ; - LuaSetReturn( L) ; - } - return 2 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmFacetNearestMidPoint( lua_State* L) -{ - // 3 o 4 parametri : Id, nFacet, ptNear [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nFacet ; - LuaCheckParam( L, 2, nFacet) - Point3d ptNear ; - LuaCheckParam( L, 3, ptNear) - int nRefId = nId ; - LuaGetParam( L, 4, nRefId) ; - LuaClearStack( L) ; - // recupero il punto Mid più vicino della faccia della superficie trimesh - Point3d ptMid ; - Vector3d vtN ; - if ( EgtSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptMid, vtN)) { - LuaSetReturn( L, ptMid) ; - LuaSetReturn( L, vtN) ; - } - else { - LuaSetReturn( L) ; - LuaSetReturn( L) ; - } - return 2 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmFacetCenter( lua_State* L) -{ - // 2 o 3 parametri : Id, nFacet [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nFacet ; - LuaCheckParam( L, 2, nFacet) - int nRefId = nId ; - LuaGetParam( L, 3, nRefId) ; - LuaClearStack( L) ; - // recupero il centro della faccia della superficie trimesh - Point3d ptCen ; - Vector3d vtN ; - if ( EgtSurfTmFacetCenter( nId, nFacet, nRefId, ptCen, vtN)) { - LuaSetReturn( L, ptCen) ; - LuaSetReturn( L, vtN) ; - } - else { - LuaSetReturn( L) ; - LuaSetReturn( L) ; - } - return 2 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmFacetNormVersor( lua_State* L) -{ - // 2 o 3 parametri : Id, nFacet [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nFacet ; - LuaCheckParam( L, 2, nFacet) - int nRefId = nId ; - LuaGetParam( L, 3, nRefId) ; - LuaClearStack( L) ; - // recupero la normale della faccia della superficie trimesh - Vector3d vtNorm ; - if ( EgtSurfTmFacetNormVersor( nId, nFacet, nRefId, vtNorm)) - LuaSetReturn( L, vtNorm) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaExtTextNormVersor( lua_State* L) -{ - // 1 o 2 parametri : Id [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - int nRefId = nId ; - LuaGetParam( L, 2, nRefId) ; - LuaClearStack( L) ; - // recupero il versore - Vector3d vtNorm ; - if ( EgtExtTextNormVersor( nId, nRefId, vtNorm)) - LuaSetReturn( L, vtNorm) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGeoSnap( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSP", LuaStartPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtEP", LuaEndPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtMP", LuaMidPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtCP", LuaCenterPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtGP", LuaCentroid) ; - bOk = bOk && LuaRegisterFunction( "EgtUP", LuaAtParamPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtNP", LuaNearPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtIP", LuaIntersectionPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtSV", LuaStartVector) ; - bOk = bOk && LuaRegisterFunction( "EgtEV", LuaEndVector) ; - bOk = bOk && LuaRegisterFunction( "EgtMV", LuaMidVector) ; - bOk = bOk && LuaRegisterFunction( "EgtUV", LuaAtParamVector) ; - bOk = bOk && LuaRegisterFunction( "EgtFR", LuaFrame) ; - bOk = bOk && LuaRegisterFunction( "EgtET", LuaExtrusionByThickness) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveLength", LuaCurveLength) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveExtrusion", LuaCurveExtrusion) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveThickness", LuaCurveThickness) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveArcRadius", LuaCurveArcRadius) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveArcNormVersor", LuaCurveArcNormVersor) ; - bOk = bOk && LuaRegisterFunction( "EgtCurveCompoCenter", LuaCurveCompoCenter) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmFacetNbr", LuaSurfTmFacetNbr) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmFacetNearestEndPoint", LuaSurfTmFacetNearestEndPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmFacetNearestMidPoint", LuaSurfTmFacetNearestMidPoint) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ; - bOk = bOk && LuaRegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ; - bOk = bOk && LuaRegisterFunction( "EgtExtTextNormVersor", LuaExtTextNormVersor) ; - return bOk ; -} diff --git a/LUA_GeoTransform.cpp b/LUA_GeoTransform.cpp deleted file mode 100644 index 7919494..0000000 --- a/LUA_GeoTransform.cpp +++ /dev/null @@ -1,260 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_GeoTransform.cpp Data : 29.09.14 Versione : 1.5i5 -// Contenuto : Funzioni di trasformazione geometrica per LUA. -// -// -// -// Modifiche : 29.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EInConst.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaMove( lua_State* L) -{ - // 2 o 3 parametri : Id/s, VtMove [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Vector3d vtMove ; - LuaCheckParam( L, 2, vtMove) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 3, nRefType) ; - LuaClearStack( L) ; - // eseguo traslazione - bool bOk = EgtMove( vId, vtMove, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRotate( lua_State* L) -{ - // 4 o 5 parametri : Id/s, PtAx, VtAx, dAngRotDeg [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Point3d ptAx ; - LuaCheckParam( L, 2, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 3, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 4, dAngRotDeg) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // eseguo rotazione - bool bOk = EgtRotate( vId, ptAx, vtAx, dAngRotDeg, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaScale( lua_State* L) -{ - // 5 o 6 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Frame3d frRef ; - LuaCheckParam( L, 2, frRef) - double dCoeffX ; - LuaCheckParam( L, 3, dCoeffX) - double dCoeffY ; - LuaCheckParam( L, 4, dCoeffY) - double dCoeffZ ; - LuaCheckParam( L, 5, dCoeffZ) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // eseguo scalatura - bool bOk = EgtScale( vId, frRef, dCoeffX, dCoeffY, dCoeffZ, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMirror( lua_State* L) -{ - // 3 o 4 parametri : Id/s, PtOn, VtN [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // eseguo riflessione - bool bOk = EgtMirror( vId, ptOn, vtN, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaShear( lua_State* L) -{ - // 5 o 6 parametri : Id, PtOn, VtN, VtDir, Coeff [, nRefType] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - Vector3d vtDir ; - LuaCheckParam( L, 4, vtDir) - double dCoeff ; - LuaCheckParam( L, 5, dCoeff) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; - LuaClearStack( L) ; - // eseguo stiramento - bool bOk = EgtShear( vId, ptOn, vtN, vtDir, dCoeff, nRefType) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMoveGroup( lua_State* L) -{ - // 2 parametri : Id, VtMove - int nId ; - LuaCheckParam( L, 1, nId) - Vector3d vtMove ; - LuaCheckParam( L, 2, vtMove) - LuaClearStack( L) ; - // eseguo traslazione - bool bOk = ( EgtMoveGroup( nId, vtMove.v) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRotateGroup( lua_State* L) -{ - // 4 parametri : Id, PtAx, VtAx, dAngRotDeg - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptAx ; - LuaCheckParam( L, 2, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 3, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 4, dAngRotDeg) - LuaClearStack( L) ; - // eseguo rotazione - bool bOk = ( EgtRotateGroup( nId, ptAx.v, vtAx.v, dAngRotDeg) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaScaleGroup( lua_State* L) -{ - // 5 parametri : Id, Frame, CoeffX, CoeffY, CoeffZ - int nId ; - LuaCheckParam( L, 1, nId) - Frame3d frRef ; - LuaCheckParam( L, 2, frRef) - double dCoeffX ; - LuaCheckParam( L, 3, dCoeffX) - double dCoeffY ; - LuaCheckParam( L, 4, dCoeffY) - double dCoeffZ ; - LuaCheckParam( L, 5, dCoeffZ) - LuaClearStack( L) ; - // eseguo scalatura - bool bOk = ( EgtScaleGroup( nId, frRef.Orig().v, - frRef.VersX().v, frRef.VersY().v, frRef.VersZ().v, - dCoeffX, dCoeffY, dCoeffZ) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMirrorGroup( lua_State* L) -{ - // 3 parametri : Id, PtOn, VtN - int sId ; - LuaCheckParam( L, 1, sId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - LuaClearStack( L) ; - // eseguo scalatura - bool bOk = ( EgtMirrorGroup( sId, ptOn.v, vtN.v) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaShearGroup( lua_State* L) -{ - // 5 parametri : Id, PtOn, VtN, VtDir, Coeff - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - Vector3d vtDir ; - LuaCheckParam( L, 4, vtDir) - double dCoeff ; - LuaCheckParam( L, 5, dCoeff) - LuaClearStack( L) ; - // eseguo scalatura - bool bOk = ( EgtShearGroup( nId, ptOn.v, vtN.v, vtDir.v, dCoeff) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGeoTransform( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtMove", LuaMove) ; - bOk = bOk && LuaRegisterFunction( "EgtRotate", LuaRotate) ; - bOk = bOk && LuaRegisterFunction( "EgtScale", LuaScale) ; - bOk = bOk && LuaRegisterFunction( "EgtMirror", LuaMirror) ; - bOk = bOk && LuaRegisterFunction( "EgtShear", LuaShear) ; - bOk = bOk && LuaRegisterFunction( "EgtMoveGroup", LuaMoveGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtRotateGroup", LuaRotateGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtScaleGroup", LuaScaleGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtMirrorGroup", LuaMirrorGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtShearGroup", LuaShearGroup) ; - return bOk ; -} diff --git a/LUA_GeomDB.cpp b/LUA_GeomDB.cpp deleted file mode 100644 index 6a4b9c0..0000000 --- a/LUA_GeomDB.cpp +++ /dev/null @@ -1,189 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5 -// Contenuto : Funzioni generali per LUA. -// -// -// -// Modifiche : 27.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - - -//------------------------------------------------------------------------------- -static int -LuaSetDefaultMaterial( lua_State* L) -{ - // un solo parametro, il colore - Color colDef ; - if ( ! LuaGetParam( L, 1, colDef)) - return luaL_error( L, "Invalide first parameter") ; - LuaClearStack( L) ; - // imposto il colore di default - int vCol[4] ; - colDef.GetInt( vCol) ; - bool bOk = ( EgtSetDefaultMaterial( vCol) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetGridFrame( lua_State* L) -{ - // 1 parametro : Frame - Frame3d frFrame ; - LuaCheckParam( L, 1, frFrame) ; - LuaClearStack( L) ; - // imposto il riferimento della Griglia (o CPlane) - bool bOk = ( EgtSetGridFrame( frFrame)) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetGridFrame( lua_State* L) -{ - // 1 o nessun parametro : [nRefId] - int nRefId = GDB_ID_ROOT ; - if ( lua_gettop( L) >= 1) - LuaCheckParam( L, 1, nRefId) - LuaClearStack( L) ; - // recupero il riferimento della griglia - Frame3d frFrame ; - EgtGetGridFrame( nRefId, frFrame) ; - // restituisco il risultato - LuaSetReturn( L, frFrame) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetGridVersZ( lua_State* L) -{ - // 1 o nessun parametro : [nRefId] - int nRefId = GDB_ID_ROOT ; - if ( lua_gettop( L) >= 1) - LuaCheckParam( L, 1, nRefId) - LuaClearStack( L) ; - // recupero il versore Z della griglia e lo restituisco - Vector3d vtVersZ ; - if ( EgtGetGridVersZ( nRefId, vtVersZ)) - LuaSetReturn( L, vtVersZ) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaNewFile( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // nuovo progetto - bool bOk = ( EgtNewFile() != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaOpenFile( lua_State* L) -{ - // 1 parametro : path del file da aprire - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - LuaClearStack( L) ; - // apro il file - bool bOk = EgtOpenFile( sFilePath) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaInsertFile( lua_State* L) -{ - // 1 parametro : path del file da importare - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - LuaClearStack( L) ; - // apro il file - bool bOk = EgtInsertFile( sFilePath) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSaveFile( lua_State* L) -{ - // 1 o 2 parametri : path del file [, flag] - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - int nFlag = GDB_SV_CMPTXT ; - LuaGetParam( L, 2, nFlag) ; - LuaClearStack( L) ; - // salvo il file - bool bOk = EgtSaveFile( sFilePath, nFlag) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSaveObjToFile( lua_State* L) -{ - // 2 o 3 parametri : nId, path del file [, flag] - int nId ; - LuaCheckParam( L, 1, nId) - string sFilePath ; - LuaCheckParam( L, 2, sFilePath) - int nFlag = GDB_SV_CMPTXT ; - LuaGetParam( L, 3, nFlag) ; - LuaClearStack( L) ; - // copio il gruppo nel file - bool bOk = EgtSaveObjToFile( nId, sFilePath, nFlag) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallGeomDB( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSetDefaultMaterial", LuaSetDefaultMaterial) ; - bOk = bOk && LuaRegisterFunction( "EgtSetGridFrame", LuaSetGridFrame) ; - bOk = bOk && LuaRegisterFunction( "EgtGetGridFrame", LuaGetGridFrame) ; - bOk = bOk && LuaRegisterFunction( "EgtGetGridVersZ", LuaGetGridVersZ) ; - bOk = bOk && LuaRegisterFunction( "EgtNewFile", LuaNewFile) ; - bOk = bOk && LuaRegisterFunction( "EgtOpenFile", LuaOpenFile) ; - bOk = bOk && LuaRegisterFunction( "EgtInsertFile", LuaInsertFile) ; - bOk = bOk && LuaRegisterFunction( "EgtSaveFile", LuaSaveFile) ; - bOk = bOk && LuaRegisterFunction( "EgtSaveObjToFile", LuaSaveObjToFile) ; - return bOk ; -} diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp deleted file mode 100644 index d0b6976..0000000 --- a/LUA_MachMgr.cpp +++ /dev/null @@ -1,544 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2015-2015 -//---------------------------------------------------------------------------- -// File : LUA_MachMgr.cpp Data : 24.03.15 Versione : 1.6c8 -// Contenuto : Funzioni Machining Manager per LUA. -// -// -// -// Modifiche : 24.03.15 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "AuxTools.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaGetMachGroupNbr( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero il numero di macchinate - int nTot = EgtGetMachGroupNbr() ; - // restituisco il risultato - LuaSetReturn( L, nTot) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetFirstMachGroup( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero l'identificativo della prima macchinata - int nId = EgtGetFirstMachGroup() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetNextMachGroup( lua_State* L) -{ - // 1 parametro : identificativo di una macchinata - int nId ; - LuaCheckParam( L, 1, nId) - LuaClearStack( L) ; - // recupero l'identificativo della successiva macchinata - int nNextId = EgtGetNextMachGroup( nId) ; - // restituisco il risultato - if ( nNextId != GDB_ID_NULL) - LuaSetReturn( L, nNextId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaAddMachGroup( lua_State* L) -{ - // 2 parametri : nome del gruppo, nome della macchina da utilizzare - string sName ; - LuaCheckParam( L, 1, sName) - string sMachineName ; - LuaCheckParam( L, 2, sMachineName) - LuaClearStack( L) ; - // aggiungo la macchinata - int nId = EgtAddMachGroup( sName, sMachineName) ; - // restituisco il risultato - LuaSetReturn( L, nId) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRemoveMachGroup( lua_State* L) -{ - // 1 parametro : identificativo del gruppo - int nMGroupInd ; - LuaCheckParam( L, 1, nMGroupInd) - LuaClearStack( L) ; - // rimuovo la macchinata - bool bOk = ( EgtRemoveMachGroup( nMGroupInd) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetMachGroupName( lua_State* L) -{ - // 1 parametro : identificativo del gruppo - int nMGroupInd ; - LuaCheckParam( L, 1, nMGroupInd) - LuaClearStack( L) ; - // recupero il nome della macchinata - string sName ; - bool bOk = EgtGetMachGroupName( nMGroupInd, sName) ; - // restituisco il risultato - if ( bOk) - LuaSetReturn( L, sName) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetMachGroupId( lua_State* L) -{ - // 1 parametro : nome del gruppo - string sGroupName ; - LuaCheckParam( L, 1, sGroupName) - LuaClearStack( L) ; - // recupero l'identificativo della macchinata - int nId = EgtGetMachGroupId( sGroupName) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetCurrMachGroup( lua_State* L) -{ - // 1 parametro : identificativo del gruppo - int nMGroupInd ; - LuaCheckParam( L, 1, nMGroupInd) - LuaClearStack( L) ; - // imposto il gruppo corrente - bool bOk = ( EgtSetCurrMachGroup( nMGroupInd) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaResetCurrMachGroup( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // imposto il gruppo corrente - bool bOk = ( EgtResetCurrMachGroup() != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaGetCurrMachGroup( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // recupero l'identificativo del gruppo corrente - int nId = EgtGetCurrMachGroup() ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( 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) -{ - // 5 parametri : Pto origine, dWidth, dLen, dH, Color - Point3d ptOrig ; - LuaCheckParam( L, 1, ptOrig) - double dWidth ; - LuaCheckParam( L, 2, dWidth) - double dLength ; - LuaCheckParam( L, 3, dLength) - double dHeight ; - LuaCheckParam( L, 4, dHeight) - Color cCol ; - LuaCheckParam( L, 5, cCol) - LuaClearStack( L) ; - // inserisco il grezzo nella macchinata corrente - int nInd = EgtAddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ; - // restituisco il risultato - if ( nInd != GDB_ID_NULL) - LuaSetReturn( L, nInd) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaAddRawPartWithPart( lua_State* L) -{ - // 4 parametri : nPartId, nCrvId, dOverMat, Color - int nPartId ; - LuaCheckParam( L, 1, nPartId) - int nCrvId = GDB_ID_NULL ; - LuaGetParam( L, 2, nCrvId) ; - double dOverMat ; - LuaCheckParam( L, 3, dOverMat) - Color cCol ; - LuaCheckParam( L, 4, cCol) - LuaClearStack( L) ; - // inserisco il grezzo nella macchinata corrente - int nInd = EgtAddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ; - // restituisco il risultato - if ( nInd != GDB_ID_NULL) - LuaSetReturn( L, nInd) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaModifyRawPartHeight( lua_State* L) -{ - // 2 parametri : nRawId, dHeight - int nRawId ; - LuaCheckParam( L, 1, nRawId) - double dHeight ; - LuaCheckParam( L, 2, dHeight) - LuaClearStack( L) ; - // modifico lo spessore del grezzo - bool bOk = EgtModifyRawPartHeight( nRawId, dHeight) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRemoveRawPart( lua_State* L) -{ - // 1 parametro : nRawId - int nRawId ; - LuaCheckParam( L, 1, nRawId) - LuaClearStack( L) ; - // elimino il grezzo dalla macchinata corrente - bool bOk = EgtRemoveRawPart( nRawId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaTranslateRawPart( lua_State* L) -{ - // 2 parametri : nRawId, vtMove - int nRawId ; - LuaCheckParam( L, 1, nRawId) - Vector3d vtMove ; - LuaCheckParam( L, 2, vtMove) - LuaClearStack( L) ; - // traslo il grezzo - bool bOk = EgtTranslateRawPart( nRawId, vtMove) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRotateRawPart( lua_State* L) -{ - // 3 parametri : nRawId, vtAx, dAngRotDeg - int nRawId ; - LuaCheckParam( L, 1, nRawId) - Vector3d vtAx ; - LuaCheckParam( L, 2, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 3, dAngRotDeg) - LuaClearStack( L) ; - // ruoto il grezzo - bool bOk = EgtRotateRawPart( nRawId, vtAx, dAngRotDeg) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMoveToCornerRawPart( lua_State* L) -{ - // 3 parametri : nRawId, ptCorner, nFlag - int nRawId ; - LuaCheckParam( L, 1, nRawId) - Point3d ptCorner ; - LuaCheckParam( L, 2, ptCorner) - int nFlag ; - LuaCheckParam( L, 3, nFlag) - LuaClearStack( L) ; - // sposto il grezzo nel corner - bool bOk = EgtMoveToCornerRawPart( nRawId, ptCorner, nFlag) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaMoveToCenterRawPart( lua_State* L) -{ - // 3 parametri : nRawId, ptCenter, nFlag - int nRawId ; - LuaCheckParam( L, 1, nRawId) - Point3d ptCenter ; - LuaCheckParam( L, 2, ptCenter) - int nFlag ; - LuaCheckParam( L, 3, nFlag) - LuaClearStack( L) ; - // sposto il grezzo nel corner - 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 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRemovePartFromRawPart( lua_State* L) -{ - // 1 parametro : nPartId - int nPartId ; - LuaCheckParam( L, 1, nPartId) - LuaClearStack( L) ; - // elimino il grezzo dalla macchinata corrente - bool bOk = EgtRemovePartFromRawPart( nPartId) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaTranslatePartInRawPart( lua_State* L) -{ - // 2 parametri : nPartId, vtMove - int nPartId ; - LuaCheckParam( L, 1, nPartId) - Vector3d vtMove ; - LuaCheckParam( L, 2, vtMove) - LuaClearStack( L) ; - // traslo il pezzo nel grezzo - bool bOk = EgtTranslatePartInRawPart( nPartId, vtMove) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaRotatePartInRawPart( lua_State* L) -{ - // 3 parametri : nPartId, vtAx, dAngRotDeg - int nPartId ; - LuaCheckParam( L, 1, nPartId) - Vector3d vtAx ; - LuaCheckParam( L, 2, vtAx) - double dAngRotDeg ; - LuaCheckParam( L, 3, dAngRotDeg) - LuaClearStack( L) ; - // ruoto il pezzo nel grezzo - bool bOk = EgtRotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallMachMgr( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupNbr", LuaGetMachGroupNbr) ; - bOk = bOk && LuaRegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ; - bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ; - bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupId", LuaGetMachGroupId) ; - 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( "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) ; - - return bOk ; -} diff --git a/LUA_Scene.cpp b/LUA_Scene.cpp deleted file mode 100644 index 562ae31..0000000 --- a/LUA_Scene.cpp +++ /dev/null @@ -1,193 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2014-2014 -//---------------------------------------------------------------------------- -// File : LUA_Scene.cpp Data : 29.09.14 Versione : 1.5i5 -// Contenuto : Funzioni di visualizzazione per LUA. -// -// -// -// Modifiche : 29.09.14 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "API.h" -#include "LUA.h" -#include "LUA_Base.h" -#include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EGkLuaAux.h" -#include "/EgtDev/Include/EGnStringUtils.h" - -using namespace std ; - -//------------------------------------------------------------------------------- -static int -LuaSetBackground( lua_State* L) -{ - // 2 o 3 parametri : colore top, colore bottom [, flag ridisegna] - Color colTop ; - LuaCheckParam( L, 1, colTop) - Color colBot ; - LuaCheckParam( L, 2, colBot) - bool bRedraw ; - LuaGetParam( L, 3, bRedraw) ; - LuaClearStack( L) ; - // imposto lo sfondo - bool bOk = ( EgtSetBackground( colTop, colBot, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaDraw( lua_State* L) -{ - // nessun parametro - LuaClearStack( L) ; - // eseguo ridisegno - bool bOk = ( EgtDraw() != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetShowMode( lua_State* L) -{ - // 1 o 2 parametri : nShowMode [, flag ridisegna] - int nShowMode ; - LuaCheckParam( L, 1, nShowMode) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) ; - LuaClearStack( L) ; - // imposto il modo di visualizzazione - bool bOk = ( EgtSetShowMode( nShowMode, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetShowCurveDirection( lua_State* L) -{ - // 1 o 2 parametri : bool bShowCrvDir [, flag ridisegna] - bool bShowCrvDir ; - LuaCheckParam( L, 1, bShowCrvDir) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) ; - LuaClearStack( L) ; - // imposto visualizzazione direzione curve - bool bOk = ( EgtSetShowCurveDirection( bShowCrvDir, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetShowTriaAdv( lua_State* L) -{ - // 1 o 2 parametri : flag bAdvanced [, flag ridisegna] - bool bAdvanced ; - LuaCheckParam( L, 1, bAdvanced) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) , - LuaClearStack( L) ; - // imposto visualizzazione direzione curve - bool bOk = ( EgtSetShowTriaAdv( bAdvanced, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaZoom( lua_State* L) -{ - // 1 o 2 parametri : nZoomType [, flag ridisegna] - int nZoomType ; - LuaCheckParam( L, 1, nZoomType) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) ; - LuaClearStack( L) ; - // imposto zoom - bool bOk = ( EgtZoom( nZoomType, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetView( lua_State* L) -{ - // 1 o 2 parametri : nViewDir [, flag ridisegna] - int nViewDir ; - LuaCheckParam( L, 1, nViewDir) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) ; - LuaClearStack( L) ; - // imposto direzione di vista - bool bOk = ( EgtSetView( nViewDir, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetGenericView( lua_State* L) -{ - // 2 o 3 parametri : dAngVertDeg, dAngHorizDeg [, flag ridisegna] - double dAngVertDeg ; - LuaCheckParam( L, 1, dAngVertDeg) - double dAngHorizDeg ; - LuaCheckParam( L, 2, dAngHorizDeg) - bool bRedraw = true ; - LuaGetParam( L, 3, bRedraw) ; - LuaClearStack( L) ; - // imposto direzione di vista - bool bOk = ( EgtSetGenericView( dAngVertDeg, dAngHorizDeg, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSetViewCenter( lua_State* L) -{ - // 1 o 2 parametri : ptCen [, flag ridisegna] - Point3d ptCen ; - LuaCheckParam( L, 1, ptCen) - bool bRedraw = true ; - LuaGetParam( L, 2, bRedraw) ; - LuaClearStack( L) ; - // imposto centro di vista - bool bOk = ( EgtSetViewCenter( ptCen.v, bRedraw) != FALSE) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -bool -LuaInstallScene( void) -{ - bool bOk = true ; - bOk = bOk && LuaRegisterFunction( "EgtSetBackground", LuaSetBackground) ; - bOk = bOk && LuaRegisterFunction( "EgtDraw", LuaDraw) ; - bOk = bOk && LuaRegisterFunction( "EgtSetShowMode", LuaSetShowMode) ; - bOk = bOk && LuaRegisterFunction( "EgtSetShowCurveDirection", LuaSetShowCurveDirection) ; - bOk = bOk && LuaRegisterFunction( "EgtSetShowTriaAdv", LuaSetShowTriaAdv) ; - bOk = bOk && LuaRegisterFunction( "EgtZoom", LuaZoom) ; - bOk = bOk && LuaRegisterFunction( "EgtSetView", LuaSetView) ; - bOk = bOk && LuaRegisterFunction( "EgtSetGenericView", LuaSetGenericView) ; - bOk = bOk && LuaRegisterFunction( "EgtSetViewCenter", LuaSetViewCenter) ; - return bOk ; -} diff --git a/stdafx.h b/stdafx.h index d41bf0c..a8d1005 100644 --- a/stdafx.h +++ b/stdafx.h @@ -31,4 +31,5 @@ #pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtExecutor" EGTLIBVER ".lib") #pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua52" EGTLIBVER ".lib")