GlobeEngine
DouglasPeuckerDrawablePath.h
Go to the documentation of this file.
1 //
2 // DrawablePolyline.h
3 // GlobeEngine
4 //
5 // Created by Mathias Thöny on 27.12.11.
6 // Copyright (c) 2011 University of Zurich. All rights reserved.
7 //
8 
9 #ifndef GlobeEngine_DouglasPeuckerDrawablePath_h
10 #define GlobeEngine_DouglasPeuckerDrawablePath_h
11 
12 #include <queue>
13 #include "PolyLine.h"
14 #include "OpenGL_Includes.h"
15 #include "DrawableComponent.h"
16 #include "ArrayTreeNode.h"
17 
18 namespace geData {
20  {
21  public:
23  this->distance = -1.0f;
24  this->splitHeight = -1.0;
25  this->enabled = false;
26  };
28 
29  void setDistance(double _in) {
30  distance = _in;
31  };
32  double getDistance() const {
33  return distance;
34  }
35  void setSplitHeight(double _in) {
36  this->splitHeight = _in;
37  };
38  double getSplitHeight() const {
39  return this->splitHeight;
40  }
41 
42  void printValue() const {
43  //ArrayBinTreeNode::printValue();
44  std::cout << this << " ";
45  std::cout << this->enabled << " ";
46  std::cout << this->distance << " ";
47  std::cout << this->splitHeight << " ";
48  }
49 
50  void enable() {
51  enabled = true;
52  }
53 
54  void disable() {
55  enabled = false;
56  }
57 
58  bool IsEnabled(){
59  return enabled;
60  }
61 
62  private:
63  double splitHeight;
64  double distance;
65  bool enabled;
66 
67  };
68 
70  {
71 
72  public:
73  /* 0 = line,
74  1 = triangulated with overlaps,
75  2 = triangulated as nice ribbon,
76  3 = gputriangulated
77  */
84  void clear();
85  void update();
86  void create() {};
87  void createVAO(GEOMETRYDRAWMODE _in);
88  void createTriangleIndices();
89  void createRibbonIndices();
90 
93 
94 
95  /* 0=line, 1=lineWithThickness, 2=triangulated, 3=gputriangulated */
97  return this->drawMode;
98  };
99 
100  // inherited
101  void draw(std::shared_ptr<ge::Camera> _cam);
102  void drawWithOcclusionQueries(DrawableComponent::RENDERSTATE _state, std::shared_ptr<ge::Camera> _cam);
103 
104  // protected methods
105  void setLineThickness(double _thickness);
106 
107  // douglas peucker property
109  void setRefinementLevel(); //int _level);
110 
111  // protected
112  void enableOcclusionQueries(bool _in);
113  void printDPTree(int _idx);
114  void printAllDPTrees();
115  void printPoints();
116 
117  unsigned int connectTree(unsigned int _min, unsigned int _max,
118  unsigned int _parent, short _childIdx, unsigned int _treeIdx);
119  void inOrderTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _activePointIdx);
120  void inOrderHeightTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _activePointIdx);
121  bool nodeAccessPossible(unsigned int _id, unsigned int _treeIdx);
122 
123  unsigned int inOrderUpdateTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _alloverID);
124  unsigned int inOrderHeightUpdateTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _alloverID);
125 
126  bool enableNeighborRecursive(short _child, unsigned int _id, unsigned int _treeIdx);
127  bool enableHeightNeighborRecursive(short _child, unsigned int _id, unsigned int _treeIdx);
128 
129  void setRefined(bool _in);
130  bool IsRefined();
132  return occlusionQueriesEnabled;
133  }
134 
135  void updateSingleScanning();
136  void updateInitialScanning();
137 
138  void enableInitialScan();
139  void disableInitialScan();
140  bool isInitialScanningOn();
141 
142  private:
143  void genenerateOcclusionQueries();
144  void beginOcclusionQueries(int idx);
145  void endOcclusionQueries();
146  void readOcclusionQueryResult(GLuint* _ids, GLuint* _results);
147 
148  void clearInitial();
149  void allocateOcclusionMemory();
150  void deleteOcclusionMemory();
151  void generateControlPointArray();
152  void removeSlopesAtStartAndEnd();
153  void evaluateLineQuery();
154 
155 
156  GEOMETRYDRAWMODE drawMode;
157  DrawableComponent::RENDERSTATE renderState;
158  // Spline property
159  //bool needsRefinement;
160 
161  int pointSum;
162  /* indexed douglas peucker information */
163  DouglasPeuckerPathNode** dptrees;
164  unsigned int* dptreeSize;
165  int* dptreeRoots;
166  unsigned int visibleSegmentCount;
167  /* Hardware occlusion queries
168  * 0 = no query requested
169  * 1 = query requested
170  * 2 = glBeginQuery called
171  * 3 = wait for result
172  * 4 = result ready, query deleted
173  */
174  GLuint* occlusionQueryIDs;
175  GLuint* occlusionQueryGTIDs;
176  // occlusion queries
177  // 0=not set 1=requested 2=finished
178  // pixels showed the ground truth
179  GLuint* occlusionGroundTruths;
180  GLuint* renderPixelInLastFrames;
181  GLuint checkForOcclusionResult;
182 
183  GLuint* indices;
184  // temp arrays
185  std::vector<unsigned int> ids;
186  std::queue<unsigned int> uids;
187 
188  char refinementStep;
189  bool occlusionQueriesEnabled;
190  bool isRefined;
191  bool initialScanningOn;
192  };
193 }
194 #endif
void createVAO(GEOMETRYDRAWMODE _in)
Definition: DouglasPeuckerDrawablePath.cpp:414
Definition: DrawableComponent.h:25
Definition: DouglasPeuckerDrawablePath.h:78
void printDPTree(int _idx)
Definition: DouglasPeuckerDrawablePath.cpp:1066
enum GEOMETRYDRAWMODE getDrawMode() const
Definition: DouglasPeuckerDrawablePath.h:96
void disable()
Definition: DouglasPeuckerDrawablePath.h:54
void setDistance(double _in)
Definition: DouglasPeuckerDrawablePath.h:29
unsigned int connectTree(unsigned int _min, unsigned int _max, unsigned int _parent, short _childIdx, unsigned int _treeIdx)
Definition: DouglasPeuckerDrawablePath.cpp:796
void setupGeometryBuffersWithLineStripInformation()
Definition: DouglasPeuckerDrawablePath.cpp:458
void inOrderTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _activePointIdx)
Definition: DouglasPeuckerDrawablePath.cpp:887
double getDistance() const
Definition: DouglasPeuckerDrawablePath.h:32
void setLineThickness(double _thickness)
Definition: DouglasPeuckerDrawablePath.cpp:1093
Definition: AvalancheTrainingSimulationEngine.h:39
void enableOcclusionQueries(bool _in)
Definition: DouglasPeuckerDrawablePath.cpp:990
DouglasPeuckerPathNode()
Definition: DouglasPeuckerDrawablePath.h:22
void enable()
Definition: DouglasPeuckerDrawablePath.h:50
bool IsOcclusionQueriesEnabled()
Definition: DouglasPeuckerDrawablePath.h:131
void setDouglasPeuckerIndices()
Definition: DouglasPeuckerDrawablePath.cpp:723
bool enableHeightNeighborRecursive(short _child, unsigned int _id, unsigned int _treeIdx)
bool enableNeighborRecursive(short _child, unsigned int _id, unsigned int _treeIdx)
Definition: DouglasPeuckerDrawablePath.cpp:392
void disableInitialScan()
Definition: DouglasPeuckerDrawablePath.cpp:1112
bool IsRefined()
Definition: DouglasPeuckerDrawablePath.cpp:1103
~DouglasPeuckerDrawablePath()
Definition: DouglasPeuckerDrawablePath.cpp:20
Definition: DouglasPeuckerDrawablePath.h:79
Definition: DouglasPeuckerDrawablePath.h:69
Definition: DouglasPeuckerDrawablePath.h:19
double getSplitHeight() const
Definition: DouglasPeuckerDrawablePath.h:38
bool IsEnabled()
Definition: DouglasPeuckerDrawablePath.h:58
DouglasPeuckerDrawablePath()
Definition: DouglasPeuckerDrawablePath.cpp:5
void printAllDPTrees()
Definition: DouglasPeuckerDrawablePath.cpp:1076
void drawWithOcclusionQueries(DrawableComponent::RENDERSTATE _state, std::shared_ptr< ge::Camera > _cam)
Definition: DouglasPeuckerDrawablePath.cpp:689
void setRefined(bool _in)
Definition: DouglasPeuckerDrawablePath.cpp:1098
Definition: ArrayTreeNode.h:14
void update()
Definition: DouglasPeuckerDrawablePath.cpp:101
void enableInitialScan()
Definition: DouglasPeuckerDrawablePath.cpp:1108
void createTriangleIndices()
Definition: DouglasPeuckerDrawablePath.cpp:594
bool nodeAccessPossible(unsigned int _id, unsigned int _treeIdx)
void draw(std::shared_ptr< ge::Camera > _cam)
Definition: DouglasPeuckerDrawablePath.cpp:621
unsigned int inOrderHeightUpdateTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _alloverID)
Definition: DouglasPeuckerDrawablePath.cpp:205
void createRibbonIndices()
Definition: DouglasPeuckerDrawablePath.cpp:610
Definition: PolyLine.h:24
GEOMETRYDRAWMODE
Definition: DouglasPeuckerDrawablePath.h:78
void setRefinementLevel()
Definition: DouglasPeuckerDrawablePath.cpp:826
void printValue() const
Definition: DouglasPeuckerDrawablePath.h:42
Definition: DouglasPeuckerDrawablePath.h:80
void create()
Definition: DouglasPeuckerDrawablePath.h:86
Definition: DouglasPeuckerDrawablePath.h:81
~DouglasPeuckerPathNode()
Definition: DouglasPeuckerDrawablePath.h:27
void setupGeometryBuffersAsRibbons()
Definition: DouglasPeuckerDrawablePath.cpp:481
bool isInitialScanningOn()
Definition: DouglasPeuckerDrawablePath.cpp:1117
void updateSingleScanning()
Definition: DouglasPeuckerDrawablePath.cpp:278
unsigned int inOrderUpdateTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _alloverID)
Definition: DouglasPeuckerDrawablePath.cpp:359
void clear()
Definition: DouglasPeuckerDrawablePath.cpp:44
void setSplitHeight(double _in)
Definition: DouglasPeuckerDrawablePath.h:35
void updateInitialScanning()
Definition: DouglasPeuckerDrawablePath.cpp:127
void inOrderHeightTraversal(unsigned int _id, unsigned int _treeIdx, unsigned int _activePointIdx)
Definition: DouglasPeuckerDrawablePath.cpp:908