Skip to content

SAC Models Refactoring: getClassName() #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sample_consensus/include/pcl/sample_consensus/sac_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ namespace pcl
virtual SacModel
getModelType () const = 0;

/** \brief Get a string representation of the name of this class. */
inline const std::string&
getClassName () const
{
return (model_name_);
}

/** \brief Return the size of a sample from which a model is computed */
inline unsigned int
getSampleSize () const
Expand Down Expand Up @@ -434,7 +441,7 @@ namespace pcl
return (computeVariance (error_sqr_dists_));
}

protected:
protected:
/** \brief Fills a sample array with random samples from the indices_ vector
* \param[out] sample the set of indices of target_ to analyze
*/
Expand Down Expand Up @@ -505,6 +512,9 @@ namespace pcl
virtual bool
isSampleGood (const std::vector<int> &samples) const = 0;

/** \brief The model name. */
std::string model_name_;

/** \brief A boost shared pointer to the point cloud data array. */
PointCloudConstPtr input_;

Expand Down Expand Up @@ -629,7 +639,7 @@ namespace pcl
typedef Eigen::Matrix<Scalar,InputsAtCompileTime,1> InputType;
typedef Eigen::Matrix<Scalar,ValuesAtCompileTime,InputsAtCompileTime> JacobianType;

/** \brief Empty Construtor. */
/** \brief Empty Constructor. */
Functor () : m_data_points_ (ValuesAtCompileTime) {}

/** \brief Constructor
Expand Down
12 changes: 9 additions & 3 deletions sample_consensus/include/pcl/sample_consensus/sac_model_circle.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace pcl
class SampleConsensusModelCircle2D : public SampleConsensusModel<PointT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::radius_min_;
Expand All @@ -78,7 +79,9 @@ namespace pcl
*/
SampleConsensusModelCircle2D (const PointCloudConstPtr &cloud, bool random = false)
: SampleConsensusModel<PointT> (cloud, random), tmp_inliers_ ()
{};
{
model_name_ = "SampleConsensusModelCircle2D";
}

/** \brief Constructor for base SampleConsensusModelCircle2D.
* \param[in] cloud the input point cloud dataset
Expand All @@ -89,7 +92,9 @@ namespace pcl
const std::vector<int> &indices,
bool random = false)
: SampleConsensusModel<PointT> (cloud, indices, random), tmp_inliers_ ()
{};
{
model_name_ = "SampleConsensusModelCircle2D";
}

/** \brief Copy constructor.
* \param[in] source the model to copy into this
Expand All @@ -98,6 +103,7 @@ namespace pcl
SampleConsensusModel<PointT> (), tmp_inliers_ ()
{
*this = source;
model_name_ = "SampleConsensusModelCircle2D";
}

/** \brief Empty destructor */
Expand Down Expand Up @@ -152,7 +158,7 @@ namespace pcl
const double threshold);

/** \brief Recompute the 2d circle coefficients using the given inlier set and return them to the user.
* @note: these are the coefficients of the 2d circle model after refinement (eg. after SVD)
* @note: these are the coefficients of the 2d circle model after refinement (e.g. after SVD)
* \param[in] inliers the data inliers found as supporting the model
* \param[in] model_coefficients the initial guess for the optimization
* \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
Expand Down
14 changes: 11 additions & 3 deletions sample_consensus/include/pcl/sample_consensus/sac_model_circle3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace pcl
class SampleConsensusModelCircle3D : public SampleConsensusModel<PointT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::radius_min_;
Expand All @@ -79,7 +80,10 @@ namespace pcl
*/
SampleConsensusModelCircle3D (const PointCloudConstPtr &cloud,
bool random = false)
: SampleConsensusModel<PointT> (cloud, random) {};
: SampleConsensusModel<PointT> (cloud, random)
{
model_name_ = "SampleConsensusModelCircle3D";
}

/** \brief Constructor for base SampleConsensusModelCircle3D.
* \param[in] cloud the input point cloud dataset
Expand All @@ -89,7 +93,10 @@ namespace pcl
SampleConsensusModelCircle3D (const PointCloudConstPtr &cloud,
const std::vector<int> &indices,
bool random = false)
: SampleConsensusModel<PointT> (cloud, indices, random) {};
: SampleConsensusModel<PointT> (cloud, indices, random)
{
model_name_ = "SampleConsensusModelCircle3D";
}

/** \brief Empty destructor */
virtual ~SampleConsensusModelCircle3D () {}
Expand All @@ -101,6 +108,7 @@ namespace pcl
SampleConsensusModel<PointT> (), tmp_inliers_ ()
{
*this = source;
model_name_ = "SampleConsensusModelCircle3D";
}

