diff --git a/Chiseling.cpp b/Chiseling.cpp index f57e426..0f6e9b8 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -330,7 +330,7 @@ Chiseling::SetGeometry( const SELVECTOR& vIds) // test sull'entità int nSubs ; if ( ! VerifyGeometry( Id, nSubs, nType)) { - string sOut = "Entity " + ToString( Id) + " skipped by Milling" ; + string sOut = "Entity " + ToString( Id) + " skipped by Chiseling" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) ; continue ; } @@ -371,7 +371,7 @@ Chiseling::Preview( bool bRecalc) // aggiorno dati geometrici dell'utensile if ( ! UpdateToolData()) { - LOG_INFO( GetEMkLogger(), "Error in Milling : UpdateToolData failed") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : UpdateToolData failed") ; return false ; } @@ -434,7 +434,7 @@ Chiseling::Apply( bool bRecalc) // aggiorno dati geometrici dell'utensile if ( ! UpdateToolData()) { - LOG_INFO( GetEMkLogger(), "Error in Milling : UpdateToolData failed") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : UpdateToolData failed") ; return false ; } @@ -608,7 +608,7 @@ Chiseling::UpdateToolData( void) // aggiorno i parametri m_TParams = *pTdata ; if ( ! EqualNoCase( m_Params.m_sToolName, m_TParams.m_sName)) { - string sLog = "Warning in Milling : tool name changed (" + + string sLog = "Warning in Chiseling : tool name changed (" + m_Params.m_sToolName + "->" + m_TParams.m_sName +")" ; LOG_INFO( GetEMkLogger(), sLog.c_str()) ; } @@ -807,7 +807,7 @@ Chiseling::Chain( int nGrpDestId) vpCrvs.emplace_back( GetCurve( Id)) ; // ne verifico la validità if ( IsNull( vpCrvs.back())) { - string sOut = "Entity " + ToString( Id) + " skipped by Milling" ; + string sOut = "Entity " + ToString( Id) + " skipped by Chiseling" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) ; vpCrvs.back().Reset() ; } @@ -943,6 +943,44 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) double dThick ; pCompo->GetThickness( dThick) ; + // se richiesto offset + double dOffs = GetOffsR() ; + if ( abs( dOffs) > EPS_SMALL) { + // valore offset + double dSignOffs = ( m_Params.m_nWorkSide == CHISEL_WS_RIGHT) ? dOffs : - dOffs ; + // flag offset + int nFlag = ICurve::OFF_EXTEND ; + // se percorso chiuso senza overlap ed inizio/fine è un angolo esterno + if ( pCompo->IsClosed()) { + Vector3d vtStart, vtEnd ; + if ( pCompo->GetStartDir( vtStart) && pCompo->GetEndDir( vtEnd) && + ( vtEnd ^ vtStart) * vtExtr * dSignOffs > 0) + nFlag += ICurve::OFF_FORCE_OPEN ; + } + // esecuzione offset + if ( ! pCompo->SimpleOffset( dSignOffs, nFlag)) { + // se curva piatta, provo con offset avanzato + bool bOk = false ; + Plane3d plPlane ; + if ( pCompo->IsFlat( plPlane, 100 * EPS_SMALL) && + AreSameOrOppositeVectorApprox( vtExtr, plPlane.vtN)) { + OffsetCurve OffsCrv ; + if ( OffsCrv.Make( pCompo, dSignOffs, nFlag)) { + ICurve* pOffs = OffsCrv.GetLongerCurve() ; + if ( pOffs != nullptr) { + pCompo->Clear() ; + pCompo->AddCurve( pOffs) ; + bOk = true ; + } + } + } + if ( ! bOk) { + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Offset not computable") ; + return false ; + } + } + } + // unisco le parti allineate if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL)) return false ; @@ -950,7 +988,7 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) // recupero il box del grezzo in globale BBox3d b3Raw ; if ( ! GetRawGlobBox( m_nPhase, nPathId, 0.5 * m_TParams.m_dDiam, b3Raw) || b3Raw.IsEmpty()) { - LOG_INFO( GetEMkLogger(), "Error in Milling : Empty RawBox") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Empty RawBox") ; return false ; } @@ -967,7 +1005,7 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) double dDepth ; string sMyDepth = m_Params.m_sDepth ; if ( ! ExeLuaEvalNumExpr( ToUpper( sMyDepth), &dDepth)) { - LOG_INFO( GetEMkLogger(), "Error in Milling : Depth not computable") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Depth not computable") ; return false ; } // se spessore positivo, lo sottraggo dal risultato @@ -1001,12 +1039,12 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) if ( dDepth + max( dThick, 0.0) > m_TParams.m_dMaxMat) { dDepth = m_TParams.m_dMaxMat - max( dThick, 0.0) ; dElev = m_TParams.m_dMaxMat ; - string sInfo = "Warning in Milling : machining depth (" + ToString( dElev, 1) + + string sInfo = "Warning in Chiseling : machining depth (" + ToString( dElev, 1) + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; } else { - string sInfo = "Error in Milling : machining depth (" + ToString( dElev, 1) + + string sInfo = "Error in Chiseling : machining depth (" + ToString( dElev, 1) + ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ; LOG_INFO( GetEMkLogger(), sInfo.c_str()) ; return false ; @@ -1149,7 +1187,7 @@ Chiseling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT dElev = dCurrElev ; } else { - LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Entity GetElevation") ; return false ; } // da una parte @@ -1159,7 +1197,7 @@ Chiseling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT dElev = dCurrElev ; } else { - LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Entity GetElevation") ; return false ; } // dall'altra parte @@ -1169,7 +1207,7 @@ Chiseling::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT dElev = dCurrElev ; } else { - LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; + LOG_INFO( GetEMkLogger(), "Error in Chiseling : Entity GetElevation") ; return false ; } }