diff --git a/Drilling.cpp b/Drilling.cpp index 0cf476d..d65cd58 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -2779,8 +2779,8 @@ Drilling::GenerateHoleCl( int nInd, const SelData& nCircId, const string& sPName // assegno l'elevazione massima m_pGeomDB->SetInfo( nPathId, KEY_ELEV, hole.dLen) ; // foro normale - if ( m_Params.m_dStep < EPS_SMALL || - m_Params.m_dStep > hole.dLen - EPS_SMALL) { + if ( ( m_Params.m_dStep < EPS_SMALL || m_Params.m_dStep > hole.dLen - 10 * EPS_SMALL) && + GetDoubleLastStep() > hole.dLen - 10 * EPS_SMALL) { if ( DoStandardDrilling( hole, nCircId, nPathId, dMHOff, vtA, currToolData)) { // aggiorno numero forature ++ m_nDrillings ; @@ -3572,25 +3572,20 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO if ( AddRapidMove( ptP2, bSplitArcs) == GDB_ID_NULL) return false ; } - // determino se foro in doppio - bool bDouble = false ; - { int nDouble = 0 ; - if ( GetValInNotes( m_Params.m_sUserNotes, UN_DOUBLE, nDouble) && - ( nDouble == 1 || nDouble == 2 || nDouble == 3)) - bDouble = true ; - } - + // parametri per foro in doppio + bool bDouble = ( GetDoubleType( m_Params.m_sUserNotes) != 0) ; + double dDoubleLastStep = GetDoubleLastStep() ; // ciclo di affondamento a step const double MIN_STEP = 1 ; const double APPR_STEP = 1 ; const double MIN_MOVE = 1 ; double dOrigStep = max( m_Params.m_dStep, MIN_STEP) ; - double dSteppedLen = ( bDouble ? hole.dLen - dOrigStep : hole.dLen) ; + double dSteppedLen = ( bDouble ? hole.dLen - dDoubleLastStep : hole.dLen) ; int nStep = int( ceil( dSteppedLen / dOrigStep)) ; double dStep = dSteppedLen / nStep ; if ( bDouble) ++ nStep ; - double dLastStep = ( bDouble ? dOrigStep : dStep) ; + double dLastStep = ( bDouble ? dDoubleLastStep : dStep) ; if ( dReturnPos < - dStep + APPR_STEP + MIN_MOVE) dReturnPos = - dStep + APPR_STEP + MIN_MOVE ; double dCurrLen = 0 ; @@ -3723,6 +3718,22 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId, double dMHO return true ; } +//---------------------------------------------------------------------------- +double +Drilling::GetDoubleLastStep( void) +{ + // se non è foratura in doppio, restituisco valore molto grande + const double FALSE_LASTSTEP = 10000 ; + if ( GetDoubleType( m_Params.m_sUserNotes) == 0) + return FALSE_LASTSTEP ; + // recupero valore + const double MIN_LASTSTEP = 15 ; + double dDoubleLastStep = m_Params.m_dStep ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_LASTSTEP, dDoubleLastStep)) + dDoubleLastStep = max( dDoubleLastStep, MIN_LASTSTEP) ; + return dDoubleLastStep ; +} + //---------------------------------------------------------------------------- // Debug Functions //---------------------------------------------------------------------------- diff --git a/Drilling.h b/Drilling.h index 822f5ab..9ba2ac6 100644 --- a/Drilling.h +++ b/Drilling.h @@ -128,6 +128,7 @@ class Drilling : public Machining bool MultiHeadOrderConfig( TABMHDRILL& tabDrills, const VECTORHOLE& vHoles, const Vector3d& vtTool, const Vector3d& vtAux) ; bool MultiHeadHoleToolsConfig( const VECTORHOLE& vHoles, int nConfig, INTINTVECTOR& vConfMask) ; int VerifyMultiParallelDrills( void) ; + double GetDoubleLastStep( void) ; /* debug functions */ void PrintConfigs( const VECTORHOLE& vHoles) ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index dc42c73..7773a2b 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index e3a1c0c..bdee15b 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -488,11 +488,15 @@ class MachMgr : public IMachMgr bool GetOperationNewName( std::string& sName) const ; const ToolData* GetMachiningToolData( void) const ; // Simulation - bool SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; + bool SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, + const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; + bool SimRemoveCollisionObj( int nFrameId) ; + bool SimGetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) const ; bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ; - bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, int nFlag, double dPar1, double dPar2, - const INTVECTOR& vVmill, bool bFirst) ; + bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, int nFlag, + double dPar1, double dPar2, const INTVECTOR& vVmill, bool bFirst) ; bool SimEnableToolsForVmill( bool bEnable) ; int SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ; bool SimSaveCmd( int nType, int nPar, const std::string& sPar, const std::string& sPar2) ; diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index 3ded32a..35e1cef 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -176,6 +176,29 @@ MachMgr::SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, co return m_pSimul->AddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::SimRemoveCollisionObj( int nFrameId) +{ + // verifico simulatore + if ( m_pSimul == nullptr) + return false ; + // rimuovo gli oggetti da verificare per la collisione con il grezzo con FrameId indicato + return m_pSimul->RemoveCollisionObj( nFrameId) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SimGetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) const +{ + // verifico simulatore + if ( m_pSimul == nullptr) + return false ; + // recupero i dati dell'oggetto di collisione di posizione indicata nel relativo vettore + return m_pSimul->GetCollisionObj( nPos, nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; +} + //---------------------------------------------------------------------------- bool MachMgr::SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) diff --git a/Machine.h b/Machine.h index deb68c9..52b991e 100644 --- a/Machine.h +++ b/Machine.h @@ -402,6 +402,8 @@ class Machine static int LuaEmtSetWarning( lua_State* L) ; static int LuaEmtAddCollisionObj( lua_State* L) ; static int LuaEmtAddCollisionObjEx( lua_State* L) ; + static int LuaEmtRemoveCollisionObj( lua_State* L) ; + static int LuaEmtGetCollisionObj( lua_State* L) ; static int LuaEmtExecCollisionCheck( lua_State* L) ; static int LuaEmtOnCollision( lua_State* L) ; static int LuaEmtSetToolForVmill( lua_State* L) ; diff --git a/MachineLua.cpp b/MachineLua.cpp index 63edcc0..ba6c000 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -144,6 +144,10 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtAddCollisionObj", Machine::LuaEmtAddCollisionObj) ; // registro la funzione estesa per aggiungere un oggetto da verificare per la collisione in simulazione m_LuaMgr.RegisterFunction( "EmtAddCollisionObjEx", Machine::LuaEmtAddCollisionObjEx) ; + // registro la funzione per rimuovere oggetti con dato FrameId da verificare per la collisione in simulazione + m_LuaMgr.RegisterFunction( "EmtRemoveCollisionObj", Machine::LuaEmtRemoveCollisionObj) ; + // registro la funzione per avere i dati dell'oggetto con posizione indicata nel vettore da verificare per la collisione in simulazione + m_LuaMgr.RegisterFunction( "EmtGetCollisionObj", Machine::LuaEmtGetCollisionObj) ; // registro la funzione di esecuzione della verifica di collisione in simulazione m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ; // registro la funzione di gestione della collisione in simulazione @@ -1428,6 +1432,65 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +int +Machine::LuaEmtRemoveCollisionObj( lua_State* L) +{ + // 1 parametro : nFrameId + int nFrameId ; + LuaCheckParam( L, 1, nFrameId) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // assegno i dati + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimRemoveCollisionObj( nFrameId)) ; + // assegno risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtGetCollisionObj( lua_State* L) +{ + // 1 parametro : nPos + int nPos ; + LuaCheckParam( L, 1, nPos) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // recupero i dati + int nInd ; + bool bToolOn ; + int nFrameId ; + int nType ; + Vector3d vtMove ; + double dPar1 ; + double dPar2 ; + double dPar3 ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && + m_pMchLua->m_pMchMgr->SimGetCollisionObj( nPos, nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ; + // assegno risultato + if ( bOk) { + LuaSetParam( L, true) ; + LuaSetParam( L, nInd) ; + LuaSetParam( L, bToolOn) ; + LuaSetParam( L, nFrameId) ; + LuaSetParam( L, nType) ; + LuaSetParam( L, vtMove) ; + LuaSetParam( L, dPar1) ; + LuaSetParam( L, dPar2) ; + LuaSetParam( L, dPar3) ; + return 9 ; + } + else { + LuaSetParam( L, false) ; + return 1 ; + } +} + //---------------------------------------------------------------------------- int Machine::LuaEmtExecCollisionCheck( lua_State* L) diff --git a/Machining.cpp b/Machining.cpp index 0025672..f94bcdc 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -584,7 +584,7 @@ Machining::GetToolPreviewStepCount( void) const -- nCount ; nRiseId = m_pGeomDB->GetNextName( nRiseId, MCH_CL_RISE) ; } - // tolgo le entità di tipo HOME + // tolgo le entit� HOME int nHomeId = m_pGeomDB->GetFirstNameInGroup( nPxId, MCH_CL_HOME) ; while ( nHomeId != GDB_ID_NULL) { -- nCount ; @@ -609,7 +609,7 @@ Machining::GetToolPreviewNext( int nEntId, int nParentId, int nStId) const // ciclo nel gruppo while ( nNewId != GDB_ID_NULL) { string sName ; m_pGeomDB->GetName( nNewId, sName) ; - if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE && sName != MCH_CL_HOME) + if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE && sName != MCH_CL_HOME) break ; nNewId = m_pGeomDB->GetNext( nNewId) ; } diff --git a/OperUserNotesConst.h b/OperUserNotesConst.h index a86b5af..28b8239 100644 --- a/OperUserNotesConst.h +++ b/OperUserNotesConst.h @@ -26,6 +26,9 @@ static const std::string UN_DOUBLE = "DOUBLE" ; static const std::string UN_MIRRORAX = "MirrorAx" ; static const std::string UN_DELTAZ = "DeltaZ" ; +// Solo per Drilling +static const std::string UN_LASTSTEP = "LastStep" ; + // Solo per FiveAxisMilling static const std::string UN_SINGCONEANG = "SingConeAng" ; diff --git a/Sawing.cpp b/Sawing.cpp index a4db978..ad6ed75 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -1603,6 +1603,15 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId) double dThick ; pCompo->GetThickness( dThick) ; + // aggiusto eventuali normali inverse di archi rispetto ad estrusione + const ICurve* pCrv = pCompo->GetFirstCurve() ; + while ( pCrv != nullptr) { + const ICurveArc* pArc = GetCurveArc( pCrv) ; + if ( pArc != nullptr && pArc->GetNormVersor() * vtExtr < 0) + const_cast(pArc)->InvertN() ; + pCrv = pCompo->GetNextCurve() ; + } + // recupero distanza da fondo dei grezzi interessati dal percorso double dRbDist, dAllRbDist ; double dToler = 2 * m_TParams.m_dThick + tan( abs( m_Params.m_dSideAngle) * DEGTORAD) * m_TParams.m_dMaxMat ; diff --git a/Simulator.h b/Simulator.h index 7c2ba80..2ce446d 100644 --- a/Simulator.h +++ b/Simulator.h @@ -53,6 +53,9 @@ class __declspec( novtable) ISimulator virtual bool GetMoveInfo( int& nGmove, double& dFeed) const = 0 ; virtual bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) = 0 ; + virtual bool RemoveCollisionObj( int nFrameId) = 0 ; + virtual bool GetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) = 0 ; virtual bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) = 0 ; virtual bool OnCollision( int nCdInd, int nObjInd, int& nErr) = 0 ; virtual bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, int nFlag, diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index 199e4c8..2bcb705 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -2336,6 +2336,34 @@ SimulatorMP::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, c return true ; } +//---------------------------------------------------------------------------- +bool +SimulatorMP::RemoveCollisionObj( int nFrameId) +{ + erase_if( m_CollObj, [nFrameId]( CollObj Item) { return ( Item.nFrameId == nFrameId) ; }) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +SimulatorMP::GetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) +{ + // posizione nel vettore non valida + if ( nPos < 0 || nPos >= ssize( m_CollObj)) + return false ; + // assegno i dati + nInd = m_CollObj[nPos].nInd ; + bToolOn = m_CollObj[nPos].bToolOn ; + nFrameId = m_CollObj[nPos].nFrameId ; + nType = m_CollObj[nPos].nType ; + vtMove = m_CollObj[nPos].vtMove ; + dPar1 = m_CollObj[nPos].dPar1 ; + dPar2 = m_CollObj[nPos].dPar2 ; + dPar3 = m_CollObj[nPos].dPar3 ; + return true ; +} + //---------------------------------------------------------------------------- bool SimulatorMP::SetToolForVmill( const string& sTool, const string& sHead, int nExit, int nFlag, double dPar1, double dPar2, diff --git a/SimulatorMP.h b/SimulatorMP.h index afb1f83..9635854 100644 --- a/SimulatorMP.h +++ b/SimulatorMP.h @@ -40,6 +40,9 @@ class SimulatorMP : public ISimulator bool GetMoveInfo( int& nGmove, double& dFeed) const override ; bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) override ; + bool RemoveCollisionObj( int nFrameId) override ; + bool GetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) override ; bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) override ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) override ; bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, int nFlag, diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index f2e1e92..f3572fc 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -2343,7 +2343,8 @@ SimulatorSP::OnResetMachine( void) //---------------------------------------------------------------------------- bool -SimulatorSP::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) +SimulatorSP::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, + const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifiche sui parametri if ( nInd <= 0 || nFrameId <= GDB_ID_NULL) @@ -2374,6 +2375,35 @@ SimulatorSP::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, c } // aggiungo al vettore m_CollObj.emplace_back( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +SimulatorSP::RemoveCollisionObj( int nFrameId) +{ + erase_if( m_CollObj, [nFrameId]( CollObj Item) { return ( Item.nFrameId == nFrameId) ; }) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +SimulatorSP::GetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) +{ + // posizione nel vettore non valida + if ( nPos < 0 || nPos >= ssize( m_CollObj)) + return false ; + // assegno i dati + nInd = m_CollObj[nPos].nInd ; + bToolOn = m_CollObj[nPos].bToolOn ; + nFrameId = m_CollObj[nPos].nFrameId ; + nType = m_CollObj[nPos].nType ; + vtMove = m_CollObj[nPos].vtMove ; + dPar1 = m_CollObj[nPos].dPar1 ; + dPar2 = m_CollObj[nPos].dPar2 ; + dPar3 = m_CollObj[nPos].dPar3 ; return true ; } diff --git a/SimulatorSP.h b/SimulatorSP.h index 983c3f6..ae54298 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -40,6 +40,9 @@ class SimulatorSP : public ISimulator bool GetMoveInfo( int& nGmove, double& dFeed) const override ; bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) override ; + bool RemoveCollisionObj( int nFrameId) override ; + bool GetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType, + Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) override ; bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) override ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) override ; bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, int nFlag,