48#include "simple_octree.h"
49#include "model_library.h"
50#include <pcl/pcl_exports.h>
107 if ( rigid_transform )
146 inline std::map<const ModelLibrary::Model*,Entry>&
158 return (&res->second);
166 return model_to_entry_[model].addRigidTransform (axis_angle, translation);
200 float min = -(AUX_PI_FLOAT + 0.000000001f), max = AUX_PI_FLOAT + 0.000000001f;
201 float bounds[6] = {min, max, min, max, min, max};
227 const std::vector<CellOctree::Node*>& full_leaves =
octree_.getFullLeaves ();
228 int max_num_transforms = 0;
231 for (
const auto &full_leaf : full_leaves)
239 const std::set<CellOctree::Node*>& neighs = full_leaf->getNeighbors ();
242 for (
const auto &neigh : neighs)
251 if ( num_transforms > max_num_transforms )
253 with_most_votes = *entry;
254 max_num_transforms = num_transforms;
258 if ( !max_num_transforms )
269 CellOctree::Node* cell =
octree_.createLeaf (axis_angle[0], axis_angle[1], axis_angle[2]);
273 const float *b =
octree_.getBounds ();
274 printf (
"WARNING in 'RotationSpace::%s()': the provided axis-angle input (%f, %f, %f) is "
275 "out of the rotation space bounds ([%f, %f], [%f, %f], [%f, %f]).\n",
276 __func__, axis_angle[0], axis_angle[1], axis_angle[2], b[0], b[1], b[2], b[3], b[4], b[5]);
302 rot_space->setCenter (leaf->
getCenter ());
316 const std::list<RotationSpace*>&
319 std::list<RotationSpace*>&
344 build (
const float* pos_bounds,
float translation_cell_size,
float rotation_cell_size)
360 inline std::list<RotationSpace*>&
366 inline const std::list<RotationSpace*>&
382 RotationSpaceOctree::Node* leaf =
pos_octree_.createLeaf (position[0], position[1], position[2]);
386 printf (
"WARNING in 'RigidTransformSpace::%s()': the input position (%f, %f, %f) is out of bounds.\n",
387 __func__, position[0], position[1], position[2]);
391 float rot_angle, axis_angle[3];
Stores some information about the model.
const float * getAxisAngle() const
const Entry & operator=(const Entry &src)
int getNumberOfTransforms() const
const float * getTranslation() const
const Entry & addRigidTransform(const float axis_angle[3], const float translation[3])
void computeAverageRigidTransform(float *rigid_transform=nullptr)
virtual ~RotationSpaceCellCreator()=default
RotationSpaceCell * create(const SimpleOctree< RotationSpaceCell, RotationSpaceCellCreator, float >::Node *)
RotationSpaceCellCreator()=default
const RotationSpaceCell::Entry & addRigidTransform(const ModelLibrary::Model *model, const float axis_angle[3], const float translation[3])
const RotationSpaceCell::Entry * getEntry(const ModelLibrary::Model *model) const
std::map< const ModelLibrary::Model *, Entry > model_to_entry_
std::map< const ModelLibrary::Model *, Entry > & getEntries()
virtual ~RotationSpaceCell()
RotationSpaceCell()=default
RotationSpace * create(const SimpleOctree< RotationSpace, RotationSpaceCreator, float >::Node *leaf)
RotationSpaceCreator()=default
std::list< RotationSpace * > rotation_spaces_
const std::list< RotationSpace * > & getRotationSpaces() const
void setDiscretization(float value)
int getNumberOfRotationSpaces() const
virtual ~RotationSpaceCreator()=default
std::list< RotationSpace * > & getRotationSpaces()
This is a class for a discrete representation of the rotation space based on the axis-angle represent...
void setCenter(const float *c)
const float * getCenter() const
bool addRigidTransform(const ModelLibrary::Model *model, const float axis_angle[3], const float translation[3])
bool getTransformWithMostVotes(const ModelLibrary::Model *model, float rigid_transform[12]) const
RotationSpace(float discretization)
We use the axis-angle representation for rotations.
RotationSpaceCellCreator cell_creator_
const Scalar * getCenter() const
void axisAngleToRotationMatrix(const T axis_angle[3], T rotation_matrix[9])
brief Computes a rotation matrix from the provided input vector 'axis_angle'.
void mult3(T *v, T scalar)
v = scalar*v.
void add3(T a[3], const T b[3])
a += b
void set3(T v[3], T value)
v[0] = v[1] = v[2] = value
void copy3(const T src[3], T dst[3])
dst = src
void rotationMatrixToAxisAngle(const T rotation_matrix[9], T axis[3], T &angle)
brief Extracts the angle-axis representation from 'rotation_matrix', i.e., computes a rotation 'axis'...
SimpleOctree< RotationSpaceCell, RotationSpaceCellCreator, float > CellOctree
SimpleOctree< RotationSpace, RotationSpaceCreator, float > RotationSpaceOctree