diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 7e10deb..f60aa05 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 8e0c1d0..afd05c9 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -2624,6 +2624,13 @@ PocketingNT::ExtendOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) if ( ! pSfr->IsValid()) return true ; + // Se non richiesto controllo con il Grezzo, non estendo alcun lato + // ( NB. potrebbe essere scelto un unteriore parametro dalle note utenti) + int nOpenOutRaw ; + m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, UN_OPENOUTRAW, nOpenOutRaw) && nOpenOutRaw != 0) ; + if ( m_bOpenOutRaw) + return true ; + // se la superficie non ha lati aperti, allora non devo fare nulla bool bAllClosed = true ; for ( int nC = 0 ; nC < pSfr->GetChunkCount() && bAllClosed ; ++ nC) { @@ -2890,6 +2897,7 @@ PocketingNT::CalcLimitRegion( const ISurfFlatRegion* pSfrPock, const ISurfFlatRe // se richiesto non controllo dei lati aperti if ( m_bOpenOutRaw && pSfrLimit->IsValid()) { + double dExtension = 4. * m_TParams.m_dDiam + max( 0., m_dOpenMinSafe) + EPS_SMALL ; for ( int nC = 0 ; nC < pSfrPock->GetChunkCount() ; ++ nC) { for ( int nL = 0 ; nL < pSfrPock->GetLoopCount( nC) ; ++ nL) { // recupero la curva di bordo @@ -2902,22 +2910,25 @@ PocketingNT::CalcLimitRegion( const ISurfFlatRegion* pSfrPock, const ISurfFlatRe return false ; // scorro i tratti omogenei aperti for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) { - if ( vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE) { + if ( ! IsNull( vpCrvs[i]) && vpCrvs[i]->IsValid() && vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE) { // regione da sottrarre PtrOwner pSfrSubtract( CreateSurfFlatRegion()) ; if ( IsNull( pSfrSubtract)) return false ; if ( vpCrvs[i]->IsClosed()) { - pSfrSubtract.Set( GetSurfFlatRegionFromFatCurve( vpCrvs[i]->Clone(), 4 * m_TParams.m_dDiam + EPS_SMALL, false, false)) ; + pSfrSubtract.Set( GetSurfFlatRegionFromFatCurve( vpCrvs[i]->Clone(), dExtension, false, false)) ; if ( IsNull( pSfrSubtract) || ! pSfrSubtract->IsValid()) return false ; + if ( AreOppositeVectorApprox( pSfrSubtract->GetNormVersor(), pSfrPock->GetNormVersor())) + pSfrSubtract->Invert() ; } else { // creo la curva di Offset esterna ( deve esistere ed essere valida) + vpCrvs[i]->SetExtrusion( pSfrPock->GetNormVersor()) ; OffsetCurve OffsCrv ; PtrOwner pOffsExt( CreateCurveComposite()) ; if ( IsNull( pOffsExt) || - ! OffsCrv.Make( vpCrvs[i], 4 * m_TParams.m_dDiam, ICurve::OFF_FILLET) || + ! OffsCrv.Make( vpCrvs[i], dExtension, ICurve::OFF_FILLET) || ! pOffsExt.Set( OffsCrv.GetLongerCurve()) || IsNull( pOffsExt)) return false ; @@ -2925,7 +2936,7 @@ PocketingNT::CalcLimitRegion( const ISurfFlatRegion* pSfrPock, const ISurfFlatRe PtrOwner pOffsInt( CreateCurveComposite()) ; if ( IsNull( pOffsInt)) return false ; - if ( OffsCrv.Make( vpCrvs[i], - 4 * m_TParams.m_dDiam, ICurve::OFF_FILLET)) { + if ( OffsCrv.Make( vpCrvs[i], - dExtension, ICurve::OFF_FILLET)) { PtrOwner pMyCrv( OffsCrv.GetLongerCurve()) ; if ( ! IsNull( pMyCrv) && pMyCrv->IsValid()) pOffsInt.Set( pMyCrv) ; @@ -3059,6 +3070,10 @@ PocketingNT::ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) if ( ! pStm->IsValid()) return true ; + // Recupero dalle Note utenti il parametro OpenOutRaw + int nOpenOutRaw ; + m_bOpenOutRaw = ( GetValInNotes( m_Params.m_sUserNotes, UN_OPENOUTRAW, nOpenOutRaw) && nOpenOutRaw != 0) ; + // recupero i Chunk della superficie ISURFFRPOVECTOR vChunks( pSfr->GetChunkCount()) ; for ( int nC = 0 ; nC < int( vChunks.size()) ; ++ nC) @@ -3075,6 +3090,23 @@ PocketingNT::ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) double dOpenExtension = 0. ; if ( GetValInNotes( m_Params.m_sUserNotes, UN_OPEN, dOpenExtension) && dOpenExtension > EPS_SMALL) m_dOpenInRawExtension = dOpenExtension ; + + // se la superficie ha flag di OpenOutRaw e non è stata impostata alcuna estensione massima, + // non modifico la geometria, lascio l'aperto esattamente dove si trova + // se invece ho flat di OpenOutRaw, dato che il lato aperto viene lasciato tale, devo ridurre la + // sua estensione del raggio utensile + if ( m_bOpenOutRaw) { + if ( dOpenExtension < 10. * EPS_SMALL) + return true ; + else { + m_dOpenInRawExtension -= m_TParams.m_dDiam / 2. ; + if ( m_dOpenInRawExtension < EPS_SMALL) { + m_dOpenInRawExtension = 0. ; + return true ; + } + } + } + const double LEN_EXTENSION = 1000. ; const double TOL_PT_INSIDE_STM = 3. ; #if DEBUG_OPEN_EDGE_IN_RAW @@ -3159,7 +3191,7 @@ PocketingNT::ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) return false ; // considero il bordo come tutto chiuso ( evito entrate da fuori dal pezzo) for ( int i = 0 ; i < pCrvNewBorder->GetCurveCount() ; ++ i) - pCrvNewBorder->SetCurveTempProp( i, TEMP_PROP_CLOSE_EDGE, 0) ; + pCrvNewBorder->SetCurveTempProp( i, m_bOpenOutRaw ? TEMP_PROP_OPEN_EDGE : TEMP_PROP_CLOSE_EDGE, 0) ; } // se invece presenta solo alcuni tratti Open interni al pezzo else { @@ -3278,9 +3310,9 @@ PocketingNT::ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) pLineAfter->SetTempProp( vpCrvs[nIndAfter]->GetTempProp( 0), 0) ; vpCrvs[nIndAfter]->AddCurve( Release( pLineAfter), false) ; vpCrvs[i].Set( Release( pCrvOffsOpenInPart)) ; - // considero questo tratto come chiuso + // assegno proprietà di lato aperto/chiuso for ( int j = 0 ; j < vpCrvs[i]->GetCurveCount() ; ++ j) - vpCrvs[i]->SetCurveTempProp( j, TEMP_PROP_CLOSE_EDGE, 0) ; + vpCrvs[i]->SetCurveTempProp( j, m_bOpenOutRaw ? TEMP_PROP_OPEN_EDGE : TEMP_PROP_CLOSE_EDGE, 0) ; } } // ricostrusico il nuovo bordo