EgtMachKernel (MillingToolComp) :

- aggiunta gestione per OneWay a più step e semplificazione del codice.
This commit is contained in:
Riccardo Elitropi
2026-05-26 16:11:09 +02:00
parent 1ebce72c1d
commit f089cd1e1c
3 changed files with 144 additions and 227 deletions
+84 -227
View File
@@ -50,6 +50,7 @@ const double OSC_MIN_LEN = 0.1 ;
const double LIM_DOWN_APPRZ = -0.5 ;
const double DELTA_ELEV_RAD = 4.0 ;
const double LIM_SIN_DIFF_DIR = 0.175 ;
const Color TOOL_CORR_COLOR = Color( 0, 255, 255) ;
//------------------------------ Errors --------------------------------------
// 2301 = "Error in Milling : UpdateToolData failed"
@@ -858,6 +859,10 @@ Milling::Apply( bool bRecalc, bool bPostApply)
if ( m_bToolComp) {
m_Params.m_dLiCompLen = GetToolCompPerpLen() ;
m_Params.m_dLoCompLen = GetToolCompPerpLen() ;
// l'uscita deve essere tra quelle ammesse
int nLeadOutType = GetLeadOutType() ;
if ( nLeadOutType == MILL_LO_NONE || nLeadOutType == MILL_LO_PERP_TG)
m_Params.m_nLeadOutType = MILL_LO_AS_LI ;
}
if ( m_bToolComp && m_TParams.m_nCorr == 0) {
m_bToolComp = false ;
@@ -2592,14 +2597,8 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
return false ;
}
else {
int nId = AddLinearMove( ptP3, bSplitArcs) ;
if ( nId == GDB_ID_NULL)
if ( AddLinearMove( ptP3, bSplitArcs, GetCorrType( TOOL_CORR_PATH, false), nullptr, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, false)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
}
@@ -2624,14 +2623,8 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
return false ;
}
else {
int nId = AddArcMove( ptP3, ptCen, dAngCen, vtN) ;
if ( nId == GDB_ID_NULL)
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, GetCorrType( TOOL_CORR_PATH, false), nullptr, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, false)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
}
@@ -3318,7 +3311,6 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
Point3d ptStart ;
pCurve->GetStartPoint( ptStart) ;
Vector3d vtStart = m_vtStartDir ;
// pCurve->GetStartDir( vtStart) ;
// imposto versore correzione e ausiliario sul punto di partenza
CalcAndSetCorrAuxDir( pCompo, i, false, true) ;
// punto inizio attacco
@@ -3326,7 +3318,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
Vector3d vtDir1 ;
double dCalcStElev = 0 ;
// se speciale e step intermedio
if ( bSpecial && k > 1) {
if ( ! m_bToolComp && bSpecial && k > 1) {
ptP1 = ptStart + dStep * vtTool ;
}
// altrimenti
@@ -3377,19 +3369,25 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
dStElev = ( j - 1) * dStep ;
}
// approccio standard al punto iniziale
if ( k == 1 || bMidRetract) {
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dExtrAppr, bOutStart,
bAhAboveStartEnd || bUhBelowStartEnd, k == 1, bSplitArcs)) {
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
return false ;
if ( ! ( m_bToolComp && bSpecial && k > 1)) {
if ( k == 1 || bMidRetract) {
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dExtrAppr, bOutStart,
bAhAboveStartEnd || bUhBelowStartEnd, k == 1, bSplitArcs)) {
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
return false ;
}
}
// altrimenti approccio diretto al punto iniziale
else {
if ( ! AddDirectApproach( ptP1, bSplitArcs)) {
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
return false ;
}
}
}
// altrimenti approccio diretto al punto iniziale
else {
if ( ! AddDirectApproach( ptP1, bSplitArcs)) {
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
return false ;
}
SetFeed( GetStartFeed()) ;
AddLinearMove( ptP1) ;
}
}
// altrimenti, approccio per lame e frese che non lavorano di testa
@@ -3476,6 +3474,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
}
}
}
// aggiungo attacco
SetFeed( GetStartFeed()) ;
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtTool, dCalcStElev, false, pCompo, bSplitArcs)) {
@@ -3499,8 +3498,14 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
}
else {
Point3d ptP3 = pLine->GetEnd() ;
if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL)
return false ;
if ( ! m_bToolComp) {
if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL)
return false ;
}
else {
if ( AddLinearMove( ptP3, bSplitArcs, GetCorrType( TOOL_CORR_PATH, false), nullptr, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
}
}
}
else if ( pCurve->GetType() == CRV_ARC) {
@@ -3519,20 +3524,25 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
double dAngCen = pArc->GetAngCenter() ;
Vector3d vtN = pArc->GetNormVersor() ;
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
return false ;
if ( ! m_bToolComp) {
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
return false ;
}
else {
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, GetCorrType( TOOL_CORR_PATH, false), nullptr, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
}
}
}
// se ultima entità, uscita e retrazione
if ( i == nMaxInd) {
// se speciale e step intermedio salto uscita e retrazione
if ( bSpecial && k != nStep)
if ( bSpecial && k != nStep && ! m_bToolComp)
continue ;
// dati fine entità
Point3d ptEnd ;
pCurve->GetEndPoint( ptEnd) ;
Vector3d vtEnd = m_vtEndDir ;
// pCurve->GetEndDir( vtEnd) ;
// elevazione sul punto finale
double dEndElev ;
if ( ! GetElevation( m_nPhase, ptEnd, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
@@ -3547,8 +3557,11 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
return false ;
}
// se tool compensation e speciale, allora salto uscita e retroazione
if ( m_bToolComp && bSpecial && k != nStep)
continue ;
// se step finale o intermedi con retrazione
if ( k == nStep || bMidRetract || ! bSafeDirLinkStartEnd) {
if ( ( k == nStep || bMidRetract || ! bSafeDirLinkStartEnd)) {
// determino se la fine dell'uscita è fuori dal grezzo
Vector3d vtRetr( vtTool.x, vtTool.y, 0) ;
if ( ! vtRetr.Normalize())
@@ -5073,18 +5086,8 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
if ( nType == MILL_LI_GLIDE && ! pCompo->IsClosed() && m_dAddedOverlap < EPS_SMALL) {
if ( ! m_bToolComp)
nType = MILL_LI_NONE ;
else {
// aggiungo movimento per l'inizio del percorso
int nIdTC = AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
return true ;
}
else
return ( AddLinearMove( ptStart, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
// Eseguo a seconda del tipo
switch ( nType) {
@@ -5109,32 +5112,14 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
return false ;
}
else {
int nIdTC = AddLinearMove( ptMid, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
if ( AddLinearMove( ptMid, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
if ( ! m_bToolComp)
return ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
if ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
return false ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData != nullptr) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
return true ;
}
else
return ( AddLinearMove( ptStart, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
case MILL_LI_TG_PERP :
{
Vector3d vtPerp = vtStart ;
@@ -5165,14 +5150,8 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
return false ;
}
else {
int nIdTC = AddLinearMove( ptMid, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
if ( AddLinearMove( ptMid, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
PtrOwner<ICurve> pCrv( GetArc2PVN( ptStart, ptMid, - vtStart, vtTool)) ;
@@ -5181,20 +5160,8 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
pCrv->Invert() ;
if ( ! m_bToolComp)
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
if ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
return false ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData != nullptr) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
return true ;
}
else
return ( AddCurveMove( pCrv, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
case MILL_LI_GLIDE :
{
@@ -5250,33 +5217,15 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
return false ;
}
else {
int nIdTC = AddLinearMove( ptMid, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
if ( AddLinearMove( ptMid, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
// emetto (con eventuale spezzatura)
if ( ! m_bToolComp)
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
if ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
return false ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData != nullptr) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
return true ;
}
else
return ( AddCurveMove( pCrv, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
case MILL_LI_ZIGZAG :
{
@@ -5365,26 +5314,9 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d&
Point3d ptCorrE ; pArc->GetStartPoint( ptCorrE) ;
Vector3d vtCorrDir = ptCorrE - ptCen ; vtCorrDir.Normalize() ;
Point3d ptCorrS = ptCorrE - m_Params.m_dLiCompLen * vtCorrDir ;
int nIdTC = AddLinearMove( ptCorrE, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
if ( AddLinearMove( ptCorrE, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
if ( AddCurveMove( pArc, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
return false ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData != nullptr) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
return true ;
return ( AddCurveMove( pArc, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
}
default :
@@ -5603,29 +5535,14 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
if ( IsNull( pArc) || ! pArc->Set( ptCen, vtTool, dRad, - vtCen, dAngCen, 0.))
return false ;
// emetto l'elica (con eventuale spezzatura)
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
if ( AddCurveMove( pArc, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
if ( AddCurveMove( pArc, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData != nullptr) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
// emetto il tratto perpendicolare
Point3d ptCorrS ; pArc->GetEndPoint( ptCorrS) ;
Vector3d vtCorrDir = ptCen - ptCorrS ; vtCorrDir.Normalize() ;
Point3d ptCorrE = ptCorrS + m_Params.m_dLiCompLen * vtCorrDir ;
int nIdTC = AddLinearMove( ptCorrE, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
if ( AddLinearMove( ptCorrE, bSplitArcs, GetCorrType( TOOL_CORR_OUT, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_OUT, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
ptP1 = ptCorrE ;
vtDir1 = vtCorrDir ;
return true ;
@@ -5643,15 +5560,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
vtPerp.Rotate( vtRot, 0, ( bCcwRot ? 1 : - 1)) ;
ptP1 = ptEnd + vtPerp * GetToolCompPerpLen() ;
vtDir1 = ptP1 - ptEnd ;
int nIdTC = AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADIN) ;
if ( nIdTC == GDB_ID_NULL)
return false ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nIdTC)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetCorrType( GetCorrType( TOOL_CORR_IN, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
return true ;
return ( AddLinearMove( ptP1, bSplitArcs, GetCorrType( TOOL_CORR_IN, bInvert), &MCH_CL_LEADIN, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
}
// eseguo a seconda del tipo
@@ -5679,17 +5588,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
if ( ! m_bToolComp)
bOk = ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
bOk = ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; bOk && nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
bOk = ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
bOk = ( AddLinearMove( ptP1, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
// eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile)
if ( dCompLen > 10 * EPS_SMALL) {
@@ -5699,16 +5598,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
ptP1 += vtDir1 * dCompLen ;
if ( ! m_bToolComp)
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdTC = AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) ;
bOk = ( nIdTC != GDB_ID_NULL) ;
CamData* pCamData = bOk ? GetCamData( m_pGeomDB->GetUserObj( nIdTC)) : nullptr ;
bOk = bOk && ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_OUT, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
else
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, GetCorrType( TOOL_CORR_OUT, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
// eventuale movimento in elevazione per flottante
if ( m_bTHoldFloating && dFloatElev > 10 * EPS_SMALL) {
@@ -5752,19 +5643,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
bool bOk = true ;
if ( ! m_bToolComp)
bOk = ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
bOk = ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; bOk && nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
bOk = ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
}
else
bOk = ( AddCurveMove( pCrv, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
// eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile)
if ( dCompLen > 10 * EPS_SMALL) {
vtDir1 = OrthoCompo( vtDirF, vtTool) ;
@@ -5773,16 +5653,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
ptP1 += vtDir1 * dCompLen ;
if ( ! m_bToolComp)
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdTC = AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) ;
bOk = ( nIdTC != GDB_ID_NULL) ;
CamData* pCamData = bOk ? GetCamData( m_pGeomDB->GetUserObj( nIdTC)) : nullptr ;
bOk = bOk && ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_OUT, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
else
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, GetCorrType( TOOL_CORR_OUT, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
// eventuale movimento in elevazione per flottante
if ( m_bTHoldFloating && dFloatElev > 10 * EPS_SMALL) {
@@ -5839,19 +5711,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
bool bOk = true ;
if ( ! m_bToolComp)
bOk = ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdS = m_pGeomDB->GetLastInGroup( m_nPathId) ;
bOk = ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
int nIdE = m_pGeomDB->GetLastInGroup( m_nPathId) ;
for ( int nId = nIdS + 1 ; bOk && nId <= nIdE ; ++ nId) {
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
bOk = ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_PATH, bInvert)) ;
m_pGeomDB->SetMaterial( nId, AQUA) ;
}
}
}
else
bOk = ( AddCurveMove( pCrv, bSplitArcs, GetCorrType( TOOL_CORR_PATH, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
// eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile)
if ( dCompLen > 10 * EPS_SMALL) {
vtDir1 = OrthoCompo( vtDir1, vtTool) ;
@@ -5860,16 +5721,8 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d
ptP1 += vtDir1 * dCompLen ;
if ( ! m_bToolComp)
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
else {
int nIdTC = AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) ;
bOk = ( nIdTC != GDB_ID_NULL) ;
CamData* pCamData = bOk ? GetCamData( m_pGeomDB->GetUserObj( nIdTC)) : nullptr ;
bOk = bOk && ( pCamData != nullptr) ;
if ( bOk) {
pCamData->SetCorrType( GetCorrType( TOOL_CORR_OUT, bInvert)) ;
m_pGeomDB->SetMaterial( nIdTC, AQUA) ;
}
}
else
bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, GetCorrType( TOOL_CORR_OUT, bInvert), &MCH_CL_LEADOUT, &TOOL_CORR_COLOR) != GDB_ID_NULL) ;
}
return bOk ;
}
@@ -7051,13 +6904,17 @@ Milling::CalcOffset( ICurveComposite* pCompo, double dSignOffs) const
// se curva piatta con estrusione non perpendicolare forzo offset avanzato
bool bAdvOffs = ( bIsFlat && abs( vtExtr * plPlane.GetVersN()) < cos( 0.1 * DEGTORAD)) ;
// eseguo offset semplice
if ( ! m_bToolComp && ! bAdvOffs && pCompo->SimpleOffset( dSignOffs, nFlag))
return true ;
if ( m_bToolComp) {
int nSign = ( dSignOffs > 0.) - ( dSignOffs < 0.) ;
pCompo->SimpleOffset( - nSign * GetToolCompMinRadOffset()) ;
pCompo->SimpleOffset( nSign * GetToolCompMinRadOffset()) ;
return true ;
if ( ! m_bToolComp) {
if ( ! bAdvOffs && pCompo->SimpleOffset( dSignOffs, nFlag))
return true ;
}
else {
if ( ! bAdvOffs && pCompo->SimpleOffset( dSignOffs, nFlag)) {
int nSign = ( dSignOffs > 0.) - ( dSignOffs < 0.) ;
pCompo->SimpleOffset( - nSign * GetToolCompMinRadOffset()) ;
pCompo->SimpleOffset( nSign * GetToolCompMinRadOffset()) ;
return true ;
}
}
// eseguo offset avanzato
if ( bIsFlat) {
+4
View File
@@ -325,12 +325,16 @@ class Operation : public IUserObj
int AddLinearMove( const Point3d& ptP, const std::string& sName) ;
int AddLinearMove( const Point3d& ptP, bool bSplit) ;
int AddLinearMove( const Point3d& ptP, bool bSplit, const std::string& sName) ;
int AddLinearMove( const Point3d& ptP, bool bSplit, int nCorrType, const std::string* sName = nullptr, const Color* pColor = nullptr) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, const std::string& sName) ;
int AddArcMove ( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, int nCorrType,
const std::string* psName = nullptr, const Color* pColor = nullptr) ;
int AddCurveMove( const ICurve* pCrv) ;
int AddCurveMove( const ICurve* pCrv, const std::string& sName) ;
int AddCurveMove( const ICurve* pCrv, bool bSplit) ;
int AddCurveMove( const ICurve* pCrv, bool bSplit, const std::string& sName) ;
int AddCurveMove( const ICurve* pCrv, bool bSplit, int nCorrType, const std::string* psName = nullptr, const Color* pColor = nullptr) ;
bool ResetMoveData( void) ;
protected :
+56
View File
@@ -348,6 +348,25 @@ Operation::AddLinearMove( const Point3d& ptP, bool bSplit, const string& sName)
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddLinearMove( const Point3d& ptP, bool bSplit, int nCorrType, const string* psName, const Color* pColor)
{
int nFirstId = AddLinearMove( ptP, bSplit) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
if ( psName != nullptr)
m_pGeomDB->SetName( nId, *psName) ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData == nullptr || ! pCamData->SetCorrType( nCorrType))
return GDB_ID_NULL ;
if ( pColor != nullptr)
m_pGeomDB->SetMaterial( nId, *pColor) ;
nId = m_pGeomDB->GetNext( nId) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN)
@@ -422,6 +441,24 @@ Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen,
return nId ;
}
//----------------------------------------------------------------------------
int
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, int nCorrType,
const string* psName, const Color* pColor)
{
int nId = AddArcMove( ptP, ptCen, dAngCen, vtN) ;
if ( nId != GDB_ID_NULL) {
if ( psName != nullptr)
m_pGeomDB->SetName( nId, *psName) ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData == nullptr || ! pCamData->SetCorrType( nCorrType))
return GDB_ID_NULL ;
if ( pColor != nullptr)
m_pGeomDB->SetMaterial( nId, *pColor) ;
}
return nId ;
}
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv)
@@ -530,6 +567,25 @@ Operation::AddCurveMove( const ICurve* pCrv, bool bSplit, const string& sName)
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv, bool bSplit, int nCorrType, const string* psName, const Color* pColor)
{
int nFirstId = AddCurveMove( pCrv, bSplit) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
if ( psName != nullptr)
m_pGeomDB->SetName( nId, *psName) ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nId)) ;
if ( pCamData == nullptr || ! pCamData->SetCorrType( nCorrType))
return GDB_ID_NULL ;
if ( pColor != nullptr)
m_pGeomDB->SetMaterial( nId, *pColor) ;
nId = m_pGeomDB->GetNext( nId) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
bool
Operation::ResetMoveData( void)