ChunkManager.hpp
Go to the documentation of this file.
1 
37 #ifndef CHUNK_MANAGER_HPP
38 #define CHUNK_MANAGER_HPP
39 
44 #include "lvr2/io/Model.hpp"
45 #include "lvr2/types/Channel.hpp"
46 
47 namespace lvr2
48 {
49 
51 {
52  public:
53  using FilterFunction = std::function<bool(MultiChannelMap::val_type, size_t)>;
54 
69  float chunksize,
70  float maxChunkOverlap,
71  std::string savePath,
72  std::string layer = std::string("mesh"),
73  size_t cacheSize = 200
74  );
75 
76 
77  ChunkManager(std::vector<MeshBufferPtr> meshes,
78  float chunksize,
79  float maxChunkOverlap,
80  std::string savePath,
81  std::vector<std::string> layers,
82  size_t cacheSize = 200);
83 
94  ChunkManager(std::string hdf5Path, size_t cacheSize = 200, float chunkSize = 10.0f);
95 
102  {
103  return m_boundingBox;
104  }
105 
116  void buildChunks(MeshBufferPtr mesh, float maxChunkOverlap, std::string savePath, std::string layer = std::string("mesh"));
117 
127  MeshBufferPtr extractArea(const BoundingBox<BaseVector<float>>& area, std::string layer= std::string("mesh"));
128 
129  void extractArea(const BoundingBox<BaseVector<float> >& area,
130  std::unordered_map<std::size_t, MeshBufferPtr>& chunks,
131  std::string layer = std::string("mesh"));
132 
133 
156  const std::map<std::string, FilterFunction> filter,
157  std::string layer = std::string("mesh"));
158 
164  std::vector<std::string> getChannelsFromMesh(std::string layer = std::string("mesh"));
165 
170  void loadAllChunks(std::string layer = std::string("mesh"));
171 
172  private:
180  void initBoundingBox(MeshBufferPtr mesh);
181 
196  void
197  cutLargeFaces(std::shared_ptr<HalfEdgeMesh<BaseVector<float>>> halfEdgeMesh,
198  float overlapRatio,
199  std::shared_ptr<std::unordered_map<unsigned int, unsigned int>> splitVertices,
200  std::shared_ptr<std::unordered_map<unsigned int, unsigned int>> splitFaces);
201 
211  const FaceHandle& handle) const;
212 
213  // /**
214  // * @brief find corresponding grid cell of given point
215  // *
216  // * @param vec point of mesh to find cell id for
217  // * @return cell id
218  // */
219  // std::string getCellName(const BaseVector<float>& vec) const;
220 
228 
239  template <typename T>
241  std::unordered_map<std::size_t, MeshBufferPtr>& chunks,
242  std::string channelName,
243  std::size_t staticVertexIndexOffset,
244  std::size_t numVertices,
245  std::size_t numFaces,
246  std::vector<std::unordered_map<std::size_t, std::size_t>>& areaVertexIndices);
247 
261  template <typename T>
263  applyChannelFilter(const std::vector<bool>& vertexFilter,
264  const std::vector<bool>& faceFilter,
265  const size_t numVertices,
266  const size_t numFaces,
267  const MeshBufferPtr meshBuffer,
268  const MultiChannelMap::val_type& originalChannel) const;
269 };
270 
271 } /* namespace lvr2 */
272 
273 #include "ChunkManager.tcc"
274 
275 #endif // CHUNK_MANAGER_HPP
void buildChunks(MeshBufferPtr mesh, float maxChunkOverlap, std::string savePath, std::string layer=std::string("mesh"))
buildChunks builds chunks from an original mesh
HalfEdgeMesh< Vec > mesh
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
MeshBufferPtr extractArea(const BoundingBox< BaseVector< float >> &area, std::string layer=std::string("mesh"))
extractArea creates and returns MeshBufferPtr of merged chunks for given area.
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
std::function< bool(MultiChannelMap::val_type, size_t)> FilterFunction
std::vector< std::string > getChannelsFromMesh(std::string layer=std::string("mesh"))
Get all existing channels from mesh.
ChunkManager(MeshBufferPtr meshes, float chunksize, float maxChunkOverlap, std::string savePath, std::string layer=std::string("mesh"), size_t cacheSize=200)
ChunkManager creates chunks from an original mesh.
BaseVector< float > getFaceCenter(std::shared_ptr< HalfEdgeMesh< BaseVector< float >>> mesh, const FaceHandle &handle) const
getFaceCenter gets the center point for a given face
ChannelPtr< T > extractChannelOfArea(std::unordered_map< std::size_t, MeshBufferPtr > &chunks, std::string channelName, std::size_t staticVertexIndexOffset, std::size_t numVertices, std::size_t numFaces, std::vector< std::unordered_map< std::size_t, std::size_t >> &areaVertexIndices)
reads and combines a channel of multiple chunks
void initBoundingBox(MeshBufferPtr mesh)
initBoundingBox calculates a bounding box of the original mesh
void loadAllChunks(std::string layer=std::string("mesh"))
Loads all chunks into the ChunkHashGrid. DEBUG – Only used for testing, but might be useful for smal...
Half-edge data structure implementing the BaseMesh interface.
void filter(lvr2::PointBufferPtr &cloud, lvr2::indexArray &inlier, size_t j)
BoundingBox< BaseVector< float > > m_boundingBox
BoundingBox< BaseVector< float > > getGlobalBoundingBox()
getGlobalBoundingBox is a getter for the bounding box of the entire chunked model ...
BaseVector< int > getCellCoordinates(const BaseVector< float > &vec) const
find corresponding grid cell of given point
void cutLargeFaces(std::shared_ptr< HalfEdgeMesh< BaseVector< float >>> halfEdgeMesh, float overlapRatio, std::shared_ptr< std::unordered_map< unsigned int, unsigned int >> splitVertices, std::shared_ptr< std::unordered_map< unsigned int, unsigned int >> splitFaces)
cutLargeFaces cuts a face if it is too large
MultiChannelMap::val_type applyChannelFilter(const std::vector< bool > &vertexFilter, const std::vector< bool > &faceFilter, const size_t numVertices, const size_t numFaces, const MeshBufferPtr meshBuffer, const MultiChannelMap::val_type &originalChannel) const
applies given filter arrays to one channel
typename Channel< T >::Ptr ChannelPtr
Definition: Channel.hpp:82
Handle to access faces of the mesh.
Definition: Handles.hpp:140


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:06