mirror of https://github.com/CGAL/cgal
force images to be taken by reference
This commit is contained in:
parent
953b01db1f
commit
0e62685f39
|
|
@ -506,8 +506,9 @@ From the example (\ref Mesh_3/mesh_implicit_domains_2.cpp):
|
|||
{
|
||||
static_assert(!parameters::is_default_parameter<CGAL_NP_CLASS, internal_np::image_3_param_t>::value, "Value for required parameter not found");
|
||||
using parameters::get_parameter;
|
||||
using parameters::get_parameter_reference;
|
||||
using parameters::choose_parameter;
|
||||
const CGAL::Image_3& image_ = get_parameter(np,internal_np::image_3_param);
|
||||
const CGAL::Image_3& image_ = get_parameter_reference(np,internal_np::image_3_param);
|
||||
auto iso_value_ = choose_parameter(get_parameter(np, internal_np::iso_value_param), 0);
|
||||
auto value_outside_ = choose_parameter(get_parameter(np, internal_np::voxel_value), 0);
|
||||
FT relative_error_bound_ = choose_parameter(get_parameter(np, internal_np::error_bound), FT(1e-3));
|
||||
|
|
@ -597,6 +598,7 @@ where the labeled image is used with a precomputed 3D image of weights :
|
|||
static Labeled_mesh_domain_3 create_labeled_image_mesh_domain(const CGAL::Image_3& image_, const CGAL_NP_CLASS& np = parameters::default_values())
|
||||
{
|
||||
using parameters::get_parameter;
|
||||
using parameters::get_parameter_reference;
|
||||
using parameters::choose_parameter;
|
||||
auto iso_value_ = choose_parameter(get_parameter(np, internal_np::iso_value_param), FT(0));
|
||||
auto value_outside_ = choose_parameter(get_parameter(np, internal_np::voxel_value), FT(0));
|
||||
|
|
@ -605,9 +607,10 @@ where the labeled image is used with a precomputed 3D image of weights :
|
|||
CGAL::Random* p_rng_ = choose_parameter(get_parameter(np, internal_np::rng), (CGAL::Random*)(0));
|
||||
auto null_subdomain_index_ = choose_parameter(get_parameter(np, internal_np::null_subdomain_index_param), Null_functor());
|
||||
auto construct_surface_patch_index_ = choose_parameter(get_parameter(np, internal_np::surface_patch_index), Null_functor());
|
||||
CGAL::Image_3 weights_ = choose_parameter(get_parameter(np, internal_np::weights_param), CGAL::Image_3());
|
||||
const CGAL::Image_3& weights_ = choose_parameter(get_parameter_reference(np, internal_np::weights_param), CGAL::Image_3());
|
||||
CGAL_USE(iso_value_);
|
||||
namespace p = CGAL::parameters;
|
||||
|
||||
if (weights_.is_valid())
|
||||
{
|
||||
return Labeled_mesh_domain_3
|
||||
|
|
@ -645,8 +648,9 @@ where the labeled image is used with a precomputed 3D image of weights :
|
|||
{
|
||||
static_assert(!parameters::is_default_parameter<CGAL_NP_CLASS, internal_np::image_3_param_t>::value, "Value for required parameter not found");
|
||||
using parameters::get_parameter;
|
||||
using parameters::get_parameter_reference;
|
||||
using parameters::choose_parameter;
|
||||
const CGAL::Image_3& image_ = get_parameter(np,internal_np::image_3_param);
|
||||
const CGAL::Image_3& image_ = get_parameter_reference(np,internal_np::image_3_param);
|
||||
auto iso_value_ = choose_parameter(get_parameter(np, internal_np::iso_value_param), FT(0));
|
||||
auto value_outside_ = choose_parameter(get_parameter(np, internal_np::voxel_value), FT(0));
|
||||
FT relative_error_bound_ = choose_parameter(get_parameter(np, internal_np::error_bound), FT(1e-3));
|
||||
|
|
@ -654,7 +658,7 @@ where the labeled image is used with a precomputed 3D image of weights :
|
|||
CGAL::Random* p_rng_ = choose_parameter(get_parameter(np, internal_np::rng), (CGAL::Random*)(0));
|
||||
auto null_subdomain_index_ = choose_parameter(get_parameter(np, internal_np::null_subdomain_index_param), Null_functor());
|
||||
auto construct_surface_patch_index_ = choose_parameter(get_parameter(np, internal_np::surface_patch_index), Null_functor());
|
||||
CGAL::Image_3 weights_ = choose_parameter(get_parameter(np, internal_np::weights_param), CGAL::Image_3());
|
||||
const CGAL::Image_3& weights_ = choose_parameter(get_parameter_reference(np, internal_np::weights_param), CGAL::Image_3());
|
||||
|
||||
namespace p = CGAL::parameters;
|
||||
if (weights_.is_valid())
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
#define CGAL_MESH_3_PARAMETERS_H
|
||||
|
||||
#include <CGAL/license/Mesh_3.h>
|
||||
#include <CGAL/disable_warnings.h>
|
||||
#include <CGAL/Named_function_parameters.h>
|
||||
#include <CGAL/optimize_mesh_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
|
|||
|
|
@ -48,10 +48,13 @@ enum all_default_t { all_default };
|
|||
enum X { Y };
|
||||
#define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \
|
||||
enum X { Y };
|
||||
#define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \
|
||||
enum X { Y };
|
||||
#define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z)
|
||||
#include <CGAL/STL_Extension/internal/parameters_interface.h>
|
||||
#undef CGAL_add_named_parameter
|
||||
#undef CGAL_add_named_parameter_with_compatibility
|
||||
#undef CGAL_add_named_parameter_with_compatibility_ref_only
|
||||
#undef CGAL_add_extra_named_parameter_with_compatibility
|
||||
|
||||
template <typename T, typename Tag, typename Base>
|
||||
|
|
@ -271,6 +274,16 @@ struct Named_function_parameters
|
|||
typedef Named_function_parameters<K, internal_np::X, self> Params;\
|
||||
return Params(k, *this); \
|
||||
}
|
||||
#define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \
|
||||
template<typename K> \
|
||||
Named_function_parameters<std::reference_wrapper<const K>, \
|
||||
internal_np::X, self> \
|
||||
Z(const K& k) const \
|
||||
{ \
|
||||
typedef Named_function_parameters<std::reference_wrapper<const K>,\
|
||||
internal_np::X, self> Params; \
|
||||
return Params(std::cref(k), *this); \
|
||||
}
|
||||
#define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \
|
||||
template<typename K> \
|
||||
Named_function_parameters<K, internal_np::X, self> \
|
||||
|
|
@ -282,6 +295,7 @@ struct Named_function_parameters
|
|||
#include <CGAL/STL_Extension/internal/parameters_interface.h>
|
||||
#undef CGAL_add_named_parameter
|
||||
#undef CGAL_add_named_parameter_with_compatibility
|
||||
#undef CGAL_add_named_parameter_with_compatibility_ref_only
|
||||
#undef CGAL_add_extra_named_parameter_with_compatibility
|
||||
|
||||
template <typename OT, typename OTag>
|
||||
|
|
@ -325,7 +339,7 @@ inline no_parameters(Named_function_parameters<T,Tag,Base>)
|
|||
return Params();
|
||||
}
|
||||
|
||||
template <class Tag>
|
||||
template <class Tag, bool ref_only = false>
|
||||
struct Boost_parameter_compatibility_wrapper
|
||||
{
|
||||
template <typename K>
|
||||
|
|
@ -345,6 +359,26 @@ struct Boost_parameter_compatibility_wrapper
|
|||
}
|
||||
};
|
||||
|
||||
template <class Tag>
|
||||
struct Boost_parameter_compatibility_wrapper<Tag, true>
|
||||
{
|
||||
template <typename K>
|
||||
Named_function_parameters<std::reference_wrapper<const K>, Tag>
|
||||
operator()(const K& p) const
|
||||
{
|
||||
typedef Named_function_parameters<std::reference_wrapper<const K>, Tag> Params;
|
||||
return Params(std::cref(p));
|
||||
}
|
||||
|
||||
template <typename K>
|
||||
Named_function_parameters<std::reference_wrapper<const K>, Tag>
|
||||
operator=(const K& p) const
|
||||
{
|
||||
typedef Named_function_parameters<std::reference_wrapper<const K>, Tag> Params;
|
||||
return Params(std::cref(p));
|
||||
}
|
||||
};
|
||||
|
||||
// define free functions and Boost_parameter_compatibility_wrapper for named parameters
|
||||
#define CGAL_add_named_parameter(X, Y, Z) \
|
||||
template <typename K> \
|
||||
|
|
@ -357,12 +391,15 @@ struct Boost_parameter_compatibility_wrapper
|
|||
// TODO: need to make sure this works when using several compilation units
|
||||
#define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \
|
||||
const Boost_parameter_compatibility_wrapper<internal_np::X> Z;
|
||||
#define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \
|
||||
const Boost_parameter_compatibility_wrapper<internal_np::X, true> Z;
|
||||
#define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \
|
||||
const Boost_parameter_compatibility_wrapper<internal_np::X> Z;
|
||||
#include <CGAL/STL_Extension/internal/parameters_interface.h>
|
||||
#undef CGAL_add_named_parameter
|
||||
#undef CGAL_add_extra_named_parameter_with_compatibility
|
||||
#undef CGAL_add_named_parameter_with_compatibility
|
||||
#undef CGAL_add_named_parameter_with_compatibility_ref_only
|
||||
|
||||
// function to extract a parameter
|
||||
template <typename T, typename Tag, typename Base, typename Query_tag>
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ CGAL_add_named_parameter_with_compatibility(mesh_param_t, mesh_param, mesh_optio
|
|||
CGAL_add_named_parameter_with_compatibility(manifold_param_t, manifold_param, manifold_option)
|
||||
CGAL_add_named_parameter_with_compatibility(features_option_param_t,features_options_param,features_options)
|
||||
|
||||
CGAL_add_named_parameter_with_compatibility(image_3_param_t, image_3_param, image)
|
||||
CGAL_add_named_parameter_with_compatibility_ref_only(image_3_param_t, image_3_param, image)
|
||||
CGAL_add_named_parameter_with_compatibility(iso_value_param_t, iso_value_param, iso_value)
|
||||
CGAL_add_named_parameter_with_compatibility(image_subdomain_index_t, image_subdomain_index, image_values_to_subdomain_indices)
|
||||
CGAL_add_named_parameter_with_compatibility(voxel_value_t, voxel_value, value_outside)
|
||||
|
|
@ -310,7 +310,7 @@ CGAL_add_named_parameter_with_compatibility(error_bound_t, error_bound, relative
|
|||
CGAL_add_named_parameter_with_compatibility(rng_t, rng, p_rng)
|
||||
CGAL_add_named_parameter_with_compatibility(null_subdomain_index_param_t,null_subdomain_index_param, null_subdomain_index)
|
||||
CGAL_add_named_parameter_with_compatibility(surface_patch_index_t, surface_patch_index, construct_surface_patch_index)
|
||||
CGAL_add_named_parameter_with_compatibility(weights_param_t, weights_param, weights)
|
||||
CGAL_add_named_parameter_with_compatibility_ref_only(weights_param_t, weights_param, weights)
|
||||
|
||||
CGAL_add_named_parameter_with_compatibility(edge_size_param_t, edge_size_param, edge_size)
|
||||
CGAL_add_named_parameter_with_compatibility(edge_sizing_field_param_t, edge_sizing_field_param, edge_sizing_field)
|
||||
|
|
|
|||
Loading…
Reference in New Issue