EgtGeomKernel 1.8d1 :
- inserite le modifiche di Lorenzo a Zmap - aggiunta a Zmap la possibilità di visualizzare le normali.
This commit is contained in:
+395
-30
@@ -26,7 +26,7 @@ using namespace std ;
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV,
|
||||
const Point3d& ptMin, const Point3d& ptMax, double& dU1, double& dU2)
|
||||
const Point3d& ptMin, const Point3d& ptMax, double& dU1, double& dU2) const
|
||||
{
|
||||
// Il box è allineato agli assi
|
||||
|
||||
@@ -312,7 +312,8 @@ VolZmap::AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag)
|
||||
bool
|
||||
VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& CylFrame, double dL, double dR,
|
||||
Point3d& ptInt1, Point3d& ptInt2)
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2,
|
||||
bool bTapO, bool bTapL)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
// nel centro della circonferenza di base e l'asse di simmetria
|
||||
@@ -323,14 +324,16 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
Point3d ptP = ptLineSt ;
|
||||
Vector3d vtV = vtLineDir ;
|
||||
|
||||
// Trasformazione delle coordinate
|
||||
// Trasformazione delle coordinate:
|
||||
// l'asse del cilindro corrisponde con
|
||||
// l'asse x del sistema di riferimento
|
||||
ptP.ToLoc( CylFrame) ;
|
||||
vtV.ToLoc( CylFrame) ;
|
||||
|
||||
DBLVECTOR vdCoef(3) ;
|
||||
DBLVECTOR vdRoots ;
|
||||
|
||||
double dSqRad = dR * dR ;
|
||||
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) ;
|
||||
@@ -347,12 +350,18 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
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) {
|
||||
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
// Nessuna intersezione
|
||||
@@ -370,31 +379,43 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
|
||||
if ( nRoot == 2) {
|
||||
|
||||
double dEpsO = ( bTapO ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsL = ( bTapL ? EPS_SMALL : - EPS_SMALL) ;
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
swap( ptInt1, ptInt2) ;
|
||||
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 + EPS_SMALL) {
|
||||
if ( ptInt1.x < dL + dEpsL) {
|
||||
|
||||
if ( ptInt1.x > - EPS_SMALL) {
|
||||
if ( ptInt1.x > dEpsO) {
|
||||
|
||||
if ( ptInt2.x > dL)
|
||||
if ( ptInt2.x > dL + dEpsL) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
vtN2.Set( -1, 0, 0) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x > dL) {
|
||||
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) ;
|
||||
}
|
||||
else if ( ptInt2.x > 0)
|
||||
else if ( ptInt2.x > dEpsO) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
@@ -405,7 +426,12 @@ VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
// Riporto le coordinate nel sistema di riferimento griglia
|
||||
ptInt1.ToGlob( CylFrame) ;
|
||||
ptInt2.ToGlob( CylFrame) ;
|
||||
}
|
||||
vtN1.ToGlob( CylFrame) ;
|
||||
vtN2.ToGlob( CylFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -516,11 +542,12 @@ VolZmap::IntersZLineCylinder( const Point3d& ptLine,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& ConusFrame, double dTan, double dl, double dL,
|
||||
Point3d& ptInt1, Point3d& ptInt2)
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
// nel vertice del cono e l'asse di simmetria deve coincidere
|
||||
@@ -541,6 +568,8 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
double dSqTan = dTan * dTan ;
|
||||
double dMinRad = dTan * dl ;
|
||||
double dMaxRad = dTan * dL ;
|
||||
double dDeltaR = dMaxRad - dMinRad ;
|
||||
double dHei = dL - dl ;
|
||||
|
||||
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) ;
|
||||
@@ -558,18 +587,32 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
if ( nRoot == 1) {
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
|
||||
Vector3d vtU = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
|
||||
vtU.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
|
||||
if ( ptInt1.x < dL + EPS_SMALL) {
|
||||
|
||||
if ( ptInt1.x > dl)
|
||||
if ( ptInt1.x > dl) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
if ( ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z > dMaxRad * dMaxRad)
|
||||
|
||||
return false ;
|
||||
@@ -580,6 +623,9 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.ToGlob( ConusFrame) ;
|
||||
vtN2.ToGlob( ConusFrame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
@@ -595,27 +641,46 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
Vector3d vtU1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
Vector3d vtU2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG).x * X_AX ;
|
||||
|
||||
vtU1.Normalize() ;
|
||||
vtU2.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU1 ;
|
||||
vtN2 = dDeltaR * X_AX - dHei * vtU2 ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
|
||||
if ( ptInt1.x < dL + EPS_SMALL) {
|
||||
|
||||
if ( ptInt1.x > dl - EPS_SMALL) {
|
||||
|
||||
if ( ptInt2.x > dL)
|
||||
if ( ptInt2.x > dL) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
|
||||
if ( ptInt2.x > dL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
else if ( ptInt2.x > dl - EPS_SMALL)
|
||||
else if ( ptInt2.x > dl - EPS_SMALL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
@@ -628,12 +693,16 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
else if ( ptInt2.x < dl) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
else if ( ptInt2.x < dL)
|
||||
else if ( ptInt2.x < dL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = - X_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
@@ -641,19 +710,230 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.ToGlob( ConusFrame) ;
|
||||
vtN2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
return false ;
|
||||
}*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
|
||||
const Frame3d& ConusFrame, double dTan, double dl, double dL,
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2,
|
||||
bool bTapLow, bool bTapUp)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
// nel vertice del cono e l'asse di simmetria deve coincidere
|
||||
// con l'asse x.
|
||||
// La funzione restituisce true in caso di intersezione,
|
||||
// false altrimenti.
|
||||
|
||||
Point3d ptP = ptLineSt ;
|
||||
Vector3d vtV = vtLineDir ;
|
||||
|
||||
// Trasformazione delle coordinate
|
||||
ptP.ToLoc( ConusFrame) ;
|
||||
vtV.ToLoc( ConusFrame) ;
|
||||
|
||||
DBLVECTOR vdCoef(3) ;
|
||||
DBLVECTOR vdRoots ;
|
||||
|
||||
double dSqTan = dTan * dTan ;
|
||||
double dMinRad = dTan * dl ;
|
||||
double dMaxRad = dTan * dL ;
|
||||
double dDeltaR = dMaxRad - dMinRad ;
|
||||
double dHei = dL - dl ;
|
||||
|
||||
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 ;
|
||||
|
||||
// Computo radici
|
||||
int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ;
|
||||
|
||||
// Nessuna soluzione
|
||||
if ( nRoot == 0)
|
||||
return false ;
|
||||
|
||||
double dEpsLow = ( bTapLow ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsUp = ( bTapUp ? EPS_SMALL : - EPS_SMALL) ;
|
||||
|
||||
// Una soluzione: la retta iterseca superficie
|
||||
// laterale e un piano
|
||||
if ( nRoot == 1) {
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
|
||||
Vector3d vtU = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
|
||||
vtU.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
|
||||
if ( ptInt1.x < dL + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
if ( ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z > dMaxRad * dMaxRad)
|
||||
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.ToGlob( ConusFrame) ;
|
||||
vtN2.ToGlob( ConusFrame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
|
||||
}
|
||||
// Due soluzioni: la retta interseca due volte la
|
||||
// superficie laterale
|
||||
else if ( nRoot == 2) {
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
ptInt2 = ptP + vdRoots[1] * vtV ;
|
||||
|
||||
if ( ptInt1.x > ptInt2.x)
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
Vector3d vtU1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG).x * X_AX ;
|
||||
Vector3d vtU2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG).x * X_AX ;
|
||||
|
||||
vtU1.Normalize() ;
|
||||
vtU2.Normalize() ;
|
||||
|
||||
vtN1 = dDeltaR * X_AX - dHei * vtU1 ;
|
||||
vtN2 = dDeltaR * X_AX - dHei * vtU2 ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
if ( abs( vtV.x) < EPS_ZERO) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow && ptInt1.x < dL + dEpsUp) {
|
||||
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.ToGlob( ConusFrame) ;
|
||||
vtN2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
if ( ptInt1.x < dL + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > dl + dEpsLow) {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsUp) {
|
||||
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
}
|
||||
else if ( ptInt1.x > - EPS_SMALL) {
|
||||
|
||||
if ( ptInt2.x > dL + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
else if ( ptInt2.x > dl + dEpsLow) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
vtN1 = X_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x < 0)
|
||||
|
||||
return false ;
|
||||
|
||||
else if ( ptInt2.x < dl + dEpsLow) {
|
||||
|
||||
ptInt1 = ptP + ( ( dl - ptP.x) / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
else if ( ptInt2.x < dL + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP + ( ( dL - ptP.x) / vtV.x) * vtV ;
|
||||
vtN1 = - X_AX ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
ptInt1.ToGlob( ConusFrame) ;
|
||||
ptInt2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.ToGlob( ConusFrame) ;
|
||||
vtN2.ToGlob( ConusFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d& ptLineSt,
|
||||
const Frame3d& CircFrame, double dSqRad, double dLongMvLen, double dOrtMvLen,
|
||||
Point3d& ptInt1, Point3d& ptInt2)
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2,
|
||||
bool bTapLow, bool bTapUp)
|
||||
{
|
||||
// NB: L'origine del sistema di riferimento deve essere
|
||||
// nel centro della circonferenza di base, la cui tralsazione obliqua
|
||||
@@ -672,6 +952,10 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
Point3d ptP = ptLineSt ;
|
||||
Vector3d vtV = vtLineDir ;
|
||||
|
||||
// Asse cilindro ellittico
|
||||
Vector3d vtAx( dLongMvLen, dOrtMvLen, 0) ;
|
||||
vtAx.Normalize() ;
|
||||
|
||||
// Trasformazione delle coordinate
|
||||
ptP.ToLoc( CircFrame) ;
|
||||
vtV.ToLoc( CircFrame) ;
|
||||
@@ -700,6 +984,12 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
ptInt1.ToGlob( CircFrame) ;
|
||||
ptInt2.ToGlob( CircFrame) ;
|
||||
|
||||
vtN1 = X_AX ;
|
||||
vtN2 = - X_AX ;
|
||||
|
||||
vtN1.ToGlob( CircFrame) ;
|
||||
vtN2.ToGlob( CircFrame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
// Nessuna intersezione
|
||||
@@ -711,10 +1001,15 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
return false ;
|
||||
}
|
||||
|
||||
double dEpsLow = ( bTapLow ? - EPS_SMALL : EPS_SMALL) ;
|
||||
double dEpsUp = ( bTapUp ? EPS_SMALL : - EPS_SMALL) ;
|
||||
|
||||
// L'equazione ammette o due soluzioni (eventualmente
|
||||
// coincidenti) oppure nessuna o infinite se la la retta
|
||||
// appartiene alla superficie
|
||||
|
||||
Vector3d vtMv( dLongMvLen, dOrtMvLen, 0) ;
|
||||
|
||||
if ( nRoot == 2) {
|
||||
|
||||
ptInt1 = ptP + vdRoots[0] * vtV ;
|
||||
@@ -725,30 +1020,73 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
|
||||
swap( ptInt1, ptInt2) ;
|
||||
|
||||
Vector3d vtTest1 = ( ptInt1 - ORIG) - ( ptInt1 - ORIG) * vtAx * vtAx ;
|
||||
Vector3d vtTest2 = ( ptInt2 - ORIG) - ( ptInt2 - ORIG) * vtAx * vtAx ;
|
||||
|
||||
if ( ptInt1.x < dLongMvLen + EPS_SMALL) {
|
||||
double dY0_1, dY0_2 ;
|
||||
|
||||
if ( ptInt1.x > - EPS_SMALL) {
|
||||
if ( vtTest1.y > 0) {
|
||||
|
||||
if ( ptInt2.x > dLongMvLen)
|
||||
dY0_1 = ( dSqRad - ptInt1.z * ptInt1.z > 0 ? sqrt( dSqRad - ptInt1.z * ptInt1.z) : 0) ;
|
||||
}
|
||||
else {
|
||||
|
||||
dY0_1 = ( dSqRad - ptInt1.z * ptInt1.z > 0 ? - sqrt( dSqRad - ptInt1.z * ptInt1.z) : 0) ;
|
||||
}
|
||||
|
||||
Vector3d vtCirc1( 0, - dY0_1, - ptInt1.z) ;
|
||||
Vector3d vtTan1( 0, - vtCirc1.z, vtCirc1.y) ;
|
||||
Vector3d vtCross1 = vtTan1 ^ vtMv ;
|
||||
|
||||
vtN1 = ( vtCross1 * vtCirc1 > 0 ? vtCross1 : - vtCross1) ;
|
||||
|
||||
if ( vtTest2.y > 0) {
|
||||
|
||||
dY0_2 = ( dSqRad - ptInt2.z * ptInt2.z > 0 ? sqrt( dSqRad - ptInt2.z * ptInt2.z) : 0) ;
|
||||
}
|
||||
else {
|
||||
|
||||
dY0_2 = ( dSqRad - ptInt2.z * ptInt2.z > 0 ? - sqrt( dSqRad - ptInt2.z * ptInt2.z) : 0) ;
|
||||
}
|
||||
|
||||
Vector3d vtCirc2( 0, - dY0_2, - ptInt2.z) ;
|
||||
Vector3d vtTan2( 0, - vtCirc2.z, vtCirc2.y) ;
|
||||
Vector3d vtCross2 = vtTan2 ^ vtMv ;
|
||||
|
||||
vtN2 = ( vtCross2 * vtCirc2 > 0 ? vtCross2 : - vtCross2) ;
|
||||
|
||||
|
||||
|
||||
if ( ptInt1.x < dLongMvLen + dEpsUp) {
|
||||
|
||||
if ( ptInt1.x > + dEpsLow) {
|
||||
|
||||
if ( ptInt2.x > dLongMvLen + dEpsUp) {
|
||||
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.x) / vtV.x) * vtV ;
|
||||
vtN2 = - X_AX ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ptInt2.x > dLongMvLen) {
|
||||
if ( ptInt2.x > dLongMvLen + dEpsUp) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt2 = ptP + ( ( dLongMvLen - ptP.x) / vtV.x) * vtV ;
|
||||
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
vtN2.Set( -1, 0, 0) ;
|
||||
|
||||
if ( ptInt1.y * ptInt1.y + ptInt1.z * ptInt1.z > dSqRad &&
|
||||
ptInt2.y * ptInt2.y + ptInt2.z * ptInt2.z > dSqRad)
|
||||
|
||||
return false ;
|
||||
}
|
||||
else if ( ptInt2.x > 0)
|
||||
else if ( ptInt2.x > dEpsLow) {
|
||||
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
ptInt1 = ptP - ( ptP.x / vtV.x) * vtV ;
|
||||
vtN1.Set( 1, 0, 0) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
@@ -760,6 +1098,12 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
|
||||
// griglia
|
||||
ptInt1.ToGlob( CircFrame) ;
|
||||
ptInt2.ToGlob( CircFrame) ;
|
||||
|
||||
vtN1.ToGlob( CircFrame) ;
|
||||
vtN2.ToGlob( CircFrame) ;
|
||||
|
||||
vtN1.Normalize() ;
|
||||
vtN2.Normalize() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -769,7 +1113,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,
|
||||
Point3d& ptInt1, Point3d& ptInt2)
|
||||
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
|
||||
{
|
||||
|
||||
double SqIndet = EPS_SMALL * EPS_SMALL ;
|
||||
@@ -793,6 +1137,8 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
|
||||
Vector3d vtOb( dLenY, - dDeltaX, 0) ;
|
||||
|
||||
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 ;
|
||||
@@ -800,6 +1146,11 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
Point3d ptI5 = ptP + ( ( vtFacet5 * vtOb) / ( vtV * vtOb)) * vtV ;
|
||||
Point3d ptI6 = ptP + ( ( vtFacet6 * vtOb) / ( vtV * vtOb)) * vtV ;
|
||||
|
||||
if ( abs( vtV.z) < EPS_ZERO &&
|
||||
abs( ptP.z) > dLenZ / 2 - EPS_SMALL)
|
||||
|
||||
return false ;
|
||||
|
||||
int nIntNum = 0 ;
|
||||
|
||||
// Intersezione con la prima faccia
|
||||
@@ -807,6 +1158,7 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
ptI1.x * dLenY >= dDeltaX * ptI1.y && ( ptI1.x - dLenX) * dLenY <= dDeltaX * ptI1.y) {
|
||||
|
||||
ptInt1 = ptI1 ;
|
||||
vtN1 = - Z_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
|
||||
@@ -817,11 +1169,13 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
if ( nIntNum == 0) {
|
||||
|
||||
ptInt1 = ptI2 ;
|
||||
vtN1 = Z_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI2).SqLen() > SqIndet) {
|
||||
|
||||
ptInt2 = ptI2 ;
|
||||
vtN2 = Z_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
@@ -834,11 +1188,13 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
if ( nIntNum == 0) {
|
||||
|
||||
ptInt1 = ptI3 ;
|
||||
vtN1 = Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI3).SqLen() > SqIndet) {
|
||||
|
||||
ptInt2 = ptI3 ;
|
||||
vtN2 = Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
@@ -851,11 +1207,13 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
if ( nIntNum == 0) {
|
||||
|
||||
ptInt1 = ptI4 ;
|
||||
vtN1 = - Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI4).SqLen() > SqIndet) {
|
||||
|
||||
ptInt2 = ptI4 ;
|
||||
vtN2 = - Y_AX ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
@@ -868,11 +1226,13 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
if ( nIntNum == 0) {
|
||||
|
||||
ptInt1 = ptI5 ;
|
||||
vtN1 = vtOb ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI5).SqLen() > SqIndet) {
|
||||
|
||||
ptInt2 = ptI5 ;
|
||||
vtN2 = vtOb ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
@@ -885,11 +1245,13 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
if ( nIntNum == 0) {
|
||||
|
||||
ptInt1 = ptI6;
|
||||
vtN1 = - vtOb ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
else if ( ( ptInt1 - ptI6).SqLen() > SqIndet) {
|
||||
|
||||
ptInt2 = ptI6;
|
||||
vtN2 = - vtOb ;
|
||||
++ nIntNum ;
|
||||
}
|
||||
}
|
||||
@@ -900,6 +1262,9 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
|
||||
ptInt1.ToGlob( PolyFrame) ;
|
||||
ptInt2.ToGlob( PolyFrame) ;
|
||||
|
||||
vtN1.ToGlob( PolyFrame) ;
|
||||
vtN2.ToGlob( PolyFrame) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user