EgtGeomKernel :

- in Zmap aggiunta AvoidSphere
- aggiunta funzione IntersLineSphere
- migliorie a visualizzazione Zmap.
This commit is contained in:
Dario Sassi
2018-02-05 07:14:03 +00:00
parent fdef0bb7a3
commit 5649e228a0
8 changed files with 177 additions and 58 deletions
+94 -29
View File
@@ -20,6 +20,7 @@
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EGkIntersLineTria.h"
#include "/EgtDev/Include/EGkIntersLinePlane.h"
#include "/EgtDev/Include/EGkIntersLineSphere.h"
#include "/EgtDev/Include/EGkChainCurves.h"
using namespace std ;
@@ -595,18 +596,20 @@ VolZmap::AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag) const
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
continue ;
for ( int k = 0 ; k < 4 ; ++ k) {
Point3d ptC = ptO + i * m_dStep * vtX + j * m_dStep * vtY ;
for ( int k = 0 ; k < 5 ; ++ k) {
Point3d ptT = ptO + ( i + 0.5) * m_dStep * vtX + ( j + 0.5) * m_dStep * vtY ;
if ( k == 0)
ptC += 0.1 * m_dStep * vtX + 0.1 * m_dStep * vtY ;
;
else if ( k == 1)
ptC += 0.9 * m_dStep * vtX + 0.1 * m_dStep * vtY ;
ptT += - 0.4 * m_dStep * vtX - 0.4 * m_dStep * vtY ;
else if ( k == 2)
ptC += 0.9 * m_dStep * vtX + 0.9 * m_dStep * vtY ;
ptT += + 0.4 * m_dStep * vtX - 0.4 * m_dStep * vtY ;
else if ( k == 3)
ptC += 0.1 * m_dStep * vtX + 0.9 * m_dStep * vtY ;
ptT += + 0.4 * m_dStep * vtX + 0.4 * m_dStep * vtY ;
else if ( k == 4)
ptT += - 0.4 * m_dStep * vtX + 0.4 * m_dStep * vtY ;
double dZmin, dZmax ;
if ( IntersLineBox( ptC, vtK, ORIG, ORIG + vtDiag, dZmin, dZmax)) {
if ( IntersLineBox( ptT, vtK, ORIG, ORIG + vtDiag, dZmin, dZmax)) {
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
if ( ! ( dZmax < m_Values[0][nPos][nIndex].dMin - EPS_SMALL ||
dZmin > m_Values[0][nPos][nIndex].dMax + EPS_SMALL))
@@ -620,18 +623,85 @@ VolZmap::AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag) const
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::AvoidSphere( const Point3d& ptCenter, double dRad) const
{
// Porto la sfera nel riferimento intrinseco dello Zmap
Point3d ptC = ptCenter ;
ptC.ToLoc( m_MapFrame) ;
// BBox della sfera
BBox3d b3Box( ptC) ;
b3Box.Expand( dRad) ;
// BBox dello Zmap nel suo riferimento intrinseco
BBox3d b3Zmap( ORIG, Point3d( m_nNx[0] * m_dStep, m_nNy[0] * m_dStep, m_dMaxZ[0])) ;
// Se non interferiscono, posso uscire
BBox3d b3Int ;
if ( ! b3Zmap.FindIntersection( b3Box, b3Int))
return true ;
// Limiti su indici
int nStI = Clamp( int( b3Int.GetMin().x / m_dStep), 0, m_nNx[0] -1) ;
int nEnI = Clamp( int( b3Int.GetMax().x / m_dStep), 0, m_nNx[0] -1) ;
int nStJ = Clamp( int( b3Int.GetMin().y / m_dStep), 0, m_nNy[0] -1) ;
int nEnJ = Clamp( int( b3Int.GetMax().y / m_dStep), 0, m_nNy[0] -1) ;
// Ciclo di intersezione dei dexel con la sfera (nel riferimento intrinseco)
for ( int i = nStI ; i <= nEnI ; ++ i) {
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
continue ;
for ( int k = 0 ; k < 5 ; ++ k) {
Point3d ptT = ORIG + ( i + 0.5) * m_dStep * X_AX + ( j + 0.5) * m_dStep * Y_AX ;
if ( k == 0)
;
else if ( k == 1)
ptT += - 0.4 * m_dStep * X_AX - 0.4 * m_dStep * Y_AX ;
else if ( k == 2)
ptT += + 0.4 * m_dStep * X_AX - 0.4 * m_dStep * Y_AX ;
else if ( k == 3)
ptT += + 0.4 * m_dStep * X_AX + 0.4 * m_dStep * Y_AX ;
else if ( k == 4)
ptT += - 0.4 * m_dStep * X_AX + 0.4 * m_dStep * Y_AX ;
Point3d ptI1, ptI2 ;
if ( IntersLineSphere( ptT, Z_AX, ptC, dRad, ptI1, ptI2) != ILST_NO) {
double dZmin = ptI1.z ;
double dZmax = ptI2.z ;
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
if ( ! ( dZmax < m_Values[0][nPos][nIndex].dMin - EPS_SMALL ||
dZmin > m_Values[0][nPos][nIndex].dMax + EPS_SMALL))
return false ;
}
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::AvoidCylinder( const Frame3d& frCyl, double dL, double dR) const
{
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir,
const Frame3d& CylFrame, double dL, double dR,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2,
bool bTapO, bool bTapL)
const Frame3d& CylFrame, double dL, double dR, bool bTapO, bool bTapL,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
{
// NB: L'origine del sistema di riferimento deve essere
// nel centro della circonferenza di base e l'asse di simmetria
// deve coincidere con l'asse x.
// La funzione restituisce true in caso di intersezione,
// false altrimenti.
// 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 ;
@@ -755,8 +825,7 @@ VolZmap::IntersZLineCylinder( const Point3d& ptLine,
double& dInfZ, double& dSupZ)
{
// NB: Le coordinate sono espresse nel sistema griglia
// La funzione restituisce true in caso di intersezione,
// false altrimenti.
// La funzione restituisce true in caso di intersezione, false altrimenti.
double dSqRad = dCylR * dCylR ;
@@ -857,15 +926,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, Vector3d& vtN1, Vector3d& vtN2,
bool bTapLow, bool bTapUp)
const Frame3d& ConusFrame, double dTan, double dl, double dL, bool bTapLow, bool bTapUp,
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.
// 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 ;
@@ -1062,15 +1128,14 @@ VolZmap::IntersLineConus( const Point3d& ptLineSt, const Vector3d& vtLineDir,
bool
VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d& ptLineSt,
const Frame3d& CircFrame, double dSqRad, double dLongMvLen, double dOrtMvLen,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2,
bool bTapLow, bool bTapUp)
bool bTapLow, bool bTapUp,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
{
// NB: L'origine del sistema di riferimento deve essere
// nel centro della circonferenza di base, la cui tralsazione obliqua
// nel centro della circonferenza di base, la cui traslazione obliqua
// genera il cilindro ellittico, e l'asse x deve essere l'asse
// di simmetria di tale circonferenza.
// La funzione restituisce true in caso di intersezione,
// false altrimenti.
// 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