diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index acf481d..377c90d 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -1708,917 +1708,203 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt // interseco con la prima metà del tool in posizione iniziale e con la seconda metà del tool in posizione finale // se sto trattando un cilindro - if ( dMaxRad - dMinRad < EPS_SMALL) { - // prima di calcolare l'intersezione verifico che ci sia interferenza con i box - if( bbStartCyl.SqDistFromPointXY( r) < EPS_ZERO) { - Frame3d frStartCyl ; - frStartCyl.Set( ptP1T, vtLs[0]) ; - Point3d pt1, pt2 ; - Vector3d vt1, vt2 ; - if ( IntersLineCylinder( r, Z_AX, frStartCyl, dHeight, dMaxRad, false, false, pt1, vt1, pt2, vt2)) { - bool bUpdate1 = false ; - bool bUpdate2 = false ; - bool bOnTopBase1 = ( pt1 - frStartCyl.Orig()) * frStartCyl.VersZ() > dHeight - EPS_SMALL ; - bool bOnBottomBase1 = ( pt1 - frStartCyl.Orig()) * frStartCyl.VersZ() < EPS_SMALL ; - bool bOnTopBase2 = ( pt2 - frStartCyl.Orig()) * frStartCyl.VersZ() > dHeight - EPS_SMALL ; - bool bOnBottomBase2 = ( pt2 - frStartCyl.Orig()) * frStartCyl.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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide1 = ( pt1 - frStartCyl.Orig()) * vtDirTipStartEx ; - double dTopBaseSide1 = ( pt1 - ( frStartCyl.Orig() + frStartCyl.VersZ() * dHeight))* vtDirTopStartEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase1) - bUpdate1 = dBottomBaseSide1 < 0 ; - else if ( bOnTopBase1) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase1) - bApproxedSideBottom = true ; - else if ( bOnTopBase1) - bUpdate1 = dTopBaseSide1 < 0 ; - } - if ( bOnBottomBase1 && bApproxedSideBottom) { - vvtTipStartAux.front().GetAngle(pt1 - frStartCyl.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 + BOOLVECTOR vbUpdate( 2) ; + PNTVECTOR vPntInters( 2) ; + VCT3DVECTOR vVtIntersNorm( 2) ; + // ciclo sulle due posizioni del tool : start e end della passata + for( int t = 0 ; t < 2 ; ++t) { + // prima di calcolare l'intersezione verifico che ci sia interferenza con i box + bool bBoxInters = false ; + if( t == 0) + bBoxInters = bbStartCyl.SqDistFromPointXY( r) < EPS_ZERO ; + else if ( t == 1) + bBoxInters = bbEndCyl.SqDistFromPointXY( r) < EPS_ZERO ; + + if( bBoxInters) { + Frame3d frTool ; + if ( t == 0) + frTool.Set( ptP1T, vtLs.front()) ; + else if ( t == 1) + frTool.Set( ptP2T, vtLe.back()) ; + + bool bIntersFound = false ; + // calcolo le intersezioni in base alla forma del tool: cilindro o cono + if ( dMaxRad - dMinRad < EPS_SMALL) + bIntersFound = IntersLineCylinder( r, Z_AX, frTool, dHeight, dMaxRad, false, false, vPntInters[0], vVtIntersNorm[0], vPntInters[1], vVtIntersNorm[1]) ; + else + bIntersFound = IntersLineConus( r, Z_AX, frTool, dTan, dMinH, dMaxH, false, false, vPntInters[0], vVtIntersNorm[0], vPntInters[1], vVtIntersNorm[1]) ; + + if ( bIntersFound) { + // ciclo sulle due intersezioni + fill(vbUpdate.begin(), vbUpdate.end(), false) ; + for( int p = 0 ; p < 2 ; ++p) { + bool bOnTopBase = ( vPntInters[p] - frTool.Orig() ) * frTool.VersZ() > dHeight - EPS_SMALL ; + bool bOnBottomBase = ( vPntInters[p] - frTool.Orig() ) * frTool.VersZ() < EPS_SMALL ; + // se ho un'intersezione su una base devo verificare se la devo considerare o no + if ( bOnBottomBase || bOnTopBase) { + // verifico se sono nella metà della base il cui contorno è in contatto con le bilineari + //base inferiore + double dSectorAng = 0 ; + bool bApproxedSideBottom = false ; + bool bApproxedSideTop = false ; + double dBottomBaseSide = 0 ; + if ( t == 0) + dBottomBaseSide = ( vPntInters[p] - frTool.Orig()) * vtDirTipStartEx ; + else if ( t == 1) + dBottomBaseSide = ( vPntInters[p] - frTool.Orig()) * vtDirTipEndEx ; + double dTopBaseSide = 0 ; + if ( t == 0) + dTopBaseSide = ( vPntInters[p] - ( frTool.Orig() + frTool.VersZ() * dHeight)) * vtDirTopStartEx ; + else if ( t == 1) + dTopBaseSide = ( vPntInters[p] - ( frTool.Orig() + frTool.VersZ() * dHeight)) * vtDirTopEndEx ; + if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt1 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - if ( dSide > 0) - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; + if ( dSide < 0) { + bApproxedSideBottom = dBottomBaseSide < 0 ; + bApproxedSideTop = dTopBaseSide > 0 ; + } + else { + bApproxedSideBottom = dBottomBaseSide > 0 ; + bApproxedSideTop = dTopBaseSide < 0 ; + } + } + else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { + if ( t == 0) { + bApproxedSideBottom = dBottomBaseSide < 0 ; + bApproxedSideTop = dTopBaseSide < 0 ; + } + else if ( t == 1) { + bApproxedSideBottom = dBottomBaseSide > 0 ; + bApproxedSideTop = dTopBaseSide > 0 ; + } + } + else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ + if ( bOnBottomBase) { + if ( t == 0) + vbUpdate[p] = dBottomBaseSide < 0 ; + else if ( t == 1) + vbUpdate[p] = dBottomBaseSide > 0 ; + } + else if ( bOnTopBase) + bApproxedSideTop = true ; } else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide1 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt1 - frStartCyl.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt1 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; + if ( bOnBottomBase) + bApproxedSideBottom = true ; + else if ( bOnTopBase) { + if ( t == 0) + vbUpdate[p] = dTopBaseSide < 0 ; + else if( t == 1) + vbUpdate[p] = dTopBaseSide > 0 ; } } + if ( bOnBottomBase && bApproxedSideBottom) { + if ( t == 0) + vvtTipStartAux.front().GetAngle( vPntInters[p] - frTool.Orig(), dSectorAng) ; + else if( t == 1) + vvtTipEndAux.front().GetAngle( vPntInters[p] - frTool.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 + if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { + double dDist = 0 ; + if ( t == 0) + dDist = ( vPntInters[p] - frTool.Orig() ) * vvtTipStartAux[nSector] ; + else if( t == 1) + dDist = ( vPntInters[p] - frTool.Orig() ) * vvtTipEndAux[nSector] ; + + if ( dSide > 0) + vbUpdate[p] = dDist < dMinRadApprox - EPS_SMALL ; + else + vbUpdate[p] = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; + } + else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { + double dDist = 0 ; + // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base + if ( dBottomBaseSide > 0) { + if ( t == 0) { + // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto + dDist = ( vPntInters[p] - frTool.Orig() ) * ( -vvtTipStartAux[( nSub + 1 ) - nSector] ) ; + vbUpdate[p] = dDist < dMinRadApprox - EPS_SMALL ; + } + else if ( t == 1) + vbUpdate[p] = true ; + } + else { + if ( t == 0) + vbUpdate[p] = true ; + else if ( t == 1 ) { + dDist = (vPntInters[p] - frTool.Orig()) * vvtTipEndAux[nSector] ; + vbUpdate[p] = dDist < dMinRadApprox - EPS_SMALL ; + } + } + } + else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) + vbUpdate[p] = true ; + } + // base superiore + else if( bOnTopBase && bApproxedSideTop) { + if ( t == 0) + vvtTopStartAux.front().GetAngle( vPntInters[p] - ( frTool.Orig() + frTool.VersZ() * dHeight ), dSectorAng) ; + else if( t == 1) + vvtTopEndAux.front().GetAngle( vPntInters[p] - ( frTool.Orig() + frTool.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 + if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { + double dDist = 0 ; + if ( t == 0) + dDist = ( vPntInters[p] - ( frTool.Orig() + frTool.VersZ() * dHeight)) * vvtTopStartAux[nSector] ; + else if( t == 1) + dDist = ( vPntInters[p] - ( frTool.Orig() + frTool.VersZ() * dHeight)) * vvtTopEndAux[nSector] ; + + if( dSide < 0) + vbUpdate[p] = dDist < dMaxRadApprox - EPS_SMALL ; + else + vbUpdate[p] = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; + } + else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { + double dDist = 0 ; + // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base + if ( dTopBaseSide > 0) { + // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto + if ( t == 0) + dDist = ( vPntInters[p] - frTool.Orig()) * ( -vvtTipStartAux[( nSub + 1 ) - nSector]) ; + else if( t == 1) + dDist = ( vPntInters[p] - frTool.Orig()) * ( -vvtTipEndAux[( nSub + 1 ) - nSector]) ; + vbUpdate[p] = dDist < dMinRadApprox - EPS_SMALL ; + } + else + vbUpdate[p] = true ; + } + else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) + vbUpdate[p] = true ; + } + else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && + (( t == 0 && ((bOnTopBase && dSide < 0) || ( bOnBottomBase && dSide > 0))) || + ( t == 1 && ((bOnTopBase && dSide > 0) || ( bOnBottomBase && dSide < 0))))) + vbUpdate[p] = true ; } - // base superiore - else if( bOnTopBase1 && bApproxedSideTop) { - vvtTopStartAux.front().GetAngle( pt1 - ( frStartCyl.Orig() + frStartCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt1 - ( frStartCyl.Orig() + frStartCyl.VersZ() * dHeight)) * vvtTopStartAux[nSector] ; - if( dSide < 0) - bUpdate1 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide1 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt1 - frStartCyl.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt1 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - } + else { + double dHInters = 0 ; + if ( t == 0) + dHInters = (vPntInters[p] - ptP1T) * vtLs.front() ; + else if( t == 1) + dHInters = (vPntInters[p] - ptP2T) * vtLe.back() ; + Vector3d vtDir = Media( vtDirTip, vtDirTop, dHInters / dHeight) ; + if ( t == 0) + vbUpdate[p] = vVtIntersNorm[p] * vtDir > 0 ; + else if ( t == 1) + vbUpdate[p] = vVtIntersNorm[p] * vtDir < 0 ; } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase1 && dSide < 0) || ( bOnBottomBase1 && dSide > 0))) - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide2 = ( pt2 - frStartCyl.Orig()) * vtDirTipStartEx ; - double dTopBaseSide2 = ( pt2 - ( frStartCyl.Orig() + frStartCyl.VersZ() * dHeight))* vtDirTopStartEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase2) - bUpdate2 = dBottomBaseSide2 < 0 ; - else if ( bOnTopBase2) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase2) - bApproxedSideBottom = true ; - else if ( bOnTopBase2) - bUpdate2 = dTopBaseSide2 < 0 ; - } - if ( bOnBottomBase2 && bApproxedSideBottom) { - vvtTipStartAux.front().GetAngle( pt2 - frStartCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt2 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - if ( dSide > 0) - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide2 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt2 - frStartCyl.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt2 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - } - } - // base superiore - else if( bOnTopBase2 && bApproxedSideTop) { - vvtTopStartAux.front().GetAngle( pt2 - ( frStartCyl.Orig() + frStartCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt2 - ( frStartCyl.Orig() + frStartCyl.VersZ() * dHeight)) * vvtTopStartAux[nSector] ; - if( dSide < 0) - bUpdate2 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide2 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt2 - frStartCyl.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt2 - frStartCyl.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase2 && dSide < 0) || ( bOnBottomBase2 && dSide > 0))) - 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) { - Frame3d frEndCyl ; - frEndCyl.Set( ptP2T, vtLe.back()) ; - Point3d pt1, pt2 ; - Vector3d vt1, vt2 ; - if ( IntersLineCylinder( r, Z_AX, frEndCyl, dHeight, dMaxRad, false, false, pt1, vt1, pt2, vt2)){ - bool bUpdate1 = false ; - bool bUpdate2 = false ; - bool bOnTopBase1 = ( pt1 - frEndCyl.Orig()) * frEndCyl.VersZ() > dHeight - EPS_SMALL ; - bool bOnBottomBase1 = ( pt1 - frEndCyl.Orig()) * frEndCyl.VersZ() < EPS_SMALL ; - bool bOnTopBase2 = ( pt2 - frEndCyl.Orig()) * frEndCyl.VersZ() > dHeight - EPS_SMALL ; - bool bOnBottomBase2 = ( pt2 - frEndCyl.Orig()) * frEndCyl.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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide1 = ( pt1 - frEndCyl.Orig()) * vtDirTipEndEx ; - double dTopBaseSide1 = ( pt1 - ( frEndCyl.Orig() + frEndCyl.VersZ() * dHeight))* vtDirTopEndEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase1) - bUpdate1 = dBottomBaseSide1 > 0 ; - else if ( bOnTopBase1) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE ) { - if ( bOnBottomBase1) - bApproxedSideBottom = true ; - else if ( bOnTopBase1) - bUpdate1 = dTopBaseSide1 > 0 ; - } - if ( bOnBottomBase1 && bApproxedSideBottom) { - vvtTipEndAux.front().GetAngle(pt1 - frEndCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt1 - frEndCyl.Orig()) * vvtTipEndAux[nSector] ; - if ( dSide < 0) - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide1 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt1 - frEndCyl.Orig()) * ( - vvtTipEndAux[(nSub + 1) - nSector]) ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - else { - dDist = (pt1 - frEndCyl.Orig()) * vvtTipEndAux[nSector] ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - // base superiore - else if( bOnTopBase1 && bApproxedSideTop) { - vvtTopEndAux.front().GetAngle( pt1 - ( frEndCyl.Orig() + frEndCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt1 - ( frEndCyl.Orig() + frEndCyl.VersZ() * dHeight)) * vvtTopEndAux[nSector] ; - if( dSide > 0) - bUpdate1 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide1 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt1 - frEndCyl.Orig()) * ( - vvtTipEndAux[(nSub + 1) - nSector]) ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - else { - dDist = (pt1 - frEndCyl.Orig()) * vvtTipEndAux[nSector] ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase1 && dSide > 0) || ( bOnBottomBase1 && dSide < 0))) - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide2 = ( pt2 - frEndCyl.Orig()) * vtDirTipEndEx ; - double dTopBaseSide2 = ( pt2 - ( frEndCyl.Orig() + frEndCyl.VersZ() * dHeight))* vtDirTopEndEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase2) - bUpdate2 = dBottomBaseSide2 > 0 ; - else if ( bOnTopBase2) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase2) - bApproxedSideBottom = true ; - else if ( bOnTopBase2) - bUpdate2 = dTopBaseSide2 > 0 ; - } - if ( bOnBottomBase2 && bApproxedSideBottom) { - vvtTipEndAux.front().GetAngle(pt2 - frEndCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt2 - frEndCyl.Orig()) * vvtTipEndAux[nSector] ; - if ( dSide < 0) - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide2 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt2 - frEndCyl.Orig()) * ( - vvtTipEndAux[(nSub + 1) - nSector]) ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - else { - dDist = (pt2 - frEndCyl.Orig()) * vvtTipEndAux[nSector] ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - // base superiore - else if( bOnTopBase2 && bApproxedSideTop) { - vvtTopEndAux.front().GetAngle( pt2 - ( frEndCyl.Orig() + frEndCyl.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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt2 - ( frEndCyl.Orig() + frEndCyl.VersZ() * dHeight)) * vvtTopEndAux[nSector] ; - if( dSide > 0) - bUpdate2 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide2 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt2 - frEndCyl.Orig()) * ( - vvtTopEndAux[(nSub + 1) - nSector]) ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - else { - dDist = (pt2 - frEndCyl.Orig()) * vvtTopEndAux[nSector] ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - else if ( (n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase2 && dSide > 0) || ( bOnBottomBase2 && dSide < 0)))) - 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) ; + if ( vbUpdate[0]) + UpdateMaxMin( vPntInters[0], vVtIntersNorm[0], vInters) ; + if ( vbUpdate[1]) + UpdateMaxMin( vPntInters[1], vVtIntersNorm[1], vInters) ; } } } - // se sto trattando un cono - else { - if( bbStartCyl.SqDistFromPointXY( r) < EPS_ZERO) { - Frame3d frStartCon ; - frStartCon.Set( ptVS, vtLs[0]) ; - Point3d pt1, pt2 ; - Vector3d vt1, vt2 ; - if ( IntersLineConus( r, Z_AX, frStartCon, dTan, dMinH, dMaxH, false, false, pt1, vt1, pt2, vt2)) { - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide1 = ( pt1 - frStartCon.Orig()) * vtDirTipStartEx ; - double dTopBaseSide1 = ( pt1 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight))* vtDirTopStartEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase1) - bUpdate1 = dBottomBaseSide1 < 0 ; - else if ( bOnTopBase1) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase1) - bApproxedSideBottom = true ; - else if ( bOnTopBase1) - bUpdate1 = dTopBaseSide1 < 0 ; - } - if ( bOnBottomBase1 && bApproxedSideBottom) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt1 - frStartCon.Orig()) * vvtTipStartAux[nSector] ; - if ( dSide > 0) - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide1 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt1 - frStartCon.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt1 - frStartCon.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - } - } - // base superiore - else if( bOnTopBase1 && bApproxedSideTop) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - 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 if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide1 > 0) { - dDist = (pt1 - frStartCon.Orig()) * ( - vvtTopStartAux[(nSub + 1) - nSector]) ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt1 - frStartCon.Orig()) * vvtTopStartAux[nSector] ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase1 && dSide < 0) || ( bOnBottomBase1 && dSide > 0))) - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide2 = ( pt2 - frStartCon.Orig()) * vtDirTipStartEx ; - double dTopBaseSide2 = ( pt2 - ( frStartCon.Orig() + frStartCon.VersZ() * dHeight))* vtDirTopStartEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase2) - bUpdate2 = dBottomBaseSide2 < 0 ; - else if ( bOnTopBase2) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase2) - bApproxedSideBottom = true ; - else if ( bOnTopBase2) - bUpdate2 = dTopBaseSide2 < 0 ; - } - if ( bOnBottomBase2 && bApproxedSideBottom) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt2 - frStartCon.Orig()) * vvtTipStartAux[nSector] ; - if ( dSide > 0) - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide2 > 0) { - // in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - dDist = (pt2 - frStartCon.Orig()) * ( - vvtTipStartAux[(nSub + 1) - nSector]) ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //dDist = (pt2 - frStartCon.Orig()) * vvtTipStartAux[nSector] ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - } - - } - // base superiore - else if( bOnTopBase2 && bApproxedSideTop) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - 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 if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide2 > 0) { - dDist = (pt2 - frStartCon.Orig()) * ( - vvtTopStartAux[(nSub + 1) - nSector]) ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - else { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt2 - frStartCon.Orig()) * vvtTopStartAux[nSector] ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase2 && dSide < 0) || ( bOnBottomBase2 && dSide > 0))) - 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) { - Frame3d frEndCon ; - frEndCon.Set( ptVE, vtLe.back()) ; - Point3d pt1, pt2 ; - Vector3d vt1, vt2 ; - if ( IntersLineConus( r, Z_AX, frEndCon, dTan, dMinH, dMaxH, false, false, pt1, vt1, pt2, vt2)) { - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide1 = ( pt1 - frEndCon.Orig()) * vtDirTipEndEx ; - double dTopBaseSide1 = ( pt1 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight))* vtDirTopEndEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide1 < 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide1 > 0 ; - bApproxedSideTop = dTopBaseSide1 > 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase1) - bUpdate1 = dBottomBaseSide1 > 0 ; - else if ( bOnTopBase1) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE ) { - if ( bOnBottomBase1) - bApproxedSideBottom = true ; - else if ( bOnTopBase1) - bUpdate1 = dTopBaseSide1 > 0 ; - } - if ( bOnBottomBase1 && bApproxedSideBottom) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt1 - frEndCon.Orig()) * vvtTipEndAux[nSector] ; - if ( dSide < 0) - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide1 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt1 - frEndCon.Orig()) * ( - vvtTipEndAux[(nSub + 1) - nSector]) ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - else { - dDist = (pt1 - frEndCon.Orig()) * vvtTipEndAux[nSector] ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - // base superiore - else if( bOnTopBase1 && bApproxedSideTop) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt1 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight)) * vvtTopEndAux[nSector] ; - if( dSide > 0) - bUpdate1 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate1 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide1 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt1 - frEndCon.Orig()) * ( - vvtTopEndAux[(nSub + 1) - nSector]) ; - //bUpdate1 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate1 = true ; - } - else { - dDist = (pt1 - frEndCon.Orig()) * vvtTopEndAux[nSector] ; - bUpdate1 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase1 && dSide > 0) || ( bOnBottomBase1 && dSide < 0))) - 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 ; - bool bApproxedSideBottom = false ; - bool bApproxedSideTop = false ; - double dBottomBaseSide2 = ( pt2 - frEndCon.Orig()) * vtDirTipEndEx ; - double dTopBaseSide2 = ( pt2 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight))* vtDirTopEndEx ; - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - if ( dSide < 0) { - bApproxedSideBottom = dBottomBaseSide2 < 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 < 0 ; - } - } - else if ( n5AxisType == VolZmap::Move5Axis::ACROSS) { - bApproxedSideBottom = dBottomBaseSide2 > 0 ; - bApproxedSideTop = dTopBaseSide2 > 0 ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX){ - if ( bOnBottomBase2) - bUpdate2 = dBottomBaseSide2 > 0 ; - else if ( bOnTopBase2) - bApproxedSideTop = true ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - if ( bOnBottomBase2) - bApproxedSideBottom = true ; - else if ( bOnTopBase2) - bUpdate2 = dTopBaseSide2 > 0 ; - } - if ( bOnBottomBase2 && bApproxedSideBottom) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = (pt2 - frEndCon.Orig()) * vvtTipEndAux[nSector] ; - if ( dSide < 0) - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONCAVE) { - double dDist = 0 ; - // per il caso ALONG_CONCAVE dovrei avere dSide < 0, quindi sulla base bottom avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dBottomBaseSide2 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt2 - frEndCon.Orig()) * ( - vvtTipEndAux[(nSub + 1) - nSector]) ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - else { - dDist = (pt2 - frEndCon.Orig()) * vvtTipEndAux[nSector] ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - // base superiore - else if( bOnTopBase2 && bApproxedSideTop) { - 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 - if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS) { - double dDist = ( pt2 - ( frEndCon.Orig() + frEndCon.VersZ() * dHeight)) * vvtTopEndAux[nSector] ; - if( dSide > 0) - bUpdate2 = dDist < dMaxRadApprox - EPS_SMALL ; - else - bUpdate2 = dDist > dMaxRadApprox - EPS_SMALL && dDist < dMaxRad ; - } - else if ( n5AxisType == VolZmap::Move5Axis::ALONG_CONVEX) { - double dDist = 0 ; - // per il caso ALONG_CONVEX dovrei avere dSide > 0, quindi sulla base top avere i punti ausiliari nella parte posteriore del cerchio di base - if ( dTopBaseSide2 > 0) { - //// in questo caso devo prendere il vettore Aux dell'angolo supplementare e con segno opposto - //dDist = (pt2 - frEndCon.Orig()) * ( - vvtTopEndAux[(nSub + 1) - nSector]) ; - //bUpdate2 = dDist > dMinRadApprox - EPS_SMALL && dDist < dMinRad ; - bUpdate2 = true ; - } - else { - dDist = (pt2 - frEndCon.Orig()) * vvtTopEndAux[nSector] ; - bUpdate2 = dDist < dMinRadApprox - EPS_SMALL ; - } - } - } - else if ( n5AxisType == VolZmap::Move5Axis::NO_BASE_INTERS && ((bOnTopBase2 && dSide > 0) || ( bOnBottomBase2 && dSide < 0))) - 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) ; - } - } - } - - //if ( vInters.size() != 0 ) { - // // se ho un numero dispari di intersezioni devo migliorare la gestione - - // // riordino le intersezioni rispetto alla loro z - // sort( vInters.begin(), vInters.end(), []( PNTVECT& a, PNTVECT& b){ return a.first.z < b.first.z ;}) ; - // if ( vInters.size() > 2) { - // INTVECTOR vErase ; - // bool bStartNewInterval = true ; - // // elimino eventuali doppioni di punti - // for ( int w = 0 ; w < int( vInters.size()) ; ++w) { - // // se è l'ultimo punto esco - // if ( w == int( vInters.size() - 1)) - // break ; - // // se sono due punti vicino tolgo il secondo se sto cercando l'inizio di un intervallo - // // mentre se sto cercando la fine tolgo il primo - // if ( vInters[w + 1].first.z - vInters[w].first.z < 1) { - // if ( bStartNewInterval) { - // // se sto cercando l'inizio, ma sono gli ultimi due punti e sono vicini allora tolgo entrambi ed esco - // if ( w == int( vInters.size() - 2)) { - // // serve che siano in quest'ordine - // vErase.push_back( w) ; - // vErase.push_back( w + 1) ; - // break ; - // } - // else - // vErase.push_back( w + 1) ; - // ++w ; - // } - // else { - // vErase.push_back( w) ; - // ++w ; - // } - // } - // bStartNewInterval = ! bStartNewInterval ; - // } - - // // elimino i doppioni - // for ( int w = vErase.size() - 1 ; w >= 0 ; --w) - // vInters.erase( vInters.begin() + vErase[w]) ; - // } - // if ( vInters.size() % 2 == 0) { - // for( int z = 0 ; z < int( vInters.size()) ; z += 2) - // SubtractIntervals( nGrid, i, j, vInters[z].first.z, vInters[z+1].first.z, vInters[z].second, vInters[z+1].second, nToolNum) ; - // } - // else if ( vInters.size() == 3) - // SubtractIntervals( nGrid, i, j, vInters.front().first.z, vInters.back().first.z, vInters.front().second, vInters.back().second, nToolNum) ; - //} if ( vInters.size() != 0 ) { sort( vInters.begin(), vInters.end(), []( PNTVECT& a, PNTVECT& b){ return a.first.z < b.first.z ;}) ; SubtractIntervals( nGrid, i, j, vInters.front().first.z, vInters.back().first.z, vInters.front().second, vInters.back().second, nToolNum) ;