EgtMachKernel :

- svuotatura nel caso di materiale residuo negli angoli, prima implementazione.
This commit is contained in:
SaraP
2021-05-11 11:38:05 +02:00
parent bccbedb92f
commit ded589ac0d
+81 -11
View File
@@ -3116,8 +3116,8 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
//----------------------------------------------------------------------------
bool
Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
ICurveComposite* pMCrv, ICurveComposite* pRCrv)
{
ICurveComposite* pMCrv, ICurveComposite* pRCrv)
{
// inizializzo i risultati
pMCrv->Clear() ;
pRCrv->Clear() ;
@@ -3146,13 +3146,15 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
ICURVEPOVECTOR vOffs ;
ICURVEPOVECTOR vCrvStack ;
DBLVECTOR vRadStack ;
PtrOwner<ICurve> pOffs ;
PtrOwner<ICurveComposite> pOffs ;
double dCurrRad = GetCurveRadius( pCompo) ;
while ( nIter < MAX_ITER) {
double dOffsOld = 0.0 ;
while ( nIter < MAX_ITER) {
// calcolo
OffsetCurve OffsCrv ;
if ( ! OffsCrv.Make( ( nIter == 0 ? (ICurve*) pCompo : pOffs), - dOffs, ICurve::OFF_FILLET) ||
( nIter == 0 && nReg == 0 && OffsCrv.GetCurveCount() == 0)) {
( nIter == 0 && nReg == 0 && OffsCrv.GetCurveCount() == 0)) {
m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
return false ;
}
@@ -3182,19 +3184,87 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
dCurrRad = vRadStack.back() ;
vRadStack.pop_back() ;
}
// analizzo pOffs per aggiungere tratti lineari in corrispondenza degli angoli critici
PtrOwner<ICurveComposite> pNewOffs ; // curva con tratti aggiuntivi
if ( nIter > 1)
pNewOffs.Set( CreateCurveComposite()) ;
else if ( ! IsNull( pOffs))
pNewOffs.Set( pOffs->Clone()) ;
if ( ! IsNull( pOffs) && nIter > 1) {
double dOverlap = 1 - dOffsOld / m_TParams.m_dDiam ;
double dSharpSin = 1 - 2 * dOverlap ; // valore critico
const ICurve * pCrv = pOffs->GetFirstCurve() ;
while ( pCrv != nullptr) {
pNewOffs->AddCurve( pCrv->Clone()) ;
// curva successiva
const ICurve * pCrvNext = pOffs->GetNextCurve() ;
if ( pCrvNext == nullptr) {
pCrvNext = pOffs->GetFirstCurve() ;
pOffs->GetLastCurve() ;
}
else
pOffs->GetPrevCurve() ;
// angolo fra le curve
Vector3d vtS, vtE ;
Point3d ptVertex ;
pCrv->GetEndPoint( ptVertex) ;
pCrv->GetEndDir( vtE) ;
pCrvNext->GetStartDir( vtS) ;
vtS.Normalize() ;
vtE.Normalize() ;
vtS.Invert() ;
double dCosAng = vtS * vtE ;
double dAngSin = sqrt( (1 - dCosAng) / 2) ;
// se angolo critico
if ( dAngSin < dSharpSin) {
double dLen = ( m_TParams.m_dDiam / 2 - m_TParams.m_dDiam * dOverlap) / dAngSin - m_TParams.m_dDiam / 2 ;
Vector3d vtDir = vtE ;
double dCosRot = sqrt( ( 1 + dCosAng) / 2) ;
double dSinRot = sqrt( ( 1 - dCosAng) / 2) ;
vtDir.Rotate( vtE ^ vtS, dCosRot, dSinRot) ;
vtDir.Normalize() ;
Point3d ptNew = ptVertex + dLen * vtDir ;
// curva da aggiungere
PtrOwner<ICurveComposite> pAddCrv ;
pAddCrv.Set( CreateCurveComposite()) ;
pAddCrv->AddPoint( ptVertex) ;
pAddCrv->AddLine( ptNew) ;
pAddCrv->AddLine( ptVertex) ;
pNewOffs->AddCurve( Release( pAddCrv)) ;
}
pCrv = pOffs->GetNextCurve() ;
}
}
double dRad = GetCurveRadius( pNextOffs) ;
bool bNextOk = ( dRad > EPS_ZERO && dRad < dCurrRad) ;
bool bSmallRad = ( nIter == 0 ? dOffs < dTRad + GetOffsR() + EPS_ZERO : dOffs < dTRad + EPS_ZERO) ;
// se completato step di offset, accodo la curva offsettata al percorso di lavoro
if ( ! IsNull( pOffs) && ( bNextOk || bSmallRad)) {
// inserisco l'offset nel vettore
vOffs.emplace_back( Release( pOffs)) ;
if ( ! IsNull( pNewOffs) && ( bNextOk || bSmallRad)) {
// inserisco l'offset nel vettore
vOffs.emplace_back( Release( pNewOffs)) ;
}
// se offset va bene
// aggiorno valore di dOffs
dOffsOld = dOffs ;
// se offset va bene
if ( bNextOk) {
// sistemo per prossimo step
dCurrRad = dRad ;
pOffs.Set( Release( pNextOffs)) ;
pOffs.Set( GetCurveComposite( Release( pNextOffs))) ;
// nuovo valore pari allo step
dOffs = GetSideStep() ;
}
@@ -3257,7 +3327,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
for ( int i = 0 ; i < int( vOffs.size()) ; ++ i) {
// se collegamento da aggiungere
if ( ! IsNull( vLinks[i])) {
// accodo nel percorso di lavorazione
// accodo nel percorso di lavorazione
pMCrv->AddCurve( Release( vLinks[i])) ;
}
// se richiesta percorrenza invertita