The spica renderer
bounds3d.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_BOUND3D_H_
6 #define _SPICA_BOUND3D_H_
7 
8 #include <type_traits>
9 
10 #include "point3d.h"
11 #include "ray.h"
12 
13 namespace spica {
14 
15 template <class T>
16 class Bounds3_ {
17 public:
18  // Public methods
19  Bounds3_();
20  Bounds3_(const Point3_<T>& posMin, const Point3_<T>& posMax);
21  Bounds3_(const Bounds3_<T>& b);
22 
23  virtual ~Bounds3_();
24 
25  Bounds3_<T>& operator=(const Bounds3_<T>& b);
26  bool operator==(const Bounds3_<T>& b) const;
27  bool operator!=(const Bounds3_<T>& b) const;
28 
30  int maximumExtent() const;
31 
33  bool intersect(const Ray& ray, double* tNear = nullptr,
34  double* tFar = nullptr) const;
35 
36  //** Merge two bounds. */
37  static Bounds3_<T> merge(const Bounds3_<T>& b1, const Bounds3_<T>& b2);
38 
39  void merge(const Bounds3_<T>& b);
40  void merge(const Point3_<T>& p);
41  bool inside(const Point3_<T>& p) const;
42 
43  T area() const;
44 
45  inline Point3_<T> posMin() const { return posMin_; }
46  inline Point3_<T> posMax() const { return posMax_; }
47 
48 private:
49  // Private fields
50  Point3_<T> posMin_;
51  Point3_<T> posMax_;
52 
53  static_assert(std::is_arithmetic<T>::value,
54  "Template type must be arithmetic!!");
55 };
56 
57 using Bounds3i = Bounds3_<int>;
60 
61 } // namespace spica
62 
63 #include "bounds3d_detail.h"
64 
65 #endif // _SPICA_BOUND3D_H_
bool intersect(const Ray &ray, double *tNear=nullptr, double *tFar=nullptr) const
Intersection test.
Definition: bounds3d_detail.h:64
int maximumExtent() const
Maximum extent: return 0 -> x, 1 -> y, 2 -> z.
Definition: bounds3d_detail.h:56
Ray class.
Definition: ray.h:24
Definition: bounds3d.h:16
Definition: core.hpp:68