diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp index ba40516..81ca5df 100644 --- a/MachiningsMgr.cpp +++ b/MachiningsMgr.cpp @@ -51,6 +51,8 @@ const string MF_HOLEDTOL = "HOLEDTOL" ; const double MF_CURR_HOLEDTOL = 10 * EPS_SMALL ; const string MF_EXTSAWARCMINRAD = "EXTSAWARCMINRAD" ; const double MF_CURR_EXTSAWARCMINRAD = 200 ; +const string MF_SPLITARCS = "SPLITARCS" ; +const int MF_CURR_SPLITARCS = SPLAR_NEVER ; //---------------------------------------------------------------------------- @@ -67,6 +69,7 @@ MachiningsMgr::MachiningsMgr( void) m_dExtraROnDrillRegion = MF_CURR_EXTRARDR ; m_dHoleDiamToler = MF_CURR_HOLEDTOL ; m_dExtSawArcMinRad = MF_CURR_EXTSAWARCMINRAD ; + m_nSplitArcs = MF_CURR_SPLITARCS ; } //---------------------------------------------------------------------------- @@ -250,6 +253,8 @@ MachiningsMgr::LoadGeneral( Scanner& TheScanner, bool& bEnd) bOk = FromString( sVal, m_dHoleDiamToler) ; else if ( ToUpper( sKey) == MF_EXTSAWARCMINRAD) bOk = FromString( sVal, m_dExtSawArcMinRad) ; + else if ( ToUpper( sKey) == MF_SPLITARCS) + bOk = FromString( sVal, m_nSplitArcs) ; else bOk = false ; } @@ -422,6 +427,8 @@ MachiningsMgr::SaveGeneral( Writer& TheWriter) const bOk = bOk && TheWriter.OutText( sOut) ; sOut = MF_EXTSAWARCMINRAD + "=" + ToString( m_dExtSawArcMinRad) ; bOk = bOk && TheWriter.OutText( sOut) ; + sOut = MF_SPLITARCS + "=" + ToString( m_nSplitArcs) ; + bOk = bOk && TheWriter.OutText( sOut) ; return bOk ; } @@ -951,3 +958,13 @@ MachiningsMgr::SetExtSawArcMinRad( double dRad) } return true ; } + +//---------------------------------------------------------------------------- +bool +MachiningsMgr::SetSplitArcs( int nFlag) +{ + if ( nFlag < SPLAR_NEVER || nFlag > SPLAR_ALWAYS) + return false ; + m_nSplitArcs = nFlag ; + return true ; +} diff --git a/MachiningsMgr.h b/MachiningsMgr.h index b42d53c..143923a 100644 --- a/MachiningsMgr.h +++ b/MachiningsMgr.h @@ -68,6 +68,9 @@ class MachiningsMgr bool SetExtSawArcMinRad( double dRad) ; double GetExtSawArcMinRad( void) { return m_dExtSawArcMinRad ; } + bool SetSplitArcs( int nFlag) ; + double GetSplitArcs( void) + { return m_nSplitArcs ; } private : bool Clear( void) ; @@ -106,4 +109,5 @@ class MachiningsMgr double m_dExtraROnDrillRegion ; double m_dHoleDiamToler ; double m_dExtSawArcMinRad ; + int m_nSplitArcs ; } ; \ No newline at end of file diff --git a/Milling.cpp b/Milling.cpp index b016b28..a1cc991 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -943,6 +943,22 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) string sPathName ; m_pGeomDB->GetName( nPathId, sPathName) ; + // eventuale approssimazione con segmenti di linea + + bool bSplitArcs = ( m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() == SPLAR_ALWAYS) ; + if ( bSplitArcs) { + const double ANG_TOL_MAX_DEG = 90 ; + PolyLine PL ; + if ( pCompo->ApproxWithLines( 50 * EPS_SMALL, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL)) { + // sostituisco le linee alle curve originali + pCompo->Clear() ; + pCompo->FromPolyLine( PL) ; + // riassegno estrusione e spessore + pCompo->SetExtrusion( vtExtr) ; + pCompo->SetThickness( dThick) ; + } + } + // verifiche sull'ampiezza dell'angolo al centro degli eventuali archi const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ; int nMaxInd = pCompo->GetCurveCount() - 1 ; @@ -1041,7 +1057,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) } // aggiungo attacco SetFeed( GetStartFeed()) ; - if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr)) { + if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) { LOG_INFO( GetEMkLogger(), "Error in Milling : LeadIn not computable") ; return false ; } @@ -1075,7 +1091,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // aggiungo uscita Point3d ptP1 ; SetFeed( GetStartFeed()) ; - if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) { + if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) { LOG_INFO( GetEMkLogger(), "Error in Milling : LeadOut not computable") ; return false ; } @@ -1181,9 +1197,19 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const //---------------------------------------------------------------------------- bool -Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN) +Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, + const Vector3d& vtN, bool bSplitArcs) { - switch ( m_Params.m_nLeadInType) { + // assegno i parametri + int nType = m_Params.m_nLeadInType ; + if ( bSplitArcs) { + if ( nType == MILL_LI_TANGENT) + nType = MILL_LI_LINEAR ; + if ( nType == MILL_LI_HELIX) + nType = MILL_LI_LINEAR ; // prevedere un nuovo tipo zig-zag + } + // eseguo a seconda del tipo + switch ( nType) { case MILL_LI_NONE : return true ; case MILL_LI_LINEAR : @@ -1253,7 +1279,8 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& //---------------------------------------------------------------------------- bool -Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, Point3d& ptP1) +Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, + Point3d& ptP1, bool bSplitArcs) { // assegno i parametri int nType = m_Params.m_nLeadOutType ; @@ -1264,6 +1291,10 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d dTang = m_Params.m_dLiTang ; dPerp = m_Params.m_dLiPerp ; } + if ( bSplitArcs) { + if ( nType == MILL_LO_TANGENT) + nType = MILL_LO_LINEAR ; + } // eseguo a seconda del tipo switch ( nType) { case MILL_LO_NONE : diff --git a/Milling.h b/Milling.h index 0f89933..c60a91e 100644 --- a/Milling.h +++ b/Milling.h @@ -68,8 +68,10 @@ class Milling : public Machining bool AddApproach( 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 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 AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, + const Vector3d& vtN, bool bSplitArcs) ; + bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, + Point3d& ptP1, bool bSplitArcs) ; private : double GetSpeed() const