diff --git a/Classification/include/CGAL/Classification/Feature/Eigen.h b/Classification/include/CGAL/Classification/Feature/Eigen.h index 8407208dbc4..793e3433449 100644 --- a/Classification/include/CGAL/Classification/Feature/Eigen.h +++ b/Classification/include/CGAL/Classification/Feature/Eigen.h @@ -28,6 +28,7 @@ #include /// \cond SKIP_IN_MANUAL +#ifndef CGAL_NO_DEPRECATED_CODE namespace CGAL { @@ -92,6 +93,7 @@ public: Its default name is "linearity". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Linearity, please update your code with Eigenvalue instead") class Linearity #ifdef DOXYGEN_RUNNING : public Feature_base @@ -139,6 +141,7 @@ public: Its default name is "planarity". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Planarity, please update your code with Eigenvalue instead") class Planarity #ifdef DOXYGEN_RUNNING : public Feature_base @@ -186,6 +189,7 @@ public: Its default name is "sphericity". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Sphericity, please update your code with Eigenvalue instead") class Sphericity #ifdef DOXYGEN_RUNNING : public Feature_base @@ -233,6 +237,7 @@ public: Its default name is "omnivariance". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Omnivariance, please update your code with Eigenvalue instead") class Omnivariance #ifdef DOXYGEN_RUNNING : public Feature_base @@ -277,6 +282,7 @@ public: Its default name is "anisotropy". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Anisotropy, please update your code with Eigenvalue instead") class Anisotropy #ifdef DOXYGEN_RUNNING : public Feature_base @@ -324,6 +330,7 @@ public: Its default name is "eigentropy". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Eigentropy, please update your code with Eigenvalue instead") class Eigentropy #ifdef DOXYGEN_RUNNING : public Feature_base @@ -377,6 +384,7 @@ public: Its default name is "surface_variation". */ +CGAL_DEPRECATED_MSG("you are using the deprecated feature Surface_variation, please update your code with Eigenvalue instead") class Surface_variation #ifdef DOXYGEN_RUNNING : public Feature_base @@ -417,6 +425,7 @@ public: } // namespace CGAL +#endif /// \endcond #endif // CGAL_CLASSIFICATION_FEATURES_EIGEN_H diff --git a/Classification/include/CGAL/Classification/Feature/Hsv.h b/Classification/include/CGAL/Classification/Feature/Hsv.h index 87d4b555af8..69fe9fbd7f8 100644 --- a/Classification/include/CGAL/Classification/Feature/Hsv.h +++ b/Classification/include/CGAL/Classification/Feature/Hsv.h @@ -29,6 +29,7 @@ #include /// \cond SKIP_IN_MANUAL +#ifndef CGAL_NO_DEPRECATED_CODE namespace CGAL { @@ -83,6 +84,7 @@ namespace Feature { is `CGAL::Classification::RGB_Color`. */ template +CGAL_DEPRECATED_MSG("you are using the deprecated feature Hsv, please update your code with Color_channel instead") class Hsv : public Feature_base { public: @@ -169,6 +171,7 @@ public: } // namespace CGAL +#endif /// \endcond #endif // CGAL_CLASSIFICATION_FEATURE_HSV_H diff --git a/Classification/include/CGAL/Classification/Point_set_feature_generator.h b/Classification/include/CGAL/Classification/Point_set_feature_generator.h index 164dd856258..42364ea804a 100644 --- a/Classification/include/CGAL/Classification/Point_set_feature_generator.h +++ b/Classification/include/CGAL/Classification/Point_set_feature_generator.h @@ -281,6 +281,64 @@ public: /// @} /// \cond SKIP_IN_MANUAL + +#ifndef CGAL_NO_DEPRECATED_CODE + // deprecated + template + CGAL_DEPRECATED_MSG("you are using a deprecated constructor of CGAL::Classification::Point_set_feature_generator, please update your code") + Point_set_feature_generator(Feature_set& features, + const PointRange& input, + PointMap point_map, + std::size_t nb_scales, + VectorMap normal_map = VectorMap(), + ColorMap color_map = ColorMap(), + EchoMap echo_map = EchoMap(), + float voxel_size = -1.f) + : m_input (input), m_point_map (point_map) + { + m_bbox = CGAL::bounding_box + (boost::make_transform_iterator (m_input.begin(), CGAL::Property_map_to_unary_function(m_point_map)), + boost::make_transform_iterator (m_input.end(), CGAL::Property_map_to_unary_function(m_point_map))); + + CGAL::Real_timer t; t.start(); + + m_scales.reserve (nb_scales); + + m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size)); + + if (voxel_size == -1.f) + voxel_size = m_scales[0]->grid_resolution(); + + for (std::size_t i = 1; i < nb_scales; ++ i) + { + voxel_size *= 2; + m_scales.push_back (new Scale (m_input, m_point_map, m_bbox, voxel_size, m_scales[i-1]->grid)); + } + t.stop(); + CGAL_CLASSIFICATION_CERR << "Scales computed in " << t.time() << " second(s)" << std::endl; + t.reset(); + + typedef typename Default::Get::type + Vmap; + typedef typename Default::Get::type + Cmap; + typedef typename Default::Get::type + Emap; + + generate_point_based_features (features); + generate_normal_based_features (features, get_parameter(normal_map)); + generate_color_based_features (features, get_parameter(color_map)); + generate_echo_based_features (features, get_parameter(echo_map)); + } + + // Functions to remove when deprecated constructor is removed + void generate_normal_based_features(const CGAL::Constant_property_map&) { } + void generate_color_based_features(const CGAL::Constant_property_map&) { } + void generate_echo_based_features(const CGAL::Constant_property_map&) { } +#endif + virtual ~Point_set_feature_generator() { clear(); diff --git a/Classification/test/Classification/CMakeLists.txt b/Classification/test/Classification/CMakeLists.txt index 411b07dce92..66e6ffafae8 100644 --- a/Classification/test/Classification/CMakeLists.txt +++ b/Classification/test/Classification/CMakeLists.txt @@ -85,10 +85,17 @@ if( WIN32 ) endif() create_single_source_cgal_program( "test_classification_point_set.cpp" CXX_FEATURES ${needed_cxx_features} ) - if(TARGET test_classification_point_set) target_link_libraries(test_classification_point_set PUBLIC ${classification_linked_libraries}) if (TBB_FOUND) CGAL_target_use_TBB( test_classification_point_set ) endif() endif() + +create_single_source_cgal_program( "deprecated_test_classification_point_set.cpp" CXX_FEATURES ${needed_cxx_features} ) +if(TARGET deprecated_test_classification_point_set) + target_link_libraries(deprecated_test_classification_point_set PUBLIC ${classification_linked_libraries}) + if (TBB_FOUND) + CGAL_target_use_TBB( deprecated_test_classification_point_set ) + endif() +endif() diff --git a/Classification/test/Classification/deprecated_test_classification_point_set.cpp b/Classification/test/Classification/deprecated_test_classification_point_set.cpp new file mode 100644 index 00000000000..1e5e19c6056 --- /dev/null +++ b/Classification/test/Classification/deprecated_test_classification_point_set.cpp @@ -0,0 +1,136 @@ +#include + +#if defined (_MSC_VER) && !defined (_WIN64) +#pragma warning(disable:4244) // boost::number_distance::distance() + // converts 64 to 32 bits integers +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point; +typedef Kernel::Vector_3 Vector; + +typedef CGAL::Point_set_3 Point_set; +typedef Point_set::Point_map Point_map; + +typedef Kernel::Iso_cuboid_3 Iso_cuboid_3; + +namespace Classification = CGAL::Classification; + +typedef Classification::Label_handle Label_handle; +typedef Classification::Feature_handle Feature_handle; +typedef Classification::Label_set Label_set; +typedef Classification::Feature_set Feature_set; + +typedef Classification::Sum_of_weighted_features_classifier Classifier; + +typedef Classification::Point_set_feature_generator Feature_generator; + +typedef Point_set::Property_map Size_t_map; +typedef Point_set::Property_map Color_map; + + + +int main (int, char**) +{ + Point_set pts; + + pts.add_normal_map(); + + bool map_added = false; + Size_t_map echo_map; + Color_map color_map; + + boost::tie (echo_map, map_added) = pts.add_property_map ("echo"); + CGAL_assertion (map_added); + boost::tie (color_map, map_added) = pts.add_property_map ("color"); + CGAL_assertion (map_added); + + for (std::size_t i = 0; i < 1000; ++ i) + { + Point_set::iterator it + = pts.insert (Point (CGAL::get_default_random().get_double(), + CGAL::get_default_random().get_double(), + CGAL::get_default_random().get_double()), + Vector (CGAL::get_default_random().get_double(), + CGAL::get_default_random().get_double(), + CGAL::get_default_random().get_double())); + echo_map[*it] = std::size_t(CGAL::get_default_random().get_int(0, 4)); + color_map[*it] = CGAL::make_array ((unsigned char)(CGAL::get_default_random().get_int(0, 255)), + (unsigned char)(CGAL::get_default_random().get_int(0, 255)), + (unsigned char)(CGAL::get_default_random().get_int(0, 255))); + } + + Feature_set features; + Feature_generator generator (features, pts, pts.point_map(), + 5, // using 5 scales + pts.normal_map(), + color_map, echo_map); + + CGAL_assertion (generator.number_of_scales() == 5); + CGAL_assertion (features.size() == 80); + + Label_set labels; + + std::vector training_set (pts.size(), -1); + for (std::size_t i = 0; i < 20; ++ i) + { + std::ostringstream oss; + oss << "label_" << i; + Label_handle lh = labels.add(oss.str().c_str()); + + for (std::size_t j = 0; j < 10; ++ j) + training_set[std::size_t(CGAL::get_default_random().get_int(0, int(training_set.size())))] = int(i); + } + CGAL_assertion (labels.size() == 20); + + Classifier classifier (labels, features); + + classifier.train (training_set, 800); +#ifdef CGAL_LINKED_WITH_TBB + classifier.train (training_set, 800); +#endif + + std::vector label_indices(pts.size(), -1); + + Classification::classify + (pts, labels, classifier, label_indices); + + Classification::classify_with_local_smoothing + (pts, pts.point_map(), labels, classifier, + generator.neighborhood().sphere_neighbor_query(0.01f), + label_indices); + + Classification::classify_with_graphcut + (pts, pts.point_map(), labels, classifier, + generator.neighborhood().k_neighbor_query(12), + 0.2f, 10, label_indices); + +#ifdef CGAL_LINKED_WITH_TBB + Classification::classify + (pts, labels, classifier, label_indices); + + Classification::classify_with_local_smoothing + (pts, pts.point_map(), labels, classifier, + generator.neighborhood().sphere_neighbor_query(0.01f), + label_indices); + + Classification::classify_with_graphcut + (pts, pts.point_map(), labels, classifier, + generator.neighborhood().k_neighbor_query(12), + 0.2f, 10, label_indices); +#endif + + Classification::Evaluation evaluation (labels, training_set, label_indices); + + return EXIT_SUCCESS; +} diff --git a/Classification/test/Classification/test_classification_point_set.cpp b/Classification/test/Classification/test_classification_point_set.cpp index edc9e6a507c..1751aaaa5f6 100644 --- a/Classification/test/Classification/test_classification_point_set.cpp +++ b/Classification/test/Classification/test_classification_point_set.cpp @@ -74,12 +74,12 @@ int main (int, char**) features.begin_parallel_additions(); #endif - Feature_generator generator (features, pts, pts.point_map(), 5); // using 5 scales + Feature_generator generator (pts, pts.point_map(), 5); // using 5 scales - generator.generate_point_based_features(); - generator.generate_normal_based_features(pts.normal_map()); - generator.generate_color_based_features(color_map); - generator.generate_echo_based_features(echo_map); + generator.generate_point_based_features(features); + generator.generate_normal_based_features(features, pts.normal_map()); + generator.generate_color_based_features(features, color_map); + generator.generate_echo_based_features(features, echo_map); #ifdef CGAL_LINKED_WITH_TBB features.end_parallel_additions();