EgtGeomKernel 1.8e4 :

- correzione a ApproxOnSide e MakeConvex di PolyLine per percorsi chiusi
- migliorie e correzioni Zmap.
This commit is contained in:
Dario Sassi
2017-05-25 09:40:56 +00:00
parent 0a98461e3e
commit 98299d118c
7 changed files with 304 additions and 2293 deletions
-493
View File
@@ -71,170 +71,6 @@ VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV,
return ( dU2 >= dU1) ;
}
/*
//----------------------------------------------------------------------------
bool
VolZmap::IntersLineVoxel( const Point3d& ptP, const Vector3d& vtV, int nIndI, int nIndJ, int nIndK,
int& nFace1, int& nFace2, double& dU1, double& dU2) const
{
// Controllo sull'ammissibilità del voxel
if ( nIndI < - 1 || nIndI >= int( m_nNx[0]) ||
nIndJ < - 1 || nIndJ >= int( m_nNy[0]) ||
nIndK < - 1 || nIndK >= int( m_nNy[1]))
return false ;
Point3d ptInt ;
int nIntNum = 0 ;
double dU ;
// Intersezione con le facce 1 e 3
if ( abs( vtV.y) > EPS_ZERO) {
// Intersezione con la prima faccia
dU1 = ( ( nIndJ + 0.5) * m_dStep - ptP.y) / vtV.y ;
ptInt = ptP + dU1 * vtV ;
if ( ptInt.x > ( nIndI + 0.5) * m_dStep - EPS_SMALL &&
ptInt.x < ( nIndI + 1.5) * m_dStep + EPS_SMALL &&
ptInt.z > ( nIndK + 0.5) * m_dStep - EPS_SMALL &&
ptInt.z < ( nIndK + 1.5) * m_dStep + EPS_SMALL) {
nFace1 = 1 ;
++ nIntNum ;
}
// Intersezione con la terza faccia
dU = ( ( nIndJ + 1.5) * m_dStep - ptP.y) / vtV.y ;
ptInt = ptP + dU * vtV ;
if ( ptInt.x > ( nIndI + 0.5) * m_dStep - EPS_SMALL &&
ptInt.x < ( nIndI + 1.5) * m_dStep + EPS_SMALL &&
ptInt.z > ( nIndK + 0.5) * m_dStep - EPS_SMALL &&
ptInt.z < ( nIndK + 1.5) * m_dStep + EPS_SMALL) {
if ( nIntNum == 0) {
dU1 = dU ;
nFace1 = 3 ;
++ nIntNum ;
}
else if ( nIntNum == 1) {
dU2 = dU ;
nFace2 = 3 ;
++ nIntNum ;
}
}
}
// Intersezione con le facce 2 e 4
if ( abs( vtV.x) > EPS_ZERO) {
// Intersezione con la seconda faccia
dU = ( ( nIndI + 0.5) * m_dStep - ptP.x) / vtV.x ;
ptInt = ptP + dU * vtV ;
if ( ptInt.y > ( nIndJ + 0.5) * m_dStep - EPS_SMALL &&
ptInt.y < ( nIndJ + 1.5) * m_dStep + EPS_SMALL &&
ptInt.z > ( nIndK + 0.5) * m_dStep - EPS_SMALL &&
ptInt.z < ( nIndK + 1.5) * m_dStep + EPS_SMALL) {
if ( nIntNum == 0) {
dU1 = dU ;
nFace1 = 2 ;
++ nIntNum ;
}
else if ( nIntNum == 1) {
dU2 = dU ;
nFace2 = 2 ;
++ nIntNum ;
}
}
// Intersezione con la quarta faccia
dU = ( ( nIndI + 1.5) * m_dStep - ptP.x) / vtV.x ;
ptInt = ptP + dU * vtV ;
if ( ptInt.y > ( nIndJ + 0.5) * m_dStep - EPS_SMALL &&
ptInt.y < ( nIndJ + 1.5) * m_dStep + EPS_SMALL &&
ptInt.z > ( nIndK + 0.5) * m_dStep - EPS_SMALL &&
ptInt.z < ( nIndK + 1.5) * m_dStep + EPS_SMALL) {
if ( nIntNum == 0) {
dU1 = dU ;
nFace1 = 4 ;
++ nIntNum ;
}
else if ( nIntNum == 1) {
dU2 = dU ;
nFace2 = 4 ;
++ nIntNum ;
}
}
}
// Intersezione con le facce 5 e 6
if ( abs( vtV.z) > EPS_ZERO) {
// Intersezione con la quinta faccia
dU = ( ( nIndK + 0.5) * m_dStep - ptP.z) / vtV.z ;
ptInt = ptP + dU * vtV ;
if ( ptInt.x > ( nIndI + 0.5) * m_dStep - EPS_SMALL &&
ptInt.x < ( nIndI + 1.5) * m_dStep + EPS_SMALL &&
ptInt.y > ( nIndJ + 0.5) * m_dStep - EPS_SMALL &&
ptInt.y < ( nIndJ + 1.5) * m_dStep + EPS_SMALL) {
if ( nIntNum == 0) {
dU1 = dU ;
nFace1 = 5 ;
++ nIntNum ;
}
else if ( nIntNum == 1) {
dU2 = dU ;
nFace2 = 5 ;
++ nIntNum ;
}
}
// Intersezione con la sesta faccia
dU = ( ( nIndK + 1.5) * m_dStep - ptP.z) / vtV.z ;
ptInt = ptP + dU * vtV ;
if ( ptInt.x > ( nIndI + 0.5) * m_dStep - EPS_SMALL &&
ptInt.x < ( nIndI + 1.5) * m_dStep + EPS_SMALL &&
ptInt.y > ( nIndJ + 0.5) * m_dStep - EPS_SMALL &&
ptInt.y < ( nIndJ + 1.5) * m_dStep + EPS_SMALL) {
if ( nIntNum == 0) {
dU1 = dU ;
nFace1 = 6 ;
++ nIntNum ;
}
else if ( nIntNum == 1) {
dU2 = dU ;
nFace2 = 6 ;
++ nIntNum ;
}
}
}
if ( dU1 > dU2) {
swap( dU1, dU2) ;
swap( nFace1, nFace2) ;
}
return ( nIntNum == 2) ;
} */
//----------------------------------------------------------------------------
bool
@@ -888,188 +724,6 @@ 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, Vector3d& vtN1, Vector3d& vtN2)
{
// 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 ;
// 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 + EPS_SMALL) {
if ( ptInt1.x > dl) {
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 ( ptInt1.x < dL + EPS_SMALL) {
if ( ptInt1.x > dl - EPS_SMALL) {
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 ;
vtN1 = X_AX ;
vtN2 = - X_AX ;
}
else if ( ptInt2.x > dl - EPS_SMALL) {
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) {
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) {
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::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
@@ -1616,150 +1270,3 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
else
return false ;
}
/*
//----------------------------------------------------------------------------
bool
VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLineDir,
const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX,
Point3d& ptInt1, Point3d& ptInt2)
{
double SqIndet = EPS_SMALL * EPS_SMALL ;
Point3d ptP = ptLineSt ;
Vector3d vtV = vtLineDir ;
// Trasformazione delle coordinate
ptP.ToLoc( PolyFrame) ;
vtV.ToLoc( PolyFrame) ;
// 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) ;
// Servono per descrivere i piani obliqui
Vector3d vtFacet5 = ptFacet135 - ptP ;
Vector3d vtFacet6 = ptFacet246 - ptP ;
Vector3d vtOb( dLenY, - dDeltaX, 0) ;
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 ptI5 = ptP + ( ( vtFacet5 * vtOb) / ( vtV * vtOb)) * vtV ;
Point3d ptI6 = ptP + ( ( vtFacet6 * vtOb) / ( vtV * vtOb)) * vtV ;
int nIntNum = 0 ;
// Intersezione con la prima faccia
if ( ptI1.y > - EPS_SMALL && ptI1.y < dLenY + EPS_SMALL &&
ptI1.x * dLenY > dDeltaX * ptI1.y - EPS_SMALL &&
( ptI1.x - dLenX) * dLenY < dDeltaX * ptI1.y + EPS_SMALL) {
ptInt1 = ptI1 ;
++ nIntNum ;
}
// Intersezione con la seconda faccia
if ( ptI2.y > - EPS_SMALL && ptI2.y <dLenY + EPS_SMALL &&
ptI2.x * dLenY > dDeltaX * ptI2.y - EPS_SMALL &&
( ptI2.x - dLenX) * dLenY < dDeltaX * ptI2.y + EPS_SMALL) {
if ( nIntNum == 0) {
ptInt1 = ptI2 ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI2).SqLen() > SqIndet) {
ptInt2 = ptI2 ;
++ nIntNum ;
}
}
// Intersezione con la terza faccia
if ( nIntNum < 2 &&
ptI3.x > - EPS_SMALL && ptI3.x < dLenX + EPS_SMALL &&
ptI3.z > - ptFacet135.z - EPS_SMALL &&
ptI3.z < ptFacet135.z + EPS_SMALL) {
if ( nIntNum == 0) {
ptInt1 = ptI3 ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI3).SqLen() > SqIndet) {
ptInt2 = ptI3 ;
++ nIntNum ;
}
}
// Intersezione con la quarta faccia
if ( nIntNum < 2 &&
ptI4.x > dDeltaX - EPS_SMALL && ptI4.x < dLenX + dDeltaX + EPS_SMALL &&
ptI4.z > - ptFacet135.z - EPS_SMALL &&
ptI4.z < ptFacet135.z + EPS_SMALL) {
if ( nIntNum == 0) {
ptInt1 = ptI4 ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI4).SqLen() > SqIndet) {
ptInt2 = ptI4 ;
++ nIntNum ;
}
}
// Intersezione con la quinta faccia
if ( nIntNum < 2 &&
ptI5.y > - EPS_SMALL && ptI5.y < dLenY + EPS_SMALL &&
ptI5.z > - ptFacet135.z - EPS_SMALL &&
ptI5.z < ptFacet135.z + EPS_SMALL) {
if ( nIntNum == 0) {
ptInt1 = ptI5 ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI5).SqLen() > SqIndet) {
ptInt2 = ptI5 ;
++ nIntNum ;
}
}
// Intersezione con la sesta faccia
if ( nIntNum < 2 &&
ptI6.y > - EPS_SMALL && ptI6.y < dLenY + EPS_SMALL &&
ptI6.z > - ptFacet135.z - EPS_SMALL &&
ptI6.z < ptFacet135.z + EPS_SMALL) {
if ( nIntNum == 0) {
ptInt1 = ptI6;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI6).SqLen() > SqIndet) {
ptInt2 = ptI6;
++ nIntNum ;
}
}
if ( nIntNum == 2) {
ptInt1.ToGlob( PolyFrame) ;
ptInt2.ToGlob( PolyFrame) ;
return true ;
}
else
return false ;
} */