From c5795df8d059983282ec73584612b806c912493f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 30 Jun 2015 14:06:31 +0000 Subject: [PATCH] EgtMachKernel : - aggiunta funzione SetParam alle diverse lavorazioni - aggiunto calcolo elevazione da grezzo - estesa lavorazione di taglio con lama. --- CamData.cpp | 18 +- CamData.h | 2 - Disposition.cpp | 1 + Drilling.cpp | 85 ++++++- Drilling.h | 4 + DrillingData.cpp | 20 +- DrillingData.h | 5 + EgtMachKernel.vcxproj | 2 + EgtMachKernel.vcxproj.filters | 6 + MachMgr.h | 12 +- MachMgrOperations.cpp | 122 +++++++-- Machining.cpp | 136 +++++++++- Machining.h | 12 +- MachiningConst.h | 2 +- Milling.cpp | 28 +++ Milling.h | 4 + Sawing.cpp | 452 +++++++++++++++++++++++++++++----- Sawing.h | 10 +- SawingData.cpp | 74 +++++- SawingData.h | 44 ++-- ToolData.cpp | 8 + ToolData.h | 4 + 22 files changed, 890 insertions(+), 161 deletions(-) diff --git a/CamData.cpp b/CamData.cpp index 38e9c99..faa22a1 100644 --- a/CamData.cpp +++ b/CamData.cpp @@ -22,8 +22,7 @@ using namespace std ; //---------------------------------------------------------------------------- -static int CAM_TOTPARAM = 8 ; -static std::string CAM_ORID = "OrId" ; +static int CAM_TOTPARAM = 7 ; static std::string CAM_CORR = "Corr" ; static std::string CAM_TDIR = "TDir" ; static std::string CAM_CDIR = "CDir" ; @@ -53,7 +52,6 @@ CamData::Clone( void) const try { pCam->m_nOwnerId = GDB_ID_NULL ; pCam->m_pGeomDB = nullptr ; - pCam->m_OriId = m_OriId ; pCam->m_nCorre = m_nCorre ; pCam->m_vtTool = m_vtTool ; pCam->m_vtCorr = m_vtCorr ; @@ -75,7 +73,6 @@ bool CamData::Dump( string& sOut, const char* szNewLine) const { sOut += GetClassName() + szNewLine ; - sOut += CAM_ORID + "=" + ToString( m_OriId) + szNewLine ; sOut += CAM_CORR + "=" + ToString( m_nCorre) + szNewLine ; sOut += CAM_TDIR + "=" + ToString( m_vtTool) + szNewLine ; sOut += CAM_CDIR + "=" + ToString( m_vtCorr) + szNewLine ; @@ -117,7 +114,6 @@ CamData::Save( STRVECTOR& vString) const try { vString.insert( vString.begin(), CAM_TOTPARAM, "") ; int k = - 1 ; - vString[++k] = CAM_ORID + "=" + ToString( m_OriId) ; vString[++k] = CAM_CORR + "=" + ToString( m_nCorre) ; vString[++k] = CAM_TDIR + "=" + ToString( m_vtTool) ; vString[++k] = CAM_CDIR + "=" + ToString( m_vtCorr) ; @@ -139,8 +135,7 @@ CamData::Load( const STRVECTOR& vString) if ( int( vString.size()) < CAM_TOTPARAM) return false ; int k = - 1 ; - if ( ! GetVal( vString[++k], CAM_ORID, m_OriId) || - ! GetVal( vString[++k], CAM_CORR, m_nCorre) || + if ( ! GetVal( vString[++k], CAM_CORR, m_nCorre) || ! GetVal( vString[++k], CAM_TDIR, m_vtTool) || ! GetVal( vString[++k], CAM_CDIR, m_vtCorr) || ! GetVal( vString[++k], CAM_ADIR, m_vtAux) || @@ -381,20 +376,11 @@ CamData::CamData( void) { m_nOwnerId = GDB_ID_NULL ; m_pGeomDB = nullptr ; - m_OriId = SelData() ; m_nCorre = 0 ; m_dFeed = 0 ; m_nFlag = 0 ; } -//---------------------------------------------------------------------------- -bool -CamData::SetOrigId( SelData Id) -{ - m_OriId = Id ; - return true ; -} - //---------------------------------------------------------------------------- bool CamData::SetToolDir( const Vector3d& vtDir) diff --git a/CamData.h b/CamData.h index 35055b2..af42cd2 100644 --- a/CamData.h +++ b/CamData.h @@ -45,7 +45,6 @@ class CamData : public IUserObj public : CamData( void) ; - bool SetOrigId( SelData Id) ; bool SetToolDir( const Vector3d& vtDir) ; bool SetCorrDir( const Vector3d& vtDir) ; bool SetAuxDir( const Vector3d& vtDir) ; @@ -59,7 +58,6 @@ class CamData : public IUserObj private : int m_nOwnerId ; IGeomDB* m_pGeomDB ; - SelData m_OriId ; // identificativo geometria di origine int m_nCorre ; // tipo correzione (0, 41, 42, 141, 142, 40) Vector3d m_vtTool ; // versore fresa Vector3d m_vtCorr ; // versore correzione diff --git a/Disposition.cpp b/Disposition.cpp index 5bce452..9297364 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -17,6 +17,7 @@ #include "DllMain.h" #include "Disposition.h" #include "Table.h" +#include "/EgtDev/Include/EMkDispositionConst.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" diff --git a/Drilling.cpp b/Drilling.cpp index 9d2205d..58e6647 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -172,6 +172,89 @@ Drilling::Prepare( const string& sDriName) return true ; } +//---------------------------------------------------------------------------- +bool +Drilling::SetParam( int nType, bool bVal) +{ + switch ( nType) { + case MPA_INVERT : + m_Params.m_bInvert = bVal ; + break ; + default : + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::SetParam( int nType, int nVal) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::SetParam( int nType, double dVal) +{ + switch ( nType) { + case MPA_TOOLSPEED : + if ( ! m_TParams.VerifySpeed( dVal)) + return false ; + m_TParams.m_dSpeed = dVal ; + break ; + case MPA_TOOLFEED : + m_TParams.m_dFeed = dVal ; + break ; + case MPA_TOOLSTARTFEED : + m_TParams.m_dStartFeed = dVal ; + break ; + case MPA_TOOLENDFEED : + m_TParams.m_dEndFeed = dVal ; + break ; + case MPA_STARTPOS : + m_Params.m_dStartPos = dVal ; + break ; + case MPA_STARTSLOWLEN : + m_Params.m_dStartSlowLen = dVal ; + break ; + case MPA_ENDSLOWLEN : + m_Params.m_dEndSlowLen = dVal ; + break ; + case MPA_THROUADDLEN : + m_Params.m_dThroughAddLen = dVal ; + break ; + case MPA_STEP : + m_Params.m_dStep = dVal ; + break ; + case MPA_RETURNPOS : + m_Params.m_dReturnPos = dVal ; + break ; + default : + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::SetParam( int nType, const string& sVal) +{ + switch ( nType) { + case MPA_TOOL : { + const ToolData* pTdata ; + if ( ! m_Params.VerifyTool( m_pMchMgr, sVal, pTdata)) + return false ; + m_Params.m_sToolName = sVal ; + m_Params.m_ToolUuid = pTdata->m_Uuid ; + m_TParams = *pTdata ; + } break ; + default : + return false ; + } + return true ; +} + //---------------------------------------------------------------------------- bool Drilling::SetGeometry( const SELVECTOR& vIds) @@ -320,7 +403,6 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId) double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ; // imposto dati comuni SetPathId( nPathId) ; - SetOrigId( Id) ; SetToolDir( hole.vtDir) ; // 1 -> punto approccio double dAppr = GetApproachDist() ; @@ -402,7 +484,6 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId) double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ; // imposto dati comuni SetPathId( nPathId) ; - SetOrigId( Id) ; SetToolDir( hole.vtDir) ; // 1 -> punto approccio double dAppr = GetApproachDist() ; diff --git a/Drilling.h b/Drilling.h index 82cd66f..ea7a307 100644 --- a/Drilling.h +++ b/Drilling.h @@ -32,6 +32,10 @@ class Drilling : public Machining public : // Machining virtual bool Prepare( const std::string& sDriName) ; + virtual bool SetParam( int nType, bool bVal) ; + virtual bool SetParam( int nType, int nVal) ; + 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) ; diff --git a/DrillingData.cpp b/DrillingData.cpp index bbbbfea..889976d 100644 --- a/DrillingData.cpp +++ b/DrillingData.cpp @@ -148,4 +148,22 @@ DrillingData::ToString( int nInd) const case KEY_UUID : return ( sDrillingKey[KEY_UUID] + "=" + ::ToString( m_Uuid)) ; default : return "" ; } -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +bool +DrillingData::VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const +{ + if ( pMachMgr == nullptr) + return false ; + ToolsMgr* pTMgr = pMachMgr->GetCurrToolsMgr() ; + if ( pTMgr == nullptr) + return false ; + pTdata = pTMgr->GetTool( sVal) ; + if ( pTdata == nullptr) + return false ; + if ( ( pTdata->m_nType & TF_DRILLBIT) == 0 || + pTdata->m_nType != TT_MILL_STD) + return false ; + return true ; +} diff --git a/DrillingData.h b/DrillingData.h index e7aac39..c7082d4 100644 --- a/DrillingData.h +++ b/DrillingData.h @@ -14,6 +14,7 @@ #pragma once #include "MachiningData.h" +#include "MachMgr.h" //---------------------------------------------------------------------------- struct DrillingData : public MachiningData @@ -27,14 +28,18 @@ struct DrillingData : public MachiningData double m_dThroughAddLen ; // lunghezza aggiuntiva di foratura se passante double m_dStep ; // passo di affondameto (0=nessun passo) double m_dReturnPos ; // quota di ritorno (+=fuori, -=dentro) + DrillingData( void) : m_ToolUuid(), m_bInvert( false), m_dStartPos( 0), m_dStartSlowLen( 0), m_dEndSlowLen( 0), m_dThroughAddLen( 0), m_dStep( 0), m_dReturnPos( 0) {} + virtual int GetType( void) const { return MT_DRILLING ; } virtual int GetSize( void) const ; virtual std::string GetTitle( void) const ; virtual bool FromString( const std::string& sString, int& nKey) ; virtual std::string ToString( int nInd) const ; + + bool VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const ; } ; //---------------------------------------------------------------------------- diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj index 9d86e84..aad0e19 100644 --- a/EgtMachKernel.vcxproj +++ b/EgtMachKernel.vcxproj @@ -248,7 +248,9 @@ copy $(TargetPath) \EgtProg\Dll64 + + diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters index 6409d4c..4758a20 100644 --- a/EgtMachKernel.vcxproj.filters +++ b/EgtMachKernel.vcxproj.filters @@ -221,6 +221,12 @@ Header Files + + Header Files\Include + + + Header Files\Include + diff --git a/MachMgr.h b/MachMgr.h index d25335e..037c573 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -107,6 +107,14 @@ class MachMgr : public IMachMgr int& nStat, double& dX, double& dY, double& dZ) ; virtual bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; // Operations + virtual int AddMachining( const std::string& sName, const std::string& sMachining) ; + virtual bool SetMachiningParam( int nType, bool bVal) ; + virtual bool SetMachiningParam( int nType, int nVal) ; + virtual bool SetMachiningParam( int nType, double dVal) ; + virtual bool SetMachiningParam( int nType, const std::string& sVal) ; + virtual bool SetMachiningGeometry( const SELVECTOR& vIds) ; + virtual bool Apply( void) ; + // Da verificare bene virtual int GetOperationNbr( void) const ; virtual int GetFirstOperation( void) const ; virtual int GetNextOperation( int nId) const ; @@ -116,11 +124,7 @@ class MachMgr : public IMachMgr virtual bool SetCurrMachining( int nId) ; virtual bool ResetCurrMachining( void) ; virtual int GetCurrMachining( void) const ; - // Da verificare bene virtual int AddDisposition( const std::string& sName) ; - virtual int AddMachining( const std::string& sName, const std::string& sMachining) ; - virtual bool SetMachiningGeometry( const SELVECTOR& vIds) ; - virtual bool Apply( void) ; public : MachMgr( void) ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 450f3fc..fbcf45c 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -135,6 +135,37 @@ MachMgr::GetOperationId( const string& sName) const return GDB_ID_NULL ; } +//---------------------------------------------------------------------------- +// Dispositions +//---------------------------------------------------------------------------- +int +MachMgr::AddDisposition( const string& sName) +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // recupero nome originale, partendo da quello proposto + string sNewName = sName ; + if ( ! GetOperationNewName( sNewName)) + return GDB_ID_NULL ; + // inserisco il gruppo + int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; + if ( nId == GDB_ID_NULL) + return GDB_ID_NULL ; + // assegno il nome + m_pGeomDB->SetName( nId, sNewName) ; + // installo il gestore della disposizione + Disposition* pDisp = new(nothrow) Disposition ; + if ( pDisp == nullptr) + return GDB_ID_NULL ; + m_pGeomDB->SetUserObj( nId, pDisp) ; + pDisp->Init( this) ; + return nId ; +} + +//---------------------------------------------------------------------------- +// Machinings //---------------------------------------------------------------------------- bool MachMgr::SetCurrMachining( int nId) @@ -179,33 +210,6 @@ MachMgr::GetCurrMachining( void) const return GDB_ID_NULL ; } -//---------------------------------------------------------------------------- -int -MachMgr::AddDisposition( const string& sName) -{ - // recupero il gruppo delle operazioni nella macchinata corrente - int nOperGrpId = GetCurrOperId() ; - if ( nOperGrpId == GDB_ID_NULL) - return GDB_ID_NULL ; - // recupero nome originale, partendo da quello proposto - string sNewName = sName ; - if ( ! GetOperationNewName( sNewName)) - return GDB_ID_NULL ; - // inserisco il gruppo - int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; - if ( nId == GDB_ID_NULL) - return GDB_ID_NULL ; - // assegno il nome - m_pGeomDB->SetName( nId, sNewName) ; - // installo il gestore della lavorazione - Disposition* pDisp = new(nothrow) Disposition ; - if ( pDisp == nullptr) - return GDB_ID_NULL ; - m_pGeomDB->SetUserObj( nId, pDisp) ; - pDisp->Init( this) ; - return nId ; -} - //---------------------------------------------------------------------------- int MachMgr::AddMachining( const string& sName, const std::string& sMachining) @@ -255,6 +259,70 @@ MachMgr::AddMachining( const string& sName, const std::string& sMachining) return nId ; } +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachiningParam( int nType, bool bVal) +{ + // 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 ; + // imposto il parametro + return pMch->SetParam( nType, bVal) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachiningParam( int nType, int nVal) +{ + // 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 ; + // imposto il parametro + return pMch->SetParam( nType, nVal) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachiningParam( int nType, double dVal) +{ + // 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 ; + // imposto il parametro + return pMch->SetParam( nType, dVal) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachiningParam( int nType, const string& sVal) +{ + // 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 ; + // imposto il parametro + return pMch->SetParam( nType, sVal) ; +} + //---------------------------------------------------------------------------- bool MachMgr::SetMachiningGeometry( const SELVECTOR& vIds) diff --git a/Machining.cpp b/Machining.cpp index 88e6682..3bd2016 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -18,6 +18,7 @@ #include "CamData.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkIntersLineSurfTm.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -62,24 +63,145 @@ Machining::Init( MachMgr* pMchMgr) //---------------------------------------------------------------------------- Machining::Machining( void) : m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_pMchMgr( nullptr), - m_nPathId( GDB_ID_NULL), m_OrigId(), m_bCurr( false), m_ptCurr(), + m_nPathId( GDB_ID_NULL), m_bCurr( false), m_ptCurr(), m_vtTool(), m_vtCorr(), m_vtAux(), m_dFeed( 0), m_nFlag( 0) { } +//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- bool -Machining::SetPathId( int nPathId) +Machining::GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dElev) { - m_nPathId = nPathId ; - return true ; + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // inizializzo elevazione + dElev = INFINITO ; + // ciclo sui grezzi + bool bFound = false ; + int nRawId = m_pMchMgr->GetFirstRawPart() ; + while ( nRawId != GDB_ID_NULL) { + // intersezione del raggio dal punto alla trimesh del grezzo + const double RAY_LEN = 10000 ; + int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; + if ( pStm != nullptr) { + bFound = true ; + // recupero il riferimento della trimesh + Frame3d frStm ; + m_pGeomDB->GetGlobFrame( nStmId, frStm) ; + // porto il raggio in questo riferimento + Point3d ptPL = ptP ; + ptPL.ToLoc( frStm) ; + Vector3d vtDirL = vtDir ; + vtDirL.ToLoc( frStm) ; + ILSIVECTOR vInfo ; + if ( IntersLineSurfTm( ptPL, vtDirL, RAY_LEN, *pStm, vInfo)) { + for ( const auto& Info : vInfo) { + // se tratto di intersezione coincidente, considero la posizione più lontana, ovvero 2 + if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { + // se prosegue un tratto precedente, non devo controllare sia minimo + if ( fabs( dElev - Info.dU) < EPS_SMALL) + dElev = Info.dU2 ; + else + dElev = min( dElev, Info.dU2) ; + } + // altrimenti intersezione puntuale, verifico che esca (coseno >= 0) + else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) { + dElev = min( dElev, Info.dU) ; + } + } + } + } + // passo al grezzo successivo + nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; + } + // se non trovate intersezioni, elevazione nulla + if ( dElev > INFINITO - 1) + dElev = 0 ; + return bFound ; } //---------------------------------------------------------------------------- bool -Machining::SetOrigId( SelData OrigId) +Machining::GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) { - m_OrigId = OrigId ; + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // inizializzo elevazione + dElev = INFINITO ; + // ciclo sui grezzi + bool bFound = false ; + int nRawId = m_pMchMgr->GetFirstRawPart() ; + while ( nRawId != GDB_ID_NULL) { + // intersezione del raggio dal punto alla trimesh del grezzo + const double RAY_LEN = 10000 ; + int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ; + if ( pStm != nullptr) { + bFound = true ; + // recupero il riferimento della trimesh + Frame3d frStm ; + m_pGeomDB->GetGlobFrame( nStmId, frStm) ; + // porto il segmento e la direzione in questo riferimento + Point3d ptP1L = ptP1 ; + ptP1L.ToLoc( frStm) ; + Point3d ptP2L = ptP2 ; + ptP2L.ToLoc( frStm) ; + Vector3d vtDirL = vtDir ; + vtDirL.ToLoc( frStm) ; + ILSIVECTOR vInfo ; + // inizializzo elevazione della superficie + double dElevS = 0 ; + // faccio test con un insieme di punti ( !!! sostituire con intersezione tra rettangolo e trimesh !!!) + const double STEP = 50 ; + int nStep = max( (int) ceil( ApproxDist( ptP1L, ptP2L) / STEP), 3) ; + for ( int i = 0 ; i <= nStep ; ++ i) { + // calcolo punto di test + double dFraz = i / (double) nStep ; + Point3d ptPL = Media( ptP1L, ptP2L, dFraz) ; + // inizializzo elevazione del punto + double dElevP = INFINITO ; + // calcolo elevazione sul punto + if ( IntersLineSurfTm( ptPL, vtDirL, RAY_LEN, *pStm, vInfo)) { + for ( const auto& Info : vInfo) { + // se tratto di intersezione coincidente, considero la posizione più lontana, ovvero 2 + if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { + // se prosegue un tratto precedente, non devo controllare sia minimo + if ( fabs( dElevP - Info.dU) < EPS_SMALL) + dElevP = Info.dU2 ; + else + dElevP = min( dElevP, Info.dU2) ; + } + // altrimenti intersezione puntuale, verifico che esca (coseno >= 0) + else if ( Info.dCosDN > - COS_ORTO_ANG_ZERO) { + dElevP = min( dElevP, Info.dU) ; + } + } + } + // se elevazione calcolata, aggiorno quella della superficie + if ( dElevP < INFINITO - 1) + dElevS = max( dElevS, dElevP) ; + } + // aggiorno elevazione complessiva + if ( dElevS > 0) + dElev = min( dElev, dElevS) ; + } + // passo al grezzo successivo + nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; + } + // se non trovate intersezioni, elevazione nulla + if ( dElev > INFINITO - 1) + dElev = 0 ; + return bFound ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +bool +Machining::SetPathId( int nPathId) +{ + m_nPathId = nPathId ; return true ; } @@ -145,7 +267,6 @@ Machining::AddStart( const Point3d& ptP) if ( IsNull( pCam)) return GDB_ID_NULL ; // assegno valori - pCam->SetOrigId( m_OrigId) ; pCam->SetToolDir( m_vtTool) ; pCam->SetCorrDir( m_vtCorr) ; pCam->SetAuxDir( m_vtAux) ; @@ -181,7 +302,6 @@ Machining::AddLinearMove( const Point3d& ptP) if ( IsNull( pCam)) return GDB_ID_NULL ; // assegno valori - pCam->SetOrigId( m_OrigId) ; pCam->SetToolDir( m_vtTool) ; pCam->SetCorrDir( m_vtCorr) ; pCam->SetAuxDir( m_vtAux) ; diff --git a/Machining.h b/Machining.h index b1c2872..3ce0085 100644 --- a/Machining.h +++ b/Machining.h @@ -31,7 +31,11 @@ class Machining : public IUserObj public : virtual bool Init( MachMgr* pMchMgr) ; - virtual bool Prepare( const std::string& sDriName) = 0 ; + virtual bool Prepare( const std::string& sMchName) = 0 ; + virtual bool SetParam( int nType, bool bVal) = 0 ; + virtual bool SetParam( int nType, int nVal) = 0 ; + 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 ResetGeometry( void) = 0 ; virtual bool Apply( void) = 0 ; @@ -40,11 +44,14 @@ class Machining : public IUserObj protected : Machining( void) ; + + protected : double GetApproachDist( void) { return 30.0 ; } + bool GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dElev) ; + bool GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) ; protected : bool SetPathId( int nPathId) ; - bool SetOrigId( SelData OrigId) ; bool SetToolDir( const Vector3d& vtDir) ; bool SetCorrDir( const Vector3d& vtDir) ; bool SetAuxDir( const Vector3d& vtDir) ; @@ -59,7 +66,6 @@ class Machining : public IUserObj IGeomDB* m_pGeomDB ; // puntatore al DB geometrico MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni int m_nPathId ; // identificativo del gruppo corrente di inserimento dati - SelData m_OrigId ; // identificativo della geometria originaria corrente bool m_bCurr ; // punto corrente valido Point3d m_ptCurr ; // posizione corrente Vector3d m_vtTool ; // direzione fresa corrente diff --git a/MachiningConst.h b/MachiningConst.h index 899f29e..e1a2fdb 100644 --- a/MachiningConst.h +++ b/MachiningConst.h @@ -13,7 +13,7 @@ #pragma once -#include +#include "/EgtDev/Include/EMkMachiningConst.h" //---------------------------------------------------------------------------- // Chiave per elenco identificativi di selezione diff --git a/Milling.cpp b/Milling.cpp index 44db9ff..44a2869 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -158,6 +158,34 @@ Milling::Prepare( const string& sMillName) return true ; } +//---------------------------------------------------------------------------- +bool +Milling::SetParam( int nType, bool bVal) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Milling::SetParam( int nType, int nVal) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Milling::SetParam( int nType, double dVal) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Milling::SetParam( int nType, const string& sVal) +{ + return false ; +} + //---------------------------------------------------------------------------- bool Milling::SetGeometry( const SELVECTOR& vIds) diff --git a/Milling.h b/Milling.h index 2ef1924..7e4d778 100644 --- a/Milling.h +++ b/Milling.h @@ -32,6 +32,10 @@ class Milling : public Machining public : // Machining virtual bool Prepare( const std::string& sMillName) ; + virtual bool SetParam( int nType, bool bVal) ; + virtual bool SetParam( int nType, int nVal) ; + 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) ; diff --git a/Sawing.cpp b/Sawing.cpp index 7065db5..aba9622 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -17,12 +17,15 @@ #include "DllMain.h" #include "Sawing.h" #include "MachiningConst.h" +#include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EgkChainCurves.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" #include "/EgtDev/Include/EgtPointerOwner.h" +// per far dimenticare macro di WinUser.h +#undef GetClassName using namespace std ; @@ -158,6 +161,131 @@ Sawing::Prepare( const string& sSawName) return true ; } +//---------------------------------------------------------------------------- +bool +Sawing::SetParam( int nType, bool bVal) +{ + switch ( nType) { + case MPA_INVERT : + m_Params.m_bInvert = bVal ; + break ; + case MPA_TOANDFROM : + m_Params.m_bToAndFrom = bVal ; + break ; + default : + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::SetParam( int nType, int nVal) +{ + switch ( nType) { + case MPA_WORKSIDE : + if ( ! m_Params.VerifyWorkSide( nVal)) + return false ; + m_Params.m_nWorkSide = nVal ; + break ; + case MPA_HEADSIDE : + if ( ! m_Params.VerifyHeadSide( nVal)) + return false ; + m_Params.m_nHeadSide = nVal ; + break ; + case MPA_LEADINTYPE : + if ( ! m_Params.VerifyLeadInType( nVal)) + return false ; + m_Params.m_nLeadInType = nVal ; + break ; + case MPA_EXTLINKTYPE : + if ( ! m_Params.VerifyExtLinkType( nVal)) + return false ; + m_Params.m_nExtLinkType = nVal ; + break ; + case MPA_LEADOUTTYPE : + if ( ! m_Params.VerifyLeadOutType( nVal)) + return false ; + m_Params.m_nLeadOutType = nVal ; + break ; + case MPA_CURVEUSE : + if ( ! m_Params.VerifyCurveUse( nVal)) + return false ; + m_Params.m_nCurveUse = nVal ; + break ; + default : + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::SetParam( int nType, double dVal) +{ + switch ( nType) { + case MPA_TOOLSPEED : + if ( ! m_TParams.VerifySpeed( dVal)) + return false ; + m_TParams.m_dSpeed = dVal ; + break ; + case MPA_TOOLFEED : + m_TParams.m_dFeed = dVal ; + break ; + case MPA_TOOLSTARTFEED : + m_TParams.m_dStartFeed = dVal ; + break ; + case MPA_TOOLENDFEED : + m_TParams.m_dEndFeed = dVal ; + break ; + case MPA_TOOLTIPFEED : + m_TParams.m_dTipFeed = dVal ; + break ; + case MPA_TOOLOFFSR : + m_TParams.m_dOffsR = dVal ; + break ; + case MPA_TOOLOFFSL : + m_TParams.m_dOffsL = dVal ; + break ; + case MPA_DEPTH : + m_Params.m_sDepth = ToString( dVal) ; + break ; + case MPA_SIDEANGLE : + if ( ! m_Params.VerifySideAngle( dVal)) + return false ; + m_Params.m_dSideAngle = dVal ; + break ; + case MPA_APPROX : + m_Params.m_dApprox = dVal ; + break ; + default : + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::SetParam( int nType, const string& sVal) +{ + switch ( nType) { + case MPA_TOOL : { + const ToolData* pTdata ; + if ( ! m_Params.VerifyTool( m_pMchMgr, sVal, pTdata)) + return false ; + m_Params.m_sToolName = sVal ; + m_Params.m_ToolUuid = pTdata->m_Uuid ; + m_TParams = *pTdata ; + } break ; + case MPA_DEPTH_STR : + m_Params.m_sDepth = sVal ; + break ; + default : + return false ; + } + return true ; +} + //---------------------------------------------------------------------------- bool Sawing::SetGeometry( const SELVECTOR& vIds) @@ -228,71 +356,11 @@ Sawing::Apply( void) // lavoro ogni singola catena int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ; while ( nPathId != GDB_ID_NULL) { - PathApply( nPathId) ; + PathApply( nPathId, nClId) ; nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } return true ; - -#if 0 - // recupero gruppo per geometria di lavorazione del primo utensile - int nT1Id = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, SAW_T1) ; - // se non c'è, lo aggiungo - if ( nT1Id == GDB_ID_NULL) { - nT1Id = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; - if ( nT1Id == GDB_ID_NULL) - return false ; - m_pGeomDB->SetName( nT1Id, SAW_T1) ; - m_pGeomDB->SetMaterial( nT1Id, BLUE) ; - } - // altrimenti lo svuoto - else - m_pGeomDB->EmptyGroup( nT1Id) ; - // elaboro le singole curve - for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) { - // recupero la curva (per ora linea) - PtrOwner pCurve( GetCurve( m_vId[i])) ; - if ( IsNull( pCurve) || pCurve->GetType() != CRV_LINE) { - string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Sawing" ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) ; - continue ; - } - // calcolo i versori fresa e correzione - Vector3d vtTool, vtCorr ; - if ( ! CalculateToolAndCorrVersors( Get( pCurve), vtTool, vtCorr)) { - string sOut = "Entity " + ToString( m_vId[i]) + " non versorable by Sawing" ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) ; - continue ; - } - // correzioni per lato lama, lato mandrino - if ( ! AdjustForSide( Get( pCurve))) { - string sOut = "Entity " + ToString( m_vId[i]) + " non offsetable by Sawing" ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) ; - continue ; - } - // aggiungo affondamento - pCurve->Translate( - vtCorr * m_Params.m_dDepth) ; - // imposto dati comuni - SetPathId( nT1Id) ; - SetOrigId( m_vId[i]) ; - SetToolDir( vtTool) ; - SetCorrDir( vtCorr) ; - // 1 -> punto iniziale - Point3d ptP1 ; - pCurve->GetStartPoint( ptP1) ; - if ( AddStart( ptP1) == GDB_ID_NULL) - return false ; - // 2 -> punto finale - SetFeed( m_TParams.m_dFeed) ; - Point3d ptP2 ; - pCurve->GetEndPoint( ptP2) ; - if ( AddLinearMove( ptP2) == GDB_ID_NULL) - return false ; - - } - - return true ; -#endif } //---------------------------------------------------------------------------- @@ -466,9 +534,205 @@ Sawing::Chain( int nGrpDestId) //---------------------------------------------------------------------------- bool -Sawing::PathApply( int nPathId) +Sawing::PathApply( int nPathId, int nClId) { - + // recupero gruppo per geometria temporanea + const string GRP_TEMP = "Temp" ; + int nTempId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, GRP_TEMP) ; + // se non c'è, lo aggiungo + if ( nTempId == GDB_ID_NULL) { + nTempId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nTempId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nTempId, GRP_TEMP) ; + } + // altrimenti lo svuoto + else + m_pGeomDB->EmptyGroup( nTempId) ; + // in ogni caso lo dichiaro temporaneo e non visibile + m_pGeomDB->SetLevel( nTempId, GDB_LV_TEMP) ; + m_pGeomDB->SetStatus( nTempId, GDB_ST_OFF) ; + + // copio la curva composita da elaborare + int nCrvId = m_pGeomDB->GetFirstInGroup( nPathId) ; + if ( m_pGeomDB->GetGeoType( nCrvId) != CRV_COMPO) + return false ; + int nCopyId = m_pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nTempId) ; + if ( nCopyId == GDB_ID_NULL) + return false ; + ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ; + + // elaboro la curva composita e la esplodo nelle curve componenti + if ( m_Params.m_nCurveUse == SAW_CRV_APPROX || + m_Params.m_nCurveUse == SAW_CRV_CONVEX) { + // calcolo l'approssimazione lineare con eventuale convessità + PolyLine PL ; + int nType = ICurve::APL_STD ; + if ( m_Params.m_nWorkSide == SAW_WS_LEFT) + nType = (( m_Params.m_nCurveUse == SAW_CRV_APPROX) ? ICurve::APL_LEFT : ICurve::APL_LEFT_CONVEX) ; + else if ( m_Params.m_nWorkSide == SAW_WS_RIGHT) + nType = (( m_Params.m_nCurveUse == SAW_CRV_APPROX) ? ICurve::APL_RIGHT : ICurve::APL_RIGHT_CONVEX) ; + if ( ! pCompo->ApproxWithLines( m_Params.m_dApprox, ANG_RIGHT, nType, PL)) + return false ; + // salvo estrusione e spessore + Vector3d vtExtr ; + pCompo->GetExtrusion( vtExtr) ; + double dThick ; + pCompo->GetThickness( dThick) ; + // sostituisco la curva composita con la sua approssimazione + if ( ! pCompo->Clear() || ! pCompo->FromPolyLine( PL)) + return false ; + // assegno estrusione e spessore originali + pCompo->SetExtrusion( vtExtr) ; + pCompo->SetThickness( dThick) ; + } + + // se lama non centrata e richiesto, eseguo offset + if ( m_Params.m_nWorkSide != SAW_WS_CENTER && fabs( m_TParams.m_dOffsL) > EPS_SMALL) { + double dOffs = ( m_Params.m_nWorkSide == SAW_WS_RIGHT) ? m_TParams.m_dOffsL : - m_TParams.m_dOffsL ; + if ( ! pCompo->SimpleOffset( dOffs, ICurve::OFF_EXTEND)) + return false ; + } + + // unisco le parti allineate + if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL)) + return false ; + + // eventuale inversione percorso + if ( m_Params.m_bInvert) + pCompo->Invert() ; + + // recupero estrusione e spessore + Vector3d vtExtr ; + pCompo->GetExtrusion( vtExtr) ; + double dThick ; + pCompo->GetThickness( dThick) ; + + // valuto l'espressione dell'affondamento + string sExec = "TH=" + (( dThick * vtExtr.z < 0) ? ToString( fabs( dThick)) : ToString( 0)) ; + ExeLuaExecLine( sExec) ; + double dDepth ; + if ( ! ExeLuaEvalNumExpr( m_Params.m_sDepth, &dDepth)) { + string sOut = "Depth non calculable by Sawing" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + return false ; + } + + // recupero nome del path + string sPathName ; + m_pGeomDB->GetName( nPathId, sPathName) ; + + // ciclo sulle curve elementari + bool bClosed = pCompo->IsClosed() ; + int nMaxInd = pCompo->GetCurveNumber() - 1 ; + for ( int i = 0 ; i <= nMaxInd ; ++ i) { + // curva precedente + int j = (( i == 0 && bClosed) ? nMaxInd : i - 1) ; + const ICurve* pCrvP = pCompo->GetCurve( j) ; ; + // curva corrente + const ICurve* pCrvC = pCompo->GetCurve( i) ; + // curva successiva + int k = (( i == nMaxInd && bClosed) ? 0 : i + 1) ; + const ICurve* pCrvN = pCompo->GetCurve( k) ; + // elaborazioni sulla curva corrente + string sName = sPathName + "_" + ToString( i) ; + if ( ! EntityApply( pCrvP, pCrvC, pCrvN, dDepth, i == 0, i == nMaxInd, sName, nClId)) + return false ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, + double dDepth, bool bIsFirst, bool bIsLast, const string& sName, 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 + Vector3d vtTool, vtCorr ; + if ( ! CalculateToolAndCorrVersors( Get( pLine), vtTool, vtCorr)) { + string sOut = "Entity non versorable by Sawing" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + return false ; + } + // correzioni per lato lama, lato mandrino + if ( ! AdjustForSide( Get( pLine))) { + string sOut = "Entity non offsetable by Sawing" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + return false ; + } + // aggiungo affondamento + pLine->Translate( - vtCorr * dDepth) ; + // calcolo elevazione + double dElev ; + if ( ! GetElevation( pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev)) { + string sOut = "Entity non elevation-enabled by Sawing" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + return false ; + } + // direzione linea corrente + Vector3d vtDirC ; + pLine->GetStartDir( vtDirC) ; + // calcolo tipo angolo con precedente + bool bExtAngPC = true ; + if ( pCrvP != nullptr) { + Vector3d vtDirP ; + pCrvP->GetEndDir( vtDirP) ; + double dAngPC ; + vtDirP.GetAngleXY( vtDirC, dAngPC) ; + if ( ( m_Params.m_nWorkSide == SAW_WS_LEFT && dAngPC > EPS_ANG_SMALL) || + ( m_Params.m_nWorkSide == SAW_WS_RIGHT && dAngPC < - EPS_ANG_SMALL)) + bExtAngPC = false ; + } + // calcolo tipo angolo con successivo + bool bExtAngCN = true ; + if ( pCrvN != nullptr) { + Vector3d vtDirN ; + pCrvN->GetStartDir( vtDirN) ; + double dAngCN ; + vtDirC.GetAngleXY( vtDirN, dAngCN) ; + if ( ( m_Params.m_nWorkSide == SAW_WS_LEFT && dAngCN > EPS_ANG_SMALL) || + ( m_Params.m_nWorkSide == SAW_WS_RIGHT && dAngCN < - EPS_ANG_SMALL)) + bExtAngCN = false ; + } + // aggiusto per tipo estremi + AdjustForEdges( Get( pLine), dElev, bIsFirst, bIsLast, bExtAngPC, bExtAngCN) ; + // recupero distanza di approccio + double dAppr = GetApproachDist() ; + // imposto dati comuni + SetPathId( nPxId) ; + SetToolDir( vtTool) ; + SetCorrDir( vtCorr) ; + // 1 -> punto sopra inizio + Point3d ptP1 = pLine->GetStart() + vtCorr * ( dElev + dAppr) ; + if ( AddStart( ptP1) == GDB_ID_NULL) + return false ; + // 2 -> movimento al punto iniziale + SetFeed( m_TParams.m_dTipFeed) ; + Point3d ptP2 = pLine->GetStart() ; + if ( AddLinearMove( ptP2) == GDB_ID_NULL) + return false ; + // 3 -> movimento al punto finale + SetFeed( m_TParams.m_dFeed) ; + Point3d ptP3 = pLine->GetEnd() ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + // 4 -> movimento di risalita sopra il punto finale + SetFeed( m_TParams.m_dFeed) ; + Point3d ptP4 = pLine->GetEnd() + vtCorr * ( dElev + dAppr) ; + if ( AddLinearMove( ptP4) == GDB_ID_NULL) + return false ; return true ; } @@ -512,4 +776,64 @@ Sawing::AdjustForSide( ICurve* pCurve) dOffs = - 0.5 * m_TParams.m_dThick ; // eseguo offset curva ( nel piano XY globale) return pCurve->SimpleOffset( dOffs) ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +bool +Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN) +{ + // 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) ; + // verifiche e aggiustamenti sull'inizio + double dDeltaI = 0 ; + if ( ! bExtAngPC) + dDeltaI = - dDeltaT ; + else if ( bIsFirst) { + if ( m_Params.m_nLeadInType == SAW_LI_STRICT) + dDeltaI = - dDeltaT ; + else if ( m_Params.m_nLeadInType == SAW_LI_OUT) + dDeltaI = dDeltaT ; + else if ( m_Params.m_nLeadInType == SAW_LI_EXT_CENT) + ; // estendere al bordo del grezzo + else if ( m_Params.m_nLeadInType == SAW_LI_EXT_OUT) + ; // estendere al bordo del grezzo e aggiungere dDeltaT + } + else { + if ( m_Params.m_nExtLinkType == SAW_EL_EXT_NEXT || + m_Params.m_nExtLinkType == SAW_EL_EXT_BOTH) { + ; // estendere al bordo del grezzo se LeadIn EXT_OUT aggiungere dDeltaT + } + } + // verifiche e aggiustamenti sulla fine + double dDeltaF = 0 ; + if ( ! bExtAngCN) + dDeltaF = - dDeltaT ; + else if ( bIsLast) { + if ( m_Params.m_nLeadOutType == SAW_LI_STRICT) + dDeltaF = - dDeltaT ; + else if ( m_Params.m_nLeadInType == SAW_LO_EXT) + ; // estendere al bordo del grezzo + } + else { + if ( m_Params.m_nExtLinkType == SAW_EL_EXT_PREV || + m_Params.m_nExtLinkType == SAW_EL_EXT_BOTH) { + ; // estendere al bordo del grezzo + } + } + // controllo se lunghezza entità accettabile + const double MIN_LEN = 10 ; + double dLenXY = DistXY( pLine->GetStart(), pLine->GetEnd()) ; + if ( dDeltaI + dLenXY + dDeltaF < MIN_LEN) + return false ; + // modifico gli estremi + if ( dDeltaF > EPS_SMALL) + pLine->ExtendEndByLen( dDeltaF) ; + else if ( dDeltaF < - EPS_SMALL) + pLine->TrimEndAtLen( dLenXY + dDeltaF) ; + if ( dDeltaI > EPS_SMALL) + pLine->ExtendStartByLen( dDeltaI) ; + else if ( dDeltaI < - EPS_SMALL) + pLine->TrimStartAtLen( fabs( dDeltaI)) ; + + return true ; +} diff --git a/Sawing.h b/Sawing.h index a94c2d2..3cdfa9d 100644 --- a/Sawing.h +++ b/Sawing.h @@ -18,6 +18,7 @@ #include "ToolData.h" class ICurve ; +class ICurveLine ; //---------------------------------------------------------------------------- class Sawing : public Machining @@ -32,9 +33,12 @@ class Sawing : public Machining public : // Machining virtual bool Prepare( const std::string& sSawName) ; + virtual bool SetParam( int nType, bool bVal) ; + virtual bool SetParam( int nType, int nVal) ; + 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 PathApply( int nPathId) ; public : Sawing( void) ; @@ -43,8 +47,12 @@ class Sawing : public Machining bool VerifyGeometry( SelData Id, int& nSubs) ; ICurve* GetCurve( SelData Id) ; bool Chain( int nGrpDestId) ; + bool PathApply( int nPathId, int nClId) ; + bool EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN, + double dDepth, bool bIsFirst, bool bIsLast, const std::string& sName, int nClId) ; bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ; bool AdjustForSide( ICurve* pCurve) ; + bool AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN) ; private : SELVECTOR m_vId ; // identificativi entità geometriche da lavorare diff --git a/SawingData.cpp b/SawingData.cpp index 50ca1c9..24c272a 100644 --- a/SawingData.cpp +++ b/SawingData.cpp @@ -15,6 +15,8 @@ #include "stdafx.h" #include "SawingData.h" #include "MachiningDataFactory.h" +#include "/EgtDev/Include/EMkMachiningConst.h" +#include "/EgtDev/Include/EGkGeoConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -129,7 +131,7 @@ SawingData::FromString( const string& sString, int& nKey) bOk = ::FromString( sVal, m_dSideAngle) ; break ; case KEY_TAF : - bOk = ::FromString( sVal, m_bToAndFro) ; + bOk = ::FromString( sVal, m_bToAndFrom) ; break ; case KEY_TNAME : m_sToolName = sVal ; @@ -166,7 +168,7 @@ SawingData::ToString( int nInd) const case KEY_LOTY : return ( sSawingKey[KEY_LOTY] + "=" + ::ToString( m_nLeadOutType)) ; case KEY_NAME : return ( sSawingKey[KEY_NAME] + "=" + m_sName) ; case KEY_SA : return ( sSawingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ; - case KEY_TAF : return ( sSawingKey[KEY_TAF] + "=" + ::ToString( m_bToAndFro)) ; + case KEY_TAF : return ( sSawingKey[KEY_TAF] + "=" + ::ToString( m_bToAndFrom)) ; case KEY_TNAME : return ( sSawingKey[KEY_TNAME] + "=" + m_sToolName) ; case KEY_TUUID : return ( sSawingKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ; case KEY_UUID : return ( sSawingKey[KEY_UUID] + "=" + ::ToString( m_Uuid)) ; @@ -174,3 +176,71 @@ SawingData::ToString( int nInd) const default : return "" ; } } + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyWorkSide( int nVal) const +{ + return ( nVal == SAW_WS_CENTER || nVal == SAW_WS_LEFT || nVal == SAW_WS_RIGHT) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyHeadSide( int nVal) const +{ + return ( nVal == SAW_HS_LEFT || nVal == SAW_HS_RIGHT) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyLeadInType( int nVal) const +{ + return ( nVal == SAW_LI_STRICT || nVal == SAW_LI_CENT || nVal == SAW_LI_OUT || + nVal == SAW_LI_EXT_CENT || nVal == SAW_LI_EXT_OUT) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyExtLinkType( int nVal) const +{ + return ( nVal == SAW_EL_CENT || nVal == SAW_EL_EXT_PREV || nVal == SAW_EL_EXT_NEXT || + nVal == SAW_EL_EXT_BOTH) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyLeadOutType( int nVal) const +{ + return ( nVal == SAW_LO_STRICT || nVal == SAW_LO_CENT || nVal == SAW_LO_EXT) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyCurveUse( int nVal) const +{ + return ( nVal == SAW_CRV_SKIP || nVal == SAW_CRV_APPROX || nVal == SAW_CRV_CONVEX) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifySideAngle( double dVal) const +{ + return ( ( dVal > - EPS_SMALL && dVal < 60 + EPS_SMALL) || fabs( dVal - 99) < EPS_SMALL) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const +{ + if ( pMachMgr == nullptr) + return false ; + ToolsMgr* pTMgr = pMachMgr->GetCurrToolsMgr() ; + if ( pTMgr == nullptr) + return false ; + pTdata = pTMgr->GetTool( sVal) ; + if ( pTdata == nullptr) + return false ; + if ( ( pTdata->m_nType & TF_SAWBLADE) == 0) + return false ; + return true ; +} diff --git a/SawingData.h b/SawingData.h index 6cc0f11..c9ce324 100644 --- a/SawingData.h +++ b/SawingData.h @@ -14,6 +14,7 @@ #pragma once #include "MachiningData.h" +#include "MachMgr.h" //---------------------------------------------------------------------------- struct SawingData : public MachiningData @@ -23,7 +24,7 @@ struct SawingData : public MachiningData bool m_bInvert ; // flag di inversione direzione lavorazione int m_nWorkSide ; // lato di lavoro (destra, sinistra, centro) int m_nHeadSide ; // lato di posizionamento del mandrino ( destra o sinistra) - bool m_bToAndFro ; // taglio avanti-indietro + bool m_bToAndFrom ; // taglio avanti-indietro std::string m_sDepth ; // affondamento (espressione numerica) double m_dSideAngle ; // angolo di sbandamento (0..+60deg, 99=auto) int m_nLeadInType ; // tipo di attacco (interno, centro, fuori, esteso, esteso fuori) @@ -31,44 +32,27 @@ struct SawingData : public MachiningData int m_nLeadOutType ; // tipo di uscita (interno, centro, esteso) int m_nCurveUse ; // gestione delle curve(salta, approssima, convesso) double m_dApprox ; // valore di approssimazione per curve + SawingData( void) - : m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_bToAndFro( false), m_dSideAngle( 0), + : m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_bToAndFrom( false), m_dSideAngle( 0), m_nLeadInType( 0), m_nExtLinkType( 0), m_nLeadOutType( 0), m_nCurveUse( 0), m_dApprox( 0) {} + virtual int GetType( void) const { return MT_SAWING ; } virtual int GetSize( void) const ; virtual std::string GetTitle( void) const ; virtual bool FromString( const std::string& sString, int& nKey) ; virtual std::string ToString( int nInd) const ; + + bool VerifyWorkSide( int nVal) const ; + bool VerifyHeadSide( int nVal) const ; + bool VerifyLeadInType( int nVal) const ; + bool VerifyExtLinkType( int nVal) const ; + bool VerifyLeadOutType( int nVal) const ; + bool VerifyCurveUse( int nVal) const ; + bool VerifySideAngle( double dVal) const ; + bool VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const ; } ; //---------------------------------------------------------------------------- inline const SawingData* GetSawingData( const MachiningData* pMdata) { return (dynamic_cast( pMdata)) ; } - -//---------------------------------------------------------------------------- -// Lato di lavoro della lama -enum { SAW_WS_CENTER = 0, - SAW_WS_LEFT = 1, - SAW_WS_RIGHT = 2 } ; -// Lato di posizionamento della testa -enum { SAW_HS_LEFT = 1, - SAW_HS_RIGHT = 2 } ; -// Tipo di attacco con lama -enum { SAW_LI_STRICT = 0, - SAW_LI_CENT = 1, - SAW_LI_OUT = 2, - SAW_LI_EXT_CENT = 3, - SAW_LI_EXT_OUT = 4} ; -// Tipo di uscita con lama -enum { SAW_LO_STRICT = 0, - SAW_LO_CENT = 1, - SAW_LO_EXT = 2} ; -// Tipo di link esterno con lama -enum { SAW_EL_CENT = 0, - SAW_EL_EXT_PREV = 1, - SAW_EL_EXT_NEXT = 2, - SAW_EL_EXT_SMALLER = 3} ; -// Gestione curve -enum { SAW_CRV_SKIP = 0, - SAW_CRV_APPROX = 1, - SAW_CRV_CONVEX = 2} ; diff --git a/ToolData.cpp b/ToolData.cpp index c4ee4f8..6381c87 100644 --- a/ToolData.cpp +++ b/ToolData.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "ToolData.h" +#include "/EgtDev/Include/EGkGeoConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -229,3 +230,10 @@ ToolData::ToString( int nInd) const default : return "" ; } } + +//---------------------------------------------------------------------------- +bool +ToolData::VerifySpeed( double dVal) const +{ + return ( dVal < m_dMaxSpeed + EPS_SMALL) ; +} diff --git a/ToolData.h b/ToolData.h index 4a7b6b6..5d1ffad 100644 --- a/ToolData.h +++ b/ToolData.h @@ -45,14 +45,18 @@ struct ToolData double m_dOffsL ; // offset longitudinale std::string m_sSysNotes ; // note interne std::string m_sUserNotes ; // note dell'utente + ToolData( void) : m_Uuid(), m_nExit( 0), m_nCorr(0), m_nType(0), m_dMaxSpeed(0), m_dMaxMat(0), m_dDiam( 0), m_dTDiam( 0), m_dLen( 0), m_dTLen( 0), m_dThick( 0), m_dCornRad( 0), m_dSideAng( 0), m_dSpeed( 0), m_dFeed(0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dOffsR( 0), m_dOffsL( 0) {} + int GetSize( void) const ; bool FromString( const std::string& sString, int& nKey) ; std::string ToString( int nInd) const ; + + bool VerifySpeed( double dVal) const ; } ; //----------------------------------------------------------------------------