EgtMachKernel 2.6e6 :
- in Finitura Superfici aggiunto sottotipo OneWay - in Finitura Superfici aggiunta verifica utensile con superfici in attacchi e uscite - nelle lavorazioni di Superficie escluso utilizzo di rinvio da sotto - corretto Dump di svuotature per stringhe chiave-valore vuote - prime modifiche a Sgrossatura Supefici.
This commit is contained in:
+533
-40
@@ -62,6 +62,7 @@ using namespace std ;
|
||||
// 3119 = "Error in SurfFinishing : link outstroke"
|
||||
// 3120 = "Error in SurfFinishing : post apply not calculable"
|
||||
// 3121 = "Error in SurfFinishing : Linear Approx not computable"
|
||||
// 3122 = "Error in SurfFinishing : aggregate from bottom not allowed"
|
||||
// 3151 = "Warning in SurfFinishing : Skipped entity (xx)"
|
||||
// 3152 = "Warning in SurfFinishing : No machinable path"
|
||||
// 3153 = "Warning in SurfFinishing : Tool name changed (xx)"
|
||||
@@ -494,6 +495,12 @@ SurfFinishing::Apply( bool bRecalc, bool bPostApply)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// non è prevista finitura superficie con aggregato da sotto
|
||||
if ( IsAggrBottom( m_TParams.m_sHead)) {
|
||||
m_pMchMgr->SetLastError( 3122, "Error in SurfFinishing : aggregate from bottom not allowed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico se necessario continuare nell'aggiornamento
|
||||
if ( ! bRecalc && ! bToolChanged &&
|
||||
( m_nStatus == MCH_ST_OK || ( ! bPostApply && m_nStatus == MCH_ST_NO_POSTAPPL))) {
|
||||
@@ -1230,11 +1237,14 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
// Eseguo la lavorazione a seconda del tipo
|
||||
double dElev = dDepth ;
|
||||
switch ( m_Params.m_nSubType) {
|
||||
case SURFFIN_SUB_ONEWAY :
|
||||
case SURFFIN_SUB_ZIGZAG :
|
||||
if ( ! AddZigZag( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, bSkipMaxDown))
|
||||
return false ;
|
||||
break ;
|
||||
case SURFFIN_SUB_ONEWAY :
|
||||
if ( ! AddOneWay( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, bSkipMaxDown))
|
||||
return false ;
|
||||
break ;
|
||||
case SURFFIN_SUB_SPIRALIN :
|
||||
if ( ! AddSpiral( pCAvTlStm, frSurf, pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs, true))
|
||||
return false ;
|
||||
@@ -1309,7 +1319,6 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
@@ -1465,10 +1474,19 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto)
|
||||
double dStartOnExtr = vtStart * vtExtr ;
|
||||
if ( dStartOnExtr > 0) {
|
||||
vtStart -= dStartOnExtr * vtExtr ;
|
||||
vtStart.Normalize() ;
|
||||
}
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione inizio attacco per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
@@ -1512,17 +1530,30 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// determino elevazione su uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dElev ;
|
||||
// aggiungo uscita
|
||||
// vettore tangente finale non deve scendere rispetto a estrusione
|
||||
double dEndOnExtr = vtEnd * vtExtr ;
|
||||
if ( dEndOnExtr < 0) {
|
||||
vtEnd -= dEndOnExtr * vtExtr ;
|
||||
vtEnd.Normalize() ;
|
||||
}
|
||||
// determino fine uscita
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione fine uscita per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// aggiungo uscita
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) {
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// se non è ultimo tratto, aggiungo retrazione di collegamento
|
||||
if ( k < int( vpCrvs.size()) - 1) {
|
||||
if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) {
|
||||
@@ -1746,6 +1777,393 @@ SurfFinishing::CalcZigZag( const ICurveComposite* pOffs,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::AddOneWay( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dDepth, double dElev, bool bSplitArcs, bool bSkipMaxDown)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// calcolo curva offsettata del raggio utensile
|
||||
double dOffs = m_Params.m_dOverlap - 0.5 * m_TParams.m_dDiam ;
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCompo, dOffs, ICurve::OFF_FILLET)) {
|
||||
m_pMchMgr->SetLastError( 3109, "Error in SurfFinishing : Offset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// ciclo sulle curve risultanti
|
||||
bool bStart = true ;
|
||||
while ( OffsCrv.GetCurveCount() > 0) {
|
||||
// recupero la prima curva di offset
|
||||
PtrOwner<ICurveComposite> pOffs ;
|
||||
if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) {
|
||||
m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino il riferimento di base e il box della svuotatura
|
||||
Frame3d frPocket ;
|
||||
Point3d ptCen ; pCompo->GetCentroid( ptCen) ;
|
||||
frPocket.Set( ptCen, vtExtr) ;
|
||||
frPocket.Rotate( ptCen, vtExtr, m_Params.m_dSideAngle) ;
|
||||
pOffs->ToLoc( frPocket) ;
|
||||
// calcolo i percorsi di svuotatura
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
if ( ! CalcOneWay( pOffs, vpCrvs))
|
||||
return false ;
|
||||
// ciclo sui percorsi
|
||||
double dProgCoeff = 1. / max( int( vpCrvs.size()), 1) ;
|
||||
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
|
||||
// li correggo per non interferire con le superfici
|
||||
if ( pCAvTlStm != nullptr) {
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
if ( ! vpCrvs[k]->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
// eventuale aggiunta di punti per garantire max distanza
|
||||
const double MIN_DIST = 1. ;
|
||||
const double MAX_DIST = 50. ;
|
||||
double dDist = Clamp( m_TParams.m_dDiam / 2, MIN_DIST, MAX_DIST) ;
|
||||
if ( ! PL.AdjustForMaxSegmentLen( dDist))
|
||||
return false ;
|
||||
// porto nel riferimento delle superfici
|
||||
PL.LocToLoc( frPocket, frSurf) ;
|
||||
// porto i dati geometrici in locale alle superfici
|
||||
Vector3d vtAxL = vtTool ;
|
||||
vtAxL.ToLoc( frSurf) ;
|
||||
Vector3d vtMoveL = vtAxL ;
|
||||
// traslo della lunghezza utensile diminuita dell'affondamento
|
||||
PL.Translate( vtAxL * ( m_TParams.m_dLen - dDepth)) ;
|
||||
// eseguo CAv
|
||||
if ( ! pCAvTlStm->TestPath( PL.GetUPointList(), vtAxL, vtMoveL, m_Params.m_dApprox, ( k + 1) * dProgCoeff))
|
||||
return false ;
|
||||
// contro-traslo della lunghezza utensile
|
||||
PL.Translate( - vtAxL * m_TParams.m_dLen) ;
|
||||
// riporto la polilinea nel riferimento della curva
|
||||
PL.LocToLoc( frSurf, frPocket) ;
|
||||
// elimino i punti allineati
|
||||
PL.RemoveAlignedPoints( 0.8 * m_Params.m_dApprox) ;
|
||||
// se richiesto, elimino i punti al massimo affondamento
|
||||
if ( bSkipMaxDown) {
|
||||
PNTULIST& vPntU = PL.GetUPointList() ;
|
||||
bool bPrevDwn = true ;
|
||||
Point3d ptPrev = P_INVALID ;
|
||||
auto currPU = vPntU.begin() ;
|
||||
while ( currPU != vPntU.end()) {
|
||||
auto nextPU = next( currPU) ;
|
||||
bool bNext = ( nextPU != vPntU.end()) ;
|
||||
bool bNextDown = ( bNext ? nextPU->second > -m_Params.m_dApprox : true) ;
|
||||
// punto corrente è al minimo
|
||||
if ( currPU->second > -m_Params.m_dApprox) {
|
||||
// se precedente e successivo al minimo, cancello e basta
|
||||
if ( bPrevDwn && bNextDown) {
|
||||
if ( ! ptPrev.IsValid() || abs( currPU->first.y - ptPrev.y) > 10 * EPS_SMALL)
|
||||
ptPrev = currPU->first ;
|
||||
currPU = vPntU.erase( currPU) ;
|
||||
bPrevDwn = true ;
|
||||
}
|
||||
// se precedente ok e successivo al minimo, aggiungo opportuno movimento di uscita
|
||||
else if ( ! bPrevDwn && bNextDown && bNext) {
|
||||
Vector3d vtDir = nextPU->first - currPU->first ;
|
||||
double dMove = vtDir.Len() ;
|
||||
if ( dMove > 100 * EPS_SMALL) {
|
||||
vtDir /= dMove ;
|
||||
dMove = min( dMove, 2.) ;
|
||||
Point3d ptNew = currPU->first + vtDir * dMove ;
|
||||
ptPrev = ptNew ;
|
||||
currPU = next( vPntU.insert( nextPU, { ptNew, 0})) ;
|
||||
bPrevDwn = true ;
|
||||
}
|
||||
else {
|
||||
ptPrev = currPU->first ;
|
||||
currPU = nextPU ;
|
||||
bPrevDwn = false ;
|
||||
}
|
||||
}
|
||||
// se precedente al minimo e successivo ok, aggiungo opportuno movimento di ingresso
|
||||
else if ( bPrevDwn && ptPrev.IsValid() && ! bNextDown) {
|
||||
Vector3d vtDir = currPU->first - ptPrev ;
|
||||
double dMove = vtDir.Len() ;
|
||||
if ( dMove > 9 * EPS_SMALL) {
|
||||
vtDir /= dMove ;
|
||||
dMove = min( dMove, 2.) ;
|
||||
Point3d ptNew = currPU->first - vtDir * dMove ;
|
||||
vPntU.insert( currPU, { ptNew, 0}) ;
|
||||
ptPrev = currPU->first ;
|
||||
currPU = nextPU ;
|
||||
}
|
||||
else {
|
||||
ptPrev = currPU->first ;
|
||||
currPU = nextPU ;
|
||||
}
|
||||
bPrevDwn = true ;
|
||||
}
|
||||
// altrimenti va tenuto
|
||||
else {
|
||||
ptPrev = currPU->first ;
|
||||
currPU = nextPU ;
|
||||
bPrevDwn = true ;
|
||||
}
|
||||
}
|
||||
// punto corrente sulla superficie
|
||||
else {
|
||||
ptPrev = currPU->first ;
|
||||
currPU = nextPU ;
|
||||
bPrevDwn = false ;
|
||||
}
|
||||
}
|
||||
// se eliminati tutti i punti passo oltre
|
||||
if ( PL.GetLineNbr() == 0)
|
||||
continue ;
|
||||
}
|
||||
// creo una curva composita a partire dalla polilinea
|
||||
PtrOwner< ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
|
||||
return false ;
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
vpCrvs[k].Set( pCompo) ;
|
||||
}
|
||||
// ciclo sulle curve elementari
|
||||
int nMaxInd = vpCrvs[k]->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = vpCrvs[k]->GetCurve( i) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCurve( pCrvC->Clone()) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
pCurve->ToGlob( frPocket) ;
|
||||
// se prima entità
|
||||
if ( i == 0 ) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto)
|
||||
double dStartOnExtr = vtStart * vtExtr ;
|
||||
if ( dStartOnExtr > 0) {
|
||||
vtStart -= dStartOnExtr * vtExtr ;
|
||||
vtStart.Normalize() ;
|
||||
}
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione inizio attacco per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se inizio, approccio globale al punto iniziale
|
||||
if ( bStart) {
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 3111, "Error in SurfFinishing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
bStart = false ;
|
||||
}
|
||||
// altrimenti, approccio di collegamento
|
||||
else {
|
||||
if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 3113, "Error in SurfFinishing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// elaborazioni sulla curva corrente (sempre un segmento di retta)
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
if ( pLine == nullptr)
|
||||
return false ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
Vector3d vtMove ; pLine->GetStartDir( vtMove) ;
|
||||
SetFeed( GetRightFeed( vtMove, vtTool)) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se ultima entità
|
||||
if ( i == nMaxInd) {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// vettore tangente finale non deve scendere rispetto a estrusione
|
||||
double dEndOnExtr = vtEnd * vtExtr ;
|
||||
if ( dEndOnExtr < 0) {
|
||||
vtEnd -= dEndOnExtr * vtExtr ;
|
||||
vtEnd.Normalize() ;
|
||||
}
|
||||
// determino fine uscita
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione fine uscita per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// aggiungo uscita
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// se non è ultimo tratto, aggiungo retrazione di collegamento
|
||||
if ( k < int( vpCrvs.size()) - 1) {
|
||||
if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 3112, "Error in SurfFinishing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti aggiungo retrazione finale
|
||||
else {
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 3115, "Error in SurfFinishing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::CalcOneWay( const ICurveComposite* pOffs,
|
||||
ICRVCOMPOPOVECTOR& vpCrvs)
|
||||
{
|
||||
// ingombro del contorno offsettato
|
||||
BBox3d b3Pocket ;
|
||||
pOffs->GetLocalBBox( b3Pocket) ;
|
||||
Point3d ptMin ; double dDimX, dDimY, dDimZ ;
|
||||
b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
|
||||
|
||||
// lunghezza del contorno offsettato
|
||||
double dLen ; pOffs->GetLength( dLen) ;
|
||||
|
||||
// passi in Y
|
||||
int nYStep = static_cast<int>( ceil( ( dDimY - 20 * EPS_SMALL) / GetSideStep())) ;
|
||||
double dYStep = ( nYStep > 0 ? ( dDimY - 20 * EPS_SMALL) / nYStep : 0) ;
|
||||
|
||||
// tratto valido
|
||||
struct Section {
|
||||
bool bActive ;
|
||||
Point3d ptS ;
|
||||
Point3d ptE ;
|
||||
double dOs ;
|
||||
double dOe ;
|
||||
} ;
|
||||
// raccolta di tratti
|
||||
typedef vector<vector<Section>> VECVECSECT ;
|
||||
|
||||
VECVECSECT vvSec ;
|
||||
vvSec.resize( nYStep + 1) ;
|
||||
|
||||
// calcolo le linee di svuotatura
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i <= nYStep ; ++ i) {
|
||||
// definisco la linea
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
const double EXP_LEN = 1.0 ;
|
||||
Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + 10 * EPS_SMALL + i * dYStep, ptMin.z + dDimZ) ;
|
||||
if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) {
|
||||
m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// calcolo la classificazione della curva rispetto al contorno esterno offsettato
|
||||
IntersCurveCurve intCC( *pLine, *pOffs) ;
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! intCC.GetCurveClassification( 0, EPS_SMALL, ccClass)) {
|
||||
m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino gli intervalli di curva da conservare
|
||||
Intervals inOk ;
|
||||
for ( auto& ccOne : ccClass) {
|
||||
if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)
|
||||
inOk.Add( ccOne.dParS, ccOne.dParE) ;
|
||||
}
|
||||
// inserisco i tratti validi (sempre secondo X+)
|
||||
double dParS, dParE ;
|
||||
bool bFound = inOk.GetFirst( dParS, dParE) ;
|
||||
while ( bFound) {
|
||||
// determino i dati della sezione
|
||||
Section Sect ;
|
||||
Sect.bActive = true ;
|
||||
pLine->GetPointD1D2( dParS, ICurve::FROM_PLUS, Sect.ptS) ;
|
||||
pLine->GetPointD1D2( dParE, ICurve::FROM_MINUS, Sect.ptE) ;
|
||||
pOffs->GetParamAtPoint( Sect.ptS, Sect.dOs, 10 * EPS_SMALL) ;
|
||||
pOffs->GetParamAtPoint( Sect.ptE, Sect.dOe, 10 * EPS_SMALL) ;
|
||||
// inserisco nel contenitore
|
||||
vvSec[i].emplace_back( Sect) ;
|
||||
++ nCount ;
|
||||
// recupero successivo intervallo
|
||||
bFound = inOk.GetNext( dParS, dParE) ;
|
||||
}
|
||||
}
|
||||
|
||||
// creo i percorsi di svuotatura
|
||||
vpCrvs.reserve( nCount) ;
|
||||
int nI = -1, nJ = -1 ;
|
||||
while ( true) {
|
||||
// se sezione non valida
|
||||
if ( nI < 0 || nJ < 0) {
|
||||
// ricerco la prima valida
|
||||
for ( int k = 0 ; k < int( vvSec.size()) && nI < 0 ; ++ k) {
|
||||
for ( int l = 0 ; l < int( vvSec[k].size()) && nJ < 0 ; ++ l) {
|
||||
if ( vvSec[k][l].bActive) {
|
||||
nI = k ;
|
||||
nJ = l ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovata, creo nuova curva composita
|
||||
if ( nI >= 0 && nJ >= 0) {
|
||||
// creo la curva
|
||||
vpCrvs.emplace_back( CreateCurveComposite()) ;
|
||||
// aggiungo punto iniziale
|
||||
vpCrvs.back()->AddPoint( vvSec[nI][nJ].ptS) ;
|
||||
}
|
||||
// altrimenti, esco
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// aggiungo la sezione alla curva
|
||||
Section& Sec = vvSec[nI][nJ] ;
|
||||
Sec.bActive = false ;
|
||||
vpCrvs.back()->AddLine( vvSec[nI][nJ].ptE) ;
|
||||
nI = -1 ;
|
||||
nJ = -1 ;
|
||||
}
|
||||
|
||||
// se richiesta percorrenza invertita
|
||||
if ( m_Params.m_bInvert) {
|
||||
for ( auto& pCompo : vpCrvs)
|
||||
pCompo->Invert() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
@@ -1754,7 +2172,6 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
@@ -1833,10 +2250,19 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// vettore tangente iniziale non deve salire rispetto a estrusione (poi si prende opposto)
|
||||
double dStartOnExtr = vtStart * vtExtr ;
|
||||
if ( dStartOnExtr > 0) {
|
||||
vtStart -= dStartOnExtr * vtExtr ;
|
||||
vtStart.Normalize() ;
|
||||
}
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione inizio attacco per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptStart, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
@@ -1880,17 +2306,30 @@ SurfFinishing::AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// determino elevazione su uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dElev ;
|
||||
// aggiungo uscita
|
||||
// vettore tangente finale non deve scendere rispetto a estrusione
|
||||
double dEndOnExtr = vtEnd * vtExtr ;
|
||||
if ( dEndOnExtr < 0) {
|
||||
vtEnd -= dEndOnExtr * vtExtr ;
|
||||
vtEnd.Normalize() ;
|
||||
}
|
||||
// determino fine uscita
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadOutEnd( ptEnd, vtEnd, vtExtr, ptP1))
|
||||
return false ;
|
||||
// eventuale correzione fine uscita per evitare interferenze
|
||||
if ( ! GetLastGoodPoint( pCAvTlStm, frSurf, ptEnd, ptP1, vtTool, ptP1))
|
||||
return false ;
|
||||
// aggiungo uscita
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) {
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, ptP1, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 3114, "Error in SurfFinishing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// se non è ultimo tratto, aggiungo retrazione di collegamento
|
||||
if ( false) {
|
||||
if ( ! AddLinkRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) {
|
||||
@@ -2146,7 +2585,7 @@ SurfFinishing::GetLeadInType( void) const
|
||||
bool
|
||||
SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, Point3d& ptP1) const
|
||||
{
|
||||
// Assegno il tipo
|
||||
// Assegno tipo e parametri
|
||||
int nType = GetLeadInType() ;
|
||||
double dTang = m_Params.m_dLiTang ;
|
||||
double dPerp = m_Params.m_dLiPerp ;
|
||||
@@ -2162,8 +2601,8 @@ SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart,
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtStart) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptStart - vtStart * dTang + vtPerp * dPerp ;
|
||||
return true ;
|
||||
}
|
||||
return true ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -2173,10 +2612,11 @@ SurfFinishing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart,
|
||||
bool
|
||||
SurfFinishing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs)
|
||||
{
|
||||
// Se inizio e fine coincidono, non devo fare alcunché
|
||||
if ( AreSamePointApprox( ptP1, ptStart))
|
||||
return true ;
|
||||
// Assegno il tipo
|
||||
int nType = GetLeadInType() ;
|
||||
double dTang = m_Params.m_dLiTang ;
|
||||
double dPerp = m_Params.m_dLiPerp ;
|
||||
// Eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case SURFFIN_LI_NONE :
|
||||
@@ -2207,9 +2647,9 @@ SurfFinishing::GetLeadOutType( void) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1, bool bSplitArcs)
|
||||
SurfFinishing::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1) const
|
||||
{
|
||||
// assegno i parametri
|
||||
// Assegno tipo e parametri
|
||||
int nType = GetLeadOutType() ;
|
||||
double dTang = m_Params.m_dLoTang ;
|
||||
double dPerp = m_Params.m_dLoPerp ;
|
||||
@@ -2224,19 +2664,12 @@ SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Ve
|
||||
dTang = m_Params.m_dLiTang ;
|
||||
dPerp = m_Params.m_dLiPerp ;
|
||||
}
|
||||
// eseguo a seconda del tipo
|
||||
// Calcolo punto finale
|
||||
switch ( nType) {
|
||||
case SURFFIN_LO_NONE :
|
||||
ptP1 = ptEnd ;
|
||||
return true ;
|
||||
case SURFFIN_LO_LINEAR :
|
||||
{
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
case SURFFIN_LO_TANGENT :
|
||||
{
|
||||
// calcolo punto finale dell'uscita
|
||||
@@ -2244,23 +2677,83 @@ SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Ve
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
// inserisco uscita
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
// assegno direzione finale dell'uscita
|
||||
Vector3d vtDirF ;
|
||||
if ( ! pCrv->GetEndDir( vtDirF))
|
||||
return false ;
|
||||
bool bOk = true ;
|
||||
// emetto movimento
|
||||
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
return true ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Point3d& ptP1, const Vector3d& vtTool, bool bSplitArcs)
|
||||
{
|
||||
// Se inizio e fine coincidono, non devo fare alcunché
|
||||
if ( AreSamePointApprox( ptEnd, ptP1))
|
||||
return true ;
|
||||
// Assegno tipo e parametri
|
||||
int nType = GetLeadOutType() ;
|
||||
// se uscita come ingresso
|
||||
if ( nType == SURFFIN_LO_AS_LI) {
|
||||
int nLiType = GetLeadInType() ;
|
||||
switch ( nLiType) {
|
||||
case SURFFIN_LI_LINEAR : nType = SURFFIN_LO_LINEAR ; break ;
|
||||
case SURFFIN_LI_TANGENT : nType = SURFFIN_LO_TANGENT ; break ;
|
||||
default : nType = SURFFIN_LO_NONE ; break ;
|
||||
}
|
||||
}
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case SURFFIN_LO_NONE :
|
||||
return true ;
|
||||
case SURFFIN_LO_LINEAR :
|
||||
return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
case SURFFIN_LO_TANGENT :
|
||||
// inserisco uscita
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
// assegno direzione finale dell'uscita
|
||||
Vector3d vtDirF ;
|
||||
if ( ! pCrv->GetEndDir( vtDirF))
|
||||
return false ;
|
||||
// emetto movimento
|
||||
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFinishing::GetLastGoodPoint( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
||||
const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, Point3d& ptP1)
|
||||
{
|
||||
// porto i punti e il versore nel riferimento superficie
|
||||
Point3d ptStartL = GetToLoc( ptStart, frSurf) ;
|
||||
Point3d ptEndL = GetToLoc( ptEnd, frSurf) ;
|
||||
Vector3d vtToolL = GetToLoc( vtTool, frSurf) ;
|
||||
// porto i punti dal tip al naso mandrino
|
||||
ptStartL += vtToolL * m_TParams.m_dLen ;
|
||||
ptEndL += vtToolL * m_TParams.m_dLen ;
|
||||
// verifico che il movimento non interferisca con la superficie
|
||||
PNTULIST lstPntU{ { ptStartL, 0}, { ptEndL, 1}} ;
|
||||
if ( ! pCAvTlStm->TestPath( lstPntU, vtToolL, vtToolL, m_Params.m_dApprox, 0))
|
||||
return false ;
|
||||
// cerco l'ultimo punto non spostato per evitare collisione
|
||||
bool bFound = false ;
|
||||
auto currPU = lstPntU.begin() ;
|
||||
while ( ! bFound && currPU != lstPntU.end()) {
|
||||
auto nextPU = next( currPU) ;
|
||||
if ( nextPU == lstPntU.end() || nextPU->second < -m_Params.m_dApprox){
|
||||
bFound = true ;
|
||||
ptP1 = GetToGlob( currPU->first - vtToolL * m_TParams.m_dLen, frSurf) ;
|
||||
}
|
||||
currPU = nextPU ;
|
||||
}
|
||||
return bFound ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
SurfFinishing::GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const
|
||||
|
||||
Reference in New Issue
Block a user