EgtGeomKernel :
- modifiche a calcolo spilloni di Zmap e varie altre.
This commit is contained in:
+173
-183
@@ -694,56 +694,53 @@ VolZmap::AvoidCylinder( const Frame3d& frCyl, double dL, double dR) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// NB: L'origine del sistema di riferimento è nel centro della circonferenza di base
|
||||
// e l'asse di simmetria coincide con l'asse z.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
bool
|
||||
VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dL, double dR, bool bTapO, bool bTapL,
|
||||
const Frame3d& CylFrame, double dH, double dR, bool bTapO, bool bTapL,
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento è nel centro della circonferenza di base
|
||||
// e l'asse di simmetria coincide con l'asse x.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
|
||||
Point3d ptP = ptLineSt ;
|
||||
Vector3d vtV = vtLineDir ;
|
||||
|
||||
// Trasformazione delle coordinate:
|
||||
// l'asse del cilindro corrisponde con
|
||||
// l'asse x del sistema di riferimento
|
||||
// l'asse z del sistema di riferimento
|
||||
ptP.ToLoc( CylFrame) ;
|
||||
vtV.ToLoc( CylFrame) ;
|
||||
|
||||
DBLVECTOR vdCoef(3) ;
|
||||
DBLVECTOR vdRoots ;
|
||||
// Non vogliamo che i dexel a filo vengano tagliati
|
||||
double dSqRad = dR * dR ;
|
||||
double dSqRadSafe = dSqRad - 2 * dR * EPS_SMALL ;
|
||||
|
||||
double dSqRad = dR * dR - 2 * dR * EPS_SMALL ;
|
||||
|
||||
vdCoef[0] = ptP.y * ptP.y + ptP.z * ptP.z - dSqRad ;
|
||||
vdCoef[1] = 2 * ( ptP.y * vtV.y + ptP.z * vtV.z) ;
|
||||
vdCoef[2] = vtV.y * vtV.y + vtV.z * vtV.z ;
|
||||
vdCoef[0] = ptP.x * ptP.x + ptP.y * ptP.y - dSqRad ;
|
||||
vdCoef[1] = 2 * ( ptP.x * vtV.x + ptP.y * vtV.y) ;
|
||||
vdCoef[2] = vtV.x * vtV.x + vtV.y * vtV.y ;
|
||||
|
||||
// Computo radici
|
||||
int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ;
|
||||
|
||||
// Nessuna soluzione
|
||||
if ( nRoot == 0 || nRoot == 1) {
|
||||
|
||||
if ( abs( vtV.x) > EPS_ZERO) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
if ( ptInt1.y * ptInt1.y + ptInt1.z * ptInt1.z <= dSqRad &&
|
||||
ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z <= dSqRad) {
|
||||
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
// Intersezioni con i piani che limitano il cilindro in altezza
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
// Normali nei punti di interseione
|
||||
vtN1 = Z_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
// Se le soluzioni sono all'interno delle circonferenze
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y <= dSqRadSafe &&
|
||||
ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y <= dSqRadSafe) {
|
||||
// Trasformiamo le coordinate nel sistema Zmap e abbiamo finito
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
return true ;
|
||||
}
|
||||
// Nessuna intersezione
|
||||
@@ -760,43 +757,40 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
// appartiene alla superficie
|
||||
|
||||
if ( nRoot == 2) {
|
||||
|
||||
// Tolleranze per tagliare o meno i dexel a filo sulle
|
||||
// circonferenze di base e di top.
|
||||
double dEpsO = ( bTapO ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsL = ( bTapL ? EPS_SMALL : - EPS_SMALL) ;
|
||||
|
||||
// Punti d'intersezione trovati
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
if ( ptInt1.z > ptInt2.z)
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
vtN1.Set( 0, ( ORIG - ptInt1).y, ( ORIG - ptInt1).z) ;
|
||||
vtN2.Set( 0, ( ORIG - ptInt2).y, ( ORIG - ptInt2).z) ;
|
||||
|
||||
|
||||
if ( ptInt1.x < dL + dEpsL) {
|
||||
|
||||
if ( ptInt1.x > dEpsO) {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsL) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
vtN2.Set( -1, 0, 0) ;
|
||||
// Setto le normali
|
||||
vtN1.Set( ( ORIG - ptInt1).x, ( ORIG - ptInt1).y, 0) ;
|
||||
vtN2.Set( ( ORIG - ptInt2).x, ( ORIG - ptInt2).y, 0) ;
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
// Studio le soluzioni
|
||||
if ( ptInt1.z < dH + dEpsL) {
|
||||
if ( ptInt1.z > dEpsO) {
|
||||
if ( ptInt2.z > dH + dEpsL) {
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
vtN2.Set( 0, 0, -1) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsL) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
vtN2.Set( -1, 0, 0) ;
|
||||
if ( ptInt2.z > dH + dEpsL) {
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
vtN1.Set( 0, 0, 1) ;
|
||||
vtN2.Set( 0, 0, -1) ;
|
||||
}
|
||||
else if ( ptInt2.x > dEpsO) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
else if ( ptInt2.z > dEpsO) {
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
vtN1.Set( 0, 0, 1) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -809,12 +803,8 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -926,7 +916,7 @@ VolZmap::IntersZLineCylinder( const Point3d& ptLine,
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& ConusFrame, double dTan, double dl, double dL, bool bTapLow, bool bTapUp,
|
||||
const Frame3d& ConusFrame, double dTan, double dh, double dH, bool bTapLow, bool bTapUp,
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
@@ -944,14 +934,14 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
DBLVECTOR vdRoots ;
|
||||
|
||||
double dSqTan = dTan * dTan ;
|
||||
double dMinRad = dTan * dl ;
|
||||
double dMaxRad = dTan * dL ;
|
||||
double dMinRad = dTan * dh ;
|
||||
double dMaxRad = dTan * dH ;
|
||||
double dDeltaR = dMaxRad - dMinRad ;
|
||||
double dHei = dL - dl ;
|
||||
double dHei = dH - dh ;
|
||||
|
||||
vdCoef[0] = dSqTan * ptP.x * ptP.x - ptP.y * ptP.y - ptP.z * ptP.z ;
|
||||
vdCoef[1] = 2 * ( dSqTan * ptP.x * vtV.x - ptP.y * vtV.y - ptP.z * vtV.z) ;
|
||||
vdCoef[2] = dSqTan * vtV.x * vtV.x - vtV.y * vtV.y - vtV.z * vtV.z ;
|
||||
vdCoef[0] = dSqTan * ptP.z * ptP.z - ptP.x * ptP.x - ptP.y * ptP.y ;
|
||||
vdCoef[1] = 2 * ( dSqTan * ptP.z * vtV.z - ptP.x * vtV.x - ptP.y * vtV.y) ;
|
||||
vdCoef[2] = dSqTan * vtV.z * vtV.z - vtV.x * vtV.x - vtV.y * vtV.y ;
|
||||
|
||||
// Computo radici
|
||||
int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ;
|
||||
@@ -969,32 +959,32 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
|
||||
Vector3d vtU = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
Vector3d vtU = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).z * Z_AX ;
|
||||
|
||||
vtU.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU ;
|
||||
vtN1 = dDeltaR * Z_AX - dHei * vtU ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
|
||||
if ( ptInt1.x < dL + dEpsUp) {
|
||||
if ( ptInt1.z < dH + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow) {
|
||||
if ( ptInt1.z > dh + dEpsLow) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
else if ( ptInt1.z > - EPS_SMALL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt1 = ptP + ( ( dh - ptP.z) / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
vtN1 = Z_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
|
||||
if ( ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z > dMaxRad * dMaxRad)
|
||||
if ( ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y > dMaxRad * dMaxRad)
|
||||
|
||||
return false ;
|
||||
}
|
||||
@@ -1020,24 +1010,24 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
if ( ptInt1.z > ptInt2.z)
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
Vector3d vtU1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
Vector3d vtU2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG).x * X_AX ;
|
||||
Vector3d vtU1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).z * Z_AX ;
|
||||
Vector3d vtU2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG).z * Z_AX ;
|
||||
|
||||
vtU1.Normalize() ;
|
||||
vtU2.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU1 ;
|
||||
vtN2 = dDeltaR * X_AX - dHei * vtU2 ;
|
||||
vtN1 = dDeltaR * Z_AX - dHei * vtU1 ;
|
||||
vtN2 = dDeltaR * Z_AX - dHei * vtU2 ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
if ( abs( vtV.x) < EPS_ZERO) {
|
||||
if ( abs( vtV.z) < EPS_ZERO) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow && ptInt1.x < dL + dEpsUp) {
|
||||
if ( ptInt1.z > dh + dEpsLow && ptInt1.z < dH + dEpsUp) {
|
||||
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
@@ -1055,53 +1045,53 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
}
|
||||
|
||||
|
||||
if ( ptInt1.x < dL + dEpsUp) {
|
||||
if ( ptInt1.z < dH + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow) {
|
||||
if ( ptInt1.z > dh + dEpsLow) {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsUp) {
|
||||
if ( ptInt2.z > dH + dEpsUp) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
else if ( ptInt1.z > - EPS_SMALL) {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsUp) {
|
||||
if ( ptInt2.z > dH + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt1 = ptP + ( ( dh - ptP.z) / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
vtN1 = Z_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
else if ( ptInt2.x > dl + dEpsLow) {
|
||||
else if ( ptInt2.z > dh + dEpsLow) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
vtN1 = X_AX ;
|
||||
ptInt1 = ptP + ( ( dh - ptP.z) / vtV.z) * vtV ;
|
||||
vtN1 = Z_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x < 0)
|
||||
if ( ptInt2.z < 0)
|
||||
|
||||
return false ;
|
||||
|
||||
else if ( ptInt2.x < dl + dEpsLow) {
|
||||
else if ( ptInt2.z < dh + dEpsLow) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt1 = ptP + ( ( dh - ptP.z) / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
vtN1 = Z_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
else if ( ptInt2.x < dL + dEpsUp) {
|
||||
else if ( ptInt2.z < dH + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
vtN1 = - X_AX ;
|
||||
ptInt1 = ptP + ( ( dH - ptP.z) / vtV.z) * vtV ;
|
||||
vtN1 = - Z_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -1133,13 +1123,13 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
// nel centro della circonferenza di base, la cui traslazione obliqua
|
||||
// genera il cilindro ellittico, e l'asse x deve essere l'asse
|
||||
// genera il cilindro ellittico, e l'asse z deve essere l'asse
|
||||
// di simmetria di tale circonferenza.
|
||||
// La funzione restituisce true in caso di intersezione, false altrimenti.
|
||||
// NB: dSqRad è il quadrato del raggio della circonferenza la cui
|
||||
// traslazione obliqua genera il cilindro ellittico, dLongMvLen e
|
||||
// dOrtMvLen sono rispettivamente le lunghezze delle proiezioni del
|
||||
// movimento su x e y del sistema di riferimento CircFrame.
|
||||
// movimento su z e x del sistema di riferimento CircFrame.
|
||||
|
||||
double dObCoef = dOrtMvLen / dLongMvLen ;
|
||||
double dSqCoef = dObCoef * dObCoef ;
|
||||
@@ -1148,7 +1138,7 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
Vector3d vtV = vtLineDir ;
|
||||
|
||||
// Asse cilindro ellittico
|
||||
Vector3d vtAx( dLongMvLen, dOrtMvLen, 0) ;
|
||||
Vector3d vtAx( dOrtMvLen, 0, dLongMvLen) ;
|
||||
vtAx.Normalize() ;
|
||||
|
||||
// Trasformazione delle coordinate
|
||||
@@ -1158,9 +1148,9 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
vector <double> vdCoef(3) ;
|
||||
vector <double> vdRoots ;
|
||||
|
||||
vdCoef[0] = dSqCoef * ptP.x * ptP.x + ptP.y * ptP.y + ptP.z * ptP.z - 2 * dObCoef * ptP.x * ptP.y - dSqRad ;
|
||||
vdCoef[1] = 2 * ( dSqCoef * vtV.x * ptP.x + vtV.y * ptP.y + vtV.z * ptP.z - dObCoef * ( vtV.x * ptP.y + vtV.y * ptP.x)) ;
|
||||
vdCoef[2] = dSqCoef * vtV.x * vtV.x + vtV.y * vtV.y + vtV.z * vtV.z - 2 * dObCoef * vtV.x * vtV.y ;
|
||||
vdCoef[0] = dSqCoef * ptP.z * ptP.z + ptP.x * ptP.x + ptP.y * ptP.y - 2 * dObCoef * ptP.z * ptP.x - dSqRad ;
|
||||
vdCoef[1] = 2 * ( dSqCoef * vtV.z * ptP.z + vtV.x * ptP.x + vtV.y * ptP.y - dObCoef * ( vtV.z * ptP.x + vtV.x * ptP.z)) ;
|
||||
vdCoef[2] = dSqCoef * vtV.z * vtV.z + vtV.x * vtV.x + vtV.y * vtV.y - 2 * dObCoef * vtV.z * vtV.x ;
|
||||
|
||||
int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ;
|
||||
|
||||
@@ -1168,19 +1158,19 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
// Nessuna soluzione
|
||||
if ( nRoot == 0 || nRoot == 1) {
|
||||
|
||||
if ( abs( vtV.x) > EPS_ZERO) {
|
||||
if ( abs( vtV.z) > EPS_ZERO) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
if ( ptInt1.y * ptInt1.y + ptInt1.z * ptInt1.z < dSqRad &&
|
||||
( ptInt2.y - dOrtMvLen) * ( ptInt2.y - dOrtMvLen) + ptInt2.z * ptInt2.z < dSqRad) {
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y < dSqRad &&
|
||||
( ptInt2.x - dOrtMvLen) * ( ptInt2.x - dOrtMvLen) + ptInt2.y * ptInt2.y < dSqRad) {
|
||||
|
||||
ptInt1.ToGlob( CircFrame) ;
|
||||
ptInt2.ToGlob( CircFrame) ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
vtN1 = Z_AX ;
|
||||
vtN2 = - Z_AX ;
|
||||
|
||||
vtN1.ToGlob( CircFrame) ;
|
||||
vtN2.ToGlob( CircFrame) ;
|
||||
@@ -1203,7 +1193,7 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
// coincidenti) oppure nessuna o infinite se la la retta
|
||||
// appartiene alla superficie
|
||||
|
||||
Vector3d vtMv( dLongMvLen, dOrtMvLen, 0) ;
|
||||
Vector3d vtMv( dOrtMvLen, 0, dLongMvLen) ;
|
||||
|
||||
if ( nRoot == 2) {
|
||||
|
||||
@@ -1211,76 +1201,76 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
if ( ptInt1.z > ptInt2.z)
|
||||
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
Vector3d vtTest1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG) * vtAx * vtAx ;
|
||||
Vector3d vtTest2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG) * vtAx * vtAx ;
|
||||
|
||||
double dY0_1, dY0_2 ;
|
||||
double dX0_1, dX0_2 ;
|
||||
|
||||
if ( vtTest1.y > 0) {
|
||||
if ( vtTest1.x > 0) {
|
||||
|
||||
dY0_1 = ( dSqRad - ptInt1.z * ptInt1.z > 0 ? sqrt( dSqRad - ptInt1.z * ptInt1.z) : 0) ;
|
||||
dX0_1 = ( dSqRad - ptInt1.y * ptInt1.y > 0 ? sqrt( dSqRad - ptInt1.y * ptInt1.y) : 0) ;
|
||||
}
|
||||
else {
|
||||
|
||||
dY0_1 = ( dSqRad - ptInt1.z * ptInt1.z > 0 ? - sqrt( dSqRad - ptInt1.z * ptInt1.z) : 0) ;
|
||||
dX0_1 = ( dSqRad - ptInt1.y * ptInt1.y > 0 ? - sqrt( dSqRad - ptInt1.y * ptInt1.y) : 0) ;
|
||||
}
|
||||
|
||||
Vector3d vtCirc1( 0, - dY0_1, - ptInt1.z) ;
|
||||
Vector3d vtTan1( 0, - vtCirc1.z, vtCirc1.y) ;
|
||||
Vector3d vtCirc1( - dX0_1, - ptInt1.y, 0) ;
|
||||
Vector3d vtTan1( vtCirc1.y, - vtCirc1.x, 0) ;
|
||||
Vector3d vtCross1 = vtTan1 ^ vtMv ;
|
||||
|
||||
vtN1 = ( vtCross1 * vtCirc1 > - EPS_ZERO ? vtCross1 : - vtCross1) ;
|
||||
|
||||
if ( vtTest2.y > 0) {
|
||||
if ( vtTest2.x > 0) {
|
||||
|
||||
dY0_2 = ( dSqRad - ptInt2.z * ptInt2.z > 0 ? sqrt( dSqRad - ptInt2.z * ptInt2.z) : 0) ;
|
||||
dX0_2 = ( dSqRad - ptInt2.y * ptInt2.y > 0 ? sqrt( dSqRad - ptInt2.y * ptInt2.y) : 0) ;
|
||||
}
|
||||
else {
|
||||
|
||||
dY0_2 = ( dSqRad - ptInt2.z * ptInt2.z > 0 ? - sqrt( dSqRad - ptInt2.z * ptInt2.z) : 0) ;
|
||||
dX0_2 = ( dSqRad - ptInt2.y * ptInt2.y > 0 ? - sqrt( dSqRad - ptInt2.y * ptInt2.y) : 0) ;
|
||||
}
|
||||
|
||||
Vector3d vtCirc2( 0, - dY0_2, - ptInt2.z) ;
|
||||
Vector3d vtTan2( 0, - vtCirc2.z, vtCirc2.y) ;
|
||||
Vector3d vtCirc2( - dX0_2, - ptInt2.y, 0) ;
|
||||
Vector3d vtTan2( vtCirc2.y, - vtCirc2.x, 0) ;
|
||||
Vector3d vtCross2 = vtTan2 ^ vtMv ;
|
||||
|
||||
vtN2 = ( vtCross2 * vtCirc2 > - EPS_ZERO ? vtCross2 : - vtCross2) ;
|
||||
|
||||
|
||||
|
||||
if ( ptInt1.x < dLongMvLen + dEpsUp) {
|
||||
if ( ptInt1.z < dLongMvLen + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > + dEpsLow) {
|
||||
if ( ptInt1.z > + dEpsLow) {
|
||||
|
||||
if ( ptInt2.x > dLongMvLen + dEpsUp) {
|
||||
if ( ptInt2.z > dLongMvLen + dEpsUp) {
|
||||
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.x) / vtV.x) * vtV ;
|
||||
vtN2 = - X_AX ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.z) / vtV.z) * vtV ;
|
||||
vtN2 = - Z_AX ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x > dLongMvLen + dEpsUp) {
|
||||
if ( ptInt2.z > dLongMvLen + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.z) / vtV.z) * vtV ;
|
||||
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
vtN2.Set( -1, 0, 0) ;
|
||||
vtN1.Set( 0, 0, 1) ;
|
||||
vtN2.Set( 0, 0, -1) ;
|
||||
|
||||
if ( ptInt1.y * ptInt1.y + ptInt1.z * ptInt1.z > dSqRad &&
|
||||
ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z > dSqRad)
|
||||
if ( ptInt1.x * ptInt1.x + ptInt1.y * ptInt1.y > dSqRad &&
|
||||
ptInt2.x * ptInt2.x + ptInt2.y * ptInt2.y > dSqRad)
|
||||
|
||||
return false ;
|
||||
}
|
||||
else if ( ptInt2.x > dEpsLow) {
|
||||
else if ( ptInt2.z > dEpsLow) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
ptInt1 = ptP - ( ptP.z / vtV.z) * vtV ;
|
||||
vtN1.Set( 0, 0, 1) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
@@ -1307,7 +1297,7 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX,
|
||||
const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaZ,
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
|
||||
{
|
||||
Point3d ptP = ptLineSt ;
|
||||
@@ -1320,107 +1310,107 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
// Facce 1 e 2 parallele a XY
|
||||
// Facce 3 e 4 parallele a XZ
|
||||
// Facce 5 e 6 oblique
|
||||
Point3d ptFacet135( 0, 0, dLenZ /2) ;
|
||||
Point3d ptFacet246( dLenX + dDeltaX, dLenY, - dLenZ / 2) ;
|
||||
Point3d ptFacet135( 0, dLenY / 2, 0) ;
|
||||
Point3d ptFacet246( dLenX , - dLenY / 2, dLenZ + dDeltaZ) ;
|
||||
|
||||
// Servono per descrivere i piani obliqui
|
||||
Vector3d vtFacet5 = ptFacet135 - ptP ;
|
||||
Vector3d vtFacet6 = ptFacet246 - ptP ;
|
||||
|
||||
Vector3d vtOb( dLenY, - dDeltaX, 0) ;
|
||||
Vector3d vtOb( - dDeltaZ, 0, dLenX) ;
|
||||
|
||||
vtOb.Normalize() ;
|
||||
|
||||
Point3d ptI1 = ptP + ( ( ptFacet135.z - ptP.z) / vtV.z) * vtV ;
|
||||
Point3d ptI2 = ptP + ( ( ptFacet246.z - ptP.z) / vtV.z) * vtV ;
|
||||
Point3d ptI3 = ptP + ( ( ptFacet135.y - ptP.y) / vtV.y) * vtV ;
|
||||
Point3d ptI4 = ptP + ( ( ptFacet246.y - ptP.y) / vtV.y) * vtV ;
|
||||
Point3d ptI1 = ptP + ( ( ptFacet135.y - ptP.y) / vtV.y) * vtV ;
|
||||
Point3d ptI2 = ptP + ( ( ptFacet246.y - ptP.y) / vtV.y) * vtV ;
|
||||
Point3d ptI3 = ptP + ( ( ptFacet135.x - ptP.x) / vtV.x) * vtV ;
|
||||
Point3d ptI4 = ptP + ( ( ptFacet246.x - ptP.x) / vtV.x) * vtV ;
|
||||
Point3d ptI5 = ptP + ( ( vtFacet5 * vtOb) / ( vtV * vtOb)) * vtV ;
|
||||
Point3d ptI6 = ptP + ( ( vtFacet6 * vtOb) / ( vtV * vtOb)) * vtV ;
|
||||
|
||||
// Controlli affinché non vengano tagliati dexel a filo
|
||||
// con il passaggio dell'utensile:
|
||||
// Controllo sulle facce 1 e 2
|
||||
if ( abs( vtV.z) < EPS_ZERO &&
|
||||
abs( ptP.z) > dLenZ / 2 - EPS_SMALL)
|
||||
if ( abs( vtV.y) < EPS_ZERO &&
|
||||
abs( ptP.y) > dLenY / 2 - EPS_SMALL)
|
||||
return false ;
|
||||
// Controllo sulle facce 3 e 4
|
||||
if ( abs( vtV.y) < EPS_ZERO &&
|
||||
( ptP.y < EPS_SMALL ||
|
||||
ptP.y > dLenY - EPS_SMALL))
|
||||
if ( abs( vtV.x) < EPS_ZERO &&
|
||||
( ptP.x < EPS_SMALL ||
|
||||
ptP.x > dLenX - EPS_SMALL))
|
||||
return false ;
|
||||
// Controllo sulle facce 5 e 6
|
||||
Vector3d vtW( dDeltaX, dLenY, 0) ;
|
||||
Vector3d vtW( 0, dLenX, dDeltaZ) ;
|
||||
vtW.Normalize() ;
|
||||
Vector3d vtU = vtV - vtV.z * Z_AX - vtV * vtW * vtW ;
|
||||
Vector3d vtU = vtV - vtV.y * Y_AX - vtV * vtW * vtW ;
|
||||
if ( vtU.Len() < EPS_ZERO &&
|
||||
( ptP.x * dLenY < dDeltaX * ptP.y + dLenY * EPS_SMALL ||
|
||||
ptP.x * dLenY > dDeltaX * ptP.y + dLenY * ( dLenX - EPS_SMALL)))
|
||||
( ptP.z * dLenX < dDeltaZ * ptP.x + dLenX * EPS_SMALL ||
|
||||
ptP.z * dLenX > dDeltaZ * ptP.x + dLenX * ( dLenY - EPS_SMALL)))
|
||||
return false ;
|
||||
|
||||
// Ricerca intersezioni con le facce
|
||||
int nIntNum = 0 ;
|
||||
|
||||
// Intersezione con la prima faccia
|
||||
if ( ptI1.y >= 0 && ptI1.y <= dLenY &&
|
||||
ptI1.x * dLenY >= dDeltaX * ptI1.y && ( ptI1.x - dLenX) * dLenY <= dDeltaX * ptI1.y) {
|
||||
if ( ptI1.x >= 0 && ptI1.x <= dLenX &&
|
||||
ptI1.z * dLenX >= dDeltaZ * ptI1.x && ( ptI1.z - dLenZ) * dLenX <= dDeltaZ * ptI1.x) {
|
||||
|
||||
ptInt1 = ptI1 ;
|
||||
vtN1 = - Z_AX ;
|
||||
vtN1 = - Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
|
||||
// Intersezione con la seconda faccia
|
||||
if ( ptI2.y >= 0 && ptI2.y <= dLenY &&
|
||||
ptI2.x * dLenY >= dDeltaX * ptI2.y && ( ptI2.x - dLenX) * dLenY <= dDeltaX * ptI2.y) {
|
||||
if ( ptI2.x >= 0 && ptI2.x <= dLenX &&
|
||||
ptI2.z * dLenX >= dDeltaZ * ptI2.x && ( ptI2.z - dLenZ) * dLenX <= dDeltaZ * ptI2.x) {
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptI2 ;
|
||||
vtN1 = Z_AX ;
|
||||
vtN1 = Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI2).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptI2 ;
|
||||
vtN2 = Z_AX ;
|
||||
vtN2 = Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la terza faccia
|
||||
if ( nIntNum < 2 &&
|
||||
ptI3.x >= 0 && ptI3.x <= dLenX &&
|
||||
ptI3.z >= - ptFacet135.z && ptI3.z <= ptFacet135.z) {
|
||||
ptI3.z >= 0 && ptI3.z <= dLenZ &&
|
||||
ptI3.y >= - ptFacet135.y && ptI3.y <= ptFacet135.y) {
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptI3 ;
|
||||
vtN1 = Y_AX ;
|
||||
vtN1 = X_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI3).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptI3 ;
|
||||
vtN2 = Y_AX ;
|
||||
vtN2 = X_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la quarta faccia
|
||||
if ( nIntNum < 2 &&
|
||||
ptI4.x >= dDeltaX && ptI4.x <= dLenX + dDeltaX &&
|
||||
ptI4.z >= - ptFacet135.z && ptI4.z <= ptFacet135.z) {
|
||||
ptI4.z >= dDeltaZ && ptI4.z <= dLenZ + dDeltaZ &&
|
||||
ptI4.y >= - ptFacet135.y && ptI4.y <= ptFacet135.y) {
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptI4 ;
|
||||
vtN1 = - Y_AX ;
|
||||
vtN1 = - X_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI4).SqLen() > SQ_EPS_SMALL) {
|
||||
ptInt2 = ptI4 ;
|
||||
vtN2 = - Y_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
|
||||
// Intersezione con la quinta faccia
|
||||
if ( nIntNum < 2 &&
|
||||
ptI5.y >= 0 && ptI5.y <= dLenY &&
|
||||
ptI5.z >= - ptFacet135.z && ptI5.z <= ptFacet135.z) {
|
||||
ptI5.x >= 0 && ptI5.x <= dLenX &&
|
||||
ptI5.y >= - ptFacet135.y && ptI5.y <= ptFacet135.y) {
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptI5 ;
|
||||
vtN1 = vtOb ;
|
||||
@@ -1435,8 +1425,8 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
|
||||
// Intersezione con la sesta faccia
|
||||
if ( nIntNum < 2 &&
|
||||
ptI6.y >= 0 && ptI6.y <= dLenY &&
|
||||
ptI6.z >= - ptFacet135.z && ptI6.z <= ptFacet135.z) {
|
||||
ptI6.x >= 0 && ptI6.x <= dLenX &&
|
||||
ptI6.y >= - ptFacet135.y && ptI6.y <= ptFacet135.y) {
|
||||
if ( nIntNum == 0) {
|
||||
ptInt1 = ptI6;
|
||||
vtN1 = - vtOb ;
|
||||
|
||||
Reference in New Issue
Block a user