Intersection.hpp
Go to the documentation of this file.
1 #ifndef LVR2_RAYCASTING_INTERSECTION_HPP
2 #define LVR2_RAYCASTING_INTERSECTION_HPP
3 
4 #include <string>
5 #include <sstream>
6 #include <tuple>
7 #include <type_traits>
8 #include <iostream>
10 
11 namespace lvr2 {
12 
13 // Intersect flags
14 // weird intersection construction
15 
16 namespace intelem {
17 
22 struct Point {
24 };
25 
30 struct Distance {
31  float dist;
32 };
33 
39 struct Normal {
41 };
42 
47 struct Face {
48  unsigned int face_id;
49 };
50 
65 struct Barycentrics {
67 };
68 
73 struct Mesh {
74  unsigned int mesh_id;
75 };
76 
77 } // namespace intelem
78 
102 template<typename ...Tp>
103 struct Intersection : public Tp...
104 {
105 public:
106  static constexpr std::size_t N = sizeof...(Tp);
107  using elems = std::tuple<Tp...>;
108 
109 private:
110  template <typename T, typename Tuple>
111  struct has_type;
112 
113  template <typename T>
114  struct has_type<T, std::tuple<>> : std::false_type {};
115 
116  template <typename T, typename U, typename... Ts>
117  struct has_type<T, std::tuple<U, Ts...>> : has_type<T, std::tuple<Ts...>> {};
118 
119 
120  template <typename T, typename... Ts>
121  struct has_type<T, std::tuple<T, Ts...>> : std::true_type {};
122 
123  template<typename F>
124  struct has_elem {
125  static constexpr bool value = has_type<F, elems>::type::value;
126  };
127 
128 public:
136  template<typename F>
137  static constexpr bool has() {
138  return has_elem<F>::value;
139  }
140 };
141 
142 // Common types
147 using AllInt = Intersection<
154 
155 } // namespace lvr2
156 
157 
158 template<typename ...T>
159 std::ostream& operator<<(std::ostream& os, const lvr2::Intersection<T...>& intersection)
160 {
161  using IntT = lvr2::Intersection<T...>;
162  os << "Raycaster Intersection: \n";
163 
164  if constexpr(IntT::template has<lvr2::intelem::Point>())
165  {
166  os << "-- point: " << intersection.point.transpose() << "\n";
167  }
168 
169  if constexpr(IntT::template has<lvr2::intelem::Distance>())
170  {
171  os << "-- dist: " << intersection.dist << "\n";
172  }
173 
174  if constexpr(IntT::template has<lvr2::intelem::Normal>())
175  {
176  os << "-- normal: " << intersection.normal.transpose() << "\n";
177  }
178 
179  if constexpr(IntT::template has<lvr2::intelem::Face>())
180  {
181  os << "-- face: " << intersection.face_id << "\n";
182  }
183 
184  if constexpr(IntT::template has<lvr2::intelem::Barycentrics>())
185  {
186  os << "-- barycentrics: " << intersection.b_uv.transpose() << "\n";
187  }
188 
189  if constexpr(IntT::template has<lvr2::intelem::Mesh>())
190  {
191  os << "-- mesh: " << intersection.mesh_id << "\n";
192  }
193 
194  return os;
195 }
196 
197 #endif // LVR2_RAYCASTING_INTERSECTION_HPP
lvr2::intelem::Face
Intersection face as uint id.
Definition: Intersection.hpp:47
lvr2::intelem::Point
Intersection point (x,y,z)
Definition: Intersection.hpp:22
lvr2::Vector2f
Eigen::Vector2f Vector2f
Eigen 2D vector, single precision.
Definition: MatrixTypes.hpp:141
lvr2::Intersection
CRTP Container for User defined intersection elements.
Definition: Intersection.hpp:103
lvr2::intelem::Barycentrics
Barycentric coordinates of the intersection point.
Definition: Intersection.hpp:65
lvr2::intelem::Distance::dist
float dist
Definition: Intersection.hpp:31
lvr2::intelem::Mesh
Receive the intersected Mesh. TODO.
Definition: Intersection.hpp:73
lvr2::intelem::Normal::normal
Vector3f normal
Definition: Intersection.hpp:40
lvr2::Intersection::elems
std::tuple< Tp... > elems
Definition: Intersection.hpp:107
lvr2::Intersection::has_type
Definition: Intersection.hpp:111
lvr2::intelem::Mesh::mesh_id
unsigned int mesh_id
Definition: Intersection.hpp:74
lvr2::intelem::Distance
Intersection distance(float)
Definition: Intersection.hpp:30
kfusion::device::Normal
float4 Normal
Definition: internal.hpp:13
lvr2::intelem::Barycentrics::b_uv
Vector2f b_uv
Definition: Intersection.hpp:66
lvr2::Intersection::has
static constexpr bool has()
Check if Intersection container has a specific intelem (lvr2::intelem).
Definition: Intersection.hpp:137
lvr2::intelem::Point::point
Vector3f point
Definition: Intersection.hpp:23
operator<<
std::ostream & operator<<(std::ostream &os, const lvr2::Intersection< T... > &intersection)
Definition: Intersection.hpp:159
lvr2::Vector3f
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
Definition: MatrixTypes.hpp:118
MatrixTypes.hpp
kfusion::device::Point
float4 Point
Definition: internal.hpp:14
lvr2::intelem::Face::face_id
unsigned int face_id
Definition: Intersection.hpp:48
std
Definition: HalfEdge.hpp:124
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Intersection::has_elem
Definition: Intersection.hpp:124
lvr2::intelem::Normal
Raycaster should compute the normal of the intersected face flipped towards the ray.
Definition: Intersection.hpp:39
lvr2::Intersection::has_elem::value
static constexpr bool value
Definition: Intersection.hpp:125
lvr2::Intersection::N
static constexpr std::size_t N
Definition: Intersection.hpp:106


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