diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp new file mode 100644 index 0000000..df1837f --- /dev/null +++ b/EXE_GdbCreateVol.cpp @@ -0,0 +1,68 @@ +//---------------------------------------------------------------------------- +// EgalTech 2016-2016 +//---------------------------------------------------------------------------- +// File : EXE_GdbCreateVol.cpp Data : 27.10.16 Versione : 1.6v7 +// Contenuto : Funzioni di creazione solidi del DB geometrico per EXE. +// +// +// +// Modifiche : 27.10.16 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "AuxTools.h" +#include "GeoTools.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGkVolZmap.h" +#include "/EgtDev/Include/EgkStringUtils3d.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +int +ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDimY, double dDimZ, + double dPrec, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // 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 ptOnXL = GetPointLocal( pGeomDB, ptIni + X_AX, nRefType, frLoc) ; + Point3d ptOnYL = GetPointLocal( pGeomDB, ptIni + Y_AX, nRefType, frLoc) ; + // ne ricavo un riferimento intrinseco + Frame3d frBox ; + bOk = bOk && frBox.Set( ptIniL, ptOnXL, ptOnYL) ; + // creo lo Zmap nel suo riferimento intrinseco + PtrOwner pVZM( CreateVolZmap()) ; + bOk = bOk && ! IsNull( pVZM) ; + bOk = bOk && pVZM->CreateMap( ORIG, dDimX, dDimY, dDimZ, dPrec) ; + // lo porto nel riferimento locale + bOk = bOk && pVZM->ToGlob( frBox) ; + // inserisco lo Zmap nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapBox(" + IdToString( nParentId) + ",{" + + ToString( ptIni) + "}," + + ToString( dDimX) + "," + + ToString( dDimY) + "," + + ToString( dDimZ) + "," + + ToString( dPrec) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} \ No newline at end of file diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp new file mode 100644 index 0000000..dec75c5 --- /dev/null +++ b/EXE_GdbModifyVol.cpp @@ -0,0 +1,83 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2016 +//---------------------------------------------------------------------------- +// File : EXE_ModifyVol.cpp Data : 27.10.16 Versione : 1.6v7 +// Contenuto : Funzioni di modifica dei solidi per EXE. +// +// +// +// Modifiche : 27.10.16 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "AuxTools.h" +#include "GeoTools.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkVolZmap.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +bool +ExeVolZmapSetStdTool( int nId, const string& sToolName, double dLen, double dDiam, double dCornR) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap e assegno i dati dell'utensile + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pVZM != nullptr && pVZM->SetStdTool( sToolName, dLen, 0.5 * dDiam, dCornR)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapSetStdTool(" + IdToString( nId) + "," + + sToolName + "," + + ToString( dLen) + "," + + ToString( dDiam) + "," + + ToString( dCornR) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, + const Point3d& ptPe, const Vector3d& vtDe, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ; + // porto in locale i punti e i vettori + Point3d ptPsL = GetPointLocal( pGeomDB, ptPs, nRefType, frLoc) ; + Vector3d vtDsL = GetVectorLocal( pGeomDB, vtDs, nRefType, frLoc) ; + Point3d ptPeL = GetPointLocal( pGeomDB, ptPe, nRefType, frLoc) ; + Vector3d vtDeL = GetVectorLocal( pGeomDB, vtDe, nRefType, frLoc) ; + // recupero lo Zmap e eseguo movimento di fresatura con l'utensile già associato + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bOk = bOk && ( pVZM != nullptr && pVZM->MillingStep( ptPsL, vtDsL, ptPeL, vtDeL)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapMillingStep(" + IdToString( nId) + ",{" + + ToString( ptPs) + "},{" + + ToString( vtDs) + "},{" + + ToString( ptPe) + "},{" + + ToString( vtDe) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} \ No newline at end of file diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 9b90cdd..3a23fe9 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 0e34a77..7ac12ff 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -230,6 +230,8 @@ copy $(TargetPath) \EgtProg\Dll64 + + @@ -267,10 +269,12 @@ copy $(TargetPath) \EgtProg\Dll64 + + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index 5540f8a..87d3002 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -278,6 +278,18 @@ File di origine\EXE + + File di origine\EXE + + + File di origine\LUA + + + File di origine\EXE + + + File di origine\LUA + diff --git a/LUA.h b/LUA.h index bb62182..6b747d3 100644 --- a/LUA.h +++ b/LUA.h @@ -36,6 +36,9 @@ bool LuaInstallGdbCreateCurve( LuaMgr& luaMgr) ; //-------------------------- GdbCreateSurf ----------------------------------- bool LuaInstallGdbCreateSurf( LuaMgr& luaMgr) ; +//-------------------------- GdbCreateVol ------------------------------------ +bool LuaInstallGdbCreateVol( LuaMgr& luaMgr) ; + //-------------------------- GdbModify --------------------------------------- bool LuaInstallGdbModify( LuaMgr& luaMgr) ; @@ -45,6 +48,9 @@ bool LuaInstallGdbModifyCurve( LuaMgr& luaMgr) ; //-------------------------- GdbModifySurf ----------------------------------- bool LuaInstallGdbModifySurf( LuaMgr& luaMgr) ; +//-------------------------- GdbModifyVol ----------------------------------- +bool LuaInstallGdbModifyVol( LuaMgr& luaMgr) ; + //-------------------------- GdbPartLayer ------------------------------------ bool LuaInstallGdbPartLayer( LuaMgr& luaMgr) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index b122cca..a7af5c3 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -54,6 +54,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreateSurf (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallGdbCreateVol( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallGdbCreateVol (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallGdbModify( LuaMgr)) { LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModify (" __FUNCTION__ ")") return false ; @@ -66,6 +70,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifySurf (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallGdbModifyVol( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyVol (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallGdbPartLayer( LuaMgr)) { LOG_ERROR( GetLogger(), "Error in LuaInstallGdbPartLayer (" __FUNCTION__ ")") return false ; diff --git a/LUA_GdbCreateVol.cpp b/LUA_GdbCreateVol.cpp new file mode 100644 index 0000000..7adcc0f --- /dev/null +++ b/LUA_GdbCreateVol.cpp @@ -0,0 +1,60 @@ +//---------------------------------------------------------------------------- +// EgalTech 2016-2016 +//---------------------------------------------------------------------------- +// File : LUA_GdbCreateVol.cpp Data : 27.10.16 Versione : 1.6vt +// Contenuto : Funzioni di creazione solidi per LUA. +// +// +// +// Modifiche : 27.10.16 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkLuaAux.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +static int +LuaCreateVolZmapBox( lua_State* L) +{ + // 5 o 6 parametri : ParentId, PtIni, dDimX, dDimY, dDimZ, dPrec [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptIni ; + LuaCheckParam( L, 2, ptIni) + double dDimX ; + LuaCheckParam( L, 3, dDimX) + double dDimY ; + LuaCheckParam( L, 4, dDimY) + double dDimZ ; + LuaCheckParam( L, 5, dDimZ) + double dPrec ; + LuaCheckParam( L, 6, dPrec) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 7, nRefType) ; + LuaClearStack( L) ; + // creo VZM parallelepipedo + int nId = ExeCreateVolZmap( nParentId, ptIni, dDimX, dDimY, dDimZ, dPrec, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallGdbCreateVol( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ; + return bOk ; +} diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp new file mode 100644 index 0000000..39da829 --- /dev/null +++ b/LUA_GdbModifyVol.cpp @@ -0,0 +1,79 @@ +//---------------------------------------------------------------------------- +// EgalTech 2016-2016 +//---------------------------------------------------------------------------- +// File : LUA_GdbModifyVol.cpp Data : 27.10.16 Versione : 1.6v7 +// Contenuto : Funzioni di modifica dei solidi per LUA. +// +// +// +// Modifiche : 27.10.16 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkLuaAux.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +static int +LuaVolZmapSetStdTool( lua_State* L) +{ + // 5 parametri : Id, sToolName, dLen, dDiam, dCornR + int nId ; + LuaCheckParam( L, 1, nId) + string sToolName ; + LuaCheckParam( L, 2, sToolName) + double dLen ; + LuaCheckParam( L, 3, dLen) + double dDiam ; + LuaCheckParam( L, 4, dDiam) + double dCornR ; + LuaCheckParam( L, 5, dCornR) + LuaClearStack( L) ; + // imposto utensile standard a Zmap indicato + bool bOk = ExeVolZmapSetStdTool( nId, sToolName, dLen, dDiam, dCornR) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaVolZmapMillingStep( lua_State* L) +{ + // 5 o 6 parametri : nId, ptPs, vtDs, ptPe, vtDe [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptPs ; + LuaCheckParam( L, 2, ptPs) + Vector3d vtDs ; + LuaCheckParam( L, 3, vtDs) + Point3d ptPe ; + LuaCheckParam( L, 4, ptPe) + Vector3d vtDe ; + LuaCheckParam( L, 5, vtDe) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 6, nRefType) ; + LuaClearStack( L) ; + // eseguo movimento di fresatura con l'utensile già associato a Zmap + bool bOk = ExeVolZmapMillingStep( nId, ptPs, vtDs, ptPe, vtDe, nRefType) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallGdbModifyVol( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; + return bOk ; +} \ No newline at end of file