MeshOctree.hpp
Go to the documentation of this file.
1 #ifndef CHUNKED_MESH_OCTREE
2 #define CHUNKED_MESH_OCTREE
3 
4 #include <vector>
5 
6 #include "lvr2/display/BOct.hpp"
10 
12 
13 namespace lvr2
14 {
15 //
16 // struct BOct
17 // {
18 // long long m_child : 48;
19 // unsigned char m_valid : 8;
20 // unsigned char m_leaf : 8;
21 // BOct(): m_child(0), m_valid(0), m_leaf(0){}
22 // };
23 
24  struct ChunkLeaf
25  {
26  std::vector<BaseVector<float> > m_centroids;
27  std::vector<size_t> m_hashes;
28 // unsigned long long m_mesh : 56;
29 // unsigned char m_loaded : 8;
30 // ChunkLeaf(): m_mesh(0), m_loaded(0){}
31  };
32 
33  template <typename BaseVecT>
34  class MeshOctree
35  {
36  public:
37  MeshOctree(float voxelSize, std::vector<size_t>& hashes, std::vector<BaseVecT>& centroids, BoundingBox<BaseVecT>& bb);
38 
39  //void intersect(double planes[6][4], std::vector<unsigned int>& indices);
40  void intersect(double planes[24], std::vector<BaseVecT>& indices, std::vector<size_t>& hashes);
41  void setLOD(unsigned char lod) { m_lod = lod; }
42 
44 
45  virtual ~MeshOctree() { m_root = NULL; }
46 
47  private:
48  float m_voxelSize;
51  // needs [] operator and has to be strict linear in memory
52 // FloatChannel m_points;
53 
54 // std::vector<size_t> m_hashes;
55 // std::vector<BaseVecT> m_centroid;
56 
57 
59 
60  unsigned char m_lod;
61  size_t numLeafs;
62 
63  template <typename T>
64  void link(BOct* parent, T* child);
65 
66  template <typename T>
67  T* getChildPtr(BOct* parent);
68 
69  unsigned char getIndex(const BaseVecT& point, const BoundingBox<BaseVecT>& bbox);
70 
71  void getBBoxes(const BoundingBox<BaseVecT>& bbox, BoundingBox<BaseVecT>* boxes);
72 
73 // template <typename PtrT>
74 // void sortPC(size_t start, size_t size, const BoundingBox<BaseVecT>& bbox, size_t bucket_sizes[8]);
75 
76  long buildTree(BOct* oct, std::vector<size_t>& hashes, std::vector<BaseVecT>& centroids, const BoundingBox<BaseVecT>& bbox);
77 
78 
79  void intersect(ChunkLeaf* leaf, const BoundingBox<BaseVecT>& bbox, double planes[24], std::vector<BaseVecT >& indices, std::vector<size_t>& hashes);
80 
81  void intersect(BOct* oct, const BoundingBox<BaseVecT>& bbox, double planes[24], std::vector<BaseVecT >& indices, std::vector<size_t>& hashes);
82 
83 
84  void getHashes(BOct* oct, std::vector<BaseVecT>& indices, std::vector<size_t>& hashes);
85 
86 // void colorAndWrite(BOct* oct);
87 //
88 // void colorAndWrite(BOct* oct, unsigned char index);
89 //
90 // void writeChunkLeaf(Leaf* leaf, unsigned char index);
91 
92  // void intersect(BOct* oct, const BoundingBox<BaseVecT>& octBBox, const BoundingBox<BaseVecT>& cullBBox, std::vector<BaseVecT >& pts);
93 
94  // void intersect(const BoundingBox<BaseVecT>& cullBBox, std::vector<BaseVecT >& pts);
95 
96  };
97 }
98 
99 #include "lvr2/display/MeshOctree.tcc"
100 
101 #endif
BaseVector.hpp
MemoryHandler.hpp
lvr2::ChunkLeaf::m_centroids
std::vector< BaseVector< float > > m_centroids
Definition: MeshOctree.hpp:26
lvr2::MeshOctree::~MeshOctree
virtual ~MeshOctree()
Definition: MeshOctree.hpp:45
lvr2::MeshOctree::numLeafs
size_t numLeafs
Definition: MeshOctree.hpp:61
lvr2::MeshOctree::m_voxelSize
float m_voxelSize
Definition: MeshOctree.hpp:48
lvr2::MeshOctree::m_lod
unsigned char m_lod
Definition: MeshOctree.hpp:60
lvr2::MeshOctree::getHashes
void getHashes(BOct *oct, std::vector< BaseVecT > &indices, std::vector< size_t > &hashes)
lvr2::MeshOctree::m_root
BOct * m_root
Definition: MeshOctree.hpp:49
NULL
#define NULL
Definition: mydefs.hpp:141
ChunkMemoryHandler
Definition: MemoryHandler.hpp:8
lvr2::BOct
Definition: BOct.hpp:8
BOct.hpp
lvr2::MeshOctree::link
void link(BOct *parent, T *child)
PointBuffer.hpp
lvr2::MeshOctree::m_mem
ChunkMemoryHandler m_mem
Definition: MeshOctree.hpp:58
lvr2::MeshOctree
Definition: MeshOctree.hpp:34
lvr2::MeshOctree::genDisplayLists
void genDisplayLists()
Definition: MeshOctree.hpp:43
lvr2::MeshOctree::intersect
void intersect(double planes[24], std::vector< BaseVecT > &indices, std::vector< size_t > &hashes)
lvr2::MeshOctree::getBBoxes
void getBBoxes(const BoundingBox< BaseVecT > &bbox, BoundingBox< BaseVecT > *boxes)
lvr2::BoundingBox
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
lvr2::ChunkLeaf::m_hashes
std::vector< size_t > m_hashes
Definition: MeshOctree.hpp:27
lvr2::MeshOctree::getChildPtr
T * getChildPtr(BOct *parent)
lvr2::MeshOctree::getIndex
unsigned char getIndex(const BaseVecT &point, const BoundingBox< BaseVecT > &bbox)
lvr2::MeshOctree::MeshOctree
MeshOctree(float voxelSize, std::vector< size_t > &hashes, std::vector< BaseVecT > &centroids, BoundingBox< BaseVecT > &bb)
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::MeshOctree::setLOD
void setLOD(unsigned char lod)
Definition: MeshOctree.hpp:41
lvr2::MeshOctree::m_bbox
BoundingBox< BaseVecT > m_bbox
Definition: MeshOctree.hpp:50
BoundingBox.hpp
lvr2::MeshOctree::buildTree
long buildTree(BOct *oct, std::vector< size_t > &hashes, std::vector< BaseVecT > &centroids, const BoundingBox< BaseVecT > &bbox)
lvr2::ChunkLeaf
Definition: MeshOctree.hpp:24


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