GlobeEngine
MBlockQuadtree.h
Go to the documentation of this file.
1 
8 #ifndef GlobeEngine_Raster_MBlockQuadtree_h
9 #define GlobeEngine_Raster_MBlockQuadtree_h
10 
11 #include <memory>
12 #include <iostream>
13 #include <math.h>
14 #include <set>
15 #include "DrawableComponent.h"
16 #include "CullableSpatialKey.h"
17 #include "ArrayTree.h"
18 #include "Texture.h"
19 #include "TerrainConfigStructs.h"
20 
21 using std::shared_ptr;
22 
23 namespace geRaster {
24 
25  class MBlock;
27 
28  class MBlockQuadtree : public MBlockQuadTreeTemplate
29  {
30  public:
31  enum LayerType {ELEVATION = 0, ORTHO };
32 
34  {
35  int tmsID;
36  int idx;
38 
39  MBlockQuadtreeLevel(int _tmsID, int _idx, LayerType _type) :
40  tmsID(_tmsID), idx(_idx), type(_type){}
41  };
42 
44  {
47  // Data arrays
48  std::vector<float> colsteps;
49  std::vector<float> edgelengths;
50  };
51 
52  public:
55  void clear();
56 
57  void create();
58  void create(vmml::Vector4d _bound);
59  void create(double _zero_x, double _zero_y, double _edge);
60  void createRootnode(vmml::Vector4d _bound);
61  void locateAndSetTexture(std::shared_ptr<geSpatial::CullableSpatialKey> _key, MBlockQuadtree::MBlockQuadtreeLevel _level, std::shared_ptr<ge::TextureHandle> _tex, float _max_error, float* _errors);
62  void removeNodeAndTexture(std::shared_ptr<geSpatial::CullableSpatialKey> _key);
63  void traverseAndMarkNodesInViewFrustum(std::shared_ptr<ge::Camera> _cam, bool _markToDelete);
64 
66  int locateMBlock(double _x, double _y, double _kPatchEdgeLenght);
67  void addKPatch(int _mblock, int _uid);
69 
70  // returns a reference to the visible MBlockField
71  std::shared_ptr<MBlock> const& getVisibleMBlock(int _idx);
72  const double* getBounds() const;
73  float getEdgeLenght() const;
75  void setPointPerSidePerMBlockError(int _input);
76  int getVisibleMBlockSize() const;
77 
78  // Dynamic update
79  void setReadyForGeometryUpdate(bool _in=true);
80  bool isReadyForGeometryUpdate() const;
81  void requestKey(std::shared_ptr<geSpatial::CullableSpatialKey> _key);
82  void removeKey(std::shared_ptr<geSpatial::CullableSpatialKey> _key);
83 
84  void print() const;
85  void printChildren(unsigned int _lod, bool _details) const;
86  void printVisibleChildren() const;
87 
88  std::vector< std::shared_ptr<geSpatial::CullableSpatialKey> > getWaitingRequests();
89 
90  std::vector< std::shared_ptr<geSpatial::CullableSpatialKey> > getWaitingRemoves();
91 
92  // gets the waiting key list
93  void cleanWaitingRequests();
94  bool waitingRequests();
95  bool removeRequests();
96 
97  // handling multiple layers of textures and
98  // height fields
100  void addLayerID(int _id, MBlockQuadtree::LayerType _type);
101  int getLayerIDAtLevel(int _level);
102  int getLayerCount();
103 
104  void calculateEdgelenghtsAndColsteps(int _maxLodLevels, int _patchSize, TerrainVis::TriangulationTechnique _technique);
105 
106  std::shared_ptr<MBlockQuadtree::MBlockQuadtreeLoDInfo> getLoDInfo() const;
107 
109 
110  public:
111  std::vector<int> visibleChildren;
112  //std::vector< std::shared_ptr<MBlock> > visibleChildren;
113  // Global quadtree properties
115 
119 
120  std::vector<MBlockQuadtreeLevel> tmsServiceLayerIDs;
121 
122  std::shared_ptr<MBlockQuadtreeLoDInfo> lodinfo;
123 
125 
127  };
128 }
129 #endif
130 
void setPointPerSidePerMBlockError(int _input)
Definition: MBlockQuadtree.cpp:335
void createRootnode(vmml::Vector4d _bound)
Definition: MBlockQuadtree.cpp:26
std::set< std::shared_ptr< geSpatial::CullableSpatialKey >, geSpatial::CullableSpatialKeyComp >::iterator CullableSpatialKeySetIterator
Definition: CullableSpatialKey.h:241
void printChildren(unsigned int _lod, bool _details) const
Definition: MBlockQuadtree.cpp:383
void cleanWaitingRequests()
Definition: MBlockQuadtree.cpp:208
void addKPatch(int _mblock, int _uid)
Definition: MBlockQuadtree.cpp:232
int tmsID
Definition: MBlockQuadtree.h:35
LayerType
Definition: MBlockQuadtree.h:31
std::vector< MBlockQuadtreeLevel > tmsServiceLayerIDs
Definition: MBlockQuadtree.h:120
void setVisibleChildren(TerrainVis::TriangulationTechnique _technique)
Definition: MBlockQuadtree.cpp:76
Definition: ArrayTree.h:13
std::set< std::shared_ptr< geSpatial::CullableSpatialKey >, geSpatial::CullableSpatialKeyComp > CullableSpatialKeySet
Definition: CullableSpatialKey.h:240
std::shared_ptr< MBlockQuadtreeLoDInfo > lodinfo
Definition: MBlockQuadtree.h:122
LayerType type
Definition: MBlockQuadtree.h:37
int getLayerIDAtLevel(int _level)
Definition: MBlockQuadtree.cpp:224
Definition: KPatchBase.h:13
void addLayerID(int _id, MBlockQuadtree::LayerType _type)
Definition: MBlockQuadtree.cpp:220
std::vector< int > visibleChildren
Definition: MBlockQuadtree.h:111
MBlockQuadtreeLevel(int _tmsID, int _idx, LayerType _type)
Definition: MBlockQuadtree.h:39
int locateMBlock(double _x, double _y, double _kPatchEdgeLenght)
Definition: MBlockQuadtree.cpp:118
void print() const
Definition: MBlockQuadtree.cpp:358
Definition: MBlockQuadtree.h:28
MBlockQuadtree()
Definition: MBlockQuadtree.cpp:12
void setReadyForGeometryUpdate(bool _in=true)
Definition: MBlockQuadtree.cpp:350
int getLayerCount()
Definition: MBlockQuadtree.cpp:228
geSpatial::CullableSpatialKeySet removableKeys
Definition: MBlockQuadtree.h:118
geSpatial::CullableSpatialKeySetIterator waitingKeysItr
Definition: MBlockQuadtree.h:116
bool readyForGeometryUpdate
Definition: MBlockQuadtree.h:124
std::shared_ptr< MBlock > const & getVisibleMBlock(int _idx)
Definition: MBlockQuadtree.cpp:320
void removeKey(std::shared_ptr< geSpatial::CullableSpatialKey > _key)
Definition: MBlockQuadtree.cpp:132
void removeNodeAndTexture(std::shared_ptr< geSpatial::CullableSpatialKey > _key)
Definition: MBlockQuadtree.cpp:193
MBlockQuadtree::MBlockQuadtreeLevel const & getQuadtreeLevelAtIdx(int _idx) const
Definition: MBlockQuadtree.cpp:216
std::vector< std::shared_ptr< geSpatial::CullableSpatialKey > > getWaitingRequests()
Definition: MBlockQuadtree.cpp:149
void cleanKPatchInformation()
Definition: MBlockQuadtree.cpp:264
~MBlockQuadtree()
Definition: MBlockQuadtree.cpp:16
double minimalMBlockBound
Definition: MBlockQuadtree.h:45
int getVisibleMBlockSize() const
Definition: MBlockQuadtree.cpp:345
bool isReadyForGeometryUpdate() const
Definition: MBlockQuadtree.cpp:354
void calculateEdgelenghtsAndColsteps(int _maxLodLevels, int _patchSize, TerrainVis::TriangulationTechnique _technique)
Definition: MBlockQuadtree.cpp:271
void clear()
Definition: MBlockQuadtree.cpp:20
std::vector< float > edgelengths
Definition: MBlockQuadtree.h:49
geSpatial::CullableSpatialKeySet waitingKeys
Definition: MBlockQuadtree.h:117
Definition: MBlock.h:18
std::shared_ptr< MBlockQuadtree::MBlockQuadtreeLoDInfo > getLoDInfo() const
Definition: MBlockQuadtree.cpp:315
TriangulationTechnique
Definition: TerrainConfigStructs.h:29
Definition: MBlockQuadtree.h:31
std::vector< std::shared_ptr< geSpatial::CullableSpatialKey > > getWaitingRemoves()
Definition: MBlockQuadtree.cpp:186
Definition: MBlockQuadtree.h:31
std::vector< float > colsteps
Definition: MBlockQuadtree.h:48
void locateAndSetTexture(std::shared_ptr< geSpatial::CullableSpatialKey > _key, MBlockQuadtree::MBlockQuadtreeLevel _level, std::shared_ptr< ge::TextureHandle > _tex, float _max_error, float *_errors)
Definition: MBlockQuadtree.cpp:113
bool waitingRequests()
Definition: MBlockQuadtree.cpp:212
int pointcountPerSideOfMblockerrors
Definition: MBlockQuadtree.h:114
geData::ArrayTree< std::shared_ptr< MBlock > > MBlockQuadTreeTemplate
Definition: MBlockQuadtree.h:25
short maxLoDForCoordinateCalculation
Definition: MBlockQuadtree.h:126
float getEdgeLenght() const
Definition: MBlockQuadtree.cpp:330
bool removeRequests()
Definition: MBlockQuadtree.cpp:204
void traverseAndMarkNodesInViewFrustum(std::shared_ptr< ge::Camera > _cam, bool _markToDelete)
Definition: MBlockQuadtree.cpp:69
void requestKey(std::shared_ptr< geSpatial::CullableSpatialKey > _key)
Definition: MBlockQuadtree.cpp:125
int idx
Definition: MBlockQuadtree.h:36
double baseEdgeLength
Definition: MBlockQuadtree.h:46
int getPointPerSidePerMBlockError() const
Definition: MBlockQuadtree.cpp:340
void printVisibleChildren() const
Definition: MBlockQuadtree.cpp:366
void create()
Definition: MBlockQuadtree.cpp:42
Definition: MBlockQuadtree.h:33
short getMaxLoDForCoordinateCalculation()
Definition: MBlockQuadtree.cpp:379
const double * getBounds() const
Definition: MBlockQuadtree.cpp:325