GlobeEngine
ClusterGrid.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_Cluster_h
10 #define GlobeEngine_Cluster_h
11 
12 #include <vmmlib/vmmlib.hpp>
13 #include "OpenGL_Includes.h"
14 #include "VBOVertex.h"
15 #include "Texture.h"
16 
17 namespace geGIS {
18 
20  {
21  //std::shared_ptr<ge::Texture2Dui> countTexture;
22  std::shared_ptr<ge::Texture2Dui> offsetTexture;
23  std::shared_ptr<ge::Texture2Dui> maxMortonDepthTexture;
24  std::shared_ptr<ge::Texture2Dui> boundOffsetTexture;
25  };
26 
28  {
29 
30  public:
31  ClusterGrid();
32  ~ClusterGrid();
33  void clear();
34  void create(vmml::Vector2ui _clusterCount,
35  vmml::Vector2d _clusterSize,
36  vmml::Vector4d _objectBounds);
37 
38  vmml::Vector2ui getClusterIDForPoint(const ge::Vertex2d& _p1, double _addDistance);
39  vmml::Vector4ui getClusterIDBoundsForLine(const ge::Vertex2d& _p1, const ge::Vertex2d& _p2, double _lineAdditionalDistance);
40  std::vector<unsigned int> getClustersByLineIntersection(const ge::Vertex2d& _p1, const ge::Vertex2d& _p2, double _lineWidth);
41  bool intersectLineWithClusters(vmml::Vector2ui _cluster, double _lineAdditionalDistance, const ge::Vertex2d& _p1, const ge::Vertex2d& _p2);
42  void assignLineToClusterIDs(unsigned int _lineSegmentID, std::vector<unsigned int> _clusterIds);
45 
46  vmml::Vector2ui getClusterID2D(unsigned int _clusterID);
47  vmml::Vector4d getClusterBounds(vmml::Vector2ui _cluster, double _lineAdditionalDistance);
48 
50 
51  void setMortonForCluster(unsigned int _idx, std::vector<size_t> _mortonCodes);
52  std::vector<size_t> getMortonCodesForCluster(unsigned int _idx);
53 
54  void setMaxMortonDepthForCluster(unsigned int _idx, unsigned int _depth);
55  void setMortonBoundOffsetForCluster(unsigned int _idx, unsigned int _offset);
56 
57  unsigned int getLineSegmentIDForCluster(int _clusterID, int _lineIdx) const;
58  unsigned int getNumberOfLinesForCluster(int _clusterId) const;
59  unsigned int getGPUIndexCount() const;
60  unsigned int getClusterCount() const;
61  vmml::Vector2ui getClusterCount2D() const;
62  vmml::Vector2d getClusterSize() const;
63  vmml::Vector4d getBounds() const;
64  vmml::Vector4d getClusterBounds() const;
65  private:
66 
67  unsigned int clusterCount1D;
68  vmml::Vector2ui clusterCount;
69  vmml::Vector2d clusterSize;
70  vmml::Vector4d objectBounds;
71 
72  unsigned int gpuIndexCount;
73  std::vector<unsigned int> lineSegmentIDPerClusterID[65536];
74  std::vector<size_t> mortonOrderPerClusterID[65536];
75  //unsigned int idSumsPerClusterID[65536];
76  unsigned int idOffsetsPerClusterID[65536];
77 
78  unsigned int maxMortonDepthPerClusterID[65536];
79  unsigned int offsetMortonBoundsPerClusterID[65536];
80 
81  ClusterGridTextures textures;
82  };
83 }
84 #endif
~ClusterGrid()
Definition: ClusterGrid.cpp:14
ClusterGrid()
Definition: ClusterGrid.cpp:10
vmml::Vector2ui getClusterIDForPoint(const ge::Vertex2d &_p1, double _addDistance)
Definition: ClusterGrid.cpp:41
Definition: ClusterGrid.h:17
Definition: ClusterGrid.h:19
unsigned int getLineSegmentIDForCluster(int _clusterID, int _lineIdx) const
Definition: ClusterGrid.cpp:230
Definition: ClusterGrid.h:27
void copyClusterGridToGPUBuffer()
Definition: ClusterGrid.cpp:178
vmml::Vector2d getClusterSize() const
Definition: ClusterGrid.cpp:246
vmml::Vector4d getBounds() const
Definition: ClusterGrid.cpp:250
vmml::Vector4ui getClusterIDBoundsForLine(const ge::Vertex2d &_p1, const ge::Vertex2d &_p2, double _lineAdditionalDistance)
Definition: ClusterGrid.cpp:53
void copyClusterGridBoundInfoToGPUBuffer()
Definition: ClusterGrid.cpp:204
unsigned int getGPUIndexCount() const
Definition: ClusterGrid.cpp:254
unsigned int getClusterCount() const
Definition: ClusterGrid.cpp:238
const ClusterGridTextures * getClusterHandles()
Definition: ClusterGrid.cpp:258
std::shared_ptr< ge::Texture2Dui > maxMortonDepthTexture
Definition: ClusterGrid.h:23
vmml::Vector4d getClusterBounds() const
void clear()
Definition: ClusterGrid.cpp:18
std::shared_ptr< ge::Texture2Dui > boundOffsetTexture
Definition: ClusterGrid.h:24
bool intersectLineWithClusters(vmml::Vector2ui _cluster, double _lineAdditionalDistance, const ge::Vertex2d &_p1, const ge::Vertex2d &_p2)
Definition: ClusterGrid.cpp:138
std::shared_ptr< ge::Texture2Dui > offsetTexture
Definition: ClusterGrid.h:22
void setMortonForCluster(unsigned int _idx, std::vector< size_t > _mortonCodes)
Definition: ClusterGrid.cpp:226
unsigned int getNumberOfLinesForCluster(int _clusterId) const
Definition: ClusterGrid.cpp:234
void assignLineToClusterIDs(unsigned int _lineSegmentID, std::vector< unsigned int > _clusterIds)
Definition: ClusterGrid.cpp:169
Definition: VBOVertex.h:51
std::vector< unsigned int > getClustersByLineIntersection(const ge::Vertex2d &_p1, const ge::Vertex2d &_p2, double _lineWidth)
Definition: ClusterGrid.cpp:94
std::vector< size_t > getMortonCodesForCluster(unsigned int _idx)
Definition: ClusterGrid.cpp:222
vmml::Vector2ui getClusterID2D(unsigned int _clusterID)
Definition: ClusterGrid.cpp:33
vmml::Vector2ui getClusterCount2D() const
Definition: ClusterGrid.cpp:242
void setMaxMortonDepthForCluster(unsigned int _idx, unsigned int _depth)
Definition: ClusterGrid.cpp:218
void create(vmml::Vector2ui _clusterCount, vmml::Vector2d _clusterSize, vmml::Vector4d _objectBounds)
Definition: ClusterGrid.cpp:23
void setMortonBoundOffsetForCluster(unsigned int _idx, unsigned int _offset)
Definition: ClusterGrid.cpp:214