diff --git a/AuxTools.cpp b/AuxTools.cpp index 34dd9ed..a9b4f5e 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -68,6 +68,19 @@ IdListToString( const INTVECTOR& vIds) return sIds ; } +//---------------------------------------------------------------------------- +const string +SelListToString( const SELVECTOR& vIds) +{ + string sIds ; + sIds.reserve( 12 * vIds.size()) ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += "{" + ToString( vIds[i]) + "}," ; + if ( ! sIds.empty()) + sIds.pop_back() ; + return sIds ; +} + //---------------------------------------------------------------------------- const char* NgeTypeToString( int nNgeType) diff --git a/AuxTools.h b/AuxTools.h index 6e7034b..5e3d27d 100644 --- a/AuxTools.h +++ b/AuxTools.h @@ -23,6 +23,8 @@ std::string StringToLuaString( const std::string& sText) ; const std::string IdToString( int nId) ; // Lista di Id completa (parametro per lua) const std::string IdListToString( const INTVECTOR& vIds) ; +// Lista di SelData completa ( parametro per lua) +const std::string SelListToString( const SELVECTOR& vIds) ; // Tipo del file Nge const char* NgeTypeToString( int nNgeType) ; // Tipo punto per creazione rette e archi diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 17a2291..89ff347 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -735,6 +735,111 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType) return nNewId ; } +//---------------------------------------------------------------------------- +int +ExeSplitCurveAtParam( int nId, double dParam) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la curva + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pCurve != nullptr) ; + // verifico che il punto di taglio sia interno alla curva + bool bIsInside = false ; + if ( bOk) { + // determino lunghezza totale della curva + double dLen ; + bOk = bOk && pCurve->GetLength( dLen) ; + // determino lunghezza al parametro di taglio + double dCutLen ; + bOk = bOk && pCurve->GetLengthAtParam( dParam, dCutLen) ; + // interno se la lunghezza al parametro e la lunghezza rimanente sono entrambe significative + if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL) + bIsInside = true ; + } + // 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( dParam) ; + bOk = bOk && pCopyCrv->TrimStartAtParam( dParam) ; + } + nNewId = ( bOk ? nNewId : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSplitCurveAtParam(" + ToString( nId) + "," + + ToString( dParam) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return nNewId ; +} + +//---------------------------------------------------------------------------- +int +ExeSplitCurveAtCorners( int nId, double dTgAngToler, int* pnCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // !!! deve essere fatta anche sulle curve di Bezier !!! + // recupero la curva composita + ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pCompo != nullptr) ; + // calcolo i punti di perdita di tangenza + DBLVECTOR vU ; + double dMinCos = cos( dTgAngToler * DEGTORAD) ; + for ( int i = 1 ; i < pCompo->GetCurveCount() ; ++ i) { + Point3d ptPrev, ptNext ; + Vector3d vtPrev, vtNext ; + if ( pCompo->GetPointTang( i, ICurve::FROM_MINUS, ptPrev, vtPrev) && + pCompo->GetPointTang( i, ICurve::FROM_PLUS, ptNext, vtNext) && + vtPrev * vtNext < dMinCos) + vU.push_back( i) ; + } + // recupero un intervallo di id contigui per tutte le parti + int nFirstId = pGeomDB->GetNewId() ; + bOk = bOk && pGeomDB->ChangeId( nId, nFirstId) ; + int nCurrId = nFirstId ; + // eseguo la divisione + int nCount = 1 ; + double dUPrev = 0 ; + for ( int i = 0 ; i < int( vU.size()) ; ++ i) { + // copio la curva + int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ; + ICurveComposite* pCopyCrv = GetCurveComposite( pGeomDB->GetGeoObj( nCopyId)) ; + bOk = bOk && ( pCopyCrv != nullptr) ; + ++ nCount ; + // trimmo l'originale + bOk = bOk && pCompo->TrimStartEndAtParam( dUPrev, vU[i]) ; + // la copia diventa il nuovo corrente + nCurrId = nCopyId ; + pCompo = pCopyCrv ; + dUPrev = vU[i] ; + } + // se fatta almeno una suddivisione, trimmo l'ultima parte + if ( dUPrev > EPS_PARAM) + bOk = bOk && pCompo->TrimStartAtParam( dUPrev) ; + nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSplitCurveAtCorners(" + ToString( nId) + "," + + ToString( dTgAngToler) + ")" + + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; +} + //---------------------------------------------------------------------------- int ExeSplitCurveAtSelfInters( int nId, int* pnCount) @@ -745,19 +850,21 @@ ExeSplitCurveAtSelfInters( int nId, int* pnCount) ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCurve != nullptr) ; // calcolo le auto-intersezioni - SelfIntersCurve sintC( *pCurve) ; DBLVECTOR vU ; - IntCrvCrvInfo iccInfo ; - for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) { - if ( ! iccInfo.bOverlap) { - vU.push_back( iccInfo.IciA[0].dU) ; - vU.push_back( iccInfo.IciB[0].dU) ; - } - else { - vU.push_back( iccInfo.IciA[0].dU) ; - vU.push_back( iccInfo.IciA[1].dU) ; - vU.push_back( iccInfo.IciB[0].dU) ; - vU.push_back( iccInfo.IciB[1].dU) ; + if ( bOk) { + SelfIntersCurve sintC( *pCurve) ; + IntCrvCrvInfo iccInfo ; + for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) { + if ( ! iccInfo.bOverlap) { + vU.push_back( iccInfo.IciA[0].dU) ; + vU.push_back( iccInfo.IciB[0].dU) ; + } + else { + vU.push_back( iccInfo.IciA[0].dU) ; + vU.push_back( iccInfo.IciA[1].dU) ; + vU.push_back( iccInfo.IciB[0].dU) ; + vU.push_back( iccInfo.IciB[1].dU) ; + } } } // ordino il vettore in senso crescente diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index ca62ac4..b21ad77 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -1216,6 +1216,27 @@ ExeGetOperationPhase( int nId) return pGseCtx->m_pMachMgr->GetOperationPhase( nId) ; } +//----------------------------------------------------------------------------- +bool +ExeGetOperationName( int nId, string& sName) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero la fase di appartenenza della operazione della macchinata corrente + sName = pGseCtx->m_pMachMgr->GetOperationName( nId) ; + return ( ! sName.empty()) ; +} + +//----------------------------------------------------------------------------- +int +ExeGetOperationId( const string& sName) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // recupero l'identificativo dell'operazione con il nome indicato della macchinata corrente + return pGseCtx->m_pMachMgr->GetOperationId( sName) ; +} + //----------------------------------------------------------------------------- bool ExeRemoveOperation( int nId) @@ -1330,12 +1351,41 @@ ExeGetPhaseDisposition( int nPhase) // Lavorazioni //----------------------------------------------------------------------------- int -ExeAddMachining( const string& sName, const std::string& sMachining) +ExeAddMachining( const string& sName, const string& sMachining) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // aggiunge una lavorazione, prendendo i dati dalla libreria - return pGseCtx->m_pMachMgr->AddMachining( sName, sMachining) ; + int nId = pGseCtx->m_pMachMgr->AddMachining( sName, sMachining) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddMachining(" + sName + "," + + sMachining + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return nId ; +} + +//----------------------------------------------------------------------------- +int +ExeAddMachining( const string& sName, int nMchType, const string& sTool) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // aggiunge una lavorazione dati tipo e nome utensile + int nId = pGseCtx->m_pMachMgr->AddMachining( sName, nMchType, sTool) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCreateMachining(" + sName + "," + + ToString( nMchType) + "," + + sTool + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return nId ; } //----------------------------------------------------------------------------- @@ -1345,7 +1395,14 @@ ExeSetCurrMachining( int nId) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto la lavorazione di identificativo Id come corrente - return pGseCtx->m_pMachMgr->SetCurrMachining( nId) ; + bool bOk = pGseCtx->m_pMachMgr->SetCurrMachining( nId) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetCurrMachining(" + ToString( nId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1355,7 +1412,14 @@ ExeResetCurrMachining( void) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // reset della lavorazione corrente - return pGseCtx->m_pMachMgr->ResetCurrMachining() ; + bool bOk = pGseCtx->m_pMachMgr->ResetCurrMachining() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtResetCurrMachining()" + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1375,7 +1439,16 @@ ExeSetMachiningParam( int nType, bool bVal) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto un parametro alla lavorazione corrente - return pGseCtx->m_pMachMgr->SetMachiningParam( nType, bVal) ; + bool bOk = pGseCtx->m_pMachMgr->SetMachiningParam( nType, bVal) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + + ( bVal ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1385,7 +1458,16 @@ ExeSetMachiningParam( int nType, int nVal) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto un parametro alla lavorazione corrente - return pGseCtx->m_pMachMgr->SetMachiningParam( nType, nVal) ; + bool bOk = pGseCtx->m_pMachMgr->SetMachiningParam( nType, nVal) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + + ToString( nVal) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1395,7 +1477,16 @@ ExeSetMachiningParam( int nType, double dVal) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto un parametro alla lavorazione corrente - return pGseCtx->m_pMachMgr->SetMachiningParam( nType, dVal) ; + bool bOk = pGseCtx->m_pMachMgr->SetMachiningParam( nType, dVal) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + + ToString( dVal) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1405,7 +1496,16 @@ ExeSetMachiningParam( int nType, const string& sVal) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto un parametro alla lavorazione corrente - return pGseCtx->m_pMachMgr->SetMachiningParam( nType, sVal) ; + bool bOk = pGseCtx->m_pMachMgr->SetMachiningParam( nType, sVal) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + + sVal + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1415,7 +1515,16 @@ ExeSetMachiningGeometry( const SELVECTOR& vIds) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto la geometria alla lavorazione corrente - return pGseCtx->m_pMachMgr->SetMachiningGeometry( vIds) ; + ExeSetModified() ; + bool bOk = pGseCtx->m_pMachMgr->SetMachiningGeometry( vIds) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetMachiningGeometry({" + SelListToString( vIds) + "})" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1425,7 +1534,15 @@ ExePreviewMachining( bool bRecalc) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto la geometria alla lavorazione corrente - return pGseCtx->m_pMachMgr->MachiningPreview( bRecalc) ; + bool bOk = pGseCtx->m_pMachMgr->MachiningPreview( bRecalc) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtPreviewMachining(" + ToString( bRecalc) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- @@ -1435,7 +1552,15 @@ ExeApplyMachining( bool bRecalc) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_MACHMGR( pGseCtx, false) // imposto la geometria alla lavorazione corrente - return pGseCtx->m_pMachMgr->MachiningApply( bRecalc) ; + bool bOk = pGseCtx->m_pMachMgr->MachiningApply( bRecalc) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtApplyMachining(" + ToString( bRecalc) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; } //----------------------------------------------------------------------------- diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 346510f..1121072 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -464,7 +464,7 @@ VerifyAndAdjustFlatParts( void) bOk = bOk && nNewId != GDB_ID_NULL ; // assegno il colore Color cCol = AQUA ; - cCol.SetAlpha( 0.3) ; + cCol.SetAlpha( 0.2) ; bOk = bOk && pGeomDB->SetMaterial( nNewId, cCol) ; // scrittura delle dimensioni nel layer della regione if ( bOk) { @@ -651,6 +651,18 @@ ExeAdjustFlatPartLayer( int nLayerId) bOk = bOk && ExeCreateCurveCompoByReorder( nLayerId, vAccwIds, ORIG, true, RTY_GLOB, nullptr) != GDB_ID_NULL ; if ( vAcwIds.size() > 1) bOk = bOk && ExeCreateCurveCompoByReorder( nLayerId, vAcwIds, ORIG, true, RTY_GLOB, nullptr) != GDB_ID_NULL ; + // spezzo le curve composite con discontinuità + nId = pGeomDB->GetFirstInGroup( nLayerId) ; + while ( nId != GDB_ID_NULL && bOk) { + // Recupero successiva + int nNextId = pGeomDB->GetNext( nId) ; + // Se curva composita + if ( pGeomDB->GetGeoType( nId) == CRV_COMPO) { + bOk = ( ExeSplitCurveAtCorners( nId, 5.0, nullptr) != GDB_ID_NULL) ; + } + // Passo all'entità successiva + nId = nNextId ; + } // se rimasta una sola curva composita la spezzo in due parti if ( pGeomDB->GetGroupObjs( nLayerId) == 1) { int nId = pGeomDB->GetFirstInGroup( nLayerId) ; @@ -659,16 +671,8 @@ ExeAdjustFlatPartLayer( int nLayerId) int nTotCurve = pCompo->GetCurveCount() ; // se contiene più curve semplici, la spezzo ad una giunzione if ( nTotCurve >= 2) { - // copio la curva - int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ; - ICurveComposite* pCompo2 = GetCurveComposite( pGeomDB->GetGeoObj( nCopyId)) ; - if ( pCompo2 != nullptr) { - int nHalfCurve = nTotCurve / 2 ; - // elimino dall'originale la seconda metà delle curve - pCompo->TrimEndAtParam( nHalfCurve) ; - // elimino dalla copia la prima metà delle curve - pCompo2->TrimStartAtParam( nHalfCurve) ; - } + int nHalfCurve = nTotCurve / 2 ; + ExeSplitCurveAtParam( nId, nHalfCurve) ; } // altrimenti la spezzo esattamente a metà else @@ -933,7 +937,7 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH) return false ; // assegno il colore Color cCol = AQUA ; - cCol.SetAlpha( 0.3) ; + cCol.SetAlpha( 0.2) ; pGeomDB->SetMaterial( nSfrId, cCol) ; return true ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5ff4c48..f394e2e 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 9bd909a..707c86b 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -375,6 +375,46 @@ LuaSplitCurveAtPoint( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSplitCurveAtParam( lua_State* L) +{ + // 2 parametri : Id, dParam + int nId ; + LuaCheckParam( L, 1, nId) + double dParam ; + LuaCheckParam( L, 2, dParam) + LuaClearStack( L) ; + // divido la curva nel punto + int nFirstId = ExeSplitCurveAtParam( nId, dParam) ; + if ( nFirstId != GDB_ID_NULL) + LuaSetParam( L, nFirstId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSplitCurveAtCorners( lua_State* L) +{ + // 2 parametri : Id, dTgAngToler + int nId ; + LuaCheckParam( L, 1, nId) + double dTgAngToler ; + LuaCheckParam( L, 2, dTgAngToler) + LuaClearStack( L) ; + // divido la curva nei punti angolosi + int nCount ; + int nNewId = ExeSplitCurveAtCorners( nId, dTgAngToler, &nCount) ; + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nCount) ; + return 2 ; +} + //---------------------------------------------------------------------------- static int LuaSplitCurveAtSelfInters( lua_State* L) @@ -619,6 +659,8 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtTrimCurveWithRegion", LuaTrimCurveWithRegion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurve", LuaSplitCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtParam", LuaSplitCurveAtParam) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtCorners", LuaSplitCurveAtCorners) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtSelfInters", LuaSplitCurveAtSelfInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtModifyArcRadius", LuaModifyArcRadius) ; bOk = bOk && luaMgr.RegisterFunction( "EgtModifyArcToExplementary", LuaModifyArcToExplementary) ; diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 7a2996f..7590eca 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -1534,6 +1534,28 @@ LuaAddMachining( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateMachining( lua_State* L) +{ + // 3 parametri : sName, nMchType, sTool + string sName ; + LuaCheckParam( L, 1, sName) + int nMchType ; + LuaCheckParam( L, 2, nMchType) + string sTool ; + LuaCheckParam( L, 3, sTool) + LuaClearStack( L) ; + // aggiungo la lavorazione (creandola al momento) + int nId = ExeAddMachining( sName, nMchType, sTool) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetCurrMachining( lua_State* L) @@ -1549,6 +1571,19 @@ LuaSetCurrMachining( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaResetCurrMachining( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // imposto la lavorazione come corrente + bool bOk = ExeResetCurrMachining() ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetMachiningParam( lua_State* L) @@ -2261,7 +2296,9 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetPhaseDisposition", LuaGetPhaseDisposition) ; // Machinings bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachining", LuaAddMachining) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCreateMachining", LuaCreateMachining) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachining", LuaSetCurrMachining) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtResetCurrMachining", LuaResetCurrMachining) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningParam", LuaSetMachiningParam) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningGeometry", LuaSetMachiningGeometry) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPreviewMachining", LuaPreviewMachining) ;