add detect_features named parameter for create_labeled_image_mesh_domain_with_features

todo : move it to create_labeled_image_mesh_domain and remove
create_labeled_image_mesh_domain_with_features as soon as PR on named
parameters is merged
This commit is contained in:
Jane Tournois 2022-09-27 16:17:25 +02:00
parent 4cdf1dc722
commit bca99f4a18
10 changed files with 141 additions and 10 deletions

View File

@ -114,6 +114,7 @@ BOOST_PARAMETER_NAME( (weights, tag) weights_)
BOOST_PARAMETER_NAME( (p_rng, tag ) p_rng_)
BOOST_PARAMETER_NAME( (null_subdomain_index, tag ) null_subdomain_index_)
BOOST_PARAMETER_NAME( (construct_surface_patch_index, tag ) construct_surface_patch_index_)
BOOST_PARAMETER_NAME( (detect_features, tag ) detect_features_)
// First used in <CGAL/Gray_image_mesh_domain_3.h>
BOOST_PARAMETER_NAME( (image, tag ) image_)

View File

@ -13,6 +13,9 @@
#include <CGAL/Mesh_domain_with_polyline_features_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_3/detect_features_in_image.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Labeled_mesh_domain_3<K> Image_domain;
typedef CGAL::Mesh_domain_with_polyline_features_3<Image_domain> Mesh_domain;
@ -47,7 +50,8 @@ int main(int argc, char* argv[])
/// [Domain creation]
Mesh_domain domain
= Mesh_domain::create_labeled_image_mesh_domain_with_features(image);
= Mesh_domain::create_labeled_image_mesh_domain_with_features(image,
detect_features = CGAL::Mesh_3::Detect_features_in_image());
/// [Domain creation]
CGAL::Bbox_3 bbox = domain.bbox();

View File

@ -24,6 +24,7 @@
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Implicit_to_labeling_function_wrapper.h>
#include <CGAL/Mesh_3/Null_subdomain_index.h>
#include <CGAL/Random.h>
namespace CGAL {

View File

@ -26,6 +26,7 @@
#include <CGAL/Random.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_3/Image_to_labeled_function_wrapper.h>
#include <CGAL/Mesh_3/Null_subdomain_index.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>

View File

@ -55,7 +55,7 @@
#endif
#include <boost/optional.hpp>
#include <CGAL/Mesh_3/detect_features_in_image.h> //needs Null_subdomain_index
#include <CGAL/Mesh_3/Null_subdomain_index.h>
namespace CGAL {
namespace Mesh_3 {
@ -126,6 +126,17 @@ namespace internal {
}
};
template<typename Mesh_domain, typename DetectFunctor>
void detect_features(const CGAL::Image_3& image,
Mesh_domain& domain,
DetectFunctor functor)
{
if (boost::is_same<DetectFunctor, Null_functor>::value)
return;
else
return functor(image, domain);
}
} // end namespace CGAL::Mesh_3::internal
} // end namespace CGAL::Mesh_3
@ -485,6 +496,7 @@ CGAL_IGNORE_BOOST_PARAMETER_NAME_WARNINGS
(image_values_to_subdomain_indices_, *, Null_functor())
(null_subdomain_index_, *, Null_functor())
(construct_surface_patch_index_, *, Null_functor())
(detect_features_, *, Null_functor())
)
)
{
@ -497,7 +509,7 @@ CGAL_IGNORE_BOOST_PARAMETER_NAME_WARNINGS
p::null_subdomain_index = null_subdomain_index_,
p::construct_surface_patch_index = construct_surface_patch_index_);
CGAL::Mesh_3::detect_features_in_image(image_, domain);
CGAL::Mesh_3::internal::detect_features(image_, domain, detect_features_);
return domain;
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2015 GeometryFactory
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Laurent Rineau
#ifndef CGAL_INTERNAL_MESH_3_INTERNAL_NULL_SUBDOMAIN_INDEX
#define CGAL_INTERNAL_MESH_3_INTERNAL_NULL_SUBDOMAIN_INDEX
#include <CGAL/license/Mesh_3.h>
namespace CGAL {
struct Null_subdomain_index {
template <typename T>
bool operator()(const T& x) const { return 0 == x; }
};
}
#endif //CGAL_INTERNAL_MESH_3_INTERNAL_NULL_SUBDOMAIN_INDEX

