diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 1c7a9ce..c77292e 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -1097,14 +1097,14 @@ 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 + // 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()) @@ -1755,6 +1755,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt } else { if( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS || n5AxisType == VolZmap::Move5Axis::ACROSS){ + // inferiori CurveArc cArcTipStart1, cArcTipEnd1, cArcTipStart2,cArcTipEnd2 ; if ( dSide > 0) { cArcTipStart1.SetC2PN( ptP1T, vPntTipStartFront[0], vPntTipStartFront[1], vtLs[s]) ; @@ -1780,7 +1781,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.emplace_back( cBezTipStart2->GetAllControlPoints()) ; PNTVECTOR vPntTipEnd2 = cBezTipEnd2->GetAllControlPoints() ; vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd2.begin(), vPntTipEnd2.end()) ; - // superfici superiori 1 + // superiori CurveArc cArcTopStart1, cArcTopEnd1, cArcTopStart2, cArcTopEnd2 ; if ( dSide > 0) { cArcTopStart1.SetC2PN( ptS[s], vPntTopStartBack[0], vPntTopStartBack[1], vtLs[s]) ; @@ -1794,6 +1795,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt cArcTopStart2.SetC2PN( ptS[s], vPntTopStartFront[2], vPntTopStartFront[1], vtLs[s]) ; cArcTopEnd2.SetC2PN( ptE[s], vPntTopEndFront[2], vPntTopEndFront[1], vtLe[s]) ; } + // superfici superiori 1 PtrOwner cBezTopStart1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopStart1, nDegU, bRat))) ; PtrOwner cBezTopEnd1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopEnd1, nDegU, bRat))) ; vvPtCtrl.emplace_back( cBezTopStart1->GetAllControlPoints()) ; @@ -1807,6 +1809,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd2.begin(), vPntTopEnd2.end()) ; // aggiungo le superfici bilineari anche nell'altro verso sia per il top che per il tip if( n5AxisType == VolZmap::Move5Axis::ACROSS) { + // inferiori CurveArc cArcTipStart1, cArcTipEnd1, cArcTipStart2, cArcTipEnd2 ; if ( dSide > 0) { cArcTipStart1.SetC2PN( ptP1T, vPntTipStartBack[1], vPntTipStartBack[0], vtLs[s]) ; @@ -1832,7 +1835,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.emplace_back( cBezTipStart2->GetAllControlPoints()) ; PNTVECTOR vPntTip2 = cBezTipEnd2->GetAllControlPoints() ; vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.begin(), vPntTip2.end()) ; - + // superiori CurveArc cArcTopStart1, cArcTopEnd1, cArcTopStart2, cArcTopEnd2 ; if ( dSide > 0) { cArcTopStart1.SetC2PN( ptS[s], vPntTopStartFront[1], vPntTopStartFront[0], vtLs[s]) ; @@ -1861,12 +1864,13 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt } } else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - // superfici superiori 1 + // superfici CurveArc cArcTopStart1, cArcTopEnd1, cArcTopStart2, cArcTopEnd2 ; cArcTopStart1.SetC2PN( ptS[s], vPntTopStartExF[1], vPntTopStartExF[0], vtLs[s]) ; cArcTopEnd1.SetC2PN( ptE[s], vPntTopEndExF[1], vPntTopEndExF[0], vtLe[s]) ; cArcTopStart2.SetC2PN( ptS[s], vPntTopStartExF[2], vPntTopStartExF[1], vtLs[s]) ; cArcTopEnd2.SetC2PN( ptE[s], vPntTopEndExF[2], vPntTopEndExF[1], vtLe[s]) ; + // superfici superiori 1 PtrOwner cBezTopStart1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopStart1, nDegU, bRat))) ; PtrOwner cBezTopEnd1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopEnd1, nDegU, bRat))) ; vvPtCtrl.emplace_back( cBezTopStart1->GetAllControlPoints()) ; @@ -1878,12 +1882,13 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.emplace_back( cBezTopStart2->GetAllControlPoints()) ; PNTVECTOR vPntTop2 = cBezTopEnd2->GetAllControlPoints() ; vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTop2.begin(), vPntTop2.end()) ; - // superfici superiori indietro 1 + // superfici CurveArc cArcTopStart3, cArcTopEnd3, cArcTopStart4, cArcTopEnd4 ; cArcTopStart3.SetC2PN( ptS[s], vPntTopStartExB[0], vPntTopStartExB[1], vtLs[s]) ; cArcTopEnd3.SetC2PN( ptE[s], vPntTopEndExB[0], vPntTopEndExB[1], vtLe[s]) ; cArcTopStart4.SetC2PN( ptS[s], vPntTopStartExB[1], vPntTopStartExB[2], vtLs[s]) ; cArcTopEnd4.SetC2PN( ptE[s], vPntTopEndExB[1], vPntTopEndExB[2], vtLe[s]) ; + // superfici superiori indietro 1 PtrOwner cBezTopStart3( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopStart3, nDegU, bRat))) ; PtrOwner cBezTopEnd3( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopEnd3, nDegU, bRat))) ; vvPtCtrl.emplace_back( cBezTopStart3->GetAllControlPoints()) ; @@ -1906,12 +1911,13 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip.begin(), vPntTip.end()) ; } else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - // inferiori 1 + // inferiori CurveArc cArcTipStart1, cArcTipEnd1, cArcTipStart2, cArcTipEnd2 ; cArcTipStart1.SetC2PN( ptP1T, vPntTipStartFront[0], vPntTipStartFront[1], vtLs[s]) ; cArcTipEnd1.SetC2PN( ptP2T, vPntTipEndFront[0], vPntTipEndFront[1], vtLe[s]) ; cArcTipStart2.SetC2PN( ptP1T, vPntTipStartFront[1], vPntTipStartFront[2], vtLs[s]) ; cArcTipEnd2.SetC2PN( ptP2T, vPntTipEndFront[1], vPntTipEndFront[2], vtLe[s]) ; + // inferiori 1 PtrOwner cBezTipStart1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTipStart1, nDegU, bRat))) ; PtrOwner cBezTipEnd1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTipEnd1, nDegU, bRat))) ; vvPtCtrl.emplace_back( cBezTipStart1->GetAllControlPoints()) ; @@ -1923,12 +1929,13 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.emplace_back( cBezTipStart2->GetAllControlPoints()) ; PNTVECTOR vPntTip2 = cBezTipEnd2->GetAllControlPoints() ; vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.begin(), vPntTip2.end()) ; - // inferiori indietro 1 + // inferiori CurveArc cArcTipStart3, cArcTipEnd3, cArcTipStart4, cArcTipEnd4 ; cArcTipStart3.SetC2PN( ptP1T, vPntTipStartBack[1], vPntTipStartBack[0], vtLs[s]) ; cArcTipEnd3.SetC2PN( ptP2T, vPntTipEndBack[1], vPntTipEndBack[0], vtLe[s]) ; cArcTipStart4.SetC2PN( ptP1T, vPntTipStartBack[2], vPntTipStartBack[1], vtLs[s]) ; cArcTipEnd4.SetC2PN( ptP2T, vPntTipEndBack[2], vPntTipEndBack[1], vtLe[s]) ; + // inferiori indietro 1 PtrOwner cBezTipStart3( GetBasicCurveBezier(ArcToBezierCurve( &cArcTipStart3, nDegU, bRat))) ; PtrOwner cBezTipEnd3( GetBasicCurveBezier(ArcToBezierCurve( &cArcTipEnd3, nDegU, bRat))) ; vvPtCtrl.emplace_back( cBezTipStart3->GetAllControlPoints()) ; @@ -1990,7 +1997,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStart2.begin(), vPntStart2.end()) ; // superfici di base dei tool - if ( (! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide < 0)) || + if ( (! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide < 0)) && n5AxisType != VolZmap::Move5Axis::ALONG_CONCAVE) { // start back tip CurveArc cArcTipStartBack1, cArcTipStartBack2 ; @@ -2019,7 +2026,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipStartFront2.begin(), vPntTipStartFront2.end()) ; } } - if ( ! ( ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide > 0) || + if ( ( ! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide > 0) || ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE))) { // end front tip CurveArc cArcTipEndFront1, cArcTipEndFront2 ; @@ -2049,7 +2056,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt } } - if ( (! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide > 0)) || + if ( (! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide > 0)) && n5AxisType != VolZmap::Move5Axis::ALONG_CONVEX) { // start back top CurveArc cArcTopStartBack1, cArcTopStartBack2 ; @@ -2078,7 +2085,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopStartFront2.begin(), vPntTopStartFront2.end()) ; } } - if ( ! ( ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide < 0) || + if ( ( ! ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && dSide < 0) || ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX))) { // end front top CurveArc cArcTopEndFront1, cArcTopEndFront2 ; @@ -2161,7 +2168,6 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt #endif // scorro tutti gli spilloni interessati - int nAllStepsSurfs = nTotSurf * nStepCnt ; int j = 0 ; int nLastForwardJ = -1 ; struct IntervalsToSubtract { @@ -2216,7 +2222,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt INTINTVECTOR vStartEndsX ; bool bXInclude = false ; IntersLineBezierSurfSet( ptLineStart, vtLineStart, vSurfBez, vIntersX, vSurfX) ; - if( vIntersX.size() > 0) { + if( vIntersX.size() > 1) { SortGroupInters( vIntersX, vStartEndsX, X_AX) ; // se ho più di una intersezione e il punto di studio è compreso tra questi punti allora le info lungo questa direzione mi dicono che sono interno al volume spazzato bXInclude = vIntersX[vStartEndsX.front().first].first.x < ptLineStart.x && vIntersX[vStartEndsX.back().second].first.x > ptLineStart.x ; @@ -2415,46 +2421,18 @@ 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(), n5AxisType) ; - //case Tool::CYLMILL : - // return Cyl_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), 0, 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 ; + case Tool::CYLMILL : + return Cyl_5AxisMilling( nGrid, ptPs, ptPe, vtLs, vtLe, CurrTool.GetToolNum(), 0, 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 ; } - - ///// questo swithc non dovrebbe servire - - //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 ; } @@ -2647,7 +2625,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co //} //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])) ; + // 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]), n5AxisType) ; //} //bool bOk = true ; //int nTerminated = 0 ;