EgtMachKernel :
- LeadIn/LeadOut.
This commit is contained in:
+281
-92
@@ -34,6 +34,8 @@
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
// per far dimenticare macro di WinUser.h
|
||||
#undef GetClassName
|
||||
|
||||
@@ -98,6 +100,7 @@ SurfRoughing::Clone( void) const
|
||||
pSrR->m_dTHoldDiam = m_dTHoldDiam ;
|
||||
pSrR->m_nStatus = m_nStatus ;
|
||||
pSrR->m_nPaths = m_nPaths ;
|
||||
pSrR->m_dMaxHelixRad = m_dMaxHelixRad ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pSrR ;
|
||||
@@ -214,6 +217,7 @@ SurfRoughing::SurfRoughing( void)
|
||||
m_dTHoldDiam = 0 ;
|
||||
m_nStatus = MCH_ST_TO_VERIFY ;
|
||||
m_nPaths = 0 ;
|
||||
m_dMaxHelixRad = INFINITO ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1209,7 +1213,7 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
PtrOwner<ISurfFlatRegion> pSfr( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr) || ! pSfr->AddExtLoop( *pCompo)) {
|
||||
m_pMchMgr->SetLastError( 3024, "Error in SurfRoughing : region not computable") ;
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
pSfr->Translate( -i * dStep * vtTool) ;
|
||||
// piano di taglio per silhouette (compreso di offset longitudinale)
|
||||
@@ -1334,15 +1338,32 @@ SurfRoughing::AddPocket( const INTVECTOR& vPocket, const Vector3d& vtTool, const
|
||||
// ciclo sulle regioni
|
||||
bool bStart = true ;
|
||||
for ( int nPockId : vPocket) {
|
||||
|
||||
// calcolo la svuotatura
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( m_pGeomDB->GetGeoObj( nPockId)) ;
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
if ( ! CalcPocketing( pSfr, m_TParams.m_dDiam / 2, GetOffsR(), m_Params.m_dSideStep, m_Params.m_dSideAngle,
|
||||
m_Params.m_nSubType, true, vpCrvs))
|
||||
return false ;
|
||||
|
||||
// salvo i loop esterni della superficie corrente come Polylinee ( per LeadIn/LeadOut)
|
||||
POLYLINEVECTOR vPLExtLoops ; vPLExtLoops.resize( pSfr->GetChunkCount()) ;
|
||||
for ( int c = 0 ; c < int( vPLExtLoops.size()) ; ++ c) {
|
||||
PtrOwner<ICurveComposite> pCrvExtLoop( ConvertCurveToComposite( pSfr->GetLoop( c, 0))) ;
|
||||
if ( IsNull( pCrvExtLoop) ||
|
||||
! pCrvExtLoop->ApproxWithLines( LIN_TOL_MID, ANG_TOL_STD_DEG, ICurve::APL_RIGHT, vPLExtLoops[c]))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// ciclo sui percorsi
|
||||
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
|
||||
// ciclo sulle curve elementari
|
||||
// controllo se il percorso ha un ingresso presso un lato aperto
|
||||
bool bOutStart = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetCurve( 0)->GetTempProp( 0) == 2) ;
|
||||
// inizializzo la curva di Ritorno per LeadIn/LeadOut
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pRCrv))
|
||||
return false ;
|
||||
// ciclo sulle curve elementari
|
||||
int nMaxInd = vpCrvs[k]->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -1352,21 +1373,35 @@ SurfRoughing::AddPocket( const INTVECTOR& vPocket, const Vector3d& vtTool, const
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// se prima entità
|
||||
if ( i == 0 ) {
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// calcolo la curva pRCrv associata
|
||||
Point3d ptUp = ptStart ;
|
||||
if ( bOutStart)
|
||||
pCurve->GetEndPoint( ptUp) ;
|
||||
if ( m_Params.m_nSubType == SURFROU_SUB_SPIRALIN)
|
||||
if ( ! CalcRetCrv( vpCrvs[k], ptUp, bOutStart, pRCrv))
|
||||
return false ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, pRCrv, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
GetLeadInType() == POCKET_LI_HELIX ||
|
||||
GetLeadInType() == POCKET_LI_GLIDE) {
|
||||
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
|
||||
dStElev = - LIO_ELEV_TOL ;
|
||||
}
|
||||
// se inizio, approccio globale al punto iniziale
|
||||
if ( bStart) {
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) {
|
||||
@@ -1384,7 +1419,22 @@ SurfRoughing::AddPocket( const INTVECTOR& vPocket, const Vector3d& vtTool, const
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
// controllo in quale chunk della pSfr si trova il mio percorso
|
||||
int nInd = 0 ;
|
||||
for ( nInd = 0 ; nInd < int( vPLExtLoops.size()) ; ++ nInd) {
|
||||
// prendo il punto finale della prima curva, così sono interno alla regione
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
if ( IsPointInsidePolyLine( ptEnd, vPLExtLoops[nInd], 500 * EPS_SMALL))
|
||||
break ;
|
||||
}
|
||||
PtrOwner<ICurveComposite> pCompo( ConvertCurveToComposite( pSfr->GetLoop( nInd, 0))) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pCompo,
|
||||
( ( m_Params.m_nSubType == SURFROU_SUB_SPIRALIN || m_Params.m_nSubType == SURFROU_SUB_SPIRALOUT)) ? Get( pRCrv) : nullptr,
|
||||
( m_Params.m_nSubType == SURFROU_SUB_SPIRALOUT) ? m_Params.m_bInvert : ! m_Params.m_bInvert,
|
||||
bSplitArcs, bOutStart, false)) {
|
||||
m_pMchMgr->SetLastError( 3013, "Error in SurfRoughing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1423,7 +1473,9 @@ SurfRoughing::AddPocket( const INTVECTOR& vPocket, const Vector3d& vtTool, const
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1, bSplitArcs)) {
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr,
|
||||
( ( m_Params.m_nSubType == SURFROU_SUB_SPIRALIN || m_Params.m_nSubType == SURFROU_SUB_SPIRALOUT)) ? Get( pRCrv) : nullptr,
|
||||
bSplitArcs, false, ptP1, dEndElev)) {
|
||||
m_pMchMgr->SetLastError( 3014, "Error in SurfRoughing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1566,36 +1618,31 @@ SurfRoughing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSa
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfRoughing::GetLeadInType( void) const
|
||||
{
|
||||
if ( abs( m_Params.m_dLiTang) < min( 0.1 * m_TParams.m_dDiam, 0.1) &&
|
||||
abs( m_Params.m_dLiPerp) < min( 0.1 * m_TParams.m_dDiam, 0.1))
|
||||
return SURFFIN_LI_NONE ;
|
||||
return m_Params.m_nLeadInType ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, Point3d& ptP1) const
|
||||
SurfRoughing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool,
|
||||
const ICurveComposite* pRCrv, Point3d& ptP1) const
|
||||
{
|
||||
// Assegno il tipo
|
||||
// Assegno tipo e parametri
|
||||
int nType = GetLeadInType() ;
|
||||
double dTang = m_Params.m_dLiTang ;
|
||||
double dPerp = m_Params.m_dLiPerp ;
|
||||
if ( nType == SURFROU_LI_GLIDE && ( pRCrv == nullptr || pRCrv->GetCurveCount() == 0))
|
||||
nType = SURFROU_LI_NONE ;
|
||||
// Calcolo punto iniziale
|
||||
switch ( nType) {
|
||||
case SURFFIN_LI_NONE :
|
||||
case SURFROU_LI_NONE :
|
||||
case SURFROU_LI_ZIGZAG :
|
||||
case SURFROU_LI_HELIX :
|
||||
ptP1 = ptStart ;
|
||||
return true ;
|
||||
case SURFFIN_LI_LINEAR :
|
||||
case SURFFIN_LI_TANGENT :
|
||||
case SURFROU_LI_GLIDE :
|
||||
{
|
||||
Vector3d vtPerp = vtStart ;
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtStart) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptStart - vtStart * dTang + vtPerp * dPerp ;
|
||||
double dLen, dU ;
|
||||
if ( ! pRCrv->GetLength( dLen) || ! pRCrv->GetParamAtLength( dLen - m_Params.m_dLiTang, dU) ||
|
||||
! pRCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP1)) {
|
||||
if ( ! pRCrv->GetStartPoint( ptP1))
|
||||
return false ;
|
||||
}
|
||||
ptP1 += vtTool * ( vtTool * ( ptStart - ptP1)) ;
|
||||
return true ;
|
||||
}
|
||||
default :
|
||||
@@ -1605,91 +1652,166 @@ SurfRoughing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs)
|
||||
SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||
const ICurveComposite* pCompo, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
|
||||
bool bNoneForced, bool bSkipControl)
|
||||
{
|
||||
// Assegno il tipo
|
||||
int nType = GetLeadInType() ;
|
||||
// Eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case SURFFIN_LI_NONE :
|
||||
return true ;
|
||||
case SURFFIN_LI_LINEAR :
|
||||
return ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
case SURFFIN_LI_TANGENT :
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptStart, ptP1, -vtStart, vtTool)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
pCrv->Invert() ;
|
||||
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
if ( bNoneForced ||
|
||||
AreSamePointEpsilon( ptP1, ptStart, 10 * EPS_SMALL) ||
|
||||
( nType == SURFROU_LI_GLIDE && ( pRCrv == nullptr || pRCrv->GetCurveCount() == 0)))
|
||||
nType = SURFROU_LI_NONE ;
|
||||
// Se elica e fattibile lo creo
|
||||
if ( nType == SURFROU_LI_HELIX) {
|
||||
// vettore dal punto al centro elica
|
||||
Vector3d vtCen = vtStart ;
|
||||
vtCen.Rotate( vtN, 0, ( bAtLeft ? 1 : - 1)) ;
|
||||
// dati dell'elica
|
||||
double dRad = min( 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam), m_dMaxHelixRad) ;
|
||||
Point3d ptCen = ptP1 + vtCen * dRad ;
|
||||
double dDeltaN = ( ptStart - ptP1) * vtN ;
|
||||
double dAngCen = ceil( - dDeltaN / ( m_Params.m_dLiElev + 20 * EPS_SMALL)) * ( bAtLeft ? ANG_FULL : - ANG_FULL) ;
|
||||
// verifico se fattibile
|
||||
if ( bSkipControl || VerifyLeadInHelix( pCompo, ptCen, dRad)) {
|
||||
// creo l'elica
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->Set( ptCen, vtN, dRad, - vtCen, dAngCen, dDeltaN))
|
||||
return false ;
|
||||
// emetto l'elica (con eventuale spezzatura)
|
||||
return ( AddCurveMove( pArc, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
// altrimenti zigzag
|
||||
else
|
||||
nType = SURFROU_LI_ZIGZAG ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
SurfRoughing::GetLeadOutType( void) const
|
||||
{
|
||||
if ( abs( m_Params.m_dLoTang) < min( 0.1 * m_TParams.m_dDiam, 0.1) &&
|
||||
abs( m_Params.m_dLoPerp) < min( 0.1 * m_TParams.m_dDiam, 0.1) &&
|
||||
m_Params.m_nLeadOutType != SURFFIN_LO_AS_LI)
|
||||
return SURFFIN_LO_NONE ;
|
||||
return m_Params.m_nLeadOutType ;
|
||||
// Se zigzag e fattibile lo creo
|
||||
if ( nType == SURFROU_LI_ZIGZAG) {
|
||||
// dati dello zigzag
|
||||
double dDeltaN = ( ptStart - ptP1) * vtN ;
|
||||
int nStep = int( ceil( - dDeltaN / ( m_Params.m_dLiElev + 20 * EPS_SMALL))) ;
|
||||
double dStep = - dDeltaN / nStep ;
|
||||
Point3d ptPa = ptP1 + vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
Point3d ptPb = ptP1 - vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
// verifico se fattibile
|
||||
if ( bSkipControl || VerifyLeadInZigZag( pCompo, ptPa, ptPb)) {
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
if ( AddLinearMove( ptPa - vtN * ( i - 0.75) * dStep, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( AddLinearMove( ptPb - vtN * ( i - 0.25) * dStep, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
// altrimenti diretto
|
||||
else {
|
||||
nType = SURFROU_LI_NONE ;
|
||||
if ( m_TParams.m_nType == TT_MILL_NOTIP)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// Se a scivolo e fattibile
|
||||
if ( nType == SURFROU_LI_GLIDE) {
|
||||
if ( pRCrv != nullptr) {
|
||||
// recupero la parte richiesta della curva di ritorno
|
||||
PtrOwner<ICurveComposite> pCrv ;
|
||||
double dLen, dU ;
|
||||
if ( pRCrv->GetLength( dLen) && pRCrv->GetParamAtLength( dLen - m_Params.m_dLiTang, dU)) {
|
||||
double dParS, dParE ;
|
||||
pRCrv->GetDomain( dParS, dParE) ;
|
||||
if ( ! pCrv.Set( ConvertCurveToComposite( pRCrv->CopyParamRange( dU, dParE))))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! pCrv.Set( pRCrv->Clone()))
|
||||
return false ;
|
||||
}
|
||||
pCrv->SetExtrusion( vtN) ;
|
||||
// la porto alla giusta quota
|
||||
Point3d ptFin ; pCrv->GetEndPoint( ptFin) ;
|
||||
Vector3d vtMove = ptStart - ptFin ;
|
||||
pCrv->Translate( vtMove) ;
|
||||
// assegno la corretta pendenza
|
||||
double dNini = ( ptP1 - ORIG) * vtN ;
|
||||
double dNfin = ( ptStart - ORIG) * vtN ;
|
||||
AdjustCurveSlope( pCrv, dNini, dNfin) ;
|
||||
// emetto (con eventuale spezzatura)
|
||||
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
// altrimenti diretto
|
||||
else
|
||||
nType = SURFROU_LI_NONE ;
|
||||
}
|
||||
// Se diretto
|
||||
if ( nType == SURFROU_LI_NONE) {
|
||||
Point3d ptCurr = ptP1 ;
|
||||
GetCurrPos( ptCurr) ;
|
||||
if ( ! AreSamePointApprox( ptCurr, ptStart)) {
|
||||
if ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
// Altrimenti errore
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1, bool bSplitArcs)
|
||||
SurfRoughing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||
const ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced,
|
||||
Point3d& ptP1, double& dElev)
|
||||
{
|
||||
// assegno i parametri
|
||||
int nType = GetLeadOutType() ;
|
||||
double dTang = m_Params.m_dLoTang ;
|
||||
double dPerp = m_Params.m_dLoPerp ;
|
||||
// se uscita come ingresso
|
||||
if ( nType == SURFFIN_LO_AS_LI) {
|
||||
int nLiType = GetLeadInType() ;
|
||||
switch ( nLiType) {
|
||||
case SURFFIN_LI_LINEAR : nType = SURFFIN_LO_LINEAR ; break ;
|
||||
case SURFFIN_LI_TANGENT : nType = SURFFIN_LO_TANGENT ; break ;
|
||||
default : nType = SURFFIN_LO_NONE ; break ;
|
||||
}
|
||||
dTang = m_Params.m_dLiTang ;
|
||||
dPerp = m_Params.m_dLiPerp ;
|
||||
}
|
||||
if ( bNoneForced ||
|
||||
( nType == SURFROU_LO_GLIDE && ( pRCrv == nullptr || pRCrv->GetCurveCount() == 0)))
|
||||
nType = SURFROU_LO_NONE ;
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case SURFFIN_LO_NONE :
|
||||
ptP1 = ptEnd ;
|
||||
return true ;
|
||||
case SURFFIN_LO_LINEAR :
|
||||
case SURFROU_LO_NONE :
|
||||
{
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
// nessuna uscita
|
||||
ptP1 = ptEnd ;
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( GetElevation( m_nPhase, ptP1 - 10 * EPS_SMALL * vtN, vtN, GetRadiusForStartEndElevation(), vtN, dEndElev))
|
||||
dElev = dEndElev ;
|
||||
return true ;
|
||||
}
|
||||
case SURFFIN_LO_TANGENT :
|
||||
case SURFROU_LO_GLIDE :
|
||||
{
|
||||
// calcolo punto finale dell'uscita
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ;
|
||||
vtPerp.Rotate( vtRot, 0, -1) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
// inserisco uscita
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
// assegno direzione finale dell'uscita
|
||||
Vector3d vtDirF ;
|
||||
if ( ! pCrv->GetEndDir( vtDirF))
|
||||
return false ;
|
||||
// emetto movimento
|
||||
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
// recupero la parte richiesta della curva di ritorno
|
||||
PtrOwner<ICurveComposite> pCrv ;
|
||||
double dU ;
|
||||
if ( pRCrv->GetParamAtLength( m_Params.m_dLoTang, dU)) {
|
||||
if ( ! pCrv.Set( ConvertCurveToComposite( pRCrv->CopyParamRange( 0, dU))))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! pCrv.Set( pRCrv->Clone()))
|
||||
return false ;
|
||||
}
|
||||
// la porto alla giusta quota
|
||||
Point3d ptIni ; pCrv->GetStartPoint( ptIni) ;
|
||||
Vector3d vtMove = ptEnd - ptIni ;
|
||||
pCrv->Translate( vtMove) ;
|
||||
Point3d ptFin ; pCrv->GetEndPoint( ptFin) ;
|
||||
ptFin += vtN * 1.0 ;
|
||||
pCrv->ModifyEnd( ptFin) ;
|
||||
// emetto (con eventuale spezzatura)
|
||||
AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) ;
|
||||
// determino elevazione su fine uscita
|
||||
ptP1 = ptFin ;
|
||||
double dEndElev ;
|
||||
if ( GetElevation( m_nPhase, ptP1 - 10 * EPS_SMALL * vtN, vtN, GetRadiusForStartEndElevation(), vtN, dEndElev))
|
||||
dElev = dEndElev ;
|
||||
return true ;
|
||||
}
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1718,3 +1840,70 @@ SurfRoughing::GetRadiusForStartEndElevation( void) const
|
||||
double dDeltaRad = min( DELTA_ELEV_RAD, 0.5 * m_TParams.m_dTDiam) ;
|
||||
return ( 0.5 * m_TParams.m_dTDiam + dDeltaRad) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::CalcRetCrv( const ICurveComposite* pCompo, const Point3d& ptRef, bool bOutStart, ICurveComposite* pRCrv) const
|
||||
{
|
||||
// controllo i parametri
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
pRCrv->Clear() ;
|
||||
// cerco la sottocurva che ha come punto finale il punto ptStart
|
||||
for ( int u = ( bOutStart ? 1 : 0) ; u < pCompo->GetCurveCount() ; ++ u) {
|
||||
// recupero la sottocurva
|
||||
const ICurve* pCrv = pCompo->GetCurve( u) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// la aggiungo al percorso
|
||||
if ( ! pRCrv->AddCurve( *pCrv))
|
||||
return false ;
|
||||
// recupero il suo punto finale
|
||||
Point3d ptEnd ;
|
||||
if ( ! pCrv->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
// se coincide con ptStart, la sottocurva di interesse è trovata
|
||||
if ( AreSamePointApprox( ptRef, ptEnd))
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) const
|
||||
{
|
||||
// recupero il piano della curva di contorno
|
||||
Point3d ptStart ;
|
||||
Vector3d vtN ;
|
||||
if ( pCompo == nullptr || ! pCompo->GetStartPoint( ptStart) || ! pCompo->GetExtrusion( vtN))
|
||||
return false ;
|
||||
// porto il centro sullo stesso piano del contorno
|
||||
Point3d ptCenL = ptCen - ( ptCen - ptStart) * vtN * vtN ;
|
||||
// calcolo la distanza del centro dal contorno
|
||||
double dMinDist ;
|
||||
return ( DistPointCurve( ptCenL, *pCompo).GetDist( dMinDist) && dMinDist > dRad + 0.5 * m_TParams.m_dDiam - 10 * EPS_SMALL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) const
|
||||
{
|
||||
// recupero il piano della curva di contorno
|
||||
Point3d ptStart ;
|
||||
Vector3d vtN ;
|
||||
if ( pCompo == nullptr || ! pCompo->GetStartPoint( ptStart) || ! pCompo->GetExtrusion( vtN))
|
||||
return false ;
|
||||
// porto i punti sullo stesso piano del contorno
|
||||
Point3d ptPaL = ptPa - ( ptPa - ptStart) * vtN * vtN ;
|
||||
Point3d ptPbL = ptPb - ( ptPb - ptStart) * vtN * vtN ;
|
||||
// calcolo la distanza dei due punti dal contorno
|
||||
double dMinDistPa ;
|
||||
if ( ! DistPointCurve( ptPaL, *pCompo).GetDist( dMinDistPa))
|
||||
return false ;
|
||||
double dMinDistPb ;
|
||||
if ( ! DistPointCurve( ptPbL, *pCompo).GetDist( dMinDistPb))
|
||||
return false ;
|
||||
return ( dMinDistPa > 0.5 * m_TParams.m_dDiam - 10 * EPS_SMALL && dMinDistPb > 0.5 * m_TParams.m_dDiam - 10 * EPS_SMALL) ;
|
||||
}
|
||||
|
||||
+24
-7
@@ -36,7 +36,7 @@ class SurfRoughing : public Machining
|
||||
|
||||
public : // Operation
|
||||
int GetType( void) const override
|
||||
{ return OPER_SAWFINISHING ; }
|
||||
{ return OPER_SURFROUGHING ; }
|
||||
bool IsEmpty( void) const override
|
||||
{ return ( m_nPaths == 0) ; }
|
||||
bool UpdateStatus( int nModif) override
|
||||
@@ -79,12 +79,20 @@ class SurfRoughing : public Machining
|
||||
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, Point3d& ptP1) const ;
|
||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs) ;
|
||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, Point3d& ptP1, bool bSplitArcs) ;
|
||||
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, const ICurveComposite* pCrvPath, Point3d& ptP1) const ;
|
||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
|
||||
const Vector3d& vtN, const ICurveComposite* pCompo, const ICurveComposite* pRCrv,
|
||||
bool bAtLeft, bool bSplitArcs, bool bNoneForced, bool bSkipControl) ;
|
||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||
const ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced,
|
||||
Point3d& ptP1, double& dElev) ;
|
||||
bool GetActiveSurfaces( INTVECTOR& vSurfId) const ;
|
||||
double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ;
|
||||
double GetRadiusForStartEndElevation( void) const ;
|
||||
bool CalcRetCrv( const ICurveComposite* pCompo, const Point3d& ptRef, bool bOutStart,
|
||||
ICurveComposite* pRCrv) const ;
|
||||
bool VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) const ;
|
||||
bool VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) const ;
|
||||
|
||||
private :
|
||||
double GetSpeed() const
|
||||
@@ -103,8 +111,16 @@ class SurfRoughing : public Machining
|
||||
{ return ( IsUnknownValue( m_Params.m_dOffsL) ? m_TParams.m_dOffsL : m_Params.m_dOffsL) ; }
|
||||
double GetSideStep( void) const
|
||||
{ return Clamp( m_Params.m_dSideStep, 0.1, m_TParams.m_dTDiam) ; }
|
||||
int GetLeadInType( void) const ;
|
||||
int GetLeadOutType( void) const ;
|
||||
int GetLeadInType( void) const
|
||||
{ if ( m_Params.m_dLiTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
|
||||
return SURFROU_LI_NONE ;
|
||||
if ( m_Params.m_nLeadInType != SURFROU_LI_GLIDE && m_Params.m_dLiElev < 10 * EPS_SMALL)
|
||||
return SURFROU_LI_NONE ;
|
||||
return m_Params.m_nLeadInType ; }
|
||||
int GetLeadOutType( void) const
|
||||
{ if ( m_Params.m_dLoTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
|
||||
return SURFROU_LO_NONE ;
|
||||
return m_Params.m_nLeadOutType ; }
|
||||
|
||||
private :
|
||||
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
|
||||
@@ -115,4 +131,5 @@ class SurfRoughing : public Machining
|
||||
double m_dTHoldDiam ; // diametro del porta-utensile
|
||||
int m_nStatus ; // stato di aggiornamento della lavorazione
|
||||
int m_nPaths ; // numero di percorsi di lavoro generati
|
||||
} ;
|
||||
double m_dMaxHelixRad ; // raggio massimo attacco ad elica nel caso di cerchi
|
||||
} ;
|
||||
Reference in New Issue
Block a user