EgtGeomKernel :

- modifiche a calcolo spilloni di Zmap e varie altre.
This commit is contained in:
Dario Sassi
2018-02-09 07:41:15 +00:00
parent 3caa17c369
commit 21a1f9e35d
3 changed files with 321 additions and 370 deletions
+147 -186
View File
@@ -566,7 +566,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
bool
VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe)
{
// Controllo sull'effettiva esisenza del movimento
// Controllo sull'effettiva esistenza del movimento
if ( AreSamePointApprox( ptPs, ptPe) && AreSameVectorApprox( vtDs, vtDe))
return true ;
@@ -587,15 +587,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
ptLe[1].x = ptLe[0].y ; ptLe[1].y = ptLe[0].z ; ptLe[1].z = ptLe[0].x ;
ptLe[2].x = ptLe[0].z ; ptLe[2].y = ptLe[0].x ; ptLe[2].z = ptLe[0].y ;
}
else {
ptLs[1].x = 0 ; ptLs[1].y = 0 ; ptLs[1].z = 0 ;
ptLs[2].x = 0 ; ptLs[2].y = 0 ; ptLs[2].z = 0 ;
ptLe[1].x = 0 ; ptLe[1].y = 0 ; ptLe[1].z = 0 ;
ptLe[2].x = 0 ; ptLe[2].y = 0 ; ptLe[2].z = 0 ;
}
// Vettori nei sistemi di riferimento intrinseci dello Zmap
Vector3d vtLs[3] ;
Vector3d vtLe[3] ;
@@ -2385,6 +2377,9 @@ VolZmap::Conus_XYDrilling( unsigned int nGrid, const Point3d& ptS, const Point3d
Vector3d vtUmin = ( ptIntMin - ptV) - ( ptIntMin - ptV) * vtV * vtV ;
Vector3d vtUmax = ( ptIntMax - ptV) - ( ptIntMax - ptV) * vtV * vtV ;
vtUmin.Normalize() ;
vtUmax.Normalize() ;
Vector3d vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmin ;
Vector3d vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmax ;
@@ -2772,49 +2767,41 @@ VolZmap::Conus_XYMilling( unsigned int nGrid, const Point3d & ptS, const Point3d
// ---------- Cilindro e sfera -----------------------------------------------
//----------------------------------------------------------------------------
bool
VolZmap::CylBall_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
VolZmap::CylBall_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
{
double dStemHeigth = m_Tool.GetHeigth() ;
// Sfera
if ( m_Tool.GetType() == Tool::BALLMILL)
dStemHeigth -= m_Tool.GetRadius() ;
// Altezza cilindro
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
// Sottraggo cilindro
CompCyl_Drilling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, false) ;
// Sfera
// Se è sfera la sottraggo
if ( m_Tool.GetType() == Tool::BALLMILL) {
Point3d ptSBall = ptS - dStemHeigth * vtToolDir ;
Point3d ptEBall = ptE - dStemHeigth * vtToolDir ;
CompBall_Milling( nGrid, ptSBall, ptEBall, m_Tool.GetRadius()) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::CylBall_Milling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
VolZmap::CylBall_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
{
double dStemHeigth = m_Tool.GetHeigth() ;
// Sfera
if ( m_Tool.GetType() == Tool::BALLMILL)
dStemHeigth -= m_Tool.GetRadius() ;
// Altezza cilindro
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
// Sottraggo cilindro
CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, false) ;
// Sfera
// Se è sfera la sottraggo
if ( m_Tool.GetType() == Tool::BALLMILL) {
Point3d ptSBall = ptS - dStemHeigth * vtToolDir ;
Point3d ptEBall = ptE - dStemHeigth * vtToolDir ;
CompBall_Milling( nGrid, ptSBall, ptEBall, m_Tool.GetRadius()) ;
}
return true ;
}
// ---------- Coni -----------------------------------------------------------
//----------------------------------------------------------------------------
bool
VolZmap::Conus_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
VolZmap::Conus_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
{
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
@@ -2838,7 +2825,7 @@ VolZmap::Conus_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3d
//----------------------------------------------------------------------------
bool
VolZmap::Conus_Milling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
VolZmap::Conus_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
{
double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ;
@@ -2848,13 +2835,15 @@ VolZmap::Conus_Milling( unsigned int nGrid, const Point3d & ptS, const Point3d &
if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) {
Point3d ptSBall = ptS - dStemHeigth * vtToolDir ;
Point3d ptEBall = ptE - dStemHeigth * vtToolDir ;
CompConus_Milling( nGrid, ptSBall, ptEBall, vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetRadius(), m_Tool.GetTipRadius(), true, false) ;
CompConus_Milling( nGrid, ptSBall, ptEBall, vtToolDir, m_Tool.GetTipHeigth(),
m_Tool.GetRadius(), m_Tool.GetTipRadius(), true, false) ;
}
else {
Point3d ptSBall = ptS - m_Tool.GetHeigth() * vtToolDir ;
Point3d ptEBall = ptE - m_Tool.GetHeigth() * vtToolDir ;
CompConus_Milling( nGrid, ptSBall, ptEBall, - vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetTipRadius(), m_Tool.GetRadius(), false, true) ;
CompConus_Milling( nGrid, ptSBall, ptEBall, - vtToolDir, m_Tool.GetTipHeigth(),
m_Tool.GetTipRadius(), m_Tool.GetRadius(), false, true) ;
}
return true ;
@@ -3227,7 +3216,7 @@ VolZmap::CompCyl_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Point
// Quote estreme del gambo
double dMinStemZ = min( min( ptS.z, ptTStemS.z), min( ptE.z, ptTStemE.z)) ;
double dMaxStemZ = max( max( ptS.z, ptTStemS.z), max( ptS.z, ptTStemS.z)) ;
double dMaxStemZ = max( max( ptS.z, ptTStemS.z), max( ptE.z, ptTStemE.z)) ;
// Ciclo sui punti
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
@@ -3287,7 +3276,7 @@ VolZmap::CompConus_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Poi
Vector3d vtMin, vtMax ;
// Ciclo sui punti
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i)
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
double dX = ( i + 0.5) * m_dStep ; double dY = ( j + 0.5) * m_dStep ;
@@ -3296,8 +3285,9 @@ VolZmap::CompConus_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Poi
double dSqDist = vtC * vtC ;
if ( dSqDist < dSqMinRad)
SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX) ;
if ( dSqDist < dSqMinRad) {
SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX) ;
}
else if ( dSqDist < dSafeSqMaxRad) { // dSafeSqMaxRad è sperimentale
@@ -3319,7 +3309,7 @@ VolZmap::CompConus_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Poi
vtMin.Normalize() ;
SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ;
SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ;
}
else {
@@ -3338,11 +3328,12 @@ VolZmap::CompConus_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Poi
vtMax.Normalize() ;
SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ;
SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ;
}
}
}
}
return true ;
}
@@ -3904,6 +3895,7 @@ bool
VolZmap::CompCyl_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir,
double dHei, double dRad, bool bTapB, bool bTapT)
{
// Verifico che il cilindro con il suo movimento intersechi la griglia
unsigned int nStartI, nEndI, nStartJ, nEndJ ;
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
dRad, dRad, dHei) ;
@@ -3914,40 +3906,20 @@ VolZmap::CompCyl_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d
Point3d ptI = ( ( ptE - ptS) * vtToolDir > 0 ? ptE : ptS) ;
Point3d ptF = ( ( ptE - ptS) * vtToolDir > 0 ? ptS - vtToolDir * dHei : ptE - vtToolDir * dHei) ;
// Sistema di riferimento cilindro
Vector3d vtV1 = - vtToolDir ;
// Altezza cilindro totale altezza + moto
double dH = ( ptF - ptI).Len() ;
Point3d ptP = ( abs( vtV1.z) < EPS_SMALL ? Point3d( ptI.x, ptI.y, ptI.z + 1) : Point3d( ptI.x + 1, ptI.y, ptI.z)) ;
Vector3d vtV = ( abs( vtV1.z) < EPS_SMALL ? vtToolDir : Z_AX) ;
// Sistema di riferimento del cilindro
Frame3d CylFrame ; CylFrame.Set( ptF, vtToolDir) ;
Vector3d vtV2 = ptP - ptI + ( ( ( ptI - ptP) * vtV1) / ( vtV * vtV1)) * vtV ;
vtV2.Normalize() ;
Vector3d vtV3 = vtV1 ^ vtV2 ;
Frame3d CylFrame ; CylFrame.Set( ptI, vtV1, vtV2, vtV3) ;
double dMin, dMax;
Vector3d vtNmin, vtNmax ;
// Lunghezzza cilindro totale altezza + moto
double dLen = ( ptF - ptI).Len() ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
double dX = ( i + 0.5) * m_dStep ;
double dY = ( j + 0.5) * m_dStep ;
Point3d ptC( dX, dY, 0) ;
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
Point3d ptInt1, ptInt2 ;
Vector3d vtN1, vtN2 ;
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dLen, dRad, bTapB, bTapT, ptInt1, ptInt2,vtN1, vtN2)) {
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, dRad, bTapB, bTapT, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -3960,7 +3932,6 @@ VolZmap::CompCyl_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
}
@@ -3970,7 +3941,7 @@ VolZmap::CompCyl_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d
//----------------------------------------------------------------------------
bool
VolZmap::CompConus_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir,
VolZmap::CompConus_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir,
double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT)
{
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
@@ -3982,39 +3953,23 @@ VolZmap::CompConus_Drilling( unsigned int nGrid, const Point3d & ptS, const Poin
// Apertura del cono
double dDeltaR = dMaxRad - dMinRad ;
double dTan = dDeltaR / dHei ;
double dL = ( ( dMaxRad * dHei) / dDeltaR) ;
double dl = dL - dHei ;
double dConeMaxH = ( ( dMaxRad * dHei) / dDeltaR) ;
double dConeMinH = dConeMaxH - dHei ;
bool bTapCylEn = bTapB ;
Point3d ptVertex = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) - vtToolDir * dL ;
Point3d ptVertex = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) - vtToolDir * dConeMaxH ;
// Sistema di riferimento del cono
Vector3d vtV1 = vtToolDir ;
// Sistemi di riferimento del cono e del cilindro
Frame3d ConusFrame ; ConusFrame.Set( ptVertex, vtToolDir) ;
Frame3d CylFrame = ConusFrame ; CylFrame.Translate( vtToolDir * dConeMaxH) ;
Point3d ptP = ( abs( vtV1.z) < EPS_SMALL ? Point3d( ptVertex.x, ptVertex.y, ptVertex.z + 1) :
Point3d( ptVertex.x + 1, ptVertex.y, ptVertex.z)) ;
// L'altezza del cilindro è il movimento
double dH = ( ptE - ptS).Len() ;
Vector3d vtV = ( abs( vtV1.z) < EPS_SMALL ? vtToolDir : Z_AX) ;
Vector3d vtV2 = ptP - ptVertex + ( ( ( ptVertex - ptP) * vtV1) / ( vtV * vtV1)) * vtV ;
vtV2.Normalize() ;
Vector3d vtV3 = vtV1 ^ vtV2 ;
Frame3d ConusFrame ; ConusFrame.Set( ptVertex, vtV1, vtV2, vtV3) ;
// Lunghezzza cilindro totale altezza + moto
double dLen = ( ptE - ptS).Len() ;
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
double dX = ( i + 0.5) * m_dStep ;
double dY = ( j + 0.5) * m_dStep ;
@@ -4024,40 +3979,42 @@ VolZmap::CompConus_Drilling( unsigned int nGrid, const Point3d & ptS, const Poin
Vector3d vtN1, vtN2 ;
// Cilindro
if ( IntersLineCylinder( ptC - vtV1 * dL, Z_AX, ConusFrame, dLen, dMaxRad, true, bTapCylEn,
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, dMaxRad, true, bTapCylEn,
ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtV1.z * dL ;
dMax = ptInt2.z + vtV1.z * dL ;
dMin = ptInt1.z ;
dMax = ptInt2.z ;
vtNmin = vtN1 ;
vtNmax = vtN2 ;
}
else {
dMin = ptInt2.z + vtV1.z * dL ;
dMax = ptInt1.z + vtV1.z * dL ;
dMin = ptInt2.z ;
dMax = ptInt1.z ;
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Cono
if ( IntersLineConus( ptC , Z_AX, ConusFrame, dTan, dl, dL, bTapT, true,
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dConeMinH, dConeMaxH, bTapT, true,
ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z /*+ vtV1.z * dL*/ ;
dMax = ptInt2.z /*+ vtV1.z * dL*/ ;
dMin = ptInt1.z ;
dMax = ptInt2.z ;
vtNmin = vtN1 ;
vtNmax = vtN2 ;
}
else {
dMin = ptInt2.z /*+ vtV1.z * dL*/ ;
dMax = ptInt1.z /*+ vtV1.z * dL*/ ;
dMin = ptInt2.z ;
dMax = ptInt1.z ;
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
}
@@ -4078,14 +4035,14 @@ VolZmap::CompPar_Drilling( unsigned int nGrid, double dLenX, double dLenY, doubl
return true ;
// Costruzione di un sistema di riferimento per il volume
// asportato dal solido nelle psoizioni iniziale e finale.
// asportato dal solido nelle posizioni iniziale e finale.
Vector3d vtV1 = vtToolDir ;
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 ;
Frame3d ParaFrame ; ParaFrame.Set( ptO, vtV1, vtV2, vtV3) ;
Frame3d ParaFrame ; ParaFrame.Set( ptO, vtV2, vtV3, vtV1) ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
@@ -4098,7 +4055,7 @@ VolZmap::CompPar_Drilling( unsigned int nGrid, double dLenX, double dLenY, doubl
Point3d ptInt1, ptInt2 ;
Vector3d vtN1, vtN2 ;
if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenZ + dLenMove, dLenX, dLenY, 0, ptInt1, ptInt2, vtN1, vtN2)) {
if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenX, dLenY, dLenZ + dLenMove, 0, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
@@ -4141,7 +4098,6 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
// Studio delle simmetrie
Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ;
Point3d ptF = ( vtToolDir * ( ptE - ptS) > 0 ? ptE : ptS) ;
Point3d ptITip = ptI - vtToolDir * dHei ;
Point3d ptFTip = ptF - vtToolDir * dHei ;
@@ -4153,8 +4109,10 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
Vector3d vtV1 = vtToolDir ;
Vector3d vtV2 = vtMoveOrt ; vtV2.Normalize() ;
Vector3d vtV3 = vtV1 ^ vtV2 ;
Frame3d CylFrame ; CylFrame.Set( ptITip, vtV2, vtV3, vtV1) ;
Frame3d CylFrame ; CylFrame.Set( ptITip, vtV1, vtV2, vtV3) ;
// Verifica se movimento lungo Z
bool bMoveOnZ = ( vtMove.IsZplus() || vtMove.IsZminus()) ;
// Parametri geometrici di moto e cilindro
double dSqRad = dRad * dRad ;
@@ -4167,10 +4125,6 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
bool bCylEn = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ;
bool bElpsB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ;
bool bElpsT = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapT) ;
// Minima e massima quota z
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
@@ -4182,6 +4136,8 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
// Cilindro iniziale
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, bCylSt, bCylEn, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -4194,7 +4150,6 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
@@ -4202,6 +4157,8 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
// del sistema di riferimento, quindi usiamo lo stesso sistema sommando a ptC
// il vettore che congiunge le due origini.
if ( IntersLineCylinder( ptC - vtMove, Z_AX, CylFrame, dHei, dRad, bCylSt, bCylEn, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtMove.z ;
dMax = ptInt2.z + vtMove.z ;
@@ -4214,12 +4171,13 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Poliedro interno
if ( IntersLineMyPolyhedron( ptC, Z_AX, CylFrame, dHei, dOrtLen, 2 * dRad, dLongLen, ptInt1, ptInt2, vtN1, vtN2)) {
if ( ! bMoveOnZ && IntersLineMyPolyhedron( ptC, Z_AX, CylFrame, dOrtLen, 2 * dRad, dHei, dLongLen, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -4232,13 +4190,14 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Cilindro ellittico di punta
if ( IntersLineEllipticalCylinder( Z_AX, ptC, CylFrame, dSqRad,
dLongLen, dOrtLen, bElpsT, bElpsT, ptInt1, ptInt2, vtN1, vtN2)) {
if ( ! bMoveOnZ && IntersLineEllipticalCylinder( Z_AX, ptC, CylFrame, dSqRad,
dLongLen, dOrtLen, bElpsT, bElpsT, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -4251,15 +4210,16 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Cilindro ellittico di base: L'unica differenza rispetto a prima è l'origine
// del sistema di riferimento, quindi usiamo lo stesso sistema sommando a ptC
// il vettore che congiunge le due origini.
if ( IntersLineEllipticalCylinder( Z_AX, ptC - dHei * vtV1, CylFrame, dSqRad,
if ( ! bMoveOnZ && IntersLineEllipticalCylinder( Z_AX, ptC - dHei * vtV1, CylFrame, dSqRad,
dLongLen, dOrtLen, bElpsB, bElpsB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + dHei * vtV1.z ;
dMax = ptInt2.z + dHei * vtV1.z ;
@@ -4272,7 +4232,6 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
}
@@ -4313,13 +4272,16 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
Vector3d vtMvLong = ( vtMove * vtToolDir) * vtToolDir ;
Vector3d vtMvOrt = vtMove - vtMvLong ;
// Verifica se movimento lungo Z
bool bMoveOnZ = ( vtMove.IsZplus() || vtMove.IsZminus()) ;
// Terna destrorsa e unitaria
Vector3d vtV1 = vtToolDir ;
Vector3d vtV2 = vtMvOrt ; vtV2.Normalize() ;
Vector3d vtV3 = vtV1 ^ vtV2 ;
// Sistema di riferimento intrinseco del movimento
Frame3d ConusFrame ; ConusFrame.Set( ptV, vtV1, vtV2, vtV3) ;
Frame3d ConusFrame ; ConusFrame.Set( ptV, vtV2, vtV3, vtV1) ;
// Dimensioni lineari movimento
double dLongLen = vtMvLong.Len() ;
@@ -4380,9 +4342,6 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
bool bElpsB = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapB) ;
bool bElpsT = ( abs( vtToolDir * vtUmv) > EPS_SMALL ? true : bTapT) ;
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( dRatio * dTan <= 1) {
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
@@ -4398,7 +4357,8 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
// Cono iniziale
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dl, dL, bConeT, bConeB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -4411,13 +4371,13 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Cono finale
if ( IntersLineConus( ptC - vtMove, Z_AX, ConusFrame, dTan, dl, dL, bConeT, bConeB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtMove.z ;
dMax = ptInt2.z + vtMove.z ;
@@ -4430,7 +4390,6 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
@@ -4488,12 +4447,12 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
if ( nIntNum == 0) {
ptInt1 = ptPoly3 ;
vtN1 = - vtIF ;
vtN1 = vtIF ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptPoly3).SqLen() > dSqIndet) {
ptInt2 = ptPoly3 ;
vtN2 = - vtIF ;
vtN2 = vtIF ;
++ nIntNum ;
}
}
@@ -4507,12 +4466,12 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
if ( nIntNum == 0) {
ptInt1 = ptPoly4 ;
vtN1 = vtIF ;
vtN1 = - vtIF ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptPoly4).SqLen() > dSqIndet) {
ptInt2 = ptPoly4 ;
vtN2 = vtIF ;
vtN2 = - vtIF ;
++ nIntNum ;
}
}
@@ -4555,35 +4514,38 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
}
}
}
// Se il poliedro è attraversato taglio
if ( nIntNum == 2) {
// Se il poliedro è attraversato taglio
if ( nIntNum == 2) {
// Riporto le intersezioni nel sistema griglia
ptInt1.ToGlob( PolyFrame) ;
ptInt2.ToGlob( PolyFrame) ;
// Riporto le intersezioni nel sistema griglia
ptInt1.ToGlob( PolyFrame) ;
ptInt2.ToGlob( PolyFrame) ;
vtN1.ToGlob( PolyFrame) ;
vtN2.ToGlob( PolyFrame) ;
vtN1.ToGlob( PolyFrame) ;
vtN2.ToGlob( PolyFrame) ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
vtNmin = vtN1 ;
vtNmax = vtN2 ;
}
else {
dMin = ptInt2.z ;
dMax = ptInt1.z ;
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
vtNmin = vtN1 ;
vtNmax = vtN2 ;
}
else {
dMin = ptInt2.z ;
dMax = ptInt1.z ;
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Traslazione ellisse di punta
if ( IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dl, ConusFrame, dSqMinRad,
if ( ! bMoveOnZ && IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dl, ConusFrame, dSqMinRad,
dLongLen, dOrtLen, bElpsT, bElpsT, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtV1.z * dl ;
dMax = ptInt2.z + vtV1.z * dl ;
@@ -4596,13 +4558,14 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Traslazione ellisse di base
if ( IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dL, ConusFrame, dSqMaxRad,
dLongLen, dOrtLen, bElpsB, bElpsB, ptInt1, ptInt2, vtN1, vtN2)) {
if ( ! bMoveOnZ && IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dL, ConusFrame, dSqMaxRad,
dLongLen, dOrtLen, bElpsB, bElpsB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtV1.z * dL ;
dMax = ptInt2.z + vtV1.z * dL ;
@@ -4615,7 +4578,6 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
}
@@ -4637,6 +4599,8 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
// Cono
if ( IntersLineConus( ptC, Z_AX, ConusFrame, dTan, dl, dL, bConeT, bConeB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z ;
dMax = ptInt2.z ;
@@ -4649,13 +4613,14 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
// Traslazione ellisse
if ( IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dL, ConusFrame, dSqMaxRad,
dLongLen, dOrtLen, bConeB, bConeB, ptInt1, ptInt2, vtN1, vtN2)) {
if ( ! bMoveOnZ && IntersLineEllipticalCylinder( Z_AX, ptC - vtV1 * dL, ConusFrame, dSqMaxRad,
dLongLen, dOrtLen, bConeB, bConeB, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if( ptInt1.z < ptInt2.z) {
dMin = ptInt1.z + vtV1.z * dL ;
dMax = ptInt2.z + vtV1.z * dL ;
@@ -4668,7 +4633,6 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
vtNmin = vtN2 ;
vtNmax = vtN1 ;
}
SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ;
}
}
@@ -4698,10 +4662,7 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
Vector3d vtV2 = ( vtMove * ( vtV1 ^ vtAux) > 0 ? ( vtV1 ^ vtAux) : ( vtAux ^ vtV1)) ;
Vector3d vtV3 = vtV1 ^ vtV2 ;
Point3d ptO = ptS - dLenZ * vtV1 - vtV2 * ( 0.5 * dLenX) ;
Frame3d ParaFrame ; ParaFrame.Set( ptO, vtV1, vtV2, vtV3) ;
// Lunghezza della traiettoria
double dLenMove = vtMove * vtV2 ;
Frame3d ParaFrame ; ParaFrame.Set( ptO, vtV2, vtV3, vtV1) ;
// Studio del volume asportato durante il moto
Point3d ptLs = ( vtMove * vtAux >= 0 ? ptS : ptE) ;
@@ -4712,20 +4673,20 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
Vector3d vtMv = ptLe - ptLs ;
bool bSymmetry = vtMv * ( vtW3 ^ vtToolDir) > 0 ;
bool bSymmetry = vtMv * vtAnsatz > 0 ;
Vector3d vtW2 = ( bSymmetry ? vtAnsatz : - vtAnsatz) ;
Vector3d vtW1 = ( bSymmetry ? vtToolDir : - vtToolDir) ;
Point3d ptBase = bSymmetry ? ptLs - dLenZ * vtW1 : ptLs ;
Frame3d MotionFrame ; /*MotionFrame.Set( ptOMotion, vtU1, vtU2, vtU3) ;*/
Frame3d MotionFrame ;
Point3d ptDiagMin = ptBase - vtW2 * ( 0.5 * dLenX) + vtW3 * ( 0.5 * dLenY) ;
Point3d ptDiagMax = ptBase + vtW2 * ( 0.5 * dLenX) - vtW3 * ( 0.5 * dLenY) ;
Vector3d vtU1 = ptDiagMax - ptDiagMin ;
double dDimX = ( ptDiagMax - ptDiagMin).Len() ;
double dDimLong = ( ptDiagMax - ptDiagMin).Len() ;
vtU1.Normalize() ;
bool bSymmetry2 = vtU1 * vtMv > 0 ;
Vector3d vtU2 = ( bSymmetry2 ? vtMv - vtMv * vtU1 * vtU1 :
@@ -4735,10 +4696,10 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
Point3d ptOMotion = ( vtMv * vtU1 > 0 ? ptDiagMin : ptDiagMin + vtMv) + vtU3 * ( 0.5 * dLenZ) ;
MotionFrame.Set( ptOMotion, vtU1, vtU2, vtU3) ;
MotionFrame.Set( ptOMotion, vtU2, vtU3, vtU1) ;
double dLen1 = abs( vtMv * vtU1) ;
double dLen2 = abs( vtMv * vtU2) ;
double dDeltaLong = abs( vtMv * vtU1) ;
double dDimOrt = abs( vtMv * vtU2) ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
@@ -4752,7 +4713,7 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
Vector3d vtN1, vtN2 ;
// Solido nella posizione iniziale
if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenZ, dLenX, dLenY, 0, ptInt1, ptInt2, vtN1, vtN2)) {
if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenX, dLenY, dLenZ, 0, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
@@ -4772,7 +4733,7 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
}
// Solido nella posizione finale
if ( IntersLineMyPolyhedron( ptC - vtMove, Z_AX, ParaFrame, dLenZ, dLenX, dLenY, 0, ptInt1, ptInt2, vtN1, vtN2)) {
if ( IntersLineMyPolyhedron( ptC - vtMove, Z_AX, ParaFrame, dLenX, dLenY, dLenZ, 0, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
@@ -4792,7 +4753,7 @@ VolZmap::CompPar_Milling( unsigned int nGrid, double dLenX, double dLenY, double
}
// Volume spazzato nel moto
if ( IntersLineMyPolyhedron( ptC, Z_AX, MotionFrame, dDimX, dLen2, dLenZ, dLen1, ptInt1, ptInt2, vtN1, vtN2)) {
if ( IntersLineMyPolyhedron( ptC, Z_AX, MotionFrame, dDimOrt, dLenZ, dDimLong, dDeltaLong, ptInt1, ptInt2, vtN1, vtN2)) {
double dMin, dMax ;
Vector3d vtNmin, vtNmax ;
if ( ptInt1.z < ptInt2.z) {
@@ -4836,18 +4797,18 @@ VolZmap::CompBall_Milling( unsigned int nGrid, const Point3d & ptLs, const Point
Vector3d vtW ;
// Costruisco sistema di riferimento
if ( vtV.x * vtV.x > 0.3)
if ( vtV.x * vtV.x > 0.09)
vtW.Set( - ( vtV.y + vtV.z) / vtV.x, 1, 1) ;
else if ( vtV.y * vtV.y > 0.3)
else if ( vtV.y * vtV.y > 0.09)
vtW.Set( 1, - ( vtV.x + vtV.z) / vtV.y, 1) ;
else
vtW.Set( 1, 1, - ( vtV.x + vtV.y) / vtV.z) ;
Point3d ptOnY = ptLs + vtW ;
//Point3d ptOnX = ptLs + vtW ;
Frame3d CylFrame ; CylFrame.Set( ptLs, ptLe, ptOnY) ;
Frame3d CylFrame ; CylFrame.Set( ptLs, vtV, vtW) ;
double dSqRad = dRad * dRad ;