From b96b43e1ece1d7df1712f875f763b70c99e9d468 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 16 Jun 2015 07:43:02 +0000 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=201.6f2=20:=20-=20aggiunto=20User?= =?UTF-8?q?Obj=20CamData=20per=20rappresentare=20dati=20tipo=20CL=20in=20e?= =?UTF-8?q?ntit=C3=A0=20geometriche=20-=20possibilit=C3=A0=20di=20ruotare?= =?UTF-8?q?=20i=20sottopezzi=20-=20aggiunto=20calcolo=20percorsi=20di=20la?= =?UTF-8?q?vorazione=20di=20fori=20-=20aggiunte=20prime=20versioni=20parzi?= =?UTF-8?q?ali=20di=20taglio=20con=20lama=20e=20fresatura.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Axis.cpp | 6 +- Axis.h | 6 +- CamData.cpp | 463 ++++++++++++++++++++++++++++++++ CamData.h | 70 +++++ Disposition.cpp | 133 +++++---- Disposition.h | 28 +- Drilling.cpp | 488 +++++++++++++++++++++++++++++----- Drilling.h | 77 ++---- EgtMachKernel.rc | Bin 11774 -> 11774 bytes EgtMachKernel.vcxproj | 9 + EgtMachKernel.vcxproj.filters | 27 ++ Exit.cpp | 6 +- Exit.h | 6 +- Head.cpp | 6 +- Head.h | 6 +- MachConst.h | 5 + MachMgr.h | 12 +- MachMgrBasic.cpp | 1 + MachMgrFixtures.cpp | 8 +- MachMgrMachGroups.cpp | 7 +- MachMgrMachines.cpp | 18 ++ MachMgrOperations.cpp | 111 +++++++- MachMgrRawParts.cpp | 8 +- Machine.cpp | 18 +- Machining.cpp | 210 +++++++++++++++ Machining.h | 70 +++++ Milling.cpp | 171 ++++++++++++ Milling.h | 43 +++ Sawing.cpp | 348 ++++++++++++++++++++++++ Sawing.h | 51 ++++ SawingData.h | 14 + Table.cpp | 6 +- Table.h | 6 +- 33 files changed, 2206 insertions(+), 232 deletions(-) create mode 100644 CamData.cpp create mode 100644 CamData.h create mode 100644 Machining.cpp create mode 100644 Machining.h create mode 100644 Milling.cpp create mode 100644 Milling.h create mode 100644 Sawing.cpp create mode 100644 Sawing.h diff --git a/Axis.cpp b/Axis.cpp index d3beb03..1a27928 100644 --- a/Axis.cpp +++ b/Axis.cpp @@ -16,19 +16,19 @@ #include "Axis.h" #include "MachConst.h" #include "/EgtDev/Include/EGkGdbConst.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGkStringUtils3d.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkAxis", Axis) ; +USEROBJ_REGISTER( "EMkAxis", Axis) ; //---------------------------------------------------------------------------- const string& Axis::GetClassName( void) const { - return OBJUSER_GETNAME( Axis) ; + return USEROBJ_GETNAME( Axis) ; } //---------------------------------------------------------------------------- diff --git a/Axis.h b/Axis.h index 2572332..b49d540 100644 --- a/Axis.h +++ b/Axis.h @@ -14,13 +14,13 @@ #pragma once #include "Machine.h" -#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkUserObj.h" #include "/EgtDev/Include/EGkPoint3d.h" //---------------------------------------------------------------------------- -class Axis : public IObjUser +class Axis : public IUserObj { - public : + public : // IUserObj virtual Axis* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; diff --git a/CamData.cpp b/CamData.cpp new file mode 100644 index 0000000..38e9c99 --- /dev/null +++ b/CamData.cpp @@ -0,0 +1,463 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : CamData.cpp Data : 10.06.15 Versione : 1.6f2 +// Contenuto : Implementazione informazioni Cam di ogni movimento. +// +// +// +// Modifiche : 10.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "CamData.h" +#include "/EgtDev/Include/EGkGeomDB.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EGnStringKeyVal.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +static int CAM_TOTPARAM = 8 ; +static std::string CAM_ORID = "OrId" ; +static std::string CAM_CORR = "Corr" ; +static std::string CAM_TDIR = "TDir" ; +static std::string CAM_CDIR = "CDir" ; +static std::string CAM_ADIR = "ADir" ; +static std::string CAM_PBAS = "PBas" ; +static std::string CAM_FEED = "Feed" ; +static std::string CAM_FLAG = "Flg" ; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EMkCamData", CamData) ; + +//---------------------------------------------------------------------------- +const string& +CamData::GetClassName( void) const +{ + return USEROBJ_GETNAME( CamData) ; +} + +//---------------------------------------------------------------------------- +CamData* +CamData::Clone( void) const +{ + // alloco oggetto + CamData* pCam = new(nothrow) CamData ; + // eseguo copia dei dati + if ( pCam != nullptr) { + 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 ; + pCam->m_vtAux = m_vtAux ; + pCam->m_dFeed = m_dFeed ; + pCam->m_nFlag = m_nFlag ; + } + catch( ...) { + delete pCam ; + return nullptr ; + } + } + // ritorno l'oggetto + return pCam ; +} + +//---------------------------------------------------------------------------- +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 ; + sOut += CAM_ADIR + "=" + ToString( m_vtAux) + szNewLine ; + sOut += CAM_PBAS + "=" + ToString( m_ptBase) + szNewLine ; + sOut += CAM_FEED + "=" + ToString( m_dFeed) + szNewLine ; + sOut += CAM_FLAG + "=" + ToString( m_nFlag) + szNewLine ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetOwner( int nId, IGeomDB* pGDB) +{ + m_nOwnerId = nId ; + m_pGeomDB = pGDB ; + return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ; +} + +//---------------------------------------------------------------------------- +int +CamData::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +IGeomDB* +CamData::GetGeomDB( void) const +{ + return m_pGeomDB ; +} + +//---------------------------------------------------------------------------- +bool +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) ; + vString[++k] = CAM_ADIR + "=" + ToString( m_vtAux) ; + vString[++k] = CAM_PBAS + "=" + ToString( m_ptBase) ; + vString[++k] = CAM_FEED + "=" + ToString( m_dFeed) ; + vString[++k] = CAM_FLAG + "=" + ToString( m_nFlag) ; + } + catch( ...) { + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +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) || + ! GetVal( vString[++k], CAM_TDIR, m_vtTool) || + ! GetVal( vString[++k], CAM_CDIR, m_vtCorr) || + ! GetVal( vString[++k], CAM_ADIR, m_vtAux) || + ! GetVal( vString[++k], CAM_PBAS, m_ptBase) || + ! GetVal( vString[++k], CAM_FEED, m_dFeed) || + ! GetVal( vString[++k], CAM_FLAG, m_nFlag)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::GetDrawPolyLines( POLYLINELIST& lstPL) const +{ + bool bToDraw = false ; + // se vettore fresa non nullo + if ( ! m_vtTool.IsSmall()) { + bToDraw = true ; + // aggiungo polilinea alla lista + lstPL.emplace_back() ; + PolyLine& PL = lstPL.back() ; + // dimensioni + const double TLEN = 40 ; + const double ALEN = 4 ; + // inserisco disegno nella polilinea + PL.AddUPoint( 0, m_ptBase) ; + Point3d ptTip = m_ptBase + m_vtTool * TLEN ; + PL.AddUPoint( 1, ptTip) ; + // aggiungo simil-freccia + Frame3d frF ; + frF.Set( ptTip, m_vtTool) ; + Point3d ptP2 = ORIG + Vector3d( ALEN, 0, -ALEN) ; + ptP2.ToGlob( frF) ; + PL.AddUPoint( 2, ptP2) ; + Point3d ptP3 = ORIG + Vector3d( -ALEN, 0, -ALEN) ; + ptP3.ToGlob( frF) ; + PL.AddUPoint( 3, ptP3) ; + PL.AddUPoint( 4, ptTip) ; + Point3d ptP5 = ORIG + Vector3d( 0, ALEN, -ALEN) ; + ptP5.ToGlob( frF) ; + PL.AddUPoint( 5, ptP5) ; + Point3d ptP6 = ORIG + Vector3d( 0, -ALEN, -ALEN) ; + ptP6.ToGlob( frF) ; + PL.AddUPoint( 6, ptP6) ; + PL.AddUPoint( 6, ptTip) ; + } + // se vettore correzione non nullo + if ( ! m_vtCorr.IsSmall()) { + bToDraw = true ; + // aggiungo polilinea alla lista + lstPL.emplace_back() ; + PolyLine& PL = lstPL.back() ; + // dimensioni + const double CLEN = 20 ; + const double ALEN = 2 ; + // inserisco disegno nella polilinea + PL.AddUPoint( 0, m_ptBase) ; + Point3d ptTip = m_ptBase + m_vtCorr * CLEN ; + PL.AddUPoint( 1, ptTip) ; + // aggiungo simil-freccia + Frame3d frF ; + if ( m_vtTool. IsSmall()) + frF.Set( ptTip, m_vtCorr) ; + else + frF.Set( ptTip, m_vtCorr, m_vtTool) ; + Point3d ptP2 = ORIG + Vector3d( 0, ALEN, 0) ; + ptP2.ToGlob( frF) ; + PL.AddUPoint( 2, ptP2) ; + Point3d ptP3 = ORIG + Vector3d( 0, ALEN, - ALEN) ; + ptP3.ToGlob( frF) ; + PL.AddUPoint( 3, ptP3) ; + Point3d ptP4 = ORIG + Vector3d( 0, 0, - ALEN) ; + ptP4.ToGlob( frF) ; + PL.AddUPoint( 4, ptP4) ; + } + // se vettore ausiliario non nullo + if ( ! m_vtAux.IsSmall()) { + bToDraw = true ; + // aggiungo polilinea alla lista + lstPL.emplace_back() ; + PolyLine& PL = lstPL.back() ; + // dimensioni + const double CLEN = 20 ; + const double ALEN = 2 ; + // inserisco disegno nella polilinea + PL.AddUPoint( 0, m_ptBase) ; + Point3d ptTip = m_ptBase + m_vtAux * CLEN ; + PL.AddUPoint( 1, ptTip) ; + // aggiungo simil-freccia + Frame3d frF ; + if ( m_vtTool. IsSmall()) + frF.Set( ptTip, m_vtAux) ; + else + frF.Set( ptTip, m_vtAux, m_vtTool) ; + Point3d ptP2 = ORIG + Vector3d( 0, ALEN, - 0.5 * ALEN) ; + ptP2.ToGlob( frF) ; + PL.AddUPoint( 2, ptP2) ; + Point3d ptP3 = ORIG + Vector3d( 0, 0, - ALEN) ; + ptP3.ToGlob( frF) ; + PL.AddUPoint( 3, ptP3) ; + } + + return bToDraw ; +} + +//---------------------------------------------------------------------------- +bool +CamData::Translate( const Vector3d& vtMove) +{ + m_ptBase.Translate( vtMove) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) +{ + if ( ! m_ptBase.Rotate( ptAx, vtAx, dCosAng, dSinAng)) + return false ; + if ( ! m_vtTool.Rotate( vtAx, dCosAng, dSinAng)) + return false ; + if ( ! m_vtCorr.Rotate( vtAx, dCosAng, dSinAng)) + return false ; + if ( ! m_vtAux.Rotate( vtAx, dCosAng, dSinAng)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) +{ + if ( ! m_ptBase.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ)) + return false ; + if ( ! m_vtTool.IsSmall()) { + if ( ! m_vtTool.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) || ! m_vtTool.Normalize()) + return false ; + } + if ( ! m_vtCorr.IsSmall()) { + double dLen = m_vtCorr.Len() ; + if ( ! m_vtCorr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) || ! m_vtCorr.Normalize()) + return false ; + m_vtCorr *= dLen ; + } + if ( ! m_vtAux.IsSmall()) { + if ( ! m_vtAux.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) || ! m_vtAux.Normalize()) + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) +{ + if ( ! m_ptBase.Mirror( ptOn, vtNorm)) + return false ; + if ( ! m_vtTool.Mirror( vtNorm)) + return false ; + if ( ! m_vtCorr.Mirror( vtNorm)) + return false ; + if ( ! m_vtAux.Mirror( vtNorm)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) +{ + if ( ! m_ptBase.Shear( ptOn, vtNorm, vtDir, dCoeff)) + return false ; + if ( ! m_vtTool.IsSmall()) { + if ( ! m_vtTool.Shear( vtNorm, vtDir, dCoeff) || ! m_vtTool.Normalize()) + return false ; + } + if ( ! m_vtCorr.IsSmall()) { + double dLen = m_vtCorr.Len() ; + if ( ! m_vtCorr.Shear( vtNorm, vtDir, dCoeff) || ! m_vtCorr.Normalize()) + return false ; + m_vtCorr *= dLen ; + } + if ( ! m_vtAux.IsSmall()) { + if ( ! m_vtAux.Shear( vtNorm, vtDir, dCoeff) || ! m_vtAux.Normalize()) + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::ToGlob( const Frame3d& frRef) +{ + if ( ! m_ptBase.ToGlob( frRef)) + return false ; + if ( ! m_vtTool.ToGlob( frRef)) + return false ; + if ( ! m_vtCorr.ToGlob( frRef)) + return false ; + if ( ! m_vtAux.ToGlob( frRef)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::ToLoc( const Frame3d& frRef) +{ + if ( ! m_ptBase.ToLoc( frRef)) + return false ; + if ( ! m_vtTool.ToLoc( frRef)) + return false ; + if ( ! m_vtCorr.ToLoc( frRef)) + return false ; + if ( ! m_vtAux.ToLoc( frRef)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) +{ + if ( ! m_ptBase.LocToLoc( frOri, frDest)) + return false ; + if ( ! m_vtTool.LocToLoc( frOri, frDest)) + return false ; + if ( ! m_vtCorr.LocToLoc( frOri, frDest)) + return false ; + if ( ! m_vtAux.LocToLoc( frOri, frDest)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +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) +{ + m_vtTool = vtDir ; + ResetObjGraphics() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetCorrDir( const Vector3d& vtDir) +{ + m_vtCorr = vtDir ; + ResetObjGraphics() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetAuxDir( const Vector3d& vtDir) +{ + m_vtAux = vtDir ; + ResetObjGraphics() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetBasePoint( const Point3d& ptBase) +{ + m_ptBase = ptBase ; + ResetObjGraphics() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetFeed( double dFeed) +{ + m_dFeed = dFeed ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +CamData::SetFlag( int nFlag) +{ + m_nFlag = nFlag ; + return true ; +} + +//---------------------------------------------------------------------------- +void +CamData::ResetObjGraphics( void) +{ + if ( m_pGeomDB == nullptr) + return ; + IGeoObj* pGeo = m_pGeomDB->GetGeoObj( m_nOwnerId) ; + if ( pGeo == nullptr) + return ; + IObjGraphics* pGraph = pGeo->GetObjGraphics() ; + if ( pGraph == nullptr) + return ; + pGraph->Reset() ; +} diff --git a/CamData.h b/CamData.h new file mode 100644 index 0000000..35055b2 --- /dev/null +++ b/CamData.h @@ -0,0 +1,70 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : CamData.h Data : 10.06.15 Versione : 1.6f2 +// Contenuto : Dichiarazione della classe CamData. +// +// +// +// Modifiche : 10.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkVector3d.h" +#include "/EgtDev/Include/EGkUserObj.h" +#include "/EgtDev/Include/EGkSelection.h" + +//---------------------------------------------------------------------------- +class CamData : public IUserObj +{ + public : // IUserObj + virtual CamData* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool SetOwner( int nId, IGeomDB* pGDB) ; + virtual int GetOwner( void) const ; + virtual IGeomDB* GetGeomDB( void) const ; + virtual bool ToSave( void) const { return true ; } + virtual bool Save( STRVECTOR& vString) const ; + virtual bool Load( const STRVECTOR& vString) ; + virtual bool GetDrawPolyLines( POLYLINELIST& lstPL) const ; + virtual bool Translate( const Vector3d& vtMove) ; + virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) + { double dAngRad = dAngDeg * DEGTORAD ; + return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } + virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; + virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; + virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ; + virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ; + virtual bool ToGlob( const Frame3d& frRef) ; + virtual bool ToLoc( const Frame3d& frRef) ; + virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ; + + public : + CamData( void) ; + bool SetOrigId( SelData Id) ; + bool SetToolDir( const Vector3d& vtDir) ; + bool SetCorrDir( const Vector3d& vtDir) ; + bool SetAuxDir( const Vector3d& vtDir) ; + bool SetBasePoint( const Point3d& ptBase) ; + bool SetFeed( double dFeed) ; + bool SetFlag( int nFlag) ; + + private : + void ResetObjGraphics( void) ; + + 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 + Vector3d m_vtAux ; // versore ausiliario + Point3d m_ptBase ; // punto base per il disegno dei vettori + double m_dFeed ; // velocità di avanzamento in lavorazione + int m_nFlag ; // flag per usi vari +} ; \ No newline at end of file diff --git a/Disposition.cpp b/Disposition.cpp index d176f01..5bce452 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -18,20 +18,33 @@ #include "Disposition.h" #include "Table.h" #include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" #include "/EgtDev/Include/EGnFileUtils.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkDisposition", Disposition) ; +static std::string DIS_TABLE = "Tab" ; +static std::string DIS_FXD_TOT = "FxT" ; +static std::string DIS_FXD_NAME = "FxN" ; +static std::string DIS_FXD_POS = "FxP" ; +static std::string DIS_FXD_ANG = "FxA" ; +static std::string DIS_MVD_TOT = "MvT" ; +static std::string DIS_MVD_ID = "MvI" ; +static std::string DIS_MVD_TYPE = "MvT" ; +static std::string DIS_MVD_PNT = "MvP" ; +static std::string DIS_MVD_ANG = "MvA" ; +static std::string DIS_MVD_FLAG = "MvF" ; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EMkDisposition", Disposition) ; //---------------------------------------------------------------------------- const string& Disposition::GetClassName( void) const { - return OBJUSER_GETNAME( Disposition) ; + return USEROBJ_GETNAME( Disposition) ; } //---------------------------------------------------------------------------- @@ -64,25 +77,26 @@ Disposition::Dump( string& sOut, const char* szNewLine) const { sOut += GetClassName() + szNewLine ; sOut += "Tab=" + m_sTabName + ( m_bTabOk ? " (ok)" : " (to verify)") + szNewLine ; - for ( int i = 0 ; i < int( m_vFixData.size()) ; ++ i) { - sOut += "FxD=" + m_vFixData[i].sName + "," + - ToString( m_vFixData[i].nId) + ",(" + - ToString( m_vFixData[i].ptPos) + ")" + szNewLine ; + for ( const auto& FixData : m_vFixData) { + sOut += "FxD=" + FixData.sName + "," + + ToString( FixData.nId) + ",(" + + ToString( FixData.ptPos) + ")," + + ToString( FixData.dAng) + szNewLine ; } - for ( int i = 0 ; i < int( m_vMvrData.size()) ; ++ i) { - sOut += "MvD=" + ToString( m_vMvrData[i].nRawId) + "," ; - switch (m_vMvrData[i].nType) { + for ( const auto& MvrData : m_vMvrData) { + sOut += "MvD=" + ToString( MvrData.nRawId) + "," ; + switch ( MvrData.nType) { case MoveRawData::NONE : sOut += string( " NONE") + szNewLine ; break ; case MoveRawData::COR : - sOut += " COR,(" + ToString( m_vMvrData[i].ptP) + ")," + ToString( m_vMvrData[i].nFlag) + szNewLine ; + sOut += " COR,(" + ToString( MvrData.ptP) + ")," + ToString( MvrData.nFlag) + szNewLine ; break ; case MoveRawData::CEN : - sOut += " CEN,(" + ToString( m_vMvrData[i].ptP) + ")," + ToString( m_vMvrData[i].nFlag) + szNewLine ; + sOut += " CEN,(" + ToString( MvrData.ptP) + ")," + ToString( MvrData.nFlag) + szNewLine ; break ; case MoveRawData::ROT : - sOut += " ROT,(" + ToString( m_vMvrData[i].ptP) + ")" + szNewLine ; + sOut += " ROT,(" + ToString( MvrData.ptP) + ")" + szNewLine ; break ; } } @@ -96,7 +110,7 @@ Disposition::Save( STRVECTOR& vString) const try { int k = - 1 ; int nFxdTot = int( m_vFixData.size()) ; - int nFxdLines = 1 + 2 * nFxdTot ; + int nFxdLines = 1 + 3 * nFxdTot ; int nMvdTot = int( m_vMvrData.size()) ; int nMvdLines = 1 + 4 * nMvdTot ; vString.insert( vString.begin(), 1 + nFxdLines + nMvdLines, "") ; @@ -106,19 +120,20 @@ Disposition::Save( STRVECTOR& vString) const // dati sottopezzi if ( ! SetVal( DIS_FXD_TOT, nFxdTot, vString[++k])) return false ; - for ( int i = 0 ; i < nFxdTot ; ++ i) { - if ( ! SetVal( DIS_FXD_NAME, m_vFixData[i].sName, vString[++k]) || - ! SetVal( DIS_FXD_POS, m_vFixData[i].ptPos, vString[++k])) + for ( const auto& FixData : m_vFixData) { + if ( ! SetVal( DIS_FXD_NAME, FixData.sName, vString[++k]) || + ! SetVal( DIS_FXD_POS, FixData.ptPos, vString[++k]) || + ! SetVal( DIS_FXD_ANG, FixData.dAng, vString[++k])) return false ; } // dati posizionamento grezzi if ( ! SetVal( DIS_MVD_TOT, nMvdTot, vString[++k])) return false ; - for ( int i = 0 ; i < nMvdTot ; ++ i) { - if ( ! SetVal( DIS_MVD_ID, m_vMvrData[i].nRawId, vString[++k]) || - ! SetVal( DIS_MVD_TYPE, m_vMvrData[i].nType, vString[++k]) || - ! SetVal( DIS_MVD_PNT, m_vMvrData[i].ptP, vString[++k]) || - ! SetVal( DIS_MVD_FLAG, m_vMvrData[i].nFlag, vString[++k])) + for ( const auto& MvrData : m_vMvrData) { + if ( ! SetVal( DIS_MVD_ID, MvrData.nRawId, vString[++k]) || + ! SetVal( DIS_MVD_TYPE, MvrData.nType, vString[++k]) || + ! SetVal( DIS_MVD_PNT, MvrData.ptP, vString[++k]) || + ! SetVal( DIS_MVD_FLAG, MvrData.nFlag, vString[++k])) return false ; } } @@ -140,13 +155,14 @@ Disposition::Load( const STRVECTOR& vString) int nFxdTot ; if ( ! GetVal( vString[++k], DIS_FXD_TOT, nFxdTot)) return false ; - int nFxdLines = 1 + 2 * nFxdTot ; + int nFxdLines = 1 + 3 * nFxdTot ; if ( int( vString.size()) < 1 + nFxdLines + 1) return false ; m_vFixData.insert( m_vFixData.begin(), nFxdTot, FixtureData()) ; - for ( int i = 0 ; i < nFxdTot ; ++ i) { - if ( ! GetVal( vString[++k], DIS_FXD_NAME, m_vFixData[i].sName) || - ! GetVal( vString[++k], DIS_FXD_POS, m_vFixData[i].ptPos)) + for ( auto& FixData : m_vFixData) { + if ( ! GetVal( vString[++k], DIS_FXD_NAME, FixData.sName) || + ! GetVal( vString[++k], DIS_FXD_POS, FixData.ptPos) || + ! GetVal( vString[++k], DIS_FXD_ANG, FixData.dAng)) return false ; } // dati posizionamento grezzi @@ -157,11 +173,11 @@ Disposition::Load( const STRVECTOR& vString) if ( int( vString.size()) < 1 + nFxdLines + nMvdLines) return false ; m_vMvrData.insert( m_vMvrData.begin(), nMvdTot, MoveRawData()) ; - for ( int i = 0 ; i < nMvdTot ; ++ i) { - if ( ! GetVal( vString[++k], DIS_MVD_ID, m_vMvrData[i].nRawId) || - ! GetVal( vString[++k], DIS_MVD_TYPE, m_vMvrData[i].nType) || - ! GetVal( vString[++k], DIS_MVD_PNT, m_vMvrData[i].ptP) || - ! GetVal( vString[++k], DIS_MVD_FLAG, m_vMvrData[i].nFlag)) + for ( auto& MvrData : m_vMvrData) { + if ( ! GetVal( vString[++k], DIS_MVD_ID, MvrData.nRawId) || + ! GetVal( vString[++k], DIS_MVD_TYPE, MvrData.nType) || + ! GetVal( vString[++k], DIS_MVD_PNT, MvrData.ptP) || + ! GetVal( vString[++k], DIS_MVD_FLAG, MvrData.nFlag)) return false ; } return true ; @@ -244,36 +260,36 @@ bool Disposition::Apply(void) { // aggiornamento sottopezzi - for ( auto iIter = m_vFixData.begin() ; iIter != m_vFixData.end() ; ++ iIter) { + for ( auto& FixData : m_vFixData) { // se sottopezzo da caricare - if ( iIter->nId == GDB_ID_NULL) { - int nId = AddSubPiece( iIter->sName, iIter->ptPos, false) ; + if ( FixData.nId == GDB_ID_NULL) { + int nId = AddSubPiece( FixData.sName, FixData.ptPos, false) ; if ( nId == GDB_ID_NULL) { - string sOut = "Error adding subpiece " + iIter->sName ; + string sOut = "Error adding subpiece " + FixData.sName ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) ; } else - iIter->nId = nId ; + FixData.nId = nId ; } } // aggiornamento movimento pezzi - for ( auto iIter = m_vMvrData.begin() ; iIter != m_vMvrData.end() ; ++ iIter) { - switch ( iIter->nType) { + for ( const auto& vMvrData : m_vMvrData) { + switch ( vMvrData.nType) { case MoveRawData::COR : - if ( ! MoveToCornerRawPart( iIter->nRawId, iIter->ptP, iIter->nFlag, false)) { - string sOut = "Error in MoveToCornerRawPart " + ToString( iIter->nRawId) ; + if ( ! MoveToCornerRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false)) { + string sOut = "Error in MoveToCornerRawPart " + ToString( vMvrData.nRawId) ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) ; } break ; case MoveRawData::CEN : - if ( ! MoveToCenterRawPart( iIter->nRawId, iIter->ptP, iIter->nFlag, false)) { - string sOut = "Error in MoveToCenterRawPart " + ToString( iIter->nRawId) ; + if ( ! MoveToCenterRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false)) { + string sOut = "Error in MoveToCenterRawPart " + ToString( vMvrData.nRawId) ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) ; } break ; case MoveRawData::ROT : - if ( ! ApplyRotationToRawPart( iIter->nRawId, iIter->ptP.x, iIter->ptP.y, iIter->ptP.z)) { - string sOut = "Error in ApplyRotationToRawPart " + ToString( iIter->nRawId) ; + if ( ! ApplyRotationToRawPart( vMvrData.nRawId, vMvrData.ptP.x, vMvrData.ptP.y, vMvrData.ptP.z)) { + string sOut = "Error in ApplyRotationToRawPart " + ToString( vMvrData.nRawId) ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) ; } break ; @@ -285,7 +301,7 @@ Disposition::Apply(void) //---------------------------------------------------------------------------- int -Disposition::AddSubPiece( const string& sName, const Point3d& ptPos, bool bAddToList) +Disposition::AddSubPiece( const string& sName, const Point3d& ptPos, double dAngDeg, bool bAddToList) { // verifico MachMgr e GeomDB if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) @@ -312,9 +328,12 @@ Disposition::AddSubPiece( const string& sName, const Point3d& ptPos, bool bAddTo // la muovo nella posizione voluta Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ; m_pGeomDB->TranslateGlob( nFixtId, vtMove) ; + // la ruoto + if ( fabs( dAngDeg) > EPS_ANG_SMALL) + m_pGeomDB->RotateGroup( nFixtId, ORIG, Z_AX, dAngDeg) ; // se da aggiungere alla lista if ( bAddToList) - m_vFixData.emplace_back( sName, nFixtId, ptPos) ; + m_vFixData.emplace_back( sName, nFixtId, ptPos, 0) ; return nFixtId ; } @@ -340,6 +359,28 @@ Disposition::MoveSubPiece( int nId, const Vector3d& vtMove) return true ; } +//---------------------------------------------------------------------------- +bool +Disposition::RotateSubPiece( int nId, double dAngDeg) +{ + // verifica validità sottopezzo + if ( ! VerifyFixture( nId)) + return false ; + // verifico aggiornamento tavola + if ( ! m_bTabOk && ! SetTable( m_sTabName)) + return false ; + // muovo l'oggetto + m_pGeomDB->RotateGroup( nId, ORIG, Z_AX, dAngDeg) ; + // aggiorno la posizione dell'oggetto nel vettore dei comandi + for ( auto& FixData : m_vFixData) { + if ( FixData.nId == nId) { + FixData.dAng += dAngDeg ; + break ; + } + } + return true ; +} + //---------------------------------------------------------------------------- bool Disposition::RemoveSubPiece( int nId) diff --git a/Disposition.h b/Disposition.h index 38c96fc..46776b2 100644 --- a/Disposition.h +++ b/Disposition.h @@ -14,7 +14,7 @@ #pragma once #include "/EgtDev/Include/EGkPoint3d.h" -#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkUserObj.h" #include "/EgtDev/Include/EgtNumCollection.h" #include @@ -24,10 +24,11 @@ struct FixtureData std::string sName ; // nome del dispositivo di bloccaggio int nId ; // identificativo Point3d ptPos ; // posizione nel riferimento tavola + double dAng ; // angolo di rotazione attorno al centro FixtureData( void) - : sName(), nId( GDB_ID_NULL), ptPos() {} - FixtureData( const std::string& sN, int nI, const Point3d& ptP) - : sName( sN), nId( nI), ptPos( ptP) {} + : sName(), nId( GDB_ID_NULL), ptPos(), dAng( 0) {} + FixtureData( const std::string& sN, int nI, const Point3d& ptP, double dA) + : sName( sN), nId( nI), ptPos( ptP), dAng( dA) {} } ; typedef std::vector FIXDATAVECTOR ; @@ -47,21 +48,9 @@ struct MoveRawData typedef std::vector MVRDATAVECTOR ; //---------------------------------------------------------------------------- -static std::string DIS_TABLE = "Tab" ; -static std::string DIS_FXD_TOT = "FxT" ; -static std::string DIS_FXD_NAME = "FxN" ; -static std::string DIS_FXD_POS = "FxP" ; -static std::string DIS_MVD_TOT = "MvT" ; -static std::string DIS_MVD_ID = "MvI" ; -static std::string DIS_MVD_TYPE = "MvT" ; -static std::string DIS_MVD_PNT = "MvP" ; -static std::string DIS_MVD_ANG = "MvA" ; -static std::string DIS_MVD_FLAG = "MvF" ; - -//---------------------------------------------------------------------------- -class Disposition : public IObjUser +class Disposition : public IUserObj { - public : + public : // IUserObj virtual Disposition* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; @@ -77,8 +66,9 @@ class Disposition : public IObjUser bool Init( MachMgr* pMchMgr) ; bool SetTable( const std::string& sTable) ; bool Apply( void) ; - int AddSubPiece( const std::string& sName, const Point3d& ptPos, bool bAddToList = true) ; + int AddSubPiece( const std::string& sName, const Point3d& ptPos, double dAngDeg = 0, bool bAddToList = true) ; bool MoveSubPiece( int nId, const Vector3d& vtMove) ; + bool RotateSubPiece( int nId, double dAngDeg) ; bool RemoveSubPiece( int nId) ; bool MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList = true) ; bool MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList = true) ; diff --git a/Drilling.cpp b/Drilling.cpp index 901fde7..e855871 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -4,7 +4,7 @@ // File : Drilling.cpp Data : 21.05.15 Versione : 1.6e7 // Contenuto : Implementazione gestione forature. // -// +// Note : Questa lavorazione è sempre espressa nel riferimento globale. // // Modifiche : 21.05.15 DS Creazione modulo. // @@ -16,19 +16,42 @@ #include "MachMgr.h" #include "DllMain.h" #include "Drilling.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "CamData.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveArc.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" +#include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkDrilling", Drilling) ; +static std::string DRI_IDS = "IDS" ; +static std::string DRI_T1 = "T1" ; + +//---------------------------------------------------------------------------- +struct Hole +{ + int nOriId ; // identificativo della geometria di origine + Point3d ptIni ; // punto iniziale + Vector3d vtDir ; // direzione di riferimento (dal fondo verso l'inizio) + double dDiam ; // diametro + double dLen ; // lunghezza dell'asse + bool bBlind ; // flag per cieco/passante + // eventuale tipo ( standard, ribassato, svasato) + Hole( void) + : nOriId( GDB_ID_NULL), ptIni(), vtDir(), dDiam( 0), dLen( 0), bBlind( true) {} +}; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EMkDrilling", Drilling) ; //---------------------------------------------------------------------------- const string& Drilling::GetClassName( void) const { - return OBJUSER_GETNAME( Drilling) ; + return USEROBJ_GETNAME( Drilling) ; } //---------------------------------------------------------------------------- @@ -60,13 +83,10 @@ Drilling::Dump( string& sOut, const char* szNewLine) const { sOut += GetClassName() + szNewLine ; sOut += DRI_IDS + EQUAL + ToString( m_vId) + szNewLine ; - sOut += DRI_INV + EQUAL + ToString( m_Params.m_bInvert) + szNewLine ; - sOut += DRI_SPS + EQUAL + ToString( m_Params.m_dStartPos) + szNewLine ; - sOut += DRI_SSL + EQUAL + ToString( m_Params.m_dStartSlowLen) + szNewLine ; - sOut += DRI_ESL + EQUAL + ToString( m_Params.m_dEndSlowLen) + szNewLine ; - sOut += DRI_TAL + EQUAL + ToString( m_Params.m_dThroughAddLen) + szNewLine ; - sOut += DRI_STP + EQUAL + ToString( m_Params.m_dStep) + szNewLine ; - sOut += DRI_RPS + EQUAL + ToString( m_Params.m_dReturnPos) + szNewLine ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + sOut += m_Params.ToString( i) + szNewLine ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + sOut += m_TParams.ToString( i) + szNewLine ; return true ; } @@ -76,16 +96,15 @@ bool Drilling::Save( STRVECTOR& vString) const { try { - vString.insert( vString.begin(), 8, "") ; - if ( ! SetVal( DRI_IDS, m_vId, vString[0]) || - ! SetVal( DRI_INV, m_Params.m_bInvert, vString[1]) || - ! SetVal( DRI_SPS, m_Params.m_dStartPos, vString[2]) || - ! SetVal( DRI_SSL, m_Params.m_dStartSlowLen, vString[3]) || - ! SetVal( DRI_ESL, m_Params.m_dEndSlowLen, vString[4]) || - ! SetVal( DRI_TAL, m_Params.m_dThroughAddLen, vString[5]) || - ! SetVal( DRI_STP, m_Params.m_dStep, vString[6]) || - ! SetVal( DRI_RPS, m_Params.m_dReturnPos, vString[7])) + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + vString.insert( vString.begin(), nSize, "") ; + int k = - 1 ; + if ( ! SetVal( DRI_IDS, m_vId, vString[++k])) return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + vString[++k] = m_Params.ToString( i) ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + vString[++k] = m_TParams.ToString( i) ; } catch( ...) { return false ; @@ -97,62 +116,411 @@ Drilling::Save( STRVECTOR& vString) const bool Drilling::Load( const STRVECTOR& vString) { - if ( vString.size() < 8) + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + if ( int( vString.size()) < nSize) return false ; - if ( ! GetVal( vString[0], DRI_IDS, m_vId) || - ! GetVal( vString[1], DRI_INV, m_Params.m_bInvert) || - ! GetVal( vString[2], DRI_SPS, m_Params.m_dStartPos) || - ! GetVal( vString[3], DRI_SSL, m_Params.m_dStartSlowLen) || - ! GetVal( vString[4], DRI_ESL, m_Params.m_dEndSlowLen) || - ! GetVal( vString[5], DRI_TAL, m_Params.m_dThroughAddLen) || - ! GetVal( vString[6], DRI_STP, m_Params.m_dStep) || - ! GetVal( vString[7], DRI_RPS, m_Params.m_dReturnPos)) + int k = - 1 ; + if ( ! GetVal( vString[++k], DRI_IDS, m_vId)) return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) { + int nKey ; + if ( ! m_Params.FromString( vString[++k], nKey) || nKey != i) + return false ; + } + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) { + int nKey ; + if ( ! m_TParams.FromString( vString[++k], nKey) || nKey != i) + return false ; + } return true ; } -//---------------------------------------------------------------------------- -bool -Drilling::SetOwner( int nId, IGeomDB* pGDB) -{ - m_nOwnerId = nId ; - m_pGeomDB = pGDB ; - return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ; -} - -//---------------------------------------------------------------------------- -int -Drilling::GetOwner( void) const -{ - return m_nOwnerId ; -} - -//---------------------------------------------------------------------------- -IGeomDB* -Drilling::GetGeomDB( void) const -{ - return m_pGeomDB ; -} - //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- Drilling::Drilling( void) { m_nOwnerId = GDB_ID_NULL ; m_pGeomDB = nullptr ; - m_Params.m_bInvert = false ; - m_Params.m_dStartPos = 5 ; - m_Params.m_dStartSlowLen = 0 ; - m_Params.m_dEndSlowLen = 0 ; - m_Params.m_dThroughAddLen = 2 ; - m_Params.m_dStep = 0 ; - m_Params.m_dReturnPos= 0 ; + m_Params.m_sName = "*" ; + m_Params.m_sToolName = "*" ; + m_TParams.m_sName = "*" ; + m_TParams.m_sHead = "*" ; } //---------------------------------------------------------------------------- bool -Drilling::Add( const string& sName) +Drilling::Prepare( const string& sDriName) { + // verifico il gestore lavorazioni + if ( m_pMchMgr == nullptr) + return false ; + // recupero il gestore DB utensili della macchina corrente + ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ; + if ( pTMgr == nullptr) + return false ; + // recupero il gestore DB lavorazioni della macchina corrente + MachiningsMgr* pMMgr = m_pMchMgr->GetCurrMachiningsMgr() ; + if ( pMMgr == nullptr) + return false ; + // ricerca della lavorazione di libreria con il nome indicato + const DrillingData* pDdata = GetDrillingData( pMMgr->GetMachining( sDriName)) ; + if ( pDdata == nullptr) + return false ; + m_Params = *pDdata ; + // ricerca dell'utensile usato dalla lavorazione + const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ; + if ( pTdata == nullptr) + return false ; + m_TParams = *pTdata ; + m_Params.m_sToolName = m_TParams.m_sName ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::SetGeometry( const SELVECTOR& vIds) +{ + // verifico validità gestore DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // reset della geometria corrente + m_vId.clear() ; + // verifico che gli identificativi rappresentino dei fori con il corretto diametro + for ( int i = 0 ; i < int( vIds.size()) ; ++ i) { + // recupero i dati del foro + Hole hole ; + if ( ! GetHoleData( vIds[i], hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > EPS_SMALL) { + string sOut = "Entity " + ToString( vIds[i].nId) + " skipped by Drilling" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + continue ; + } + // posso aggiungere alla lista + m_vId.push_back( vIds[i]) ; + } + return ( ! m_vId.empty()) ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Apply( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // recupero gruppo per geometria di lavorazione del primo utensile + int nT1Id = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, DRI_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, DRI_T1) ; + m_pGeomDB->SetMaterial( nT1Id, GREEN) ; + } + // altrimenti lo svuoto + else + m_pGeomDB->EmptyGroup( nT1Id) ; + // elaboro i singoli fori + for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) { + // recupero i dati del foro + Hole hole ; + if ( ! GetHoleData( m_vId[i], hole)) { + string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Drilling" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + continue ; + } + // limito lunghezza foro a massima lavorazione della punta + if ( hole.dLen > m_TParams.m_dMaxMat + EPS_SMALL) { + hole.dLen = m_TParams.m_dMaxMat ; + string sOut = "Drill bit too short for Hole " + ToString( m_vId[i]) ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + } + // foro normale + if ( m_Params.m_dStep < EPS_SMALL || + m_Params.m_dStep > hole.dLen - EPS_SMALL) { + if ( ! DoStandardDrilling( hole, m_vId[i], nT1Id)) { + string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Standard Drilling" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + } + } + else { + if ( ! DoPeckDrilling( hole, m_vId[i], nT1Id)) { + string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Peck Drilling" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + } + } + } + // calcolo gli assi macchina + + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::GetHoleData( SelData Id, Hole& hole) +{ + // deve essere un arco (ignoro il sotto identificativo) + const ICurveArc* pArc = GetCurveArc( m_pGeomDB->GetGeoObj( Id.nId)) ; + if ( pArc == nullptr) + return false ; + // deve avere estrusione e spessore + double dThick ; + Vector3d vtExtr ; + if ( ! pArc->GetThickness( dThick) || ! pArc->GetExtrusion( vtExtr) || + ( dThick * vtExtr).IsSmall ()) + return false ; + // ne recupero il riferimento globale + Frame3d frGlob ; + if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob)) + return false ; + // assegno Id + hole.nOriId = Id.nId ; + // ne recupero il diametro + hole.dDiam = 2 * pArc->GetRadius() ; + // ne recupero il centro + hole.ptIni = pArc->GetCenter() ; + hole.ptIni.ToGlob( frGlob) ; + // ne recupero versore direzione e lunghezza + hole.vtDir = (( dThick < 0) ? vtExtr : - vtExtr) ; + hole.vtDir.ToGlob( frGlob) ; + hole.vtDir.Normalize() ; + hole.dLen = fabs( dThick) ; + // lo dichiaro cieco (andrà calcolato opportunamente) + hole.bBlind = true ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId) +{ + // aggiusto alcuni parametri del ciclo di foratura + double dStartSlowLen = fabs( m_Params.m_dStartSlowLen) ; + if ( fabs( m_TParams.m_dStartFeed - m_TParams.m_dFeed) < EPS_SMALL) + dStartSlowLen = 0 ; + double dEndSlowLen = ( hole.bBlind ? 0 : fabs( m_Params.m_dEndSlowLen)) ; + if ( fabs( m_TParams.m_dEndFeed - m_TParams.m_dFeed) < EPS_SMALL) + dEndSlowLen = 0 ; + if ( ( dStartSlowLen + dEndSlowLen) > hole.dLen) { + dStartSlowLen = dStartSlowLen / ( dStartSlowLen + dEndSlowLen) * hole.dLen ; + dEndSlowLen = hole.dLen - dStartSlowLen ; + } + double dAddLen = ( hole.bBlind ? 0 : m_Params.m_dThroughAddLen) ; + bool bStartSlow = ( dStartSlowLen > EPS_SMALL) ; + bool bStd = ( ( hole.dLen - dStartSlowLen - dEndSlowLen) > EPS_SMALL) ; + bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ; + // determino alcune caratteristiche dell'utensile + 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() ; + Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ; + if ( AddStart( ptP1) == GDB_ID_NULL) + return false ; + // 2 -> punto fuori (se diverso dal precedente) + if ( m_Params.m_dStartPos < dAppr) { + SetFeed( MAX_FEED) ; + SetFlag( 0) ; + Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ; + if ( AddLinearMove( ptP2) == GDB_ID_NULL) + return false ; + } + // 3 -> punto termine velocità ridotta iniziale (se previsto) + if ( bStartSlow) { + SetFeed( m_TParams.m_dStartFeed) ; + if ( ! bStd && ! bEndSlow) + SetFlag( 1) ; // fondo del foro + Point3d ptP3 = hole.ptIni - hole.vtDir * dStartSlowLen ; + if ( ! bStd && ! bEndSlow) + ptP3 -= hole.vtDir * dAddLen ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // 4 -> punto termine velocità standard (se risulta) + if ( bStd) { + SetFeed( m_TParams.m_dFeed) ; + if ( ! bEndSlow) + SetFlag( 1) ; // fondo del foro + Point3d ptP4 = hole.ptIni - hole.vtDir * ( hole.dLen - dEndSlowLen) ; + if ( ! bEndSlow) + ptP4 -= hole.vtDir * dAddLen ; + if ( AddLinearMove( ptP4) == GDB_ID_NULL) + return false ; + } + // 5 -> punto termine velocità finale ridotta (se previsto) + if ( bEndSlow) { + SetFeed( m_TParams.m_dEndFeed) ; + SetFlag( 1) ; // fondo del foro + Point3d ptP5 = hole.ptIni - hole.vtDir * ( hole.dLen + dAddLen) ; + if ( AddLinearMove( ptP5) == GDB_ID_NULL) + return false ; + } + // 6 -> ritorno all'approccio del foro + SetFeed( MAX_FEED) ; + SetFlag( 0) ; + if ( AddLinearMove( ptP1) == GDB_ID_NULL) + return false ; + + // reset dati di movimento + ResetMoveData() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId) +{ + // aggiusto alcuni parametri del ciclo di foratura + double dStartSlowLen = fabs( m_Params.m_dStartSlowLen) ; + if ( fabs( m_TParams.m_dStartFeed - m_TParams.m_dFeed) < EPS_SMALL) + dStartSlowLen = 0 ; + double dEndSlowLen = ( hole.bBlind ? 0 : fabs( m_Params.m_dEndSlowLen)) ; + if ( fabs( m_TParams.m_dEndFeed - m_TParams.m_dFeed) < EPS_SMALL) + dEndSlowLen = 0 ; + if ( ( dStartSlowLen + dEndSlowLen) > hole.dLen) { + dStartSlowLen = dStartSlowLen / ( dStartSlowLen + dEndSlowLen) * hole.dLen ; + dEndSlowLen = hole.dLen - dStartSlowLen ; + } + double dStdLen = hole.dLen - dStartSlowLen - dEndSlowLen ; + double dAddLen = ( hole.bBlind ? 0 : m_Params.m_dThroughAddLen) ; + double dReturnPos = m_Params.m_dReturnPos ; + bool bStartSlow = ( dStartSlowLen > EPS_SMALL) ; + bool bStd = ( dStdLen > EPS_SMALL) ; + bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ; + // determino alcune caratteristiche dell'utensile + 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() ; + Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ; + if ( AddStart( ptP1) == GDB_ID_NULL) + return false ; + // 2 -> punto fuori (se diverso dal precedente) + if ( m_Params.m_dStartPos < dAppr) { + SetFeed( MAX_FEED) ; + SetFlag( 0) ; + Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ; + if ( AddLinearMove( ptP2) == GDB_ID_NULL) + return false ; + } + // ciclo di affondamento a step + const double MIN_STEP = 5 ; + const double APPR_STEP = 1 ; + const double MIN_MOVE = 1 ; + double dStep = max( m_Params.m_dStep, MIN_STEP) ; + int nStep = int( ceil( hole.dLen / dStep)) ; + dStep = hole.dLen / nStep ; + if ( dReturnPos < - dStep + APPR_STEP + MIN_MOVE) + dReturnPos = - dStep + APPR_STEP + MIN_MOVE ; + double dCurrLen = 0 ; + for ( int i = 1 ; i <= nStep ; ++ i) { + // se non è primo step faccio retrazione e riaffondo + if ( i != 1) { + // retrazione + SetFeed( MAX_FEED) ; + SetFlag( 3) ; // punto di scarico truciolo + Point3d ptPr = hole.ptIni + hole.vtDir * dReturnPos ; + if ( AddLinearMove( ptPr) == GDB_ID_NULL) + return false ; + // riaffondo + SetFeed( MAX_FEED) ; + SetFlag( 0) ; + Point3d ptPa = hole.ptIni - hole.vtDir * ( dCurrLen - APPR_STEP) ; + if ( AddLinearMove( ptPa) == GDB_ID_NULL) + return false ; + } + // lunghezza di fine step + double dEndLen = dCurrLen + dStep ; + // 3 -> punto termine velocità ridotta iniziale (se previsto) + if ( bStartSlow && ( i == 1 || dCurrLen < dStartSlowLen + EPS_SMALL)) { + // lunghezza di esecuzione + double dLen = min( dStartSlowLen, dEndLen) ; + // determino se arrivo in fondo al foro + bool bHoleEnd = ( ! bStd && ! bEndSlow && dLen > hole.dLen - EPS_SMALL) ; + // determino se arrivo in fondo allo step + bool bStepEnd = ( dLen > dEndLen - EPS_SMALL) ; + // assegno parametri + SetFeed( m_TParams.m_dStartFeed) ; + if ( bHoleEnd) + SetFlag( 1) ; // fondo del foro + else if ( bStepEnd) + SetFlag( 2) ; // fondo dello step + // movimento + Point3d ptP3 = hole.ptIni - hole.vtDir * dLen ; + if ( bHoleEnd) + ptP3 -= hole.vtDir * dAddLen ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + // aggiorno posizione e verifico se step completato + dCurrLen = dLen ; + if ( bHoleEnd || bStepEnd) + continue ; + } + // 4 -> punto termine velocità standard (se risulta) + if ( bStd && dCurrLen < dStartSlowLen + dStdLen + EPS_SMALL) { + // lunghezza di esecuzione + double dLen = min( hole.dLen - dEndSlowLen, dEndLen) ; + // determino se arrivo in fondo al foro + bool bHoleEnd = ( ! bEndSlow && dLen > hole.dLen - EPS_SMALL) ; + // determino se arrivo in fondo allo step + bool bStepEnd = ( dLen > dEndLen - EPS_SMALL) ; + // assegno parametri + SetFeed( m_TParams.m_dFeed) ; + if ( bHoleEnd) + SetFlag( 1) ; // fondo del foro + else if ( bStepEnd) + SetFlag( 2) ; // fondo dello step + // movimento + Point3d ptP4 = hole.ptIni - hole.vtDir * dLen ; + if ( bHoleEnd) + ptP4 -= hole.vtDir * dAddLen ; + if ( AddLinearMove( ptP4) == GDB_ID_NULL) + return false ; + // aggiorno posizione e verifico se step completato + dCurrLen = dLen ; + if ( bHoleEnd || bStepEnd) + continue ; + } + // 5 -> punto termine velocità finale ridotta (se previsto) + if ( bEndSlow) { + // lunghezza di esecuzione + double dLen = dEndLen ; + // determino se arrivo in fondo al foro + bool bHoleEnd = ( dLen > hole.dLen - EPS_SMALL) ; + // sono sempre in fondo allo step + // assegno parametri + SetFeed( m_TParams.m_dEndFeed) ; + if ( bHoleEnd) + SetFlag( 1) ; // fondo del foro + else + SetFlag( 2) ; // fondo dello step + // movimento + Point3d ptP5 = hole.ptIni - hole.vtDir * dLen ; + if ( bHoleEnd) + ptP5 -= hole.vtDir * dAddLen ; + if ( AddLinearMove( ptP5) == GDB_ID_NULL) + return false ; + // aggiorno posizione + dCurrLen = dLen ; + } + } + + // 6 -> ritorno all'approccio del foro + SetFeed( MAX_FEED) ; + SetFlag( 0) ; + if ( AddLinearMove( ptP1) == GDB_ID_NULL) + return false ; + + // reset dati di movimento + ResetMoveData() ; return true ; } diff --git a/Drilling.h b/Drilling.h index defaa5d..82cd66f 100644 --- a/Drilling.h +++ b/Drilling.h @@ -13,75 +13,38 @@ #pragma once -#include "/EgtDev/Include/EGkObjUser.h" -#include "/EgtDev/Include/EgtNumCollection.h" -#include +#include "Machining.h" +#include "DrillingData.h" +#include "ToolData.h" + +struct Hole ; //---------------------------------------------------------------------------- -struct DrillingParams +class Drilling : public Machining { - bool m_bInvert ; // flag di inversione direzione lavorazione per fori aperti - double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0) - double m_dStartSlowLen ; // lunghezza rallentamento iniziale - double m_dEndSlowLen ; // lunghezza rallentamento finale - 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) -} ; - -//---------------------------------------------------------------------------- -struct DrillBitParams -{ - std::string m_sName ; // nome dell'utensile - std::string m_sTcPos ; // posizione di attrezzaggio - std::string m_sHead ; // testa di montaggio - int m_nExit ; // uscita di montaggio - int m_nCorr ; // numero di correttore - int m_nType ; // tipo di utensile : foratore, foratore lungo o fresa (lavora di testa) - double m_dMaxSpeed ; // massima velocità di rotazione ammessa (giri/minuto) - double m_dMaxMat ; // massimo materiale - double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) - double m_dFeed ; // velocità di lavorazione normale - double m_dStartFeed ; // velocità di lavorazione iniziale - double m_dEndFeed ; // velocità di lavorazione finale - double m_dDiam ; // diametro - double m_dTDiam ; // diametro totale (di ingombro) - double m_dLen ; // lunghezza controllata - double m_dTLen ; // lunghezza totale (di ingombro) -} ; - -//---------------------------------------------------------------------------- -static std::string DRI_IDS = "Ids" ; -static std::string DRI_INV = "Inv" ; -static std::string DRI_SPS = "Sps" ; -static std::string DRI_SSL = "Ssl" ; -static std::string DRI_ESL = "Esl" ; -static std::string DRI_TAL = "Tal" ; -static std::string DRI_STP = "Stp" ; -static std::string DRI_RPS = "Rps" ; - -//---------------------------------------------------------------------------- -class Drilling : public IObjUser -{ - public : + public : // IUserObj virtual Drilling* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; virtual bool ToSave( void) const { return true ; } virtual bool Save( STRVECTOR& vString) const ; virtual bool Load( const STRVECTOR& vString) ; - virtual bool SetOwner( int nId, IGeomDB* pGDB) ; - virtual int GetOwner( void) const ; - virtual IGeomDB* GetGeomDB( void) const ; + + public : // Machining + virtual bool Prepare( const std::string& sDriName) ; + virtual bool SetGeometry( const SELVECTOR& vIds) ; + virtual bool Apply( void) ; public : Drilling( void) ; - bool Add( const std::string& sName) ; private : - int m_nOwnerId ; - IGeomDB* m_pGeomDB ; - INTVECTOR m_vId ; // identificativi entità geometriche da lavorare - DrillingParams m_Params ; // parametri lavorazione - DrillBitParams m_TParams ; // parametri utensile + bool GetHoleData( SelData Id, Hole& hole) ; + bool DoStandardDrilling( const Hole& hole, SelData Id, int nPathId) ; + bool DoPeckDrilling( const Hole& hole, SelData Id, int nPathId) ; + + private : + SELVECTOR m_vId ; // identificativi entità geometriche da lavorare + DrillingData m_Params ; // parametri lavorazione + ToolData m_TParams ; // parametri utensile } ; \ No newline at end of file diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 4b046237c7402d1752df555faf69f35880218c7f..2dd76d7240ba85310a18149c01b347a39022aa2c 100644 GIT binary patch delta 121 zcmewt{V#gMH#Sx?1|0^Y&A-{KnVHiVj3z&n)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RVBQCa3@a delta 121 zcmewt{V#gMH#SyN1|0_T&A-{KnVC}=%qKsT)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RVZICddE) diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj index e3e42bf..f48725f 100644 --- a/EgtMachKernel.vcxproj +++ b/EgtMachKernel.vcxproj @@ -205,6 +205,7 @@ copy $(TargetPath) \EgtProg\Dll64 + false false @@ -221,6 +222,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -229,7 +231,9 @@ copy $(TargetPath) \EgtProg\Dll64 + + Create @@ -243,9 +247,11 @@ copy $(TargetPath) \EgtProg\Dll64 + + @@ -255,12 +261,15 @@ copy $(TargetPath) \EgtProg\Dll64 + + + diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters index 3b19acc..236f603 100644 --- a/EgtMachKernel.vcxproj.filters +++ b/EgtMachKernel.vcxproj.filters @@ -117,6 +117,18 @@ Source Files\Machinings + + Source Files\Operations + + + Source Files\Operations + + + Source Files\Operations + + + Source Files\Operations + @@ -191,6 +203,21 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/Exit.cpp b/Exit.cpp index 6562810..4b2e12d 100644 --- a/Exit.cpp +++ b/Exit.cpp @@ -16,19 +16,19 @@ #include "Exit.h" #include "MachConst.h" #include "/EgtDev/Include/EGkGdbConst.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkUserOBJFactory.h" #include "/EgtDev/Include/EGkStringUtils3d.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkExit", Exit) ; +USEROBJ_REGISTER( "EMkExit", Exit) ; //---------------------------------------------------------------------------- const string& Exit::GetClassName( void) const { - return OBJUSER_GETNAME( Exit) ; + return USEROBJ_GETNAME( Exit) ; } //---------------------------------------------------------------------------- diff --git a/Exit.h b/Exit.h index c084918..7536ec8 100644 --- a/Exit.h +++ b/Exit.h @@ -14,13 +14,13 @@ #pragma once #include "Machine.h" -#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkUserObj.h" #include "/EgtDev/Include/EGkPoint3d.h" //---------------------------------------------------------------------------- -class Exit : public IObjUser +class Exit : public IUserObj { - public : + public : // IUserObj virtual Exit* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; diff --git a/Head.cpp b/Head.cpp index 2824193..ea6ea7b 100644 --- a/Head.cpp +++ b/Head.cpp @@ -16,19 +16,19 @@ #include "Head.h" #include "MachConst.h" #include "/EgtDev/Include/EGkGdbConst.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGkStringUtils3d.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkHead", Head) ; +USEROBJ_REGISTER( "EMkHead", Head) ; //---------------------------------------------------------------------------- const string& Head::GetClassName( void) const { - return OBJUSER_GETNAME( Head) ; + return USEROBJ_GETNAME( Head) ; } //---------------------------------------------------------------------------- diff --git a/Head.h b/Head.h index 311f262..eb7c31e 100644 --- a/Head.h +++ b/Head.h @@ -14,13 +14,13 @@ #pragma once #include "Machine.h" -#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkUserObj.h" #include "/EgtDev/Include/EGkPoint3d.h" //---------------------------------------------------------------------------- -class Head : public IObjUser +class Head : public IUserObj { - public : + public : // IUserObj virtual Head* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; diff --git a/MachConst.h b/MachConst.h index 6bdff10..eab580d 100644 --- a/MachConst.h +++ b/MachConst.h @@ -57,3 +57,8 @@ const std::string MACHININGS_FILE = "Machinings.data" ; //---------------------------------------------------------------------------- // Minimo spessore del grezzo const double RAW_MIN_H = 1 ; + +//---------------------------------------------------------------------------- +// Feed equivalente a massima +const double MAX_FEED = 100000 ; + diff --git a/MachMgr.h b/MachMgr.h index adfad79..d25335e 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -91,7 +91,7 @@ class MachMgr : public IMachMgr virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; // Tables and Fixtures virtual bool SetTable( const std::string& sTable) ; - virtual int AddSubPiece( const std::string& sName, const Point3d& ptPos) ; + virtual int AddSubPiece( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ; // Machine virtual bool SetAxisPos( const std::string& sAxis, double dVal) ; virtual bool GetAxisPos( const std::string& sAxis, double& dVal) ; @@ -113,9 +113,14 @@ class MachMgr : public IMachMgr virtual bool GetOperationNewName( std::string& sName) const ; virtual std::string GetOperationName( int nId) const ; virtual int GetOperationId( const std::string& sName) const ; + 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 AddDrilling( 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) ; @@ -149,6 +154,8 @@ class MachMgr : public IMachMgr bool GetRawPartCenter( int nRawId, Point3d& ptCen) ; // Machines Machine* GetCurrMachine( void) const ; + ToolsMgr* GetCurrToolsMgr( void) const ; + MachiningsMgr* GetCurrMachiningsMgr( void) const ; private : // Basic @@ -195,4 +202,5 @@ class MachMgr : public IMachMgr MachGrp m_cCurrMGrp ; // dati principali macchinata corrente int m_nCurrMch ; // indice macchina corrente (0-based) MCHDATAVECTOR m_vMachines ; // elenco macchine caricate + int m_nCurrMachiningId ; // identificativo della lavorazione corrente } ; diff --git a/MachMgrBasic.cpp b/MachMgrBasic.cpp index fdb70f2..11ecbf6 100644 --- a/MachMgrBasic.cpp +++ b/MachMgrBasic.cpp @@ -47,6 +47,7 @@ MachMgr::MachMgr( void) m_nMachAuxId = GDB_ID_NULL ; m_nCurrMGrpId = GDB_ID_NULL ; m_nCurrMch = 0 ; + m_nCurrMachiningId = GDB_ID_NULL ; } //---------------------------------------------------------------------------- diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index b0d4796..9d3be4a 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -29,20 +29,20 @@ MachMgr::SetTable( const string& sTable) { // imposto la tavola per la disposizione ( e il calcolo) int nDispId = GetFirstOperation() ; - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; return ( pDisp != nullptr && pDisp->SetTable( sTable)) ; } //---------------------------------------------------------------------------- int -MachMgr::AddSubPiece( const string& sName, const Point3d& ptPos) +MachMgr::AddSubPiece( const string& sName, const Point3d& ptPos, double dAngRotDeg) { // recupero la prima operazione, deve essere la disposizione int nDispId = GetFirstOperation() ; // recupero l'oggetto disposizione - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp == nullptr) return false ; // eseguo l'operazione - return pDisp->AddSubPiece( sName, ptPos) ; + return pDisp->AddSubPiece( sName, ptPos, dAngRotDeg) ; } diff --git a/MachMgrMachGroups.cpp b/MachMgrMachGroups.cpp index 25c48d4..451d7c3 100644 --- a/MachMgrMachGroups.cpp +++ b/MachMgrMachGroups.cpp @@ -130,6 +130,8 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName) m_pGeomDB->Erase( nNewId) ; return GDB_ID_NULL ; } + // reset lavorazione corrente + m_nCurrMachiningId = GDB_ID_NULL ; // restituisco l'identificativo del gruppo return nNewId ; } @@ -294,7 +296,7 @@ MachMgr::SetCurrMachGroup( int nId) m_pGeomDB->SetStatus( GetCurrMGeoId(), GDB_ST_ON) ; // eseguo la prima operazione di disposizione int nDispId = GetFirstOperation() ; - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp != nullptr) { pDisp->Init( this) ; return pDisp->Apply() ; @@ -320,9 +322,10 @@ MachMgr::ResetCurrMachGroup( void) // nascondo gruppo corrente e la relativa macchina m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_OFF) ; m_pGeomDB->SetStatus( GetCurrMGeoId(), GDB_ST_OFF) ; - // dichiaro nessun gruppo corrente e la relativa macchina + // dichiaro nessun gruppo corrente, la relativa macchina e la lavorazione corrente m_nCurrMGrpId = GDB_ID_NULL ; m_nCurrMch = - 1 ; + m_nCurrMachiningId = GDB_ID_NULL ; return true ; } diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 0e052a2..13c37be 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -89,6 +89,24 @@ MachMgr::GetCurrMachine( void) const return m_vMachines[m_nCurrMch].pMachine ; } +//---------------------------------------------------------------------------- +ToolsMgr* +MachMgr::GetCurrToolsMgr( void) const +{ + if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size())) + return nullptr ; + return m_vMachines[m_nCurrMch].pTsMgr ; +} + +//---------------------------------------------------------------------------- +MachiningsMgr* +MachMgr::GetCurrMachiningsMgr( void) const +{ + if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size())) + return nullptr ; + return m_vMachines[m_nCurrMch].pMsMgr ; +} + //---------------------------------------------------------------------------- bool MachMgr::SetAxisPos( const string& sAxis, double dVal) diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 34b5ad3..450f3fc 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -18,6 +18,8 @@ #include "MachConst.h" #include "Disposition.h" #include "Drilling.h" +#include "Sawing.h" +#include "Milling.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -133,6 +135,50 @@ MachMgr::GetOperationId( const string& sName) const return GDB_ID_NULL ; } +//---------------------------------------------------------------------------- +bool +MachMgr::SetCurrMachining( int nId) +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return false ; + // verifico che il gruppo di indice nId appartenga a questo gruppo + if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) + return false ; + // verifico che questo gruppo sia realmente una lavorazione + Machining* pMch = dynamic_cast( m_pGeomDB->GetUserObj( nId)) ; + if ( pMch == nullptr) + return false ; + // gli imposto il manager generale delle lavorazioni + pMch->Init( this) ; + // imposto la lavorazione corrente + m_nCurrMachiningId = nId ; + return true ; +} +//---------------------------------------------------------------------------- +bool +MachMgr::ResetCurrMachining( void) +{ + m_nCurrMachiningId = GDB_ID_NULL ; + return true ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetCurrMachining( void) const +{ + // recupero il gruppo delle operazioni nella macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // verifico che la lavorazione corrente appartenga a questo gruppo + if ( m_pGeomDB->GetParentId( m_nCurrMachiningId) == nOperGrpId) + return m_nCurrMachiningId ; + else + return GDB_ID_NULL ; +} + //---------------------------------------------------------------------------- int MachMgr::AddDisposition( const string& sName) @@ -155,15 +201,24 @@ MachMgr::AddDisposition( const string& sName) Disposition* pDisp = new(nothrow) Disposition ; if ( pDisp == nullptr) return GDB_ID_NULL ; + m_pGeomDB->SetUserObj( nId, pDisp) ; pDisp->Init( this) ; - m_pGeomDB->SetObjUser( nId, pDisp) ; return nId ; } //---------------------------------------------------------------------------- int -MachMgr::AddDrilling( const string& sName) +MachMgr::AddMachining( const string& sName, const std::string& sMachining) { + // recupero il gestore delle lavorazioni della macchina corrente + MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ; + if ( pMMgr == nullptr) + return GDB_ID_NULL ; + // recupero il tipo di lavorazione + const MachiningData* pMd = pMMgr->GetMachining( sMachining) ; + if ( pMd == nullptr) + return GDB_ID_NULL ; + int nMchType = pMd->GetType() ; // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) @@ -179,9 +234,55 @@ MachMgr::AddDrilling( const string& sName) // assegno il nome m_pGeomDB->SetName( nId, sNewName) ; // installo il gestore della lavorazione - Drilling* pDrilling = new(nothrow) Drilling ; - if ( pDrilling == nullptr) + Machining* pMch = nullptr ; + switch ( nMchType) { + case MT_DRILLING : pMch = new( nothrow) Drilling ; break ; + case MT_SAWING : pMch = new( nothrow) Sawing ; break ; + case MT_MILLING : pMch = new( nothrow) Milling ; break ; + } + if ( pMch == nullptr) { + m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; - m_pGeomDB->SetObjUser( nId, pDrilling) ; + } + m_pGeomDB->SetUserObj( nId, pMch) ; + pMch->Init( this) ; + if ( ! pMch->Prepare( sMachining)) { + m_pGeomDB->Erase( nId) ; + return GDB_ID_NULL ; + } + // la dichiaro lavorazione corrente + m_nCurrMachiningId = nId ; return nId ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachiningGeometry( const SELVECTOR& vIds) +{ + // 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 la geometria + return pMch->SetGeometry( vIds) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::Apply( void) +{ + // 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 la geometria + return pMch->Apply() ; +} \ No newline at end of file diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index 22ba566..a760b9b 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -340,7 +340,7 @@ MachMgr::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) // recupero la prima operazione, deve essere la disposizione int nDispId = GetFirstOperation() ; // recupero l'oggetto disposizione - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp == nullptr) return false ; // eseguo l'operazione @@ -354,7 +354,7 @@ MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag) // recupero la prima operazione, deve essere la disposizione int nDispId = GetFirstOperation() ; // recupero l'oggetto disposizione - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp == nullptr) return false ; // eseguo l'operazione @@ -368,7 +368,7 @@ MachMgr::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag) // recupero la prima operazione, deve essere la disposizione int nDispId = GetFirstOperation() ; // recupero l'oggetto disposizione - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp == nullptr) return false ; // eseguo l'operazione @@ -382,7 +382,7 @@ MachMgr::MoveRawPart( int nRawId, const Vector3d& vtMove) // recupero la prima operazione, deve essere la disposizione int nDispId = GetFirstOperation() ; // recupero l'oggetto disposizione - Disposition* pDisp = dynamic_cast( m_pGeomDB->GetObjUser( nDispId)) ; + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; if ( pDisp == nullptr) return false ; // eseguo l'operazione diff --git a/Machine.cpp b/Machine.cpp index ebae647..5e97091 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -177,7 +177,7 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType if ( pTab == nullptr) return false ; pTab->Set( sName, nType, ptRef1) ; - m_pGeomDB->SetObjUser( nLay, pTab) ; + m_pGeomDB->SetUserObj( nLay, pTab) ; // aggiusto la posizione della tavola if ( ! AdjustTablePos( nLay, ptRef1)) return false ; @@ -257,7 +257,7 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType, if ( pAxis == nullptr) return false ; pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dHome) ; - m_pGeomDB->SetObjUser( nLay, pAxis) ; + m_pGeomDB->SetUserObj( nLay, pAxis) ; // verifico il vettore rappresentativo dell'asse if ( ! AdjustAxisVector( nLay, sPart, sName, nType, ptPos, vtDir)) return false ; @@ -360,7 +360,7 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s if ( pHead == nullptr) return false ; pHead->Set( sName, MCH_HT_STD, sHSet, vtADir) ; - m_pGeomDB->SetObjUser( nLay, pHead) ; + m_pGeomDB->SetUserObj( nLay, pHead) ; // aggiorno la testa capostipite if ( ! AddHeadToSet( sHSet, sName)) return false ; @@ -402,7 +402,7 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const if ( pHead == nullptr) return false ; pHead->Set( sName, MCH_HT_MULTI, sHSet, vtADir) ; - m_pGeomDB->SetObjUser( nLay, pHead) ; + m_pGeomDB->SetUserObj( nLay, pHead) ; // aggiorno la testa capostipite if ( ! AddHeadToSet( sHSet, sName)) return false ; @@ -425,28 +425,28 @@ Machine::GetGroup( const string& sGroup) const Axis* Machine::GetAxis( int nGroup) const { - return ( dynamic_cast( m_pGeomDB->GetObjUser( nGroup))) ; + return ( dynamic_cast( m_pGeomDB->GetUserObj( nGroup))) ; } //---------------------------------------------------------------------------- Table* Machine::GetTable( int nGroup) const { - return ( dynamic_cast( m_pGeomDB->GetObjUser( nGroup))) ; + return ( dynamic_cast( m_pGeomDB->GetUserObj( nGroup))) ; } //---------------------------------------------------------------------------- Head* Machine::GetHead( int nGroup) const { - return ( dynamic_cast( m_pGeomDB->GetObjUser( nGroup))) ; + return ( dynamic_cast( m_pGeomDB->GetUserObj( nGroup))) ; } //---------------------------------------------------------------------------- Exit* Machine::GetExit( int nGroup) const { - return ( dynamic_cast( m_pGeomDB->GetObjUser( nGroup))) ; + return ( dynamic_cast( m_pGeomDB->GetUserObj( nGroup))) ; } //---------------------------------------------------------------------------- @@ -552,7 +552,7 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) if ( pExit == nullptr) return false ; pExit->Set( sName, vMuExit[i].ptPos, vMuExit[i].vtTDir) ; - m_pGeomDB->SetObjUser( nGT, pExit) ; + m_pGeomDB->SetUserObj( nGT, pExit) ; } else { string sOut = " Error finding frame " + sName ; diff --git a/Machining.cpp b/Machining.cpp new file mode 100644 index 0000000..88e6682 --- /dev/null +++ b/Machining.cpp @@ -0,0 +1,210 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Machining.cpp Data : 10.06.15 Versione : 1.6f2 +// Contenuto : Implementazione gestione base lavorazioni. +// +// +// +// Modifiche : 10.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "MachMgr.h" +#include "Machining.h" +#include "CamData.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkGeomDB.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +bool +Machining::SetOwner( int nId, IGeomDB* pGDB) +{ + m_nOwnerId = nId ; + m_pGeomDB = pGDB ; + return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ; +} + +//---------------------------------------------------------------------------- +int +Machining::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +IGeomDB* +Machining::GetGeomDB( void) const +{ + return m_pGeomDB ; +} + +//---------------------------------------------------------------------------- +bool +Machining::Init( MachMgr* pMchMgr) +{ + m_pMchMgr = pMchMgr ; + if ( m_pMchMgr == nullptr) + return false ; + if ( m_pMchMgr->GetGeomDB() != m_pGeomDB) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +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_vtTool(), m_vtCorr(), m_vtAux(), m_dFeed( 0), m_nFlag( 0) +{ +} + +//---------------------------------------------------------------------------- +bool +Machining::SetPathId( int nPathId) +{ + m_nPathId = nPathId ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetOrigId( SelData OrigId) +{ + m_OrigId = OrigId ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetToolDir( const Vector3d& vtDir) +{ + m_vtTool = vtDir ; + return ( m_vtTool.Normalize()) ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetCorrDir( const Vector3d& vtDir) +{ + m_vtCorr = vtDir ; + return ( ! m_vtCorr.IsSmall()) ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetAuxDir( const Vector3d& vtDir) +{ + m_vtAux = vtDir ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetFeed( double dFeed) +{ + m_dFeed = dFeed ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machining::SetFlag( int nFlag) +{ + m_nFlag = nFlag ; + return true ; +} + +//---------------------------------------------------------------------------- +int +Machining::AddStart( const Point3d& ptP) +{ + // verifico di essere in uno stato valido per inizio + if ( m_vtTool.IsSmall()) + return GDB_ID_NULL ; + // creo oggetto punto per DB geometrico + PtrOwner pGP( CreateGeoPoint3d()) ; + if ( IsNull( pGP)) + return GDB_ID_NULL ; + // assegno le coordinate del punto + pGP->Set( ptP) ; + // inserisco l'oggetto nel DB geometrico + int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pGP)) ; + if ( nId == GDB_ID_NULL) + return GDB_ID_NULL ; + // creo oggetto dati Cam + PtrOwner pCam( new( nothrow) CamData) ; + 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) ; + pCam->SetBasePoint( ptP) ; + // associo questo oggetto a quello geometrico + m_pGeomDB->SetUserObj( nId, Release( pCam)) ; + // salvo la posizione corrente + m_bCurr = true ; + m_ptCurr = ptP ; + return nId ; +} + +//---------------------------------------------------------------------------- +int +Machining::AddLinearMove( const Point3d& ptP) +{ + // verifico di essere in uno stato valido per un movimento lineare + if ( ! m_bCurr || m_vtTool.IsSmall() || m_dFeed < EPS_SMALL) + return GDB_ID_NULL ; + // creo oggetto linea per DB geometrico + PtrOwner pLine( CreateCurveLine()) ; + if ( IsNull( pLine)) + return GDB_ID_NULL ; + // assegno le coordinate degli estremi + if ( ! pLine->Set( m_ptCurr, ptP)) + return GDB_ID_NULL ; + // inserisco l'oggetto nel DB geometrico + int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pLine)) ; + if ( nId == GDB_ID_NULL) + return GDB_ID_NULL ; + // creo oggetto dati Cam + PtrOwner pCam( new( nothrow) CamData) ; + 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) ; + pCam->SetBasePoint( ptP) ; + pCam->SetFeed( m_dFeed) ; + pCam->SetFlag( m_nFlag) ; + // associo questo oggetto a quello geometrico + m_pGeomDB->SetUserObj( nId, Release( pCam)) ; + // salvo la posizione corrente + m_ptCurr = ptP ; + return nId ; +} + +//---------------------------------------------------------------------------- +bool +Machining::ResetMoveData( void) +{ + m_bCurr = false ; + m_ptCurr = ORIG ; + m_vtTool = V_NULL ; + m_vtCorr = V_NULL ; + m_vtAux = V_NULL ; + m_dFeed = 0 ; + m_nFlag = 0 ; + return true ; +} diff --git a/Machining.h b/Machining.h new file mode 100644 index 0000000..b1c2872 --- /dev/null +++ b/Machining.h @@ -0,0 +1,70 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Machining.h Data : 07.06.15 Versione : 1.6f2 +// Contenuto : Dichiarazione della classe Machining da cui derivano +// tutti i gestori delle lavorazioni. +// +// +// +// Modifiche : 07.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" +#include "/EgtDev/Include/EGkUserObj.h" +#include "/EgtDev/Include/EGkSelection.h" +#include "/EgtDev/Include/EgtNumCollection.h" + +class MachMgr ; + +//---------------------------------------------------------------------------- +class Machining : public IUserObj +{ + public : // IUserObj + virtual bool SetOwner( int nId, IGeomDB* pGDB) ; + virtual int GetOwner( void) const ; + virtual IGeomDB* GetGeomDB( void) const ; + + public : + virtual bool Init( MachMgr* pMchMgr) ; + virtual bool Prepare( const std::string& sDriName) = 0 ; + virtual bool SetGeometry( const SELVECTOR& vIds) = 0 ; + //virtual bool ResetGeometry( void) = 0 ; + virtual bool Apply( void) = 0 ; + //virtual bool Simulate( void) = 0 ; + //virtual bool Generate( void) = 0 ; + + protected : + Machining( void) ; + double GetApproachDist( void) { return 30.0 ; } + + protected : + bool SetPathId( int nPathId) ; + bool SetOrigId( SelData OrigId) ; + bool SetToolDir( const Vector3d& vtDir) ; + bool SetCorrDir( const Vector3d& vtDir) ; + bool SetAuxDir( const Vector3d& vtDir) ; + bool SetFeed( double dFeed) ; + bool SetFlag( int nFlag) ; + int AddStart( const Point3d& ptP) ; + int AddLinearMove( const Point3d& ptP) ; + bool ResetMoveData( void) ; + + protected : + int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore + 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 + Vector3d m_vtCorr ; // direzione correzione corrente + Vector3d m_vtAux ; // direzione ausiliaria corrente + double m_dFeed ; // feed corrente + int m_nFlag ; // flag corrente +} ; diff --git a/Milling.cpp b/Milling.cpp new file mode 100644 index 0000000..000661e --- /dev/null +++ b/Milling.cpp @@ -0,0 +1,171 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Milling.cpp Data : 07.06.15 Versione : 1.6f2 +// Contenuto : Implementazione gestione fresature. +// +// +// +// Modifiche : 07.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "MachMgr.h" +#include "DllMain.h" +#include "Milling.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" +#include "/EgtDev/Include/EGnStringKeyVal.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +static std::string KEY_IDS = "IDS" ; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EMkMilling", Milling) ; + +//---------------------------------------------------------------------------- +const string& +Milling::GetClassName( void) const +{ + return USEROBJ_GETNAME( Milling) ; +} + +//---------------------------------------------------------------------------- +Milling* +Milling::Clone( void) const +{ + // alloco oggetto + Milling* pMill = new(nothrow) Milling ; + // eseguo copia dei dati + if ( pMill != nullptr) { + try { + pMill->m_nOwnerId = GDB_ID_NULL ; + pMill->m_pGeomDB = nullptr ; + pMill->m_Params = m_Params ; + pMill->m_TParams = m_TParams ; + } + catch( ...) { + delete pMill ; + return nullptr ; + } + } + // ritorno l'oggetto + return pMill ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += KEY_IDS + EQUAL + ToString( m_vId) + szNewLine ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + sOut += m_Params.ToString( i) + szNewLine ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + sOut += m_TParams.ToString( i) + szNewLine ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Save( STRVECTOR& vString) const +{ + try { + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + vString.insert( vString.begin(), nSize, "") ; + int k = - 1 ; + if ( ! SetVal( KEY_IDS, m_vId, vString[++k])) + return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + vString[++k] = m_Params.ToString( i) ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + vString[++k] = m_TParams.ToString( i) ; + } + catch( ...) { + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Load( const STRVECTOR& vString) +{ + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + if ( int( vString.size()) < nSize) + return false ; + int k = - 1 ; + if ( ! GetVal( vString[++k], KEY_IDS, m_vId)) + return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) { + int nKey ; + if ( ! m_Params.FromString( vString[++k], nKey) || nKey != i) + return false ; + } + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) { + int nKey ; + if ( ! m_TParams.FromString( vString[++k], nKey) || nKey != i) + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Milling::Milling( void) +{ + m_nOwnerId = GDB_ID_NULL ; + m_pGeomDB = nullptr ; + m_Params.m_sName = "*" ; + m_Params.m_sToolName = "*" ; + m_TParams.m_sName = "*" ; + m_TParams.m_sHead = "*" ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Prepare( const string& sMillName) +{ + // verifico il gestore lavorazioni + if ( m_pMchMgr == nullptr) + return false ; + // recupero il gestore DB utensili della macchina corrente + ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ; + if ( pTMgr == nullptr) + return false ; + // recupero il gestore DB lavorazioni della macchina corrente + MachiningsMgr* pMMgr = m_pMchMgr->GetCurrMachiningsMgr() ; + if ( pMMgr == nullptr) + return false ; + // ricerca della lavorazione di libreria con il nome indicato + const MillingData* pDdata = GetMillingData( pMMgr->GetMachining( sMillName)) ; + if ( pDdata == nullptr) + return false ; + m_Params = *pDdata ; + // ricerca dell'utensile usato dalla lavorazione + const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ; + if ( pTdata == nullptr) + return false ; + m_TParams = *pTdata ; + m_Params.m_sToolName = m_TParams.m_sName ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Milling::SetGeometry( const SELVECTOR& vIds) +{ + return false ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Apply( void) +{ + return false ; +} diff --git a/Milling.h b/Milling.h new file mode 100644 index 0000000..e4ac790 --- /dev/null +++ b/Milling.h @@ -0,0 +1,43 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Milling.h Data : 07.06.15 Versione : 1.6f2 +// Contenuto : Dichiarazione della classe Milling. +// +// +// +// Modifiche : 07.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machining.h" +#include "MillingData.h" +#include "ToolData.h" + +//---------------------------------------------------------------------------- +class Milling : public Machining +{ + public : // IUserObj + virtual Milling* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool ToSave( void) const { return true ; } + virtual bool Save( STRVECTOR& vString) const ; + virtual bool Load( const STRVECTOR& vString) ; + + public : // Machining + virtual bool Prepare( const std::string& sMillName) ; + virtual bool SetGeometry( const SELVECTOR& vIds) ; + virtual bool Apply( void) ; + + public : + Milling( void) ; + + private : + INTVECTOR m_vId ; // identificativi entità geometriche da lavorare + MillingData m_Params ; // parametri lavorazione + ToolData m_TParams ; // parametri utensile +} ; \ No newline at end of file diff --git a/Sawing.cpp b/Sawing.cpp new file mode 100644 index 0000000..d5a5b4f --- /dev/null +++ b/Sawing.cpp @@ -0,0 +1,348 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Sawing.cpp Data : 07.06.15 Versione : 1.6f2 +// Contenuto : Implementazione gestione tagli con lama. +// +// Note : Questa lavorazione è sempre espressa nel riferimento globale. +// +// Modifiche : 07.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "MachMgr.h" +#include "DllMain.h" +#include "Sawing.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" +#include "/EgtDev/Include/EGnStringKeyVal.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +static std::string SAW_IDS = "IDS" ; +static std::string SAW_T1 = "T1" ; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EMkSawing", Sawing) ; + +//---------------------------------------------------------------------------- +const string& +Sawing::GetClassName( void) const +{ + return USEROBJ_GETNAME( Sawing) ; +} + +//---------------------------------------------------------------------------- +Sawing* +Sawing::Clone( void) const +{ + // alloco oggetto + Sawing* pSaw = new(nothrow) Sawing ; + // eseguo copia dei dati + if ( pSaw != nullptr) { + try { + pSaw->m_nOwnerId = GDB_ID_NULL ; + pSaw->m_pGeomDB = nullptr ; + pSaw->m_Params = m_Params ; + pSaw->m_TParams = m_TParams ; + } + catch( ...) { + delete pSaw ; + return nullptr ; + } + } + // ritorno l'oggetto + return pSaw ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Dump( string& sOut, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += SAW_IDS + EQUAL + ToString( m_vId) + szNewLine ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + sOut += m_Params.ToString( i) + szNewLine ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + sOut += m_TParams.ToString( i) + szNewLine ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Save( STRVECTOR& vString) const +{ + try { + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + vString.insert( vString.begin(), nSize, "") ; + int k = - 1 ; + if ( ! SetVal( SAW_IDS, m_vId, vString[++k])) + return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) + vString[++k] = m_Params.ToString( i) ; + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) + vString[++k] = m_TParams.ToString( i) ; + } + catch( ...) { + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Load( const STRVECTOR& vString) +{ + int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ; + if ( int( vString.size()) < nSize) + return false ; + int k = - 1 ; + if ( ! GetVal( vString[++k], SAW_IDS, m_vId)) + return false ; + for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) { + int nKey ; + if ( ! m_Params.FromString( vString[++k], nKey) || nKey != i) + return false ; + } + for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) { + int nKey ; + if ( ! m_TParams.FromString( vString[++k], nKey) || nKey != i) + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +Sawing::Sawing( void) +{ + m_nOwnerId = GDB_ID_NULL ; + m_pGeomDB = nullptr ; + m_Params.m_sName = "*" ; + m_Params.m_sToolName = "*" ; + m_TParams.m_sName = "*" ; + m_TParams.m_sHead = "*" ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Prepare( const string& sSawName) +{ + // verifico il gestore lavorazioni + if ( m_pMchMgr == nullptr) + return false ; + // recupero il gestore DB utensili della macchina corrente + ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ; + if ( pTMgr == nullptr) + return false ; + // recupero il gestore DB lavorazioni della macchina corrente + MachiningsMgr* pMMgr = m_pMchMgr->GetCurrMachiningsMgr() ; + if ( pMMgr == nullptr) + return false ; + // ricerca della lavorazione di libreria con il nome indicato + const SawingData* pDdata = GetSawingData( pMMgr->GetMachining( sSawName)) ; + if ( pDdata == nullptr) + return false ; + m_Params = *pDdata ; + // ricerca dell'utensile usato dalla lavorazione + const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ; + if ( pTdata == nullptr) + return false ; + m_TParams = *pTdata ; + m_Params.m_sToolName = m_TParams.m_sName ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::SetGeometry( const SELVECTOR& vIds) +{ + // verifico validità gestore DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // reset della geometria corrente + m_vId.clear() ; + // verifico che gli identificativi rappresentino delle entità ammissibili + for ( const auto& Id : vIds) { + // test sull'entità + if ( ! VerifyGeometry( Id)) { + string sOut = "Entity " + ToString( Id) + " skipped by Sawing" ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + continue ; + } + // posso aggiungere alla lista + m_vId.push_back( Id) ; + } + return ( ! m_vId.empty()) ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Apply( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // 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 ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::VerifyGeometry( SelData Id) +{ + // ammessi : curve o facce di polymesh + + // !!! per ora accetto solo linee !!! + const ICurveLine* pLine = nullptr ; + const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; + // se direttamente la curva + if ( Id.nSub == SEL_SUB_ALL) + pLine = GetCurveLine( m_pGeomDB->GetGeoObj( Id.nId)) ; + // altrimenti sottocurva di composita + else { + const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ; + if ( pCompo != nullptr) + pLine = GetCurveLine( pCompo->GetCurve( Id.nSub)) ; + } + return ( pLine != nullptr) ; +} + +//---------------------------------------------------------------------------- +ICurve* +Sawing::GetCurve( SelData Id) +{ + // ammessi : curve o facce di polymesh + // nel caso di facce si deve recuperare la linea di base + + // !!! per ora accetto solo linee !!! + const ICurveLine* pLine = nullptr ; + const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; + // se direttamente la curva + if ( Id.nSub == SEL_SUB_ALL) + pLine = GetCurveLine( m_pGeomDB->GetGeoObj( Id.nId)) ; + // altrimenti sottocurva di composita + else { + const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ; + if ( pCompo != nullptr) + pLine = GetCurveLine( pCompo->GetCurve( Id.nSub)) ; + } + if ( pLine == nullptr) + return nullptr ; + // ne recupero il riferimento globale + Frame3d frGlob ; + if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob)) + return nullptr ; + // ne faccio una copia e la porto in globale + PtrOwner pCurve( pLine->Clone()) ; + if ( IsNull( pCurve)) + return nullptr ; + pCurve->ToGlob( frGlob) ; + // imposto estrusione a Zglob+ + pCurve->SetExtrusion( Z_AX) ; + return Release( pCurve) ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) +{ + // recupero la direzione della linea + pCurve->GetStartDir( vtTool) ; + // annullo la componente in Z e normalizzo + vtTool.z = 0 ; + if ( ! vtTool.Normalize()) + return false ; + // ruoto attorno a Zglob+ a seconda del lato mandrino + if ( m_Params.m_nHeadSide == SAW_HS_LEFT) + vtTool.Rotate( Z_AX, 0, 1) ; + else + vtTool.Rotate( Z_AX, 0, -1) ; + // versore correzione + vtCorr = Z_AX ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::AdjustForSide( ICurve* pCurve) +{ + // se lato lavoro e lato mandrino coincidono, non devo fare alcunché + if ( ( m_Params.m_nWorkSide == SAW_WS_LEFT && m_Params.m_nHeadSide == SAW_HS_LEFT) || + ( m_Params.m_nWorkSide == SAW_WS_RIGHT && m_Params.m_nHeadSide == SAW_HS_RIGHT)) + return true ; + // calcolo offset curva + double dOffs = 0 ; + if ( m_Params.m_nWorkSide == SAW_WS_LEFT) + dOffs = - m_TParams.m_dThick ; + else if ( m_Params.m_nWorkSide == SAW_WS_RIGHT) + dOffs = m_TParams.m_dThick ; + else if ( m_Params.m_nHeadSide == SAW_HS_LEFT) // lama in centro + dOffs = 0.5 * m_TParams.m_dThick ; + else // testa a destra e lama in centro + dOffs = - 0.5 * m_TParams.m_dThick ; + // eseguo offset curva ( nel piano XY globale) + return pCurve->SimpleOffset( dOffs) ; +} \ No newline at end of file diff --git a/Sawing.h b/Sawing.h new file mode 100644 index 0000000..e8e6341 --- /dev/null +++ b/Sawing.h @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : Sawing.h Data : 07.06.15 Versione : 1.6f2 +// Contenuto : Dichiarazione della classe Sawing. +// +// +// +// Modifiche : 07.06.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "Machining.h" +#include "SawingData.h" +#include "ToolData.h" + +class ICurve ; + +//---------------------------------------------------------------------------- +class Sawing : public Machining +{ + public : // IUserObj + virtual Sawing* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ; + virtual bool ToSave( void) const { return true ; } + virtual bool Save( STRVECTOR& vString) const ; + virtual bool Load( const STRVECTOR& vString) ; + + public : // Machining + virtual bool Prepare( const std::string& sSawName) ; + virtual bool SetGeometry( const SELVECTOR& vIds) ; + virtual bool Apply( void) ; + + public : + Sawing( void) ; + + private : + bool VerifyGeometry( SelData Id) ; + ICurve* GetCurve( SelData Id) ; + bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ; + bool AdjustForSide( ICurve* pCurve) ; + + private : + SELVECTOR m_vId ; // identificativi entità geometriche da lavorare + SawingData m_Params ; // parametri lavorazione + ToolData m_TParams ; // parametri utensile +} ; diff --git a/SawingData.h b/SawingData.h index 482bcd5..45c51eb 100644 --- a/SawingData.h +++ b/SawingData.h @@ -41,3 +41,17 @@ struct SawingData : public MachiningData 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 lavorazione di lama +enum { SAW_TY_STRICT = 0, + SAW_TY_CENT_ON = 1, + SAW_TY_CENT_OUT = 2, + SAW_TY_EXT_ON = 3, + SAW_TY_EXT_OUT = 4} ; diff --git a/Table.cpp b/Table.cpp index 7cfb243..da8f6ba 100644 --- a/Table.cpp +++ b/Table.cpp @@ -16,19 +16,19 @@ #include "Table.h" #include "MachConst.h" #include "/EgtDev/Include/EGkGdbConst.h" -#include "/EgtDev/Include/EGkObjUserFactory.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGkStringUtils3d.h" using namespace std ; //---------------------------------------------------------------------------- -OBJUSER_REGISTER( "EMkTable", Table) ; +USEROBJ_REGISTER( "EMkTable", Table) ; //---------------------------------------------------------------------------- const string& Table::GetClassName( void) const { - return OBJUSER_GETNAME( Table) ; + return USEROBJ_GETNAME( Table) ; } //---------------------------------------------------------------------------- diff --git a/Table.h b/Table.h index 7672e01..1835715 100644 --- a/Table.h +++ b/Table.h @@ -14,13 +14,13 @@ #pragma once #include "Machine.h" -#include "/EgtDev/Include/EGkObjUser.h" +#include "/EgtDev/Include/EGkUserObj.h" #include "/EgtDev/Include/EGkPoint3d.h" //---------------------------------------------------------------------------- -class Table : public IObjUser +class Table : public IUserObj { - public : + public : // IUserObj virtual Table* Clone( void) const ; virtual const std::string& GetClassName( void) const ; virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;