From cc2a72d5aff1c8e8704a0aeb99745db758a69b84 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 15 Dec 2015 14:48:11 +0000 Subject: [PATCH] EgtMachKernel 1.6l3 : - aggiunta prima gestione preview tagli con lama. --- Drilling.cpp | 9 ++- Drilling.h | 3 +- EgtMachKernel.rc | Bin 11782 -> 11782 bytes MachMgr.h | 3 +- MachMgrOperations.cpp | 22 +++++- Machining.h | 3 +- MachiningConst.h | 1 + Milling.cpp | 9 ++- Milling.h | 3 +- Sawing.cpp | 158 +++++++++++++++++++++++++++++++++++++----- Sawing.h | 15 ++-- 11 files changed, 195 insertions(+), 31 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index d3fce24..ee080c8 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -277,7 +277,14 @@ Drilling::SetGeometry( const SELVECTOR& vIds) //---------------------------------------------------------------------------- bool -Drilling::Apply( void) +Drilling::Preview( bool bRecalc) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Apply( bool bRecalc) { // verifico validità gestore DB geometrico e Id del gruppo if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) diff --git a/Drilling.h b/Drilling.h index f3106df..70389e3 100644 --- a/Drilling.h +++ b/Drilling.h @@ -37,7 +37,8 @@ class Drilling : public Machining virtual bool SetParam( int nType, double dVal) ; virtual bool SetParam( int nType, const std::string& sVal) ; virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Apply( void) ; + virtual bool Preview( bool bRecalc) ; + virtual bool Apply( bool bRecalc) ; virtual bool GetParam( int nType, bool& bVal) const ; virtual bool GetParam( int nType, int& nVal) const ; virtual bool GetParam( int nType, double& dVal) const ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index f55db0b7b31a4f0160461116c70585f551eb0cb1..c2fd6c998a795718d24fddc13eea04ffbf0c2b8c 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFyA^ItYwW=7-5j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHPhB8F delta 97 zcmZpRX^YwLhmFx_^ItYwW=5mQj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHP01iS diff --git a/MachMgr.h b/MachMgr.h index 8acdf55..cdbcb7f 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -166,7 +166,8 @@ class MachMgr : public IMachMgr virtual bool SetMachiningParam( int nType, double dVal) ; virtual bool SetMachiningParam( int nType, const std::string& sVal) ; virtual bool SetMachiningGeometry( const SELVECTOR& vIds) ; - virtual bool MachiningApply( void) ; + virtual bool MachiningPreview( bool bRecalc) ; + virtual bool MachiningApply( bool bRecalc) ; virtual bool GetMachiningParam( int nType, bool& bVal) const ; virtual bool GetMachiningParam( int nType, int& dVal) const ; virtual bool GetMachiningParam( int nType, double& dVal) const ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 0248752..95f5f40 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -434,7 +434,7 @@ MachMgr::SetMachiningGeometry( const SELVECTOR& vIds) //---------------------------------------------------------------------------- bool -MachMgr::MachiningApply( void) +MachMgr::MachiningPreview( bool bRecalc) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; @@ -444,8 +444,24 @@ MachMgr::MachiningApply( void) Machining* pMch = dynamic_cast( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; - // imposto la geometria - return pMch->Apply() ; + // calcolo l'anteprima della lavorazione + return pMch->Preview( bRecalc) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::MachiningApply( bool bRecalc) +{ + // recupero la lavorazione corrente + int nCurrMchId = GetCurrMachining() ; + if ( nCurrMchId == GDB_ID_NULL) + return false ; + // ne recupero il gestore + Machining* pMch = dynamic_cast( m_pGeomDB->GetUserObj( nCurrMchId)) ; + if ( pMch == nullptr) + return false ; + // calcolo la lavorazione + return pMch->Apply( bRecalc) ; } //---------------------------------------------------------------------------- diff --git a/Machining.h b/Machining.h index 5ccfd9b..0a3ef3e 100644 --- a/Machining.h +++ b/Machining.h @@ -39,7 +39,8 @@ class Machining : public IUserObj virtual bool SetParam( int nType, double dVal) = 0 ; virtual bool SetParam( int nType, const std::string& sVal) = 0 ; virtual bool SetGeometry( const SELVECTOR& vIds) = 0 ; - virtual bool Apply( void) = 0 ; + virtual bool Preview( bool bRecalc) = 0 ; + virtual bool Apply( bool bRecalc) = 0 ; virtual bool GetParam( int nType, bool& bVal) const = 0 ; virtual bool GetParam( int nType, int& nVal) const = 0 ; virtual bool GetParam( int nType, double& dVal) const = 0 ; diff --git a/MachiningConst.h b/MachiningConst.h index b8d0f95..c513d12 100644 --- a/MachiningConst.h +++ b/MachiningConst.h @@ -20,6 +20,7 @@ static std::string KEY_IDS = "IDS" ; // Sottogruppi delle lavorazioni static std::string MCH_AUX = "AUX" ; +static std::string MCH_PV = "PV" ; static std::string MCH_CL = "CL" ; static std::string MCH_PATH = "P" ; // Nomi di entità speciali diff --git a/Milling.cpp b/Milling.cpp index 74ec4c3..13dbdc6 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -191,7 +191,14 @@ Milling::SetGeometry( const SELVECTOR& vIds) //---------------------------------------------------------------------------- bool -Milling::Apply( void) +Milling::Preview( bool bRecalc) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Apply( bool bRecalc) { return false ; } diff --git a/Milling.h b/Milling.h index 59e6eeb..9ce074a 100644 --- a/Milling.h +++ b/Milling.h @@ -37,7 +37,8 @@ class Milling : public Machining virtual bool SetParam( int nType, double dVal) ; virtual bool SetParam( int nType, const std::string& sVal) ; virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Apply( void) ; + virtual bool Preview( bool bRecalc) ; + virtual bool Apply( bool bRecalc) ; virtual bool GetParam( int nType, bool& bVal) const ; virtual bool GetParam( int nType, int& nVal) const ; virtual bool GetParam( int nType, double& dVal) const ; diff --git a/Sawing.cpp b/Sawing.cpp index 0029044..25d8e26 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -19,6 +19,7 @@ #include "MachiningConst.h" #include "CamData.h" #include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EgkChainCurves.h" @@ -314,7 +315,7 @@ Sawing::SetGeometry( const SELVECTOR& vIds) //---------------------------------------------------------------------------- bool -Sawing::Apply( void) +Sawing::Preview( bool bRecalc) { // verifico validità gestore DB geometrico e Id del gruppo if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) @@ -322,23 +323,84 @@ Sawing::Apply( void) // recupero gruppo per geometria ausiliaria int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ; + bool bChain = false ; // se non c'è, lo aggiungo if ( nAuxId == GDB_ID_NULL) { nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; if ( nAuxId == GDB_ID_NULL) return false ; m_pGeomDB->SetName( nAuxId, MCH_AUX) ; + bChain = true ; } - // altrimenti lo svuoto - else + // altrimenti, se chiesto ricalcolo, lo svuoto + else if ( bRecalc) { m_pGeomDB->EmptyGroup( nAuxId) ; + bChain = true ; + } + + // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria + if ( bChain && ! Chain( nAuxId)) + return false ; // verifiche per angolo di sbandamento if ( ! VerifySideAngle()) return false ; - // eseguo concatenamento, inserisco i percorsi sotto la geometria ausiliaria - if ( ! Chain( nAuxId)) + // recupero gruppo per anteprima di lavorazione (PreView) + int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ; + // se non c'è, lo aggiungo + if ( nPvId == GDB_ID_NULL) { + nPvId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nPvId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nPvId, MCH_PV) ; + } + // altrimenti lo svuoto + else + m_pGeomDB->EmptyGroup( nPvId) ; + + // calcolo anteprima di ogni singola catena + int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ; + while ( nPathId != GDB_ID_NULL) { + if ( ! ProcessPath( nPathId, nPvId, GDB_ID_NULL)) + return false ; + nPathId = m_pGeomDB->GetNextGroup( nPathId) ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Apply( bool bRecalc) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + + // recupero gruppo per geometria ausiliaria + int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ; + bool bChain = false ; + // se non c'è, lo aggiungo + if ( nAuxId == GDB_ID_NULL) { + nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nAuxId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nAuxId, MCH_AUX) ; + bChain = true ; + } + // altrimenti, se chiesto ricalcolo, lo svuoto + else if ( bRecalc) { + m_pGeomDB->EmptyGroup( nAuxId) ; + bChain = true ; + } + + // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria + if ( bChain && ! Chain( nAuxId)) + return false ; + + // verifiche per angolo di sbandamento + if ( ! VerifySideAngle()) return false ; // recupero gruppo per geometria di lavorazione (Cutter Location) @@ -357,7 +419,7 @@ Sawing::Apply( void) // lavoro ogni singola catena int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ; while ( nPathId != GDB_ID_NULL) { - if ( ! PathApply( nPathId, nClId)) + if ( ! ProcessPath( nPathId, GDB_ID_NULL, nClId)) return false ; nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } @@ -722,7 +784,7 @@ Sawing::Chain( int nGrpDestId) //---------------------------------------------------------------------------- bool -Sawing::PathApply( int nPathId, int nClId) +Sawing::ProcessPath( int nPathId, int nPvId, int nClId) { // recupero gruppo per geometria temporanea const string GRP_TEMP = "Temp" ; @@ -846,7 +908,7 @@ Sawing::PathApply( int nPathId, int nClId) const ICurve* pCrvN = pCompo->GetCurve( k) ; // elaborazioni sulla curva corrente string sName = sPathName + "_" + ToString( i) ; - if ( ! EntityApply( pCrvP, pCrvC, pCrvN, dDepth, dExtraCut, i == 0, i == nMaxInd, sName, nClId)) + if ( ! ProcessEntity( pCrvP, pCrvC, pCrvN, dDepth, dExtraCut, i == 0, i == nMaxInd, sName, nPvId, nClId)) return false ; } @@ -855,19 +917,13 @@ Sawing::PathApply( int nPathId, int nClId) //---------------------------------------------------------------------------- bool -Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, - double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast, - const string& sName, int nClId) +Sawing::ProcessEntity( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, + double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast, + const string& sName, int nPvId, int nClId) { // se non è una linea, la salto if ( pCrvC->GetType() != CRV_LINE) return true ; - // creo gruppo per geometria di lavorazione della linea - int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ; - if ( nPxId == GDB_ID_NULL) - return false ; - m_pGeomDB->SetName( nPxId, sName) ; - m_pGeomDB->SetMaterial( nPxId, BLUE) ; // copio la curva PtrOwner pLine( GetCurveLine( pCrvC->Clone())) ; // calcolo i versori fresa e correzione @@ -928,6 +984,74 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr return true ; } + // Se richiesto Preview + if ( nPvId != GDB_ID_NULL) { + if ( ! GenerateEntityPv( Get( pLine), vtTool, vtCorr, dElev, dExtraCut, sName, nPvId)) + return false ; + } + + // Se richiesta geometria di lavorazione + if ( nClId != GDB_ID_NULL) { + if ( ! GenerateEntityCl( Get( pLine), vtTool, vtCorr, dElev, dExtraCut, sName, nClId)) + return false ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, + double dElev, double dExtraCut, const string& sName, int nPvId) +{ + // creo gruppo per anteprima di lavorazione della linea + int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPvId, Frame3d()) ; + if ( nPxId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nPxId, sName) ; + m_pGeomDB->SetMaterial( nPxId, BLUE) ; + + // rettangolo per parte di taglio completo + Point3d ptIni = pLine->GetStart() + dElev * vtCorr ; + Point3d ptEnd = pLine->GetEnd() + dElev * vtCorr ; + Vector3d vtToolH( vtTool.x, vtTool.y, 0) ; + vtToolH *= m_TParams.m_dThick / vtToolH.SqLen() ; + Point3d ptCross = ptEnd + vtToolH ; + Vector3d vtDZ( 0, 0, 0.1) ; + int nId = ExeCreateRectangle3P( nPxId, ptIni + vtDZ, ptCross + vtDZ, ptEnd + vtDZ, RTY_LOC) ; + // assegno colore + m_pGeomDB->SetMaterial( nId, LIME) ; + + // distanza XY tra centro e bordo taglio + double dDeltaT = (( dElev < 0.5 * m_TParams.m_dDiam) ? sqrt( dElev * m_TParams.m_dDiam - dElev * dElev) : 0) ; + // direzione del taglio + Vector3d vtDir ; + pLine->GetStartDir( vtDir) ; + + // rettangolo per parte parziale iniziale + int nId2 = ExeCreateRectangle3P( nPxId, ptIni - vtDir * dDeltaT, ptIni + vtToolH, ptIni, RTY_LOC) ; + // assegno colore + m_pGeomDB->SetMaterial( nId2, FUCHSIA) ; + + // rettangolo per parte parziale finale + int nId3 = ExeCreateRectangle3P( nPxId, ptEnd, ptCross + vtDir * dDeltaT, ptEnd + vtDir * dDeltaT, RTY_LOC) ; + // assegno colore + m_pGeomDB->SetMaterial( nId3, FUCHSIA) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::GenerateEntityCl( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, + double dElev, double dExtraCut, const string& sName, int nClId) +{ + // creo gruppo per geometria di lavorazione della linea + int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ; + if ( nPxId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nPxId, sName) ; + m_pGeomDB->SetMaterial( nPxId, BLUE) ; // Imposto dati comuni SetPathId( nPxId) ; SetToolDir( vtTool) ; diff --git a/Sawing.h b/Sawing.h index 7e1773a..0d6127f 100644 --- a/Sawing.h +++ b/Sawing.h @@ -38,7 +38,8 @@ class Sawing : public Machining virtual bool SetParam( int nType, double dVal) ; virtual bool SetParam( int nType, const std::string& sVal) ; virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Apply( void) ; + virtual bool Preview( bool bRecalc) ; + virtual bool Apply( bool bRecalc) ; virtual bool GetParam( int nType, bool& bVal) const ; virtual bool GetParam( int nType, int& nVal) const ; virtual bool GetParam( int nType, double& dVal) const ; @@ -54,10 +55,14 @@ class Sawing : public Machining ICurve* GetCurve( SelData Id) ; bool VerifySideAngle( void) ; bool Chain( int nGrpDestId) ; - bool PathApply( int nPathId, int nClId) ; - bool EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, - double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast, - const std::string& sName, int nClId) ; + bool ProcessPath( int nPathId, int nPvId, int nClId) ; + bool ProcessEntity( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, + double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast, + const std::string& sName, int nPvId, int nClId) ; + bool GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, + double dElev, double dExtraCut, const string& sName, int nPvId) ; + bool GenerateEntityCl( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, + double dElev, double dExtraCut, const string& sName, int nClId) ; bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ; bool AdjustForSide( ICurve* pCurve) ; bool AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick,