45 #include <pcl/point_types.h>
46 #include <pcl/memory.h>
47 #include <pcl/pcl_macros.h>
48 #include <pcl/for_each_type.h>
58 template <
typename Po
intT>
78 using Ptr = shared_ptr<PointRepresentation<PointT> >;
79 using ConstPtr = shared_ptr<const PointRepresentation<PointT> >;
98 inline bool isTrivial()
const {
return trivial_ && alpha_.empty (); }
106 bool is_valid =
true;
110 const float* temp =
reinterpret_cast<const float*
>(&p);
114 if (!std::isfinite (temp[i]))
128 if (!std::isfinite (temp[i]))
143 template <
typename OutputType>
void
156 out[i] = temp[i] * alpha_[i];
165 if (!alpha_.empty ())
174 if (!alpha_.empty ())
185 alpha_.resize (nr_dimensions_);
186 std::copy(rescale_array, rescale_array + nr_dimensions_, alpha_.begin());
196 template <
typename Po
intDefault>
204 using Ptr = shared_ptr<DefaultPointRepresentation<PointDefault> >;
205 using ConstPtr = shared_ptr<const DefaultPointRepresentation<PointDefault> >;
229 const float* ptr =
reinterpret_cast<const float*
> (&p);
238 template <
typename Po
intDefault>
245 struct IncrementFunctor
247 IncrementFunctor (
int &n) : n_ (n)
252 template<
typename Key>
inline void operator () ()
254 n_ += pcl::traits::datatype<PointDefault, Key>::size;
261 struct NdCopyPointFunctor
263 using Pod =
typename traits::POD<PointDefault>::type;
265 NdCopyPointFunctor (
const PointDefault &p1,
float * p2)
266 : p1_ (reinterpret_cast<const Pod&>(p1)), p2_ (p2) {}
268 template<
typename Key>
inline void operator() ()
270 using FieldT =
typename pcl::traits::datatype<PointDefault, Key>::type;
271 constexpr
int NrDims = pcl::traits::datatype<PointDefault, Key>::size;
276 template <
typename Key,
typename FieldT,
int NrDims>
279 static void copyPoint (
const Pod &p1,
float * p2,
int &f_idx)
281 const std::uint8_t * data_ptr =
reinterpret_cast<const std::uint8_t *
> (&p1) +
282 pcl::traits::offset<PointDefault, Key>::value;
283 p2[f_idx++] = *
reinterpret_cast<const FieldT*
> (data_ptr);
287 template <
typename Key,
typename FieldT,
int NrDims>
288 struct Helper<Key, FieldT[NrDims], NrDims>
290 static void copyPoint (
const Pod &p1,
float * p2,
int &f_idx)
292 const std::uint8_t * data_ptr =
reinterpret_cast<const std::uint8_t *
> (&p1) +
293 pcl::traits::offset<PointDefault, Key>::value;
294 int nr_dims = NrDims;
295 const FieldT * array =
reinterpret_cast<const FieldT *
> (data_ptr);
296 for (
int i = 0; i < nr_dims; ++i)
298 p2[f_idx++] = array[i];
311 using Ptr = shared_ptr<DefaultFeatureRepresentation<PointDefault>>;
312 using ConstPtr = shared_ptr<const DefaultFeatureRepresentation<PointDefault>>;
313 using FieldList =
typename pcl::traits::fieldList<PointDefault>::type;
318 pcl::for_each_type <FieldList> (IncrementFunctor (
nr_dimensions_));
330 pcl::for_each_type <FieldList> (NdCopyPointFunctor (p, out));
550 template <
typename Po
intDefault>
557 using Ptr = shared_ptr<CustomPointRepresentation<PointDefault> >;
558 using ConstPtr = shared_ptr<const CustomPointRepresentation<PointDefault> >;
588 const float *ptr = (
reinterpret_cast<const float*
> (&p)) +
start_dim_;
DefaultPointRepresentation()
DefaultPointRepresentation()
void copyToFloatArray(const PointNormal &p, float *out) const override
Copy point data from input point to a float array.
DefaultPointRepresentation()
A point structure representing a Shape Context.
shared_ptr< DefaultPointRepresentation< PointDefault > > Ptr
bool isTrivial() const
Returns whether this point representation is trivial.
A point structure representing the Normal Based Signature for a feature matrix of 4-by-3...
A point structure representing a Unique Shape Context.
DefaultPointRepresentation()
void copyToFloatArray(const PointDefault &p, float *out) const override
Copy the point data into a float array.
CustomPointRepresentation(const int max_dim=3, const int start_dim=0)
Constructor.
virtual bool isValid(const PointT &p) const
Verify that the input point is valid.
void copyToFloatArray(const PointDefault &p, float *out) const override
Copy point data from input point to a float array.
shared_ptr< const DefaultPointRepresentation< PointDefault > > ConstPtr
void copyToFloatArray(const PPFSignature &p, float *out) const override
Copy point data from input point to a float array.
A point structure representing the Fast Point Feature Histogram (FPFH).
int max_dim_
Use at most this many dimensions (i.e.
DefaultFeatureRepresentation()
PointRepresentation provides a set of methods for converting a point structs/object into an n-dimensi...
shared_ptr< DefaultFeatureRepresentation< PointDefault >> Ptr
CustomPointRepresentation extends PointRepresentation to allow for sub-part selection on the point...
A point structure representing the Point Feature Histogram with colors (PFHRGB).
int start_dim_
Use dimensions only starting with this one (i.e.
int nr_dimensions_
The number of dimensions in this point's vector (i.e.
void vectorize(const PointT &p, std::vector< float > &out) const
shared_ptr< const PointRepresentation< Narf * > > ConstPtr
shared_ptr< CustomPointRepresentation< PointDefault > > Ptr
A point structure representing Euclidean xyz coordinates.
void copyToFloatArray(const PointDefault &p, float *out) const override
Copy point data from input point to a float array.
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape and color descr...
virtual ~PointRepresentation()=default
Empty destructor.
DefaultPointRepresentation()
DefaultPointRepresentation()
static void copyPoint(const Pod &p1, float *p2, int &f_idx)
void vectorize(const PointT &p, OutputType &out) const
Convert input point into a vector representation, rescaling by alpha.
A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape onl...
std::vector< float > alpha_
A vector containing the rescale factor to apply to each dimension.
bool trivial_
Indicates whether this point representation is trivial.
static void copyPoint(const Pod &p1, float *p2, int &f_idx)
void copyToFloatArray(const Narf36 &p, float *out) const override
Copy point data from input point to a float array.
A point structure representing Euclidean xyz coordinates, together with normal coordinates and the su...
DefaultPointRepresentation()
void copyToFloatArray(const PointXYZI &p, float *out) const override
Copy point data from input point to a float array.
void copyToFloatArray(const SHOT1344 &p, float *out) const override
Copy point data from input point to a float array.
DefaultPointRepresentation()
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape and color descr...
DefaultPointRepresentation extends PointRepresentation to define default behavior for common point ty...
virtual void copyToFloatArray(const PointT &p, float *out) const =0
Copy point data from input point to a float array.
DefaulFeatureRepresentation extends PointRepresentation and is intended to be used when defining the ...
void copyToFloatArray(const UniqueShapeContext1960 &p, float *out) const override
Copy point data from input point to a float array.
shared_ptr< const CustomPointRepresentation< PointDefault > > ConstPtr
A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape+col...
int getNumberOfDimensions() const
Return the number of dimensions in the point's vector representation.
void copyToFloatArray(const PointXYZ &p, float *out) const override
Copy point data from input point to a float array.
A point structure representing the Viewpoint Feature Histogram (VFH).
void copyToFloatArray(const ShapeContext1980 &p, float *out) const override
Copy point data from input point to a float array.
A point structure representing the Narf descriptor.
A point structure representing Euclidean xyz coordinates, and the RGB color.
A point structure representing the Point Feature Histogram (PFH).
void setRescaleValues(const float *rescale_array)
Set the rescale values to use when vectorizing points.
shared_ptr< PointRepresentation< Narf * > > Ptr
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape descriptor...
DefaultPointRepresentation()
DefaultPointRepresentation()
~DefaultPointRepresentation() override=default
void copyToFloatArray(const SHOT352 &p, float *out) const override
Copy point data from input point to a float array.
A point structure for storing the Point Pair Feature (PPF) values.
typename pcl::traits::fieldList< PFHSignature125 >::type FieldList
void vectorize(const PointT &p, float *out) const