Improve the API of <CGAL/Mesh_3/polylines_to_protect.h>

Now the word type and the null functor are passed as parameters.
This commit is contained in:
Laurent Rineau 2016-05-20 16:52:35 +02:00
parent ee0fb3b23a
commit 4d38c931ce
3 changed files with 36 additions and 12 deletions

View File

@ -42,7 +42,7 @@ namespace CGAL {
*/ */
template<class Image, template<class Image,
class BGT, class BGT,
typename Image_word_type = unsigned char, typename Image_word_type_ = unsigned char,
typename Subdomain_index = int, typename Subdomain_index = int,
class Null_subdomain_index = Default, class Null_subdomain_index = Default,
class Wrapper_ = Default > class Wrapper_ = Default >
@ -51,7 +51,7 @@ class Labeled_image_mesh_domain_3
<typename Default::Get <typename Default::Get
<Wrapper_, <Wrapper_,
Mesh_3::Image_to_labeled_function_wrapper<Image, BGT, Mesh_3::Image_to_labeled_function_wrapper<Image, BGT,
Image_word_type, Image_word_type_,
Subdomain_index> Subdomain_index>
>::type, >::type,
BGT, BGT,
@ -59,6 +59,7 @@ class Labeled_image_mesh_domain_3
> >
{ {
public: public:
typedef Image_word_type_ Image_word_type;
typedef typename Default::Get typedef typename Default::Get
<Wrapper_, <Wrapper_,
Mesh_3::Image_to_labeled_function_wrapper<Image, BGT, Mesh_3::Image_to_labeled_function_wrapper<Image, BGT,

View File

@ -28,15 +28,20 @@
#include <CGAL/internal/Mesh_3/split_in_polylines.h> #include <CGAL/internal/Mesh_3/split_in_polylines.h>
#include <CGAL/internal/Mesh_3/Graph_manipulations.h> #include <CGAL/internal/Mesh_3/Graph_manipulations.h>
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_list.hpp>
#include <CGAL/Labeled_image_mesh_domain_3.h> // for CGAL::Null_subdomain_index
namespace CGAL { namespace CGAL {
template <typename P> template <typename P,
typename Image_word_type,
typename Null_subdomain_index>
void void
polylines_to_protect(const CGAL::Image_3& cgal_image, polylines_to_protect(const CGAL::Image_3& cgal_image,
const double, const double, const double, const double vx, const double vy, const double vz,
std::vector<std::vector<P> >& polylines) std::vector<std::vector<P> >& polylines,
Image_word_type*,
Null_subdomain_index null)
{ {
typedef typename Kernel_traits<P>::Kernel K; typedef typename Kernel_traits<P>::Kernel K;
typedef P Point_3; typedef P Point_3;
@ -85,7 +90,6 @@ polylines_to_protect(const CGAL::Image_3& cgal_image,
// we have gone too far // we have gone too far
continue; continue;
} }
typedef unsigned char Image_word_type;
typedef tuple<Pixel, Point_3, Image_word_type> Enriched_pixel; typedef tuple<Pixel, Point_3, Image_word_type> Enriched_pixel;
array<array<Enriched_pixel, 2>, 2> square = array<array<Enriched_pixel, 2>, 2> square =
@ -99,9 +103,9 @@ polylines_to_protect(const CGAL::Image_3& cgal_image,
for(int jj = 0; jj < 2; ++jj) for(int jj = 0; jj < 2; ++jj)
{ {
const Pixel& pixel = get<0>(square[ii][jj]); const Pixel& pixel = get<0>(square[ii][jj]);
double x = pixel[0] * cgal_image.vx(); double x = pixel[0] * vx;
double y = pixel[1] * cgal_image.vy(); double y = pixel[1] * vy;
double z = pixel[2] * cgal_image.vz(); double z = pixel[2] * vz;
get<1>(square[ii][jj]) = Point_3(x, y, z); get<1>(square[ii][jj]) = Point_3(x, y, z);
get<2>(square[ii][jj]) = static_cast<Image_word_type>(cgal_image.value(pixel[0], get<2>(square[ii][jj]) = static_cast<Image_word_type>(cgal_image.value(pixel[0],
pixel[1], pixel[1],
@ -340,7 +344,22 @@ case_4:
} }
template <typename P> template <typename P, typename Image_word_type, typename Null_subdomain_index>
void
polylines_to_protect(const CGAL::Image_3& cgal_image,
std::vector<std::vector<P> >& polylines,
Image_word_type* word_type,
Null_subdomain_index null)
{
polylines_to_protect<P>
(cgal_image,
cgal_image.vx(), cgal_image.vy(),cgal_image.vz(),
polylines,
word_type,
null);
}
template <typename P, typename Image_word_type>
void void
polylines_to_protect(const CGAL::Image_3& cgal_image, polylines_to_protect(const CGAL::Image_3& cgal_image,
std::vector<std::vector<P> >& polylines) std::vector<std::vector<P> >& polylines)
@ -348,7 +367,9 @@ polylines_to_protect(const CGAL::Image_3& cgal_image,
polylines_to_protect<P> polylines_to_protect<P>
(cgal_image, (cgal_image,
cgal_image.vx(), cgal_image.vy(),cgal_image.vz(), cgal_image.vx(), cgal_image.vy(),cgal_image.vz(),
polylines); polylines,
(Image_word_type*)0,
CGAL::Null_subdomain_index());
} }
} // namespace CGAL } // namespace CGAL

View File

@ -132,7 +132,9 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage,
if(protect_features && polylines.empty()){ if(protect_features && polylines.empty()){
std::vector<std::vector<Point_3> > polylines_on_bbox; std::vector<std::vector<Point_3> > polylines_on_bbox;
CGAL::polylines_to_protect<Point_3>(*pImage, polylines_on_bbox); CGAL::polylines_to_protect<
Point_3,
Image_mesh_domain::Image_word_type>(*pImage, polylines_on_bbox);
p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end());
} }
if(! polylines.empty()){ if(! polylines.empty()){