EgtMachKernel :
- in PocketingNT aggiunta funzione per scelta del punto iniziale di riferimento in base alla geometria.
This commit is contained in:
+94
-1
@@ -120,7 +120,8 @@ const string UN_MAXOPTSIZE = "MaxOptSize" ;
|
||||
#define DEBUG_MAXDEPTH 0 // Debug per controllo di MaxDepth
|
||||
#define DEBUG_SAFETY_LINK 0 // Debug raccordi tra percorsi di lavorazioni differenti
|
||||
#define DEBUG_FEED 0 // Debug per Feed
|
||||
#if DEBUG_OPEN_EDGE_EXTENSION || DEBUG_OPEN_EDGE_IN_RAW || DEBUG_SFR_STEPS || DEBUG_SFR_RAW || DEBUG_GLIDE || DEBUG_SAFETY_LINK || DEBUG_FEED
|
||||
#define DEBUG_START_POINT 0 // Debug per scelta del punto iniziale
|
||||
#if DEBUG_OPEN_EDGE_EXTENSION || DEBUG_OPEN_EDGE_IN_RAW || DEBUG_SFR_STEPS || DEBUG_SFR_RAW || DEBUG_GLIDE || DEBUG_SAFETY_LINK || DEBUG_FEED || DEBUG_START_POINT
|
||||
#include "EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "EgtDev/Include/EGkFrame3d.h"
|
||||
#endif
|
||||
@@ -1881,6 +1882,93 @@ PocketingNT::GetSfrRawProjection( const ISurfTriMesh* pStmRaw, const ISurfFlatRe
|
||||
return Release( pSfrRaw) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Point3d
|
||||
PocketingNT::GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType)
|
||||
{
|
||||
// se non ho step, allora errore
|
||||
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 ;
|
||||
#if DEBUG_START_POINT
|
||||
int nGrp = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ;
|
||||
m_pGeomDB->SetName( nGrp, "Start_Point") ;
|
||||
int nLay = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrp, GLOB_FRM) ;
|
||||
DebugDrawSfr( pSfr, false, nLay) ;
|
||||
#endif
|
||||
|
||||
// scorro le curve
|
||||
PNTVECTOR vPnts ;
|
||||
for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) {
|
||||
for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) {
|
||||
// recupero il loop come curva composita
|
||||
PtrOwner<ICurveComposite> pCrvLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ;
|
||||
if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
|
||||
continue ;
|
||||
// recupero i tratti con proprietà uniformi
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
GetHomogeneousParts( pCrvLoop, vpCrvs) ;
|
||||
// scorro i tratti con le proprietà richieste e cerco quello più lungo
|
||||
double dLenRef = 0. ;
|
||||
int nIndRef = -1 ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
if ( vpCrvs[i]->GetTempProp() == nCrvType) {
|
||||
double dLen = 0. ; vpCrvs[i]->GetLength( dLen) ;
|
||||
if ( dLen > dLenRef) {
|
||||
dLenRef = dLen ;
|
||||
nIndRef = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nIndRef == -1)
|
||||
continue ;
|
||||
Point3d ptMid ;
|
||||
vpCrvs[nIndRef]->GetMidPoint( ptMid) ;
|
||||
#if DEBUG_START_POINT
|
||||
PtrOwner<IGeoPoint3d> myPtMid( CreateGeoPoint3d()) ;
|
||||
myPtMid->Set( ptMid) ;
|
||||
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, myPtMid->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( nId, nCrvType == TEMP_PROP_CLOSE_EDGE ? AQUA : ORANGE) ;
|
||||
#endif
|
||||
vPnts.emplace_back( ptMid) ;
|
||||
}
|
||||
}
|
||||
// se non ho punti allora esco
|
||||
if ( vPnts.empty())
|
||||
return P_INVALID ;
|
||||
// recupero il punto medio
|
||||
double dX = 0., dY = 0., dZ = 0. ;
|
||||
for ( const Point3d& myPt : vPnts) {
|
||||
dX += myPt.x ;
|
||||
dY += myPt.y ;
|
||||
dZ += myPt.z ;
|
||||
}
|
||||
Point3d ptStart = Point3d( dX / int( vPnts.size()),
|
||||
dY / int( vPnts.size()),
|
||||
dZ / int( vPnts.size())) ;
|
||||
#if DEBUG_START_POINT
|
||||
PtrOwner<IGeoPoint3d> myPtStart( CreateGeoPoint3d()) ;
|
||||
myPtStart->Set( ptStart) ;
|
||||
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, myPtStart->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( nId, YELLOW) ;
|
||||
#endif
|
||||
return ptStart ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PocketingNT::GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const
|
||||
@@ -3441,6 +3529,11 @@ PocketingNT::CalcPaths( STEPINFOPOVECTOR& vStepInfo)
|
||||
// punto finale di riferimento per il percorso attuale ( serve per trovare il punto iniziale
|
||||
// del percorso successivo)
|
||||
Point3d ptStartRef = P_INVALID ;
|
||||
if ( m_TParams.m_dDiam / 2. > TOOL_RAD_PTSTART - EPS_ZERO) {
|
||||
ptStartRef = GetStartPointsFromSteps( vStepInfo, TEMP_PROP_OPEN_EDGE) ;
|
||||
if ( ! ptStartRef.IsValid())
|
||||
ptStartRef = GetStartPointsFromSteps( vStepInfo, TEMP_PROP_CLOSE_EDGE) ;
|
||||
}
|
||||
|
||||
// controllo parametri per casi ottimizzati
|
||||
double dMaxOptSize = m_Params.m_dSideStep ;
|
||||
|
||||
@@ -110,6 +110,7 @@ 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) ;
|
||||
bool ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmPart) ;
|
||||
bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ;
|
||||
bool ExtendOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) ;
|
||||
|
||||
Reference in New Issue
Block a user