ab8ec30e29
- sistemato minuscole/maiuscole.
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : EGkPointGrid3d.h Data : 15.05.14 Versione : 1.5e5
|
|
// Contenuto : Dichiarazione della classe PointGrid3d.
|
|
// Indicizzazione spaziale di Point3d mediante hash grid.
|
|
//
|
|
//
|
|
// Modifiche : 15.05.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "/EgtDev/Include/EGkBBox3d.h"
|
|
#include "/EgtDev/Include/EgtNumCollection.h"
|
|
#include <unordered_map>
|
|
|
|
struct IBox ;
|
|
|
|
//----------------------- Macro per import/export ----------------------------
|
|
#undef EGK_EXPORT
|
|
#if defined( I_AM_EGK) // da definirsi solo nella DLL
|
|
#define EGK_EXPORT __declspec( dllexport)
|
|
#else
|
|
#define EGK_EXPORT __declspec( dllimport)
|
|
#endif
|
|
|
|
//----------------------------------------------------------------------------
|
|
class PointGrid3d
|
|
{
|
|
public :
|
|
EGK_EXPORT PointGrid3d( void) : m_dCellDim( 100 * EPS_SMALL), m_dInvCellDim( 1 / m_dCellDim) {}
|
|
EGK_EXPORT bool Init( int nBuckets, double dCellDim = 100 * EPS_SMALL) ;
|
|
EGK_EXPORT bool InsertPoint( const Point3d& ptP, int nId) ;
|
|
EGK_EXPORT bool RemovePoint( const Point3d& ptP, int nId) ;
|
|
EGK_EXPORT bool Find( const BBox3d& b3Test, INTVECTOR& vnIds) const ;
|
|
EGK_EXPORT bool Find( const Point3d& ptTest, double dTol, INTVECTOR& vnIds) const ;
|
|
EGK_EXPORT bool Find( const Point3d& ptTest, double dTol, int& nId) const ;
|
|
EGK_EXPORT bool FindNearest( const Point3d& ptTest, INTVECTOR& vnIds) const ;
|
|
EGK_EXPORT bool FindNearest( const Point3d& ptTest, double dTol, int& nId) const ;
|
|
EGK_EXPORT bool First( int& nId) const ;
|
|
|
|
private :
|
|
inline int Get1dCellNbr( double dCoord) const ;
|
|
inline bool Get3dRangeNbr( const BBox3d& b3Test, IBox& iBox) const ;
|
|
inline bool Get3dRangeNbr( const Point3d& ptTest, double dTol, IBox& iBox) const ;
|
|
inline int PointHash( int nX, int nY, int nZ) const ;
|
|
|
|
private :
|
|
typedef std::unordered_multimap<int,std::pair<Point3d,int>> IPNTI_UMMAP ;
|
|
typedef std::pair<IPNTI_UMMAP::const_iterator,IPNTI_UMMAP::const_iterator> IPNTI_UMMAP_CRANGE ;
|
|
|
|
private :
|
|
BBox3d m_BBox ;
|
|
double m_dCellDim ;
|
|
double m_dInvCellDim ;
|
|
IPNTI_UMMAP m_MMap ;
|
|
} ;
|