From f2b0401105d516a291c2a710696e4f57c5086677 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 28 Dec 2015 10:36:09 +0000 Subject: [PATCH] EgtMachKernel 1.6l4 : - per tagli di lama aggiunti parametri estensione inizio/fine dei percorsi - per forature attivata Preview - aggiunte funzioni GetGeometry a tutte le lavorazioni --- Drilling.cpp | 64 +++++++++- Drilling.h | 42 +++--- EgtMachKernel.rc | Bin 11782 -> 11782 bytes MachMgr.h | 291 +++++++++++++++++++++--------------------- MachMgrOperations.cpp | 18 ++- Machining.h | 1 + MachiningConst.h | 6 + Milling.cpp | 9 ++ Milling.h | 44 ++++--- Sawing.cpp | 58 ++++++++- Sawing.h | 42 +++--- SawingData.cpp | 28 ++++ SawingData.h | 4 +- 13 files changed, 395 insertions(+), 212 deletions(-) diff --git a/Drilling.cpp b/Drilling.cpp index ee080c8..93890b0 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -279,7 +279,60 @@ Drilling::SetGeometry( const SELVECTOR& vIds) bool Drilling::Preview( bool bRecalc) { - return false ; + // 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 Preview + int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ; + // se non c'è, lo aggiungo + if ( nPvId == GDB_ID_NULL) { + nPvId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nPvId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nPvId, MCH_PV) ; + } + // altrimenti lo svuoto + else + m_pGeomDB->EmptyGroup( nPvId) ; + // elaboro i singoli fori + int i = 0 ; + for ( const auto& vId : m_vId) { + // creo gruppo per geometria di lavorazione del foro + int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPvId, Frame3d()) ; + if ( nPathId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++i)) ; + m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vId)) ; + m_pGeomDB->SetMaterial( nPathId, GREEN) ; + // recupero i dati del foro + Hole hole ; + if ( ! GetHoleData( vId, hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > EPS_SMALL) { + m_pGeomDB->Erase( nPathId) ; + string sOut = "Entity " + ToString( vId) + " 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( vId) ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; + } + // inserisco circonferenza che rappresenta il foro + PtrOwner pCrvArc( CreateCurveArc()) ; + if ( IsNull( pCrvArc) || ! pCrvArc->Set( hole.ptIni, hole.vtDir, 0.5 * hole.dDiam)) + return false ; + // assegno il versore estrusione e lo spessore + pCrvArc->SetExtrusion( hole.vtDir) ; + pCrvArc->SetThickness( - hole.dLen) ; + // inserisco nel DB + int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrvArc)) ; + // assegno nome e colore + m_pGeomDB->SetName( nId, MCH_PV_CUT) ; + m_pGeomDB->SetMaterial( nId, LIME) ; + } + + return true ; } //---------------------------------------------------------------------------- @@ -440,6 +493,15 @@ Drilling::GetToolData( void) const return m_TParams ; } +//---------------------------------------------------------------------------- +bool +Drilling::GetGeometry( SELVECTOR& vIds) const +{ + // restituisco l'elenco delle entità + vIds = m_vId ; + return true ; +} + //---------------------------------------------------------------------------- bool Drilling::GetHoleData( SelData Id, Hole& hole) diff --git a/Drilling.h b/Drilling.h index 70389e3..4f4618a 100644 --- a/Drilling.h +++ b/Drilling.h @@ -23,28 +23,30 @@ struct Hole ; class Drilling : public Machining { public : // IUserObj - virtual Drilling* Clone( void) const ; - virtual const std::string& GetClassName( void) const ; - virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; - virtual bool ToSave( void) const { return true ; } - virtual bool Save( STRVECTOR& vString) const ; - virtual bool Load( const STRVECTOR& vString) ; + Drilling* Clone( void) const override ; + const std::string& GetClassName( void) const override ; + bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; + bool ToSave( void) const override + { return true ; } + bool Save( STRVECTOR& vString) const override ; + bool Load( const STRVECTOR& vString) override ; public : // Machining - virtual bool Prepare( const std::string& sDriName) ; - virtual bool SetParam( int nType, bool bVal) ; - virtual bool SetParam( int nType, int nVal) ; - virtual bool SetParam( int nType, double dVal) ; - virtual bool SetParam( int nType, const std::string& sVal) ; - virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Preview( bool bRecalc) ; - virtual bool Apply( bool bRecalc) ; - virtual bool GetParam( int nType, bool& bVal) const ; - virtual bool GetParam( int nType, int& nVal) const ; - virtual bool GetParam( int nType, double& dVal) const ; - virtual bool GetParam( int nType, std::string& sVal) const ; - virtual const ToolData& GetToolData( void) const ; - virtual bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) ; + bool Prepare( const std::string& sDriName) override ; + bool SetParam( int nType, bool bVal) override ; + bool SetParam( int nType, int nVal) override ; + bool SetParam( int nType, double dVal) override ; + bool SetParam( int nType, const std::string& sVal) override ; + bool SetGeometry( const SELVECTOR& vIds) override ; + bool Preview( bool bRecalc) override ; + bool Apply( bool bRecalc) override ; + bool GetParam( int nType, bool& bVal) const override ; + bool GetParam( int nType, int& nVal) const override ; + bool GetParam( int nType, double& dVal) const override ; + bool GetParam( int nType, std::string& sVal) const override ; + const ToolData& GetToolData( void) const override ; + bool GetGeometry( SELVECTOR& vIds) const override ; + bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : Drilling( void) ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index c2fd6c998a795718d24fddc13eea04ffbf0c2b8c..5c6d8b7d1a87e63673cd22d439c6c9760af9d90c 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFx>^ItYwW=50Aj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQ1Kv2 delta 97 zcmZpRX^YwLhmFyA^ItYwW=7-5j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHPhB8F diff --git a/MachMgr.h b/MachMgr.h index ff1cbcd..7a077ee 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -52,165 +52,166 @@ class MachMgr : public IMachMgr { public : // Basic - virtual ~MachMgr( void) ; - virtual bool Init( const std::string& sMachinesDir, IGeomDB* pGeomDB, - int nContextId, const std::string& sLuaLibsDir, const std::string& sLuaLastRequire) ; - virtual bool Update( void) ; - virtual bool Insert( int nInsGrp) ; + ~MachMgr( void) override ; + bool Init( const std::string& sMachinesDir, IGeomDB* pGeomDB, + int nContextId, const std::string& sLuaLibsDir, const std::string& sLuaLastRequire) override ; + bool Update( void) override ; + bool Insert( int nInsGrp) override ; // Machines - virtual bool SetCurrMachine( const std::string& sMachineName) ; - virtual bool GetCurrMachineName( std::string& sMachineName) const ; + bool SetCurrMachine( const std::string& sMachineName) override ; + bool GetCurrMachineName( std::string& sMachineName) const override ; // MachGroups - virtual int GetMachGroupCount( void) const ; - virtual int GetFirstMachGroup( void) const ; - virtual int GetNextMachGroup( int nId) const ; - virtual bool GetMachGroupNewName( std::string& sName) const ; - virtual int AddMachGroup( const std::string& sName, const std::string& sMachineName) ; - virtual bool RemoveMachGroup( int nId) ; - virtual std::string GetMachGroupName( int nId) const ; - virtual int GetMachGroupId( const std::string& sName) const ; - virtual bool SetCurrMachGroup( int nId) ; - virtual bool ResetCurrMachGroup( void) ; - virtual int GetCurrMachGroup( void) const ; + int GetMachGroupCount( void) const override ; + int GetFirstMachGroup( void) const override ; + int GetNextMachGroup( int nId) const override ; + bool GetMachGroupNewName( std::string& sName) const override ; + int AddMachGroup( const std::string& sName, const std::string& sMachineName) override ; + bool RemoveMachGroup( int nId) override ; + std::string GetMachGroupName( int nId) const override ; + int GetMachGroupId( const std::string& sName) const override ; + bool SetCurrMachGroup( int nId) override ; + bool ResetCurrMachGroup( void) override ; + int GetCurrMachGroup( void) const override ; // RawParts - virtual int GetRawPartCount( void) const ; - virtual int GetFirstRawPart( void) const ; - virtual int GetNextRawPart( int nId) const ; - virtual int AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ; - virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ; - virtual bool ModifyRawPart( int nRawId, const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ; - virtual bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) ; - virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ; - virtual bool RemoveRawPart( int nRawId) ; - virtual bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; - virtual bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ; - virtual bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ; - virtual bool MoveRawPart( int nRawId, const Vector3d& vtMove) ; + int GetRawPartCount( void) const override ; + int GetFirstRawPart( void) const override ; + int GetNextRawPart( int nId) const override ; + int AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) override ; + int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) override ; + bool ModifyRawPart( int nRawId, const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) override ; + bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) override ; + bool ModifyRawPartHeight( int nRawId, double dHeight) override ; + bool RemoveRawPart( int nRawId) override ; + bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) override ; + bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) override ; + bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) override ; + bool MoveRawPart( int nRawId, const Vector3d& vtMove) ; // Parts - virtual int GetPartInRawPartCount( int nRawId) const ; - virtual int GetFirstPartInRawPart( int nRawId) const ; - virtual int GetNextPartInRawPart( int nId) const ; - virtual bool AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ; - virtual bool RemovePartFromRawPart( int nPartId) ; - virtual bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ; - virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; + int GetPartInRawPartCount( int nRawId) const override ; + int GetFirstPartInRawPart( int nRawId) const override ; + int GetNextPartInRawPart( int nId) const override ; + bool AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) override ; + bool RemovePartFromRawPart( int nPartId) override ; + bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) override ; + bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) override ; // Tables and Fixtures - virtual bool SetTable( const std::string& sTable) ; - virtual bool GetTableRef( int nInd, Point3d& ptPos) ; - virtual bool GetTableArea( int nInd, BBox3d& b3Area) ; - virtual int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ; - virtual bool ShowOnlyTable( bool bVal) ; + bool SetTable( const std::string& sTable) override ; + bool GetTableRef( int nInd, Point3d& ptPos) override ; + bool GetTableArea( int nInd, BBox3d& b3Area) override ; + int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) override ; + bool ShowOnlyTable( bool bVal) override ; // Tools DataBase - virtual bool TdbGetToolNewName( std::string& sName) const ; - virtual bool TdbAddTool( const std::string& sName, int nType) ; - virtual bool TdbCopyTool( const std::string& sSource, const std::string& sName) ; - virtual bool TdbRemoveTool( const std::string& sName) ; - virtual bool TdbGetFirstTool( int nFamily, std::string& sName, int& nType) const ; - virtual bool TdbGetNextTool( int nFamily, std::string& sName, int& nType) const ; - virtual bool TdbSetCurrTool( const std::string& sName) ; - virtual bool TdbSaveCurrTool( void) ; - virtual bool TdbIsCurrToolModified( void) const ; - virtual bool TdbSetCurrToolParam( int nType, bool bVal) ; - virtual bool TdbSetCurrToolParam( int nType, int nVal) ; - virtual bool TdbSetCurrToolParam( int nType, double dVal) ; - virtual bool TdbSetCurrToolParam( int nType, const std::string& sVal) ; - virtual bool TdbGetCurrToolParam( int nType, bool& bVal) const ; - virtual bool TdbGetCurrToolParam( int nType, int& nVal) const ; - virtual bool TdbGetCurrToolParam( int nType, double& dVal) const ; - virtual bool TdbGetCurrToolParam( int nType, std::string& sVal) const ; - virtual bool TdbSave( void) const ; - virtual bool TdbGetToolDir( std::string& sToolDir) const ; - virtual bool TdbGetToolHolderDir( std::string& sTHolderDir) const ; + bool TdbGetToolNewName( std::string& sName) const override ; + bool TdbAddTool( const std::string& sName, int nType) override ; + bool TdbCopyTool( const std::string& sSource, const std::string& sName) override ; + bool TdbRemoveTool( const std::string& sName) override ; + bool TdbGetFirstTool( int nFamily, std::string& sName, int& nType) const override ; + bool TdbGetNextTool( int nFamily, std::string& sName, int& nType) const override ; + bool TdbSetCurrTool( const std::string& sName) override ; + bool TdbSaveCurrTool( void) override ; + bool TdbIsCurrToolModified( void) const override ; + bool TdbSetCurrToolParam( int nType, bool bVal) override ; + bool TdbSetCurrToolParam( int nType, int nVal) override ; + bool TdbSetCurrToolParam( int nType, double dVal) override ; + bool TdbSetCurrToolParam( int nType, const std::string& sVal) override ; + bool TdbGetCurrToolParam( int nType, bool& bVal) const override ; + bool TdbGetCurrToolParam( int nType, int& nVal) const override ; + bool TdbGetCurrToolParam( int nType, double& dVal) const override ; + bool TdbGetCurrToolParam( int nType, std::string& sVal) const override ; + bool TdbSave( void) const override ; + bool TdbGetToolDir( std::string& sToolDir) const override ; + bool TdbGetToolHolderDir( std::string& sTHolderDir) const override ; // Machinings DataBase - virtual bool MdbGetMachiningNewName( std::string& sName) const ; - virtual bool MdbAddMachining( const std::string& sName, int nType) ; - virtual bool MdbCopyMachining( const std::string& sSource, const std::string& sName) ; - virtual bool MdbRemoveMachining( const std::string& sName) ; - virtual bool MdbGetFirstMachining( int nType, std::string& sName) const ; - virtual bool MdbGetNextMachining( int nType, std::string& sName) const ; - virtual bool MdbSetCurrMachining( const std::string& sName) ; - virtual bool MdbSaveCurrMachining( void) ; - virtual bool MdbIsCurrMachiningModified( void) const ; - virtual bool MdbSetCurrMachiningParam( int nType, bool bVal) ; - virtual bool MdbSetCurrMachiningParam( int nType, int nVal) ; - virtual bool MdbSetCurrMachiningParam( int nType, double dVal) ; - virtual bool MdbSetCurrMachiningParam( int nType, const std::string& sVal) ; - virtual bool MdbGetCurrMachiningParam( int nType, bool& bVal) const ; - virtual bool MdbGetCurrMachiningParam( int nType, int& nVal) const ; - virtual bool MdbGetCurrMachiningParam( int nType, double& dVal) const ; - virtual bool MdbGetCurrMachiningParam( int nType, std::string& sVal) const ; - virtual bool MdbSetSafeZ( double dSafeZ) ; - virtual bool MdbGetSafeZ( double& dSafeZ) const ; - virtual bool MdbSave( void) const ; - virtual bool MdbGetMachiningDir( std::string& sMchDir) const ; + bool MdbGetMachiningNewName( std::string& sName) const override ; + bool MdbAddMachining( const std::string& sName, int nType) ; + bool MdbCopyMachining( const std::string& sSource, const std::string& sName) override ; + bool MdbRemoveMachining( const std::string& sName) override ; + bool MdbGetFirstMachining( int nType, std::string& sName) const override ; + bool MdbGetNextMachining( int nType, std::string& sName) const override ; + bool MdbSetCurrMachining( const std::string& sName) override ; + bool MdbSaveCurrMachining( void) override ; + bool MdbIsCurrMachiningModified( void) const override ; + bool MdbSetCurrMachiningParam( int nType, bool bVal) override ; + bool MdbSetCurrMachiningParam( int nType, int nVal) override ; + bool MdbSetCurrMachiningParam( int nType, double dVal) override ; + bool MdbSetCurrMachiningParam( int nType, const std::string& sVal) override ; + bool MdbGetCurrMachiningParam( int nType, bool& bVal) const override ; + bool MdbGetCurrMachiningParam( int nType, int& nVal) const override ; + bool MdbGetCurrMachiningParam( int nType, double& dVal) const override ; + bool MdbGetCurrMachiningParam( int nType, std::string& sVal) const override ; + bool MdbSetSafeZ( double dSafeZ) override ; + bool MdbGetSafeZ( double& dSafeZ) const override ; + bool MdbSave( void) const override ; + bool MdbGetMachiningDir( std::string& sMchDir) const override ; // Operations : general - virtual int GetOperationCount( void) const ; - virtual int GetFirstOperation( void) const ; - virtual int GetNextOperation( int nId) const ; - virtual int GetLastOperation( void) const ; - virtual int GetPrevOperation( int nId) const ; - virtual int GetFirstActiveOperation( void) const ; - virtual int GetNextActiveOperation( int nId) const ; - virtual int GetLastActiveOperation( void) const ; - virtual int GetPrevActiveOperation( int nId) const ; - virtual int GetOperationType( int nId) const ; - virtual std::string GetOperationName( int nId) const ; - virtual int GetOperationId( const std::string& sName) const ; - virtual bool RemoveOperation( int nId) ; - virtual bool RemoveAllOperations( bool bExceptFirstDisp) ; - virtual bool SetOperationMode( int nId, bool bActive) ; - virtual bool SetAllOperationsMode( bool bExceptFirstDisp, bool bActive) ; - virtual bool SetOperationStatus( int nId, bool bShow) ; - virtual bool SetAllOperationsStatus(bool bExceptFirstDisp, bool bShow) ; + int GetOperationCount( void) const override ; + int GetFirstOperation( void) const override ; + int GetNextOperation( int nId) const override ; + int GetLastOperation( void) const override ; + int GetPrevOperation( int nId) const override ; + int GetFirstActiveOperation( void) const override ; + int GetNextActiveOperation( int nId) const override ; + int GetLastActiveOperation( void) const override ; + int GetPrevActiveOperation( int nId) const override ; + int GetOperationType( int nId) const override ; + std::string GetOperationName( int nId) const override ; + int GetOperationId( const std::string& sName) const override ; + bool RemoveOperation( int nId) override ; + bool RemoveAllOperations( bool bExceptFirstDisp) override ; + bool SetOperationMode( int nId, bool bActive) override ; + bool SetAllOperationsMode( bool bExceptFirstDisp, bool bActive) override ; + bool SetOperationStatus( int nId, bool bShow) override ; + bool SetAllOperationsStatus(bool bExceptFirstDisp, bool bShow) override ; // Operations : dispositions - virtual int AddDisposition( const std::string& sName) ; + int AddDisposition( const std::string& sName) override ; // Operations : machinings - virtual int AddMachining( const std::string& sName, const std::string& sMachining) ; - virtual bool SetCurrMachining( int nId) ; - virtual bool ResetCurrMachining( void) ; - virtual int GetCurrMachining( void) const ; - virtual bool SetMachiningParam( int nType, bool bVal) ; - virtual bool SetMachiningParam( int nType, int nVal) ; - virtual bool SetMachiningParam( int nType, double dVal) ; - virtual bool SetMachiningParam( int nType, const std::string& sVal) ; - virtual bool SetMachiningGeometry( const SELVECTOR& vIds) ; - virtual bool MachiningPreview( bool bRecalc) ; - virtual bool MachiningApply( bool bRecalc) ; - virtual bool GetMachiningParam( int nType, bool& bVal) const ; - virtual bool GetMachiningParam( int nType, int& dVal) const ; - virtual bool GetMachiningParam( int nType, double& dVal) const ; - virtual bool GetMachiningParam( int nType, std::string& sVal) const ; + int AddMachining( const std::string& sName, const std::string& sMachining) override ; + bool SetCurrMachining( int nId) override ; + bool ResetCurrMachining( void) override ; + int GetCurrMachining( void) const override ; + bool SetMachiningParam( int nType, bool bVal) override ; + bool SetMachiningParam( int nType, int nVal) override ; + bool SetMachiningParam( int nType, double dVal) override ; + bool SetMachiningParam( int nType, const std::string& sVal) override ; + bool SetMachiningGeometry( const SELVECTOR& vIds) override ; + bool MachiningPreview( bool bRecalc) override ; + bool MachiningApply( bool bRecalc) override ; + bool GetMachiningParam( int nType, bool& bVal) const override ; + bool GetMachiningParam( int nType, int& dVal) const override ; + bool GetMachiningParam( int nType, double& dVal) const override ; + bool GetMachiningParam( int nType, std::string& sVal) const override ; + bool GetMachiningGeometry( SELVECTOR& vIds) const override ; // Simulation - virtual bool SimStart( void) ; - virtual bool SimMove( int& nStatus) ; - virtual bool SimGetAxisInfoPos( int nI, std::string& sName, double& dVal) ; - virtual bool SimGetToolInfo( std::string& sName, double& dSpeed) ; - virtual bool SimGetMoveInfo( int& nGmove, double& dFeed) ; - virtual bool SimSetStep( double dStep) ; - virtual bool SimStop( void) ; + bool SimStart( void) override ; + bool SimMove( int& nStatus) override ; + bool SimGetAxisInfoPos( int nI, std::string& sName, double& dVal) override ; + bool SimGetToolInfo( std::string& sName, double& dSpeed) override ; + bool SimGetMoveInfo( int& nGmove, double& dFeed) override ; + bool SimSetStep( double dStep) override ; + bool SimStop( void) override ; // Generation - virtual bool Generate( const std::string& sCncFile, const std::string& sInfo) ; + bool Generate( const std::string& sCncFile, const std::string& sInfo) override ; // Machine Calc - virtual bool SetCalcTable( const std::string& sTable) ; - virtual bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) ; - virtual bool GetCalcTool( std::string& sTool) ; - virtual bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ; - virtual bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, - int& nStat, double& dX, double& dY, double& dZ) ; - virtual bool GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bBottom, Point3d& ptTip) ; - virtual bool GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) ; - virtual bool GetNearestAngleInStroke( int nId, double dAngRef, double& dAng) ; - virtual bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; + bool SetCalcTable( const std::string& sTable) override ; + bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) override ; + bool GetCalcTool( std::string& sTool) override ; + bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, + int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) override ; + bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, + int& nStat, double& dX, double& dY, double& dZ) override ; + bool GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, + bool bBottom, Point3d& ptTip) override ; + bool GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) override ; + bool GetNearestAngleInStroke( int nId, double dAngRef, double& dAng) override ; + bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) override ; // Machine Move - virtual bool SetAxisPos( const std::string& sAxis, double dVal) ; - virtual bool GetAxisPos( const std::string& sAxis, double& dVal) ; - virtual bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ; - virtual bool ResetAxisPos( const std::string& sAxis) ; - virtual bool ResetAllAxesPos( void) ; - virtual bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; - virtual bool ResetHeadSet( const std::string& sHead) ; + bool SetAxisPos( const std::string& sAxis, double dVal) override ; + bool GetAxisPos( const std::string& sAxis, double& dVal) override ; + bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) override ; + bool ResetAxisPos( const std::string& sAxis) override ; + bool ResetAllAxesPos( void) override ; + bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) override ; + bool ResetHeadSet( const std::string& sHead) override ; public : MachMgr( void) ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 83f0920..feb9375 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -643,4 +643,20 @@ MachMgr::GetMachiningToolData( void) const return nullptr ; // recupero il parametro return &( pMch->GetToolData()) ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetMachiningGeometry( SELVECTOR& vIds) const +{ + // 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 ; + // restituisco la geometria originale + return pMch->GetGeometry( vIds) ; +} diff --git a/Machining.h b/Machining.h index 0a3ef3e..b40c578 100644 --- a/Machining.h +++ b/Machining.h @@ -46,6 +46,7 @@ class Machining : public IUserObj virtual bool GetParam( int nType, double& dVal) const = 0 ; virtual bool GetParam( int nType, std::string& sVal) const = 0 ; virtual const ToolData& GetToolData( void) const = 0 ; + virtual bool GetGeometry( SELVECTOR& vIds) const = 0 ; virtual bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) = 0 ; protected : diff --git a/MachiningConst.h b/MachiningConst.h index c513d12..92366d3 100644 --- a/MachiningConst.h +++ b/MachiningConst.h @@ -25,6 +25,12 @@ static std::string MCH_CL = "CL" ; static std::string MCH_PATH = "P" ; // Nomi di entità speciali static std::string MCH_RISE = "RISE" ; +// Nomi di entità di preview +static std::string MCH_PV_CUT = "CUT" ; +static std::string MCH_PV_PRE_CUT = "PRC" ; +static std::string MCH_PV_POST_CUT = "POC" ; +// Chaive info con DeltaT lama in Preview +static std::string MCH_PV_KEY_DT = "DT" ; //---------------------------------------------------------------------------- // Feed equivalente a massima diff --git a/Milling.cpp b/Milling.cpp index 13dbdc6..333dfd7 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -284,6 +284,15 @@ Milling::GetToolData( void) const return m_TParams ; } +//---------------------------------------------------------------------------- +bool +Milling::GetGeometry( SELVECTOR& vIds) const +{ + // restituisco l'elenco delle entità + vIds = m_vId ; + return true ; +} + //---------------------------------------------------------------------------- bool Milling::VerifyGeometry( SelData Id, int& nSubs) diff --git a/Milling.h b/Milling.h index 9ce074a..244920f 100644 --- a/Milling.h +++ b/Milling.h @@ -23,28 +23,30 @@ class ICurve ; class Milling : public Machining { public : // IUserObj - virtual Milling* Clone( void) const ; - virtual const std::string& GetClassName( void) const ; - virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; - virtual bool ToSave( void) const { return true ; } - virtual bool Save( STRVECTOR& vString) const ; - virtual bool Load( const STRVECTOR& vString) ; + Milling* Clone( void) const override ; + const std::string& GetClassName( void) const override ; + bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; + bool ToSave( void) const override + { return true ; } + bool Save( STRVECTOR& vString) const override ; + bool Load( const STRVECTOR& vString) override ; public : // Machining - virtual bool Prepare( const std::string& sMillName) ; - virtual bool SetParam( int nType, bool bVal) ; - virtual bool SetParam( int nType, int nVal) ; - virtual bool SetParam( int nType, double dVal) ; - virtual bool SetParam( int nType, const std::string& sVal) ; - virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Preview( bool bRecalc) ; - virtual bool Apply( bool bRecalc) ; - virtual bool GetParam( int nType, bool& bVal) const ; - virtual bool GetParam( int nType, int& nVal) const ; - virtual bool GetParam( int nType, double& dVal) const ; - virtual bool GetParam( int nType, std::string& sVal) const ; - virtual const ToolData& GetToolData( void) const ; - virtual bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) ; + bool Prepare( const std::string& sMillName) override ; + bool SetParam( int nType, bool bVal) override ; + bool SetParam( int nType, int nVal) override ; + bool SetParam( int nType, double dVal) override ; + bool SetParam( int nType, const std::string& sVal) override ; + bool SetGeometry( const SELVECTOR& vIds) override ; + bool Preview( bool bRecalc) override ; + bool Apply( bool bRecalc) override ; + bool GetParam( int nType, bool& bVal) const override ; + bool GetParam( int nType, int& nVal) const override ; + bool GetParam( int nType, double& dVal) const override ; + bool GetParam( int nType, std::string& sVal) const override ; + const ToolData& GetToolData( void) const ; + bool GetGeometry( SELVECTOR& vIds) const override ; + bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : Milling( void) ; @@ -55,7 +57,7 @@ class Milling : public Machining bool Chain( int nGrpDestId) ; private : - INTVECTOR m_vId ; // identificativi entità geometriche da lavorare + SELVECTOR 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 index 2da2e0f..d02fff5 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -257,6 +257,12 @@ Sawing::SetParam( int nType, double dVal) return false ; m_Params.m_dSideAngle = dVal ; return true ; + case MPA_STARTADDLEN : + m_Params.m_dStartAddLen = dVal ; + return true ; + case MPA_ENDADDLEN : + m_Params.m_dEndAddLen = dVal ; + return true ; case MPA_APPROX : m_Params.m_dApprox = dVal ; return true ; @@ -517,6 +523,12 @@ Sawing::GetParam( int nType, double& dVal) const case MPA_SIDEANGLE : dVal = m_Params.m_dSideAngle ; return true ; + case MPA_STARTADDLEN : + dVal = m_Params.m_dStartAddLen ; + return true ; + case MPA_ENDADDLEN : + dVal = m_Params.m_dEndAddLen ; + return true ; case MPA_APPROX : dVal = m_Params.m_dApprox ; return true ; @@ -556,6 +568,15 @@ Sawing::GetToolData( void) const return m_TParams ; } +//---------------------------------------------------------------------------- +bool +Sawing::GetGeometry( SELVECTOR& vIds) const +{ + // restituisco l'elenco delle entità + vIds = m_vId ; + return true ; +} + //---------------------------------------------------------------------------- bool Sawing::AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) @@ -814,6 +835,31 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId) return false ; ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ; + // eventuale allungamento/accorciamento dell'inizio + if ( abs( m_Params.m_dStartAddLen) > EPS_SMALL) { + if ( m_Params.m_dStartAddLen > 0) { + if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) + return false ; + } + else { + if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) + return false ; + } + } + + // eventuale allungamento/accorciamento della fine + if ( abs( m_Params.m_dEndAddLen) > EPS_SMALL) { + if ( m_Params.m_dEndAddLen > 0) { + if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) + return false ; + } + else { + double dLen ; + if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) + return false ; + } + } + // elaboro la curva composita e la esplodo nelle curve componenti if ( m_Params.m_nCurveUse == SAW_CRV_APPROX || m_Params.m_nCurveUse == SAW_CRV_CONVEX) { @@ -1021,7 +1067,8 @@ Sawing::GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const Point3d ptCross = ptEnd + vtToolH ; Vector3d vtDZ( 0, 0, 0.1) ; int nId = ExeCreateRectangle3P( nPxId, ptIni + vtDZ, ptCross + vtDZ, ptEnd + vtDZ, RTY_LOC) ; - // assegno colore + // assegno nome e colore + m_pGeomDB->SetName( nId, MCH_PV_CUT) ; m_pGeomDB->SetMaterial( nId, LIME) ; // distanza XY tra centro e bordo taglio @@ -1032,14 +1079,19 @@ Sawing::GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const // rettangolo per parte parziale iniziale int nId2 = ExeCreateRectangle3P( nPxId, ptIni - vtDir * dDeltaT, ptIni + vtToolH, ptIni, RTY_LOC) ; - // assegno colore + // assegno nome e colore + m_pGeomDB->SetName( nId2, MCH_PV_PRE_CUT) ; m_pGeomDB->SetMaterial( nId2, FUCHSIA) ; // rettangolo per parte parziale finale int nId3 = ExeCreateRectangle3P( nPxId, ptEnd, ptCross + vtDir * dDeltaT, ptEnd + vtDir * dDeltaT, RTY_LOC) ; - // assegno colore + // assegno nome e colore + m_pGeomDB->SetName( nId3, MCH_PV_POST_CUT) ; m_pGeomDB->SetMaterial( nId3, FUCHSIA) ; + // salvo in info del gruppo la distanza XY tra centro e bordo taglio + m_pGeomDB->SetInfo( nPxId, MCH_PV_KEY_DT, dDeltaT) ; + return true ; } diff --git a/Sawing.h b/Sawing.h index 0d6127f..cd815dd 100644 --- a/Sawing.h +++ b/Sawing.h @@ -24,28 +24,30 @@ class ICurveLine ; class Sawing : public Machining { public : // IUserObj - virtual Sawing* Clone( void) const ; - virtual const std::string& GetClassName( void) const ; - virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; - virtual bool ToSave( void) const { return true ; } - virtual bool Save( STRVECTOR& vString) const ; - virtual bool Load( const STRVECTOR& vString) ; + Sawing* Clone( void) const override ; + const std::string& GetClassName( void) const override ; + bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; + bool ToSave( void) const override + { return true ; } + bool Save( STRVECTOR& vString) const override ; + bool Load( const STRVECTOR& vString) override ; public : // Machining - virtual bool Prepare( const std::string& sSawName) ; - virtual bool SetParam( int nType, bool bVal) ; - virtual bool SetParam( int nType, int nVal) ; - virtual bool SetParam( int nType, double dVal) ; - virtual bool SetParam( int nType, const std::string& sVal) ; - virtual bool SetGeometry( const SELVECTOR& vIds) ; - virtual bool Preview( bool bRecalc) ; - virtual bool Apply( bool bRecalc) ; - virtual bool GetParam( int nType, bool& bVal) const ; - virtual bool GetParam( int nType, int& nVal) const ; - virtual bool GetParam( int nType, double& dVal) const ; - virtual bool GetParam( int nType, std::string& sVal) const ; - virtual const ToolData& GetToolData( void) const ; - virtual bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) ; + bool Prepare( const std::string& sSawName) override ; + bool SetParam( int nType, bool bVal) override ; + bool SetParam( int nType, int nVal) override ; + bool SetParam( int nType, double dVal) override ; + bool SetParam( int nType, const std::string& sVal) override ; + bool SetGeometry( const SELVECTOR& vIds) override ; + bool Preview( bool bRecalc) override ; + bool Apply( bool bRecalc) override ; + bool GetParam( int nType, bool& bVal) const override ; + bool GetParam( int nType, int& nVal) const override ; + bool GetParam( int nType, double& dVal) const override ; + bool GetParam( int nType, std::string& sVal) const override ; + const ToolData& GetToolData( void) const override ; + bool GetGeometry( SELVECTOR& vIds) const override ; + bool AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : Sawing( void) ; diff --git a/SawingData.cpp b/SawingData.cpp index cc6131e..d44bbcc 100644 --- a/SawingData.cpp +++ b/SawingData.cpp @@ -28,6 +28,7 @@ enum nSawingKey { KEY_APPR = 0, KEY_CRV, KEY_DH, + KEY_EAL, KEY_HS, KEY_INV, KEY_LETY, @@ -36,6 +37,7 @@ enum nSawingKey { KEY_NAME, KEY_PS, KEY_SA, + KEY_SAL, KEY_ST, KEY_STY, KEY_TNAME, @@ -48,6 +50,7 @@ static const std::array sSawingKey = { "APPR", "CRV", "DH", + "EAL", "HS", "INV", "LETY", @@ -56,6 +59,7 @@ static const std::array sSawingKey = { "NAME", "PS", "SA", + "SAL", "ST", "STY", "TN", @@ -106,6 +110,8 @@ SawingData::CopyFrom( const MachiningData* pMdata) m_dStep = pSdata->m_dStep ; m_nStepType = pSdata->m_nStepType ; m_dSideAngle = pSdata->m_dSideAngle ; + m_dStartAddLen = pSdata->m_dStartAddLen ; + m_dEndAddLen = pSdata->m_dEndAddLen ; m_nLeadInType = pSdata->m_nLeadInType ; m_nExtLinkType = pSdata->m_nExtLinkType ; m_nLeadOutType = pSdata->m_nLeadOutType ; @@ -138,6 +144,8 @@ SawingData::SameAs(const MachiningData* pMdata) const m_dStep == pSdata->m_dStep && m_nStepType == pSdata->m_nStepType && m_dSideAngle == pSdata->m_dSideAngle && + m_dStartAddLen == pSdata->m_dStartAddLen && + m_dEndAddLen == pSdata->m_dEndAddLen && m_nLeadInType == pSdata->m_nLeadInType && m_nExtLinkType == pSdata->m_nExtLinkType && m_nLeadOutType == pSdata->m_nLeadOutType && @@ -192,6 +200,9 @@ SawingData::FromString( const string& sString, int& nKey) if ( m_sDepth.empty()) m_sDepth = "0" ; break ; + case KEY_EAL : + bOk = ::FromString( sVal, m_dEndAddLen) ; + break ; case KEY_HS : bOk = ::FromString( sVal, m_nHeadSide) ; break ; @@ -217,6 +228,9 @@ SawingData::FromString( const string& sString, int& nKey) case KEY_SA : bOk = ::FromString( sVal, m_dSideAngle) ; break ; + case KEY_SAL : + bOk = ::FromString( sVal, m_dStartAddLen) ; + break ; case KEY_ST : bOk = ::FromString( sVal, m_dStep) ; break ; @@ -250,6 +264,7 @@ SawingData::ToString( int nInd) const case KEY_APPR : return ( sSawingKey[KEY_APPR] + "=" + ::ToString( m_dApprox)) ; case KEY_CRV : return ( sSawingKey[KEY_CRV] + "=" + ::ToString( m_nCurveUse)) ; case KEY_DH : return ( sSawingKey[KEY_DH] + "=" + m_sDepth) ; + case KEY_EAL : return ( sSawingKey[KEY_EAL] + "=" + ::ToString( m_dEndAddLen)) ; case KEY_HS : return ( sSawingKey[KEY_HS] + "=" + ::ToString( m_nHeadSide)) ; case KEY_INV : return ( sSawingKey[KEY_INV] + "=" + ::ToString( m_bInvert)) ; case KEY_LETY : return ( sSawingKey[KEY_LETY] + "=" + ::ToString( m_nExtLinkType)) ; @@ -258,6 +273,7 @@ SawingData::ToString( int nInd) const case KEY_NAME : return ( sSawingKey[KEY_NAME] + "=" + m_sName) ; case KEY_PS : return ( sSawingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_SA : return ( sSawingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ; + case KEY_SAL : return ( sSawingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ; case KEY_ST : return ( sSawingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_STY : return ( sSawingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ; case KEY_TNAME : return ( sSawingKey[KEY_TNAME] + "=" + m_sToolName) ; @@ -417,6 +433,12 @@ SawingData::SetParam( int nType, double dVal) return false ; m_dSideAngle = dVal ; return true ; + case MPA_STARTADDLEN : + m_dStartAddLen = dVal ; + return true ; + case MPA_ENDADDLEN : + m_dEndAddLen = dVal ; + return true ; case MPA_APPROX : m_dApprox = dVal ; return true ; @@ -505,6 +527,12 @@ SawingData::GetParam( int nType, double& dVal) const case MPA_SIDEANGLE : dVal = m_dSideAngle ; return true ; + case MPA_STARTADDLEN : + dVal = m_dStartAddLen ; + return true ; + case MPA_ENDADDLEN : + dVal = m_dEndAddLen ; + return true ; case MPA_APPROX : dVal = m_dApprox ; return true ; diff --git a/SawingData.h b/SawingData.h index d058430..8d4c2ea 100644 --- a/SawingData.h +++ b/SawingData.h @@ -28,6 +28,8 @@ struct SawingData : public MachiningData double m_dStep ; // passo di affondamento (0=nessun passo) int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, va e vieni) double m_dSideAngle ; // angolo di sbandamento (0..+60deg, 99=auto) + double m_dStartAddLen ; // lunghezza addizionale da aggiungere all'inizio + double m_dEndAddLen ; // lunghezza addizionale da aggiungere alla fine int m_nLeadInType ; // tipo di attacco (interno, centro, fuori, esteso, esteso fuori) int m_nExtLinkType ; // tipo di collegamento su ang esterno ( centro, esteso prec, esteso succ, esteso minore) int m_nLeadOutType ; // tipo di uscita (interno, centro, esteso) @@ -36,7 +38,7 @@ struct SawingData : public MachiningData SawingData( void) : m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), - m_dStartPos( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0), + m_dStartPos( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0), m_dStartAddLen(0), m_dEndAddLen(0), m_nLeadInType( 0), m_nExtLinkType( 0), m_nLeadOutType( 0), m_nCurveUse( 0), m_dApprox( 0) {} virtual SawingData* Clone( void) const ; virtual bool CopyFrom( const MachiningData* pMdata) ;