/** \brief Copy constructor.
Expand Down Expand Up @@ -152,7 +160,7 @@ namespace pcl
const double threshold);

/** \brief Recompute the 3d circle coefficients using the given inlier set and return them to the user.
* @note: these are the coefficients of the 3d circle model after refinement (eg. after SVD)
* @note: these are the coefficients of the 3d circle model after refinement (e.g. after SVD)
* \param[in] inliers the data inliers found as supporting the model
* \param[in] model_coefficients the initial guess for the optimization
* \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
Expand Down
22 changes: 14 additions & 8 deletions sample_consensus/include/pcl/sample_consensus/sac_model_cone.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <pcl/sample_consensus/sac_model.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/pcl_macros.h>
#include <pcl/common/common.h>
#include <pcl/common/distances.h>
#include <limits.h>
Expand All @@ -65,6 +66,7 @@ namespace pcl
class SampleConsensusModelCone : public SampleConsensusModel<PointT>, public SampleConsensusModelFromNormals<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::radius_min_;
Expand Down Expand Up @@ -92,6 +94,7 @@ namespace pcl
, max_angle_ (std::numeric_limits<double>::max ())
, tmp_inliers_ ()
{
model_name_ = "SampleConsensusModelCone";
}

/** \brief Constructor for base SampleConsensusModelCone.
Expand All @@ -110,6 +113,7 @@ namespace pcl
, max_angle_ (std::numeric_limits<double>::max ())
, tmp_inliers_ ()
{
model_name_ = "SampleConsensusModelCone";
}

/** \brief Copy constructor.
Expand All @@ -121,6 +125,7 @@ namespace pcl
axis_ (), eps_angle_ (), min_angle_ (), max_angle_ (), tmp_inliers_ ()
{
*this = source;
model_name_ = "SampleConsensusModelCone";
}

/** \brief Empty destructor */
Expand Down Expand Up @@ -163,8 +168,8 @@ namespace pcl

/** \brief Set the minimum and maximum allowable opening angle for a cone model
* given from a user.
* \param[in] min_angle the minimum allwoable opening angle of a cone model
* \param[in] max_angle the maximum allwoable opening angle of a cone model
* \param[in] min_angle the minimum allowable opening angle of a cone model
* \param[in] max_angle the maximum allowable opening angle of a cone model
*/
inline void
setMinMaxOpeningAngle (const double &min_angle, const double &max_angle)
Expand All @@ -173,9 +178,9 @@ namespace pcl
max_angle_ = max_angle;
}

/** \brief Get the opening angle which we need minumum to validate a cone model.
* \param[out] min_angle the minimum allwoable opening angle of a cone model
* \param[out] max_angle the maximum allwoable opening angle of a cone model
/** \brief Get the opening angle which we need minimum to validate a cone model.
* \param[out] min_angle the minimum allowable opening angle of a cone model
* \param[out] max_angle the maximum allowable opening angle of a cone model
*/
inline void
getMinMaxOpeningAngle (double &min_angle, double &max_angle) const
Expand Down Expand Up @@ -224,7 +229,7 @@ namespace pcl


/** \brief Recompute the cone coefficients using the given inlier set and return them to the user.
* @note: these are the coefficients of the cone model after refinement (eg. after SVD)
* @note: these are the coefficients of the cone model after refinement (e.g. after SVD)
* \param[in] inliers the data inliers found as supporting the model
* \param[in] model_coefficients the initial guess for the optimization
* \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
Expand Down Expand Up @@ -270,8 +275,9 @@ namespace pcl
pointToAxisDistance (const Eigen::Vector4f &pt, const Eigen::VectorXf &model_coefficients);

/** \brief Get a string representation of the name of this class. */
std::string
getName () const { return ("SampleConsensusModelCone"); }
PCL_DEPRECATED ("[pcl::SampleConsensusModelCone::getName] getName is deprecated. Please use getClassName instead.")
std::string
getName () const { return (model_name_); }

protected:
/** \brief Check whether a model is valid given the user constraints.
Expand Down
14 changes: 10 additions & 4 deletions sample_consensus/include/pcl/sample_consensus/sac_model_cylinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <pcl/sample_consensus/sac_model.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/pcl_macros.h>
#include <pcl/common/common.h>
#include <pcl/common/distances.h>

Expand All @@ -65,6 +66,7 @@ namespace pcl
class SampleConsensusModelCylinder : public SampleConsensusModel<PointT>, public SampleConsensusModelFromNormals<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::radius_min_;
Expand All @@ -90,6 +92,7 @@ namespace pcl
, eps_angle_ (0)
, tmp_inliers_ ()
{
model_name_ = "SampleConsensusModelCylinder";
}

/** \brief Constructor for base SampleConsensusModelCylinder.
Expand All @@ -106,6 +109,7 @@ namespace pcl
, eps_angle_ (0)
, tmp_inliers_ ()
{
model_name_ = "SampleConsensusModelCylinder";
}

/** \brief Copy constructor.
Expand All @@ -119,6 +123,7 @@ namespace pcl
tmp_inliers_ ()
{
*this = source;
model_name_ = "SampleConsensusModelCylinder";
}

/** \brief Empty destructor */
Expand All @@ -138,7 +143,7 @@ namespace pcl
}

