mirror of https://github.com/CGAL/cgal
Simplify API (no more templates) of Local_eigen_analysis
This commit is contained in:
parent
6021b9386e
commit
a981d14cd0
|
|
@ -23,18 +23,18 @@ typedef Classif::Sum_of_weighted_features_predicate Classification_predicate;
|
|||
|
||||
typedef Classif::Planimetric_grid<Kernel, Point_range, Pmap> Planimetric_grid;
|
||||
typedef Classif::Point_set_neighborhood<Kernel, Point_range, Pmap> Neighborhood;
|
||||
typedef Classif::Local_eigen_analysis<Kernel, Point_range, Pmap> Local_eigen_analysis;
|
||||
typedef Classif::Local_eigen_analysis Local_eigen_analysis;
|
||||
|
||||
typedef Classif::Label_handle Label_handle;
|
||||
typedef Classif::Feature_handle Feature_handle;
|
||||
typedef Classif::Label_set Label_set;
|
||||
typedef Classif::Feature_set Feature_set;
|
||||
|
||||
typedef Classif::Feature::Distance_to_plane<Kernel, Point_range, Pmap> Distance_to_plane;
|
||||
typedef Classif::Feature::Linearity<Kernel, Point_range, Pmap> Linearity;
|
||||
typedef Classif::Feature::Omnivariance<Kernel, Point_range, Pmap> Omnivariance;
|
||||
typedef Classif::Feature::Planarity<Kernel, Point_range, Pmap> Planarity;
|
||||
typedef Classif::Feature::Surface_variation<Kernel, Point_range, Pmap> Surface_variation;
|
||||
typedef Classif::Feature::Distance_to_plane<Point_range, Pmap> Distance_to_plane;
|
||||
typedef Classif::Feature::Linearity Linearity;
|
||||
typedef Classif::Feature::Omnivariance Omnivariance;
|
||||
typedef Classif::Feature::Planarity Planarity;
|
||||
typedef Classif::Feature::Surface_variation Surface_variation;
|
||||
typedef Classif::Feature::Elevation<Kernel, Point_range, Pmap> Elevation;
|
||||
typedef Classif::Feature::Vertical_dispersion<Kernel, Point_range, Pmap> Dispersion;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ namespace Classif = CGAL::Classification;
|
|||
typedef Classif::Sum_of_weighted_features_predicate Classification_predicate;
|
||||
|
||||
typedef Classif::Point_set_neighborhood<Kernel, Point_range, Pmap> Neighborhood;
|
||||
typedef Classif::Local_eigen_analysis<Kernel, Point_range, Pmap> Local_eigen_analysis;
|
||||
typedef Classif::Local_eigen_analysis Local_eigen_analysis;
|
||||
|
||||
typedef Classif::Label_handle Label_handle;
|
||||
typedef Classif::Feature_handle Feature_handle;
|
||||
typedef Classif::Label_set Label_set;
|
||||
typedef Classif::Feature_set Feature_set;
|
||||
|
||||
typedef Classif::Feature::Sphericity<Kernel, Point_range, Pmap> Sphericity;
|
||||
typedef Classif::Feature::Sphericity Sphericity;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//! [Feature]
|
||||
|
|
|
|||
|
|
@ -38,21 +38,18 @@ namespace Feature {
|
|||
feature computes the distance of a point to a locally fitted
|
||||
plane.
|
||||
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
is `CGAL::Point_3`.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
template <typename PointRange, typename PointMap>
|
||||
class Distance_to_plane : public Feature_base
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
|
||||
typedef typename Kernel_traits<typename PointMap::value_type>::Kernel Kernel;
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
std::vector<float> distance_to_plane_feature;
|
||||
#else
|
||||
|
|
@ -80,7 +77,7 @@ public:
|
|||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
for(std::size_t i = 0; i < input.size(); i++)
|
||||
distance_to_plane_feature.push_back
|
||||
(CGAL::sqrt (CGAL::squared_distance (get(point_map, *(input.begin()+i)), eigen.plane(i))));
|
||||
(CGAL::sqrt (CGAL::squared_distance (get(point_map, *(input.begin()+i)), eigen.plane<Kernel>(i))));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +88,7 @@ public:
|
|||
return distance_to_plane_feature[pt_index];
|
||||
#else
|
||||
return CGAL::sqrt (CGAL::squared_distance
|
||||
(get(point_map, *(input.begin()+pt_index)), eigen.plane(pt_index)));
|
||||
(get(point_map, *(input.begin()+pt_index)), eigen.plane<Kernel>(pt_index)));
|
||||
#endif
|
||||
}
|
||||
/// \endcond
|
||||
|
|
|
|||
|
|
@ -31,23 +31,19 @@ namespace Classification {
|
|||
namespace Feature {
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Eigen_feature : public Feature_base
|
||||
{
|
||||
protected:
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
std::vector<float> attrib;
|
||||
#else
|
||||
const Local_eigen_analysis& eigen;
|
||||
const Classification::Local_eigen_analysis& eigen;
|
||||
#endif
|
||||
|
||||
public:
|
||||
Eigen_feature (const PointRange&,
|
||||
const Local_eigen_analysis& eigen)
|
||||
template <typename InputRange>
|
||||
Eigen_feature (const InputRange&,
|
||||
const Classification::Local_eigen_analysis& eigen)
|
||||
#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
: eigen (eigen)
|
||||
#endif
|
||||
|
|
@ -55,20 +51,19 @@ public:
|
|||
}
|
||||
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
virtual void init (const PointRange& input, const Local_eigen_analysis& eigen)
|
||||
virtual void init (std::size_t size, const Classification::Local_eigen_analysis& eigen)
|
||||
{
|
||||
|
||||
attrib.reserve (input.size());
|
||||
for (std::size_t i = 0; i < input.size(); ++ i)
|
||||
attrib.reserve (size);
|
||||
for (std::size_t i = 0; i < size; ++ i)
|
||||
attrib.push_back (get_value (eigen, i));
|
||||
}
|
||||
#else
|
||||
virtual void init (const PointRange&, const Local_eigen_analysis&)
|
||||
virtual void init (std::size_t, const Classification::Local_eigen_analysis&)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i) = 0;
|
||||
virtual float get_value (const Classification::Local_eigen_analysis& eigen, std::size_t i) = 0;
|
||||
virtual float value (std::size_t pt_index)
|
||||
{
|
||||
#ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
|
|
@ -91,39 +86,29 @@ public:
|
|||
\f[
|
||||
\frac{\lambda_1 - \lambda_2}{\lambda_1}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Linearity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
||||
\tparam Input model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Linearity (const PointRange& input,
|
||||
const Local_eigen_analysis& eigen) : Base (input, eigen)
|
||||
template <typename InputRange>
|
||||
Linearity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen) : Eigen_feature (input, eigen)
|
||||
{
|
||||
this->set_name("linearity");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
|
@ -148,27 +133,14 @@ public:
|
|||
\f[
|
||||
\frac{\lambda_2 - \lambda_3}{\lambda_1}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Planarity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -176,12 +148,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Planarity (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Planarity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("planarity");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -206,27 +179,14 @@ public:
|
|||
\f[
|
||||
\frac{\lambda_3}{\lambda_1}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Sphericity
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -234,12 +194,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Sphericity (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Sphericity (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("sphericity");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -263,27 +224,14 @@ public:
|
|||
\f[
|
||||
(\lambda_1 \times \lambda_2 \times \lambda_3)^{\frac{1}{3}}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Omnivariance
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -291,12 +239,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Omnivariance (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Omnivariance (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("omnivariance");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -317,27 +266,14 @@ public:
|
|||
\f[
|
||||
\frac{\lambda_1 - \lambda_3}{\lambda_1}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Anisotropy
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -345,12 +281,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Anisotropy (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Anisotropy (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("anisotropy");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -374,27 +311,14 @@ public:
|
|||
\f[
|
||||
- \sum_{i=1}^3 \lambda_i \times \log{\lambda_i}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Eigentropy
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -402,12 +326,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Eigentropy (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Eigentropy (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("eigentropy");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -436,27 +361,14 @@ public:
|
|||
\f[
|
||||
\lambda_1 + \lambda_2 + \lambda_3
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Sum_eigenvalues
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -464,12 +376,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Sum_eigenvalues (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Sum_eigenvalues (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("sum_eigen");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
@ -490,27 +403,14 @@ public:
|
|||
\f[
|
||||
\frac{\lambda_3}{\lambda_1 + \lambda_2 + \lambda_3}
|
||||
\f]
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Surface_variation
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
: public Feature_base
|
||||
#else
|
||||
: public Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits>
|
||||
: public Eigen_feature
|
||||
#endif
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Eigen_feature<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Base;
|
||||
public:
|
||||
/*!
|
||||
Constructs the feature.
|
||||
|
|
@ -518,12 +418,13 @@ public:
|
|||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
Surface_variation (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Surface_variation (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: Base(input, eigen)
|
||||
: Eigen_feature(input, eigen)
|
||||
{
|
||||
this->set_name("surface_variation");
|
||||
this->init(input, eigen);
|
||||
this->init(input.size(), eigen);
|
||||
}
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float get_value (const Local_eigen_analysis& eigen, std::size_t i)
|
||||
|
|
|
|||
|
|
@ -48,13 +48,9 @@ namespace Feature {
|
|||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
template <typename Geom_traits>
|
||||
class Verticality : public Feature_base
|
||||
{
|
||||
typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
|
||||
PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
|
||||
const typename Geom_traits::Vector_3 vertical;
|
||||
std::vector<float> verticality_feature;
|
||||
const Local_eigen_analysis* eigen;
|
||||
|
|
@ -63,11 +59,14 @@ public:
|
|||
/*!
|
||||
\brief Constructs the feature using local eigen analysis.
|
||||
|
||||
\tparam InputRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\param input input range.
|
||||
\param eigen class with precomputed eigenvectors and eigenvalues.
|
||||
*/
|
||||
#if defined(CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES) || defined(DOXYGEN_RUNNING)
|
||||
Verticality (const PointRange& input,
|
||||
template <typename InputRange>
|
||||
Verticality (const InputRange& input,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: vertical (0., 0., 1.), eigen(NULL)
|
||||
{
|
||||
|
|
@ -81,7 +80,8 @@ public:
|
|||
}
|
||||
}
|
||||
#else
|
||||
Verticality (const PointRange&,
|
||||
template <typename InputRange>
|
||||
Verticality (const InputRange&,
|
||||
const Local_eigen_analysis& eigen)
|
||||
: vertical (0., 0., 1.), eigen (&eigen)
|
||||
{
|
||||
|
|
@ -92,13 +92,15 @@ public:
|
|||
/*!
|
||||
\brief Constructs the feature using provided normals of points.
|
||||
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type
|
||||
is `RandomAccessIterator`.
|
||||
\tparam VectorMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Vector_3`.
|
||||
\param input input range.
|
||||
\param normal_map property map to access the normal vectors of the input points.
|
||||
*/
|
||||
template <typename VectorMap>
|
||||
template <typename PointRange, typename VectorMap>
|
||||
Verticality (const PointRange& input,
|
||||
VectorMap normal_map)
|
||||
: vertical (0., 0., 1.), eigen(NULL)
|
||||
|
|
@ -119,7 +121,7 @@ public:
|
|||
#ifndef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES
|
||||
if (eigen != NULL)
|
||||
{
|
||||
typename Geom_traits::Vector_3 normal = eigen->normal_vector(pt_index);
|
||||
typename Geom_traits::Vector_3 normal = eigen->normal_vector<Geom_traits>(pt_index);
|
||||
normal = normal / CGAL::sqrt (normal * normal);
|
||||
return (1. - CGAL::abs(normal * vertical));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,29 +46,16 @@ namespace Classification {
|
|||
eigenvalues of the covariance matrices of all points of a point
|
||||
set using a local neighborhood.
|
||||
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type is
|
||||
`RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
*/
|
||||
template <typename Geom_traits, typename PointRange, typename PointMap,
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float,3> >
|
||||
class Local_eigen_analysis
|
||||
{
|
||||
public:
|
||||
typedef typename Geom_traits::Point_3 Point;
|
||||
typedef typename Geom_traits::Vector_3 Vector;
|
||||
typedef typename Geom_traits::Plane_3 Plane;
|
||||
typedef CGAL::cpp11::array<float, 3> Eigenvalues; ///< Eigenvalues (sorted in ascending order)
|
||||
|
||||
private:
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
template <typename NeighborQuery>
|
||||
template <typename PointRange, typename PointMap, typename NeighborQuery, typename DiagonalizeTraits>
|
||||
class Compute_eigen_values
|
||||
{
|
||||
Local_eigen_analysis& m_eigen;
|
||||
|
|
@ -97,7 +84,7 @@ private:
|
|||
std::vector<std::size_t> neighbors;
|
||||
m_neighbor_query (get(m_point_map, *(m_input.begin()+i)), std::back_inserter (neighbors));
|
||||
|
||||
std::vector<Point> neighbor_points;
|
||||
std::vector<typename PointMap::value_type> neighbor_points;
|
||||
for (std::size_t j = 0; j < neighbors.size(); ++ j)
|
||||
neighbor_points.push_back (get(m_point_map, *(m_input.begin()+neighbors[j])));
|
||||
|
||||
|
|
@ -106,7 +93,8 @@ private:
|
|||
get(m_point_map, *(m_input.begin() + neighbors.back()))));
|
||||
m_mutex.unlock();
|
||||
|
||||
m_eigen.compute (i, get(m_point_map, *(m_input.begin()+i)), neighbor_points);
|
||||
m_eigen.compute<typename PointMap::value_type,
|
||||
DiagonalizeTraits> (i, get(m_point_map, *(m_input.begin()+i)), neighbor_points);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,29 +120,41 @@ public:
|
|||
/// \endcond
|
||||
|
||||
/*!
|
||||
|
||||
\brief Computes the local eigen analysis of an input range based
|
||||
on a local neighborhood.
|
||||
|
||||
\tparam PointRange model of `ConstRange`. Its iterator type is
|
||||
`RandomAccessIterator`.
|
||||
\tparam PointMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `Geom_traits::Point_3`.
|
||||
\tparam NeighborQuery model of `NeighborQuery`
|
||||
\tparam ConcurrencyTag enables sequential versus parallel
|
||||
algorithm. Possible values are `Parallel_tag` (default value is %CGAL
|
||||
is linked with TBB) or `Sequential_tag` (default value otherwise).
|
||||
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used
|
||||
for matrix diagonalization.
|
||||
|
||||
\param input input range.
|
||||
\param point_map property map to access the input points
|
||||
\param neighbor_query object used to access neighborhoods of points.
|
||||
*/
|
||||
template <typename NeighborQuery,
|
||||
template <typename PointRange,
|
||||
typename PointMap,
|
||||
typename NeighborQuery,
|
||||
#if defined(DOXYGEN_RUNNING)
|
||||
typename ConcurrencyTag>
|
||||
typename ConcurrencyTag,
|
||||
#elif defined(CGAL_LINKED_WITH_TBB)
|
||||
typename ConcurrencyTag = CGAL::Parallel_tag>
|
||||
typename ConcurrencyTag = CGAL::Parallel_tag,
|
||||
#else
|
||||
typename ConcurrencyTag = CGAL::Sequential_tag>
|
||||
typename ConcurrencyTag = CGAL::Sequential_tag,
|
||||
#endif
|
||||
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<float, 3> >
|
||||
Local_eigen_analysis (const PointRange& input,
|
||||
PointMap point_map,
|
||||
const NeighborQuery& neighbor_query)
|
||||
const NeighborQuery& neighbor_query,
|
||||
const ConcurrencyTag& = ConcurrencyTag(),
|
||||
const DiagonalizeTraits& = DiagonalizeTraits())
|
||||
{
|
||||
m_eigenvalues.resize (input.size());
|
||||
m_sum_eigenvalues.resize (input.size());
|
||||
|
|
@ -174,7 +174,8 @@ public:
|
|||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||
{
|
||||
tbb::mutex mutex;
|
||||
Compute_eigen_values<NeighborQuery> f(*this, input, point_map, neighbor_query, m_mean_range, mutex);
|
||||
Compute_eigen_values<PointRange, PointMap, NeighborQuery, DiagonalizeTraits>
|
||||
f(*this, input, point_map, neighbor_query, m_mean_range, mutex);
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, input.size ()), f);
|
||||
}
|
||||
else
|
||||
|
|
@ -185,14 +186,15 @@ public:
|
|||
std::vector<std::size_t> neighbors;
|
||||
neighbor_query (get(point_map, *(input.begin()+i)), std::back_inserter (neighbors));
|
||||
|
||||
std::vector<Point> neighbor_points;
|
||||
std::vector<typename PointMap::value_type> neighbor_points;
|
||||
for (std::size_t j = 0; j < neighbors.size(); ++ j)
|
||||
neighbor_points.push_back (get(point_map, *(input.begin()+neighbors[j])));
|
||||
|
||||
m_mean_range += CGAL::sqrt (CGAL::squared_distance (get(point_map, *(input.begin() + i)),
|
||||
get(point_map, *(input.begin() + neighbors.back()))));
|
||||
|
||||
compute (i, get(point_map, *(input.begin()+i)), neighbor_points);
|
||||
compute<typename PointMap::value_type, DiagonalizeTraits>
|
||||
(i, get(point_map, *(input.begin()+i)), neighbor_points);
|
||||
}
|
||||
}
|
||||
m_mean_range /= input.size();
|
||||
|
|
@ -200,25 +202,30 @@ public:
|
|||
|
||||
/*!
|
||||
\brief Returns the estimated unoriented normal vector of the point at position `index`.
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
*/
|
||||
Vector normal_vector (std::size_t index) const
|
||||
template <typename Geom_traits>
|
||||
typename Geom_traits::Vector_3 normal_vector (std::size_t index) const
|
||||
{
|
||||
return Vector(double(m_smallest_eigenvectors[index][0]),
|
||||
double(m_smallest_eigenvectors[index][1]),
|
||||
double(m_smallest_eigenvectors[index][2]));
|
||||
return typename Geom_traits::Vector_3(double(m_smallest_eigenvectors[index][0]),
|
||||
double(m_smallest_eigenvectors[index][1]),
|
||||
double(m_smallest_eigenvectors[index][2]));
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the estimated local tangent plane of the point at position `index`.
|
||||
\tparam Geom_traits model of \cgal Kernel.
|
||||
*/
|
||||
Plane plane (std::size_t index) const
|
||||
template <typename Geom_traits>
|
||||
typename Geom_traits::Plane_3 plane (std::size_t index) const
|
||||
{
|
||||
return Plane (Point (double(m_centroids[index][0]),
|
||||
double(m_centroids[index][1]),
|
||||
double(m_centroids[index][2])),
|
||||
Vector(double(m_smallest_eigenvectors[index][0]),
|
||||
double(m_smallest_eigenvectors[index][1]),
|
||||
double(m_smallest_eigenvectors[index][2])));
|
||||
return typename Geom_traits::Plane_3
|
||||
(typename Geom_traits::Point_3 (double(m_centroids[index][0]),
|
||||
double(m_centroids[index][1]),
|
||||
double(m_centroids[index][2])),
|
||||
typename Geom_traits::Vector_3 (double(m_smallest_eigenvectors[index][0]),
|
||||
double(m_smallest_eigenvectors[index][1]),
|
||||
double(m_smallest_eigenvectors[index][2])));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -237,8 +244,11 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
template <typename Point, typename DiagonalizeTraits>
|
||||
void compute (std::size_t index, const Point& query, std::vector<Point>& neighbor_points)
|
||||
{
|
||||
typedef typename Kernel_traits<Point>::Kernel::Vector_3 Vector;
|
||||
|
||||
if (neighbor_points.size() == 0)
|
||||
{
|
||||
Eigenvalues v = {{ 0.f, 0.f, 0.f }};
|
||||
|
|
|
|||
|
|
@ -104,38 +104,30 @@ public:
|
|||
<Geom_traits, PointRange, PointMap> Planimetric_grid;
|
||||
typedef Classification::Point_set_neighborhood
|
||||
<Geom_traits, PointRange, PointMap> Neighborhood;
|
||||
typedef Classification::Local_eigen_analysis
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Local_eigen_analysis;
|
||||
typedef Classification::Local_eigen_analysis Local_eigen_analysis;
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
typedef Classification::Feature_handle Feature_handle;
|
||||
typedef Classification::Label Label;
|
||||
typedef Classification::Label_handle Label_handle;
|
||||
|
||||
typedef Classification::Feature::Anisotropy
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Anisotropy;
|
||||
typedef Classification::Feature::Anisotropy Anisotropy;
|
||||
typedef Classification::Feature::Distance_to_plane
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Distance_to_plane;
|
||||
typedef Classification::Feature::Eigentropy
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Eigentropy;
|
||||
<PointRange, PointMap> Distance_to_plane;
|
||||
typedef Classification::Feature::Eigentropy Eigentropy;
|
||||
typedef Classification::Feature::Elevation
|
||||
<Geom_traits, PointRange, PointMap> Elevation;
|
||||
typedef Classification::Feature::Linearity
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Linearity;
|
||||
typedef Classification::Feature::Omnivariance
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Omnivariance;
|
||||
typedef Classification::Feature::Planarity
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Planarity;
|
||||
typedef Classification::Feature::Sphericity
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Sphericity;
|
||||
typedef Classification::Feature::Sum_eigenvalues
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Sum_eigen;
|
||||
typedef Classification::Feature::Surface_variation
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Surface_variation;
|
||||
typedef Classification::Feature::Linearity Linearity;
|
||||
typedef Classification::Feature::Omnivariance Omnivariance;
|
||||
typedef Classification::Feature::Planarity Planarity;
|
||||
typedef Classification::Feature::Sphericity Sphericity;
|
||||
typedef Classification::Feature::Sum_eigenvalues Sum_eigen;
|
||||
typedef Classification::Feature::Surface_variation Surface_variation;
|
||||
typedef Classification::Feature::Vertical_dispersion
|
||||
<Geom_traits, PointRange, PointMap> Dispersion;
|
||||
typedef Classification::Feature::Verticality
|
||||
<Geom_traits, PointRange, PointMap, DiagonalizeTraits> Verticality;
|
||||
<Geom_traits> Verticality;
|
||||
|
||||
typedef typename Classification::RGB_Color RGB_Color;
|
||||
/// \endcond
|
||||
|
||||
|
|
@ -169,7 +161,9 @@ private:
|
|||
t.reset();
|
||||
t.start();
|
||||
|
||||
eigen = new Local_eigen_analysis (input, point_map, neighborhood->k_neighbor_query(6));
|
||||
eigen = new Local_eigen_analysis
|
||||
(input, point_map, neighborhood->k_neighbor_query(6), ConcurrencyTag(), DiagonalizeTraits());
|
||||
|
||||
float range = eigen->mean_range();
|
||||
if (this->voxel_size < 0)
|
||||
this->voxel_size = range;
|
||||
|
|
|
|||
Loading…
Reference in New Issue