EgtMachKernel :
- aggiornamento Feed tra steps.
This commit is contained in:
+58
-38
@@ -135,8 +135,9 @@ SurfRoughing::DrawFeed( const ICurveComposite* pCrv, int nStep)
|
||||
}
|
||||
int myStepId = m_pGeomDB->AddGroup( GDB_ID_NULL, myId, GLOB_FRM) ;
|
||||
m_pGeomDB->SetName( myStepId, "Step " + ToString( nStep)) ;
|
||||
double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ;
|
||||
for ( int u = 0 ; u < pCrv->GetCurveCount() ; ++ u) {
|
||||
double myAngle = 120 * ( pCrv->GetCurve( u)->GetTempParam( 0) / 1000.) ;
|
||||
double myAngle = 120 * ( ( ( pCrv->GetCurve( u)->GetTempParam( 0) - dMinFeed) / ( GetFeed() - dMinFeed))) ;
|
||||
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, myStepId, pCrv->GetCurve( u)->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( nInd, GetColorFromHSV( HSV( myAngle, 1., 1.))) ;
|
||||
}
|
||||
@@ -144,7 +145,6 @@ SurfRoughing::DrawFeed( const ICurveComposite* pCrv, int nStep)
|
||||
}
|
||||
/* end debug functions */
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( GetOperationClass( OPER_SURFROUGHING), SurfRoughing) ;
|
||||
|
||||
@@ -1330,9 +1330,9 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
// definisco una struttura per i parametri utili sugli step
|
||||
struct myStepInfo {
|
||||
myStepInfo( void)
|
||||
: nInd( -1), nIndRef( -1), dDepth( 0), bSubStep( false), pSfrRemoved( nullptr) {}
|
||||
myStepInfo( int nI, int nIR, double dD, bool bSS, ISurfFlatRegion* pSR)
|
||||
: nInd( nI), nIndRef( nIR), dDepth( dD), bSubStep( bSS), pSfrRemoved( pSR) {}
|
||||
: nInd( -1), nIndRef( -1), dDepth( 0), bSubStep( false), nNumStep( 0), pSfrRemoved( nullptr) {}
|
||||
myStepInfo( int nI, int nIR, double dD, bool bSS, int nNS, ISurfFlatRegion* pSR)
|
||||
: nInd( nI), nIndRef( nIR), dDepth( dD), bSubStep( bSS), nNumStep( nNS), pSfrRemoved( pSR) {}
|
||||
~myStepInfo() {
|
||||
delete( pSfrRemoved) ;
|
||||
}
|
||||
@@ -1340,13 +1340,19 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
int nIndRef ; // ( usato solo per step intermedi ) indice step precedente
|
||||
double dDepth ; // profondità posizione piano di svuotatura ( in negativo)
|
||||
bool bSubStep ; // flag per indicare se lo Step è base o intermedio
|
||||
int nNumStep ; // numero relativo progressivo di Step ( per Feed)
|
||||
ISurfFlatRegion* pSfrRemoved ; // regione PROGRESSIVA rimossa attuale
|
||||
} ;
|
||||
/* - nNumStep -
|
||||
Nel caso di Step base indica il numero di tale step ( da 0 a nStep)
|
||||
Nel caso di SubStep indica il numero di tale SubStep relativo ai due Step Base che lo racchiudono
|
||||
( da 0 a nSubStep per ogni coppia di Step base successivi)
|
||||
*/
|
||||
vector< myStepInfo> vStepInfo ;
|
||||
|
||||
// inserisco prima gli step...
|
||||
for ( int i = 0 ; i < nStep ; ++ i)
|
||||
vStepInfo.emplace_back( i, -1, - ( i + 1) * dStep, false, nullptr) ;
|
||||
vStepInfo.emplace_back( i, -1, - ( i + 1) * dStep, false, i, nullptr) ;
|
||||
|
||||
// ... e poi gli step intermedi ( se presenti e non coincidenti con gli Step base)
|
||||
int nIndRef = 0 ; // ( step base sottostante allo step intermedio corrente )
|
||||
@@ -1361,6 +1367,7 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
if ( ( - ( i + 1) * dSubStep) - vStepInfo[nIndRef].dDepth < EPS_SMALL) {
|
||||
++ nIndRef ; // il riferimento è lo step base successivo
|
||||
// scorro gli step intermedi temporanei trovati al contrario
|
||||
int nNumStep = -1 ; // numero relativo di SubStep
|
||||
for ( auto it = vStepInfo_tmp.rbegin() ; it != vStepInfo_tmp.rend() ; ++ it) {
|
||||
// se lo step intermedio non è il precedente allo step base di riferimento
|
||||
if ( it != vStepInfo_tmp.rbegin()) {
|
||||
@@ -1370,21 +1377,21 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
// riferimento... ad eccezione del primo, i successivi in salita avranno lo step intermedio
|
||||
// precedente come riferimento
|
||||
}
|
||||
it->nNumStep = ++ nNumStep ; // aggiornamento numero relativo di SubStep
|
||||
vStepInfo.emplace_back( *it) ; // aggiungo lo step intermedio al vettore degli step
|
||||
}
|
||||
vStepInfo_tmp.clear() ; // pulisco
|
||||
}
|
||||
// aggiunta dello step intermedio al vettore temporaneo
|
||||
vStepInfo_tmp.emplace_back( nStep + i, nIndRef, - ( i + 1) * dSubStep, true, nullptr) ;
|
||||
vStepInfo_tmp.emplace_back( nStep + i, nIndRef, - ( i + 1) * dSubStep, true, 0, nullptr) ;
|
||||
}
|
||||
|
||||
// creo la regione piana di confronto
|
||||
|
||||
// su tutti gli step ricavati, calcolo le PolyLine delle Silhouette
|
||||
int nPocket = 0 ; // numero effettivo di Pocketing calcolate
|
||||
int nProgressBarStep = 0 ; // step per progressBar
|
||||
for ( auto it = vStepInfo.begin() ; it != vStepInfo.end() ; ++ it) {
|
||||
|
||||
// per i contatori non controllo se effettivamente svuoto una superficie o meno
|
||||
++ nProgressBarStep ; // aggiorno step per progressBar
|
||||
|
||||
/* ******************** Regione estesa di lavoro ******************** */
|
||||
@@ -1484,10 +1491,6 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
// se regione risultante non vuota
|
||||
if ( pSfr->IsValid() && pSfr->GetChunkCount() > 0) {
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DrawLoopsSurf( pSfr, true, Color( 1., 1., 1., .1), it->bSubStep, it->nInd) ;
|
||||
#endif
|
||||
|
||||
// se si tratta di un SottoStep, rimuovo tutti i chunk troppo snelli
|
||||
if ( it->bSubStep) {
|
||||
if ( ! RemoveChunksUnderTolerance( pSfr)) {
|
||||
@@ -1523,6 +1526,10 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
// salvo nel temp Param della FlatRegion la sua Depth di traslazione
|
||||
pSfr->SetTempParam( it->dDepth, 0) ;
|
||||
|
||||
// salvo come temp Param 1 della FlatRegion il Coefficiente correttivo
|
||||
// per Zloc della Feed ( valore compreso tra 0 e 1)
|
||||
pSfr->SetTempParam( GetAdaptedCoeffFeed( it->bSubStep, it->nNumStep, dStep, dSubStep), 1) ;
|
||||
|
||||
// la salvo nel gruppo temporaneo
|
||||
int nNew_SfrPock_Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nTempId, Release( pSfr)) ;
|
||||
if ( nNew_SfrPock_Id == GDB_ID_NULL) {
|
||||
@@ -1786,6 +1793,10 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
if ( ! bIsSubStep)
|
||||
++ nBasicStep ;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DrawLoopsSurf( pSfrPock, true, Color( 1., 1., 1., .1), bIsSubStep, nCurrStep) ;
|
||||
#endif
|
||||
|
||||
ICRVCOMPOPOVECTOR vpCrvs ; // percorso di svuotatura
|
||||
// se si tratta di uno step base, allora lavoro l'intera superficie
|
||||
if ( ! CalcPocketing( pSfrPock, m_TParams.m_dDiam / 2, 0., m_Params.m_dSideStep, m_Params.m_dSideAngle,
|
||||
@@ -1797,6 +1808,9 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
// recupero la Depth della regione
|
||||
double dDepth = pSfrPock->GetTempParam( 0) ;
|
||||
|
||||
// recupero la Feed corrente di lavorazione
|
||||
double dZlocCoeffFeed = pSfrPock->GetTempParam( 1) ;
|
||||
|
||||
// sistemo gli archi per massimo angolo al centro
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i)
|
||||
VerifyArcs( vpCrvs[i]) ;
|
||||
@@ -1809,10 +1823,6 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
// ciclo sui percorsi
|
||||
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DrawFeed( vpCrvs[k], nCurrStep) ;
|
||||
#endif
|
||||
|
||||
// controllo se il percorso ha un ingresso presso un lato aperto
|
||||
bool bOutStart = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetCurve( 0)->GetTempProp( 0) == 2) ;
|
||||
// controllo se il percorso è formato da una singola curva seguente il lato chiuso
|
||||
@@ -1834,7 +1844,7 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
return false ;
|
||||
// coefficiente feed (riduzione di feed per sezione di taglio superiore al previsto)
|
||||
double dTempParam ; vpCrvs[k]->GetCurveTempParam( i, dTempParam) ;
|
||||
double dCoeffFeed = ( dTempParam > EPS_SMALL ? dTempParam /= 1000 : 1) ;
|
||||
double dCoeffFeed = min( 1., ( dTempParam > EPS_SMALL ? dTempParam /= 1000 : 1) * dZlocCoeffFeed) ;
|
||||
// se prima entità
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
@@ -1851,6 +1861,8 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
return false ;
|
||||
// flag approccio libero in aria
|
||||
bool bOutLeadIn = ( bOutStart || bSingleCrv || bOptTrap) ;
|
||||
if ( bOutLeadIn)
|
||||
dCoeffFeed = ( dTempParam > EPS_SMALL ? dTempParam : 1) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, pRCrv, ptP1))
|
||||
@@ -1934,6 +1946,9 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
#if ENABLE_DEBUG
|
||||
vpCrvs[k]->SetCurveTempParam( i, dCoeffFeed * GetFeed()) ; // ok...
|
||||
#endif
|
||||
// se ultima entità
|
||||
if ( i == nMaxInd) {
|
||||
// dati fine entità
|
||||
@@ -1968,8 +1983,11 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
}
|
||||
}
|
||||
}
|
||||
#if ENABLE_DEBUG
|
||||
DrawFeed( vpCrvs[k], nCurrStep) ;
|
||||
#endif
|
||||
}
|
||||
++ nCurrStep ;
|
||||
++ nCurrStep ;
|
||||
// aggiorno la progressBar
|
||||
ExeProcessEvents( 50 + nCurrStep * 50 / int( vPocket.size()), 100) ;
|
||||
}
|
||||
@@ -2438,28 +2456,30 @@ SurfRoughing::RemoveChunksUnderTolerance( ISurfFlatRegion* pSfr) const
|
||||
PtrOwner<ICurve> pCrvExtLoop( pSfr->GetLoop( c, 0)) ;
|
||||
if ( IsNull( pCrvExtLoop) || ! pCrvExtLoop->IsValid())
|
||||
return false ;
|
||||
// effettuo l'offset della tolleranza richiesta
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( OffsCrv.Make( pCrvExtLoop, - m_dSubStepToler, ICurve::OFF_FILLET)) {
|
||||
// recupero la curva di Offset
|
||||
PtrOwner<ICurveComposite> pCrvOffs( ConvertCurveToComposite( OffsCrv.GetLongerCurve())) ;
|
||||
if ( ! IsNull( pCrvOffs) && pCrvOffs->IsValid() && pCrvOffs->GetCurveCount() > 0) {
|
||||
// se valida, allora conservo il chunk
|
||||
// inserisco la curva esterna
|
||||
if ( ! pSfrBeauty->AddExtLoop( Release( pCrvExtLoop)))
|
||||
// verifico se l'Offset massimo della curva è più piccolo del parametro di tolleranza
|
||||
double dMaxOffs ;
|
||||
CalcCurveLimitOffset( *pCrvExtLoop, dMaxOffs) ;
|
||||
/*
|
||||
// rimuovo il Chunk c-esimo se l'Offset massimo è minore della tolleranza
|
||||
if ( dMaxOffs < m_dSubStepToler) {
|
||||
pSfr->RemoveChunk( c) ;
|
||||
-- c ;
|
||||
}
|
||||
*/
|
||||
if ( dMaxOffs > m_dSubStepToler) {
|
||||
if ( ! pSfrBeauty->AddExtLoop( Release( pCrvExtLoop)))
|
||||
return false ;
|
||||
// inserisco le isole del Chunk corrente
|
||||
for ( int l = 1 ; l < pSfr->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurve> pCrvIsl( pSfr->GetLoop( c, l)) ;
|
||||
if ( IsNull( pCrvIsl) ||
|
||||
! pCrvIsl->IsValid() ||
|
||||
! pSfrBeauty->AddIntLoop( *pCrvIsl))
|
||||
return false ;
|
||||
// inserisco le isole del Chunk corrente
|
||||
for ( int l = 1 ; l < pSfr->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurve> pCrvIsl( pSfr->GetLoop( c, l)) ;
|
||||
if ( IsNull( pCrvIsl) ||
|
||||
! pCrvIsl->IsValid() ||
|
||||
! pSfrBeauty->AddIntLoop( *pCrvIsl))
|
||||
return false ;
|
||||
}
|
||||
continue ; // passo al Chunk successico
|
||||
}
|
||||
}
|
||||
bSameSurf = false ;
|
||||
else
|
||||
bSameSurf = false ;
|
||||
}
|
||||
|
||||
// se ho fatto modifiche, sostituisco la superficie con quella nuova
|
||||
|
||||
@@ -110,6 +110,8 @@ class SurfRoughing : public Machining
|
||||
{ return ( IsNullAngValue( m_Params.m_dSpeed) ? m_TParams.m_dSpeed : m_Params.m_dSpeed) ; }
|
||||
double GetFeed() const
|
||||
{ return ( IsNullLenValue( m_Params.m_dFeed) ? m_TParams.m_dFeed : m_Params.m_dFeed) ; }
|
||||
double GetAdaptedCoeffFeed( bool bSubStep, int nNumStep, double dStep, double dSubStep) const
|
||||
{ return ( 1. + ( bSubStep ? ( nNumStep + 1) * dSubStep / dStep : 0.)) ; }
|
||||
double GetStartFeed() const
|
||||
{ return ( IsNullLenValue( m_Params.m_dStartFeed) ? m_TParams.m_dStartFeed : m_Params.m_dStartFeed) ; }
|
||||
double GetEndFeed() const
|
||||
|
||||
Reference in New Issue
Block a user