EgtMachKernel :

- In PocketingNT migliorate le considerazioni sul Grezzo e sulle sue Parts.
This commit is contained in:
Riccardo Elitropi
2026-01-23 12:39:19 +01:00
parent 63300c9620
commit fd920a2786
2 changed files with 69 additions and 1 deletions
+68 -1
View File
@@ -46,6 +46,7 @@
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EGkDistPointSurfFr.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
#include <algorithm>
using namespace std ;
@@ -1956,6 +1957,11 @@ PocketingNT::Chain( int nGrpDestId)
return false ;
double dThick = pCrvInfo->GetTempParam( 1) ;
Vector3d vtExtr ; pCrvInfo->GetExtrusion( vtExtr) ;
// -------------- Verifico quale part del Grezzo bisogna considerare ----------------
if ( ! ChooseRawPart( pSfrChunk, ( pStmTrim == nullptr ? pStmRaw : pStmTrim))) {
m_pMchMgr->SetLastError( 2436, "Error in PocketingNT : not valid Raw") ;
return false ;
}
// -------------- Controllo esistenza di lati aperti interni al grezzo --------------
// Questi lati vengono Offsettati, raccordati e considerati poi come chiusi
if ( ! ManageOpenEdges( pSfrChunk, ( pStmTrim == nullptr ? pStmRaw : pStmTrim))) {
@@ -2985,6 +2991,59 @@ PocketingNT::CalcLimitRegion( const ISurfFlatRegion* pSfrPock, const ISurfFlatRe
return true ;
}
//----------------------------------------------------------------------------
bool
PocketingNT::ChooseRawPart( const ISurfFlatRegion* pSfrChunk, ISurfTriMesh* pStm) const
{
/* Funzione per rimuovere le Part di pStm che non interferiscono con pSfrChunk */
// Controllo dei parametri
if ( pSfrChunk == nullptr || ! pSfrChunk->IsValid())
return false ;
if ( pStm == nullptr || ! pStm->IsValid())
return true ;
// Se solo una Part, allora il grezzo da considerare è tutto
if ( pStm->GetPartCount() < 2)
return true ;
// Recupero la TriMesh ausiliaria del Chunk
const ISurfTriMesh* pStmAux = pSfrChunk->GetAuxSurf() ;
if ( pStmAux == nullptr)
return false ;
PtrOwner<ISurfTriMesh> pStmChunk( CloneSurfTriMesh( pStmAux)) ;
if ( IsNull( pStmChunk) || ! pStmChunk->IsValid())
return false ;
// Recupero il Box della TriMesh
BBox3d BBoxChunk ;
if ( ! pStmChunk->GetLocalBBox( BBoxChunk))
return false ;
// Scorro le Part della TriMesh
for ( int nPart = 0 ; nPart < pStm->GetPartCount() ; ++ nPart) {
// Recupero il Box della Part corrente
BBox3d BBoxPart ;
if ( ! pStm->GetPartLocalBBox( nPart, BBoxPart))
return false ;
// Se non c'è intersezione tra i Box, la Part corrente viene rimossa
BBox3d BBoxInt ;
if ( ! BBoxPart.FindIntersection( BBoxChunk, BBoxInt) || BBoxInt.IsEmpty()) {
pStm->RemovePart( nPart) ;
-- nPart ;
continue ;
}
// Se i Box fanno interferenza verifico in maniera corretta se davvero le superfici interferiscono
PtrOwner<ISurfTriMesh> pStmPart( pStm->ClonePart( nPart)) ;
if ( IsNull( pStmPart) || ! pStmPart->IsValid())
return false ;
if ( ! TestSurfTmSurfTm( *pStmChunk, *pStmPart, 10. * EPS_SMALL, true)) {
pStm->RemovePart( nPart) ;
-- nPart ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
PocketingNT::ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm)
@@ -3496,11 +3555,19 @@ PocketingNT::ProcessPath( int nPathId, int nPvId, int nClId)
// recupero il grezzo e la superficie di Trim [nullptr se non presente]
PtrOwner<ISurfTriMesh> pStmRaw( GetRaw()) ;
if ( IsNull( pStmRaw)) {
if ( IsNull( pStmRaw) || ! ChooseRawPart( pSfr, pStmRaw) ||
! pStmRaw->IsValid() || pStmRaw->GetTriangleCount() == 0) {
m_pMchMgr->SetLastError( 3025, "Error in PocketingNT : RawPart not computable") ;
return false ;
}
PtrOwner<ISurfTriMesh> pStmTrim( GetStmTrim()) ;
if ( ! IsNull( pStmTrim)) {
if ( ! ChooseRawPart( pSfr, pStmTrim) || ! pStmTrim->IsValid() ||
pStmTrim->GetTriangleCount() == 0) {
m_pMchMgr->SetLastError( 3025, "Error in PocketingNT : RawPart not computable") ;
return false ;
}
}
#if DEBUG_SFR_RAW
int nGrpSR = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ;
int nLaySR = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpSR, GLOB_FRM) ;
+1
View File
@@ -116,6 +116,7 @@ class PocketingNT : public Machining
ISurfFlatRegion* GetSfrRawProjection( const ISurfTriMesh* pStmRaw, const ISurfFlatRegion* pSfr, const Vector3d& vtTool) ;
Point3d GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const ;
Point3d GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) const ;
bool ChooseRawPart( const ISurfFlatRegion* pSfrChunk, ISurfTriMesh* pStm) const ;
bool ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmPart) ;
bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ;
bool ExtendOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) ;