RegionOfInterest.h
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
7 #ifndef NUKLEI_REGIONOFINTEREST_H
8 #define NUKLEI_REGIONOFINTEREST_H
9 
10 
11 #include <nuklei/Definitions.h>
12 #include <nuklei/LinearAlgebra.h>
13 #include <nuklei/GenericKernel.h>
14 #include <boost/any.hpp>
15 
16 namespace nuklei {
17 
19  {
20  public:
21  RegionOfInterest(bool positive = true) : positive_(positive) {}
22 
23  virtual ~RegionOfInterest() {}
24 
25  bool contains(const Vector3 &v) const
26  {
27  return (positive_ == contains_(v)) || (next_ && next_->contains(v));
28  }
29 
30  virtual void enqueue(boost::shared_ptr<RegionOfInterest> &roi)
31  {
32  if (next_)
33  next_->enqueue(roi);
34  else
35  next_ = roi;
36  }
37 
38  virtual void setSign(bool positive)
39  {
40  positive_ = positive;
41  }
42 
43  void buildAABBTree()
44  {
45  buildAABBTree_();
46  }
47 
48  void pushTriangles(std::list<boost::any>& triangles) const
49  {
50  if (next_)
51  next_->pushTriangles(triangles);
52  pushTriangles_(triangles);
53  }
54 
55  virtual bool intersectsPlane(const Vector3& p,
56  const Vector3& q,
57  const Vector3& r) const
58  { NUKLEI_THROW("Not implemented"); }
59  virtual bool intersectsPlane(const Vector3& p, const Vector3& v) const
60  { NUKLEI_THROW("Not implemented"); }
61 
62  protected:
63  virtual bool contains_(const Vector3 &v) const = 0;
64  virtual void buildAABBTree_()
65  { NUKLEI_THROW("Not implemented"); }
66  virtual void pushTriangles_(std::list<boost::any>& triangles) const
67  { NUKLEI_THROW("Not implemented"); }
68  bool positive_;
69  private:
70  boost::shared_ptr<RegionOfInterest> next_;
71  };
72 
73 
74  class SphereROI : public RegionOfInterest
75  {
76  public:
77  SphereROI(const Vector3 &center, double radius) :
78  center_(center), radius_(radius) {}
79 
80  SphereROI(const std::string &centerAndRadius);
81 
82  ~SphereROI() {}
83  protected:
84  bool contains_(const Vector3 &v) const;
85  private:
86  Vector3 center_;
87  double radius_;
88  };
89 
90  class BoxROI : public RegionOfInterest
91  {
92  public:
93  BoxROI(const Vector3 &centerLoc, const Quaternion &centerOri,
94  const Vector3 &edgeLengths) :
95  centerLoc_(centerLoc), centerOri_(centerOri), edgeLengths_(edgeLengths) {}
96 
97  BoxROI(const std::string &s);
98 
99  void setCenterOriSize(const std::string &centerSize);
100  void setCenterAxesSize(const std::string &centerSize);
101 
102  virtual bool intersectsPlane(const Vector3& p,
103  const Vector3& q,
104  const Vector3& r) const;
105  virtual bool intersectsPlane(const Vector3& p, const Vector3& v) const;
106 
107  ~BoxROI() {}
108  protected:
109  bool contains_(const Vector3 &v) const;
110  void buildAABBTree_();
111  void pushTriangles_(std::list<boost::any>& triangles) const;
112  private:
113  Vector3 centerLoc_;
114  Quaternion centerOri_;
115  Vector3 edgeLengths_;
116  boost::any tree_;
117  };
118 
119 }
120 
121 #endif
122 
Public namespace.
Definition: Color.cpp:9
#define NUKLEI_THROW(x)
Throws an Error.
Definition: Common.h:94
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.