-
Notifications
You must be signed in to change notification settings - Fork 1
New API for models of MeshDomain_3 based on 3D images
Laurent Rineau edited this page Feb 5, 2018
·
3 revisions
My plan is to deprecate CGAL::Gray_image_mesh_domain_3
and
CGAL::Labeled_image_mesh_domain_3
in favor of new constructors of
CGAL::Labeled_mesh_domain_3
.
The API of those constructors would be similar (I simplify) to:
template <class GT>
class Labeled_image_mesh_domain_3 {
public:
template <typename Functor>
Labeled_image_mesh_domain_3(CGAL::Image_3 image,
Functor image_values_to_subdomain_indices,
double relative_error_bound = 1e-6);
// [...]
};
The problem is that I need to distinguish between:
- a gray image for which I will use trilinear interpolation, and
- a labeled image, for which I will use no interpolation, or a labeled trilinear interpolation.
So the new constructors will use a tag:
template <class GT>
class Labeled_image_mesh_domain_3 {
public:
template <typename Functor>
Labeled_image_mesh_domain_3(CGAL::Image_3 image,
CGAL::Gray_image_mesh_domain_tag,
Functor image_values_to_subdomain_indices,
double relative_error_bound = 1e-6);
template <typename Functor>
Labeled_image_mesh_domain_3(CGAL::Image_3 image,
CGAL::Labeled_image_mesh_domain_tag,
Functor image_values_to_subdomain_indices,
double relative_error_bound = 1e-6);
// [...]
};
The precise name of those tags does not matter.
Alternatively, I can use named constructors, with static class functions acting as constructors:
template <class GT>
class Labeled_image_mesh_domain_3 {
public:
template <typename Functor>
static
Labeled_image_mesh_domain_3<GT>
create_gray_image_mesh_domain(CGAL::Image_3 image,
Functor image_values_to_subdomain_indices,
double relative_error_bound = 1e-6);
template <typename Functor>
static
Labeled_image_mesh_domain_3<GT>
create_labeled_image_mesh_domain(CGAL::Image_3 image,
Functor image_values_to_subdomain_indices,
double relative_error_bound = 1e-6);
// [...]
};
Which solution do you prefer:
- constructors using a tag, or
- static class functions acting as named constructors?
I personally prefer the named constructors:
- their names map easily from the named of the deprecated classes they replaced,
- they are easier to implement (because there are a lot more parameters, and I use the Boost Parameters library),
but as far as I know that would be the first time we use the named constructors pattern.
Concrete usage would be:
typedef CGAL::Labeled_mesh_domain_3<CGAL::Epick> Domain;
// using named constructors:
Domain domain = Domain::create_gray_image_mesh_domain(my_image, my_functor);
// using the constructors with tags:
Domain domain(my_image, CGAL::Gray_image_mesh_domain_tag(), my_functor);