EgtGeomKernel :
- estensione del VM 5 assi e 3 assi ai casi con utensili diversi dal cilindro.
This commit is contained in:
+358
-234
@@ -23,7 +23,7 @@
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
//#include "/EgtDev/Include/EGkGeoObjSave.h" // debug
|
||||
#include <future>
|
||||
|
||||
using namespace std ;
|
||||
@@ -1076,12 +1076,12 @@ VolZmap::MillingStep( int nCurrTool,
|
||||
Vector3d vtALe = GetToLoc( vtAe, m_MapFrame) ;
|
||||
vtALe.Normalize() ;
|
||||
|
||||
//static PerformanceCounter Counter ;
|
||||
//{
|
||||
//string sOut = "Draw=" + ToString( Counter.Stop(), 3) ;
|
||||
//LOG_INFO( GetEGkLogger(), sOut.c_str())
|
||||
//Counter.Start() ;
|
||||
//}
|
||||
static PerformanceCounter Counter ;
|
||||
{
|
||||
string sOut = "Draw=" + ToString( Counter.Stop(), 3) ;
|
||||
LOG_INFO( GetEGkLogger(), sOut.c_str())
|
||||
Counter.Start() ;
|
||||
}
|
||||
|
||||
// Se pura traslazione
|
||||
bool bOk ;
|
||||
@@ -1091,11 +1091,11 @@ VolZmap::MillingStep( int nCurrTool,
|
||||
else
|
||||
bOk = MillingGeneralMotionStep( ptPLs, vtDLs, vtALs, ptPLe, vtDLe, vtALe) ;
|
||||
|
||||
//{
|
||||
//string sOut = "Calc=" + ToString( Counter.Stop(), 3) ;
|
||||
//LOG_INFO( GetEGkLogger(), sOut.c_str())
|
||||
//Counter.Start() ;
|
||||
//}
|
||||
{
|
||||
string sOut = "Calc=" + ToString( Counter.Stop(), 3) ;
|
||||
LOG_INFO( GetEGkLogger(), sOut.c_str())
|
||||
Counter.Start() ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
@@ -1157,7 +1157,7 @@ VolZmap::InitializeAuxPoints( Point3d ptTop1s[3], Point3d ptTop1e[3], Point3d pt
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, const int nPhase)
|
||||
VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum)
|
||||
{
|
||||
// Controllo utensile
|
||||
if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size()))
|
||||
@@ -1225,25 +1225,35 @@ VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR&
|
||||
if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) {
|
||||
double dRadius = ptStart.x ;
|
||||
if ( dRadius > 10 * EPS_SMALL)
|
||||
CompCyl_5AxisMilling( nGrid, ptI, ptF, vtLs, vtLe, dHeight, dRadius, nToolNum, nPhase) ;
|
||||
CompCyl_5AxisMilling( nGrid, ptI, ptF, vtLs, vtLe, dHeight, dRadius, nToolNum) ;
|
||||
}
|
||||
// se altrimenti X decrescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
//CompConus_5AxisMilling( nGrid, ptI, ptF, vtLs, vtLe, dHeight, dMaxRad, dMinRad,
|
||||
// bTapB, bTapT, vtNormSt, vtNormEn, nToolNum, nPhase) ;
|
||||
CompConus_5AxisMilling( nGrid, ptI, ptF, vtLs, vtLe, dHeight, dMaxRad, dMinRad,
|
||||
bTapB, bTapT, vtNormSt, vtNormEn, nToolNum) ;
|
||||
}
|
||||
// altrimenti X crescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
//Point3d ptIn = ptI - vtLs * dHeight ;
|
||||
//Point3d ptFn = ptF - vtLe * dHeight ;
|
||||
PNTVECTOR ptIn( ptI.size()) ;
|
||||
PNTVECTOR ptFn( ptF.size()) ;
|
||||
for ( int i = 0 ; i < int( ptI.size()) ; ++i) {
|
||||
ptIn[i] = ptI[i] - vtLs[i] * dHeight ;
|
||||
ptFn[i] = ptF[i] - vtLe[i] * dHeight ;
|
||||
}
|
||||
vtNormEn.z = -vtNormEn.z ;
|
||||
vtNormSt.z = -vtNormSt.z ;
|
||||
//CompConus_5AxisMilling( nGrid, ptIn, ptFn, - vtLs, -vtLe, dHeight, dMaxRad, dMinRad,
|
||||
// bTapT, bTapB, vtNormEn, vtNormSt, nToolNum, nPhase) ;
|
||||
VCT3DVECTOR vNewVtLs( vtLs.size()) ;
|
||||
VCT3DVECTOR vNewVtLe( vtLe.size()) ;
|
||||
for ( int i = 0 ; i < int( vtLs.size()) ; ++i) {
|
||||
vNewVtLs[i] = -vtLs[i] ;
|
||||
vNewVtLe[i] = -vtLe[i] ;
|
||||
}
|
||||
CompConus_5AxisMilling( nGrid, ptIn, ptFn, vNewVtLs, vNewVtLe, dHeight, dMaxRad, dMinRad,
|
||||
bTapT, bTapB, vtNormEn, vtNormSt, nToolNum) ;
|
||||
}
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
@@ -1264,11 +1274,11 @@ VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR&
|
||||
Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dRadius = pArc->GetRadius() ;
|
||||
//// Determino le posizioni iniziale e finale del centro della sfera
|
||||
//Point3d ptCenS = ptI - vtLs * ( ptStart.y - ptCen.y) ;
|
||||
//Point3d ptCenE = ptF - vtLe * ( ptStart.y - ptCen.y) ;
|
||||
//// Eseguo l'asportazione del materiale
|
||||
//CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, nToolNum) ;
|
||||
// Determino le posizioni iniziale e finale del centro della sfera
|
||||
Point3d ptCenS = ptI.front() - vtLs.front() * ( ptStart.y - ptCen.y ) ;
|
||||
Point3d ptCenE = ptF.back() - vtLe.back() * ( ptStart.y - ptCen.y ) ;
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, nToolNum) ;
|
||||
// aggiorno l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
// Passo alla curva successiva
|
||||
@@ -1287,10 +1297,10 @@ VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR&
|
||||
return true ;
|
||||
}
|
||||
|
||||
//debug
|
||||
static vector<IGeoObj*> vGeo ;
|
||||
//static int nCount = 0 ;
|
||||
//debug
|
||||
////debug
|
||||
//static vector<IGeoObj*> vGeo ;
|
||||
////static int nCount = 0 ;
|
||||
////debug
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
@@ -1312,7 +1322,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
int nSpanU = 1 ; int nSpanV = 1 ;
|
||||
bool bRat = false ;
|
||||
|
||||
int nSub = 4 ; // numero di bilineari con cui approssimare il (quasi) semi-cilindro ellissoide che descrive il volume della punta e della cima del tool
|
||||
int nSub = 8 ; // numero di bilineari con cui approssimare il (quasi) semi-cilindro ellissoide che descrive il volume della punta e della cima del tool
|
||||
PNTVECTOR d ;
|
||||
Vector3d q = Z_AX ;
|
||||
DBLVECTOR A1, B1, C1, A2, B2, C2 ;
|
||||
@@ -1329,6 +1339,12 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
Vector3d vtDirTopEndEx ;
|
||||
Vector3d vtDirTipStartEx ;
|
||||
Vector3d vtDirTipEndEx ;
|
||||
|
||||
////debug
|
||||
//if( nGrid == 0)
|
||||
// vGeo.clear() ;
|
||||
////debug
|
||||
|
||||
for ( int s = 0 ; s < nStepCnt ; ++s) {
|
||||
// punti d riferimento sul tool
|
||||
Point3d ptTop1s ;
|
||||
@@ -1494,16 +1510,16 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
A2.push_back( a.y * q.z - a.z * q.y) ;
|
||||
B2.push_back( b.y * q.z - b.z * q.y) ;
|
||||
C2.push_back( c.y * q.z - c.z * q.y) ;
|
||||
if ( nGrid == 0)
|
||||
vGeo.push_back( vSurfBez[nSurfInd]->Clone()) ;
|
||||
//if ( nGrid == 0)
|
||||
// vGeo.push_back( vSurfBez[nSurfInd]->Clone()) ;
|
||||
}
|
||||
}
|
||||
|
||||
//debug
|
||||
if ( nGrid == 0) {
|
||||
SaveGeoObj( vGeo, "D:/Temp/VirtualMilling/5axisAdvanced/finalApprox.nge", 2) ;
|
||||
}
|
||||
//debug
|
||||
////debug
|
||||
//if ( nGrid == 0) {
|
||||
// SaveGeoObj( vGeo, "D:/Temp/VirtualMilling/5axisAdvanced/finalApprox.nge", 2) ;
|
||||
//}
|
||||
////debug
|
||||
|
||||
BBox3d bbStartCyl = GetCylMoveBBox( ptS[0], ptS[0], vtLs[0], dMaxRad, dHeight) ;
|
||||
BBox3d bbEndCyl = GetCylMoveBBox( ptE.back(), ptE.back(), vtLe.back(), dMaxRad, dHeight) ;
|
||||
@@ -1539,22 +1555,8 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
vvtTopStartAux.front() = vPntTopStartEx.front() - ptS.front() ;
|
||||
vvtTopEndAux.front() = vPntTopEndEx.front() - ptE.back() ;
|
||||
|
||||
//Frame3d frTipStart, frTipEnd, frTopStart, frTopEnd ;
|
||||
//if ( dSide > 0) {
|
||||
// frTipStart.Set( ptP1T, ) ;
|
||||
// frTipEnd.Set( ptP2T, ) ;
|
||||
// frTopStart.Set( ptS[0], ) ;
|
||||
// frTopEnd.Set( ptE.back(), ) ;
|
||||
//}
|
||||
//else if( dSide < 0) {
|
||||
// frTipStart.Set( ptP1T, ) ;
|
||||
// frTipEnd.Set( ptP2T, ) ;
|
||||
// frTopStart.Set( ptS[0], ) ;
|
||||
// frTopEnd.Set( ptE.back(), ) ;
|
||||
//}
|
||||
double dMinRadApprox = 0 ;
|
||||
double dMaxRadApprox = 0 ;
|
||||
|
||||
for ( int i = 1 ; i <= nSub ; ++i) {
|
||||
vvtTipStartAux[i] = Media( vPntTipStartEx[i-1],vPntTipStartEx[i]) - ptP1T ;
|
||||
if ( i == nSub)
|
||||
@@ -1570,34 +1572,6 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
vvtTopEndAux[i].Normalize() ;
|
||||
}
|
||||
|
||||
//// creo le quattro superficie quadrate per fare i cap della giunzione tra cilindri e bilineari
|
||||
//PNTMATRIX vvPntSq( 4) ;
|
||||
//double dAng = 90 ;
|
||||
//if ( dSide < 0)
|
||||
// dAng = -90 ;
|
||||
//// recupero i vettori con le direzioni parallele alle basi del tool
|
||||
//vtDirTopStartEx.Rotate( vtLs.front(), dAng) ;
|
||||
//vtDirTipStartEx.Rotate( vtLs.front(), dAng) ;
|
||||
//vtDirTopEndEx.Rotate( vtLe.back(), dAng) ;
|
||||
//vtDirTipEndEx.Rotate( vtLe.back(), dAng) ;
|
||||
//vvPntSq.emplace_back( PNTVECTOR( { vPntTopStartEx.front(), vPntTopStartEx.back(), vPntTopStartEx.front() + vtDirTopStartEx, vPntTopStartEx.back() + vtDirTopStartEx})) ; // top start
|
||||
//vvPntSq.emplace_back( PNTVECTOR( { vPntTipStartEx.front(), vPntTipStartEx.back(), vPntTipStartEx.front() + vtDirTipStartEx, vPntTipStartEx.back() + vtDirTipStartEx})) ; // tip start
|
||||
//vvPntSq.emplace_back( PNTVECTOR( { vPntTopEndEx.front(), vPntTopEndEx.back(), vPntTopEndEx.front() + vtDirTopEndEx, vPntTopEndEx.back() + vtDirTopEndEx})) ; // top end
|
||||
//vvPntSq.emplace_back( PNTVECTOR( { vPntTipEndEx.front(), vPntTipEndEx.back(), vPntTipEndEx.front() + vtDirTipEndEx, vPntTipEndEx.back() + vtDirTipEndEx})) ; // tip end
|
||||
//ISURFBEZPOVECTOR vBezCaps ;
|
||||
//BOXVECTOR vBezCapBox( 4) ;
|
||||
//for ( int z = 0 ; z < 3 ; ++z) {
|
||||
// //inizializzo la superficie
|
||||
// vBezCaps.emplace_back( CreateSurfBezier()) ;
|
||||
// vBezCaps.back()->Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
// vBezCaps.back()->SetControlPoint( 0, vvPntSq[z][0]) ;
|
||||
// vBezCaps.back()->SetControlPoint( 1, vvPntSq[z][1]) ;
|
||||
// vBezCaps.back()->SetControlPoint( 2, vvPntSq[z][2]) ;
|
||||
// vBezCaps.back()->SetControlPoint( 3, vvPntSq[z][3]) ;
|
||||
// // creo la box della superficie
|
||||
// vBezCapBox[z].Add( vvPntSq[z]) ;
|
||||
//}
|
||||
|
||||
// scorro tutti gli spilloni interessati
|
||||
int nAllStepsSurfs = nTotSurf * nStepCnt ;
|
||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
@@ -1838,8 +1812,90 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
Point3d pt1, pt2 ;
|
||||
Vector3d vt1, vt2 ;
|
||||
if ( IntersLineConus( r, Z_AX, frStartCon, dTan, dMinH, dMaxH, false, false, pt1, vt1, pt2, vt2)) {
|
||||
UpdateMaxMin( pt1, vt1, vInters) ;
|
||||
UpdateMaxMin( pt2, vt2, vInters) ;
|
||||
bool bUpdate1 = false ;
|
||||
bool bUpdate2 = false ;
|
||||
bool bOnTopBase1 = ( pt1 - frStartCon.Orig()) * frStartCon.VersZ() > dHeight - EPS_SMALL ;
|
||||
bool bOnBottomBase1 = ( pt1 - frStartCon.Orig()) * frStartCon.VersZ() < EPS_SMALL ;
|
||||
bool bOnTopBase2 = ( pt2 - frStartCon.Orig()) * frStartCon.VersZ() > dHeight - EPS_SMALL ;
|
||||
bool bOnBottomBase2 = ( pt2 - frStartCon.Orig()) * frStartCon.VersZ() < EPS_SMALL ;
|
||||
// se ho un'intersezione su una base devo verificare se la devo considerare o no
|
||||
if ( bOnBottomBase1 || bOnTopBase1) {
|
||||
// verifico se sono nella metà della base il cui contorno è in contatto con le bilineari
|
||||
//base inferiore
|
||||
double dSectorAng = 0 ;
|
||||
if ( bOnBottomBase1 && ( pt1 - frStartCon.Orig()) * vtDirTipStartEx > 0) {
|
||||
vvtTipStartAux.front().GetAngle(pt1 - frStartCon.Orig(), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub) + 1) ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = (pt1 - frStartCon.Orig()) * vvtTipStartAux[nSector] ;
|
||||
if ( dSide > 0)
|
||||
bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ;
|
||||
}
|
||||
// base superiore
|
||||
else if( bOnTopBase1 && ( pt1 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight))* vtDirTopStartEx > 0) {
|
||||
vvtTopStartAux.front().GetAngle( pt1 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = ( pt1 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight)) * vvtTopStartAux[nSector] ;
|
||||
if( dSide < 0)
|
||||
bUpdate1 = dDist < dMaxRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate1 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ;
|
||||
}
|
||||
else
|
||||
bUpdate1 = true ;
|
||||
}
|
||||
else {
|
||||
double dHInters1 = (pt1 - ptP1T) * vtLs.front() ;
|
||||
Vector3d vtDir1 = Media( vtDirTip, vtDirTop, dHInters1 / dHeight) ;
|
||||
bUpdate1 = vt1 * vtDir1 > 0 ;
|
||||
}
|
||||
// se ho un'intersezione su una base devo verificare se la devo considerare o no
|
||||
if ( bOnBottomBase2 || bOnTopBase2) {
|
||||
// verifico se sono nella metà della base il cui contorno è in contatto con le bilineari
|
||||
//base inferiore
|
||||
double dSectorAng = 0 ;
|
||||
if ( bOnBottomBase2 && ( pt2 - frStartCon.Orig()) * vtDirTipStartEx > 0) {
|
||||
vvtTipStartAux.front().GetAngle( pt2 - frStartCon.Orig(), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = ( pt2 - frStartCon.Orig()) * vvtTipStartAux[nSector] ;
|
||||
if ( dSide > 0)
|
||||
bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ;
|
||||
|
||||
}
|
||||
// base superiore
|
||||
else if( bOnTopBase2 && ( pt2 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight))* vtDirTopStartEx > 0) {
|
||||
vvtTopStartAux.front().GetAngle( pt2 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = ( pt2 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight)) * vvtTopStartAux[nSector] ;
|
||||
if ( dSide < 0)
|
||||
bUpdate2 = dDist < dMaxRadApprox - EPS_SMALL ;
|
||||
else {
|
||||
bUpdate2 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ;
|
||||
}
|
||||
}
|
||||
else
|
||||
bUpdate2 = true ;
|
||||
}
|
||||
else {
|
||||
double dHInters2 = ( pt2 - ptP1T) * vtLs.front() ;
|
||||
Vector3d vtDir2 = Media( vtDirTip, vtDirTop, dHInters2 / dHeight) ;
|
||||
bUpdate2 = vt2 * vtDir2 > 0 ;
|
||||
}
|
||||
if ( bUpdate1)
|
||||
UpdateMaxMin( pt1, vt1, vInters) ;
|
||||
if ( bUpdate2)
|
||||
UpdateMaxMin( pt2, vt2, vInters) ;
|
||||
}
|
||||
}
|
||||
if ( bbEndCyl.SqDistFromPointXY( r) < EPS_ZERO) {
|
||||
@@ -1848,13 +1904,91 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
Point3d pt1, pt2 ;
|
||||
Vector3d vt1, vt2 ;
|
||||
if ( IntersLineConus( r, Z_AX, frEndCon, dTan, dMinH, dMaxH, false, false, pt1, vt1, pt2, vt2)) {
|
||||
UpdateMaxMin( pt1, vt1, vInters) ;
|
||||
UpdateMaxMin( pt2, vt2, vInters) ;
|
||||
bool bUpdate1 = false ;
|
||||
bool bUpdate2 = false ;
|
||||
bool bOnTopBase1 = ( pt1 - frEndCon.Orig()) * frEndCon.VersZ() > dHeight - EPS_SMALL ;
|
||||
bool bOnBottomBase1 = ( pt1 - frEndCon.Orig()) * frEndCon.VersZ() < EPS_SMALL ;
|
||||
bool bOnTopBase2 = ( pt2 - frEndCon.Orig()) * frEndCon.VersZ() > dHeight - EPS_SMALL ;
|
||||
bool bOnBottomBase2 = ( pt2 - frEndCon.Orig()) * frEndCon.VersZ() < EPS_SMALL ;
|
||||
// se ho un'intersezione su una base devo verificare se la devo considerare o no
|
||||
if ( bOnBottomBase1 || bOnTopBase1) {
|
||||
// verifico se sono nella metà della base il cui contorno è in contatto con le bilineari
|
||||
//base inferiore
|
||||
double dSectorAng = 0 ;
|
||||
if ( bOnBottomBase1 && ( pt1 - frEndCon.Orig()) * vtDirTipEndEx > 0) {
|
||||
vvtTipStartAux.front().GetAngle(pt1 - frEndCon.Orig(), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = (pt1 - frEndCon.Orig()) * vvtTipStartAux[nSector] ;
|
||||
if ( dSide < 0)
|
||||
bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ;
|
||||
}
|
||||
// base superiore
|
||||
else if( bOnTopBase1 && ( pt1 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight))* vtDirTopEndEx > 0) {
|
||||
vvtTopStartAux.front().GetAngle( pt1 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = ( pt1 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight)) * vvtTopStartAux[nSector] ;
|
||||
if ( dSide > 0)
|
||||
bUpdate1 = dDist < dMaxRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate1 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ;
|
||||
}
|
||||
else
|
||||
bUpdate1 = true ;
|
||||
}
|
||||
else {
|
||||
double dHInters1 = (pt1 - ptP2T) * vtLe.back() ;
|
||||
Vector3d vtDir1 = Media( vtDirTip, vtDirTop, dHInters1 / dHeight) ;
|
||||
bUpdate1 = vt1 * vtDir1 < 0 ;
|
||||
}
|
||||
// se ho un'intersezione su una base devo verificare se la devo considerare o no
|
||||
if ( bOnBottomBase2 || bOnTopBase2) {
|
||||
// verifico se sono nella metà della base il cui contorno è in contatto con le bilineari
|
||||
//base inferiore
|
||||
double dSectorAng = 0 ;
|
||||
if ( bOnBottomBase2 && ( pt2 - frEndCon.Orig()) * vtDirTipEndEx > 0) {
|
||||
vvtTipStartAux.front().GetAngle(pt2 - frEndCon.Orig(), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = (pt2 - frEndCon.Orig()) * vvtTipStartAux[nSector] ;
|
||||
if ( dSide < 0)
|
||||
bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ;
|
||||
}
|
||||
// base superiore
|
||||
else if( bOnTopBase2 && ( pt2 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight))* vtDirTopEndEx > 0) {
|
||||
vvtTopStartAux.front().GetAngle( pt2 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight), dSectorAng) ;
|
||||
// determino in quale settore del semicerchio approssimato mi trovo
|
||||
int nSector = int( dSectorAng / ( 180. / nSub)) + 1 ;
|
||||
// verifico se l'intersezione linea-base è interna o esterna
|
||||
double dDist = ( pt2 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight)) * vvtTopStartAux[nSector] ;
|
||||
if ( dSide > 0)
|
||||
bUpdate2 = dDist < dMaxRadApprox - EPS_SMALL ;
|
||||
else
|
||||
bUpdate2 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ;
|
||||
}
|
||||
else
|
||||
bUpdate2 = true ;
|
||||
}
|
||||
else {
|
||||
double dHInters2 = (pt2 - ptP2T) * vtLe.back() ;
|
||||
Vector3d vtDir2 = Media( vtDirTip, vtDirTop, dHInters2 / dHeight) ;
|
||||
bUpdate2 = vt2 * vtDir2 < 0 ;
|
||||
}
|
||||
if ( bUpdate1)
|
||||
UpdateMaxMin( pt1, vt1, vInters) ;
|
||||
if ( bUpdate2)
|
||||
UpdateMaxMin( pt2, vt2, vInters) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// interseco con le basi trimmate dei cilindri ( che tengono conto dell'approssimazione fatta con bilineari del volume spazzato da top e tip)
|
||||
|
||||
|
||||
if ( vInters.size() != 0 ) {
|
||||
// se ho un numero dispari di intersezioni devo migliorare la gestione
|
||||
@@ -1912,23 +2046,9 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CompCyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe,
|
||||
double dHeight, double dRadius, int nToolNum, const int nPhase)
|
||||
double dHeight, double dRadius, int nToolNum)
|
||||
{
|
||||
bool bOk = true ;
|
||||
//// tolgo il volume del cilindro iniziale e finale del moto
|
||||
//if ( nPhase == VolZmap::MillingPhase::COUNT_START_VOL) {
|
||||
// // in base all'orientamento del tool scelgo la funzione adatta
|
||||
// if ( vtLs.SqLenXY() < EPS_SMALL * EPS_SMALL)
|
||||
// bOk = bOk && CompCyl_ZDrilling( nGrid, ptS, ptS, vtLs, dHeight, dRadius, nToolNum) ;
|
||||
// else
|
||||
// bOk = bOk && CompCyl_Drilling( nGrid, ptS, ptS, vtLs, dHeight, dRadius, false, false, nToolNum) ;
|
||||
//}
|
||||
//if ( nPhase == VolZmap::MillingPhase::COUNT_END_VOL) {
|
||||
// if ( vtLe.SqLenXY() < EPS_SMALL * EPS_SMALL)
|
||||
// bOk = bOk && CompCyl_ZDrilling( nGrid, ptE, ptE, vtLe, dHeight, dRadius, nToolNum) ;
|
||||
// else
|
||||
// bOk = bOk && CompCyl_Drilling( nGrid, ptE, ptE, vtLe, dHeight, dRadius, false, false, nToolNum) ;
|
||||
//}
|
||||
|
||||
// tolgo il valume spazzato dal tool durante il movimento
|
||||
bOk = bOk && Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, dRadius, nToolNum) ;
|
||||
@@ -1938,7 +2058,7 @@ VolZmap::CompCyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::Cyl_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, const int nPhase, double dHeightCorr)
|
||||
VolZmap::Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr)
|
||||
{
|
||||
// tolgo il volume dei cilindri all'inizio e alla fine del tratto e poi uso delle bilineari per approssimare il volume spazzato
|
||||
|
||||
@@ -1950,13 +2070,12 @@ VolZmap::Cyl_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co
|
||||
double dHeight = CurrTool.GetHeigth() - dHeightCorr ;
|
||||
double dRadius = CurrTool.GetRadius() ;
|
||||
|
||||
//return CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum, nPhase) ;
|
||||
return false ;
|
||||
return CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CylBall_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, const int nPhase)
|
||||
VolZmap::CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum)
|
||||
{
|
||||
// Controllo utensile
|
||||
if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size()))
|
||||
@@ -1964,20 +2083,19 @@ VolZmap::CylBall_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE
|
||||
Tool& CurrTool = m_vTool[m_nCurrTool] ;
|
||||
double dHeight = CurrTool.GetHeigth() - CurrTool.GetTipRadius() ;
|
||||
double dRadius = CurrTool.GetRadius() ;
|
||||
//CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dRadius, dHeight, nToolNum, nPhase) ;
|
||||
return false ;
|
||||
|
||||
CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum) ;
|
||||
|
||||
// devo poi togliere la sfera tip iniziale, la sfera tip finale e il cilindro del volume spazzato
|
||||
Point3d ptTipS = ptS - vtLs * ( CurrTool.GetHeigth()) ;
|
||||
Point3d ptTipE = ptE - vtLe * ( CurrTool.GetHeigth()) ;
|
||||
Point3d ptTipS = ptS.front() - vtLs.front() * ( CurrTool.GetHeigth() ) ;
|
||||
Point3d ptTipE = ptE.back() - vtLe.back() * ( CurrTool.GetHeigth() ) ;
|
||||
CompBall_Milling( nGrid, ptTipS, ptTipE, CurrTool.GetRadius(), CurrTool.GetToolNum()) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CompConus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, double dHei, double dMaxRad, double dMinRad,
|
||||
bool bTapB, bool bTapT, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int nPhase)
|
||||
VolZmap::CompConus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, double dHei, double dMaxRad, double dMinRad,
|
||||
bool bTapB, bool bTapT, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum)
|
||||
{
|
||||
// come per le altre funzioni che lavorano con i coni, se il cono è inverso ( che va allargandosi andando verso il fondo del tool), allora i vtL passati sono invertiti rispetto a quelli
|
||||
// reali del tool e i punti ptS e ptE sono invertiti( così come dMaxRad e dMinRad)
|
||||
@@ -1987,34 +2105,15 @@ VolZmap::CompConus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& p
|
||||
// Controllo utensile
|
||||
if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size()))
|
||||
return false ;
|
||||
Tool& CurrTool = m_vTool[m_nCurrTool] ;
|
||||
|
||||
bool bOk = true ;
|
||||
// elimino la parte occupata dal tool all'inizio e alla fine del tratto lavorato
|
||||
if ( nPhase == VolZmap::MillingPhase::COUNT_START_VOL) {
|
||||
// in base all'orientamento del tool scelgo la funzione adatta
|
||||
if ( vtLs.SqLenXY() < EPS_SMALL * EPS_SMALL)
|
||||
bOk = bOk && CompConus_ZDrilling( nGrid, ptS, ptS, vtLs, dHei, dMaxRad, dMinRad, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
else
|
||||
bOk = bOk && CompConus_Drilling( nGrid, ptS, ptS, vtLs, dHei, dMaxRad, dMinRad, false, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
if ( nPhase == VolZmap::MillingPhase::COUNT_END_VOL) {
|
||||
if ( vtLe.SqLenXY() < EPS_SMALL * EPS_SMALL)
|
||||
bOk = bOk && CompConus_ZDrilling( nGrid, ptE, ptE, vtLe, dHei, dMaxRad, dMinRad, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
else
|
||||
bOk = bOk && CompConus_Drilling( nGrid, ptE, ptE, vtLe, dHei, dMaxRad, dMinRad, false, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
//Tool& CurrTool = m_vTool[m_nCurrTool] ;
|
||||
|
||||
// tolgo il valume spazzato dal tool durante il movimento
|
||||
//bOk = bOk && Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHei, dMaxRad, dMinRad, nToolNum) ;
|
||||
return false ;
|
||||
|
||||
return bOk ;
|
||||
return Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHei, dMaxRad, dMinRad, nToolNum) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::Conus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, const int nPhase)
|
||||
VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum)
|
||||
{
|
||||
// Controllo utensile
|
||||
if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size()))
|
||||
@@ -2028,21 +2127,34 @@ VolZmap::Conus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
double dStemHeigth = dHeight - CurrTool.GetTipHeigth() ;
|
||||
|
||||
// elimino la parte del volume spazzato dalla parte cilindrica del tool
|
||||
Cyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, nToolNum, nPhase, CurrTool.GetTipHeigth()) ;
|
||||
Cyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, nToolNum, CurrTool.GetTipHeigth()) ;
|
||||
|
||||
// elimino la parte spazzata dalla punta conica del tool
|
||||
if ( CurrTool.GetTipRadius() < dRadius) {
|
||||
// Trapano
|
||||
Point3d ptSConus = ptS - dStemHeigth * vtLs ;
|
||||
Point3d ptEConus = ptE - dStemHeigth * vtLe ;
|
||||
PNTVECTOR ptSConus( ptS.size()) ;
|
||||
PNTVECTOR ptEConus( ptE.size()) ;
|
||||
for ( int i = 0 ; i < int( ptS.size()); ++i) {
|
||||
ptSConus[i] = ptS[i] - dStemHeigth * vtLs[i] ;
|
||||
ptEConus[i] = ptE[i] - dStemHeigth * vtLe[i] ;
|
||||
}
|
||||
CompConus_5AxisMilling( nGrid, ptSConus, ptEConus, vtLs, vtLe, dHeight,
|
||||
dRadius, dTipRadius, true, false, V_NULL, V_NULL, CurrTool.GetToolNum(), nPhase) ;
|
||||
dRadius, dTipRadius, true, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
else {
|
||||
Point3d ptSInvertedConus = ptS - CurrTool.GetHeigth() * vtLs ;
|
||||
Point3d ptEInvertedConus = ptE - CurrTool.GetHeigth() * vtLe ;
|
||||
CompConus_5AxisMilling( nGrid, ptSInvertedConus, ptEInvertedConus, - vtLs, - vtLe, dHeight,
|
||||
dTipRadius, dRadius, false, true, V_NULL, V_NULL, CurrTool.GetToolNum(), nPhase) ;
|
||||
double dHeight = CurrTool.GetHeigth() ;
|
||||
PNTVECTOR ptSInvertedConus( ptS.size()) ;
|
||||
PNTVECTOR ptEInvertedConus( ptS.size()) ;
|
||||
VCT3DVECTOR vNewVtLs( vtLs.size()) ;
|
||||
VCT3DVECTOR vNewVtLe( vtLe.size()) ;
|
||||
for ( int i = 0 ; i < int( ptS.size()); ++i) {
|
||||
ptSInvertedConus[i] = ptS[i] - dHeight * vtLs[i] ;
|
||||
ptEInvertedConus[i] = ptE[i] - dHeight * vtLe[i] ;
|
||||
vNewVtLs[i] = - vtLs[i] ;
|
||||
vNewVtLe[i] = - vtLe[i] ;
|
||||
}
|
||||
CompConus_5AxisMilling( nGrid, ptSInvertedConus, ptEInvertedConus, vNewVtLs, vNewVtLe, dHeight,
|
||||
dTipRadius, dRadius, false, true, V_NULL, V_NULL, CurrTool.GetToolNum()) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -2050,7 +2162,7 @@ VolZmap::Conus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, const int nPhase)
|
||||
VolZmap::SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe)
|
||||
{
|
||||
// Controllo utensile
|
||||
if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size()))
|
||||
@@ -2059,13 +2171,13 @@ VolZmap::SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR&
|
||||
|
||||
switch ( CurrTool.GetType()) {
|
||||
case Tool::GEN :
|
||||
return GenTool_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), nPhase) ;
|
||||
//case Tool::CYLMILL :
|
||||
// return Cyl_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), nPhase) ;
|
||||
//case Tool::BALLMILL :
|
||||
// return CylBall_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), nPhase) ;
|
||||
//case Tool::CONEMILL :
|
||||
// return Conus_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), nPhase) ;
|
||||
return GenTool_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum()) ;
|
||||
case Tool::CYLMILL :
|
||||
return Cyl_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum()) ;
|
||||
case Tool::BALLMILL :
|
||||
return CylBall_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum()) ;
|
||||
case Tool::CONEMILL :
|
||||
return Conus_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum()) ;
|
||||
case Tool::MORTISER :
|
||||
return false ; // in realtà potremmo accettare un moto con un angolo solo along
|
||||
case Tool::CHISEL :
|
||||
@@ -2102,32 +2214,34 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
|
||||
if ( dTipLen / nStepCnt < 0.1 * dToolCrad)
|
||||
dK = 0 ;
|
||||
// Divido il movimento in tratti con direzione utensile costante
|
||||
bool bOk = true ;
|
||||
|
||||
//////// debug - vecchia modalità
|
||||
//Point3d ptSt = ptPs ;
|
||||
//for ( int i = 0 ; i <= nStepCnt && bOk ; ++ i)
|
||||
//{
|
||||
////////// debug - vecchia modalità
|
||||
// double dPosCoeff, dDirCoeff ;
|
||||
// if ( i < nStepCnt) {
|
||||
// dPosCoeff = ( i + 0.5) / nStepCnt ;
|
||||
// dDirCoeff = double( i) / nStepCnt ;
|
||||
// }
|
||||
// else {
|
||||
// dPosCoeff = 1 ;
|
||||
// dDirCoeff = 1 ;
|
||||
// }
|
||||
// Point3d ptEn = Media( ptPs, ptPe, dPosCoeff) ;
|
||||
// Vector3d vtD = Media( vtDs, vtDe, dDirCoeff) ; vtD.Normalize() ;
|
||||
// Vector3d vtA = Media( vtAs, vtAe, dDirCoeff) ; vtA.Normalize() ;
|
||||
|
||||
// bOk = bOk && MillingTranslationStep( ptSt, ptEn, vtD, vtA) ;
|
||||
|
||||
//// aggiorno prossimo inizio
|
||||
// ptSt = ptEn ;
|
||||
////////// debug - vecchia modalità
|
||||
//}
|
||||
//bool bOk = true ;
|
||||
//for ( int i = 0 ; i <= nStepCnt && bOk ; ++ i) {
|
||||
// double dStCoeff, dEnCoeff, dDirCoeff ;
|
||||
// if ( i == 0) {
|
||||
// dStCoeff = 0 ;
|
||||
// dEnCoeff = dK / nStepCnt ;
|
||||
// dDirCoeff = 0 ;
|
||||
// }
|
||||
// else if ( i < nStepCnt) {
|
||||
// dStCoeff = ( i - dK) / nStepCnt ;
|
||||
// dEnCoeff = ( i + dK) / nStepCnt ;
|
||||
// dDirCoeff = double( i) / nStepCnt ;
|
||||
// }
|
||||
// else {
|
||||
// dStCoeff = ( nStepCnt - dK) / nStepCnt ;
|
||||
// dEnCoeff = 1 ;
|
||||
// dDirCoeff = 1 ;
|
||||
// }
|
||||
// Point3d ptSt = Media( ptPs, ptPe, dStCoeff) ;
|
||||
// Point3d ptEn = Media( ptPs, ptPe, dEnCoeff) ;
|
||||
// Vector3d vtD = Media( vtDs, vtDe, dDirCoeff) ; vtD.Normalize() ;
|
||||
// Vector3d vtA = Media( vtAs, vtAe, dDirCoeff) ; vtA.Normalize() ;
|
||||
// bOk = bOk && MillingTranslationStep( ptSt, ptEn, vtD, vtA) ;
|
||||
// // aggiorno prossimo inizio
|
||||
// ptSt = ptEn ;
|
||||
//}
|
||||
//////// debug - vecchia modalità
|
||||
|
||||
|
||||
@@ -2144,7 +2258,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
|
||||
vector<Vector3d[N_MAPS]> vtLs( nStepCnt + 1) ;
|
||||
vector<Vector3d[N_MAPS]> vtLe( nStepCnt + 1) ;
|
||||
|
||||
for ( int i = 0 ; i <= nStepCnt && bOk ; ++ i) {
|
||||
for ( int i = 0 ; i <= nStepCnt ; ++ i) {
|
||||
//// replico il tutto ma tenendo degli step più ampi e usando i veri vettori di start e end del tratto
|
||||
double dPosCoeffE, dDirCoeffE, dPosCoeffS, dDirCoeffS ;
|
||||
dPosCoeffS = double( i) / (nStepCnt + 1) ;
|
||||
@@ -2158,51 +2272,61 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
|
||||
Point3d ptEni = Media( ptPs, ptPe, i != nStepCnt ? dPosCoeffE : (dPosCoeffE + dCorr)) ;
|
||||
Vector3d vtDEi = Media( vtDs, vtDe, i != nStepCnt ? dDirCoeffE : (dPosCoeffE + dCorr)) ; vtDEi.Normalize() ;
|
||||
|
||||
int nPhase = VolZmap::MillingPhase::ONLY_LATERAL_SURF ;
|
||||
if ( i == 0)
|
||||
nPhase = VolZmap::MillingPhase::COUNT_START_VOL ;
|
||||
if ( i == nStepCnt)
|
||||
nPhase = VolZmap::MillingPhase::COUNT_END_VOL ;
|
||||
|
||||
InitializePointsAndVectors( ptSti, ptEni, vtDSi, vtDEi, ptLs[i], ptLe[i], vtLs[i], vtLe[i]) ;
|
||||
}
|
||||
|
||||
///// decommentare solo per debug
|
||||
for( int j = 0 ; j < N_MAPS; ++j) {
|
||||
PNTVECTOR ptLs_j( nStepCnt + 1) ;
|
||||
PNTVECTOR ptLe_j( nStepCnt + 1) ;
|
||||
VCT3DVECTOR vtLs_j( nStepCnt + 1) ;
|
||||
VCT3DVECTOR vtLe_j( nStepCnt + 1) ;
|
||||
/////// decommentare solo per debug
|
||||
//bool bOk = true ;
|
||||
//for( int j = 0 ; j < N_MAPS; ++j) {
|
||||
// PNTVECTOR ptLs_j( nStepCnt + 1) ;
|
||||
// PNTVECTOR ptLe_j( nStepCnt + 1) ;
|
||||
// VCT3DVECTOR vtLs_j( nStepCnt + 1) ;
|
||||
// VCT3DVECTOR vtLe_j( nStepCnt + 1) ;
|
||||
// for ( int z = 0 ; z <= nStepCnt ; ++z) {
|
||||
// ptLs_j[z] = ptLs[z][j] ;
|
||||
// ptLe_j[z] = ptLe[z][j] ;
|
||||
// vtLs_j[z] = vtLs[z][j] ;
|
||||
// vtLe_j[z] = vtLe[z][j] ;
|
||||
// }
|
||||
// SelectGeneralMotion( j, ptLs_j, ptLe_j, vtLs_j,vtLe_j) ;
|
||||
//}
|
||||
/////// decommentare solo per debug
|
||||
|
||||
// Ciclo sulle mappe
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( m_nMapNum) ;
|
||||
|
||||
vector<PNTVECTOR> ptLs_j( m_nMapNum) ;
|
||||
vector<PNTVECTOR> ptLe_j( m_nMapNum) ;
|
||||
vector<VCT3DVECTOR> vtLs_j( m_nMapNum) ;
|
||||
vector<VCT3DVECTOR> vtLe_j( m_nMapNum) ;
|
||||
for( int p = 0 ; p < m_nMapNum ; ++p) {
|
||||
ptLs_j[p].resize(nStepCnt + 1) ;
|
||||
ptLe_j[p].resize(nStepCnt + 1) ;
|
||||
vtLs_j[p].resize(nStepCnt + 1) ;
|
||||
vtLe_j[p].resize(nStepCnt + 1) ;
|
||||
for ( int z = 0 ; z <= nStepCnt ; ++z) {
|
||||
ptLs_j[z] = ptLs[z][j] ;
|
||||
ptLe_j[z] = ptLe[z][j] ;
|
||||
vtLs_j[z] = vtLs[z][j] ;
|
||||
vtLe_j[z] = vtLe[z][j] ;
|
||||
ptLs_j[p][z] = ptLs[z][p] ;
|
||||
ptLe_j[p][z] = ptLe[z][p] ;
|
||||
vtLs_j[p][z] = vtLs[z][p] ;
|
||||
vtLe_j[p][z] = vtLe[z][p] ;
|
||||
}
|
||||
int nPhase = 0 ;
|
||||
SelectGeneralMotion( j, ptLs_j, ptLe_j, vtLs_j,vtLe_j, nPhase) ;
|
||||
}
|
||||
|
||||
//// Ciclo sulle mappe
|
||||
//vector< future<bool>> vRes ;
|
||||
//vRes.resize( m_nMapNum) ;
|
||||
//for ( int j = 0 ; j < m_nMapNum ; ++ j) {
|
||||
// vRes[j] = async( launch::async, &VolZmap::SelectGeneralMotion, this, j, cref( ptLs[j]), cref( ptLe[j]), cref( vtLs[j]), cref( vtLe[j]), nPhase) ;
|
||||
//}
|
||||
//bool bOk = true ;
|
||||
//int nTerminated = 0 ;
|
||||
//while ( nTerminated < m_nMapNum) {
|
||||
// for ( int j = 0 ; j < m_nMapNum ; ++ j) {
|
||||
// if ( vRes[j].valid() && vRes[j].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
// bOk = vRes[j].get() && bOk ;
|
||||
// ++ nTerminated ;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
for ( int j = 0 ; j < m_nMapNum ; ++ j) {
|
||||
vRes[j] = async( launch::async, &VolZmap::SelectGeneralMotion, this, j, cref( ptLs_j[j]), cref( ptLe_j[j]), cref( vtLs_j[j]), cref( vtLe_j[j])) ;
|
||||
}
|
||||
bool bOk = true ;
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < m_nMapNum) {
|
||||
for ( int j = 0 ; j < m_nMapNum ; ++ j) {
|
||||
if ( vRes[j].valid() && vRes[j].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[j].get() && bOk ;
|
||||
++ nTerminated ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////debug
|
||||
// SaveGeoObj( vGeo, "D:/Temp/VirtualMilling/5axisAdvanced/finalApprox.nge", 2) ;
|
||||
////debug
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -2215,32 +2339,32 @@ VolZmap::MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const
|
||||
Vector3d vtLs[N_MAPS] ;
|
||||
Vector3d vtALs[N_MAPS] ;
|
||||
InitializePointsAndVectors( ptPs, ptPe, vtD, vtA, ptLs, ptLe, vtLs, vtALs) ;
|
||||
// Ciclo sulle mappe (scommentare solo per DEBUG)
|
||||
{
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
bOk = SelectMotion( i, ptLs[i], ptLe[i], vtLs[i], vtALs[i]) && bOk ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//// Ciclo sulle mappe
|
||||
// vector< future<bool>> vRes ;
|
||||
// vRes.resize( m_nMapNum) ;
|
||||
// for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
// vRes[i] = async( launch::async, &VolZmap::SelectMotion, this, i, cref( ptLs[i]), cref( ptLe[i]), cref( vtLs[i]), cref( vtALs[i])) ;
|
||||
// }
|
||||
// bool bOk = true ;
|
||||
// int nTerminated = 0 ;
|
||||
// while ( nTerminated < m_nMapNum) {
|
||||
//// Ciclo sulle mappe (scommentare solo per DEBUG)
|
||||
// {
|
||||
// bool bOk = true ;
|
||||
// for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
// if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
// bOk = vRes[i].get() && bOk ;
|
||||
// ++ nTerminated ;
|
||||
// }
|
||||
// bOk = SelectMotion( i, ptLs[i], ptLe[i], vtLs[i], vtALs[i]) && bOk ;
|
||||
// }
|
||||
// return true ;
|
||||
// }
|
||||
// return bOk ;
|
||||
|
||||
// Ciclo sulle mappe
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( m_nMapNum) ;
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
vRes[i] = async( launch::async, &VolZmap::SelectMotion, this, i, cref( ptLs[i]), cref( ptLe[i]), cref( vtLs[i]), cref( vtALs[i])) ;
|
||||
}
|
||||
bool bOk = true ;
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < m_nMapNum) {
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[i].get() && bOk ;
|
||||
++ nTerminated ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user