diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index b389857..52ea98a 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/VolZmapCalculus.cpp b/VolZmapCalculus.cpp index 3f3abb9..9307c03 100644 --- a/VolZmapCalculus.cpp +++ b/VolZmapCalculus.cpp @@ -1169,30 +1169,16 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaZ, Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2) { - // Costanti degli Offset - const double dOffsetX = EPS_SMALL ; - const double dOffsetY = EPS_SMALL ; - const double dOffsetZ = EPS_SMALL * sqrt( 1 + ( dDeltaZ * dDeltaZ) / ( dLenX * dLenX)) ; - - // Controllo sulle dimensioni lineari affinché sia valido l'offset - if ( dLenX <= 2 * dOffsetX || dLenY <= 2 * dOffsetY || dLenZ <= 2 * dOffsetZ) + // Controllo sulle dimensioni lineari affinché sia valido il poliedro + if ( dLenX <= 0 || dLenY <= 0 || dLenZ <= 0) return false ; - - // Accorcio le dimensioni lineari in modo opportuno: si noti che ora dLenX > 0 e ( 1 - 2 * EPS_SMALL / dLenX) < 1 - dLenX -= 2 * dOffsetX ; - dLenY -= 2 * dOffsetY ; - dLenZ -= 2 * dOffsetZ ; - dDeltaZ = dDeltaZ * ( 1 - ( 2 * EPS_SMALL) / dLenX) ; - // Riferimento del poliedro offsettato - Frame3d frInnerFrame = PolyFrame ; - frInnerFrame.Translate( dOffsetX * frInnerFrame.VersX() + ( dOffsetZ + EPS_SMALL * dDeltaZ / dLenX) * frInnerFrame.VersZ()) ; - + Point3d ptP = ptLineSt ; Vector3d vtV = vtLineDir ; // Trasformazione delle coordinate - ptP.ToLoc( frInnerFrame) ; - vtV.ToLoc( frInnerFrame) ; + ptP.ToLoc( PolyFrame) ; + vtV.ToLoc( PolyFrame) ; // Facce 1 e 2 parallele a XY // Facce 3 e 4 parallele a XZ @@ -1322,10 +1308,10 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine } if ( nIntNum == 2) { - ptInt1.ToGlob( frInnerFrame) ; - ptInt2.ToGlob( frInnerFrame) ; - vtN1.ToGlob( frInnerFrame) ; - vtN2.ToGlob( frInnerFrame) ; + ptInt1.ToGlob( PolyFrame) ; + ptInt2.ToGlob( PolyFrame) ; + vtN1.ToGlob( PolyFrame) ; + vtN2.ToGlob( PolyFrame) ; return true ; } else diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 56e350a..fd285ef 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -3341,20 +3341,27 @@ VolZmap::CompPar_ZDrilling( unsigned int nGrid, double dLenX, double dLenY, doub const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; + Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; + + dLenX -= ( 2 * EPS_SMALL) ; + dLenY -= ( 2 * EPS_SMALL) ; + dLenZ -= ( 2 * EPS_SMALL) ; + // Controllo sull'interferenza utensile-solido unsigned int nStartI, nStartJ, nEndI, nEndJ ; - bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptS, ptE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; + bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptMyS, ptMyE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; if ( ! bInterf) return true ; // Costruisco un sistema di riferimento nel piano - Point3d ptOXY( ptS.x, ptS.y, 0) ; + Point3d ptOXY( ptMyS.x, ptMyS.y, 0) ; Vector3d vtV1 = vtToolDir ^ vtAux ; Vector3d vtV2 = vtAux ; // Quote estreme del volume asportato - double dMinZ = min( min( ptS.z, ptS.z - vtToolDir.z * dLenZ), min( ptE.z, ptE.z - vtToolDir.z * dLenZ)) ; - double dMaxZ = max( max( ptS.z, ptS.z - vtToolDir.z * dLenZ), max( ptE.z, ptE.z - vtToolDir.z * dLenZ)) ; + double dMinZ = min( min( ptMyS.z, ptMyS.z - vtToolDir.z * dLenZ), min( ptMyE.z, ptMyE.z - vtToolDir.z * dLenZ)) ; + double dMaxZ = max( max( ptMyS.z, ptMyS.z - vtToolDir.z * dLenZ), max( ptMyE.z, ptMyE.z - vtToolDir.z * dLenZ)) ; for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) { for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) { @@ -3368,8 +3375,7 @@ VolZmap::CompPar_ZDrilling( unsigned int nGrid, double dLenX, double dLenY, doub double dR1 = vtR * vtV1 ; double dR2 = vtR * vtV2 ; - if ( abs( dR1) < 0.5 * dLenX - EPS_SMALL && - abs( dR2) < 0.5 * dLenY - EPS_SMALL) + if ( abs( dR1) < 0.5 * dLenX && abs( dR2) < 0.5 * dLenY) SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; } } @@ -3785,25 +3791,32 @@ VolZmap::CompPar_ZMilling( unsigned int nGrid, double dLenX, double dLenY, doubl const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; + Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; + + dLenX -= ( 2 * EPS_SMALL) ; + dLenY -= ( 2 * EPS_SMALL) ; + dLenZ -= ( 2 * EPS_SMALL) ; + // Controllo sull'interferenza utensile-solido unsigned int nStartI, nStartJ, nEndI, nEndJ ; - bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptS, ptE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; + bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptMyS, ptMyE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; if ( ! bInterf) return true ; // Quote estreme Z - double dMinZ = min( min( ptS.z, ptS.z - vtToolDir.z * dLenZ), min( ptE.z, ptE.z - vtToolDir.z * dLenZ)) ; - double dMaxZ = max( max( ptS.z, ptS.z - vtToolDir.z * dLenZ), max( ptE.z, ptE.z - vtToolDir.z * dLenZ)) ; + double dMinZ = min( min( ptMyS.z, ptMyS.z - vtToolDir.z * dLenZ), min( ptMyE.z, ptMyE.z - vtToolDir.z * dLenZ)) ; + double dMaxZ = max( max( ptMyS.z, ptMyS.z - vtToolDir.z * dLenZ), max( ptMyE.z, ptMyE.z - vtToolDir.z * dLenZ)) ; // Vettore di movimento - Vector3d vtMove = ptE - ptS ; + Vector3d vtMove = ptMyE - ptMyS ; // Sistemi di riferimento del solido nella posizione iniziale e finale Vector3d vtV2 = vtAux ; Vector3d vtV1 = vtV2 ^ vtToolDir ; vtV1.Normalize() ; - Point3d ptSXY( ptS.x, ptS.y, 0) ; - Point3d ptEXY( ptE.x, ptE.y, 0) ; + Point3d ptSXY( ptMyS.x, ptMyS.y, 0) ; + Point3d ptEXY( ptMyE.x, ptMyE.y, 0) ; // Studio del volume asportato durante il moto Frame3d MotionFrame ; @@ -3835,22 +3848,20 @@ VolZmap::CompPar_ZMilling( unsigned int nGrid, double dLenX, double dLenY, doubl double dRE2 = vtRE * vtV2 ; // Asportazione materiale nella posizione iniziale - if ( abs( dRS1) < 0.5 * dLenX - EPS_SMALL && - abs( dRS2) < 0.5 * dLenY - EPS_SMALL) + if ( abs( dRS1) < 0.5 * dLenX && abs( dRS2) < 0.5 * dLenY) SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; // Asportazione materiale nella posizione finale - if ( abs( dRE1) < 0.5 * dLenX - EPS_SMALL && - abs( dRE2) < 0.5 * dLenY - EPS_SMALL) + if ( abs( dRE1) < 0.5 * dLenX && abs( dRE2) < 0.5 * dLenY) SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; // Asportazione materiale nel moto Vector3d vtR = ptC - ptOrigXY ; double dR1 = vtR * vtW1 ; double dR2 = vtR * vtW2 ; - if ( dR2 > EPS_SMALL && dR2 < dLenW2 - EPS_SMALL && - dR1 * dLenW2 > /*dLenW1*/dDeltaW1 * dR2 + EPS_SMALL && - dR1 * dLenW2 < /*dDeltaW1*/dLenW1 * dLenW2 + /*dLenW1*/ dDeltaW1 * dR2 - EPS_SMALL) + if ( dR2 > 0 && dR2 < dLenW2 && + dR1 * dLenW2 > dDeltaW1 * dR2 && + dR1 * dLenW2 < dLenW1 * dLenW2 + dDeltaW1 * dR2) SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; } } @@ -3998,9 +4009,16 @@ VolZmap::CompPar_Drilling( unsigned int nGrid, double dLenX, double dLenY, doubl const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; + Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; + + dLenX -= ( 2 * EPS_SMALL) ; + dLenY -= ( 2 * EPS_SMALL) ; + dLenZ -= ( 2 * EPS_SMALL) ; + // Controllo sull'interferenza utensile-solido unsigned int nStartI, nStartJ, nEndI, nEndJ ; - bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptS, ptE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; + bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptMyS, ptMyE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; if ( ! bInterf) return true ; @@ -4010,8 +4028,8 @@ VolZmap::CompPar_Drilling( unsigned int nGrid, double dLenX, double dLenY, doubl Vector3d vtV2 = vtAux ^ vtV1 ; Vector3d vtV3 = vtAux ; - double dLenMove = ( ptE - ptS).Len() ; - Point3d ptO = ptS - ( ( ptE - ptS) * vtV1 > 0 ? dLenZ : dLenZ + dLenMove) * vtV1 - ( 0.5 * dLenX) * vtV2 ; + double dLenMove = ( ptMyE - ptMyS).Len() ; + Point3d ptO = ptMyS - ( ( ptMyE - ptMyS) * vtV1 > 0 ? dLenZ : dLenZ + dLenMove) * vtV1 - ( 0.5 * dLenX) * vtV2 ; Frame3d ParaFrame ; ParaFrame.Set( ptO, vtV2, vtV3, vtV1) ; for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) { @@ -4608,14 +4626,21 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; + Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; + + dLenX -= ( 2 * EPS_SMALL) ; + dLenY -= ( 2 * EPS_SMALL) ; + dLenZ -= ( 2 * EPS_SMALL) ; + // Controllo sull'interferenza utensile-solido unsigned int nStartI, nStartJ, nEndI, nEndJ ; - bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptS, ptE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; + bool bInterf = BBoxParaComp( nGrid, dLenX, dLenY, dLenZ, ptMyS, ptMyE, vtToolDir, vtAux, nStartI, nStartJ, nEndI, nEndJ) ; if ( ! bInterf) return true ; // Vettore di movimento - Vector3d vtMove = ptE - ptS ; + Vector3d vtMove = ptMyE - ptMyS ; // Sistema di riferimento del solido nella posizione iniziale (con vtMove derivo quello finale) Frame3d ParaFrame ; @@ -4623,14 +4648,14 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double Vector3d vtV1 = vtAux ^ vtV3 ; Vector3d vtV2 = vtV3 ^ vtV1 ; ParaFrame.Set( ORIG, vtV1, vtV2, vtV3) ; - ParaFrame.ChangeOrig( ptS - dLenZ * ParaFrame.VersZ() - ( 0.5 * dLenX) * ParaFrame.VersX()) ; + ParaFrame.ChangeOrig( ptMyS - dLenZ * ParaFrame.VersZ() - ( 0.5 * dLenX) * ParaFrame.VersX()) ; // Studio del volume asportato durante il moto Frame3d MotionFrame ; Vector3d vtDiagA = dLenX * ParaFrame.VersX() + dLenY * ParaFrame.VersY() ; Vector3d vtDiagB = dLenX * ParaFrame.VersX() - dLenY * ParaFrame.VersY() ; Vector3d vtW3 = ( abs( vtDiagA * vtMove) <= abs( vtDiagB * vtMove) ? vtDiagA : vtDiagB) ; - Point3d ptOrig = ptS - vtW3 / 2 - vtToolDir * ( dLenZ / 2) ; + Point3d ptOrig = ptMyS - vtW3 / 2 - vtToolDir * ( dLenZ / 2) ; double dLenW3 = vtW3.Len() ; vtW3 /= dLenW3 ; double dDeltaW3 = vtMove * vtW3 ; @@ -4671,7 +4696,7 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; } - // Solido nella posizione finale + // Solido nella posizione finale if ( IntersLineMyPolyhedron( ptC - vtMove, Z_AX, ParaFrame, dLenX, dLenY, dLenZ, 0, ptInt1, ptInt2, vtN1, vtN2)) { double dMin, dMax ; Vector3d vtNmin, vtNmax ; @@ -4911,16 +4936,16 @@ VolZmap::BBoxParaComp( unsigned int nGrid, double dLenX, double dLenY, double dL // finale della punta dell'utensile. Point3d ptSTip = ptS - vtD * dLenZ ; Point3d ptETip = ptE - vtD * dLenZ ; - - double dMaxDim = max( dLenX, dLenY) ; + + double dSemiDiag = sqrt( dLenX * dLenX + dLenY * dLenY) / 2 ; // Determinazione dei limiti del più piccolo parallelepipedo contenente il movimento - double dMinX = min( min( ptS.x, ptSTip.x), min( ptE.x, ptETip.x)) - dMaxDim ; - double dMinY = min( min( ptS.y, ptSTip.y), min( ptE.y, ptETip.y)) - dMaxDim ; - double dMinZ = min( min( ptS.z, ptSTip.z), min( ptE.z, ptETip.z)) - dMaxDim ; - double dMaxX = max( max( ptS.x, ptSTip.x), max( ptE.x, ptETip.x)) + dMaxDim ; - double dMaxY = max( max( ptS.y, ptSTip.y), max( ptE.y, ptETip.y)) + dMaxDim ; - double dMaxZ = max( max( ptS.z, ptSTip.z), max( ptE.z, ptETip.z)) + dMaxDim ; + double dMinX = min( min( ptS.x, ptSTip.x), min( ptE.x, ptETip.x)) - dSemiDiag ; + double dMinY = min( min( ptS.y, ptSTip.y), min( ptE.y, ptETip.y)) - dSemiDiag ; + double dMinZ = min( min( ptS.z, ptSTip.z), min( ptE.z, ptETip.z)) - dSemiDiag ; + double dMaxX = max( max( ptS.x, ptSTip.x), max( ptE.x, ptETip.x)) + dSemiDiag ; + double dMaxY = max( max( ptS.y, ptSTip.y), max( ptE.y, ptETip.y)) + dSemiDiag ; + double dMaxZ = max( max( ptS.z, ptSTip.z), max( ptE.z, ptETip.z)) + dSemiDiag ; unsigned int nMaxNx = m_nNx[nGrid] ; unsigned int nMaxNy = m_nNy[nGrid] ;