/** \brief Set the angle epsilon (delta) threshold.
* \param[in] ea the maximum allowed difference between the cyilinder axis and the given axis.
* \param[in] ea the maximum allowed difference between the cylinder axis and the given axis.
*/
inline void
setEpsAngle (const double ea) { eps_angle_ = ea; }
Expand Down Expand Up @@ -196,7 +201,7 @@ namespace pcl
const double threshold);

/** \brief Recompute the cylinder coefficients using the given inlier set and return them to the user.
* @note: these are the coefficients of the cylinder model after refinement (eg. after SVD)
* @note: these are the coefficients of the cylinder model after refinement (e.g. after SVD)
* \param[in] inliers the data inliers found as supporting the model
* \param[in] model_coefficients the initial guess for the optimization
* \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
Expand Down Expand Up @@ -270,8 +275,9 @@ namespace pcl
Eigen::Vector4f &pt_proj);

/** \brief Get a string representation of the name of this class. */
std::string
getName () const { return ("SampleConsensusModelCylinder"); }
PCL_DEPRECATED ("[pcl::SampleConsensusModelCylinder::getName] getName is deprecated. Please use getClassName instead.")
std::string
getName () const { return (model_name_); }

protected:
/** \brief Check whether a model is valid given the user constraints.
Expand Down
13 changes: 10 additions & 3 deletions sample_consensus/include/pcl/sample_consensus/sac_model_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace pcl
class SampleConsensusModelLine : public SampleConsensusModel<PointT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModel<PointT>::error_sqr_dists_;
Expand All @@ -78,7 +79,10 @@ namespace pcl
* \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
*/
SampleConsensusModelLine (const PointCloudConstPtr &cloud, bool random = false)
: SampleConsensusModel<PointT> (cloud, random) {};
: SampleConsensusModel<PointT> (cloud, random)
{
model_name_ = "SampleConsensusModelLine";
}

/** \brief Constructor for base SampleConsensusModelLine.
* \param[in] cloud the input point cloud dataset
Expand All @@ -88,7 +92,10 @@ namespace pcl
SampleConsensusModelLine (const PointCloudConstPtr &cloud,
const std::vector<int> &indices,
bool random = false)
: SampleConsensusModel<PointT> (cloud, indices, random) {};
: SampleConsensusModel<PointT> (cloud, indices, random)
{
model_name_ = "SampleConsensusModelLine";
}

/** \brief Empty destructor */
virtual ~SampleConsensusModelLine () {}
Expand Down Expand Up @@ -132,7 +139,7 @@ namespace pcl
const double threshold);

/** \brief Recompute the line coefficients using the given inlier set and return them to the user.
* @note: these are the coefficients of the line model after refinement (eg. after SVD)
* @note: these are the coefficients of the line model after refinement (e.g. after SVD)
* \param[in] inliers the data inliers found as supporting the model
* \param[in] model_coefficients the initial guess for the model coefficients
* \param[out] optimized_coefficients the resultant recomputed coefficients after optimization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace pcl
class SampleConsensusModelNormalParallelPlane : public SampleConsensusModelNormalPlane<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normals_;
Expand Down Expand Up @@ -112,6 +113,7 @@ namespace pcl
, cos_angle_ (-1.0)
, eps_dist_ (0.0)
{
model_name_ = "SampleConsensusModelNormalParallelPlane";
}

/** \brief Constructor for base SampleConsensusModelNormalParallelPlane.
Expand All @@ -129,6 +131,7 @@ namespace pcl
, cos_angle_ (-1.0)
, eps_dist_ (0.0)
{
model_name_ = "SampleConsensusModelNormalParallelPlane";
}

/** \brief Empty destructor */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace pcl
class SampleConsensusModelNormalPlane : public SampleConsensusModelPlane<PointT>, public SampleConsensusModelFromNormals<PointT, PointNT>
{
public:
using SampleConsensusModel<PointT>::model_name_;
using SampleConsensusModel<PointT>::input_;
using SampleConsensusModel<PointT>::indices_;
using SampleConsensusModelFromNormals<PointT, PointNT>::normals_;
Expand All @@ -101,6 +102,7 @@ namespace pcl
: SampleConsensusModelPlane<PointT> (cloud, random)
, SampleConsensusModelFromNormals<PointT, PointNT> ()
{
model_name_ = "SampleConsensusModelNormalPlane";
}

/** \brief Constructor for base SampleConsensusModelNormalPlane.
Expand All @@ -114,6 +116,7 @@ namespace pcl
: SampleConsensusModelPlane<PointT> (cloud, indices, random)
, SampleConsensusModelFromNormals<PointT, PointNT> ()
{
model_name_ = "SampleConsensusModelNormalPlane";
}

/** \brief Empty destructor */
Expand Down
Loading