083bdcf285
- aggiornamenti vari.
50 lines
1.8 KiB
C++
50 lines
1.8 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/EGKPoint3d.h"
|
|
#include "/EgtDev/Include/EgtNumCollection.h"
|
|
#include <unordered_map>
|
|
|
|
//----------------------- 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( 10 * EPS_SMALL), m_dInvCellDim( 1 / m_dCellDim) {}
|
|
EGK_EXPORT bool Init( int nBuckets, double dCellDim = 10 * EPS_SMALL) ;
|
|
EGK_EXPORT bool InsertPoint( const Point3d& ptP, int nId) ;
|
|
EGK_EXPORT bool Find( const Point3d& ptTest, double dTol, INTVECTOR& vnIds) ;
|
|
EGK_EXPORT bool Find( const Point3d& ptTest, double dTol, int& nId) ;
|
|
|
|
private :
|
|
inline int Get1dCellNbr( double dCoord) ;
|
|
inline int PointHash( int nX, int nY, int nZ) ;
|
|
|
|
private :
|
|
typedef std::unordered_multimap<int,std::pair<Point3d,int>> IPNTI_UMMAP ;
|
|
|
|
private :
|
|
double m_dCellDim ;
|
|
double m_dInvCellDim ;
|
|
IPNTI_UMMAP m_MMap ;
|
|
} ;
|