EgtMachKernel :
- in svuotature gestione SpiralIn e SpiralOut ottimizzate per cerchi - in svuotatura aggiunti attacchi zigzag e elica e uscita Glide - in contornatura miglioramenti vari.
This commit is contained in:
+319
-193
@@ -28,26 +28,30 @@
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//------------------------------ Errors --------------------------------------
|
||||
// 2501 = "Error in Pocketing : UpdateToolData failed"
|
||||
// 2502 = "Error in Pocketing : Open Contour"
|
||||
// 2503 = "Error in Pocketing : Contour Not Flat"
|
||||
// 2504 = "Error in Pocketing : Tool Dir not perpendicular to Flat Area"
|
||||
// 2505 = "Error in Pocketing : Empty RawBox"
|
||||
// 2506 = "Error in Pocketing : Depth not computable"
|
||||
// 2507 = "Error in Pocketing : machining depth (xxx) bigger than MaxMaterial (yyy)"
|
||||
// 2508 = "Error in Pocketing : Entity GetElevation"
|
||||
// 2509 = "Error in Pocketing : missing aggregate from bottom"
|
||||
// 2510 = "Error in Pocketing : path too far from part sides"
|
||||
// 2511 = "Error in Pocketing : toolpath allocation failed"
|
||||
// 2512 = "Error in Pocketing : Offset not computable"
|
||||
// 2513 = "Error in Pocketing : Toolpath not computable"
|
||||
// 2514 = "Error in Pocketing : LeadIn not computable"
|
||||
// 2515 = "Error in Pocketing : LeadOut not computable"
|
||||
// 2516 = "Error in Pocketing : Link not computable"
|
||||
// 2401 = "Error in Pocketing : UpdateToolData failed"
|
||||
// 2402 = "Error in Pocketing : Open Contour"
|
||||
// 2403 = "Error in Pocketing : Contour Not Flat"
|
||||
// 2404 = "Error in Pocketing : Tool Dir not perpendicular to Flat Area"
|
||||
// 2405 = "Error in Pocketing : Empty RawBox"
|
||||
// 2406 = "Error in Pocketing : Depth not computable"
|
||||
// 2407 = "Error in Pocketing : machining depth (xxx) bigger than MaxMaterial (yyy)"
|
||||
// 2408 = "Error in Pocketing : Entity GetElevation"
|
||||
// 2409 = "Error in Pocketing : missing aggregate from bottom"
|
||||
// 2410 = "Error in Pocketing : path too far from part sides"
|
||||
// 2411 = "Error in Pocketing : toolpath allocation failed"
|
||||
// 2412 = "Error in Pocketing : Offset not computable"
|
||||
// 2413 = "Error in Pocketing : Toolpath not computable"
|
||||
// 2414 = "Error in Pocketing : LeadIn not computable"
|
||||
// 2415 = "Error in Pocketing : LeadOut not computable"
|
||||
// 2416 = "Error in Pocketing : Link not computable"
|
||||
// 2417 = "Error in Pocketing : Linear Approx not computable"
|
||||
// 2418 = "Error in Pocketing : Return toolpath not computable"
|
||||
// 2419 = "Error in Pocketing : Chaining failed"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkPocketing", Pocketing) ;
|
||||
@@ -311,6 +315,9 @@ Pocketing::SetParam( int nType, double dVal)
|
||||
case MPA_LITANG :
|
||||
m_Params.m_dLiTang = dVal ;
|
||||
return true ;
|
||||
case MPA_LIELEV :
|
||||
m_Params.m_dLiElev = dVal ;
|
||||
return true ;
|
||||
case MPA_LOTANG :
|
||||
m_Params.m_dLoTang = dVal ;
|
||||
return true ;
|
||||
@@ -402,13 +409,15 @@ Pocketing::Preview( bool bRecalc)
|
||||
|
||||
// aggiorno dati geometrici dell'utensile
|
||||
if ( ! UpdateToolData()) {
|
||||
m_pMchMgr->SetLastError( 2501, "Error in Pocketing : UpdateToolData failed") ;
|
||||
m_pMchMgr->SetLastError( 2401, "Error in Pocketing : UpdateToolData failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId))
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2419, "Error in Pocketing : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero gruppo per geometria di Preview
|
||||
int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ;
|
||||
@@ -465,13 +474,15 @@ Pocketing::Apply( bool bRecalc)
|
||||
|
||||
// aggiorno dati geometrici dell'utensile
|
||||
if ( ! UpdateToolData()) {
|
||||
m_pMchMgr->SetLastError( 2501, "Error in Pocketing : UpdateToolData failed") ;
|
||||
m_pMchMgr->SetLastError( 2401, "Error in Pocketing : UpdateToolData failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId))
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2419, "Error in Pocketing : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
|
||||
@@ -593,6 +604,9 @@ Pocketing::GetParam( int nType, double& dVal) const
|
||||
case MPA_LITANG :
|
||||
dVal = m_Params.m_dLiTang ;
|
||||
return true ;
|
||||
case MPA_LIELEV :
|
||||
dVal = m_Params.m_dLiElev ;
|
||||
return true ;
|
||||
case MPA_LOTANG :
|
||||
dVal = m_Params.m_dLoTang ;
|
||||
return true ;
|
||||
@@ -927,6 +941,9 @@ Pocketing::Chain( int nGrpDestId)
|
||||
pCrvCompo->SetThickness( dThick) ;
|
||||
// aggiorno il nuovo punto vicino
|
||||
pCrvCompo->GetEndPoint( ptNear) ;
|
||||
// se utile, approssimo con archi
|
||||
if ( ! ApproxWithArcsIfUseful( pCrvCompo))
|
||||
return false ;
|
||||
// creo nuovo gruppo
|
||||
int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpDestId, Frame3d()) ;
|
||||
if ( nPathId == GDB_ID_NULL)
|
||||
@@ -976,7 +993,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
return false ;
|
||||
ICurve* pCrv = ::GetCurve( m_pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr || ! pCrv->IsClosed()) {
|
||||
m_pMchMgr->SetLastError( 2502, "Error in Pocketing : Open Contour") ;
|
||||
m_pMchMgr->SetLastError( 2402, "Error in Pocketing : Open Contour") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -995,11 +1012,11 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
// verifico sia piana e sistemo senso antiorario visto dalla direzione di estrusione
|
||||
Plane3d plPlane ; double dArea ;
|
||||
if ( ! pCompo->GetArea( plPlane, dArea)) {
|
||||
m_pMchMgr->SetLastError( 2503, "Error in Pocketing : Contour Not Flat") ;
|
||||
m_pMchMgr->SetLastError( 2403, "Error in Pocketing : Contour Not Flat") ;
|
||||
return false ;
|
||||
}
|
||||
if ( abs( plPlane.vtN * vtExtr) < cos( 10 * EPS_ANG_SMALL)){
|
||||
m_pMchMgr->SetLastError( 2504, "Error in Pocketing : Tool Dir not perpendicular to Flat Area") ;
|
||||
m_pMchMgr->SetLastError( 2404, "Error in Pocketing : Tool Dir not perpendicular to Flat Area") ;
|
||||
return false ;
|
||||
}
|
||||
if ( plPlane.vtN * vtExtr * dArea < 0)
|
||||
@@ -1016,7 +1033,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
// recupero il box del grezzo in globale
|
||||
BBox3d b3Raw ;
|
||||
if ( ! GetRawGlobBox( m_nPhase, nPathId, 0.5 * m_TParams.m_dDiam, b3Raw) || b3Raw.IsEmpty()) {
|
||||
m_pMchMgr->SetLastError( 2505, "Error in Pocketing : Empty RawBox") ;
|
||||
m_pMchMgr->SetLastError( 2405, "Error in Pocketing : Empty RawBox") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1033,7 +1050,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
double dDepth ;
|
||||
string sMyDepth = m_Params.m_sDepth ;
|
||||
if ( ! ExeLuaEvalNumExpr( ToUpper( sMyDepth), &dDepth)) {
|
||||
m_pMchMgr->SetLastError( 2506, "Error in Pocketing : Depth not computable") ;
|
||||
m_pMchMgr->SetLastError( 2406, "Error in Pocketing : Depth not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se spessore positivo, lo sottraggo dal risultato
|
||||
@@ -1046,37 +1063,6 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
string sPathName ;
|
||||
m_pGeomDB->GetName( nPathId, sPathName) ;
|
||||
|
||||
// eventuale approssimazione con segmenti di retta
|
||||
int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ;
|
||||
bool bSplitArcs = ( nSplitArcs == SPLAR_ALWAYS ||
|
||||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtExtr.IsZplus()) ||
|
||||
( nSplitArcs == SPLAR_GEN_PLANE && vtExtr.IsGeneric())) ;
|
||||
if ( bSplitArcs) {
|
||||
const double ANG_TOL_MAX_DEG = 90 ;
|
||||
PolyLine PL ;
|
||||
if ( pCompo->ApproxWithLines( 50 * EPS_SMALL, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL)) {
|
||||
// sostituisco le linee alle curve originali
|
||||
pCompo->Clear() ;
|
||||
pCompo->FromPolyLine( PL) ;
|
||||
// riassegno estrusione e spessore
|
||||
pCompo->SetExtrusion( vtExtr) ;
|
||||
pCompo->SetThickness( dThick) ;
|
||||
}
|
||||
}
|
||||
|
||||
// verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
int nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// se arco con angolo al centro oltre il limite, lo divido a metà
|
||||
const ICurveArc* pArc = GetCurveArc( pCompo->GetCurve( i)) ;
|
||||
if ( pArc != nullptr && abs( pArc->GetAngCenter()) > MAX_ANG_CEN) {
|
||||
pCompo->AddJoint( i + 0.5) ;
|
||||
++ i ;
|
||||
++ nMaxInd ;
|
||||
}
|
||||
}
|
||||
|
||||
// assegno il versore fresa
|
||||
Vector3d vtTool = vtExtr ;
|
||||
|
||||
@@ -1105,7 +1091,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
else {
|
||||
string sInfo = "Error in Pocketing : machining depth (" + ToString( dElev, 1) +
|
||||
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
|
||||
m_pMchMgr->SetLastError( 2507, sInfo) ;
|
||||
m_pMchMgr->SetLastError( 2407, sInfo) ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1138,6 +1124,15 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
m_pGeomDB->SetName( nPxId, sPathName) ;
|
||||
m_pGeomDB->SetMaterial( nPxId, BLUE) ;
|
||||
|
||||
// sposto l'inizio a metà del tratto più lungo
|
||||
AdjustContourStart( pCompo) ;
|
||||
|
||||
// verifico se archi vanno approssimati con segmenti di retta
|
||||
int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ;
|
||||
bool bSplitArcs = ( nSplitArcs == SPLAR_ALWAYS ||
|
||||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtExtr.IsZplus()) ||
|
||||
( nSplitArcs == SPLAR_GEN_PLANE && vtExtr.IsGeneric())) ;
|
||||
|
||||
// assegno il vettore estrazione al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
|
||||
// assegno il punto di inizio al gruppo del percorso
|
||||
@@ -1210,7 +1205,7 @@ Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
m_pMchMgr->SetLastError( 2508, "Error in Pocketing : Entity GetElevation") ;
|
||||
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
// da una parte
|
||||
@@ -1220,7 +1215,7 @@ Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
m_pMchMgr->SetLastError( 2508, "Error in Pocketing : Entity GetElevation") ;
|
||||
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
// dall'altra parte
|
||||
@@ -1230,7 +1225,7 @@ Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
m_pMchMgr->SetLastError( 2508, "Error in Pocketing : Entity GetElevation") ;
|
||||
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1252,7 +1247,7 @@ Pocketing::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d&
|
||||
int nHeadId = m_pMchMgr->GetHeadId( m_TParams.m_sHead) ;
|
||||
int nAgbType ;
|
||||
if ( ! m_pGeomDB->GetInfo( nHeadId, "AGB_TYPE", nAgbType) || nAgbType == 0) {
|
||||
m_pMchMgr->SetLastError( 2509, "Error in Pocketing : missing aggregate from bottom") ;
|
||||
m_pMchMgr->SetLastError( 2409, "Error in Pocketing : missing aggregate from bottom") ;
|
||||
return false ;
|
||||
}
|
||||
// recupero la massima distanza consentita dal rinvio
|
||||
@@ -1292,7 +1287,7 @@ Pocketing::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d&
|
||||
}
|
||||
// se supera il limite, errore
|
||||
if ( dDist > dAgbDmax) {
|
||||
m_pMchMgr->SetLastError( 2510, "Error in Pocketing : path too far from part sides") ;
|
||||
m_pMchMgr->SetLastError( 2410, "Error in Pocketing : path too far from part sides") ;
|
||||
return false ;
|
||||
}
|
||||
// assegno direzione di accesso e segnalo utilizzo aggregato da sotto
|
||||
@@ -1385,10 +1380,10 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
PtrOwner<ICurveComposite> pMCrv( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pMCrv) || IsNull( pRCrv)) {
|
||||
m_pMchMgr->SetLastError( 2511, "Error in Pocketing : toolpath allocation failed") ;
|
||||
m_pMchMgr->SetLastError( 2411, "Error in Pocketing : toolpath allocation failed") ;
|
||||
return false ;
|
||||
}
|
||||
if ( ! CalcSpiral( pCompo, Get( pMCrv), Get( pRCrv)))
|
||||
if ( ! CalcSpiral( pCompo, bSplitArcs, Get( pMCrv), Get( pRCrv)))
|
||||
return false ;
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
@@ -1419,33 +1414,38 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// se primo step, approccio e affondo
|
||||
if ( j == 1) {
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX) {
|
||||
ptP1 += vtExtr * dStElev ;
|
||||
dStElev = 0 ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2514, "Error in Pocketing : LeadIn not computable") ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, ! m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti solo collegamento
|
||||
else {
|
||||
// per ora solo collegamento diretto !!! da estendere !!!
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( AddLinearMove( ptP1) == GDB_ID_NULL) {
|
||||
m_pMchMgr->SetLastError( 2516, "Error in Pocketing : Link not computable") ;
|
||||
Point3d ptP1 = ptStart + vtExtr * dStep ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, ! m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1473,36 +1473,16 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
if ( i == nMaxInd) {
|
||||
// se step intermedio, ritorno all'inizio direttamente
|
||||
if ( j < nStep) {
|
||||
// ciclo sulle curve elementari del percorso di ritorno
|
||||
for ( int k = 0 ; k <= nMaxRInd ; ++ k) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvR = pRCrv->GetCurve( k) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pCrvR->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pRet->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pRet) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pRet->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pRet) ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
// copio la curva di ritorno
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pRCrv->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// emetto
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddCurveMove( pRet) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
@@ -1513,16 +1493,12 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2515, "Error in Pocketing : LeadOut not computable") ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, ptP1, dEndElev)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
@@ -1547,10 +1523,10 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
PtrOwner<ICurveComposite> pMCrv( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pMCrv) || IsNull( pRCrv)) {
|
||||
m_pMchMgr->SetLastError( 2511, "Error in Pocketing : toolpath allocation failed") ;
|
||||
m_pMchMgr->SetLastError( 2411, "Error in Pocketing : toolpath allocation failed") ;
|
||||
return false ;
|
||||
}
|
||||
if ( ! CalcSpiral( pCompo, Get( pMCrv), Get( pRCrv)))
|
||||
if ( ! CalcSpiral( pCompo, bSplitArcs, Get( pMCrv), Get( pRCrv)))
|
||||
return false ;
|
||||
pMCrv->Invert() ;
|
||||
pRCrv->Invert() ;
|
||||
@@ -1583,33 +1559,40 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// se primo step, approccio e affondo
|
||||
if ( j == 1) {
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX) {
|
||||
ptP1 += vtExtr * dStElev ;
|
||||
dStElev = 0 ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2514, "Error in Pocketing : LeadIn not computable") ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti solo collegamento
|
||||
else {
|
||||
// per ora solo collegamento diretto !!! da estendere !!!
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( AddLinearMove( ptP1) == GDB_ID_NULL) {
|
||||
m_pMchMgr->SetLastError( 2516, "Error in Pocketing : Link not computable") ;
|
||||
Point3d ptP1 = ptStart + vtExtr * dStep ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1637,36 +1620,16 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
if ( i == nMaxInd) {
|
||||
// se step intermedio, ritorno all'inizio direttamente
|
||||
if ( j < nStep) {
|
||||
// ciclo sulle curve elementari del percorso di ritorno
|
||||
for ( int k = 0 ; k <= nMaxRInd ; ++ k) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvR = pRCrv->GetCurve( k) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pCrvR->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pRet->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pRet) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pRet->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pRet) ;
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
// copio la curva di ritorno
|
||||
PtrOwner<ICurve> pRet( ::GetCurve( pRCrv->Clone())) ;
|
||||
if ( IsNull( pRet))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pRet->Translate( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
// emetto
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddCurveMove( pRet) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
@@ -1677,16 +1640,12 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2515, "Error in Pocketing : LeadOut not computable") ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, ptP1, dEndElev)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
@@ -1699,11 +1658,21 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcSpiral( const ICurveComposite* pCompo, ICurveComposite* pMCrv, ICurveComposite* pRCrv)
|
||||
Pocketing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs,
|
||||
ICurveComposite* pMCrv, ICurveComposite* pRCrv)
|
||||
{
|
||||
// primo offset pari al raggio utensile + sovramateriale
|
||||
double dOffs = 0.5 * m_TParams.m_dDiam + GetOffsR() ;
|
||||
|
||||
// se circonferenza, chiamo la funzione specializzata
|
||||
Point3d ptCen ; Vector3d vtN ; double dRad ; bool bCCW ;
|
||||
if ( pCompo->IsACircle( 10 * EPS_SMALL, ptCen, vtN, dRad, bCCW)) {
|
||||
double dIntRad = 0 ;
|
||||
if ( GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_ZIGZAG)
|
||||
dIntRad = 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
return CalcCircleSpiral( ptCen, vtN, dRad - dOffs, dIntRad, bSplitArcs, pMCrv, pRCrv) ;
|
||||
}
|
||||
|
||||
// ciclo di offset verso l'interno
|
||||
const int MAX_ITER = 100 ;
|
||||
int nIter = 0 ;
|
||||
@@ -1714,7 +1683,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, ICurveComposite* pMCrv, IC
|
||||
// calcolo
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCurr, - dOffs, ICurve::OFF_FILLET)) {
|
||||
m_pMchMgr->SetLastError( 2512, "Error in Pocketing : Offset not computable") ;
|
||||
m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// accodo la curva offsettata al percorso di lavoro
|
||||
@@ -1743,16 +1712,23 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, ICurveComposite* pMCrv, IC
|
||||
dCurrRad = dRad ;
|
||||
pCurr = Get( pOffs) ;
|
||||
// nuovo valore pari allo step
|
||||
dOffs = max( m_Params.m_dSideStep, min( 0.1 * m_TParams.m_dDiam, 1.)) ;
|
||||
dOffs = GetSideStep() ;
|
||||
// incremento contatore iterazioni
|
||||
++ nIter ;
|
||||
}
|
||||
|
||||
// verifico il percorso di lavoro
|
||||
if ( pMCrv->GetCurveCount() == 0) {
|
||||
m_pMchMgr->SetLastError( 2513, "Error in Pocketing : Toolpath not computable") ;
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se necessario, approssimo archi con rette
|
||||
if ( bSplitArcs && ! ApproxWithLines( pMCrv)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Linear Approx not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// eventuale sistemazione archi
|
||||
VerifyArcs( pMCrv) ;
|
||||
// compatto e inverto il percorso di ritorno
|
||||
pRCrv->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false) ;
|
||||
pRCrv->Invert() ;
|
||||
@@ -1760,6 +1736,75 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, ICurveComposite* pMCrv, IC
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double dOutRad, double dIntRad,
|
||||
bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv)
|
||||
{
|
||||
// raggio della circonferenza esterna
|
||||
if ( dOutRad < 10 * EPS_SMALL) {
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// creo e inserisco la circonferenza esterna
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->Set( ptCen, vtN, dOutRad)) {
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
Vector3d vtDir = pArc->GetStartVersor() ;
|
||||
pMCrv->AddCurve( Release( pArc)) ;
|
||||
// se richiesta percorrenza invertita
|
||||
if ( m_Params.m_bInvert)
|
||||
pMCrv->Invert() ;
|
||||
|
||||
// aggiungo le semicirconferenze della spirale ( devono essere in numero dispari)
|
||||
int nStep = int( ceil( ( dOutRad - dIntRad) / ( 0.5 * GetSideStep()))) ;
|
||||
if ( IsEven( nStep))
|
||||
nStep += 1 ;
|
||||
double dStep = ( dOutRad - dIntRad) / nStep ;
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
if ( ! IsEven( i))
|
||||
pMCrv->AddArcTg( ptCen - vtDir * ( dOutRad - i * dStep)) ;
|
||||
else
|
||||
pMCrv->AddArcTg( ptCen + vtDir * ( dOutRad - i * dStep)) ;
|
||||
}
|
||||
|
||||
// aggiungo la circonferenza interna
|
||||
pMCrv->AddArcTg( ptCen + vtDir * dIntRad) ;
|
||||
pMCrv->AddArcTg( ptCen - vtDir * dIntRad) ;
|
||||
|
||||
// verifico il percorso di lavoro
|
||||
if ( pMCrv->GetCurveCount() == 0) {
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se necessario, approssimo con rette
|
||||
if ( bSplitArcs && ! ApproxWithLines( pMCrv)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Linear Approx not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// eventuale sistemazione archi
|
||||
VerifyArcs( pMCrv) ;
|
||||
|
||||
// calcolo il percorso di ritorno
|
||||
Point3d ptStart ; pMCrv->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pMCrv->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtStart ; pMCrv->GetStartDir( vtStart) ;
|
||||
PtrOwner<ICurveArc> pArc2( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc2) || ! pArc2->Set2PVN( ptStart, ptEnd, - vtStart, vtN)) {
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Return toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
pRCrv->AddCurve( Release( pArc2)) ;
|
||||
// inverto e eventualmente sistemo archi
|
||||
pRCrv->Invert() ;
|
||||
VerifyArcs( pRCrv) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
|
||||
@@ -1808,6 +1853,7 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe
|
||||
Point3d ptP1a = ptP1b + vtTool * ( dSafeZ - dAppr) ;
|
||||
if ( ( ! m_bAggrBottom && AddRapidStart( ptP1a) == GDB_ID_NULL) ||
|
||||
( m_bAggrBottom && AddRapidMove( ptP1a) == GDB_ID_NULL))
|
||||
return false ;
|
||||
// 1b -> punto appena sopra inizio
|
||||
if ( ( dElev + dAppr) > EPS_SMALL) {
|
||||
SetFlag( 0) ;
|
||||
@@ -1891,7 +1937,7 @@ Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, con
|
||||
Point3d& ptP1)
|
||||
{
|
||||
// Assegno tipo e parametri
|
||||
int nType = m_Params.m_nLeadInType ;
|
||||
int nType = GetLeadInType() ;
|
||||
double dLen= m_Params.m_dLiTang ;
|
||||
// senso di rotazione da dir tg a dir esterna
|
||||
bool bCcwRot = true ;
|
||||
@@ -1901,14 +1947,11 @@ Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, con
|
||||
ptP1 = ptStart ;
|
||||
return true ;
|
||||
case POCKET_LI_GLIDE :
|
||||
|
||||
return false ;
|
||||
case POCKET_LI_ZIGZAG :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
case POCKET_LI_HELIX :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
ptP1 = ptStart ;
|
||||
return true ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -1917,18 +1960,10 @@ Pocketing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, con
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
|
||||
const Vector3d& vtN, bool bSplitArcs)
|
||||
const Vector3d& vtN, bool bAtLeft, bool bSplitArcs)
|
||||
{
|
||||
// Assegno il tipo
|
||||
int nType = m_Params.m_nLeadInType ;
|
||||
// se archi da spezzare
|
||||
if ( bSplitArcs) {
|
||||
if ( nType == POCKET_LI_HELIX)
|
||||
nType = POCKET_LI_ZIGZAG ;
|
||||
}
|
||||
// se parametro tg nullo, allora nessun attacco
|
||||
if ( (( ptStart - ptP1) ^ vtN).IsSmall())
|
||||
nType = POCKET_LI_NONE ;
|
||||
int nType = GetLeadInType() ;
|
||||
// Eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case POCKET_LI_NONE :
|
||||
@@ -1937,11 +1972,48 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
case POCKET_LI_ZIGZAG :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
{
|
||||
double dDeltaN = ( ptStart - ptP1) * vtN ;
|
||||
int nStep = int( ceil( - dDeltaN / ( m_Params.m_dLiElev + 10 * 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) ;
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
if ( AddLinearMove( ptPa - vtN * ( i - 0.75) * dStep, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
if ( AddLinearMove( ptPb - vtN * ( i - 0.25) * dStep, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
if ( AddLinearMove( ptStart, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
case POCKET_LI_HELIX :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
{
|
||||
// vettore dal punto al centro elica
|
||||
Vector3d vtCen = vtStart ;
|
||||
vtCen.Rotate( vtN, ( bAtLeft ? ANG_RIGHT : - ANG_RIGHT)) ;
|
||||
// dati dell'elica
|
||||
double dRad = 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
Point3d ptCen = ptP1 + vtCen * dRad ;
|
||||
double dDeltaN = ( ptStart - ptP1) * vtN ;
|
||||
double dAngCen = ceil( - dDeltaN / ( m_Params.m_dLiElev + 10 * EPS_SMALL)) * ( bAtLeft ? ANG_FULL : - ANG_FULL) ;
|
||||
// creo l'elica
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->Set( ptCen, vtN, dRad, - vtCen, dAngCen, dDeltaN))
|
||||
return false ;
|
||||
// eventuale spezzatura
|
||||
if ( bSplitArcs) {
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pArc)) || ! ApproxWithLines( pCompo))
|
||||
return false ;
|
||||
return ( AddCurveMove( pCompo, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
else {
|
||||
// emetto l'elica
|
||||
return ( AddCurveMove( pArc, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
}
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
@@ -1950,29 +2022,57 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||
Point3d& ptP1)
|
||||
const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev)
|
||||
{
|
||||
// assegno i parametri
|
||||
int nType = m_Params.m_nLeadOutType ;
|
||||
int nType = GetLeadOutType() ;
|
||||
double dTang = m_Params.m_dLoTang ;
|
||||
double dPerp = 0 ;
|
||||
double dElev = 0 ;
|
||||
// se parametrt tg nullo, allora nessuna uscita
|
||||
if ( abs( dTang) < EPS_SMALL)
|
||||
nType = POCKET_LO_NONE ;
|
||||
// senso di rotazione da dir tg a dir esterna
|
||||
bool bCcwRot = true ;
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case POCKET_LO_NONE :
|
||||
// nessuna uscita
|
||||
ptP1 = ptEnd ;
|
||||
// determino elevazione su fine uscita
|
||||
double dEndElev ;
|
||||
if ( GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtN, vtN, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dElev = dEndElev ;
|
||||
return true ;
|
||||
case POCKET_LO_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
{
|
||||
// recupero la parte richiesta della curva di ritorno
|
||||
PtrOwner<ICurveComposite> pCrv ;
|
||||
double dU ;
|
||||
if ( pRCrv->GetParamAtLength( dTang, dU)) {
|
||||
if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pRCrv->CopyParamRange( 0, dU)))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! pCrv.Set( GetCurveComposite( 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) ;
|
||||
// eventuale spezzatura
|
||||
if ( bSplitArcs && ! ApproxWithLines( pCrv))
|
||||
return false ;
|
||||
// emetto
|
||||
AddCurveMove( pCrv) ;
|
||||
// determino elevazione su fine uscita
|
||||
ptP1 = ptFin ;
|
||||
double dEndElev ;
|
||||
if ( GetElevation( m_nPhase, ptP1 - 10 * EPS_SMALL * vtN, vtN, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dElev = dEndElev ;
|
||||
return true ;
|
||||
}
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1982,3 +2082,29 @@ Pocketing::GetRadiusForStartEndElevation( void)
|
||||
const double DELTA_ELEV_RAD = 20.0 ;
|
||||
return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdjustContourStart( ICurveComposite* pCompo)
|
||||
{
|
||||
// cerco il tratto più lungo
|
||||
int i = 0 ;
|
||||
int nMax = - 1 ;
|
||||
double dLenMax = 0 ;
|
||||
const ICurve* pCrv = pCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
double dLen ;
|
||||
if ( pCrv->GetLength( dLen) && dLen > dLenMax) {
|
||||
dLenMax = dLen ;
|
||||
nMax = i ;
|
||||
}
|
||||
++ i ;
|
||||
pCrv = pCompo->GetNextCurve() ;
|
||||
}
|
||||
|
||||
// sposto inizio
|
||||
if ( nMax >= 0)
|
||||
pCompo->ChangeStartPoint( nMax + 0.5) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user