EgtMachKernel :
- in fresatura aggiunta gestione oscillazione - in fresatura su contorno chiuso con sovrapposizione ora possibili attacco e uscita ad inseguimento - in fresatura su contorno chiuso con sovrapposizione ora si sposta sempre l'attacco a metà del lato.
This commit is contained in:
+523
-76
@@ -34,6 +34,9 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//------------------------------ Constants ------------------------------------
|
||||
static const double OSC_MIN_LEN = 0.1 ;
|
||||
|
||||
//------------------------------ Errors --------------------------------------
|
||||
// 2301 = "Error in Milling : UpdateToolData failed"
|
||||
// 2302 = "Error in Milling : Offset not computable"
|
||||
@@ -66,6 +69,8 @@ using namespace std ;
|
||||
// 2356 = "Warning in Milling : machining step too small (xx)"
|
||||
// 2357 = "Warning in Milling : machining step (xxx) bigger than MaxMaterial (yyy)"
|
||||
// 2358 = "Warning in Milling : machining depth (xxx) bigger than MaxMaterial (yyy)"
|
||||
// 2359 = "Warning in Milling : oscillation incompatible with saw blade"
|
||||
// 2360 = "Warning in Milling : oscillation incompatible with depth"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( GetOperationClass( OPER_MILLING), Milling) ;
|
||||
@@ -96,10 +101,12 @@ Milling::Clone( void) const
|
||||
pMill->m_nStatus = m_nStatus ;
|
||||
pMill->m_nMills = m_nMills ;
|
||||
pMill->m_bStepOn = m_bStepOn ;
|
||||
pMill->m_dAddedOverlap = m_dAddedOverlap ;
|
||||
pMill->m_nHeadSolCh = m_nHeadSolCh ;
|
||||
pMill->m_bTiltingTab = m_bTiltingTab ;
|
||||
pMill->m_bAboveHead = m_bAboveHead ;
|
||||
pMill->m_bAggrBottom = m_bAggrBottom ;
|
||||
pMill->m_dCurrOscillLen = m_dCurrOscillLen ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pMill ;
|
||||
@@ -216,10 +223,12 @@ Milling::Milling( void)
|
||||
m_nStatus = MCH_ST_TO_VERIFY ;
|
||||
m_nMills = 0 ;
|
||||
m_bStepOn = false ;
|
||||
m_dAddedOverlap = 0 ;
|
||||
m_nHeadSolCh = MCH_SCC_NONE ;
|
||||
m_bTiltingTab = false ;
|
||||
m_bAboveHead = true ;
|
||||
m_bAggrBottom = false ;
|
||||
m_dCurrOscillLen = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1469,7 +1478,8 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
pCompo->GetEndDir( vtEnd) ;
|
||||
if ( ! AreSameVectorApprox( vtStart, vtEnd)) {
|
||||
bool bAngCCW = ( ( vtEnd ^ vtStart) * vtTool > 0.0) ;
|
||||
if ( m_Params.m_nWorkSide == MILL_WS_CENTER ||
|
||||
if ( m_Params.m_dOverlap > EPS_SMALL ||
|
||||
m_Params.m_nWorkSide == MILL_WS_CENTER ||
|
||||
( m_Params.m_nWorkSide == MILL_WS_RIGHT && ! bAngCCW) ||
|
||||
( m_Params.m_nWorkSide == MILL_WS_LEFT && bAngCCW))
|
||||
pCompo->ChangeStartPoint( 0.5) ;
|
||||
@@ -1524,7 +1534,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
}
|
||||
|
||||
// eventuale sovrapposizione per percorso chiuso
|
||||
double dAddedOverlap = 0 ;
|
||||
m_dAddedOverlap = 0 ;
|
||||
if ( pCompo->IsClosed()) {
|
||||
if ( m_Params.m_dOverlap > EPS_SMALL) {
|
||||
double dParS, dParE ;
|
||||
@@ -1533,7 +1543,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
PtrOwner<ICurve> pCrv( pCompo->CopyParamRange( dParS, dParE)) ;
|
||||
if ( ! IsNull( pCrv)) {
|
||||
pCompo->AddCurve( Release( pCrv)) ;
|
||||
dAddedOverlap = m_Params.m_dOverlap ;
|
||||
m_dAddedOverlap = m_Params.m_dOverlap ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1543,6 +1553,17 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false))
|
||||
return false ;
|
||||
|
||||
// flag di oscillazione del percorso corrente
|
||||
bool bPathOscEnable = m_Params.m_bOscEnable ;
|
||||
|
||||
// se utensile lama, disabilito eventuale oscillazione
|
||||
if ( ( m_TParams.m_nType & TF_SAWBLADE) != 0) {
|
||||
if ( bPathOscEnable) {
|
||||
bPathOscEnable = false ;
|
||||
m_pMchMgr->SetWarning( 2359, "Warning in Milling : oscillation incompatible with saw blade") ;
|
||||
}
|
||||
}
|
||||
|
||||
// recupero i punti di inizio e fine (per poi salvarli nelle info di CL path)
|
||||
Point3d ptStart ; pCompo->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ;
|
||||
@@ -1608,6 +1629,8 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
double dMaxElev ;
|
||||
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "MaxElev="), dMaxElev) && dElev > dMaxElev)
|
||||
dElev = dMaxElev ;
|
||||
// eventuale aggiuntivo all'elevazione per l'oscillazione
|
||||
double dAddElev = ( bPathOscEnable ? abs( m_Params.m_dOscHeight) : 0) ;
|
||||
// eventuale elevazione di fianco (solo per lama)
|
||||
double dSideElev = 0 ;
|
||||
FromString( ExtractInfo( m_Params.m_sUserNotes, "SideElev="), dSideElev) ;
|
||||
@@ -1641,7 +1664,13 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
m_pMchMgr->SetWarning( 2357, sInfo) ;
|
||||
}
|
||||
// se lavorazione singola
|
||||
if ( dOkStep < EPS_SMALL || dOkStep > dElev) {
|
||||
if ( dOkStep < EPS_SMALL || dOkStep > dElev + dAddElev) {
|
||||
// se c'è oscillazione e l'elevazione complessiva supera la capacità dell'utensile, annullo l'oscillazione
|
||||
if ( bPathOscEnable && dElev + dAddElev > m_TParams.m_dMaxMat + EPS_SMALL) {
|
||||
bPathOscEnable = false ;
|
||||
dAddElev = 0 ;
|
||||
m_pMchMgr->SetWarning( 2360, "Warning in Milling : oscillation incompatible with depth") ;
|
||||
}
|
||||
// se l'elevazione supera la capacità dell'utensile
|
||||
if ( dElev > m_TParams.m_dMaxMat + EPS_SMALL) {
|
||||
// se affondamento riducibile : segnalo, riduco e continuo
|
||||
@@ -1663,9 +1692,16 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
}
|
||||
// altrimenti lavorazione a step
|
||||
else {
|
||||
// se l'elevazione supera il massimo affondamento dell'utensile
|
||||
// massimo affondamento dell'utensile
|
||||
double dSafe = m_pMchMgr->GetCurrMachiningsMgr()->GetMaxDepthSafe() ;
|
||||
double dMaxDepth = m_TParams.m_dLen - ( m_TParams.m_dDiam > m_dTHoldDiam ? 0 : m_dTHoldLen) - dSafe ;
|
||||
// se c'è oscillazione e l'elevazione complessiva supera la capacità dell'utensile, annullo l'oscillazione
|
||||
if ( bPathOscEnable && dElev + dAddElev > dMaxDepth + EPS_SMALL) {
|
||||
bPathOscEnable = false ;
|
||||
dAddElev = 0 ;
|
||||
m_pMchMgr->SetWarning( 2360, "Warning in Milling : oscillation incompatible with depth") ;
|
||||
}
|
||||
// se l'elevazione supera il massimo affondamento dell'utensile
|
||||
if ( dElev > dMaxDepth + EPS_SMALL) {
|
||||
// se affondamento riducibile : segnalo, riduco e continuo
|
||||
if ( dDepth + max( dThick, 0.0) > dElev - dMaxDepth) {
|
||||
@@ -1750,30 +1786,32 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
// se altrimenti una sola passata
|
||||
else if ( dOkStep < EPS_SMALL || dOkStep > dElev) {
|
||||
m_bStepOn = false ;
|
||||
if ( ! AddStandardMilling( pCompo, vtTool, dDepth, dElev, bSplitArcs))
|
||||
if ( ! AddStandardMilling( pCompo, vtTool, dDepth, dElev, bSplitArcs, bPathOscEnable))
|
||||
return false ;
|
||||
}
|
||||
// se altrimenti passate a zig-zag
|
||||
else if ( m_Params.m_nStepType == MILL_ST_ZIGZAG) {
|
||||
m_bStepOn = true ;
|
||||
if ( ! AddZigZagMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs))
|
||||
if ( ! AddZigZagMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable))
|
||||
return false ;
|
||||
}
|
||||
// se altrimenti passate a one-way
|
||||
else if ( m_Params.m_nStepType == MILL_ST_ONEWAY) {
|
||||
m_bStepOn = true ;
|
||||
if ( ! AddOneWayMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs))
|
||||
if ( ! AddOneWayMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable))
|
||||
return false ;
|
||||
}
|
||||
// se altrimenti passate a spirale
|
||||
else if ( m_Params.m_nStepType == MILL_ST_SPIRAL) {
|
||||
m_bStepOn = true ;
|
||||
if ( dAddedOverlap > EPS_SMALL) {
|
||||
// rimuovo eventuale sovrapposizione aggiunta
|
||||
if ( m_dAddedOverlap > EPS_SMALL) {
|
||||
pCompo->Invert() ;
|
||||
pCompo->TrimStartAtLen( dAddedOverlap) ;
|
||||
pCompo->TrimStartAtLen( m_dAddedOverlap) ;
|
||||
pCompo->Invert() ;
|
||||
m_dAddedOverlap = 0 ;
|
||||
}
|
||||
if ( ! AddSpiralMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs))
|
||||
if ( ! AddSpiralMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -2016,7 +2054,7 @@ Milling::GenerateMillingPv( int nPathId, const ICurveComposite* pCompo)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, bool bSplitArcs)
|
||||
double dDepth, double dElev, bool bSplitArcs, bool bPathOscEnable)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
@@ -2024,8 +2062,13 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// in caso di oscillazione ne aggiusto i parametri secondo il percorso
|
||||
double dOscRampLen, dOscFlatLen ;
|
||||
AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ;
|
||||
|
||||
// ciclo sulle curve elementari
|
||||
bool bClosed = pCompo->IsClosed() ;
|
||||
m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ;
|
||||
int nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -2101,20 +2144,32 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( bPathOscEnable) {
|
||||
if ( ! AddOscillLine( pLine, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( bPathOscEnable) {
|
||||
if ( ! AddOscillArc( pArc, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ultima entità, uscita e retrazione
|
||||
if ( i == nMaxInd) {
|
||||
@@ -2158,7 +2213,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs)
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
@@ -2166,6 +2221,10 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// in caso di oscillazione ne aggiusto i parametri secondo il percorso
|
||||
double dOscRampLen, dOscFlatLen ;
|
||||
AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ;
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
int nStep = max( 1, static_cast<int>( ceil( dElev / dOkStep))) ;
|
||||
double dStep = dElev / nStep ;
|
||||
@@ -2177,6 +2236,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// flag direzione (prima passata indice 1)
|
||||
bool bInvert = ( ( j % 2) == 0) ;
|
||||
m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ;
|
||||
// ciclo sulle curve elementari
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -2269,21 +2329,32 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
if ( ! AddOscillLine( pLine, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
if ( ! AddOscillArc( pArc, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ultima entità, uscita e se ultimo step retrazione
|
||||
if ( i == nMaxInd) {
|
||||
@@ -2332,7 +2403,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs)
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
@@ -2340,6 +2411,10 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// in caso di oscillazione ne aggiusto i parametri secondo il percorso
|
||||
double dOscRampLen, dOscFlatLen ;
|
||||
AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ;
|
||||
|
||||
// percorso speciale : chiuso e con attacco a spirale o zigzag
|
||||
bool bSpecial = pCompo->IsClosed() && IsLeadInHelixOrZigzag() ;
|
||||
|
||||
@@ -2378,6 +2453,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// ciclo sugli step
|
||||
int nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ;
|
||||
// ciclo sulle curve elementari
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -2468,21 +2544,32 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
if ( ! AddOscillLine( pLine, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
if ( ! AddOscillArc( pArc, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ultima entità, uscita e retrazione
|
||||
if ( i == nMaxInd) {
|
||||
@@ -2528,7 +2615,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs)
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
@@ -2540,6 +2627,10 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
if ( m_Params.m_nLeadInType == MILL_LI_NONE)
|
||||
dStart = m_Params.m_dLiElev ;
|
||||
|
||||
// in caso di oscillazione ne aggiusto i parametri secondo il percorso
|
||||
double dOscRampLen, dOscFlatLen ;
|
||||
AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ;
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
int nStep = max( 1, static_cast<int>( ceil( ( dElev + dStart) / dOkStep))) ;
|
||||
double dStep = ( dElev + dStart) / nStep ;
|
||||
@@ -2554,6 +2645,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// ciclo sugli step
|
||||
for ( int j = 0 ; j <= nStep ; ++ j) {
|
||||
// ciclo sulle curve elementari
|
||||
m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ;
|
||||
double dCurrLen = 0 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -2626,24 +2718,43 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCrvC->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pLine = GetCurveLine( pCrvC) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
PtrOwner<ICurveLine> pTmpLine( pLine->Clone()) ;
|
||||
if ( IsNull( pTmpLine))
|
||||
return false ;
|
||||
pTmpLine->Translate( -vtStaDepth) ;
|
||||
if ( ! AddOscillLine( pTmpLine, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else if ( pCrvC->GetType() == CRV_ARC) {
|
||||
const ICurveArc* pArc = GetCurveArc( pCrvC) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
ptCen -= vtStaDepth ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
PtrOwner<ICurveArc> pTmpArc( pArc->Clone()) ;
|
||||
if ( IsNull( pTmpArc))
|
||||
return false ;
|
||||
pTmpArc->Translate( -vtStaDepth) ;
|
||||
if ( ! AddOscillArc( pTmpArc, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
ptCen -= vtStaDepth ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ultima entità di ultimo step, uscita e retrazione
|
||||
if ( i == nMaxInd && j == nStep) {
|
||||
@@ -2684,6 +2795,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// altrimenti aperto -> avanti e indietro
|
||||
else {
|
||||
// ciclo sugli step
|
||||
@@ -2691,6 +2803,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// flag direzione (prima passata indice 0)
|
||||
bool bInvert = ( ( j % 2) == 1) ;
|
||||
// ciclo sulle curve elementari
|
||||
m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ;
|
||||
double dCurrLen = 0 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -2763,24 +2876,44 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
PtrOwner<ICurveLine> pTmpLine( pLine->Clone()) ;
|
||||
if ( IsNull( pTmpLine))
|
||||
return false ;
|
||||
pTmpLine->Translate( -vtStaDepth) ;
|
||||
if ( ! AddOscillLine( pTmpLine, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
ptCen -= vtStaDepth ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( j == nStep && bPathOscEnable) {
|
||||
PtrOwner<ICurveArc> pTmpArc( pArc->Clone()) ;
|
||||
if ( IsNull( pTmpArc))
|
||||
return false ;
|
||||
pTmpArc->Translate( -vtStaDepth) ;
|
||||
if ( ! AddOscillArc( pTmpArc, vtTool, dOscRampLen, dOscFlatLen))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
ptCen -= vtStaDepth ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtEndDepth ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ultima entità di ultimo step, uscita e retrazione
|
||||
if ( i == nMaxInd && j == nStep) {
|
||||
@@ -3247,7 +3380,7 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const
|
||||
bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) ||
|
||||
( bInvert && m_Params.m_nWorkSide != MILL_WS_LEFT)) ;
|
||||
// verifico di poter fare l'ingresso a inseguimento
|
||||
if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed())
|
||||
if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed() && m_dAddedOverlap < EPS_SMALL)
|
||||
nType = MILL_LI_NONE ;
|
||||
// Calcolo punto iniziale
|
||||
switch ( nType) {
|
||||
@@ -3265,7 +3398,7 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const
|
||||
{
|
||||
if ( ! bInvert) {
|
||||
double dLen, dU ;
|
||||
if ( ! pCompo->GetLength( dLen) || ! pCompo->GetParamAtLength( dLen - dTang, dU) ||
|
||||
if ( ! pCompo->GetLength( dLen) || ! pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU) ||
|
||||
! pCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP1)) {
|
||||
if ( ! pCompo->GetStartPoint( ptP1))
|
||||
return false ;
|
||||
@@ -3314,7 +3447,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
|
||||
dTang = m_Params.m_dLoTang ;
|
||||
}
|
||||
// verifico di poter fare l'ingresso a inseguimento
|
||||
if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed())
|
||||
if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed() && m_dAddedOverlap < EPS_SMALL)
|
||||
nType = MILL_LI_NONE ;
|
||||
// Eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
@@ -3345,7 +3478,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
|
||||
PtrOwner<ICurveComposite> pCrv ;
|
||||
if ( ! bInvert) {
|
||||
double dLen, dU ;
|
||||
if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - dTang, dU)) {
|
||||
if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU)) {
|
||||
double dParS, dParE ;
|
||||
pCompo->GetDomain( dParS, dParE) ;
|
||||
if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE)))
|
||||
@@ -3474,7 +3607,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
|
||||
bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) ||
|
||||
( bInvert && m_Params.m_nWorkSide != MILL_WS_LEFT)) ;
|
||||
// verifico di poter fare l'uscita a inseguimento
|
||||
if ( nType == MILL_LO_GLIDE && ! pCompo->IsClosed())
|
||||
if ( nType == MILL_LO_GLIDE && ! pCompo->IsClosed() && m_dAddedOverlap < EPS_SMALL)
|
||||
nType = MILL_LO_NONE ;
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
@@ -3526,7 +3659,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
|
||||
}
|
||||
else {
|
||||
double dLen, dU ;
|
||||
if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - dTang, dU)) {
|
||||
if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU)) {
|
||||
double dParS, dParE ;
|
||||
pCompo->GetDomain( dParS, dParE) ;
|
||||
if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE)))
|
||||
@@ -3560,6 +3693,320 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AdjustOscillParams( const ICurve* pCrv, bool& bPathOscEnable, double& dRampLen, double& dFlatLen)
|
||||
{
|
||||
// se c'è oscillazione cerco di aggiustare le lunghezze dei Flat per finire con la stessa quota di partenza
|
||||
dRampLen = abs( m_Params.m_dOscRampLen) ;
|
||||
dFlatLen = abs( m_Params.m_dOscFlatLen) ;
|
||||
if ( bPathOscEnable) {
|
||||
// lunghezza del percorso
|
||||
double dLen ; pCrv->GetLength( dLen) ;
|
||||
// se percorso più corto di mezza oscillazione, la disabilito
|
||||
if ( dLen < 2 * dRampLen + 2 * OSC_MIN_LEN)
|
||||
bPathOscEnable = false ;
|
||||
else {
|
||||
int nOsc = max( static_cast<int>( dLen / ( 2 * dRampLen + 2 * dFlatLen)), 1) ;
|
||||
dFlatLen = ( dLen - nOsc * 2 * dRampLen) / ( 2 * nOsc) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen)
|
||||
{
|
||||
// lunghezze dei tratti di oscillazione
|
||||
dRampLen = max( dRampLen, OSC_MIN_LEN) ;
|
||||
dFlatLen = max( dFlatLen, OSC_MIN_LEN) ;
|
||||
double vLenRef[4] = { dRampLen, dRampLen + dFlatLen, 2 * dRampLen + dFlatLen, 2 * dRampLen + 2 * dFlatLen} ;
|
||||
// lunghezza della linea
|
||||
double dLen ; pLine->GetLength( dLen) ;
|
||||
// lunghezza corrente sulla linea
|
||||
double dCurrLen = 0 ;
|
||||
// emissione oscillazioni
|
||||
while ( dCurrLen < dLen - EPS_ZERO) {
|
||||
// lunghezza rimanente
|
||||
double dNextLen = dLen - dCurrLen ;
|
||||
// se inizio è sul primo tratto (rampa discendente)
|
||||
if ( m_dCurrOscillLen < vLenRef[0] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[0] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtTool * ( abs( m_Params.m_dOscHeight) * m_dCurrOscillLen / vLenRef[0]) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[0] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[0] ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[0] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[0] ;
|
||||
double dU ; pLine->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se inizio è sul secondo tratto (parte piatta in basso)
|
||||
else if ( m_dCurrOscillLen < vLenRef[1] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[1] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[1] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[1] ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[1] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[1] ;
|
||||
double dU ; pLine->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se inizio è sul terzo tratto (rampa ascendente)
|
||||
else if ( m_dCurrOscillLen < vLenRef[2] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[2] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
ptP3 -= vtTool * ( abs( m_Params.m_dOscHeight) * ( vLenRef[2] - m_dCurrOscillLen) / ( vLenRef[2] - vLenRef[1])) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[2] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[2] ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[2] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[2] ;
|
||||
double dU ; pLine->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti è sul quarto tratto (parte piatta in alto)
|
||||
else {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[3] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[3] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = 0 ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[3] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = 0 ;
|
||||
double dU ; pLine->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRampLen, double dFlatLen)
|
||||
{
|
||||
// lunghezze dei tratti di oscillazione
|
||||
dRampLen = max( dRampLen, OSC_MIN_LEN) ;
|
||||
dFlatLen = max( dFlatLen, OSC_MIN_LEN) ;
|
||||
double vLenRef[4] = { dRampLen, dRampLen + dFlatLen, 2 * dRampLen + dFlatLen, 2 * dRampLen + 2 * dFlatLen} ;
|
||||
// parametria dell'arco
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
double dLen ; pArc->GetLength( dLen) ;
|
||||
// lunghezza corrente sull'arco
|
||||
double dCurrLen = 0 ;
|
||||
// emissione oscillazioni
|
||||
while ( dCurrLen < dLen - EPS_ZERO) {
|
||||
// lunghezza rimanente
|
||||
double dNextLen = dLen - dCurrLen ;
|
||||
// se inizio è sul primo tratto (rampa discendente)
|
||||
if ( m_dCurrOscillLen < vLenRef[0] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[0] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtTool * ( abs( m_Params.m_dOscHeight) * m_dCurrOscillLen / vLenRef[0]) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[0] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[0] ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[0] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[0] ;
|
||||
double dU ; pArc->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se inizio è sul secondo tratto (parte piatta in basso)
|
||||
else if ( m_dCurrOscillLen < vLenRef[1] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[1] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[1] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[1] ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[1] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[1] ;
|
||||
double dU ; pArc->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
ptP3 -= vtTool * abs( m_Params.m_dOscHeight) ;
|
||||
double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se inizio è sul terzo tratto (rampa ascendente)
|
||||
else if ( m_dCurrOscillLen < vLenRef[2] - 10 * EPS_SMALL) {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[2] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 -= vtTool * ( abs( m_Params.m_dOscHeight) * ( vLenRef[2] - m_dCurrOscillLen) / ( vLenRef[2] - vLenRef[1])) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[2] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = vLenRef[2] ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[2] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = vLenRef[2] ;
|
||||
double dU ; pArc->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti è sul quarto tratto (parte piatta in alto)
|
||||
else {
|
||||
// se fine linea è entro il tratto
|
||||
if ( m_dCurrOscillLen + dNextLen < vLenRef[3] - 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen += dNextLen ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se fine linea è alla fine del tratto
|
||||
else if ( m_dCurrOscillLen + dNextLen < vLenRef[3] + 10 * EPS_SMALL) {
|
||||
dCurrLen = dLen ;
|
||||
m_dCurrOscillLen = 0 ;
|
||||
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
|
||||
double dCurrAngCen = dAngCen * dNextLen / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti fine linea è oltre
|
||||
else {
|
||||
dCurrLen += vLenRef[3] - m_dCurrOscillLen ;
|
||||
m_dCurrOscillLen = 0 ;
|
||||
double dU ; pArc->GetParamAtLength( dCurrLen, dU) ;
|
||||
Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ;
|
||||
double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
Milling::GetRadiusForStartEndElevation( void) const
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "ToolData.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
|
||||
class ICurveLine ;
|
||||
class ICurveArc ;
|
||||
class ICurveComposite ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -77,13 +79,13 @@ class Milling : public Machining
|
||||
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
|
||||
bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ;
|
||||
bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, bool bSplitArcs) ;
|
||||
double dDepth, double dElev, bool bSplitArcs, bool bPathOscEnable) ;
|
||||
bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ;
|
||||
bool AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ;
|
||||
bool AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ;
|
||||
bool AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
||||
@@ -97,6 +99,9 @@ class Milling : public Machining
|
||||
const Vector3d& vtN, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ;
|
||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, double dEndElev,
|
||||
bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) ;
|
||||
bool AdjustOscillParams( const ICurve* pCrv, bool& bPathOscEnable, double& dRampLen, double& dFlatLen) ;
|
||||
bool AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
|
||||
bool AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
|
||||
double GetRadiusForStartEndElevation( void) const ;
|
||||
bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, double dElev) const ;
|
||||
bool GetPointAboveRaw( const Point3d& ptP) const ;
|
||||
@@ -136,10 +141,12 @@ class Milling : public Machining
|
||||
int m_nStatus ; // stato di aggiornamento della lavorazione
|
||||
int m_nMills ; // numero di percorsi di lavoro generati
|
||||
bool m_bStepOn ; // flag per indicare che effettivamente si lavora a step
|
||||
double m_dAddedOverlap ; // overlap effettivamente aggiunto a percorso chiuso
|
||||
int m_nHeadSolCh ; // criterio scelta soluzione impostato nella testa
|
||||
bool m_bTiltingTab ; // flag utilizzo tavola basculante
|
||||
bool m_bAboveHead ; // flag utilizzo testa da sopra
|
||||
bool m_bAggrBottom ; // flag utilizzo di aggregato da sotto
|
||||
Vector3d m_vtAggrBottom ; // vettore direzione ausiliaria aggregato da sotto
|
||||
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
|
||||
double m_dCurrOscillLen ; // lunghezza corrente lungo il percorso per l'oscillazione
|
||||
} ;
|
||||
Reference in New Issue
Block a user