Merge commit 'd3b281a858c34a3f760c5afd925417b421b1a6d6' into Svuotature_LeadIn/Out

This commit is contained in:
Riccardo Elitropi
2024-02-26 16:10:46 +01:00
5 changed files with 372 additions and 56 deletions
+339 -40
View File
@@ -33,6 +33,7 @@
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkIntersCurveSurfTm.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
@@ -53,7 +54,7 @@ const double DELTA_ELEV_RAD = 4.0 ;
// 2303 = "Error in Milling : Empty RawBox"
// 2304 = "Error in Milling : Depth not computable"
// 2305 = "Error in Milling : machining depth (xx) bigger than MaxMaterial (yy)"
// 2306 = "Error in Milling : Entity GetElevation"
// 2306 = "Error in Milling : machining step (xx) bigger than MaxMaterial (yy)"
// 2307 = "Error in Milling : missing aggregate from bottom"
// 2308 = "Error in Milling : path too far from part sides"
// 2309 = "Error in Milling : Approach not computable"
@@ -1831,7 +1832,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
dOkStep = m_Params.m_dStep + EPS_ZERO ;
else if ( m_Params.m_dStep < -EPS_SMALL &&
( m_TParams.m_nType == TT_MILL_NOTIP ||
( ( m_TParams.m_nType & TF_SAWBLADE) != 0 && dSideElev < 10 * EPS_SMALL))) {
( ( m_TParams.m_nType & TF_SAWBLADE) != 0 && abs( dSideElev) < 10 * EPS_SMALL))) {
dOkStep = abs( m_Params.m_dStep) + EPS_ZERO ;
bStepUp = true ;
}
@@ -1902,12 +1903,27 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
}
}
// per lame e con elevazione di lato definita
else if ( dSideElev > EPS_SMALL) {
if ( dSideElev > m_TParams.m_dMaxMat) {
string sInfo = "Error in Milling : machining depth (" + ToString( dSideElev, 1) +
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
m_pMchMgr->SetLastError( 2305, sInfo) ;
return false ;
else if ( abs( dSideElev) > EPS_SMALL) {
// caso standard
if ( dSideElev > 0) {
// se l'elevazione di lato supera la capacità dell'utensile
if ( dSideElev > m_TParams.m_dMaxMat + EPS_SMALL) {
string sInfo = "Error in Milling : machining depth (" + ToString( dSideElev, 1) +
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
m_pMchMgr->SetLastError( 2305, sInfo) ;
return false ;
}
}
// per tagli a cubetti (ciascuno step di taglio cade)
else {
// se lo step supera la capacità dell'utensile
if ( m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL) {
string sInfo = "Error in Milling : machining step (" + ToString( m_Params.m_dStep, 1) +
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
m_pMchMgr->SetLastError( 2306, sInfo) ;
return false ;
}
dSideElev = abs( dSideElev) ;
}
}
@@ -1986,7 +2002,10 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
// Se lama con elevazione e step di fianco
if ( ( m_TParams.m_nType & TF_SAWBLADE) != 0 && dSideElev > 10 * EPS_SMALL && dOkStep > EPS_SMALL) {
m_bStepOn = true ;
bOk = AddSawZigZagMilling( pCompo, vtTool, dDepth, dSideElev, dOkStep, bSplitArcs) ;
if ( m_Params.m_nStepType != MILL_ST_ONEWAY)
bOk = AddSawZigZagMilling( pCompo, vtTool, dDepth, dSideElev, dOkStep, bSplitArcs) ;
else
bOk = AddSawOneWayMilling( pCompo, vtTool, dDepth, dSideElev, dOkStep, bSplitArcs) ;
}
// se altrimenti una sola passata
else if ( dOkStep < EPS_SMALL || dOkStep > dElev) {
@@ -3810,20 +3829,26 @@ class LeadIOStatus
LeadIOStatus( Milling* pMill)
{ m_pMill = pMill ;
m_dLiPerp = m_pMill->m_Params.m_dLiPerp ;
m_dLiTang = m_pMill->m_Params.m_dLiTang ;
m_dLoPerp = m_pMill->m_Params.m_dLoPerp ;
m_dLoTang = m_pMill->m_Params.m_dLoTang ;
}
~LeadIOStatus( void)
{ Restore() ;
}
void Restore( void)
{ m_pMill->m_Params.m_dLiPerp = m_dLiPerp ;
m_pMill->m_Params.m_dLiTang = m_dLiTang ;
m_pMill->m_Params.m_dLoPerp = m_dLoPerp ;
m_pMill->m_Params.m_dLoTang = m_dLoTang ;
}
private :
Milling* m_pMill ;
double m_dLiPerp ;
double m_dLiTang ;
double m_dLoPerp ;
double m_dLoTang ;
} ;
//----------------------------------------------------------------------------
@@ -3839,44 +3864,64 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT
// flag di percorso chiuso
bool bClosed = pCompo->IsClosed() ;
// recupero eventuale superficie trimesh chiusa per trim/extend
int nTriExtCstm = GDB_ID_NULL ;
int nTesId ;
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "TrimExt="), nTesId)) {
const ISurfTriMesh* pTes = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nTesId)) ;
if ( pTes != nullptr && pTes->IsClosed())
nTriExtCstm = nTesId ;
}
// determino numero e affondamento degli step
int nStep = max( 1, static_cast<int>( ceil( dElev / dOkStep))) ;
double dStep = dElev / nStep ;
// gestione parametri di attacco/uscita (con backup per ripristino all'uscita)
LeadIOStatus LioStatus( this) ;
bool bAdjustLiPerp = ( m_Params.m_dLiPerp > EPS_SMALL) ;
if ( bAdjustLiPerp)
m_Params.m_dLiPerp = max( 0., m_Params.m_dLiPerp - ( nStep - 1) * dStep) ;
bool bAdjustLoPerp = ( m_Params.m_dLoPerp > EPS_SMALL) ;
m_Params.m_dLoPerp = 0. ;
bool bAdjustLiPerp = ( m_Params.m_dLiPerp > 10 * EPS_SMALL) ;
if ( bAdjustLiPerp) {
double dNewLiPerp = max( 0., m_Params.m_dLiPerp - ( nStep - 1) * dStep) ;
m_Params.m_dLiTang *= dNewLiPerp / m_Params.m_dLiPerp ;
m_Params.m_dLiPerp = dNewLiPerp ;
}
bool bAdjustLoPerp = ( m_Params.m_dLoPerp > 10 * EPS_SMALL) ;
if ( bAdjustLoPerp) {
m_Params.m_dLoTang = 0 ;
m_Params.m_dLoPerp = 0. ;
}
// ciclo sugli step
for ( int j = 1 ; j <= nStep ; ++ j) {
// flag direzione (prima passata indice 1)
bool bInvert = ( ( j % 2) == 0) ;
// flag direzione
bool bInvert = ( (( nStep - j) % 2) == 1) ;
// copio la curva
PtrOwner<ICurveComposite> pMyCompo( pCompo->Clone()) ;
if ( IsNull( pMyCompo))
return false ;
// eseguo offset
// eseguo offset ed eventuale inversione
double dSignOffs = ( dElev - j * dStep) * ( m_Params.m_nWorkSide == MILL_WS_LEFT ? - 1 : 1) ;
if ( ! CalcOffset( pMyCompo, dSignOffs))
return false ;
// dopo primo step annullo parametro di attacco
if ( j > 1)
if ( bInvert)
pMyCompo->Invert() ;
// eventuale trim/extend con la superficie indicata
if ( nTriExtCstm != GDB_ID_NULL) {
// trim con ripristino dell'originale in caso di errore
PtrOwner<ICurveComposite> pMyCopy( pMyCompo->Clone()) ;
if ( ! TrimExtendCurveToClosedStm( pMyCompo, nTriExtCstm, bInvert))
pMyCompo.Set( pMyCopy) ;
}
// dopo primo step annullo parametri di attacco
if ( j > 1 && bAdjustLiPerp) {
m_Params.m_dLiPerp = 0. ;
m_Params.m_dLiTang = 0. ;
}
// ciclo sulle curve elementari
int nMaxInd = pCompo->GetCurveCount() - 1 ;
int nMaxInd = pMyCompo->GetCurveCount() - 1 ;
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
// curva corrente
const ICurve* pCrvC = pMyCompo->GetCurve( ( bInvert ? nMaxInd - i : i)) ;
// copio la curva
PtrOwner<ICurve> pCurve( pCrvC->Clone()) ;
if ( IsNull( pCurve))
return false ;
if ( bInvert)
pCurve->Invert() ;
const ICurve* pCurve = pMyCompo->GetCurve( i) ;
// se prima entità, se primo step approccio e sempre affondo
if ( i == 0) {
// dati inizio entità
@@ -3896,15 +3941,15 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT
Point3d ptP1 ;
Vector3d vtDir1 ;
double dCalcStElev = dStElev ;
if ( ! CalcLeadInStart( ptStart, vtStart, vtTool, dCalcStElev, bInvert, pCompo, ptP1, vtDir1))
if ( ! CalcLeadInStart( ptStart, vtStart, vtTool, dCalcStElev, bInvert, pMyCompo, ptP1, vtDir1))
return false ;
// determino se l'inizio dell'attacco è fuori dal grezzo
Vector3d vtCorr = CalcCorrDir( pCompo, ( bInvert ? nMaxInd - i + 1 : i)) ;
Vector3d vtCorr = CalcCorrDir( pMyCompo, i, bInvert) ;
bool bOutStart = GetPointOutOfRaw( ptP1, vtTool, vtCorr, dElev, dSafeZ) ;
// determino se l'inizio dell'attacco è sopra il grezzo
bool bAboveStart = m_bAboveHead && GetPointAboveRaw( ptP1, vtTool) ;
// imposto versore correzione e ausiliario sul punto di partenza
CalcAndSetCorrAuxDir( pCompo, ( bInvert ? nMaxInd - i + 1 : i)) ;
CalcAndSetCorrAuxDir( pMyCompo, i, bInvert) ;
// se primo step
if ( j == 1) {
// verifico di entrare in aria
@@ -3927,23 +3972,23 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT
// aggiungo attacco
bool bTang = (( ! bInvert && m_Params.m_dLiTang > EPS_SMALL) || ( bInvert && m_Params.m_dLoTang > EPS_SMALL)) ;
SetFeed( bTang ? GetStartFeed() : GetTipFeed()) ;
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtTool, dCalcStElev, bInvert, pCompo, bSplitArcs)) {
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtTool, dCalcStElev, bInvert, pMyCompo, bSplitArcs)) {
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
return false ;
}
}
// imposto versore correzione e ausiliario sul punto di arrivo
CalcAndSetCorrAuxDir( pCompo, ( bInvert ? nMaxInd - i : i + 1)) ;
CalcAndSetCorrAuxDir( pMyCompo, i + 1, bInvert) ;
// elaborazioni sulla curva corrente
if ( pCurve->GetType() == CRV_LINE) {
ICurveLine* pLine = GetCurveLine( pCurve) ;
const ICurveLine* pLine = GetCurveLine( pCurve) ;
Point3d ptP3 = pLine->GetEnd() ;
SetFeed( GetFeed()) ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
}
else if ( pCurve->GetType() == CRV_ARC) {
ICurveArc* pArc = GetCurveArc( pCurve) ;
const ICurveArc* pArc = GetCurveArc( pCurve) ;
Point3d ptCen = pArc->GetCenter() ;
double dAngCen = pArc->GetAngCenter() ;
Vector3d vtN = pArc->GetNormVersor() ;
@@ -3974,8 +4019,202 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT
// aggiungo uscita
Point3d ptP1 ;
Vector3d vtDir1 ;
SetFlag( 301, false) ;
SetFeed( GetEndFeed()) ;
if ( ! AddLeadOut( ptEnd, vtEnd, vtTool, dEndElev, bInvert, pCompo, bSplitArcs, ptP1, vtDir1)) {
if ( ! AddLeadOut( ptEnd, vtEnd, vtTool, dEndElev, bInvert, pMyCompo, bSplitArcs, ptP1, vtDir1)) {
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
return false ;
}
// per lame retrazione non è necessaria
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Milling::AddSawOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs)
{
// 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 ;
// flag di percorso chiuso
bool bClosed = pCompo->IsClosed() ;
// recupero eventuale superficie trimesh chiusa per trim/extend
int nTriExtCstm = GDB_ID_NULL ;
int nTesId ;
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "TrimExt="), nTesId)) {
const ISurfTriMesh* pTes = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nTesId)) ;
if ( pTes != nullptr && pTes->IsClosed())
nTriExtCstm = nTesId ;
}
// determino numero e affondamento degli step
int nStep = max( 1, static_cast<int>( ceil( dElev / dOkStep))) ;
double dStep = dElev / nStep ;
// gestione parametri di attacco/uscita (con backup per ripristino all'uscita)
LeadIOStatus LioStatus( this) ;
bool bAdjustLiPerp = ( m_Params.m_dLiPerp > 10 * EPS_SMALL) ;
if ( bAdjustLiPerp) {
double dNewLiPerp = max( 0., m_Params.m_dLiPerp - ( nStep - 1) * dStep) ;
m_Params.m_dLiTang *= dNewLiPerp / m_Params.m_dLiPerp ;
m_Params.m_dLiPerp = dNewLiPerp ;
}
bool bAdjustLoPerp = ( m_Params.m_dLoPerp > 10 * EPS_SMALL) ;
if ( bAdjustLoPerp) {
m_Params.m_dLoTang = 0 ;
m_Params.m_dLoPerp = 0. ;
}
// ciclo su step più ritorni (quelli pari sono i ritorni)
for ( int k = 1 ; k <= 2 * nStep - 1 ; ++ k) {
// indice step
int j = ( k + 1) / 2 ;
// flag ritorno
bool bReturn = ( ( k % 2) == 0) ;
// copio la curva
PtrOwner<ICurveComposite> pMyCompo( pCompo->Clone()) ;
if ( IsNull( pMyCompo))
return false ;
// eseguo offset ed eventuale inversione per ritorno
double dDelta = ( bReturn ? min( dStep, 5.) : 0) ;
double dSignOffs = ( dElev - j * dStep + dDelta) * ( m_Params.m_nWorkSide == MILL_WS_LEFT ? - 1 : 1) ;
if ( ! CalcOffset( pMyCompo, dSignOffs))
return false ;
if ( bReturn)
pMyCompo->Invert() ;
// eventuale trim/extend con la superficie indicata
if ( nTriExtCstm != GDB_ID_NULL) {
// trim con ripristino dell'originale in caso di errore
PtrOwner<ICurveComposite> pMyCopy( pMyCompo->Clone()) ;
if ( ! TrimExtendCurveToClosedStm( pMyCompo, nTriExtCstm, bReturn))
pMyCompo.Set( pMyCopy) ;
}
// dopo primo step annullo parametro di attacco
if ( k > 1 && bAdjustLiPerp) {
m_Params.m_dLiPerp = 0. ;
m_Params.m_dLiTang = 0. ;
}
// ciclo sulle curve elementari
int nMaxInd = pMyCompo->GetCurveCount() - 1 ;
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
// curva corrente
const ICurve* pCurve = pMyCompo->GetCurve( i) ;
// se prima entità, se primo step approccio e sempre affondo
if ( i == 0) {
// dati inizio entità
Point3d ptStart ;
pCurve->GetStartPoint( ptStart) ;
Vector3d vtStart ;
pCurve->GetStartDir( vtStart) ;
// determino elevazione su inizio attacco
double dStElev ;
if ( k == 1) {
if ( ! GetElevation( m_nPhase, ptStart, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
}
else
dStElev = dStep - LIO_ELEV_TOL - 10 * EPS_SMALL ;
// determino inizio attacco
Point3d ptP1 ;
Vector3d vtDir1 ;
double dCalcStElev = dStElev ;
if ( ! CalcLeadInStart( ptStart, vtStart, vtTool, dCalcStElev, bReturn, pMyCompo, ptP1, vtDir1))
return false ;
// determino se l'inizio dell'attacco è fuori dal grezzo
Vector3d vtCorr = CalcCorrDir( pMyCompo, i, bReturn) ;
bool bOutStart = GetPointOutOfRaw( ptP1, vtTool, vtCorr, dElev, dSafeZ) ;
// determino se l'inizio dell'attacco è sopra il grezzo
bool bAboveStart = m_bAboveHead && GetPointAboveRaw( ptP1, vtTool) ;
// imposto versore correzione e ausiliario sul punto di partenza
CalcAndSetCorrAuxDir( pMyCompo, i, bReturn) ;
// se primo step
if ( k == 1) {
// verifico di entrare in aria
if ( ! bOutStart) {
m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ;
return false ;
}
// eseguo affondo
SetFlag( 0) ;
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
return false ;
}
// altrimenti, affondo ( o retrazione se Return) in feed opportuna
else {
bool bStartFeed = ( bOutStart || m_TParams.m_nType == TT_MILL_NOTIP || m_TParams.m_nType == TT_MILL_POLISHING) ;
SetFeed( bReturn ? GetEndFeed() : ( bStartFeed ? GetStartFeed() : GetTipFeed())) ;
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
return false ;
}
// aggiungo attacco
bool bTang = (( ! bReturn && m_Params.m_dLiTang > EPS_SMALL) || ( bReturn && m_Params.m_dLoTang > EPS_SMALL)) ;
SetFeed( bReturn ? GetEndFeed() : ( bTang ? GetStartFeed() : GetTipFeed())) ;
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtTool, dCalcStElev, bReturn, pMyCompo, bSplitArcs)) {
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
return false ;
}
}
// imposto versore correzione e ausiliario sul punto di arrivo
CalcAndSetCorrAuxDir( pMyCompo, i + 1, bReturn) ;
// se Retrazione e ultima entità, dichiaro fine passata
if ( bReturn && i == nMaxInd)
SetFlag( 301) ;
// elaborazioni sulla curva corrente
if ( pCurve->GetType() == CRV_LINE) {
const ICurveLine* pLine = GetCurveLine( pCurve) ;
Point3d ptP3 = pLine->GetEnd() ;
SetFeed( bReturn ? GetEndFeed() : GetFeed()) ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL) {
SetFlag( 0) ;
return false ;
}
}
else if ( pCurve->GetType() == CRV_ARC) {
const ICurveArc* pArc = GetCurveArc( pCurve) ;
Point3d ptCen = pArc->GetCenter() ;
double dAngCen = pArc->GetAngCenter() ;
Vector3d vtN = pArc->GetNormVersor() ;
Point3d ptP3 ;
pArc->GetEndPoint( ptP3) ;
SetFeed( bReturn ? GetEndFeed() : GetFeed()) ;
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL) {
SetFlag( 0) ;
return false ;
}
}
SetFlag( 0) ;
// se ultima entità, uscita e se ultimo step retrazione
if ( i == nMaxInd) {
// se ultima passata, ripristino parametri originali di attacco/uscita
if ( j == nStep)
LioStatus.Restore() ;
// dati fine entità
Point3d ptEnd ;
pCurve->GetEndPoint( ptEnd) ;
Vector3d vtEnd ;
pCurve->GetEndDir( vtEnd) ;
// elevazione sul punto finale
double dEndElev ;
if ( j == nStep) {
if ( ! GetElevation( m_nPhase, ptEnd, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
dEndElev = dElev ;
}
else
dEndElev = - LIO_ELEV_TOL ;
// aggiungo uscita
Point3d ptP1 ;
Vector3d vtDir1 ;
SetFeed( GetEndFeed()) ;
if ( ! bReturn)
SetFlag( 301, false) ;
if ( ! AddLeadOut( ptEnd, vtEnd, vtTool, dEndElev, bReturn, pMyCompo, bSplitArcs, ptP1, vtDir1)) {
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
return false ;
}
@@ -4311,7 +4550,7 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const
if ( bInvert) {
// va aggiustato se non zigzag o spirale
if ( nType != MILL_LI_ZIGZAG && nType != MILL_LI_HELIX) {
switch ( m_Params.m_nLeadOutType) {
switch ( GetLeadOutType()) {
case MILL_LO_LINEAR : nType = MILL_LI_LINEAR ; break ;
case MILL_LO_PERP_TG : nType = MILL_LI_TG_PERP ; break ;
case MILL_LO_TANGENT : nType = MILL_LI_TANGENT ; break ;
@@ -5952,7 +6191,7 @@ Milling::GetPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool) const
//----------------------------------------------------------------------------
bool
Milling::CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU)
Milling::CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU, bool bInvertSide)
{
// verifico curva
if ( pCompo == nullptr)
@@ -5961,7 +6200,7 @@ Milling::CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU)
if ( m_Params.m_nWorkSide == MILL_WS_CENTER)
return true ;
// calcolo del versore correzione
Vector3d vtCorr = CalcCorrDir( pCompo, dU) ;
Vector3d vtCorr = CalcCorrDir( pCompo, dU, bInvertSide) ;
// imposto versore correzione
SetCorrDir( vtCorr) ;
// se rinvio da sotto in uso, non devo impostare direzione aux da correzione
@@ -5981,7 +6220,7 @@ Milling::CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU)
//----------------------------------------------------------------------------
Vector3d
Milling::CalcCorrDir( const ICurveComposite* pCompo, double dU)
Milling::CalcCorrDir( const ICurveComposite* pCompo, double dU, bool bInvertSide)
{
// verifico curva
if ( pCompo == nullptr)
@@ -5990,7 +6229,7 @@ Milling::CalcCorrDir( const ICurveComposite* pCompo, double dU)
if ( m_Params.m_nWorkSide == MILL_WS_CENTER)
return V_NULL ;
// angolo di rotazione da tg a versore corr/aux
bool bCcwRot = (m_Params.m_nWorkSide == MILL_WS_LEFT) ;
bool bCcwRot = (( m_Params.m_nWorkSide == MILL_WS_LEFT) != bInvertSide) ;
double dCaRot = ( bCcwRot ? ANG_RIGHT : -ANG_RIGHT) ;
// dominio parametrico della curva
double dUs, dUe ;
@@ -6078,3 +6317,63 @@ Milling::CalcOffset( ICurveComposite* pCompo, double dSignOffs)
}
return false ;
}
//----------------------------------------------------------------------------
bool
Milling::TrimExtendCurveToClosedStm( ICurveComposite* pCompo, int nCstmId, bool bInvert)
{
// dati preparatori
const ISurfTriMesh* pCstm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nCstmId)) ;
if ( pCstm == nullptr || ! pCstm->IsClosed())
return false ;
Frame3d frCstm ;
if ( ! m_pGeomDB->GetGlobFrame( nCstmId, frCstm))
return false ;
BBox3d b3Tes = pCstm->GetAllTriaBox() ;
if ( b3Tes.IsEmpty())
return false ;
double dTriExtLen ;
b3Tes.GetDiameter( dTriExtLen) ;
// inverto offset su centro utensile
double dCompOffs = 0.5 * m_TParams.m_dDiam * ( ( m_Params.m_nWorkSide == MILL_WS_RIGHT) != bInvert ? 1 : -1) ;
if ( ! CalcOffset( pCompo, -dCompOffs))
return false ;
// porto la curva nel riferimento della superficie
pCompo->ToLoc( frCstm) ;
// allungo la curva in testa e coda per essere sicuro che gli estremi siano esterni
if ( ! pCompo->AddLineTg( dTriExtLen, false) || ! pCompo->AddLineTg( dTriExtLen, true))
return false ;
// calcolo intersezioni con superficie chiusa
INTDBLVECTOR vInters ;
if ( ! IntersCurveSurfTmExt( *pCompo, *pCstm, 10 * EPS_SMALL, vInters))
return false ;
// prendo prima intersezione entrante e ultima uscente
double dParStart = -1 ;
for ( int i = 0 ; i < int( vInters.size()) ; ++ i) {
if ( vInters[i].first == CSIT_OUT_IN || vInters[i].first == CSIT_ON_IN) {
dParStart = vInters[i].second ;
break ;
}
}
double dParEnd = -1 ;
for ( int i = int( vInters.size()) - 1 ; i >= 0 ; -- i) {
if ( vInters[i].first == CSIT_IN_OUT || vInters[i].first == CSIT_IN_ON) {
dParEnd = vInters[i].second ;
break ;
}
}
// eseguo trim ed unisco le eventuali parti allineate
if ( ! pCompo->TrimStartEndAtParam( dParStart, dParEnd) ||
! pCompo->MergeCurves(10 * EPS_SMALL, 10 * EPS_ANG_SMALL))
return false ;
// riporto la curva in globale
pCompo->ToGlob( frCstm) ;
// ritorno in centro utensile
if ( ! CalcOffset(pCompo, dCompOffs))
return false ;
return true ;
}
+5 -2
View File
@@ -96,6 +96,8 @@ class Milling : public Machining
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool AddSawOneWayMilling( 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,
double dElev, double dAppr, bool bOutStart, bool bAboveStart) ;
bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, const Vector3d& vtTool,
@@ -123,9 +125,10 @@ class Milling : public Machining
double GetRadiusForStartEndElevation( bool bExtra = true) const ;
bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, double dSafeZ) const ;
bool GetPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool) const ;
bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU) ;
Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU) ;
bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU, bool bInvertSide = false) ;
Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU, bool bInvertSide = false) ;
bool CalcOffset( ICurveComposite* pCompo, double dSignOffs) ;
bool TrimExtendCurveToClosedStm( ICurveComposite* pCompo, int nCstmId, bool bInvert) ;
private :
double GetSpeed() const
+2 -2
View File
@@ -135,8 +135,8 @@ Operation::Init( MachMgr* pMchMgr)
//----------------------------------------------------------------------------
Operation::Operation( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_pMchMgr( nullptr), m_nPhase( 1),
m_nPathId( GDB_ID_NULL), m_bCurr( false), m_ptCurr(),
m_vtTool(), m_vtCorr(), m_vtAux(), m_dFeed( 0), m_nFlag( 0), m_nFlag2( 0), m_nIndex( 0)
m_nPathId( GDB_ID_NULL), m_bCurr( false), m_ptCurr(), m_vtTool(), m_vtCorr(), m_vtAux(),
m_dFeed( 0), m_nFlag( 0), m_bFlagModal( true), m_nFlag2( 0), m_bFlag2Modal( true), m_nIndex( 0)
{
}
+12 -2
View File
@@ -186,8 +186,8 @@ class Operation : public IUserObj
bool SetAuxDir( const Vector3d& vtDir) ;
bool SetCorrAuxDir( const Vector3d& vtDir) ;
bool SetFeed( double dFeed) ;
bool SetFlag( int nFlag) ;
bool SetFlag2( int nFlag2) ;
bool SetFlag( int nFlag, bool bModal = true) ;
bool SetFlag2( int nFlag2, bool bModal = true) ;
bool SetIndex( int nIndex) ;
bool GetCurrPos( Point3d& ptCurr) const
{ if ( ! m_bCurr) return false ; ptCurr = m_ptCurr ; return true ; }
@@ -218,8 +218,18 @@ class Operation : public IUserObj
Vector3d m_vtAux ; // direzione ausiliaria corrente
double m_dFeed ; // feed corrente
int m_nFlag ; // flag corrente
bool m_bFlagModal ; // valore persistente del flag
int m_nFlag2 ; // secondo flag corrente
bool m_bFlag2Modal ; // valore persistente del flag2
int m_nIndex ; // indice corrente
private :
int UseFlag( void)
{ if ( m_bFlagModal) return m_nFlag ;
int nTemp = m_nFlag ; m_nFlag = 0 ; m_bFlagModal = true ; return nTemp ; }
int UseFlag2( void)
{ if ( m_bFlag2Modal) return m_nFlag2 ;
int nTemp = m_nFlag2 ; m_nFlag2 = 0 ; m_bFlag2Modal = true ; return nTemp ; }
} ;
//----------------------------------------------------------------------------
+14 -10
View File
@@ -76,17 +76,19 @@ Operation::SetFeed( double dFeed)
//----------------------------------------------------------------------------
bool
Operation::SetFlag( int nFlag)
Operation::SetFlag( int nFlag, bool bModal)
{
m_nFlag = nFlag ;
m_bFlagModal = bModal ;
return true ;
}
//----------------------------------------------------------------------------
bool
Operation::SetFlag2( int nFlag2)
Operation::SetFlag2( int nFlag2, bool bModal)
{
m_nFlag2 = nFlag2 ;
m_bFlag2Modal = bModal ;
return true ;
}
@@ -128,8 +130,8 @@ Operation::AddRapidStart( const Point3d& ptP)
pCam->SetAuxDir( m_vtAux) ;
pCam->SetEndPoint( ptP) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( m_nFlag) ;
pCam->SetFlag2( m_nFlag2) ;
pCam->SetFlag( UseFlag()) ;
pCam->SetFlag2( UseFlag2()) ;
pCam->SetIndex( m_nIndex) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
@@ -180,8 +182,8 @@ Operation::AddRapidMove( const Point3d& ptP)
pCam->SetAuxDir( m_vtAux) ;
pCam->SetEndPoint( ptP) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( m_nFlag) ;
pCam->SetFlag2( m_nFlag2) ;
pCam->SetFlag( UseFlag()) ;
pCam->SetFlag2( UseFlag2()) ;
pCam->SetIndex( m_nIndex) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
@@ -238,8 +240,8 @@ Operation::AddLinearMove( const Point3d& ptP)
pCam->SetAuxDir( m_vtAux) ;
pCam->SetEndPoint( ptP) ;
pCam->SetFeed( m_dFeed) ;
pCam->SetFlag( m_nFlag) ;
pCam->SetFlag2( m_nFlag2) ;
pCam->SetFlag( UseFlag()) ;
pCam->SetFlag2( UseFlag2()) ;
pCam->SetIndex( m_nIndex) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
@@ -312,8 +314,8 @@ Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen,
pCam->SetDeltaN( dDeltaZ) ;
pCam->SetNormDir( vtMyN) ;
pCam->SetFeed( m_dFeed) ;
pCam->SetFlag( m_nFlag) ;
pCam->SetFlag2( m_nFlag2) ;
pCam->SetFlag( UseFlag()) ;
pCam->SetFlag2( UseFlag2()) ;
pCam->SetIndex( m_nIndex) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
@@ -424,7 +426,9 @@ Operation::ResetMoveData( void)
m_vtAux = V_NULL ;
m_dFeed = 0 ;
m_nFlag = 0 ;
m_bFlagModal = true ;
m_nFlag2 = 0 ;
m_bFlag2Modal = true ;
m_nIndex = 0 ;
return true ;
}