geolib2
Octree.h
Go to the documentation of this file.
1 #ifndef GEOLIB_OCTREE_H_
2 #define GEOLIB_OCTREE_H_
3 
4 #include "datatypes.h"
5 #include "OctreeNode.h"
6 #include "Shape.h"
7 
8 #include <vector>
9 
10 namespace geo {
11 
12 class Octree : public Shape {
13 
14  friend class OctreeNode;
15 
16 public:
17 
18  Octree(double size, double resolution = 0.1);
19 
20  Octree(const Octree& orig);
21 
22  virtual Octree* clone() const;
23 
24  virtual ~Octree();
25 
26  void clear();
27 
28  void add(const Vector3& p);
29 
30  void getCubes(std::vector<Box>& cubes) const;
31 
32  double setResolution(double resolution);
33 
34  double getResolution() const;
35 
36  bool intersect(const Ray& r, float t0, float t1, double& distance) const;
37 
38  double getMaxRadius() const;
39 
40  void raytrace(const Ray& r, float t0, float t1);
41 
42  bool contains(const Vector3& p) const;
43 
44  bool intersect(const Box& b) const;
45 
46  const Mesh& getMesh() const;
47 
48 protected:
49 
50  double resolution_;
51 
53 
55 
56  double size_;
57 
59 
60  mutable Mesh mesh_;
61 
62 };
63 
64 }
65 
66 #endif
Shape.h
geo::OctreeNode
Definition: OctreeNode.h:12
geo::Octree::offset_
Vector3 offset_
Definition: Octree.h:52
geo::Octree::Octree
Octree(double size, double resolution=0.1)
Definition: Octree.cpp:6
geo::Octree::setResolution
double setResolution(double resolution)
Definition: Octree.cpp:38
geo
Definition: Box.h:6
vector
geo::Box
Definition: Box.h:15
geo::Octree::add
void add(const Vector3 &p)
Definition: Octree.cpp:29
geo::Octree::getMesh
const Mesh & getMesh() const
return the mesh defining the shape
Definition: Octree.cpp:110
datatypes.h
geo::Octree::getResolution
double getResolution() const
Definition: Octree.cpp:46
geo::Octree::raytrace
void raytrace(const Ray &r, float t0, float t1)
Definition: Octree.cpp:68
geo::Octree::getCubes
void getCubes(std::vector< Box > &cubes) const
Definition: Octree.cpp:34
geo::Octree::max_
Vector3 max_
Definition: Octree.h:54
geo::Ray
Definition: Ray.h:10
geo::Octree::intersect
bool intersect(const Ray &r, float t0, float t1, double &distance) const
intersect: currently always throws a logic error
Definition: Octree.cpp:50
geo::Vector3
Definition: matrix.h:12
geo::Octree::size_
double size_
Definition: Octree.h:56
geo::Octree::contains
bool contains(const Vector3 &p) const
Determines whether a point p lies within the shape.
Definition: Octree.cpp:85
geo::Octree
Definition: Octree.h:12
geo::Octree::clear
void clear()
Definition: Octree.cpp:23
geo::Octree::clone
virtual Octree * clone() const
Definition: Octree.cpp:19
OctreeNode.h
geo::Octree::~Octree
virtual ~Octree()
Definition: Octree.cpp:15
geo::Octree::getMaxRadius
double getMaxRadius() const
Calculate the maximum distance from the origin of the shape to any point of the shape.
Definition: Octree.cpp:64
geo::Octree::resolution_
double resolution_
Definition: Octree.h:50
geo::Mesh
Definition: Mesh.h:25
geo::Octree::root_
OctreeNode * root_
Definition: Octree.h:58
geo::Octree::mesh_
Mesh mesh_
Definition: Octree.h:60
geo::Shape
A geometric description of a shape.
Definition: Shape.h:19