diff --git a/VolZmap.h b/VolZmap.h index ec61132..01fcd39 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -304,6 +304,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW int& nStI, int& nStJ, int& nEnI, int& nEnJ) ; // Asportazioni superfici elementari vuote + bool SurfCircCrown_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtAx, double dMaxRad, double dMinRad) ; /*bool SurfCyl_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad, bool bTapB, bool bTapT) ; bool SurfCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, @@ -314,9 +315,13 @@ class VolZmap : public IVolZmap, public IGeoObjRW const Vector3d& vtToolDir, double dHei, double dRad, bool bOuterCutter, bool bTapB, bool bTapT) ; bool SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bOuterCutter, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) ; + bool SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dMaxRad, double dMinRad, bool bOuterCutter, bool bTapB, bool bTapT, + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) ; bool SurfConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bOuterCutter, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) ; + // Intersezioni bool IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptMin, const Point3d& ptMax) const ; bool IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptMin, const Point3d& ptMax, diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index c8a86d5..6dd268f 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -5050,6 +5050,50 @@ VolZmap::IntersLineSphereCuttedByPlanes( const Point3d& ptLineP, const Vector3d& return nSol ; } +// Corona circolare +//---------------------------------------------------------------------------- +bool +VolZmap::SurfCircCrown_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtAx, double dMaxRad, double dMinRad) +{ + // Verifica sull'interferenza utensile Zmap + int nStartI, nStartJ, nEndI, nEndJ ; + if ( ! TestCompoBBox( nGrid, ptS, ptE, vtToolDir, dMaxRad, dMinRad, 1, nStartI, nStartJ, nEndI, nEndJ)) + return true ; + + // Se il movimento č in direzione opposta a quella ove la corona puņ tagliare, non devo fare nulla. + if ( vtAx.z * ( ptE - ptS).z < EPS_ZERO) + return true ; + + // Raggi di sicurezza per evitare di tagliare i dexel a filo del bordo dela regione interessata dal taglio. + double dSqSafeMinRad = dMinRad * dMinRad + 2 * dMinRad * EPS_SMALL ; + double dSqSafeMaxRad = dMaxRad * dMaxRad - 2 * dMaxRad * EPS_SMALL ; + + Point3d ptSXY( ptS.x, ptS.y, 0) ; + + // Ciclo sui dexel. + for ( int i = nStartI ; i <= nEndI ; ++ i) { + for ( int j = nStartJ ; j <= nEndJ ; ++ j) { + Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ; + Vector3d vtR = ptC - ptSXY ; + double dSqLenR = vtR * vtR ; + if ( dSqLenR > dSqSafeMinRad && dSqLenR < dSqSafeMaxRad) { + double dMinZ = min( ptS.z, ptE.z) ; + double dMaxZ = max( ptS.z, ptE.z) ; + Vector3d vtMinN, vtMaxN ; + if ( ptE.z < ptS.z) { + vtMinN.z = 1 ; + vtMaxN; + } + else { + vtMinN; + vtMaxN.z = - 1 ; + } + } + } + } + + return true ; +} // Cilindro //---------------------------------------------------------------------------- @@ -5345,8 +5389,8 @@ VolZmap::SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dDeltaH = dMinRad * dHei / ( dMaxRad - dMinRad) ; Point3d ptVertE = ptE - ( dHei + dDeltaH) * vtToolDir ; Point3d ptIntMinP( dX, dY, dMinZ) ; - Vector3d vtIntMinV = ptIntMin - ptVertE ; - double dCompLong = vtIntMin * vtToolDir ; + Vector3d vtIntMinV = ptIntMinP - ptVertE ; + double dCompLong = vtIntMinV * vtToolDir ; Vector3d vtIntMinLongV = dCompLong * vtToolDir ; Vector3d vtIntMinOrtV = vtIntMinV - vtIntMinLongV ; vtMinN = - vtIntMinOrtV + dCompLong * vtToolDir ; @@ -5355,8 +5399,8 @@ VolZmap::SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dDeltaH = dMinRad * dHei / ( dMaxRad - dMinRad) ; Point3d ptVertE = ptE - ( dHei + dDeltaH) * vtToolDir ; Point3d ptIntMaxP( dX, dY, dMaxZ) ; - Vector3d vtIntMaxV = ptIntMax - ptVertE ; - double dCompLong = vtIntMax * vtToolDir ; + Vector3d vtIntMaxV = ptIntMaxP - ptVertE ; + double dCompLong = vtIntMaxV * vtToolDir ; Vector3d vtIntMaxLongV = dCompLong * vtToolDir ; Vector3d vtIntMaxOrtV = vtIntMaxV - vtIntMaxLongV ; vtMaxN = vtIntMaxOrtV - dCompLong * vtToolDir ; @@ -5373,8 +5417,8 @@ VolZmap::SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dDeltaH = dMinRad * dHei / ( dMaxRad - dMinRad) ; Point3d ptVertE = ptE - ( dHei + dDeltaH) * vtToolDir ; Point3d ptIntMaxP( dX, dY, dMaxZ) ; - Vector3d vtIntMaxV = ptIntMax - ptVertE ; - double dCompLong = vtIntMax * vtToolDir ; + Vector3d vtIntMaxV = ptIntMaxP - ptVertE ; + double dCompLong = vtIntMaxV * vtToolDir ; Vector3d vtIntMaxLongV = dCompLong * vtToolDir ; Vector3d vtIntMaxOrtV = vtIntMaxV - vtIntMaxLongV ; vtMaxN = - vtIntMaxOrtV + dCompLong * vtToolDir ; @@ -5383,8 +5427,8 @@ VolZmap::SurfConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dDeltaH = dMinRad * dHei / ( dMaxRad - dMinRad) ; Point3d ptVertE = ptE - ( dHei + dDeltaH) * vtToolDir ; Point3d ptIntMinP( dX, dY, dMinZ) ; - Vector3d vtIntMinV = ptIntMin - ptVertE ; - double dCompLong = vtIntMin * vtToolDir ; + Vector3d vtIntMinV = ptIntMinP - ptVertE ; + double dCompLong = vtIntMinV * vtToolDir ; Vector3d vtIntMinLongV = dCompLong * vtToolDir ; Vector3d vtIntMinOrtV = vtIntMinV - vtIntMinLongV ; vtMinN = vtIntMinOrtV - dCompLong * vtToolDir ; @@ -5409,8 +5453,9 @@ VolZmap::SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, // Vettore spostamento Vector3d vtDisp = ptE - ptS ; - if ( ( vtToolDir * vtDisp > 0 && bOuterCutter) || - ( vtToolDir * vtDisp < 0 && ! bOuterCutter)) + bool bToolVecAndDispAreOpposite = vtToolDir * vtDisp < 0 ; + if ( ( ! bToolVecAndDispAreOpposite && bOuterCutter) || + ( bToolVecAndDispAreOpposite && ! bOuterCutter)) return true ; // Vertici cono iniziale e finale @@ -5436,7 +5481,7 @@ VolZmap::SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, Vector3d vtN1, vtN2 ; // Intersezione con il cono in posizione iniziale - int nIntNum = IntersLineConeCuttedByPlanes( ptC, Z_AX, ptS, vtToolDir, dMaxRad, dHei, true, + int nIntNum = IntersLineConeCuttedByPlanes( ptC, Z_AX, ptS - dHei * vtToolDir, vtToolDir, dMaxRad, dHei, true, vCutConePlaneVecSt, ptInt1, vtN1, ptInt2, vtN2); if ( nIntNum >= 1) { vParAndNormIntersVec.emplace_back() ; @@ -5450,7 +5495,7 @@ VolZmap::SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, } // Intersezione con il cono in posizione finale - nIntNum = IntersLineConeCuttedByPlanes( ptC, Z_AX, ptE, vtToolDir, dMaxRad, dHei, true, + nIntNum = IntersLineConeCuttedByPlanes( ptC, Z_AX, ptE - dHei * vtToolDir, vtToolDir, dMaxRad, dHei, true, vCutConePlaneVecEn, ptInt1, vtN1, ptInt2, vtN2) ; if ( nIntNum >= 1) { vParAndNormIntersVec.emplace_back() ; @@ -5464,7 +5509,7 @@ VolZmap::SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, } // Intersezione con il cilindro esterno - nIntNum = IntersLineCylinderCuttedByPlanes( ptC, Z_AX, ptS, vtDisp * vtAx, dMaxRad, dHei, true, + nIntNum = IntersLineCylinderCuttedByPlanes( ptC, Z_AX, ptS, vtToolDir, dMaxRad, ( bToolVecAndDispAreOpposite ? - 1 : 1) * dHei, true, vEmptyPlaneVec, ptInt1, vtN1, ptInt2, vtN2) ; if ( nIntNum >= 1) { vParAndNormIntersVec.emplace_back() ; @@ -5478,7 +5523,7 @@ VolZmap::SurfConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, } // Intersezione con il cilindro interno - nIntNum = IntersLineCylinderCuttedByPlanes( ptC, Z_AX, ptS - dHei * vtToolDir, vtToolDir, dMinRad, dHei, true, + nIntNum = IntersLineCylinderCuttedByPlanes( ptC, Z_AX, ptS/* - dHei * vtToolDir*/, vtToolDir, dMinRad, ( bToolVecAndDispAreOpposite ? - 1 : 1) * dHei, true, vEmptyPlaneVec, ptInt1, vtN1, ptInt2, vtN2) ; if ( nIntNum >= 1) { vParAndNormIntersVec.emplace_back() ;