LVRChunkedMeshBridge.hpp
Go to the documentation of this file.
1 #ifndef LVR2_CHUNKED_MESH_BRIDGE_HPP_
2 #define LVR2_CHUNKED_MESH_BRIDGE_HPP_
3 
4 #include <QObject>
5 //extern "C" {
6 //#include <GL/glx.h>
7 //}
8 
9 #undef Success
10 
11 #include <vtkSmartPointer.h>
12 #include <vtkActor.h>
13 #include <vtkActorCollection.h>
14 #include <vtkRenderer.h>
15 #include <vtkCamera.h>
16 
20 
21 #include <string>
22 
23 //#include "MeshChunkActor.hpp"
24 
25 #include <mutex>
26 #include <thread>
27 #include <condition_variable>
28 
29 #include <vtkWeakPointer.h>
30 
31 
32 
33 //class XContext;
34 //class XVisualInfo;
35 //class Window;
36 //struct XID;
37 
38 //struct XVisualInfo;
39 //typedef struct XVisualInfo XVisualInfo;
40 
41 //struct XVisualInfo;
43 //typedef unsigned long XID;
44 //typedef XID Window;
45 //struct _XDisplay;
46 //typedef struct _XDisplay Display;
47 
48 typedef std::unordered_map<size_t, vtkSmartPointer<vtkActor> > actorMap;
49 Q_DECLARE_METATYPE(actorMap)
50 
51 //#include <GL/glx.h>
52 namespace lvr2 {
53 
54 template <typename T>
56 {
57 
58  public:
59  bool operator()(std::pair<float,T> p1, std::pair<float,T> p2)
60  {
61  return p1.first > p2.first;
62  }
63 };
64 
65 
66  class LVRChunkedMeshBridge : public QObject
67  {
68  Q_OBJECT
69  public:
70  LVRChunkedMeshBridge(std::string file, vtkSmartPointer<vtkRenderer> renderer,
71  std::vector<std::string> layers, size_t cache_size = 1000);
72  void getActors(double planes[24],
73  std::vector<BaseVector<float> >& centroids,
74  std::vector<size_t >& indices);
75 
76  std::mutex mw_mutex;
77  std::condition_variable mw_cond;
78  bool release = false;
79 
80  std::unordered_map<size_t, vtkSmartPointer<vtkActor>> getHighResActors() { return m_highResActors; }
81  std::unordered_map<size_t, vtkSmartPointer<vtkActor>> getLowResActors() { return m_chunkActors; }
82  //std::unordered_map<size_t, vtkSmartPointer<vtkActor> >& actors);
83  void addInitialActors(vtkSmartPointer<vtkRenderer> renderer);
84 
85  void fetchHighRes(BoundingBox<BaseVector<float > > bb,
86  std::vector<size_t> indices,
87  std::vector<BaseVector<float>> centroids);
88 
89  double getHighResDistance() {return m_highResDistance; }
90 
91  Q_SIGNALS:
92  void updateHighRes(actorMap lowRes, actorMap highRes);
93 
94 
95  protected:
96  void computeMeshActors();
97  inline vtkSmartPointer<vtkActor> computeMeshActor(size_t& id, MeshBufferPtr& chunk);
98 
99  private:
100  vtkSmartPointer<vtkRenderer> m_renderer;
101 
102  std::thread worker;
103  std::mutex mutex;
104  std::condition_variable cond_;
106  bool getNew_;
107  bool running_;
110  // Maybe use 2 maps.
111  std::vector<size_t> m_highResIndices;
112  std::vector<BaseVector<float> > m_highResCentroids;
113  std::vector<size_t > m_lastIndices;
114  std::vector<BaseVector<float> > m_lastCentroids;
115 
116  std::vector<std::string> m_layers;
117  size_t m_cacheSize;
118  void highResWorker();
120  std::unordered_map<size_t, MeshBufferPtr> m_chunks;
121  std::unordered_map<size_t, MeshBufferPtr> m_highRes;
122  std::unordered_map<size_t, vtkSmartPointer<vtkActor> > m_chunkActors;
123  std::unordered_map<size_t, vtkSmartPointer<vtkActor> > m_highResActors;
124 
125  std::unique_ptr<MeshOctree<BaseVector<float> > > m_oct;
126  };
127  typedef boost::shared_ptr<LVRChunkedMeshBridge> ChunkedMeshBridgePtr;
128 
129 } // namespace lvr2
130 
131 #endif
std::condition_variable mw_cond
std::vector< BaseVector< float > > m_lastCentroids
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getHighResActors()
std::vector< size_t > m_highResIndices
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
BoundingBox< BaseVector< float > > m_lastRegion
BoundingBox< BaseVector< float > > m_region
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > actorMap
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
vtkSmartPointer< vtkRenderer > m_renderer
std::unique_ptr< MeshOctree< BaseVector< float > > > m_oct
std::vector< std::string > m_layers
bool operator()(std::pair< float, T > p1, std::pair< float, T > p2)
std::unordered_map< size_t, MeshBufferPtr > m_chunks
std::condition_variable cond_
std::unordered_map< size_t, MeshBufferPtr > m_highRes
FILE * file
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > m_highResActors
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getLowResActors()
std::vector< size_t > m_lastIndices
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > m_chunkActors
boost::shared_ptr< LVRChunkedMeshBridge > ChunkedMeshBridgePtr
std::vector< BaseVector< float > > m_highResCentroids


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08