diff --git a/VolZmap.h b/VolZmap.h index 1bcbf2c..8e9c61f 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -262,7 +262,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ; bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) ; - bool SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe) ; + bool SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int n5AxisType) ; bool SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtL, const Vector3d& vtAL) ; bool InitializePointsAndVectors( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtDs, const Vector3d& vtAs, Point3d ptLs[3], Point3d ptLe[3], Vector3d vtLs[3], Vector3d vtALs[3]) ; @@ -301,10 +301,10 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ; bool GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ; // lavorazioni a 5 assi - bool GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum) ; - bool Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr = 0) ; - bool CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum) ; - bool Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum) ; + bool GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) ; + bool Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr = 0, int n5AxisType) ; + bool CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) ; + bool Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) ; // COMPONENTI // Asse di simmetria diretto come l'asse Z @@ -342,11 +342,11 @@ class VolZmap : public IVolZmap, public IGeoObjRW const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp // lavorazioni a 5 assi bool Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, - double dHeight, double dMaxRad, double dMinRad, int nToolNum) ; + double dHeight, double dMaxRad, double dMinRad, int nToolNum, int n5AxisType) ; bool CompCyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, - double dHeight, double dRadius, int nToolNum) ; + double dHeight, double dRadius, int nToolNum,int n5AxisType) ; bool CompConus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtToolDirS, const VCT3DVECTOR& vtToolDirE, double dHei, double dMaxRad, double dMinRad, - bool bTapB, bool bTapT,const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ; + bool bTapB, bool bTapT,const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) ; // Generica traslazione sfera bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad, int nToolNum) ; @@ -474,6 +474,13 @@ class VolZmap : public IVolZmap, public IGeoObjRW COUNT_START_END = 3 } ; + enum Move5Axis{ + ALONG_CONVEX = 0 , + ALONG_CONCAVE = 1 , + ACROSS = 2 , + NO_BASE_INTERS = 3 + } ; + enum CuttingSurface { NONE = -1, TOOL = 0 , diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 36b6811..0c451c8 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -23,7 +23,7 @@ #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EGkSurfBezier.h" #include "/EgtDev/Include/ENkPolynomialRoots.h" -//#include "/EgtDev/Include/EGkGeoObjSave.h" // debug +#include "/EgtDev/Include/EGkGeoObjSave.h" // debug #include using namespace std ; @@ -1037,6 +1037,8 @@ VolZmap::MillingStep( int nCurrTool, return MillingStep( nCurrTool, ptPs, vtDs, Vector3d(), ptPe, vtDe, Vector3d()) ; } +static double dTotCount = 0. ; + //---------------------------------------------------------------------------- bool VolZmap::MillingStep( int nCurrTool, @@ -1092,6 +1094,15 @@ VolZmap::MillingStep( int nCurrTool, bOk = MillingGeneralMotionStep( ptPLs, vtDLs, vtALs, ptPLe, vtDLe, vtALe) ; { + //// debug per 5 assi + //double dPartCount = Counter.Stop() ; + //if ( ! AreSameVectorApprox( vtDLs, vtDLe)) { + // dTotCount += dPartCount ; + // string sOut = "Calc5Axis=" + ToString( dTotCount, 3) ; + // LOG_INFO( GetEGkLogger(), sOut.c_str()) + //} + ////debug per 5 assi + string sOut = "Calc=" + ToString( Counter.Stop(), 3) ; LOG_INFO( GetEGkLogger(), sOut.c_str()) Counter.Start() ; @@ -1157,7 +1168,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) +VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) { // Controllo utensile if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) @@ -1225,14 +1236,14 @@ 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) ; + CompCyl_5AxisMilling( nGrid, ptI, ptF, vtLs, vtLe, dHeight, dRadius, nToolNum, n5AxisType) ; } // 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) ; + bTapB, bTapT, vtNormSt, vtNormEn, nToolNum, n5AxisType) ; } // altrimenti X crescente, è un cono con vettore opposto a quello dell'utensile else { @@ -1253,7 +1264,7 @@ VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& vNewVtLe[i] = -vtLe[i] ; } CompConus_5AxisMilling( nGrid, ptIn, ptFn, vNewVtLs, vNewVtLe, dHeight, dMaxRad, dMinRad, - bTapT, bTapB, vtNormEn, vtNormSt, nToolNum) ; + bTapT, bTapB, vtNormEn, vtNormSt, nToolNum, n5AxisType) ; } // Passo alla curva successiva pPrevCurve = pCurve ; @@ -1297,15 +1308,15 @@ VolZmap::GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& return true ; } -////debug -//static vector vGeo ; -////static int nCount = 0 ; -////debug +//debug +static vector vGeo ; +//static int nCount = 0 ; +//debug //---------------------------------------------------------------------------- bool VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, - double dHeight, double dMaxRad, double dMinRad, int nToolNum) + double dHeight, double dMaxRad, double dMinRad, int nToolNum, int n5AxisType) { // tolgo il volume spazzato dal tool durante il movimento // Verifica sull'interferenza con lo Zmap @@ -1314,15 +1325,13 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt return true ; int nStepCnt = int( ptS.size()) ; - - // vettori di riferimento per trovare i punti ausiliari int nDegU = 1 ; int nDegV = 1 ; int nSpanU = 1 ; int nSpanV = 1 ; bool bRat = false ; - 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 + 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 PNTVECTOR d ; Vector3d q = Z_AX ; DBLVECTOR A1, B1, C1, A2, B2, C2 ; @@ -1510,16 +1519,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) ; @@ -2046,19 +2055,19 @@ 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) + double dHeight, double dRadius, int nToolNum, int n5AxisType) { bool bOk = true ; // tolgo il valume spazzato dal tool durante il movimento - bOk = bOk && Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, dRadius, nToolNum) ; + bOk = bOk && Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, dRadius, nToolNum, n5AxisType) ; return bOk ; } //---------------------------------------------------------------------------- bool -VolZmap::Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr) +VolZmap::Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr, int n5AxisType) { // tolgo il volume dei cilindri all'inizio e alla fine del tratto e poi uso delle bilineari per approssimare il volume spazzato @@ -2070,12 +2079,12 @@ VolZmap::Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE double dHeight = CurrTool.GetHeigth() - dHeightCorr ; double dRadius = CurrTool.GetRadius() ; - return CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum) ; + return CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum, n5AxisType) ; } //---------------------------------------------------------------------------- bool -VolZmap::CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum) +VolZmap::CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) { // Controllo utensile if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) @@ -2083,7 +2092,7 @@ VolZmap::CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& Tool& CurrTool = m_vTool[m_nCurrTool] ; double dHeight = CurrTool.GetHeigth() - CurrTool.GetTipRadius() ; double dRadius = CurrTool.GetRadius() ; - CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum) ; + CompCyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHeight, dRadius, nToolNum, n5AxisType) ; // devo poi togliere la sfera tip iniziale, la sfera tip finale e il cilindro del volume spazzato Point3d ptTipS = ptS.front() - vtLs.front() * ( CurrTool.GetHeigth() ) ; @@ -2095,7 +2104,7 @@ VolZmap::CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& //---------------------------------------------------------------------------- bool 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) + bool bTapB, bool bTapT, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) { // 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) @@ -2105,15 +2114,14 @@ VolZmap::CompConus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTO // Controllo utensile if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) return false ; - //Tool& CurrTool = m_vTool[m_nCurrTool] ; // tolgo il valume spazzato dal tool durante il movimento - return Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHei, dMaxRad, dMinRad, nToolNum) ; + return Comp_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, dHei, dMaxRad, dMinRad, nToolNum, n5AxisType) ; } //---------------------------------------------------------------------------- bool -VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum) +VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType) { // Controllo utensile if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) @@ -2127,7 +2135,7 @@ VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& p double dStemHeigth = dHeight - CurrTool.GetTipHeigth() ; // elimino la parte del volume spazzato dalla parte cilindrica del tool - Cyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, nToolNum, CurrTool.GetTipHeigth()) ; + Cyl_5AxisMilling( nGrid, ptS, ptE, vtLs, vtLe, nToolNum, CurrTool.GetTipHeigth(), n5AxisType) ; // elimino la parte spazzata dalla punta conica del tool if ( CurrTool.GetTipRadius() < dRadius) { @@ -2139,7 +2147,7 @@ VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& p 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()) ; + dRadius, dTipRadius, true, false, V_NULL, V_NULL, CurrTool.GetToolNum(), n5AxisType) ; } else { double dHeight = CurrTool.GetHeigth() ; @@ -2154,7 +2162,7 @@ VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& p vNewVtLe[i] = - vtLe[i] ; } CompConus_5AxisMilling( nGrid, ptSInvertedConus, ptEInvertedConus, vNewVtLs, vNewVtLe, dHeight, - dTipRadius, dRadius, false, true, V_NULL, V_NULL, CurrTool.GetToolNum()) ; + dTipRadius, dRadius, false, true, V_NULL, V_NULL, CurrTool.GetToolNum(), n5AxisType) ; } return true ; @@ -2162,7 +2170,7 @@ VolZmap::Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& p //---------------------------------------------------------------------------- bool -VolZmap::SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe) +VolZmap::SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int n5AxisType) { // Controllo utensile if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) @@ -2171,19 +2179,45 @@ 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()) ; - 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 : - return false ; + return GenTool_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), n5AxisType) ; + //case Tool::CYLMILL : + // return Cyl_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), n5AxisType) ; + //case Tool::BALLMILL : + // return CylBall_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), n5AxisType) ; + //case Tool::CONEMILL : + // return Conus_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), n5AxisType) ; + //case Tool::MORTISER : + // return false ; // in realtà potremmo accettare un moto con un angolo solo along + //case Tool::CHISEL : + // return false ; } + + //switch( nType) { + //case VolZmap::Move5Axis::ALONG : { + // switch ( CurrTool.GetType()) { + // case Tool::GEN : + // 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 : + // // return false ; + // } + //} + //case VolZmap::Move5Axis::ACROSS: { + // // da aggiungere i casi con la gestione solo across + //} + //case VolZmap::Move5Axis::ALONG_ACROSS: { + // // casi con la gestione ibrida + //} + //} + return false ; } @@ -2202,21 +2236,70 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co const double ANG_ACROSS_STEP = 1.0 ; const double ANG_ALONG_STEP = 1.0 ; int nStepCnt = int( max( { abs( dAlongAngDeg) / ANG_ALONG_STEP, abs( dAcrossAngDeg) / ANG_ACROSS_STEP, 1.})) ; - // Calcolo coefficiente di riduzione movimenti con direzione costante per evitare extra tagli - // !!! In attesa dell'algoritmo esatto !!! - double dToolLen = m_vTool[m_nCurrTool].GetHeigth() ; - double dToolCrad = m_vTool[m_nCurrTool].GetCornRadius() ; - Vector3d vtBase = ptPe - ptPs ; - double dBaseLen = vtBase.Len() ; - Vector3d vtTip = ptPe - dToolLen * vtDe - ( ptPs - dToolLen * vtDs) ; - double dTipLen = vtTip.Len() ; - double dK = ( vtBase * vtTip > EPS_SMALL ? dTipLen / dBaseLen : 0) ; - if ( dTipLen / nStepCnt < 0.1 * dToolCrad) - dK = 0 ; + + Vector3d vtDir = ptPe - ptPs ; + double dH = vtDir * vtDs ; + double dHStep = abs( dH / nStepCnt) ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + double dRad = CurrTool.GetRadius() ; + bool bAcross = abs( dAcrossAngDeg) > EPS_SMALL ; + bool bAcrossInters = false ; + + bool bAlong = abs( dAlongAngDeg) > EPS_SMALL ; + bool bAlongInters = false ; + bool bAlongAcrossInters = false ; + if ( bAcross && bAlong) { + Vector3d vtInters = vtDs ^ vtDe ; + Vector3d vtMaxDir = vtInters ^ vtDe ; + if ( ! vtMaxDir.Normalize()) + return false ; + vtMaxDir *= dRad ; + if ( vtMaxDir * vtDs > dHStep) { + bAcrossInters = true ; + bAlongInters = true ; + } + } + else if ( bAcross) + bAcrossInters = dRad * sin( dAcrossAngDeg) > dHStep ; + else if ( bAlong) + bAlongInters = dRad * sin( dAlongAngDeg) > dHStep ; + + int n5AxisType = VolZmap::Move5Axis::NO_BASE_INTERS ; + if ( bAcross && bAlong && ( bAcrossInters || bAlongInters)) + n5AxisType = VolZmap::Move5Axis::ACROSS ; + else if ( bAcross) { + if ( bAcrossInters) + n5AxisType = VolZmap::Move5Axis::ACROSS ; + else + n5AxisType = VolZmap::Move5Axis::NO_BASE_INTERS ; + } + else if ( bAlong) { + if ( bAlongInters) { + if ( dAlongAngDeg > 0) + n5AxisType = VolZmap::Move5Axis::ALONG_CONVEX ; + else + n5AxisType = VolZmap::Move5Axis::ALONG_CONCAVE ; + } + else + n5AxisType = VolZmap::Move5Axis::NO_BASE_INTERS ; + } + + // Divido il movimento in tratti con direzione utensile costante //////// debug - vecchia modalità //bool bOk = true ; + // // Calcolo coefficiente di riduzione movimenti con direzione costante per evitare extra tagli + // !!! In attesa dell'algoritmo esatto !!! + //double dToolLen = m_vTool[m_nCurrTool].GetHeigth() ; + //double dToolCrad = m_vTool[m_nCurrTool].GetCornRadius() ; + //Vector3d vtBase = ptPe - ptPs ; + //double dBaseLen = vtBase.Len() ; + //Vector3d vtTip = ptPe - dToolLen * vtDe - ( ptPs - dToolLen * vtDs) ; + //double dTipLen = vtTip.Len() ; + //double dK = ( vtBase * vtTip > EPS_SMALL ? dTipLen / dBaseLen : 0) ; + //if ( dTipLen / nStepCnt < 0.1 * dToolCrad) + //dK = 0 ; //for ( int i = 0 ; i <= nStepCnt && bOk ; ++ i) { // double dStCoeff, dEnCoeff, dDirCoeff ; // if ( i == 0) { @@ -2275,57 +2358,57 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co InitializePointsAndVectors( ptSti, ptEni, vtDSi, vtDEi, ptLs[i], ptLe[i], vtLs[i], vtLe[i]) ; } - /////// 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> vRes ; - vRes.resize( m_nMapNum) ; - - vector ptLs_j( m_nMapNum) ; - vector ptLe_j( m_nMapNum) ; - vector vtLs_j( m_nMapNum) ; - vector 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[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] ; - } - } - - 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])) ; - } + ///// decommentare solo per debug 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 < 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, n5AxisType) ; } + ///// decommentare solo per debug + + //// Ciclo sulle mappe + //vector< future> vRes ; + //vRes.resize( m_nMapNum) ; + + //vector ptLs_j( m_nMapNum) ; + //vector ptLe_j( m_nMapNum) ; + //vector vtLs_j( m_nMapNum) ; + //vector 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[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] ; + // } + //} + + //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 ; + // } + // } + //} return bOk ; }