diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index e6cb355ba88..4fd0770ce53 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -114,12 +114,10 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES #include -typedef CGAL::Gray_image_mesh_domain_3 > > Gray_image_domain1; -typedef CGAL::Gray_image_mesh_domain_3 > > Gray_image_domain2; -typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3 Gray_image_less_domain; -typedef CGAL::Mesh_domain_with_polyline_features_3 Gray_Image_mesh_less_domain; -typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3 Gray_image_more_domain; -typedef CGAL::Mesh_domain_with_polyline_features_3 Gray_Image_mesh_more_domain; + +typedef CGAL::Gray_image_mesh_domain_3 Gray_image_domain1; +typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3 Gray_image_domain; +typedef CGAL::Mesh_domain_with_polyline_features_3 Gray_Image_mesh_domain; Meshing_thread* cgal_code_mesh_3(const Image* pImage, const Polylines_container& polylines, @@ -149,7 +147,8 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, param.tet_shape = tet_shape; param.manifold = manifold; CGAL::Timer timer; - + Scene_c3t3_item* p_new_item = new Scene_c3t3_item; + p_new_item->setScene(scene); if(!is_gray) { Image_mesh_domain* p_domain = new Image_mesh_domain(*pImage, 1e-6); @@ -164,11 +163,6 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, p_domain->add_features(polylines.begin(), polylines.end()); } timer.start(); - Scene_c3t3_item* p_new_item = new Scene_c3t3_item; - p_new_item->setScene(scene); - - - typedef ::Mesh_function Mesh_function; Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(), p_domain, param); @@ -176,55 +170,24 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, } else { - if(inside_is_less) + Gray_Image_mesh_domain* p_domain = new Gray_Image_mesh_domain(*pImage, CGAL::Compare_to_isovalue(iso_value, inside_is_less), value_outside); + if(protect_features && polylines.empty()) { - Gray_Image_mesh_less_domain* p_domain = new Gray_Image_mesh_less_domain(*pImage, std::bind1st(std::less(), iso_value), value_outside); - if(protect_features && polylines.empty()) - { - std::cerr << "Warning : Automatic detection of features" - << " in Gray images is not implemented yet" << std::endl; - //std::vector > polylines_on_bbox; - //CGAL::polylines_to_protect(*pImage, polylines_on_bbox); - //p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); - } - if(! polylines.empty()){ - // Insert edge in domain - p_domain->add_features(polylines.begin(), polylines.end()); - } - timer.start(); - Scene_c3t3_item* p_new_item = new Scene_c3t3_item; - p_new_item->setScene(scene); - - typedef ::Mesh_function Mesh_function; - Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(), - p_domain, param); - return new Meshing_thread(p_mesh_function, p_new_item); + std::cerr << "Warning : Automatic detection of features" + << " in Gray images is not implemented yet" << std::endl; + //std::vector > polylines_on_bbox; + //CGAL::polylines_to_protect(*pImage, polylines_on_bbox); + //p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); } - else - { - Gray_Image_mesh_more_domain*p_domain = new Gray_Image_mesh_more_domain(*pImage, std::bind1st(std::greater(), iso_value), value_outside); - if(protect_features && polylines.empty()) - { - std::cerr << "Warning : Automatic detection of features" - << " in Gray images is not implemented yet" << std::endl; - //std::vector > polylines_on_bbox; - //CGAL::polylines_to_protect(*pImage, polylines_on_bbox); - //p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end()); - } - if(! polylines.empty()){ - // Insert edge in domain - p_domain->add_features(polylines.begin(), polylines.end()); - } - timer.start(); - Scene_c3t3_item* p_new_item = new Scene_c3t3_item; - p_new_item->setScene(scene); - - - typedef ::Mesh_function Mesh_function; - Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(), - p_domain, param); - return new Meshing_thread(p_mesh_function, p_new_item); + if(! polylines.empty()){ + // Insert edge in domain + p_domain->add_features(polylines.begin(), polylines.end()); } + timer.start(); + typedef ::Mesh_function Mesh_function; + Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(), + p_domain, param); + return new Meshing_thread(p_mesh_function, p_new_item); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Polyhedron_demo_mesh_3_labeled_mesh_domain_3.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Polyhedron_demo_mesh_3_labeled_mesh_domain_3.h index 3c6ecfa116e..87054a9a031 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Polyhedron_demo_mesh_3_labeled_mesh_domain_3.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Polyhedron_demo_mesh_3_labeled_mesh_domain_3.h @@ -34,6 +34,18 @@ namespace CGAL { +struct Compare_to_isovalue { + float iso_value; + bool less; + + Compare_to_isovalue(float iso_value, bool less) + : iso_value(iso_value), less(less) {} + + bool operator()(float x) const { + return (x < iso_value) == less; + } +}; + /** * \class Polyhedron_demo_labeled_mesh_domain_3 * LabeledDomain must be a Labeled_mesh_domain_3 @@ -85,17 +97,10 @@ public: p_rng) {} - ///Constructors for the Gray-level Images + ///Constructor for the Gray-level Images Polyhedron_demo_labeled_mesh_domain_3( const Image& img, - const std::binder1st > iso_value_transform, - const float value_outside) - : Base(img, iso_value_transform, value_outside) - {} - - Polyhedron_demo_labeled_mesh_domain_3( - const Image& img, - const std::binder1st > iso_value_transform, + const Compare_to_isovalue iso_value_transform, const float value_outside) : Base(img, iso_value_transform, value_outside) {}