From d83ea12f1f44f0429f8011c08abd6a10870ef4e7 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Wed, 8 Oct 2025 09:15:34 +0200 Subject: [PATCH] EgtMachKernel : - in PocketingNT piccolo miglioramento per i punti iniziali della svuotature. --- PocketingNT.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++- PocketingNT.h | 3 ++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 554045e..dcd8d85 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -2203,7 +2203,66 @@ PocketingNT::GetSfrRawProjection( const ISurfTriMesh* pStmRaw, const ISurfFlatRe //---------------------------------------------------------------------------- Point3d -PocketingNT::GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) +PocketingNT::GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const +{ + // se non ho step, allora non ho un punto di riferimento + if ( vStepInfo.empty()) + return P_INVALID ; + + // sull'ultimo Step ( quindi sulla geometria più simile a quella originaria) cerco il tratto aperto più lungo + // ( inteso come media tra gli aperti sui Chunks) + // recupero la prima regione valida a partire dalla più profonda + auto it = vStepInfo.rbegin() ; + for ( ; it != vStepInfo.rend() ; ++ it) { + if ( ( *it).pSfrPock != nullptr && ( *it).pSfrPock->IsValid() && + ( *it).pSfrPock->GetChunkCount() > 0) + break ; + } + // recupero la regione + const ISurfFlatRegion* pSfr = ( *it).pSfrPock ; + if ( pSfr == nullptr || ! pSfr->IsValid() || pSfr->GetChunkCount() == 0) + return P_INVALID ; + + // dichiaro il nuovo punto per la possibile entrata + double dZGlob = ( m_bAboveHead ? - INFINITO : INFINITO) ; + Point3d ptRef = P_INVALID ; + + // controllo se sono presenti dei lati aperti + for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { + for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) { + // recupero il Loop + PtrOwner pCompoLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ; + if ( IsNull( pCompoLoop) || ! pCompoLoop->IsValid()) + return P_INVALID ; + // scorro le sue curve + for ( int nU = 0 ; nU < pCompoLoop->GetCurveCount() ; ++ nU) { + const ICurve* pCrv = pCompoLoop->GetCurve( nU) ; + if ( pCrv == nullptr || ! pCrv->IsValid()) + return P_INVALID ; + if ( pCrv->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE) { + // calcolo il Box globale della curva e memorizzo la componente Z ( media) + BBox3d BBoxGlob ; + if ( pCrv->GetLocalBBox( BBoxGlob)) { + if ( m_bAboveHead && BBoxGlob.GetMax().z > dZGlob) { + ptRef = ( BBoxGlob.GetMin() + BBoxGlob.GetDimZ() * Z_AX + BBoxGlob.GetMax()) / 2. ; + dZGlob = ptRef.z ; + } + else if ( ! m_bAboveHead && BBoxGlob.GetMin().z < dZGlob) { + ptRef = ( BBoxGlob.GetMin() + BBoxGlob.GetMax() - BBoxGlob.GetDimZ() * Z_AX) / 2. ; + dZGlob = ptRef.z ; + } + } + } + } + } + } + + return ptRef ; +} + +//---------------------------------------------------------------------------- +Point3d +PocketingNT::GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) const { // se non ho step, allora non ho un punto di riferimento if ( vStepInfo.empty()) @@ -3944,10 +4003,15 @@ PocketingNT::CalcPaths( STEPINFOPOVECTOR& vStepInfo) // del percorso successivo) Point3d ptStartRef = P_INVALID ; if ( m_TParams.m_dDiam / 2. > TOOL_RAD_PTSTART - EPS_ZERO) { + // per utensili grandi ptStartRef = GetStartPointsFromSteps( vStepInfo, TEMP_PROP_OPEN_EDGE) ; if ( ! ptStartRef.IsValid()) ptStartRef = GetStartPointsFromSteps( vStepInfo, TEMP_PROP_CLOSE_EDGE) ; } + else { + // per teste da sopra/ da sotto + ptStartRef = GetStartPointsByHead( vStepInfo) ; + } // recupero flag per casi ottimizzati double dMaxOptSize = m_Params.m_dSideStep ; GetValInNotes( m_Params.m_sUserNotes, UN_MAXOPTSIZE, dMaxOptSize) ; diff --git a/PocketingNT.h b/PocketingNT.h index 91d920c..dc20026 100644 --- a/PocketingNT.h +++ b/PocketingNT.h @@ -114,7 +114,8 @@ class PocketingNT : public Machining ISurfTriMesh* GetExtrusionStm( const ISurfFlatRegion* pSfr, const Vector3d& vtExtr) ; ISurfFlatRegion* GetSfrByStmIntersection( const IntersParPlanesSurfTm& IPPStm, double dDist, double dSmallOffs = 0) ; ISurfFlatRegion* GetSfrRawProjection( const ISurfTriMesh* pStmRaw, const ISurfFlatRegion* pSfr, const Vector3d& vtTool) ; - Point3d GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) ; + Point3d GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const ; + Point3d GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) const ; bool ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmPart) ; bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ; bool ExtendOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) ;