EgtMachKernel :
- modifiche a svuotatura per regressione nella gestione del caso slot con ingresso e uscita aperti di larghezza pari al diametro utensile.
This commit is contained in:
+170
-158
@@ -1601,7 +1601,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
m_pMchMgr->SetWarning( 2458, sInfo) ;
|
||||
dDepth -= dElev - dMaxDepth ;
|
||||
dElev = dMaxDepth ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verifico se tavola basculante
|
||||
@@ -1974,7 +1974,7 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
|
||||
bOutRawLeadIn = true ;
|
||||
// sistemo attacco (per essere completamente fuori dal grezzo)
|
||||
if ( bOutRawLeadIn || m_bOpenOutRaw)
|
||||
vpCrvs[0]->ExtendStartByLen( m_TParams.m_dDiam / 2 + dSafeZ) ;
|
||||
vpCrvs[0]->ExtendStartByLen( m_TParams.m_dDiam / 2 + dSafeZ) ;
|
||||
}
|
||||
|
||||
// se non ottimizzato e utensile che non lavora di testa poichè ingresso non fuori dal pezzo, errore
|
||||
@@ -2005,7 +2005,7 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
|
||||
if ( bOptimizedZigZag)
|
||||
nOffsCrvNbr = 0 ; // setto a zero per non rientrare nel while
|
||||
else {
|
||||
// recupero la prima curva di offset
|
||||
// recupero la prima curva di offset
|
||||
PtrOwner<ICurveComposite> pOffs( CreateCurveComposite()) ;
|
||||
if ( IsNull( pOffs) || ! pOffs->AddCurve( OffsCrv.GetLongerCurve())) {
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
@@ -2019,7 +2019,7 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
|
||||
// calcolo i percorsi di svuotatura
|
||||
vpCrvs.clear() ;
|
||||
if ( ! CalcZigZag( pOffs, vpCrvs))
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se lucidatura
|
||||
@@ -2527,7 +2527,7 @@ Pocketing::OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth,
|
||||
PtrOwner<ICurveComposite> pCrvPocket( CloneCurveComposite( m_pGeomDB->GetGeoObj( nCrvId))) ;
|
||||
if ( IsNull( pCrvPocket))
|
||||
return false ;
|
||||
pCrvPocket->ToLoc( frPocket) ;
|
||||
pCrvPocket->ToLoc( frPocket) ;
|
||||
SetCurveAllTempProp( nCrvId, pCrvPocket) ;
|
||||
pCrvPocket->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL) ;
|
||||
// sistemo senso antiorario visto dalla direzione di estrusione
|
||||
@@ -2535,14 +2535,14 @@ Pocketing::OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth,
|
||||
Plane3d plPlane ; double dArea ;
|
||||
pCrvPocket->GetArea( plPlane, dArea) ;
|
||||
if ( plPlane.GetVersN() * vtPocket * dArea < 0)
|
||||
pCrvPocket->Invert() ;
|
||||
pCrvPocket->Invert() ;
|
||||
|
||||
// recupero gli id dei lati chiusi
|
||||
INTVECTOR vnInfoClosed ;
|
||||
for( int i = 0 ; i < pCrvPocket->GetCurveCount() ; i ++) {
|
||||
int nProp ;
|
||||
if ( pCrvPocket->GetCurveTempProp( i, nProp) && nProp == 0)
|
||||
vnInfoClosed.push_back( i) ;
|
||||
if ( pCrvPocket->GetCurveTempProp( i, nProp) && nProp == 0)
|
||||
vnInfoClosed.push_back( i) ;
|
||||
}
|
||||
int nClosedSides = vnInfoClosed.size() ;
|
||||
|
||||
@@ -2580,7 +2580,7 @@ Pocketing::OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth,
|
||||
pCrvPocket->ToGlob( frPocket) ;
|
||||
Point3d ptCen = frPocket.Orig() ;
|
||||
Vector3d vtExtr = frPocket.VersZ() ;
|
||||
frPocket.Rotate( ptCen, vtExtr, -dAng) ;
|
||||
frPocket.Rotate( ptCen, vtExtr, -dAng) ;
|
||||
pCrvPocket->ToLoc( frPocket) ;
|
||||
|
||||
// calcolo il percorso di svuotatura
|
||||
@@ -2630,12 +2630,12 @@ Pocketing::OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth,
|
||||
vpCrvs[0]->GetEndPoint( ptEnd) ;
|
||||
ptEnd += OrthoCompo( ptStart - ptEnd, X_AX) ;
|
||||
vpCrvs[0]->AddLine( ptEnd, true) ;
|
||||
vpCrvs[0]->AddLine( ptStart, false) ;
|
||||
vpCrvs[0]->AddLine( ptStart, false) ;
|
||||
}
|
||||
|
||||
// estendo la fine del percorso
|
||||
if ( ! ( nClosedSides == 3 && bTwoOpposite))
|
||||
vpCrvs[0]->ExtendEndByLen( m_TParams.m_dDiam / 4) ;
|
||||
vpCrvs[0]->ExtendEndByLen( m_TParams.m_dDiam / 4) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -2644,7 +2644,7 @@ Pocketing::OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth,
|
||||
bool
|
||||
Pocketing::ZigZagOptimizedNoClosedEdges( ICurveComposite* pCrvPocket, bool& bOptimizedZigZag, Vector3d& vtDir)
|
||||
{
|
||||
// individuo il segmento di retta più lungo
|
||||
// individuo il segmento di retta più lungo
|
||||
int nMax = -1 ;
|
||||
double dMaxLen = 0 ;
|
||||
for ( int i = 0 ; i < int( pCrvPocket->GetCurveCount()) ; ++ i) {
|
||||
@@ -2776,7 +2776,7 @@ Pocketing::ZigZagOptimizedTwoClosedEdges( ICurveComposite* pCrvPocket, const INT
|
||||
|
||||
//------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::ZigZagOptimizedThreeClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
|
||||
Pocketing::ZigZagOptimizedThreeClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
|
||||
bool& bOpposite, Vector3d& vtDir)
|
||||
{
|
||||
// verifico che i lati chiusi siano linee
|
||||
@@ -2817,7 +2817,7 @@ Pocketing::ZigZagOptimizedThreeClosedEdges( ICurveComposite* pCrvPocket, const I
|
||||
if ( dLen2 > dLen1 && dLen2 > dLen3) {
|
||||
if ( dLen1 > 1.5 * m_TParams.m_dDiam || dLen3 > 1.5 * m_TParams.m_dDiam)
|
||||
return true ;
|
||||
pCrv2->GetStartDir( vtDir) ;
|
||||
pCrv2->GetStartDir( vtDir) ;
|
||||
bOpposite = false ;
|
||||
}
|
||||
else {
|
||||
@@ -2873,12 +2873,12 @@ Pocketing::ZigZagOptimizedComputeOffset( ICurveComposite* pCrvPocket, const Vect
|
||||
BBox3d b3Loc ;
|
||||
pCrvPocket->ToLoc( frLoc) ;
|
||||
pCrvPocket->GetLocalBBox( b3Loc) ;
|
||||
pCrvPocket->ToGlob( frLoc) ;
|
||||
pCrvPocket->ToGlob( frLoc) ;
|
||||
Point3d pt ;
|
||||
double dDimX, dDimY, dDimZ ;
|
||||
b3Loc.GetMinDim( pt, dDimX, dDimY, dDimZ) ;
|
||||
// riduco la DimY della svuotatura in base al numero di lati chiusi che saranno offsettati lungo quella direzione
|
||||
dDimY -= nOffsettedEdgesOnY * ( 0.5 * m_TParams.m_dDiam + GetOffsR()) ;
|
||||
b3Loc.GetMinDim( pt, dDimX, dDimY, dDimZ) ;
|
||||
// riduco la DimY della svuotatura in base al numero di lati chiusi che saranno offsettati lungo quella direzione
|
||||
dDimY -= nOffsettedEdgesOnY * ( 0.5 * m_TParams.m_dDiam + GetOffsR()) ;
|
||||
int nYStep = static_cast<int>( ceil( ( dDimY - 30 * EPS_SMALL) / GetSideStep())) ;
|
||||
double dYSideStep = ( nYStep > 0 ? ( dDimY - 30 * EPS_SMALL) / nYStep : 0) ;
|
||||
|
||||
@@ -2886,23 +2886,23 @@ Pocketing::ZigZagOptimizedComputeOffset( ICurveComposite* pCrvPocket, const Vect
|
||||
double dOffs = 0 ;
|
||||
for ( int i = 0 ; i < pCrvPocket->GetCurveCount() ; i ++) {
|
||||
|
||||
double dOffsTmp = 0 ;
|
||||
double dOffsTmp = 0 ;
|
||||
double dVal = 0 ;
|
||||
|
||||
if ( pCrvPocket->GetCurve(i)->GetType() == CRV_LINE) {
|
||||
Vector3d vtDir ;
|
||||
if ( ! pCrvPocket->GetCurve( i)->GetStartDir( vtDir))
|
||||
return false ;
|
||||
double dSinAlpha = ( vtMainDir ^ vtDir).Len() ;
|
||||
double dSinAlpha = ( vtMainDir ^ vtDir).Len() ;
|
||||
if ( abs( dSinAlpha) > EPS_SMALL)
|
||||
dVal = ( dYSideStep - 0.5 * m_TParams.m_dDiam) / dSinAlpha - 0.5 * m_TParams.m_dDiam ;
|
||||
dVal = ( dYSideStep - 0.5 * m_TParams.m_dDiam) / dSinAlpha - 0.5 * m_TParams.m_dDiam ;
|
||||
if ( dVal > EPS_SMALL) {
|
||||
double dCosAlpha = vtMainDir * vtDir ;
|
||||
dOffsTmp = abs( ( dYSideStep - 0.5 * m_TParams.m_dDiam) * dCosAlpha) ;
|
||||
dOffsTmp = abs( ( dYSideStep - 0.5 * m_TParams.m_dDiam) * dCosAlpha) ;
|
||||
}
|
||||
}
|
||||
if ( dOffsTmp > dOffs)
|
||||
dOffs = dOffsTmp ;
|
||||
dOffs = dOffsTmp ;
|
||||
}
|
||||
|
||||
if ( dOffs > EPS_SMALL) {
|
||||
@@ -2913,7 +2913,7 @@ Pocketing::ZigZagOptimizedComputeOffset( ICurveComposite* pCrvPocket, const Vect
|
||||
return false ;
|
||||
}
|
||||
if ( OffsCrv.GetCurveCount() > 1)
|
||||
return false ;
|
||||
return false ;
|
||||
|
||||
// aggiorno pCrvPocket
|
||||
pCrvPocket->Clear() ;
|
||||
@@ -3272,13 +3272,13 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se lucidatura con epicicli
|
||||
// se lucidatura con epicicli
|
||||
if ( m_TParams.m_nType == TT_MILL_POLISHING && m_Params.m_dEpicyclesRad > EPS_SMALL ) {
|
||||
// verifico che i parametri lucidatura siano sensati
|
||||
if ( m_Params.m_dEpicyclesDist < 100 * EPS_SMALL) {
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// modifico il diametro dell'utensile per tenere conto anche del diametro degli epicicli
|
||||
m_TParams.m_dDiam += 2 * m_Params.m_dEpicyclesRad ;
|
||||
}
|
||||
@@ -3299,7 +3299,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se prima regione e gestione lato aperto ( caso non ottimizzato)
|
||||
bool bOutStart = ( nReg == 1 && bMidOpen) ;
|
||||
@@ -3325,7 +3325,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
int nOutsideRaw = 0 ;
|
||||
if ( bOptimizedTrap) {
|
||||
AdjustTrapezoidSpiralForLeadInLeadOut( pMCrv, pRCrv, vtTool, dDepth, nOutsideRaw) ;
|
||||
bOutStart = ( nOutsideRaw > 0) ;
|
||||
bOutStart = ( nOutsideRaw > 0) ;
|
||||
}
|
||||
|
||||
// verifico se ingresso da considerare fuori grezzo anche se dentro
|
||||
@@ -3338,7 +3338,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// determino numero e affondamento degli step
|
||||
int nStep = 1 ;
|
||||
nStep = max( 1, static_cast<int>( ceil( dElev / dOkStep))) ;
|
||||
@@ -3458,7 +3458,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
// atrimenti ultimo step, uscita e retrazione
|
||||
else {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
@@ -3498,7 +3498,7 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dSafeAggrBottZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeAggrBottZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
|
||||
// ciclo sulle regioni
|
||||
const int MAX_REGS = 50 ;
|
||||
int nReg = 0 ;
|
||||
@@ -3512,7 +3512,7 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se lucidatura con epicicli
|
||||
// se lucidatura con epicicli
|
||||
if ( m_TParams.m_nType == TT_MILL_POLISHING && m_Params.m_dEpicyclesRad > EPS_SMALL ) {
|
||||
// verifico che parametri lucidatura siano sensati
|
||||
if ( m_Params.m_dEpicyclesDist < 100 * EPS_SMALL) {
|
||||
@@ -3542,11 +3542,11 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
}
|
||||
|
||||
// nel caso ottimizzato verifico se posso entrare e uscire fuori dal grezzo
|
||||
bool bOutStart = false ;
|
||||
bool bOutStart = false ;
|
||||
int nOutsideRaw = 0 ;
|
||||
if ( bOptimizedTrap) {
|
||||
AdjustTrapezoidSpiralForLeadInLeadOut( pMCrv, pRCrv, vtTool, dDepth, nOutsideRaw) ;
|
||||
bOutStart = ( nOutsideRaw > 0) ;
|
||||
bOutStart = ( nOutsideRaw > 0) ;
|
||||
}
|
||||
|
||||
// se utensile che non lavora di testa e ingresso non fuori dal pezzo, errore
|
||||
@@ -3766,7 +3766,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
|
||||
if ( nReg == 0) {
|
||||
CalcTrapezoidSpiral( pCrvPocket, vtDir, dPocketSize, pMCrv, pRCrv, bOptimizedTrap) ;
|
||||
if ( bOptimizedTrap)
|
||||
return true ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
@@ -3890,14 +3890,14 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
|
||||
for ( int i = 0 ; i < int( vOffs.size()) ; ++ i) {
|
||||
// se collegamento da aggiungere
|
||||
if ( ! IsNull( vLinks[i])) {
|
||||
int nCrvsCount0 = pMCrv->GetCurveCount() ;
|
||||
int nCrvsCount0 = pMCrv->GetCurveCount() ;
|
||||
// accodo nel percorso di lavorazione
|
||||
pMCrv->AddCurve( Release( vLinks[i])) ;
|
||||
// nel caso di lucidatura setto proprietà alle curve di collegamento per poterle identificare
|
||||
if ( m_TParams.m_nType == TT_MILL_POLISHING) {
|
||||
for ( int j = nCrvsCount0 ; j < pMCrv->GetCurveCount() ; j ++)
|
||||
pMCrv->SetCurveTempProp( j, LINK_CURVE_PROP) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se richiesta percorrenza invertita
|
||||
if ( m_Params.m_bInvert)
|
||||
@@ -3920,7 +3920,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
|
||||
VerifyArcs( pMCrv) ;
|
||||
|
||||
// setto estrusione
|
||||
Vector3d vtExtr ;
|
||||
Vector3d vtExtr ;
|
||||
if ( pCompo->GetExtrusion( vtExtr))
|
||||
pMCrv->SetExtrusion( vtExtr) ;
|
||||
|
||||
@@ -4008,7 +4008,7 @@ Pocketing::CalcBoundedLinkWithBiArcs( const Point3d& ptStart, const Vector3d& vt
|
||||
if ( IsNull( pBiArcLink))
|
||||
return false ;
|
||||
|
||||
// verifico se esce dalla svuotatura
|
||||
// verifico se esce dalla svuotatura
|
||||
CRVCVECTOR ccClass ;
|
||||
IntersCurveCurve intCC( *pBiArcLink, *pCrvBound) ;
|
||||
intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ;
|
||||
@@ -4026,7 +4026,7 @@ Pocketing::CalcBoundedLinkWithBiArcs( const Point3d& ptStart, const Vector3d& vt
|
||||
Point3d ptMinDist1, ptMinDist2 ;
|
||||
Vector3d vtDir1, vtDir2 ;
|
||||
double dAng1, dAng2 ;
|
||||
int nFlag ;
|
||||
int nFlag ;
|
||||
|
||||
DistPointCurve distPtSCrv( ptStart, *pCrvBound) ;
|
||||
distPtSCrv.GetParamAtMinDistPoint( 0, dPar1, nFlag) ;
|
||||
@@ -4040,7 +4040,7 @@ Pocketing::CalcBoundedLinkWithBiArcs( const Point3d& ptStart, const Vector3d& vt
|
||||
|
||||
pCompo->AddCurve( GetBiArc( ptStart, -dAngStart, ptMinDist1, -dAng1, 0.5)) ; // primo biarco
|
||||
pCompo->AddCurve( pCrvBound->CopyParamRange( dPar1, dPar2)) ; // tratto di pCrvBound
|
||||
pCompo->AddCurve( GetBiArc( ptMinDist2, -dAng2, ptEnd, -dAngEnd, 0.5)) ; // secondo biarco
|
||||
pCompo->AddCurve( GetBiArc( ptMinDist2, -dAng2, ptEnd, -dAngEnd, 0.5)) ; // secondo biarco
|
||||
|
||||
pCrvLink->AddCurve( Release( pCompo)) ;
|
||||
}
|
||||
@@ -4128,10 +4128,10 @@ Pocketing::CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double d
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtDir, double dPocketSize,
|
||||
bool
|
||||
Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtDir, double dPocketSize,
|
||||
ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool& bOptimizedTrap)
|
||||
{
|
||||
{
|
||||
bOptimizedTrap = false ;
|
||||
|
||||
Vector3d vtExtr ; pCrvPocket->GetExtrusion( vtExtr) ;
|
||||
@@ -4145,19 +4145,20 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
pCrvPocket->SetExtrusion( vtExtr) ;
|
||||
}
|
||||
|
||||
// sistemo senso antiorario visto dalla direzione di estrusione
|
||||
// sistemo senso antiorario visto dalla direzione di estrusione
|
||||
Plane3d plPlane ; double dArea ;
|
||||
pCrvPocket->GetArea( plPlane, dArea) ;
|
||||
if ( plPlane.GetVersN() * vtExtr * dArea < 0)
|
||||
if ( plPlane.GetVersN() * vtExtr * dArea < 0)
|
||||
pCrvPocket->Invert() ;
|
||||
|
||||
// passo in un sistema di riferimento locale avente asse X allineato con uno dei due lati paralleli (possibilmente aperto) e centro nel
|
||||
// passo in un sistema di riferimento locale avente asse X allineato con uno dei due lati paralleli (possibilmente aperto) e centro nel
|
||||
// punto iniziale del lato
|
||||
Frame3d frLoc ;
|
||||
if ( ! CalcTrapezoidSpiralLocalFrame( pCrvPocket, vtDir, frLoc))
|
||||
return false ;
|
||||
pCrvPocket->ToLoc( frLoc) ;
|
||||
|
||||
// recupero flag aperto/chiuso dei lati (0=chiuso, 1=aperto)
|
||||
INTVECTOR vnProp( 4, 0) ;
|
||||
for ( int i = 0 ; i < 4 ; i++)
|
||||
pCrvPocket->GetCurveTempProp( i, vnProp[i]) ;
|
||||
@@ -4168,14 +4169,25 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
pCrvPocket->GetCurve( 2)->GetLength( dLen2) ;
|
||||
if ( vnProp[0] == 0 && abs( dPocketSize - m_TParams.m_dDiam) > EPS_SMALL)
|
||||
return false ;
|
||||
if ( vnProp[1] == 0 && vnProp[3] == 0) {
|
||||
if ( vnProp[1] == 0 && vnProp[3] == 0) {
|
||||
if ( dLen0 < m_TParams.m_dDiam - EPS_SMALL || dLen2 < m_TParams.m_dDiam - EPS_SMALL)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// calcolo la larghezza massima della svuotatura (riferimento con X parallelo a primo lato chiuso)
|
||||
Point3d ptOrig ;
|
||||
pCrvPocket->GetCurve( 1)->GetStartPoint( ptOrig) ;
|
||||
Vector3d vtX ;
|
||||
pCrvPocket->GetCurve( 1)->GetStartDir( vtX) ;
|
||||
Frame3d frDim ; frDim.Set( ptOrig, Z_AX, vtX) ; frDim.Invert() ;
|
||||
BBox3d b3Dim ;
|
||||
pCrvPocket->GetBBox( frDim, b3Dim, BBF_EXACT) ;
|
||||
double dMaxLarg = b3Dim.GetDimY() ;
|
||||
|
||||
// calcolo percorso di svuotatura
|
||||
// se lati obliqui sono entrambi chiusi e dimensione svuotatura è minore di 2 * diamentro fresa gestione speciale
|
||||
if ( vnProp[0] != 0 && vnProp[2] != 0 && vnProp[3] == 0 && vnProp[1] == 0 && max( dLen0, dLen2) < 2 * m_TParams.m_dDiam + EPS_SMALL) {
|
||||
// se lati obliqui sono entrambi chiusi e dimensione svuotatura è maggiore di diametro fresa e minore del doppio gestione speciale
|
||||
if ( vnProp[0] != 0 && vnProp[2] != 0 && vnProp[3] == 0 && vnProp[1] == 0 &&
|
||||
dMaxLarg > m_TParams.m_dDiam + 10 * EPS_SMALL && max( dLen0, dLen2) < 2 * m_TParams.m_dDiam + EPS_SMALL) {
|
||||
if ( ! SpecialAdjustTrapezoidSpiralForAngles( pMCrv, pCrvPocket)) {
|
||||
pMCrv->Clear() ;
|
||||
return false ;
|
||||
@@ -4197,8 +4209,8 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
return false ;
|
||||
Point3d ptStart( dXCoordStart, dYCoord) ;
|
||||
Point3d ptEnd( dXCoordEnd, dYCoord) ;
|
||||
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, 500 * EPS_SMALL) && vnProp[0] != 0) {
|
||||
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, 500 * EPS_SMALL) && vnProp[0] != 0) {
|
||||
Vector3d vtDir1, vtDir3 ;
|
||||
pCrvPocket->GetCurve( 1)->GetStartDir( vtDir1) ;
|
||||
pCrvPocket->GetCurve( 3)->GetStartDir( vtDir3) ;
|
||||
@@ -4211,25 +4223,25 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
if ( ! pLine1->SimpleOffset( - 0.5 * m_TParams.m_dDiam - GetOffsR()) ||
|
||||
! pLine3->SimpleOffset( - 0.5 * m_TParams.m_dDiam - GetOffsR()))
|
||||
return true ;
|
||||
|
||||
|
||||
Point3d ptS, ptE ;
|
||||
if ( vtDir3 * X_AX > EPS_SMALL) {
|
||||
pLine1->GetStartPoint( ptS) ;
|
||||
pLine3->GetStartPoint( ptE) ;
|
||||
pLine3->GetStartPoint( ptE) ;
|
||||
}
|
||||
else {
|
||||
pLine1->GetEndPoint( ptE) ;
|
||||
pLine3->GetEndPoint( ptS) ;
|
||||
}
|
||||
|
||||
|
||||
pMCrv->AddPoint( ptS) ;
|
||||
if ( vnProp[2] != 0)
|
||||
pMCrv->AddLine( ptE) ;
|
||||
if ( vnProp[2] != 0)
|
||||
pMCrv->AddLine( ptE) ;
|
||||
else
|
||||
pMCrv->AddLine( ptStart) ;
|
||||
|
||||
|
||||
pMCrv->SetCurveTempProp( 0, 1) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( ! pMCrv->AddPoint( ptStart))
|
||||
@@ -4242,27 +4254,27 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
if ( vnProp[3] == 0 && ! AdjustTrapezoidSpiralForAngles( pMCrv, pCrvPocket, true)) {
|
||||
pMCrv->Clear() ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
if ( vnProp[1] == 0 && ! AdjustTrapezoidSpiralForAngles( pMCrv, pCrvPocket, false)) {
|
||||
pMCrv->Clear() ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( pMCrv->GetCurveCount() == 0)
|
||||
return true ;
|
||||
|
||||
pMCrv->ToGlob( frLoc) ;
|
||||
if ( ! m_Params.m_bInvert) {
|
||||
pMCrv->Invert() ;
|
||||
// inverto le proprietà in modo che nProp3 sia sempre legata al punto iniziale e nProp1 a quello finale
|
||||
// inverto le proprietà in modo che nProp3 sia sempre legata al punto iniziale e nProp1 a quello finale
|
||||
swap( vnProp[1], vnProp[3]) ;
|
||||
}
|
||||
// segno i lati aperti come temp prop della curva
|
||||
int nOpenEdges = vnProp[0] + vnProp[1] * 2 + vnProp[3] * 8 ;
|
||||
pMCrv->SetTempProp( nOpenEdges, 0) ;
|
||||
int nOpenEdges = vnProp[0] + vnProp[1] * 2 + vnProp[3] * 8 ;
|
||||
pMCrv->SetTempProp( nOpenEdges, 0) ;
|
||||
pMCrv->SetExtrusion( vtExtr) ;
|
||||
|
||||
bOptimizedTrap = true ;
|
||||
@@ -4271,9 +4283,9 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Vector3d& vtD
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcTrapezoidSpiralLocalFrame( ICurveComposite* pCrvPocket, const Vector3d& vtDir, Frame3d& frLoc)
|
||||
Pocketing::CalcTrapezoidSpiralLocalFrame( ICurveComposite* pCrvPocket, const Vector3d& vtDir, Frame3d& frLoc)
|
||||
{
|
||||
// cerco i lati paralleli a vtDir
|
||||
// cerco i lati paralleli a vtDir
|
||||
int nBaseId = -1 ;
|
||||
for ( int i = 0 ; i < pCrvPocket->GetCurveCount() ; i ++) {
|
||||
Vector3d vtEdge ;
|
||||
@@ -4286,7 +4298,7 @@ Pocketing::CalcTrapezoidSpiralLocalFrame( ICurveComposite* pCrvPocket, const Vec
|
||||
if ( nBaseId != 0 && nBaseId != 1)
|
||||
return false ;
|
||||
|
||||
// imposto come lato iniziale per la curva uno dei lati paralleli a vtDir (possibilmente aperto)
|
||||
// imposto come lato iniziale per la curva uno dei lati paralleli a vtDir (possibilmente aperto)
|
||||
int nProp0, nProp2 ;
|
||||
pCrvPocket->GetCurveTempProp( nBaseId, nProp0) ;
|
||||
pCrvPocket->GetCurveTempProp( nBaseId + 2, nProp2) ;
|
||||
@@ -4326,16 +4338,16 @@ Pocketing::CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, bool bS
|
||||
double dVal ;
|
||||
Vector3d vtRef ;
|
||||
pCrvPocket->GetCurve( nCrvId)->GetStartDir( vtRef) ;
|
||||
double dCosAlpha = vtRef * X_AX ;
|
||||
double dCosAlpha = vtRef * X_AX ;
|
||||
|
||||
if ( dRad * dCosAlpha < dYCoord && dYCoord < dPocketSize + dRad * dCosAlpha) {
|
||||
double dSinAlpha = ( vtRef ^ X_AX).Len() ;
|
||||
if ( abs( dSinAlpha) < EPS_SMALL)
|
||||
return false ;
|
||||
dVal = 1.0 / dSinAlpha * ( dRad - dYCoord * dCosAlpha) ;
|
||||
return false ;
|
||||
dVal = 1.0 / dSinAlpha * ( dRad - dYCoord * dCosAlpha) ;
|
||||
}
|
||||
else if ( dYCoord < dRad * dCosAlpha)
|
||||
dVal = sqrt( dRad * dRad - dYCoord * dYCoord) ;
|
||||
dVal = sqrt( dRad * dRad - dYCoord * dYCoord) ;
|
||||
else {
|
||||
double dLen ;
|
||||
pCrvPocket->GetCurve( nCrvId)->GetLength( dLen) ;
|
||||
@@ -4346,7 +4358,7 @@ Pocketing::CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, bool bS
|
||||
if ( bStart) {
|
||||
pCrvPocket->GetCurve( nCrvId)->GetEndPoint( ptRef) ;
|
||||
dXCoord = ptRef.x + dVal ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pCrvPocket->GetCurve( nCrvId)->GetStartPoint( ptRef) ;
|
||||
dXCoord = ptRef.x - dVal ;
|
||||
@@ -4357,15 +4369,15 @@ Pocketing::CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, bool bS
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* pCrvPocket, bool bStart)
|
||||
{
|
||||
Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* pCrvPocket, bool bStart)
|
||||
{
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( ! bStart)
|
||||
pMCrv->Invert() ;
|
||||
|
||||
Point3d ptTmp ;
|
||||
pMCrv->GetStartPoint( ptTmp) ;
|
||||
double dYCoord = ptTmp.y ; // quota verticale del percorso di svuotatura
|
||||
double dYCoord = ptTmp.y ; // quota verticale del percorso di svuotatura
|
||||
pCrvPocket->GetCurve( 2)->GetStartPoint( ptTmp) ;
|
||||
double dPocketSize = ptTmp.y ;
|
||||
|
||||
@@ -4408,13 +4420,13 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC
|
||||
if ( ! pMCrv->GetParamAtPoint( ptCrv, dPar)) {
|
||||
dPar = 0.5 ;
|
||||
pMCrv->GetPointD1D2( dPar, ICurve::FROM_MINUS, ptCrv) ;
|
||||
}
|
||||
pMCrv->TrimStartAtParam( dPar) ;
|
||||
}
|
||||
pMCrv->TrimStartAtParam( dPar) ;
|
||||
|
||||
if ( ptP1.y > dPocketSize) {
|
||||
// se ptP1 è esterno alla svuotatura scambio i punti in modo da usare ptP2 per il biarco ( così da non farlo fuoriuscire troppo)
|
||||
swap( ptP1, ptP2) ;
|
||||
pCompo->Invert() ;
|
||||
swap( ptP1, ptP2) ;
|
||||
pCompo->Invert() ;
|
||||
}
|
||||
|
||||
// creo biarco fra ptP1 e ptCrv
|
||||
@@ -4428,23 +4440,23 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC
|
||||
if ( ! IsNull( pBiArc)) {
|
||||
// verifico che con il biarco non si oltrepassi il lato obliquo chiuso della svuotatura
|
||||
IntersCurveCurve intCC2( *pBiArc, *pCompo) ;
|
||||
if ( intCC2.GetIntersCount() == 1)
|
||||
bUseBiArc = true ;
|
||||
}
|
||||
if ( intCC2.GetIntersCount() == 1)
|
||||
bUseBiArc = true ;
|
||||
}
|
||||
if ( bUseBiArc)
|
||||
pCompo->AddCurve( Release( pBiArc)) ;
|
||||
else {
|
||||
double dParLine = ( dYCoord - ptP2.y) / ( ptP1.y - ptP2.y) ;
|
||||
Point3d ptOnLine = Media( ptP2, ptP1, dParLine) ;
|
||||
pCompo->AddLine( ptOnLine) ;
|
||||
pCompo->AddLine( ptCrv) ;
|
||||
}
|
||||
pCompo->AddLine( ptCrv) ;
|
||||
}
|
||||
}
|
||||
|
||||
// caso 2 : pLine è completamente sopra/sotto la linea di svuotatura
|
||||
else {
|
||||
// se è sopra modifiche per ricondurmi al caso in cui è sotto
|
||||
if ( ptP2.y > dYCoord) {
|
||||
if ( ptP2.y > dYCoord) {
|
||||
pLine->Invert() ;
|
||||
swap( ptP1, ptP2) ;
|
||||
}
|
||||
@@ -4452,8 +4464,8 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC
|
||||
// trovo l'intersezione fra il prolungamento della linea e pMCrv
|
||||
if ( bStart)
|
||||
pLine->ExtendStartByLen( 1000) ;
|
||||
else
|
||||
pLine->ExtendEndByLen( 1000) ;
|
||||
else
|
||||
pLine->ExtendEndByLen( 1000) ;
|
||||
IntersCurveCurve intCC ( *pLine, *pMCrv) ;
|
||||
if ( intCC.GetIntersCount() == 0)
|
||||
return false ;
|
||||
@@ -4466,8 +4478,8 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC
|
||||
pMCrv->TrimStartAtParam( dPar) ;
|
||||
|
||||
pCompo->AddPoint( ptP2) ;
|
||||
pCompo->AddLine( ptInt) ;
|
||||
}
|
||||
pCompo->AddLine( ptInt) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se il lato opposto a quello di riferimento è chiuso ha senso aggiungere solo se il punto è sotto la linea di svuotatura
|
||||
@@ -4476,25 +4488,25 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC
|
||||
pCompo->AddPoint( ptP2) ;
|
||||
Point3d ptCrv ;
|
||||
pMCrv->GetStartPoint( ptCrv) ;
|
||||
pCompo->AddLine( ptCrv) ;
|
||||
}
|
||||
pCompo->AddLine( ptCrv) ;
|
||||
}
|
||||
}
|
||||
|
||||
// setto temp prop per ricordare che è curva aggiuntiva per pulire angoli
|
||||
// setto temp prop per ricordare che è curva aggiuntiva per pulire angoli
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i++)
|
||||
pCompo->SetCurveTempProp( i, 1) ;
|
||||
|
||||
pMCrv->AddCurve( Release( pCompo), false) ;
|
||||
if ( ! bStart)
|
||||
pMCrv->Invert() ; // ripristino la direzione originaria
|
||||
pMCrv->Invert() ; // ripristino la direzione originaria
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* pCrvPocket)
|
||||
{
|
||||
Pocketing::SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* pCrvPocket)
|
||||
{
|
||||
// calcolo gli offset dei lati obliqui
|
||||
PtrOwner<ICurveLine> pLineS( GetCurveLine( pCrvPocket->GetCurve( 3)->Clone())) ;
|
||||
pLineS->SimpleOffset( - 0.5 * m_TParams.m_dDiam - GetOffsR()) ;
|
||||
@@ -4523,7 +4535,7 @@ Pocketing::SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const
|
||||
pLineLink->GetStartDir( vtDir) ;
|
||||
pCrvPocket->GetStartDir( vtDir2) ;
|
||||
|
||||
if ( Dist( ptS, ptE) > 500 * EPS_SMALL && AreSameOrOppositeVectorApprox( vtDir, vtDir2)) {
|
||||
if ( Dist( ptS, ptE) > 500 * EPS_SMALL && AreSameOrOppositeVectorApprox( vtDir, vtDir2)) {
|
||||
|
||||
Point3d ptCrv1, ptCrv2 ;
|
||||
pLineLink->GetPointD1D2( 0.3, ICurve::FROM_MINUS, ptCrv1) ;
|
||||
@@ -4532,29 +4544,29 @@ Pocketing::SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const
|
||||
// primo raccordo
|
||||
double dAng ;
|
||||
vtS.GetAngleXY( X_AX, dAng) ;
|
||||
PtrOwner<ICurve> pBiArc1( GetBiArc( ptS, - dAng, ptCrv1, 0, 0.5)) ;
|
||||
PtrOwner<ICurve> pBiArc1( GetBiArc( ptS, - dAng, ptCrv1, 0, 0.5)) ;
|
||||
|
||||
// secondo raccordo
|
||||
vtE.GetAngleXY( X_AX, dAng) ;
|
||||
PtrOwner<ICurve> pBiArc2( GetBiArc( ptE, dAng, ptCrv2, 180, 0.5)) ;
|
||||
pBiArc2->Invert() ;
|
||||
|
||||
if ( ! IsNull( pBiArc1) && ! IsNull( pBiArc2)) {
|
||||
if ( ! IsNull( pBiArc1) && ! IsNull( pBiArc2)) {
|
||||
bUseBiArcs = true ;
|
||||
pMCrv->AddCurve( Release( pBiArc1)) ;
|
||||
pMCrv->AddLine( ptCrv2) ;
|
||||
pMCrv->AddCurve( Release( pBiArc2)) ;
|
||||
}
|
||||
pMCrv->AddCurve( Release( pBiArc2)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se non è stato possibile creare raccordo, unisco linearmente
|
||||
if ( ! bUseBiArcs)
|
||||
pMCrv->AddCurve( Release( pLineLink)) ;
|
||||
|
||||
pMCrv->AddCurve( Release( pLineLink)) ;
|
||||
|
||||
if ( ! pMCrv->AddCurve( Release( pLineE)))
|
||||
return false ;
|
||||
|
||||
// setto temp prop per ricordare curve aggiuntive per pulire angoli
|
||||
|
||||
// setto temp prop per ricordare curve aggiuntive per pulire angoli
|
||||
pMCrv->SetCurveTempProp( 0, 1) ;
|
||||
pMCrv->SetCurveTempProp( pMCrv->GetCurveCount() - 1, 1) ;
|
||||
|
||||
@@ -4563,9 +4575,9 @@ Pocketing::SpecialAdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdjustTrapezoidSpiralForLeadInLeadOut( ICurveComposite* pCompo, ICurveComposite* pRCrv, const Vector3d& vtTool, double dDepth,
|
||||
int& nOutsideRaw)
|
||||
{
|
||||
Pocketing::AdjustTrapezoidSpiralForLeadInLeadOut( ICurveComposite* pCompo, ICurveComposite* pRCrv, const Vector3d& vtTool, double dDepth,
|
||||
int& nOutsideRaw)
|
||||
{
|
||||
// recupero la direzione principale della svuotatura
|
||||
Vector3d vtMainDir ;
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i++) {
|
||||
@@ -4574,10 +4586,10 @@ Pocketing::AdjustTrapezoidSpiralForLeadInLeadOut( ICurveComposite* pCompo, ICurv
|
||||
// se non è lato aggiuntivo per la pulitura angoli recupero la sua direzione
|
||||
pCompo->GetCurve( i)->GetStartDir( vtMainDir) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// start point
|
||||
// start point
|
||||
bool bStartOutside = false ;
|
||||
ComputeTrapezoidSpiralLeadInLeadOut( pCompo, vtMainDir, true, vtTool, dDepth, bStartOutside) ;
|
||||
// end point
|
||||
@@ -4586,26 +4598,26 @@ Pocketing::AdjustTrapezoidSpiralForLeadInLeadOut( ICurveComposite* pCompo, ICurv
|
||||
|
||||
// eventuale inversione della curva per partire sempre dall'esterno del grezzo
|
||||
if ( bEndOutside && ! bStartOutside)
|
||||
pCompo->Invert() ;
|
||||
pCompo->Invert() ;
|
||||
|
||||
nOutsideRaw = 0 ;
|
||||
if ( bStartOutside && bEndOutside)
|
||||
nOutsideRaw = 2 ;
|
||||
nOutsideRaw = 2 ;
|
||||
else if ( bStartOutside || bEndOutside) {
|
||||
nOutsideRaw = 1 ;
|
||||
nOutsideRaw = 1 ;
|
||||
|
||||
// calcolo percorso di ritorno
|
||||
// calcolo percorso di ritorno
|
||||
pRCrv->Clear() ;
|
||||
pRCrv->AddCurve( pCompo->Clone()) ;
|
||||
pRCrv->Invert() ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
bool
|
||||
Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const Vector3d& vtMainDir, bool bLeadIn, const Vector3d& vtTool, double dDepth, bool& bIsOutsideRaw)
|
||||
Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const Vector3d& vtMainDir, bool bLeadIn, const Vector3d& vtTool, double dDepth, bool& bIsOutsideRaw)
|
||||
{
|
||||
bIsOutsideRaw = false ;
|
||||
|
||||
@@ -4614,7 +4626,7 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
if ( bLeadIn) {
|
||||
pCompo->GetStartPoint( ptP) ;
|
||||
pCompo->GetStartDir( vtDir) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pCompo->GetEndPoint( ptP) ;
|
||||
pCompo->GetEndDir( vtDir) ;
|
||||
@@ -4626,7 +4638,7 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
bool bEdgeOpen = (( nPropOpen & ( bLeadIn ? 8 : 2)) > 0) ;
|
||||
bool bBaseOpen = (( nPropOpen & 1) > 0) ;
|
||||
|
||||
// recupero info per capire se sto considerando un lato aggiuntivo per pulire angoli
|
||||
// recupero info per capire se sto considerando un lato aggiuntivo per pulire angoli
|
||||
int nIdCrv = ( bLeadIn ? 0 : pCompo->GetCurveCount() - 1) ;
|
||||
int nExtraEdge ;
|
||||
pCompo->GetCurveTempProp( nIdCrv, nExtraEdge) ;
|
||||
@@ -4634,8 +4646,8 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
|
||||
// tento con allungamento se lato inclinato è aperto oppure se sto considerando un lato aggiuntivo per pulire angoli
|
||||
if ( bEdgeOpen || nExtraEdge == 1) {
|
||||
|
||||
if ( bEdgeOpen || nExtraEdge == 1) {
|
||||
|
||||
Vector3d vtDirP = ( bLeadIn ? -vtDir : vtDir) ;
|
||||
|
||||
// se forzato come fuori dal grezzo
|
||||
@@ -4650,9 +4662,9 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
double dDist ;
|
||||
Vector3d vtNorm ;
|
||||
if ( ! CalcDistanceFromRawSurface( m_nPhase, ptP, vtDirP, dDist, vtNorm))
|
||||
return false ;
|
||||
return false ;
|
||||
|
||||
// calcolo eventuali fattori correttivi
|
||||
// calcolo eventuali fattori correttivi
|
||||
double dCorr = 1 ;
|
||||
double dDistRef = dDist ;
|
||||
double dDistMin ;
|
||||
@@ -4660,10 +4672,10 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
if ( CalcDistanceFromRawSurface( m_nPhase, ptP, vtNorm, dDistMin, vtNormMin)) {
|
||||
if ( abs( dDistMin) < abs( dDist) && abs( dDistMin) > EPS_SMALL) {
|
||||
dDistRef = dDistMin ;
|
||||
dCorr = dDist / dDistMin ;
|
||||
}
|
||||
dCorr = dDist / dDistMin ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// se vicino al bordo del grezzo
|
||||
if ( dDistRef < m_TParams.m_dDiam / 2 + EPS_SMALL) {
|
||||
Point3d ptTest = ptP + vtDirP * ( dDist + ( m_TParams.m_dDiam / 2 + dSafeZ) * dCorr) ;
|
||||
@@ -4674,22 +4686,22 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
Point3d ptNewStart = ptP + vtDirP * ( dDist + ( m_TParams.m_dDiam / 2 + dSafeZ) * dCorr) ;
|
||||
pCompo->AddLine( ptNewStart, ! bLeadIn) ;
|
||||
bIsOutsideRaw = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tento con attacco ruotato di 90° se non sto considerando un tratto aggiuntivo per pulire angoli
|
||||
if ( bBaseOpen && ! bIsOutsideRaw && nExtraEdge == 0) {
|
||||
|
||||
Vector3d vtDirO = vtDir ;
|
||||
vtDirO.Rotate( vtExtr, ( m_Params.m_bInvert ? -90 : 90)) ;
|
||||
Vector3d vtDirO = vtDir ;
|
||||
vtDirO.Rotate( vtExtr, ( m_Params.m_bInvert ? -90 : 90)) ;
|
||||
// calcolo distanza dal bordo del grezzo lungo vtDirO
|
||||
double dDist ;
|
||||
Vector3d vtNorm ;
|
||||
if ( ! CalcDistanceFromRawSurface( m_nPhase, ptP, vtDirO, dDist, vtNorm))
|
||||
return false ;
|
||||
|
||||
// se vicino al bordo del grezzo
|
||||
// se vicino al bordo del grezzo
|
||||
if ( dDist < m_TParams.m_dDiam / 2 + EPS_SMALL) {
|
||||
Point3d ptTestO = ptP + vtDirO * ( dDist + m_TParams.m_dDiam / 2 + dSafeZ) ;
|
||||
ptTestO += - vtTool * dDepth ;
|
||||
@@ -4699,61 +4711,61 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V
|
||||
Point3d ptNewStart = ptP + vtDirO * ( dDist + m_TParams.m_dDiam / 2 + dSafeZ) ;
|
||||
pCompo->AddLine( ptNewStart, ! bLeadIn) ;
|
||||
bIsOutsideRaw = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs)
|
||||
{
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pCrvBound( CreateCurveComposite()) ; // curva bound da usare per CalcBoundedLink
|
||||
Pocketing::ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs)
|
||||
{
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveComposite> pCrvBound( CreateCurveComposite()) ; // curva bound da usare per CalcBoundedLink
|
||||
ICRVCOMPOPOVECTOR vpCrvsEp ;
|
||||
|
||||
|
||||
Frame3d frLoc ;
|
||||
Vector3d vtExtr ; pMCrv->GetExtrusion( vtExtr) ;
|
||||
frLoc.Set( ORIG, vtExtr) ;
|
||||
pMCrv->ToLoc( frLoc) ;
|
||||
|
||||
for ( int i = 0 ; i < pMCrv->GetCurveCount() ; i ++) {
|
||||
for ( int i = 0 ; i < pMCrv->GetCurveCount() ; i ++) {
|
||||
int nProp = 0 ;
|
||||
if ( ! pMCrv->GetCurveTempProp( i, nProp))
|
||||
return false ;
|
||||
|
||||
// se è un tratto di collegamento ho concluso percorso su cui aggiungere epicicli
|
||||
if ( nProp == LINK_CURVE_PROP) {
|
||||
if ( nProp == LINK_CURVE_PROP) {
|
||||
if ( pCompo->IsValid()) {
|
||||
PtrOwner<ICurveComposite> pCrvEp( CreateCurveComposite()) ;
|
||||
// la curva di bound è l'offset che calcolo in AddEpicycles per la prima curva compo trovata in pMCrv
|
||||
// la curva di bound è l'offset che calcolo in AddEpicycles per la prima curva compo trovata in pMCrv
|
||||
bool bAddEp = ( ! pCrvBound->IsValid()) ? AddEpicycles( pCompo, pCrvEp, pCrvBound) : AddEpicycles( pCompo, pCrvEp) ;
|
||||
if ( ! bAddEp)
|
||||
return false ;
|
||||
if ( ! bAddEp)
|
||||
return false ;
|
||||
vpCrvsEp.emplace_back( Release( pCrvEp)) ;
|
||||
pCompo.Set( CreateCurveComposite()) ;
|
||||
}
|
||||
}
|
||||
// se non è tratto di collegamento lo aggiungo alla curva
|
||||
}
|
||||
}
|
||||
// se non è tratto di collegamento lo aggiungo alla curva
|
||||
else {
|
||||
if ( ! pCompo->AddCurve( pMCrv->GetCurve(i)->Clone()))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ultima curva
|
||||
if ( ! IsNull( pCompo)) {
|
||||
PtrOwner<ICurveComposite> pCrvEp( CreateCurveComposite()) ;
|
||||
if ( ! AddEpicycles( pCompo, pCrvEp))
|
||||
return false ;
|
||||
return false ;
|
||||
vpCrvsEp.emplace_back( Release( pCrvEp)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// calcolo i collegamenti
|
||||
ICURVEPOVECTOR vLinks( vpCrvsEp.size()) ;
|
||||
for ( int i = 1 ; i < int( vpCrvsEp.size()) ; ++ i) {
|
||||
// punti e direzioni di inizio e fine
|
||||
// punti e direzioni di inizio e fine
|
||||
Point3d ptStart ; Vector3d vtStart ;
|
||||
vpCrvsEp[i-1]->GetEndPoint( ptStart) ;
|
||||
vpCrvsEp[i-1]->GetEndDir( vtStart) ;
|
||||
@@ -4780,7 +4792,7 @@ Pocketing::ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv,
|
||||
vpCrvsEp.back()->GetEndPoint( ptStart) ;
|
||||
vpCrvsEp.back()->GetEndDir( vtStart) ;
|
||||
Point3d ptEnd ; Vector3d vtEnd ;
|
||||
vpCrvsEp.front()->GetStartPoint( ptEnd) ;
|
||||
vpCrvsEp.front()->GetStartPoint( ptEnd) ;
|
||||
vpCrvsEp.front()->GetStartDir( vtEnd) ;
|
||||
|
||||
// calcolo il ritorno con biarchi (garantendo che non esca dalla svuotatura)
|
||||
@@ -4885,13 +4897,13 @@ Pocketing::AddEpicycles( ICurveComposite* pCompo, ICurveComposite * pCrv, ICurve
|
||||
k -- ;
|
||||
dStep -= EPS_SMALL ;
|
||||
if ( dStep < EPS_SMALL)
|
||||
return false ;
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
dParPrec = dPar ;
|
||||
else
|
||||
dParPrec = dPar ;
|
||||
}
|
||||
}
|
||||
// se necessario ripristino orientamento originale
|
||||
}
|
||||
// se necessario ripristino orientamento originale
|
||||
if ( m_Params.m_bInvert)
|
||||
pCrv->Invert() ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user