View File

@ -41,6 +41,8 @@ namespace CGAL
{
namespace Mesh_3
{
namespace internal
{
// Protect the intersection of the object with the box of the image,
// by declaring 1D-features. Note that `CGAL::polylines_to_protect` is
@ -245,6 +247,17 @@ bool detect_features_in_image(const CGAL::Image_3& image, Mesh_domain& domain)
return false;
}
}// namespace internal
struct Detect_features_in_image
{
template<typename Mesh_domain>
void operator()(const CGAL::Image_3& image, Mesh_domain& domain)
{
internal::detect_features_in_image(image, domain);
}
};
}//end namespace Mesh_3
}//end namespace CGAL

View File

@ -0,0 +1,76 @@
// Copyright (c) 2022 GeometryFactory (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Laurent Rineau, Jane Tournois
//
//******************************************************************************
//
//******************************************************************************
#ifndef CGAL_MESH_3_DETECT_FEATURES_ON_IMAGE_BBOX_H
#define CGAL_MESH_3_DETECT_FEATURES_ON_IMAGE_BBOX_H
#include <CGAL/license/Mesh_3.h>
#include <CGAL/Mesh_3/polylines_to_protect.h>
#include <vector>
namespace CGAL
{
namespace Mesh_3
{
namespace internal
{
template<typename Word_type, typename Mesh_domain>
void detect_features_on_bbox_with_know_word_type(const CGAL::Image_3& image,
Mesh_domain& domain)
{
using Gt = typename Mesh_domain::R;
using Point_3 = typename Gt::Point_3;
using Polyline_type = std::vector<Point_3>;
using Polylines = std::vector<Polyline_type>;
Polylines polylines_on_bbox;
CGAL::polylines_to_protect(image, polylines_on_bbox);
domain.add_features(polylines_on_bbox.begin(), polylines_on_bbox.end());
}
template<typename Mesh_domain>
void detect_features_on_bbox(const CGAL::Image_3& image, Mesh_domain& domain)
{
CGAL_IMAGE_IO_CASE(image.image(),
return detect_features_on_bbox_with_know_word_type<Word>(image, domain)
);
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.");
}
}// namespace internal
struct Detect_features_on_image_bbox
{
template<typename Mesh_domain>
void operator()(const CGAL::Image_3& image, Mesh_domain& domain)
{
internal::detect_features_on_bbox(image, domain);
}
};
}//end namespace Mesh_3
}//end namespace CGAL
#endif //CGAL_MESH_3_DETECT_FEATURES_ON_IMAGE_BBOX_H

View File

@ -36,12 +36,7 @@
#include <CGAL/Search_traits_3.h>
#include <CGAL/Orthogonal_incremental_neighbor_search.h>
namespace CGAL {
struct Null_subdomain_index {
template <typename T>
bool operator()(const T& x) const { return 0 == x; }
};
}
#include <CGAL/Mesh_3/Null_subdomain_index.h>
namespace CGAL {
namespace Mesh_3 {

View File

@ -13,6 +13,8 @@
#include "Mesh_function.h"
#include "Facet_extra_criterion.h"
#include <CGAL/Mesh_3/detect_features_in_image.h>
using namespace CGAL::Three;
@ -369,7 +371,8 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage,
(p::image = *pImage,
p::relative_error_bound = 1e-6,
p::construct_surface_patch_index =
[](int i, int j) { return (i * 1000 + j); }
[](int i, int j) { return (i * 1000 + j); },
p::detect_features = CGAL::Mesh_3::Detect_features_in_image()
)
);
}