diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp index 833bb1ac073..8efa0e2841c 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image, - weights = img_weights, + weights = std::ref(img_weights), relative_error_bound = 1e-6, features_detector = CGAL::Mesh_3::Detect_features_in_image()); /// [Domain creation] diff --git a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h index b1ccf4939d9..b5bb4c28939 100644 --- a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h @@ -126,12 +126,19 @@ namespace internal { // Detect_features_in_domain template struct Detect_features_in_domain { + std::vector> - operator()(const CGAL::Image_3& image, DetectFunctor functor) const { + operator()(const CGAL::Image_3& image, CGAL::Image_3& weights, DetectFunctor functor) const { #if defined(BOOST_MSVC) && (BOOST_MSVC < 1910) //before msvc2017 - return functor.operator()(image); + if(weights.is_valid()) + return functor.operator()(image, weights); + else + return functor.operator()(image); #else - return functor.template operator()(image); + if(weights.is_valid()) + return functor.template operator()(image, weights); + else + return functor.template operator()(image); #endif } }; @@ -139,23 +146,23 @@ namespace internal { template struct Detect_features_in_domain { std::vector> - operator()(const CGAL::Image_3&, Null_functor) const { + operator()(const CGAL::Image_3&, CGAL::Image_3&, Null_functor) const { return std::vector>(); } }; template std::vector> - detect_features(const CGAL::Image_3& image, DetectFunctor functor) + detect_features(const CGAL::Image_3& image, CGAL::Image_3& weights, DetectFunctor functor) { Detect_features_in_domain detector; - return detector(image, functor); + return detector(image, weights, functor); } template struct Add_features_in_domain { template - void operator()(const CGAL::Image_3&, MeshDomain&, const InputFeatureRange&, DetectFunctor) + void operator()(const CGAL::Image_3&, CGAL::Image_3&, MeshDomain&, const InputFeatureRange&, DetectFunctor) {} }; @@ -164,13 +171,14 @@ namespace internal { { template void operator()(const CGAL::Image_3& image, + CGAL::Image_3& weights, MeshDomain& domain, const InputFeatureRange& input_features, DetectFunctor functor) { using P = typename MeshDomain::Point_3; auto detected_feature_range - = CGAL::Mesh_3::internal::detect_features

(image, functor); + = CGAL::Mesh_3::internal::detect_features

(image, weights, functor); CGAL::merge_and_snap_polylines(image, detected_feature_range, input_features); @@ -608,13 +616,13 @@ public: * * \cgalNamedParamsBegin * \cgalParamNBegin{weights} - * \cgalParamDescription{an input 3D image that provides + * \cgalParamDescription{a reference to an input 3D image that provides * weights associated to each voxel (the word type is `unsigned char`, * and the voxels values are integers between 0 and 255). * The weights image can be generated with `CGAL::Mesh_3::generate_label_weights()`. * Its dimensions must be the same as the dimensions of `parameters::image`.} * \cgalParamDefault{CGAL::Image_3()} - * \cgalParamExtra{A const reference will be taken to the parameter passed.} + * \cgalParamExtra{if `features_detector` is provided, `weights` should be modified accordingly} * \cgalParamNEnd * \cgalParamNBegin{value_outside} * \cgalParamDescription{the value attached to voxels @@ -657,7 +665,7 @@ public: * \cgalParamNEnd * * \cgalNamedParamsEnd - * + * * \todo{Add warning about using weights and feature detection together} * * \cgalHeading{Example} @@ -680,6 +688,8 @@ public: * where the features are provided by the user: * * \snippet Mesh_3/mesh_3D_image_with_input_features.cpp Domain creation + * + * \todo what if `input_features` and `weights` are both provided? */ template static auto @@ -700,8 +710,8 @@ public: using Image_ref_type = typename internal_np::Lookup_named_param_def::reference; - CGAL::Image_3 no_weights; - const Image_ref_type weights_ = choose_parameter(get_parameter_reference(np, internal_np::weights_param), no_weights); + CGAL::Image_3 no_weights_; + Image_ref_type weights_ = choose_parameter(get_parameter_reference(np, internal_np::weights_param), no_weights_); auto features_detector_ = choose_parameter(get_parameter(np, internal_np::features_detector_param), Null_functor()); using Default_input_features = std::vector>; @@ -715,7 +725,9 @@ public: CGAL_USE(iso_value_); namespace p = CGAL::parameters; - auto image_wrapper = weights_.is_valid() + const bool use_weights + = !CGAL::parameters::is_default_parameter::value; + auto image_wrapper = use_weights ? create_weighted_labeled_image_wrapper(image_, weights_, image_values_to_subdomain_indices_, @@ -746,7 +758,7 @@ public: // features Mesh_3::internal::Add_features_in_domain() - (image_, domain, input_features_, features_detector_); + (image_, weights_, domain, input_features_, features_detector_); return domain; } diff --git a/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_image.h b/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_image.h index 843b2ecec05..26613d35f6e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_image.h +++ b/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_image.h @@ -280,6 +280,23 @@ public: return std::vector>(); } + + /*! + * @todo documentation + */ + template + std::vector> + operator()(const CGAL::Image_3& image, CGAL::Image_3&) const + { + CGAL_IMAGE_IO_CASE(image.image(), + return (internal::detect_features_in_image_with_know_word_type(image)); + ); + CGAL_error_msg("This place should never be reached, because it would mean " + "the image word type is a type that is not handled by " + "CGAL_ImageIO."); + + return std::vector>(); + } }; diff --git a/Mesh_3/include/CGAL/Mesh_3/Detect_features_on_image_bbox.h b/Mesh_3/include/CGAL/Mesh_3/Detect_features_on_image_bbox.h index ca9f068c5ba..55ee6868654 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Detect_features_on_image_bbox.h +++ b/Mesh_3/include/CGAL/Mesh_3/Detect_features_on_image_bbox.h @@ -91,6 +91,17 @@ public: { return internal::detect_features_on_bbox(image); } + + /*! + * @todo documentation + */ + template + std::vector> + operator()(const CGAL::Image_3& image, CGAL::Image_3&) const + { + return internal::detect_features_on_bbox(image); + } + }; }//end namespace Mesh_3 diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 5031410dfd8..bfb2e4d475b 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -317,7 +317,6 @@ CGAL_add_named_parameter_with_compatibility(surface_patch_index_t, surface_patch CGAL_add_named_parameter_with_compatibility_ref_only(weights_param_t, weights_param, weights) CGAL_add_named_parameter_with_compatibility(features_detector_param_t, features_detector_param, features_detector) CGAL_add_named_parameter_with_compatibility(input_features_param_t, input_features_param, input_features) -CGAL_add_named_parameter_with_compatibility(with_features_param_t, with_features_param, with_features) CGAL_add_named_parameter_with_compatibility(edge_size_param_t, edge_size_param, edge_size) CGAL_add_named_parameter_with_compatibility_ref_only(edge_sizing_field_param_t, edge_sizing_field_param, edge_sizing_field)