diff --git a/Classification/examples/Classification/example_classification.cpp b/Classification/examples/Classification/example_classification.cpp index c3aff4610e9..90510380141 100644 --- a/Classification/examples/Classification/example_classification.cpp +++ b/Classification/examples/Classification/example_classification.cpp @@ -23,18 +23,18 @@ typedef Classif::Sum_of_weighted_features_predicate Classification_predicate; typedef Classif::Planimetric_grid Planimetric_grid; typedef Classif::Point_set_neighborhood Neighborhood; -typedef Classif::Local_eigen_analysis 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 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::Distance_to_plane 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 Elevation; typedef Classif::Feature::Vertical_dispersion Dispersion; diff --git a/Classification/examples/Classification/example_feature.cpp b/Classification/examples/Classification/example_feature.cpp index b351c672c1c..887d528207e 100644 --- a/Classification/examples/Classification/example_feature.cpp +++ b/Classification/examples/Classification/example_feature.cpp @@ -18,14 +18,14 @@ namespace Classif = CGAL::Classification; typedef Classif::Sum_of_weighted_features_predicate Classification_predicate; typedef Classif::Point_set_neighborhood Neighborhood; -typedef Classif::Local_eigen_analysis 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 Sphericity; +typedef Classif::Feature::Sphericity Sphericity; /////////////////////////////////////////////////////////////////// //! [Feature] diff --git a/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h b/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h index 0bb4efe573c..012a51953e9 100644 --- a/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h +++ b/Classification/include/CGAL/Classification/Feature/Distance_to_plane.h @@ -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 > +template class Distance_to_plane : public Feature_base { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; + + typedef typename Kernel_traits::Kernel Kernel; + #ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES std::vector 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(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(pt_index))); #endif } /// \endcond diff --git a/Classification/include/CGAL/Classification/Feature/Eigen.h b/Classification/include/CGAL/Classification/Feature/Eigen.h index 2d6bddfa116..6c9f3224585 100644 --- a/Classification/include/CGAL/Classification/Feature/Eigen.h +++ b/Classification/include/CGAL/Classification/Feature/Eigen.h @@ -31,23 +31,19 @@ namespace Classification { namespace Feature { /// \cond SKIP_IN_MANUAL -template > class Eigen_feature : public Feature_base { protected: - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - #ifdef CGAL_CLASSIFICATION_PRECOMPUTE_FEATURES std::vector 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 + 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 > class Linearity #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Planarity #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Sphericity #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Omnivariance #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Anisotropy #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Eigentropy #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Sum_eigenvalues #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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 > class Surface_variation #ifdef DOXYGEN_RUNNING : public Feature_base #else - : public Eigen_feature + : public Eigen_feature #endif { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - typedef Eigen_feature 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 + 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) diff --git a/Classification/include/CGAL/Classification/Feature/Verticality.h b/Classification/include/CGAL/Classification/Feature/Verticality.h index 510fa84dddd..98948f5c5b3 100644 --- a/Classification/include/CGAL/Classification/Feature/Verticality.h +++ b/Classification/include/CGAL/Classification/Feature/Verticality.h @@ -48,13 +48,9 @@ namespace Feature { \tparam DiagonalizeTraits model of `DiagonalizeTraits` used for matrix diagonalization. */ -template > +template class Verticality : public Feature_base { - typedef Classification::Local_eigen_analysis Local_eigen_analysis; - const typename Geom_traits::Vector_3 vertical; std::vector 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 + 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 + 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 + template 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(pt_index); normal = normal / CGAL::sqrt (normal * normal); return (1. - CGAL::abs(normal * vertical)); } diff --git a/Classification/include/CGAL/Classification/Local_eigen_analysis.h b/Classification/include/CGAL/Classification/Local_eigen_analysis.h index 0321d187a17..7d4e93abdc4 100644 --- a/Classification/include/CGAL/Classification/Local_eigen_analysis.h +++ b/Classification/include/CGAL/Classification/Local_eigen_analysis.h @@ -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 > 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 Eigenvalues; ///< Eigenvalues (sorted in ascending order) private: #ifdef CGAL_LINKED_WITH_TBB - template + template class Compute_eigen_values { Local_eigen_analysis& m_eigen; @@ -97,7 +84,7 @@ private: std::vector neighbors; m_neighbor_query (get(m_point_map, *(m_input.begin()+i)), std::back_inserter (neighbors)); - std::vector neighbor_points; + std::vector 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 (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 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 > 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::value) { tbb::mutex mutex; - Compute_eigen_values f(*this, input, point_map, neighbor_query, m_mean_range, mutex); + Compute_eigen_values + f(*this, input, point_map, neighbor_query, m_mean_range, mutex); tbb::parallel_for(tbb::blocked_range(0, input.size ()), f); } else @@ -185,14 +186,15 @@ public: std::vector neighbors; neighbor_query (get(point_map, *(input.begin()+i)), std::back_inserter (neighbors)); - std::vector neighbor_points; + std::vector 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 + (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::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::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 void compute (std::size_t index, const Point& query, std::vector& neighbor_points) { + typedef typename Kernel_traits::Kernel::Vector_3 Vector; + if (neighbor_points.size() == 0) { Eigenvalues v = {{ 0.f, 0.f, 0.f }}; diff --git a/Classification/include/CGAL/Classification/Point_set_feature_generator.h b/Classification/include/CGAL/Classification/Point_set_feature_generator.h index 519bb1f45e5..d8bb60b4eb7 100644 --- a/Classification/include/CGAL/Classification/Point_set_feature_generator.h +++ b/Classification/include/CGAL/Classification/Point_set_feature_generator.h @@ -104,38 +104,30 @@ public: Planimetric_grid; typedef Classification::Point_set_neighborhood Neighborhood; - typedef Classification::Local_eigen_analysis - 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 - Anisotropy; + typedef Classification::Feature::Anisotropy Anisotropy; typedef Classification::Feature::Distance_to_plane - Distance_to_plane; - typedef Classification::Feature::Eigentropy - Eigentropy; + Distance_to_plane; + typedef Classification::Feature::Eigentropy Eigentropy; typedef Classification::Feature::Elevation Elevation; - 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::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 Dispersion; typedef Classification::Feature::Verticality - Verticality; + 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;