diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 41ca0f9..5616da9 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -53,7 +53,7 @@ ExeGetFileType( const string& sFilePath) return FT_DXF ; else if ( sFileExt == "STL") return FT_STL ; - else if ( sFileExt == "CNC") + else if ( sFileExt == "CNC" || sFileExt == "XPI") return FT_CNC ; else if ( sFileExt == "HED" || sFileExt == "ENT" || sFileExt == "ENS") return FT_CSF ; diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index d84cda1..e07fe1a 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -420,6 +420,63 @@ ExeExtractSurfTmLoops( int nId, int nDestGrpId, int* pnCount) return nFirstId ; } +//---------------------------------------------------------------------------- +int +ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, int nDestGrpId, int nRefType, 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) ; + // porto in locale alla superficie il versore di riferimento + Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frSurf) ; + // recupero i loop come polilinee + POLYLINEVECTOR vPL ; + bOk = bOk && pStm->GetSilhouette( vtDirL, 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) ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( bOk && nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + if ( bOk) + ++ nCount ; + } + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtGetSurfTmSilhouette(" + ToString( nId) + ",{" + + ToString( vtDir) + "}," + + ToString( nDestGrpId) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; +} + //---------------------------------------------------------------------------- int ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 73de9a4..03f0af9 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -305,6 +305,19 @@ ExeAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) return nId ; } +//----------------------------------------------------------------------------- +bool +ExeModifyRawPart( int nRawId, Point3d ptOrig, double dLength, double dWidth, double dHeight, Color cCol) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) + // modifico grezzo indicato nella macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->ModifyRawPart( nRawId, ptOrig, dLength, dWidth, dHeight, cCol) ; + ExeSetModified() ; + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) @@ -986,6 +999,26 @@ ExeMdbGetCurrMachiningParam( int nType, string& sVal) return pGseCtx->m_pMachMgr->MdbGetCurrMachiningParam( nType, sVal) ; } +//----------------------------------------------------------------------------- +bool +ExeMdbSetSafeZ( double dSafeZ) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // imposta la distanza di sicurezza + return pGseCtx->m_pMachMgr->MdbSetSafeZ( dSafeZ) ; +} + +//----------------------------------------------------------------------------- +bool +ExeMdbGetSafeZ( double& dSafeZ) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupera la distanza di sicurezza + return pGseCtx->m_pMachMgr->MdbGetSafeZ( dSafeZ) ; +} + //----------------------------------------------------------------------------- bool ExeMdbSave( void) @@ -1038,6 +1071,16 @@ ExeGetOperationType( int nId) return pGseCtx->m_pMachMgr->GetOperationType( nId) ; } +//----------------------------------------------------------------------------- +bool +ExeRemoveOperation( int nId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // elimino l'operazione indicata della macchinata corrente + return pGseCtx->m_pMachMgr->RemoveOperation( nId) ; +} + //----------------------------------------------------------------------------- bool ExeRemoveAllOperations( void) @@ -1212,6 +1255,26 @@ ExeSimGetAxisInfoPos( int nI, std::string& sName, double& dVal) return pGseCtx->m_pMachMgr->SimGetAxisInfoPos( nI, sName, dVal) ; } +//----------------------------------------------------------------------------- +bool +ExeSimGetToolInfo( string& sName, double& dSpeed) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero dati dell'utensile + return pGseCtx->m_pMachMgr->SimGetToolInfo( sName, dSpeed) ; +} + +//----------------------------------------------------------------------------- +bool +ExeSimGetMoveInfo( int& nGmove, double& dFeed) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero dati sul movimento corrente + return pGseCtx->m_pMachMgr->SimGetMoveInfo( nGmove, dFeed) ; +} + //----------------------------------------------------------------------------- bool ExeSimSetStep( double dStep) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f97e00c..0a7c70a 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index 16ed63a..4bbc3b2 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -135,8 +135,8 @@ LuaExtractSurfFrChunkLoops( lua_State* L) int nDestGrpId ; LuaCheckParam( L, 3, nDestGrpId) LuaClearStack( L) ; - // eseguo inversione superfici - int nCount ; + // recupero i contorni del chunk della regione + int nCount = 0 ; int nNewId = ExeExtractSurfFrChunkLoops( nId, nChunk, nDestGrpId, &nCount) ; // restituisco il risultato if ( nNewId != GDB_ID_NULL) @@ -151,14 +151,14 @@ LuaExtractSurfFrChunkLoops( lua_State* L) static int LuaExtractSurfTmLoops( lua_State* L) { - // 2 parametri : nId2, nDestGrpId + // 2 parametri : nId, nDestGrpId int nId ; LuaCheckParam( L, 1, nId) int nDestGrpId ; LuaCheckParam( L, 2, nDestGrpId) LuaClearStack( L) ; // recupero i contorni della superficie - int nCount ; + int nCount = 0 ; int nNewId = ExeExtractSurfTmLoops( nId, nDestGrpId, &nCount) ; // restituisco il risultato if ( nNewId != GDB_ID_NULL) @@ -169,6 +169,32 @@ LuaExtractSurfTmLoops( lua_State* L) return 2 ; } +//---------------------------------------------------------------------------- +static int +LuaGetSurfTmSilhouette( lua_State* L) +{ + // 3 o 4 parametri : nId, vtDir, nDestGrpId [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Vector3d vtDir ; + LuaCheckParam( L, 2, vtDir) + int nDestGrpId ; + LuaCheckParam( L, 3, nDestGrpId) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 4, nRefType) ; + LuaClearStack( L) ; + // recupero i contorni della superficie + int nCount = 0 ; + int nNewId = ExeGetSurfTmSilhouette( nId, vtDir, nDestGrpId, nRefType, &nCount) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nCount) ; + return 2 ; +} + //---------------------------------------------------------------------------- static int LuaExtractSurfTmFacetLoops( lua_State* L) @@ -206,6 +232,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfFrChunkLoops", LuaExtractSurfFrChunkLoops) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmLoops", LuaExtractSurfTmLoops) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouette", LuaGetSurfTmSilhouette) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ; return bOk ; } diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 8f1b616..c196754 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -1008,6 +1008,30 @@ LuaMdbSetCurrMachining( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaMdbSaveCurrMachining( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // salvo la lavorazione corrente + bool bOk = ExeMdbSaveCurrMachining() ; + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaMdbIsCurrMachiningModified( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // verifico se la lavorazione corrente č stata modificata + bool bOk = ExeMdbIsCurrMachiningModified() ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaMdbSetCurrMachiningParam( lua_State* L) @@ -1097,25 +1121,31 @@ LuaMdbGetCurrMachiningParam( lua_State* L) //------------------------------------------------------------------------------- static int -LuaMdbSaveCurrMachining( lua_State* L) +LuaMdbSetSafeZ( lua_State* L) { - // nessun parametro + // 1 parametro : dSafeZ + double dSafeZ ; + LuaCheckParam( L, 1, dSafeZ) LuaClearStack( L) ; - // salvo la lavorazione corrente - bool bOk = ExeMdbSaveCurrMachining() ; + // lancio salvataggio + bool bOk = ExeMdbSetSafeZ( dSafeZ) ; LuaSetParam( L, bOk) ; return 1 ; } //------------------------------------------------------------------------------- static int -LuaMdbIsCurrMachiningModified( lua_State* L) +LuaMdbGetSafeZ( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // verifico se la lavorazione corrente č stata modificata - bool bOk = ExeMdbIsCurrMachiningModified() ; - LuaSetParam( L, bOk) ; + // lancio salvataggio + double dSafeZ ; + bool bOk = ExeMdbGetSafeZ( dSafeZ) ; + if ( bOk) + LuaSetParam( L, dSafeZ) ; + else + LuaSetParam( L) ; return 1 ; } @@ -1182,6 +1212,21 @@ LuaGetOperationType( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaRemoveOperation( lua_State* L) +{ + // 1 parametro : nId + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // elimino l'operazione indicata della macchinata corrente + bool bOk = ExeRemoveOperation( nId) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaRemoveAllOperations( lua_State* L) @@ -1401,6 +1446,50 @@ LuaSimGetAxisInfoPos( lua_State* L) return 2 ; } +//------------------------------------------------------------------------------- +static int +LuaSimGetToolInfo( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero nome e speed dell'utensile corrente + string sName ; + double dSpeed ; + bool bOk = ExeSimGetToolInfo( sName, dSpeed) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, sName) ; + LuaSetParam( L, dSpeed) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSimGetMoveInfo( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero tipo e veolcitā del movimento corrente + int nGmove ; + double dFeed ; + bool bOk = ExeSimGetMoveInfo( nGmove, dFeed) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, nGmove) ; + LuaSetParam( L, dFeed) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + //------------------------------------------------------------------------------- static int LuaSimHome( lua_State* L) @@ -1808,11 +1897,14 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtMdbIsCurrMachiningModified", LuaMdbIsCurrMachiningModified) ; bOk = bOk && luaMgr.RegisterFunction( "EgtMdbSetCurrMachiningParam", LuaMdbSetCurrMachiningParam) ; bOk = bOk && luaMgr.RegisterFunction( "EgtMdbGetCurrMachiningParam", LuaMdbGetCurrMachiningParam) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtMdbSetSafeZ", LuaMdbSetSafeZ) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtMdbGetSafeZ", LuaMdbGetSafeZ) ; bOk = bOk && luaMgr.RegisterFunction( "EgtMdbSave", LuaMdbSave) ; // Operations bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstOperation", LuaGetFirstOperation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextOperation", LuaGetNextOperation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetOperationType", LuaGetOperationType) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveOperation", LuaRemoveOperation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveAllOperations", LuaRemoveAllOperations) ; // Machinings bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachining", LuaAddMachining) ; @@ -1826,6 +1918,8 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSimMove", LuaSimMove) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSimHome", LuaSimHome) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSimGetAxisInfoPos", LuaSimGetAxisInfoPos) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSimGetToolInfo", LuaSimGetToolInfo) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSimGetMoveInfo", LuaSimGetMoveInfo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSimSetStep", LuaSimSetStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSimStop", LuaSimStop) ; // Generation