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 
86  std::vector<size_t> indices,
87  std::vector<BaseVector<float>> centroids);
88 
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
lvr2::LVRChunkedMeshBridge::m_chunks
std::unordered_map< size_t, MeshBufferPtr > m_chunks
Definition: LVRChunkedMeshBridge.hpp:120
MeshOctree.hpp
lvr2::LVRChunkedMeshBridge::m_highResCentroids
std::vector< BaseVector< float > > m_highResCentroids
Definition: LVRChunkedMeshBridge.hpp:112
lvr2::BaseVector< float >
lvr2::LVRChunkedMeshBridge::fetchHighRes
void fetchHighRes(BoundingBox< BaseVector< float > > bb, std::vector< size_t > indices, std::vector< BaseVector< float >> centroids)
Definition: LVRChunkedMeshBridge.cpp:220
lvr2::LVRChunkedMeshBridge::m_lastCentroids
std::vector< BaseVector< float > > m_lastCentroids
Definition: LVRChunkedMeshBridge.hpp:114
lvr2::LVRChunkedMeshBridge::getHighResDistance
double getHighResDistance()
Definition: LVRChunkedMeshBridge.hpp:89
lvr2::LVRChunkedMeshBridge::m_lastRegion
BoundingBox< BaseVector< float > > m_lastRegion
Definition: LVRChunkedMeshBridge.hpp:109
lvr2::LVRChunkedMeshBridge::m_chunkManager
lvr2::ChunkManager m_chunkManager
Definition: LVRChunkedMeshBridge.hpp:119
lvr2::LVRChunkedMeshBridge::m_highResDistance
double m_highResDistance
Definition: LVRChunkedMeshBridge.hpp:105
lvr2::LVRChunkedMeshBridge::addInitialActors
void addInitialActors(vtkSmartPointer< vtkRenderer > renderer)
Definition: LVRChunkedMeshBridge.cpp:235
lvr2::LVRChunkedMeshBridge::getLowResActors
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getLowResActors()
Definition: LVRChunkedMeshBridge.hpp:81
lvr2::LVRChunkedMeshBridge::mw_mutex
std::mutex mw_mutex
Definition: LVRChunkedMeshBridge.hpp:76
lvr2::ChunkedMeshBridgePtr
boost::shared_ptr< LVRChunkedMeshBridge > ChunkedMeshBridgePtr
Definition: LVRChunkedMeshBridge.hpp:127
lvr2::LVRChunkedMeshBridge::m_lastIndices
std::vector< size_t > m_lastIndices
Definition: LVRChunkedMeshBridge.hpp:113
lvr2::LVRChunkedMeshBridge::getActors
void getActors(double planes[24], std::vector< BaseVector< float > > &centroids, std::vector< size_t > &indices)
Definition: LVRChunkedMeshBridge.cpp:323
lvr2::LVRChunkedMeshBridge::m_chunkActors
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > m_chunkActors
Definition: LVRChunkedMeshBridge.hpp:122
lvr2::LVRChunkedMeshBridge::highResWorker
void highResWorker()
Definition: LVRChunkedMeshBridge.cpp:35
lvr2::LVRChunkedMeshBridge::release
bool release
Definition: LVRChunkedMeshBridge.hpp:78
lvr2::LVRChunkedMeshBridge::m_highRes
std::unordered_map< size_t, MeshBufferPtr > m_highRes
Definition: LVRChunkedMeshBridge.hpp:121
lvr2::LVRChunkedMeshBridge::mutex
std::mutex mutex
Definition: LVRChunkedMeshBridge.hpp:103
lvr2::LVRChunkedMeshBridge::LVRChunkedMeshBridge
LVRChunkedMeshBridge(std::string file, vtkSmartPointer< vtkRenderer > renderer, std::vector< std::string > layers, size_t cache_size=1000)
Definition: LVRChunkedMeshBridge.cpp:26
actorMap
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > actorMap
Definition: LVRChunkedMeshBridge.hpp:48
lvr2::LVRChunkedMeshBridge::m_highResActors
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > m_highResActors
Definition: LVRChunkedMeshBridge.hpp:123
lvr2::LVRChunkedMeshBridge::m_renderer
vtkSmartPointer< vtkRenderer > m_renderer
Definition: LVRChunkedMeshBridge.hpp:100
lvr2::LVRChunkedMeshBridge
Definition: LVRChunkedMeshBridge.hpp:66
lvr2::LVRChunkedMeshBridge::cond_
std::condition_variable cond_
Definition: LVRChunkedMeshBridge.hpp:104
lvr2::LVRChunkedMeshBridge::m_layers
std::vector< std::string > m_layers
Definition: LVRChunkedMeshBridge.hpp:116
lvr2::BoundingBox
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
file
FILE * file
Definition: arithmeticencoder.cpp:77
lvr2::LVRChunkedMeshBridge::m_oct
std::unique_ptr< MeshOctree< BaseVector< float > > > m_oct
Definition: LVRChunkedMeshBridge.hpp:125
lvr2::LVRChunkedMeshBridge::m_highResIndices
std::vector< size_t > m_highResIndices
Definition: LVRChunkedMeshBridge.hpp:111
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::CompareDistancePair::operator()
bool operator()(std::pair< float, T > p1, std::pair< float, T > p2)
Definition: LVRChunkedMeshBridge.hpp:59
lvr2::CompareDistancePair
Definition: LVRChunkedMeshBridge.hpp:55
lvr2::MeshBufferPtr
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
lvr2::LVRChunkedMeshBridge::getHighResActors
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getHighResActors()
Definition: LVRChunkedMeshBridge.hpp:80
lvr2::LVRChunkedMeshBridge::running_
bool running_
Definition: LVRChunkedMeshBridge.hpp:107
lvr2::LVRChunkedMeshBridge::updateHighRes
void updateHighRes(actorMap lowRes, actorMap highRes)
lvr2::LVRChunkedMeshBridge::mw_cond
std::condition_variable mw_cond
Definition: LVRChunkedMeshBridge.hpp:77
lvr2::LVRChunkedMeshBridge::m_cacheSize
size_t m_cacheSize
Definition: LVRChunkedMeshBridge.hpp:117
ChunkManager.hpp
lvr2::LVRChunkedMeshBridge::getNew_
bool getNew_
Definition: LVRChunkedMeshBridge.hpp:106
lvr2::ChunkManager
Definition: ChunkManager.hpp:50
lvr2::LVRChunkedMeshBridge::computeMeshActor
vtkSmartPointer< vtkActor > computeMeshActor(size_t &id, MeshBufferPtr &chunk)
Definition: LVRChunkedMeshBridge.cpp:350
BoundingBox.hpp
lvr2::LVRChunkedMeshBridge::m_region
BoundingBox< BaseVector< float > > m_region
Definition: LVRChunkedMeshBridge.hpp:108
lvr2::LVRChunkedMeshBridge::computeMeshActors
void computeMeshActors()
Definition: LVRChunkedMeshBridge.cpp:332
lvr2::LVRChunkedMeshBridge::worker
std::thread worker
Definition: LVRChunkedMeshBridge.hpp:102


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 Wed Mar 2 2022 00:37:24