mirror of https://github.com/CGAL/cgal
wip
This commit is contained in:
parent
2d1fb95155
commit
d1e79542f2
|
|
@ -60,7 +60,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
Mesh_domain domain
|
Mesh_domain domain
|
||||||
= Mesh_domain::create_labeled_image_mesh_domain(image,
|
= Mesh_domain::create_labeled_image_mesh_domain(image,
|
||||||
weights = img_weights,
|
weights = std::ref(img_weights),
|
||||||
relative_error_bound = 1e-6,
|
relative_error_bound = 1e-6,
|
||||||
features_detector = CGAL::Mesh_3::Detect_features_in_image());
|
features_detector = CGAL::Mesh_3::Detect_features_in_image());
|
||||||
/// [Domain creation]
|
/// [Domain creation]
|
||||||
|
|
|
||||||
|
|
@ -126,12 +126,19 @@ namespace internal {
|
||||||
// Detect_features_in_domain
|
// Detect_features_in_domain
|
||||||
template<typename Point, typename DetectFunctor>
|
template<typename Point, typename DetectFunctor>
|
||||||
struct Detect_features_in_domain {
|
struct Detect_features_in_domain {
|
||||||
|
|
||||||
std::vector<std::vector<Point>>
|
std::vector<std::vector<Point>>
|
||||||
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
|
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1910) //before msvc2017
|
||||||
return functor.operator()<Point>(image);
|
if(weights.is_valid())
|
||||||
|
return functor.operator()<Point>(image, weights);
|
||||||
|
else
|
||||||
|
return functor.operator()<Point>(image);
|
||||||
#else
|
#else
|
||||||
return functor.template operator()<Point>(image);
|
if(weights.is_valid())
|
||||||
|
return functor.template operator()<Point>(image, weights);
|
||||||
|
else
|
||||||
|
return functor.template operator()<Point>(image);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -139,23 +146,23 @@ namespace internal {
|
||||||
template<typename Point>
|
template<typename Point>
|
||||||
struct Detect_features_in_domain<Point, Null_functor> {
|
struct Detect_features_in_domain<Point, Null_functor> {
|
||||||
std::vector<std::vector<Point>>
|
std::vector<std::vector<Point>>
|
||||||
operator()(const CGAL::Image_3&, Null_functor) const {
|
operator()(const CGAL::Image_3&, CGAL::Image_3&, Null_functor) const {
|
||||||
return std::vector<std::vector<Point>>();
|
return std::vector<std::vector<Point>>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Point, typename DetectFunctor>
|
template<typename Point, typename DetectFunctor>
|
||||||
std::vector<std::vector<Point>>
|
std::vector<std::vector<Point>>
|
||||||
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<Point, DetectFunctor> detector;
|
Detect_features_in_domain<Point, DetectFunctor> detector;
|
||||||
return detector(image, functor);
|
return detector(image, weights, functor);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool WithFeatures>
|
template<bool WithFeatures>
|
||||||
struct Add_features_in_domain {
|
struct Add_features_in_domain {
|
||||||
template<typename MeshDomain, typename InputFeatureRange, typename DetectFunctor>
|
template<typename MeshDomain, typename InputFeatureRange, typename DetectFunctor>
|
||||||
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<typename MeshDomain, typename InputFeatureRange, typename DetectFunctor>
|
template<typename MeshDomain, typename InputFeatureRange, typename DetectFunctor>
|
||||||
void operator()(const CGAL::Image_3& image,
|
void operator()(const CGAL::Image_3& image,
|
||||||
|
CGAL::Image_3& weights,
|
||||||
MeshDomain& domain,
|
MeshDomain& domain,
|
||||||
const InputFeatureRange& input_features,
|
const InputFeatureRange& input_features,
|
||||||
DetectFunctor functor)
|
DetectFunctor functor)
|
||||||
{
|
{
|
||||||
using P = typename MeshDomain::Point_3;
|
using P = typename MeshDomain::Point_3;
|
||||||
auto detected_feature_range
|
auto detected_feature_range
|
||||||
= CGAL::Mesh_3::internal::detect_features<P>(image, functor);
|
= CGAL::Mesh_3::internal::detect_features<P>(image, weights, functor);
|
||||||
|
|
||||||
CGAL::merge_and_snap_polylines(image, detected_feature_range, input_features);
|
CGAL::merge_and_snap_polylines(image, detected_feature_range, input_features);
|
||||||
|
|
||||||
|
|
@ -608,13 +616,13 @@ public:
|
||||||
*
|
*
|
||||||
* \cgalNamedParamsBegin
|
* \cgalNamedParamsBegin
|
||||||
* \cgalParamNBegin{weights}
|
* \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`,
|
* weights associated to each voxel (the word type is `unsigned char`,
|
||||||
* and the voxels values are integers between 0 and 255).
|
* and the voxels values are integers between 0 and 255).
|
||||||
* The weights image can be generated with `CGAL::Mesh_3::generate_label_weights()`.
|
* 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`.}
|
* Its dimensions must be the same as the dimensions of `parameters::image`.}
|
||||||
* \cgalParamDefault{CGAL::Image_3()}
|
* \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
|
* \cgalParamNEnd
|
||||||
* \cgalParamNBegin{value_outside}
|
* \cgalParamNBegin{value_outside}
|
||||||
* \cgalParamDescription{the value attached to voxels
|
* \cgalParamDescription{the value attached to voxels
|
||||||
|
|
@ -680,6 +688,8 @@ public:
|
||||||
* where the features are provided by the user:
|
* where the features are provided by the user:
|
||||||
*
|
*
|
||||||
* \snippet Mesh_3/mesh_3D_image_with_input_features.cpp Domain creation
|
* \snippet Mesh_3/mesh_3D_image_with_input_features.cpp Domain creation
|
||||||
|
*
|
||||||
|
* \todo what if `input_features` and `weights` are both provided?
|
||||||
*/
|
*/
|
||||||
template<typename CGAL_NP_TEMPLATE_PARAMETERS>
|
template<typename CGAL_NP_TEMPLATE_PARAMETERS>
|
||||||
static auto
|
static auto
|
||||||
|
|
@ -700,8 +710,8 @@ public:
|
||||||
using Image_ref_type = typename internal_np::Lookup_named_param_def<internal_np::weights_param_t,
|
using Image_ref_type = typename internal_np::Lookup_named_param_def<internal_np::weights_param_t,
|
||||||
CGAL_NP_CLASS,
|
CGAL_NP_CLASS,
|
||||||
CGAL::Image_3>::reference;
|
CGAL::Image_3>::reference;
|
||||||
CGAL::Image_3 no_weights;
|
CGAL::Image_3 no_weights_;
|
||||||
const Image_ref_type weights_ = choose_parameter(get_parameter_reference(np, internal_np::weights_param), 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());
|
auto features_detector_ = choose_parameter(get_parameter(np, internal_np::features_detector_param), Null_functor());
|
||||||
|
|
||||||
using Default_input_features = std::vector<std::vector<typename Labeled_mesh_domain_3::Point_3>>;
|
using Default_input_features = std::vector<std::vector<typename Labeled_mesh_domain_3::Point_3>>;
|
||||||
|
|
@ -715,7 +725,9 @@ public:
|
||||||
CGAL_USE(iso_value_);
|
CGAL_USE(iso_value_);
|
||||||
namespace p = CGAL::parameters;
|
namespace p = CGAL::parameters;
|
||||||
|
|
||||||
auto image_wrapper = weights_.is_valid()
|
const bool use_weights
|
||||||
|
= !CGAL::parameters::is_default_parameter<CGAL_NP_CLASS, internal_np::weights_param_t>::value;
|
||||||
|
auto image_wrapper = use_weights
|
||||||
? create_weighted_labeled_image_wrapper(image_,
|
? create_weighted_labeled_image_wrapper(image_,
|
||||||
weights_,
|
weights_,
|
||||||
image_values_to_subdomain_indices_,
|
image_values_to_subdomain_indices_,
|
||||||
|
|
@ -746,7 +758,7 @@ public:
|
||||||
|
|
||||||
// features
|
// features
|
||||||
Mesh_3::internal::Add_features_in_domain<!no_features>()
|
Mesh_3::internal::Add_features_in_domain<!no_features>()
|
||||||
(image_, domain, input_features_, features_detector_);
|
(image_, weights_, domain, input_features_, features_detector_);
|
||||||
|
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,23 @@ public:
|
||||||
|
|
||||||
return std::vector<std::vector<Point>>();
|
return std::vector<std::vector<Point>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @todo documentation
|
||||||
|
*/
|
||||||
|
template<typename Point>
|
||||||
|
std::vector<std::vector<Point>>
|
||||||
|
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<Word, Point>(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<std::vector<Point>>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,17 @@ public:
|
||||||
{
|
{
|
||||||
return internal::detect_features_on_bbox<Point>(image);
|
return internal::detect_features_on_bbox<Point>(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @todo documentation
|
||||||
|
*/
|
||||||
|
template<typename Point>
|
||||||
|
std::vector<std::vector<Point>>
|
||||||
|
operator()(const CGAL::Image_3& image, CGAL::Image_3&) const
|
||||||
|
{
|
||||||
|
return internal::detect_features_on_bbox<Point>(image);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//end namespace Mesh_3
|
}//end namespace Mesh_3
|
||||||
|
|
|
||||||
|
|
@ -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_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(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(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(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)
|
CGAL_add_named_parameter_with_compatibility_ref_only(edge_sizing_field_param_t, edge_sizing_field_param, edge_sizing_field)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue