From 754a9a65060104be68497022f9075b286bb725c3 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 10 Jun 2019 07:06:17 +0000 Subject: [PATCH] EgtMachKernel 2.1f1 : - migliorie a finitura superfici - resi costanti alcuni metodi delle classi Operations. --- Chiseling.cpp | 4 +- Chiseling.h | 4 +- EgtMachKernel.rc | Bin 11774 -> 11774 bytes EgtMachKernel.sln | 7 +- Milling.cpp | 10 +- Milling.h | 12 +- Mortising.cpp | 4 +- Mortising.h | 4 +- Operation.cpp | 46 ++--- Operation.h | 48 ++--- Pocketing.cpp | 14 +- Pocketing.h | 10 +- SurfFinishing.cpp | 433 +++++++++++++++++++++++++++++++++++++++------- SurfFinishing.h | 15 +- 14 files changed, 462 insertions(+), 149 deletions(-) diff --git a/Chiseling.cpp b/Chiseling.cpp index 4c0ea1d..656efe8 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -1393,7 +1393,7 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool Chiseling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, - double& dElev) + double& dElev) const { dElev = 0 ; int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -1588,7 +1588,7 @@ Chiseling::GenerateChiselingCl( const SqHole& hole, int nPathId) //---------------------------------------------------------------------------- double -Chiseling::GetRadiusForStartEndElevation( void) +Chiseling::GetRadiusForStartEndElevation( void) const { const double DELTA_ELEV_RAD = 20.0 ; return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ; diff --git a/Chiseling.h b/Chiseling.h index a3dd3fb..e713dec 100644 --- a/Chiseling.h +++ b/Chiseling.h @@ -72,10 +72,10 @@ class Chiseling : public Machining bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ; bool Chain( int nGrpDestId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ; bool GenerateChiselingPv( const SqHole& hole, int nPathId) ; bool GenerateChiselingCl( const SqHole& hole, int nPathId) ; - double GetRadiusForStartEndElevation( void) ; + double GetRadiusForStartEndElevation( void) const ; private : double GetFeed() const diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index c2d9c56df8c5a1b3f39bdd49a40570b70474d590..5350ca90afb14113ad04d504cb28c0659364b5b5 100644 GIT binary patch delta 121 zcmewt{V#gMH#Sx?1|0^&&A-{KnVHiV3@1O7)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RV5MCZGTS delta 121 zcmewt{V#gMH#SyN1|0^o&A-{KnVC}=%qBmS)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RVTECcppy diff --git a/EgtMachKernel.sln b/EgtMachKernel.sln index b04e54a..70e1d53 100644 --- a/EgtMachKernel.sln +++ b/EgtMachKernel.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.645 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtMachKernel", "EgtMachKernel.vcxproj", "{0BD58222-92F3-48B2-B656-4497D1956874}" EndProject @@ -25,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {302E156A-9D72-4BAC-A866-C6E13545A61B} + EndGlobalSection EndGlobal diff --git a/Milling.cpp b/Milling.cpp index 7fcf1a0..c25d9d3 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -1798,7 +1798,7 @@ Milling::AdjustPathDrawForSaw( int nClPathId) //---------------------------------------------------------------------------- bool Milling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, - double& dElev) + double& dElev) const { dElev = 0 ; int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -3169,7 +3169,7 @@ Milling::GetLeadInType( void) const //---------------------------------------------------------------------------- bool Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) + double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const { // Assegno tipo e parametri int nType = GetLeadInType() ; @@ -3510,7 +3510,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d //---------------------------------------------------------------------------- double -Milling::GetRadiusForStartEndElevation( void) +Milling::GetRadiusForStartEndElevation( void) const { const double DELTA_ELEV_RAD = 20.0 ; double dDeltaRad = DELTA_ELEV_RAD + max( max( m_Params.m_dStartAddLen, m_Params.m_dEndAddLen), 0.0) ; @@ -3519,7 +3519,7 @@ Milling::GetRadiusForStartEndElevation( void) //---------------------------------------------------------------------------- bool -Milling::GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) +Milling::GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) const { // per frese normali if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { @@ -3543,7 +3543,7 @@ Milling::GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) //---------------------------------------------------------------------------- bool -Milling::GetPointAboveRaw( const Point3d& ptP) +Milling::GetPointAboveRaw( const Point3d& ptP) const { // determino la posizione del punto rispetto al grezzo // ciclo sui grezzi diff --git a/Milling.h b/Milling.h index e08c7af..c5a9f11 100644 --- a/Milling.h +++ b/Milling.h @@ -73,7 +73,7 @@ class Milling : public Machining bool Chain( int nGrpDestId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool AdjustPathDrawForSaw( int nClPathId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ; bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ; bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ; bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, @@ -92,14 +92,14 @@ class Milling : public Machining bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr, bool bAboveEnd) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) ; + double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ; bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, double dEndElev, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) ; - double GetRadiusForStartEndElevation( void) ; - bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) ; - bool GetPointAboveRaw( const Point3d& ptP) ; + double GetRadiusForStartEndElevation( void) const ; + bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool) const ; + bool GetPointAboveRaw( const Point3d& ptP) const ; bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU) ; Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU) ; bool CalcOffset( ICurveComposite* pCompo, double dSignOffs) ; @@ -121,7 +121,7 @@ class Milling : public Machining { return ( IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; } int GetLeadInType( void) const ; int GetLeadOutType( void) const ; - bool IsLeadInHelixOrZigzag() + bool IsLeadInHelixOrZigzag() const { int nType = GetLeadInType() ; return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) ; } friend class LeadIOStatus ; diff --git a/Mortising.cpp b/Mortising.cpp index 2145e04..3b0c75d 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -1323,7 +1323,7 @@ Mortising::ProcessPath( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool Mortising::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, - double& dElev) + double& dElev) const { dElev = 0 ; int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -1497,7 +1497,7 @@ Mortising::GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& v //---------------------------------------------------------------------------- double -Mortising::GetRadiusForStartEndElevation( void) +Mortising::GetRadiusForStartEndElevation( void) const { const double DELTA_ELEV_RAD = 20.0 ; return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ; diff --git a/Mortising.h b/Mortising.h index e9d6b6f..6ce9bba 100644 --- a/Mortising.h +++ b/Mortising.h @@ -71,10 +71,10 @@ class Mortising : public Machining ICurve* GetCurve( SelData Id) ; bool Chain( int nGrpDestId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ; bool GenerateMortisingPv( int nPathId, const ICurveComposite* pCompo) ; bool GenerateMortisingCl( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep) ; - double GetRadiusForStartEndElevation( void) ; + double GetRadiusForStartEndElevation( void) const ; private : double GetSpeed() const diff --git a/Operation.cpp b/Operation.cpp index 31c7ba4..2a2cea7 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -122,7 +122,7 @@ Operation::UpdateFollowingOperationsStatus(int nModif) //---------------------------------------------------------------------------- bool Operation::GetElevation( int nPhase, const Point3d& ptP, - const Vector3d& vtDir, double& dElev) + const Vector3d& vtDir, double& dElev) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -183,7 +183,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP, //---------------------------------------------------------------------------- bool Operation::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, - const Vector3d& vtDir, double& dElev) + const Vector3d& vtDir, double& dElev) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -265,7 +265,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, //---------------------------------------------------------------------------- bool Operation::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3, - const Vector3d& vtDir, double& dElev) + const Vector3d& vtDir, double& dElev) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -282,7 +282,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, c //---------------------------------------------------------------------------- bool Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad, - const Vector3d& vtDir, double& dElev) + const Vector3d& vtDir, double& dElev) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -308,7 +308,7 @@ Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, //---------------------------------------------------------------------------- bool -Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) +Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -377,7 +377,7 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3 //---------------------------------------------------------------------------- bool -Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) +Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -460,7 +460,7 @@ Operation::GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dEx //---------------------------------------------------------------------------- bool -Operation::GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) +Operation::GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -493,7 +493,7 @@ Operation::GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, dou //---------------------------------------------------------------------------- bool -Operation::GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) +Operation::GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -508,7 +508,7 @@ Operation::GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) //---------------------------------------------------------------------------- bool -Operation::GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) +Operation::GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -715,7 +715,7 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF //---------------------------------------------------------------------------- bool -Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo) +Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo) const { // recupero estrusione e spessore Vector3d vtExtr = Z_AX ; @@ -751,7 +751,7 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo) //---------------------------------------------------------------------------- bool -Operation::ApproxWithLines( ICurveComposite* pCompo) +Operation::ApproxWithLines( ICurveComposite* pCompo) const { // recupero estrusione e spessore Vector3d vtExtr = Z_AX ; @@ -774,7 +774,7 @@ Operation::ApproxWithLines( ICurveComposite* pCompo) //---------------------------------------------------------------------------- bool -Operation::VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen) +Operation::VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen) const { // verifiche sull'ampiezza dell'angolo al centro degli eventuali archi int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -850,7 +850,7 @@ Operation::CalcAndSetBBox( int nClId) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- bool -Operation::GetInitialAxesValues( DBLVECTOR& vAxVal) +Operation::GetInitialAxesValues( DBLVECTOR& vAxVal) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -866,7 +866,7 @@ Operation::GetInitialAxesValues( DBLVECTOR& vAxVal) //---------------------------------------------------------------------------- bool -Operation::GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) +Operation::GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -883,7 +883,7 @@ Operation::GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) //---------------------------------------------------------------------------- bool -Operation::GetFinalAxesValues( DBLVECTOR& vAxVal) +Operation::GetFinalAxesValues( DBLVECTOR& vAxVal) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -899,7 +899,7 @@ Operation::GetFinalAxesValues( DBLVECTOR& vAxVal) //---------------------------------------------------------------------------- bool -Operation::GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) +Operation::GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) const { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -916,7 +916,7 @@ Operation::GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) //---------------------------------------------------------------------------- string -Operation::ExtractInfo( const string& sNotes, const string& sKey) +Operation::ExtractInfo( const string& sNotes, const string& sKey) const { string sInfo ; STRVECTOR vsCmd ; @@ -934,7 +934,7 @@ Operation::ExtractInfo( const string& sNotes, const string& sKey) //---------------------------------------------------------------------------- string -Operation::ExtractHint( const string& sNotes) +Operation::ExtractHint( const string& sNotes) const { return ExtractInfo( sNotes, "Hint:") ; } @@ -1728,7 +1728,7 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, const DBLVE //---------------------------------------------------------------------------- bool -Operation::ToolChangeNeeded( const Operation& Op1, const Operation& Op2) +Operation::ToolChangeNeeded( const Operation& Op1, const Operation& Op2) const { // se non cambia l'utensile, non cambia la testa fisica if ( EqualNoCase( Op1.GetToolName(), Op2.GetToolName())) @@ -1966,7 +1966,7 @@ Operation::RemoveHome( void) //---------------------------------------------------------------------------- bool -Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) +Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) const { if ( m_pMchMgr == nullptr) return false ; @@ -2020,7 +2020,7 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR //---------------------------------------------------------------------------- bool -Operation::ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) +Operation::ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const { // Recupero macchina corrente Machine* pMch = ( m_pMchMgr != nullptr ? m_pMchMgr->GetCurrMachine() : nullptr) ; @@ -2049,7 +2049,7 @@ Operation::ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) //---------------------------------------------------------------------------- bool -Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) +Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const { // Recupero macchina corrente Machine* pMch = ( m_pMchMgr != nullptr ? m_pMchMgr->GetCurrMachine() : nullptr) ; @@ -2235,7 +2235,7 @@ Operation::SpecialMoveZup( Vector3d& vtTool, DBLVECTOR& vAx, bool& bModif) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- bool -Operation::GetAggrBottomData( const string& sHead, AggrBottom& agbData) +Operation::GetAggrBottomData( const string& sHead, AggrBottom& agbData) const { // inizializzo la struttura agbData.Clear() ; diff --git a/Operation.h b/Operation.h index 85f913b..7ff5135 100644 --- a/Operation.h +++ b/Operation.h @@ -66,51 +66,51 @@ class Operation : public IUserObj protected : bool UpdateFollowingOperationsStatus( int nModif) ; bool GetElevation( int nPhase, const Point3d& ptP, - const Vector3d& vtDir, double& dElev) ; + const Vector3d& vtDir, double& dElev) const ; bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, - const Vector3d& vtDir, double& dElev) ; + const Vector3d& vtDir, double& dElev) const ; bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3, - const Vector3d& vtDir, double& dElev) ; + const Vector3d& vtDir, double& dElev) const ; bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad, - const Vector3d& vtDir, double& dElev) ; - bool GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) ; - bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) ; - bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) + const Vector3d& vtDir, double& dElev) const ; + bool GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) const ; + bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand, double& dDist, Vector3d& vtDir) const ; + bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) const { double dDummy ; return GetDistanceFromRawBottom( nPhase, nPathId, dToler, dRbDist, dDummy) ; } - bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) ; - bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) ; - bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) ; + bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const ; + bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) const ; + bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) const ; bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick) ; - bool ApproxWithArcsIfUseful( ICurveComposite* pCompo) ; - bool ApproxWithLines( ICurveComposite* pCompo) ; - bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) ; + bool ApproxWithArcsIfUseful( ICurveComposite* pCompo) const ; + bool ApproxWithLines( ICurveComposite* pCompo) const ; + bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) const ; bool CalcAndSetBBox( int nClId) ; - bool GetInitialAxesValues( DBLVECTOR& vAxVal) ; - bool GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) ; - bool GetFinalAxesValues( DBLVECTOR& vAxVal) ; - bool GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) ; - std::string Operation::ExtractInfo( const std::string& sNotes, const std::string& sKey) ; - std::string ExtractHint( const std::string& sNotes) ; + bool GetInitialAxesValues( DBLVECTOR& vAxVal) const ; + bool GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) const ; + bool GetFinalAxesValues( DBLVECTOR& vAxVal) const ; + bool GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) const ; + std::string ExtractInfo( const std::string& sNotes, const std::string& sKey) const ; + std::string ExtractHint( const std::string& sNotes) const ; bool CalculateAxesValues( const std::string& sHint, bool bSolChExact = false) ; bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) ; bool AdjustStartEndMovements( bool bVerifyPreviousLink = true) ; bool AdjustOneStartMovement( int nClPathId, int nPrevClPathId, const DBLVECTOR& vAxPrev, bool bMaxZ) ; - bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) ; + bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) const ; bool RemoveClimb( int nClPathId) ; bool AddRise( DBLVECTOR& vAxVal, double dDelta = - 1, int nClPathId = GDB_ID_NULL) ; bool RemoveRise( int nClPathId = GDB_ID_NULL) ; bool AddHome( void) ; - bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) ; - bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) ; - bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) ; + bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) const ; + bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ; + bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ; bool SpecialMoveZup( Vector3d& vtTool, DBLVECTOR& vAx, bool& bModif) ; - bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) ; + bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) const ; protected : int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore diff --git a/Pocketing.cpp b/Pocketing.cpp index 6940dfe..fa4be11 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1590,7 +1590,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) //---------------------------------------------------------------------------- bool Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, - double& dElev) + double& dElev) const { dElev = 0 ; int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -1765,13 +1765,13 @@ Pocketing::GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) } //---------------------------------------------------------------------------- -double +static double GetCurveRadius( const ICurve* pCrv) { if ( pCrv == nullptr) return 0.0 ; BBox3d b3Loc ; - if ( ! pCrv->GetLocalBBox( b3Loc)) + if ( ! pCrv->GetLocalBBox( b3Loc, BBF_EXACT)) return 0.0 ; double dRad ; if ( ! b3Loc.GetRadius( dRad)) @@ -3219,7 +3219,7 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ //---------------------------------------------------------------------------- bool Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - const ICurveComposite* pRCrv, Point3d& ptP1) + const ICurveComposite* pRCrv, Point3d& ptP1) const { // Assegno tipo e parametri int nType = GetLeadInType() ; @@ -3424,7 +3424,7 @@ Pocketing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector //---------------------------------------------------------------------------- double -Pocketing::GetRadiusForStartEndElevation( void) +Pocketing::GetRadiusForStartEndElevation( void) const { const double DELTA_ELEV_RAD = 20.0 ; return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ; @@ -3598,7 +3598,7 @@ Pocketing::AdjustContourStart( ICurveComposite* pCompo) //---------------------------------------------------------------------------- bool -Pocketing::VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) +Pocketing::VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) const { // recupero il piano della curva di contorno Point3d ptStart ; @@ -3614,7 +3614,7 @@ Pocketing::VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCe //---------------------------------------------------------------------------- bool -Pocketing::VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) +Pocketing::VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) const { // recupero il piano della curva di contorno Point3d ptStart ; diff --git a/Pocketing.h b/Pocketing.h index 10eec75..7a2115d 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -70,7 +70,7 @@ class Pocketing : public Machining bool ResetCurveAllTempProp( ICurve* pCurve) ; bool Chain( int nGrpDestId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; - bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ; + bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ; bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ; bool GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) ; bool AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, @@ -95,16 +95,16 @@ class Pocketing : public Machining bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, - const ICurveComposite* pRCrv, Point3d& ptP1) ; + const ICurveComposite* pRCrv, Point3d& ptP1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, const ICurveComposite* pCompo, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs, bool bNoneForced = false) ; bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev, bool bNoneForced = false) ; - double GetRadiusForStartEndElevation( void) ; + double GetRadiusForStartEndElevation( void) const ; bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ; bool AdjustContourStart( ICurveComposite* pCompo) ; - bool VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) ; - bool VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) ; + bool VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) const ; + bool VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) const ; private : double GetSpeed( void) const diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index 6ccb355..1c6bc23 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -1179,8 +1179,21 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId) // Eseguo la lavorazione a seconda del tipo double dElev = dDepth ; - if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs)) - return false ; + switch ( m_Params.m_nSubType) { + case SURFFIN_SUB_ONEWAY : + case SURFFIN_SUB_ZIGZAG : + if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev)) + return false ; + break ; + case SURFFIN_SUB_SPIRALIN : + if ( ! AddSpiral( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, true)) + return false ; + break ; + case SURFFIN_SUB_SPIRALOUT : + if ( ! AddSpiral( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, false)) + return false ; + break ; + } } // incremento numero di percorsi @@ -1189,11 +1202,51 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId) return true ; } +//---------------------------------------------------------------------------- +bool +SurfFinishing::GetActiveSurfaces( INTVECTOR& vSurfId) const +{ + // pulisco vettore superfici + vSurfId.clear() ; + // verifiche + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // ciclo sui grezzi attivi nella fase + int nRawId = m_pMchMgr->GetFirstRawPart() ; + while ( nRawId != GDB_ID_NULL) { + if ( m_pMchMgr->VerifyRawPartPhase(nRawId, m_nPhase)) { + // ciclo sui pezzi del grezzo + int nPartId = m_pMchMgr->GetFirstPartInRawPart( nRawId) ; + while ( nPartId != GDB_ID_NULL) { + // ciclo sui layer dei pezzi + int nLayId = m_pGeomDB->GetFirstGroupInGroup( nPartId) ; + while ( nLayId != GDB_ID_NULL) { + // ciclo sulle entità del layer + int nEntId = m_pGeomDB->GetFirstInGroup( nLayId) ; + while ( nEntId != GDB_ID_NULL) { + // se entità superficie e visibile, la aggiungo + int nStat ; + if ( m_pGeomDB->GetGeoType( nEntId) == SRF_TRIMESH && + m_pGeomDB->GetCalcStatus( nEntId, nStat) && nStat != GDB_ST_OFF) + vSurfId.emplace_back( nEntId) ; + // passo alla entità successiva + nEntId = m_pGeomDB->GetNext( nEntId) ; + } + nLayId =m_pGeomDB->GetNextGroup( nLayId) ; + } + nPartId = m_pMchMgr->GetNextPartInRawPart( nPartId) ; + } + } + nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; + } + return true ; +} + //---------------------------------------------------------------------------- bool SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) + double dDepth, double dElev) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -1288,7 +1341,9 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) return false ; // determino elevazione su inizio attacco - double dStElev = dElev ; + double dStElev ; + if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) + dStElev = dElev ; dStElev -= ( ptP1 - ptStart) * vtExtr ; // se inizio, approccio globale al punto iniziale if ( bStart) { @@ -1312,25 +1367,15 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, return false ; } } - // elaborazioni sulla curva corrente - if ( pCurve->GetType() == CRV_LINE) { - ICurveLine* pLine = GetCurveLine( pCurve) ; - Point3d ptP3 = pLine->GetEnd() ; - SetFeed( GetFeed()) ; - if ( AddLinearMove( ptP3) == GDB_ID_NULL) - return false ; - } - else if ( pCurve->GetType() == CRV_ARC) { - ICurveArc* pArc = GetCurveArc( pCurve) ; - Point3d ptCen = pArc->GetCenter() ; - double dAngCen = pArc->GetAngCenter() ; - Vector3d vtN = pArc->GetNormVersor() ; - Point3d ptP3 ; - pArc->GetEndPoint( ptP3) ; - SetFeed( GetFeed()) ; - if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL) - return false ; - } + // elaborazioni sulla curva corrente (sempre un segmento di retta) + ICurveLine* pLine = GetCurveLine( pCurve) ; + if ( pLine == nullptr) + return false ; + Point3d ptP3 = pLine->GetEnd() ; + Vector3d vtMove ; pLine->GetStartDir( vtMove) ; + SetFeed( GetRightFeed( vtMove, vtTool)) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; // se ultima entità if ( i == nMaxInd) { // dati fine entità @@ -1338,8 +1383,11 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, pCurve->GetEndPoint( ptEnd) ; Vector3d vtEnd ; pCurve->GetEndDir( vtEnd) ; + // determino elevazione su uscita + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + dEndElev = dElev ; // aggiungo uscita - double dEndElev = dElev ; Point3d ptP1 ; SetFeed( GetEndFeed()) ; if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) { @@ -1368,46 +1416,6 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, return true ; } -//---------------------------------------------------------------------------- -bool -SurfFinishing::GetActiveSurfaces( INTVECTOR& vSurfId) -{ - // pulisco vettore superfici - vSurfId.clear() ; - // verifiche - if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) - return false ; - // ciclo sui grezzi attivi nella fase - int nRawId = m_pMchMgr->GetFirstRawPart() ; - while ( nRawId != GDB_ID_NULL) { - if ( m_pMchMgr->VerifyRawPartPhase(nRawId, m_nPhase)) { - // ciclo sui pezzi del grezzo - int nPartId = m_pMchMgr->GetFirstPartInRawPart( nRawId) ; - while ( nPartId != GDB_ID_NULL) { - // ciclo sui layer dei pezzi - int nLayId = m_pGeomDB->GetFirstGroupInGroup( nPartId) ; - while ( nLayId != GDB_ID_NULL) { - // ciclo sulle entità del layer - int nEntId = m_pGeomDB->GetFirstInGroup( nLayId) ; - while ( nEntId != GDB_ID_NULL) { - // se entità superficie e visibile, la aggiungo - int nStat ; - if ( m_pGeomDB->GetGeoType( nEntId) == SRF_TRIMESH && - m_pGeomDB->GetCalcStatus( nEntId, nStat) && nStat != GDB_ST_OFF) - vSurfId.emplace_back( nEntId) ; - // passo alla entità successiva - nEntId = m_pGeomDB->GetNext( nEntId) ; - } - nLayId =m_pGeomDB->GetNextGroup( nLayId) ; - } - nPartId = m_pMchMgr->GetNextPartInRawPart( nPartId) ; - } - } - nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; - } - return true ; -} - //---------------------------------------------------------------------------- bool SurfFinishing::CalcZigZag( const ICurveComposite* pOffs, @@ -1602,6 +1610,275 @@ SurfFinishing::CalcZigZag( const ICurveComposite* pOffs, return true ; } +//---------------------------------------------------------------------------- +bool +SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, + double dDepth, double dElev, bool bInVsOut) +{ + // recupero distanze di sicurezza + double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; + double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ; + // lunghezza di approccio/retrazione + double dAppr = m_Params.m_dStartPos ; + + // calcolo la spirale dall'esterno all'interno e la curva che unisce inizio e fine + PtrOwner pMCrv( CreateCurveComposite()) ; + if ( IsNull( pMCrv)) { + m_pMchMgr->SetLastError( 3109, "Error in SurfFinishing : Offset not computable") ; + return false ; + } + if ( ! CalcSpiral( pCompo, false, pMCrv, nullptr)) + return false ; + if ( ! bInVsOut) + pMCrv->Invert() ; + + // ciclo sulle curve risultanti + bool bStart = true ; + if ( true) { + // determino il riferimento di base e il box della svuotatura + Frame3d frPocket ; + Point3d ptCen ; pCompo->GetCentroid( ptCen) ; + frPocket.Set( ptCen, vtExtr) ; + frPocket.Rotate( ptCen, vtExtr, m_Params.m_dSideAngle) ; + pMCrv->ToLoc( frPocket) ; + // ciclo sui percorsi + if ( true) { + // li correggo per non interferire con le superfici + if ( pCAvTlStm != nullptr) { + // approssimo la curva con una polilinea + PolyLine PL ; + if ( ! pMCrv->ApproxWithLines( m_Params.m_dApprox, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL)) + return false ; + // eventuale aggiunta di punti per garantire max distanza + const double MIN_DIST = 1. ; + const double MAX_DIST = 50. ; + double dDist = Clamp( m_TParams.m_dDiam / 2, MIN_DIST, MAX_DIST) ; + if ( ! PL.AdjustForMaxSegmentLen( dDist)) + return false ; + // porto nel riferimento delle superfici + PL.LocToLoc( frPocket, frSurf) ; + // porto i dati geometrici in locale alle superfici + Vector3d vtAxL = vtTool ; + vtAxL.ToLoc( frSurf) ; + Vector3d vtMoveL = vtAxL ; + // traslo della lunghezza utensile diminuita dell'affondamento + PL.Translate( vtAxL * ( m_TParams.m_dLen - dDepth)) ; + // eseguo CAv + if ( ! pCAvTlStm->TestPath( PL.GetUPointList(), vtAxL, vtMoveL, m_Params.m_dApprox)) + return false ; + // contro-traslo della lunghezza utensile + PL.Translate( - vtAxL * m_TParams.m_dLen) ; + // riporto la polilinea nel riferimento della curva + PL.LocToLoc( frSurf, frPocket) ; + // elimino i punti allineati + PL.RemoveAlignedPoints( 0.8 * m_Params.m_dApprox) ; + // creo una curva composita a partire dalla polilinea + PtrOwner< ICurveComposite> pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) + return false ; + // sostituisco la vecchia curva con la nuova + pMCrv.Set( Release( pCompo )) ; + } + // ciclo sulle curve elementari + int nMaxInd = pMCrv->GetCurveCount() - 1 ; + for ( int i = 0 ; i <= nMaxInd ; ++ i) { + // curva corrente + const ICurve* pCrvC = pMCrv->GetCurve( i) ; + // copio la curva + PtrOwner pCurve( pCrvC->Clone()) ; + if ( IsNull( pCurve)) + return false ; + pCurve->ToGlob( frPocket) ; + // se prima entità + if ( i == 0 ) { + // dati inizio entità + Point3d ptStart ; + pCurve->GetStartPoint( ptStart) ; + Vector3d vtStart ; + pCurve->GetStartDir( vtStart) ; + // determino inizio attacco + Point3d ptP1 ; + if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) + return false ; + // determino elevazione su inizio attacco + double dStElev ; + if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) + dStElev = dElev ; + dStElev -= ( ptP1 - ptStart) * vtExtr ; + // se inizio, approccio globale al punto iniziale + if ( bStart) { + if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) { + m_pMchMgr->SetLastError( 3111, "Error in SurfFinishing : Approach not computable") ; + return false ; + } + bStart = false ; + } + // altrimenti, approccio di collegamento + else { + if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) { + m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ; + return false ; + } + } + // aggiungo attacco + SetFeed( GetStartFeed()) ; + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr)) { + m_pMchMgr->SetLastError( 3113, "Error in SurfFinishing : LeadIn not computable") ; + return false ; + } + } + // elaborazioni sulla curva corrente (sempre un segmento di retta) + ICurveLine* pLine = GetCurveLine( pCurve) ; + if ( pLine == nullptr) + return false ; + Point3d ptP3 = pLine->GetEnd() ; + Vector3d vtMove ; pLine->GetStartDir( vtMove) ; + SetFeed( GetRightFeed( vtMove, vtTool)) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + // se ultima entità + if ( i == nMaxInd) { + // dati fine entità + Point3d ptEnd ; + pCurve->GetEndPoint( ptEnd) ; + Vector3d vtEnd ; + pCurve->GetEndDir( vtEnd) ; + // determino elevazione su uscita + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + dEndElev = dElev ; + // aggiungo uscita + Point3d ptP1 ; + SetFeed( GetEndFeed()) ; + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) { + m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ; + return false ; + } + // se non è ultimo tratto, aggiungo retrazione di collegamento + if ( false) { + if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { + m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ; + return false ; + } + } + // altrimenti aggiungo retrazione finale + else { + if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) { + m_pMchMgr->SetLastError( 3115, "Error in SurfFinishing : Retract not computable") ; + return false ; + } + } + } + } + } + } + + return true ; +} + +//---------------------------------------------------------------------------- +static double +GetCurveRadius( const ICurve* pCrv) +{ + if ( pCrv == nullptr) + return 0.0 ; + BBox3d b3Loc ; + if ( ! pCrv->GetLocalBBox( b3Loc, BBF_EXACT)) + return 0.0 ; + double dRad ; + if ( ! b3Loc.GetRadius( dRad)) + return 0.0 ; + return dRad ; +} + +//---------------------------------------------------------------------------- +bool +SurfFinishing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, + ICurveComposite* pMCrv, ICurveComposite* pRCrv) +{ + // primo offset pari al raggio utensile - overlap + double dTRad = 0.5 * m_TParams.m_dDiam ; + double dOffs = dTRad - m_Params.m_dOverlap ; + + // ciclo di offset verso l'interno + const int MAX_ITER = 1000 ; + int nIter = 0 ; + PtrOwner pOffs ; + const ICurve* pCurr = pCompo ; + double dCurrRad = GetCurveRadius( pCurr) + m_Params.m_dOverlap ; + while ( nIter < MAX_ITER) { + // calcolo + OffsetCurve OffsCrv ; + if ( ! OffsCrv.Make( pCurr, - dOffs, ICurve::OFF_FILLET)) { + m_pMchMgr->SetLastError( 3109, "Error in SurfFinishing : Offset not computable") ; + return false ; + } + // recupero la prima curva di offset + PtrOwner pNextOffs( OffsCrv.GetLongerCurve()) ; + double dRad = GetCurveRadius( pNextOffs) ; + bool bNextOk = ( dRad > EPS_ZERO && dRad < dCurrRad) ; + bool bSmallRad = ( nIter == 0 ? dOffs < dTRad - m_Params.m_dOverlap + EPS_ZERO : dOffs < dTRad + EPS_ZERO) ; + // se completato step di offset, accodo la curva offsettata al percorso di lavoro + if ( ! IsNull( pOffs) && ( bNextOk || bSmallRad)) { + // verifico se aggiungere linea di congiunzione + if ( pMCrv->GetCurveCount() > 0) { + Point3d ptStart ; + pOffs->GetStartPoint( ptStart) ; + // aggiungo al percorso principale + pMCrv->AddLine( ptStart) ; + // eventuale copia nel percorso di ritorno + if ( pRCrv != nullptr) + pRCrv->AddCurve( *pMCrv->GetLastCurve()) ; + } + // se richiesta percorrenza invertita + if ( m_Params.m_bInvert) + pOffs->Invert() ; + // aggiungo la curva + pMCrv->AddCurve( Release( pOffs)) ; + } + // se offset va bene + if ( bNextOk) { + // sistemo per prossimo step + dCurrRad = dRad ; + pOffs.Set( Release( pNextOffs)) ; + pCurr = Get( pOffs) ; + // nuovo valore pari allo step + dOffs = GetSideStep() ; + } + // se altrimenti riducibile, provo con offset ridotto al raggio utensile + else if ( ! bSmallRad) { + // nuovo valore pari al raggio + dOffs = ( nIter == 0 ? dTRad - m_Params.m_dOverlap : dTRad) ; + } + // altrimenti esco + else + break ; + // incremento contatore iterazioni + ++ nIter ; + } + + // verifico il percorso di lavoro + if ( pMCrv->GetCurveCount() == 0) { + m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : : Toolpath not computable") ; + return false ; + } + // se necessario, approssimo archi con rette + if ( bSplitArcs && ! ApproxWithLines( pMCrv)) { + m_pMchMgr->SetLastError( 2421, "Error in Pocketing : Linear Approx not computable") ; + return false ; + } + // eventuale sistemazione archi + VerifyArcs( pMCrv) ; + // eventualmente compatto e inverto il percorso di ritorno + if ( pRCrv != nullptr) { + pRCrv->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false) ; + pRCrv->Invert() ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool SurfFinishing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) @@ -1721,7 +1998,7 @@ SurfFinishing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dS //---------------------------------------------------------------------------- bool -SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1) +SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1) const { ptP1 = ptStart ; return true ; @@ -1741,3 +2018,29 @@ SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Ve ptP1 = ptEnd ; return true ; } + +//---------------------------------------------------------------------------- +double +SurfFinishing::GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const +{ + // Determino i versori + Vector3d vtM = vtMove ; + vtM.Normalize() ; + Vector3d vtT = vtTool ; + vtT.Normalize() ; + // Angolo tra movimento e versore utensile + double dCosMove = vtM * vtT ; + // Se l'utensile non ha movimento significativo di punta, si restituisce la feed standard + if ( dCosMove > - COS_ORTO_ANG_SMALL) + return GetFeed() ; + // Altrimenti non si deve superare la massima velocità di punta prevista + return min( GetFeed(), GetTipFeed() / abs( dCosMove)) ; +} + +//---------------------------------------------------------------------------- +double +SurfFinishing::GetRadiusForStartEndElevation( void) const +{ + const double DELTA_ELEV_RAD = 20.0 ; + return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ; +} diff --git a/SurfFinishing.h b/SurfFinishing.h index 3e9c6dd..b1a2185 100644 --- a/SurfFinishing.h +++ b/SurfFinishing.h @@ -75,16 +75,23 @@ class SurfFinishing : public Machining bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, bool bSplitArcs) ; + double dDepth, double dElev) ; bool CalcZigZag( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ; + bool AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, + const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr, + double dDepth, double dElev, bool bInVsOut) ; + bool CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs, + ICurveComposite* pMCrv, ICurveComposite* pRCrv) ; bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ; - bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1) ; + bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN) ; bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, Point3d& ptP1) ; - bool GetActiveSurfaces( INTVECTOR& vSurfId) ; + bool GetActiveSurfaces( INTVECTOR& vSurfId) const ; + double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ; + double GetRadiusForStartEndElevation( void) const ; private : double GetSpeed() const @@ -100,7 +107,7 @@ class SurfFinishing : public Machining double GetOffsR() const { return ( IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; } double GetSideStep( void) const - { return Clamp( m_Params.m_dSideStep, std::min( 0.1 * m_TParams.m_dDiam, 0.5), m_TParams.m_dTDiam) ; } + { return Clamp( m_Params.m_dSideStep, 0.1, m_TParams.m_dTDiam) ; } private : SELVECTOR m_vId ; // identificativi entità geometriche da lavorare