iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCloud2PointSSE.H
Go to the documentation of this file.
1 //NRT_HEADER_BEGIN
2 /*! @file PointCloud2/PointCloud2PointSSE.H */
3 
4 // ////////////////////////////////////////////////////////////////////////
5 // The iLab Neuromorphic Robotics Toolkit (NRT) //
6 // Copyright 2010 by the University of Southern California (USC) and the //
7 // iLab at USC. //
8 // //
9 // iLab - University of Southern California //
10 // Hedco Neurociences Building, Room HNB-10 //
11 // Los Angeles, Ca 90089-2520 - USA //
12 // //
13 // See http://ilab.usc.edu for information about this project. //
14 // ////////////////////////////////////////////////////////////////////////
15 // This file is part of The iLab Neuromorphic Robotics Toolkit. //
16 // //
17 // The iLab Neuromorphic Robotics Toolkit is free software: you can //
18 // redistribute it and/or modify it under the terms of the GNU General //
19 // Public License as published by the Free Software Foundation, either //
20 // version 3 of the License, or (at your option) any later version. //
21 // //
22 // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
23 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
24 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
25 // PURPOSE. See the GNU General Public License for more details. //
26 // //
27 // You should have received a copy of the GNU General Public License //
28 // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
29 // <http://www.gnu.org/licenses/>. //
30 // ////////////////////////////////////////////////////////////////////////
31 //
32 // Primary maintainer for this file: Shane Grant <wgrant@usc.edu>
33 //
34 //NRT_HEADER_END
35 
36 #ifdef NRT_HAVE_CLOUD
37 #ifndef NRT_POINTCLOUD2_POINTCLOUD2POINTSSE_H_
38 #define NRT_POINTCLOUD2_POINTCLOUD2POINTSSE_H_
39 
40 #include <nrt/Eigen/Eigen.H>
42 
43 namespace nrt
44 {
45  //! An SSE capable point class for representing geometry
46  /*! This point contains four values, representing XYZ geometry
47  and a fourth buffer coordinate to support SSE alignment,
48  which can be considered to make the point homogenous. Note
49  that there is no special care taken to ensure that this fourth
50  coordinate remains valid, and in general will not be used aside
51  from providing a buffer for alignment.
52 
53  This point is defined with alignment requirements such that it can be
54  easily optimized using SSE techniques.
55 
56  @tparam T The underlying type to represent
57  @ingroup pointcloud */
58  template <class T>
59  class alignas(16) PointSSE : public Point<T, 4>
60  {
61  static_assert( std::is_floating_point<T>::value,
62  "Point cloud points must use floating point values!" );
63 
64  public:
65  typedef Eigen::Matrix<T, 3, 1> Vector3;
66  typedef Eigen::Matrix<T, 4, 1> Vector4;
67 
68  //! Construct a zero valued point with w set to 0
69  PointSSE();
70 
71  //! Constructs a point with all values set to value, optionally setting w
72  PointSSE( T value, T w = 0 );
73 
74  //! Construct a point by specifying the dimensions
75  PointSSE( T x, T y, T z, T w = 0 );
76 
77  //! Construct a point from an std::array (setting w to 1)
78  explicit PointSSE( std::array<T, 3> const & init );
79 
80  //! Construct a point from an std::array
81  explicit PointSSE( std::array<T, 4> const & init );
82 
83  //! Copy constructor
84  PointSSE( Point<T, 4> const & other );
85 
86  //! Copy constructor, sets W to 0
87  explicit PointSSE( Point<T, 3> const & other );
88 
89  //! Conversion copy constructor
90  template<class U>
91  explicit PointSSE( Point<U, 4> const & other );
92 
93  //! Conversion copy constructor, sets W to 0
94  template<class U>
95  explicit PointSSE( Point<U, 3> const & other );
96 
97  //! Access the first element
98  T & x();
99  //! Access the first element
100  T const & x() const;
101 
102  //! Access the second element
103  T & y();
104  //! Access the second element
105  T const & y() const;
106 
107  //! Access the third element
108  T & z();
109  //! Access the third element
110  T const & z() const;
111 
112  //! Access the fourth element
113  T & w();
114  //! Access the fourth element
115  T const & w() const;
116 
117  //! Checks whether this point is composed of only finite values
118  bool isValid() const;
119 
120  //! Return an eigen vector mapped to the internal contents of this point
121  Eigen::Map<Vector4, Eigen::Aligned>
122  getVectorMap();
123 
124  //! Return a const eigen vector mapped to the internal contents of this point
125  Eigen::Map<const Vector4, Eigen::Aligned>
126  getVectorMap() const;
127 
128  //! Return an eigen vector mapped to the internal contents of this point, ignoring the fourth component
129  Eigen::Map<Vector3, Eigen::Aligned>
130  getVector3Map();
131 
132  //! Return a const eigen vector mapped to the internal contents of this point, ignoring the fourth component
133  Eigen::Map<const Vector3, Eigen::Aligned>
134  getVector3Map() const;
135  };
136 } // namespace nrt
137 
138 // Implementation details
140 
141 #endif // NRT_POINTCLOUD2_POINTCLOUD2POINTSSE_H_
142 #endif // NRT_HAVE_CLOUD