From f276cac096f3f5518ee3eeb548a0cbc07bdd807f Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Thu, 1 Mar 2018 10:42:00 +0800 Subject: [PATCH] remove Polyhedron output mesh vsa_mesh_approximation + vsa_mesh_segmentation -> mesh_approximation --- .../vsa_timing_benchmark.cpp | 3 +- .../vsa_approximation_2_example.cpp | 10 +- .../vsa_approximation_example.cpp | 15 +-- .../vsa_class_interface_example.cpp | 5 +- .../vsa_segmentation_example.cpp | 8 +- .../vsa_simple_approximation_example.cpp | 12 +- .../include/CGAL/VSA_approximation.h | 12 +- .../named_params_helper.h | 23 ++-- .../parameters_interface.h | 4 +- ...h_approximation.h => mesh_approximation.h} | 71 +++++----- .../include/CGAL/vsa_mesh_segmentation.h | 124 ------------------ .../vsa_class_interface_test.cpp | 3 +- .../vsa_kernel_test.cpp | 9 +- .../vsa_mesh_approximation_test.cpp | 26 ++-- .../vsa_mesh_segmentation_test.cpp | 8 +- .../vsa_meshing_manifold_test.cpp | 3 +- .../vsa_metric_test.cpp | 5 +- 17 files changed, 102 insertions(+), 239 deletions(-) rename Surface_mesh_approximation/include/CGAL/{vsa_mesh_approximation.h => mesh_approximation.h} (75%) delete mode 100644 Surface_mesh_approximation/include/CGAL/vsa_mesh_segmentation.h diff --git a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp index ad6f67c5fe9..6fc8f790846 100644 --- a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp +++ b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp @@ -76,10 +76,9 @@ int main(int argc, char *argv[]) t0.stop(); std::cerr << "iterations time " << t0.time() << " sec." << std::endl; - Polyhedron mesh_out; t0.reset(); t0.start(); - approx.extract_mesh(mesh_out); + approx.extract_mesh(); t0.stop(); std::cerr << "meshing time " << t0.time() << " sec." << std::endl; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp index ece3e132ce9..0e356674959 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Plane_proxy Plane_proxy; @@ -36,14 +36,14 @@ int main() std::vector proxies; // free function interface with named parameters - CGAL::vsa_mesh_approximation(input, - std::back_inserter(points), - std::back_inserter(triangles), + CGAL::mesh_approximation(input, CGAL::Surface_mesh_approximation::parameters::min_error_drop(0.05). // seeding with minimum error drop nb_of_iterations(40). // set number of clustering iterations after seeding mesh_chord_error(0.3). // set chord approximation error threshold when meshing facet_proxy_map(fpxmap). // get facet partition map - proxies(std::back_inserter(proxies))); // get proxies + proxies(std::back_inserter(proxies)). // get proxies + anchor_points(std::back_inserter(points)). // anchor points + indexed_triangles(std::back_inserter(triangles))); // indexed triangles return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp index 4c8add1f9b9..22926d78166 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; @@ -18,25 +18,22 @@ int main() return EXIT_FAILURE; } - // output polyhedral surface and indexed face set - Polyhedron output; + // output indexed triangles std::vector points; std::vector > triangles; // triplets of indices // free function interface with named parameters - bool valid_polyhedron = CGAL::vsa_mesh_approximation(input, - std::back_inserter(points), - std::back_inserter(triangles), + bool is_manifold = CGAL::mesh_approximation(input, CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding max_nb_proxies(200). // seeding with maximum number of proxies nb_of_iterations(30). // number of clustering iterations after seeding - // output to polyhedron - output_mesh(&output)); // valid when the indexed face set represents a 2-manifold, oriented surface + anchor_points(std::back_inserter(points)). // anchor points + indexed_triangles(std::back_inserter(triangles))); // indexed triangles std::cout << "#anchor points: " << points.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; - if (valid_polyhedron) + if (is_manifold) std::cout << "oriented, 2-manifold output." << std::endl; return EXIT_SUCCESS; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp index 626ab6ad408..5ca56e41417 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp @@ -52,9 +52,8 @@ int main() approx.teleport_proxies(2, 5); approx.run(10); - // mesh and output final polyhedral surface - Polyhedron output; - approx.extract_mesh(output); + // meshing with default parameters + approx.extract_mesh(); return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp index 8e6baad740f..fdad52cd354 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; @@ -29,12 +29,12 @@ int main() Facet_proxy_pmap fpxmap(fidx_map); // free function interface with named parameters - CGAL::vsa_mesh_segmentation(input, - fpxmap, // output segmentation + CGAL::mesh_approximation(input, CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding max_nb_proxies(200). // first stop criterion min_error_drop(0.05). // second stop criterion - nb_of_iterations(30)); // number of iterations after seeding + nb_of_iterations(30). // number of iterations after seeding + facet_proxy_map(fpxmap)); // output facet proxy-id map // TODO: retrieve segments of the segmentation diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp index c3a2551e4f3..206fd93f2b4 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; @@ -18,12 +18,12 @@ int main() // The output will be an indexed triangle mesh std::vector points; std::vector > triangles; - + // free function interface with named parameters - CGAL::vsa_mesh_approximation(input, - std::back_inserter(points), - std::back_inserter(triangles), - CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200)); + CGAL::mesh_approximation(input, + CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200). + anchor_points(std::back_inserter(points)). // anchor points + indexed_triangles(std::back_inserter(triangles))); // indexed triangles std::cout << "#vertices: " << points.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; diff --git a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h index bd5717fae3d..639e67c6d6f 100644 --- a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h @@ -851,11 +851,9 @@ public: } /*! - * @brief Extract the approximated surface mesh. + * @brief Extract the approximated indexed triangle surface. * @note If the extracted surface mesh contains non-manifold facets, * they are not built into the output polyhedron. - * @tparam PolyhedronSurface should be `CGAL::Polyhedron_3` - * @param[out] tm_out output triangle mesh * @param chord_error boundary approximation recursively split criterion * @param is_relative_to_chord set `true` if the chord_error is relative to the the chord length (relative sense), * otherwise it's relative to the average edge length (absolute sense). @@ -864,9 +862,7 @@ public: * @param pca_plane set `true` if use PCA plane fitting, otherwise use the default area averaged plane parameters * @return `true` if the extracted surface mesh is manifold, `false` otherwise. */ - template - bool extract_mesh(PolyhedronSurface &tm_out, - const FT chord_error = FT(5.0), + bool extract_mesh(const FT chord_error = FT(5.0), const bool is_relative_to_chord = false, const bool with_dihedral_angle = false, const bool optimize_anchor_location = true, @@ -896,7 +892,9 @@ public: if (optimize_anchor_location) this->optimize_anchor_location(); - return build_polyhedron_surface(tm_out); + // check manifold + CGAL::Polyhedron_3 tm_test; + return build_polyhedron_surface(tm_test); } /*! diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h index 6ec40fcec15..c346acb9ede 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h @@ -81,14 +81,6 @@ void get_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) { template void get_proxy_map(const Approximation &, internal_np::vsa_no_output_t) {} -template -void get_anchor_vertices(const Approximation &approx, OutputIterator out_itr) { - approx.anchor_vertices(out_itr); -} - -template -void get_anchor_vertices(const Approximation &, internal_np::vsa_no_output_t) {} - template void get_proxies(const Approximation &approx, OutputIterator out_itr) { approx.proxies(out_itr); @@ -97,6 +89,21 @@ void get_proxies(const Approximation &approx, OutputIterator out_itr) { template void get_proxies(const Approximation &, internal_np::vsa_no_output_t) {} +template +void get_anchor_points(const Approximation &approx, OutputIterator out_itr) { + approx.anchor_points(out_itr); +} + +template +void get_anchor_points(const Approximation &, internal_np::vsa_no_output_t) {} + +template +void get_indexed_triangles(const Approximation &approx, OutputIterator out_itr) { + approx.indexed_triangles(out_itr); +} + +template +void get_indexed_triangles(const Approximation &, internal_np::vsa_no_output_t) {} } //end of namespace CGAL #endif //CGAL_NAMED_PARAMETERS_HELPERS_H diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h index 11614092058..0aae82b4670 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h @@ -12,5 +12,5 @@ CGAL_add_named_parameter(mesh_chord_error_t, mesh_chord_error, mesh_chord_error) // output parameters CGAL_add_named_parameter(facet_proxy_map_t, facet_proxy_map, facet_proxy_map) CGAL_add_named_parameter(proxies_t, proxies, proxies) -CGAL_add_named_parameter(anchor_vertices_t, anchor_vertices, anchor_vertices) -CGAL_add_named_parameter(output_mesh_t, output_mesh, output_mesh) +CGAL_add_named_parameter(anchor_points_t, anchor_points, anchor_points) +CGAL_add_named_parameter(indexed_triangles_t, indexed_triangles, indexed_triangles) diff --git a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h similarity index 75% rename from Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h rename to Surface_mesh_approximation/include/CGAL/mesh_approximation.h index 08b8720af0d..22d40ce1363 100644 --- a/Surface_mesh_approximation/include/CGAL/vsa_mesh_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -26,16 +25,12 @@ namespace CGAL { * @tparam TriangleMesh model of `FaceListGraph`. * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, * and no `face_index_map` is given as a named parameter, then the internal one should be initialized. - * @tparam AnchorPointOutputIterator a class model of `OutputIterator` with `GeomTraits::Point_3` value type - * @tparam IndexedTriangleOutputIterator a class model of `OutputIterator` with `std::vector` value type * @tparam NamedParameters a sequence of \ref namedparameters * * @param tm a triangle surface mesh to be approximated - * @param[out] apts_out_itr output iterator over anchor points - * @param[out] tris_out_itr output iterator over indexed triangles (triplets of integers referring to anchor points) * @param np optional sequence of \ref namedparameters among the ones listed below * @return `true` if the indexed triangles represent a valid 2-manifold, oriented surface mesh, and `false` otherwise. - * + * * \cgalNamedParamsBegin * \cgalParamBegin{geom_traits} a geometric traits class instance, model of `Kernel`. * Exact constructions kernels are not supported by this function. @@ -55,25 +50,21 @@ namespace CGAL { * \cgalParamEnd * \cgalParamBegin{mesh_chord_error} maximum chord approximation error used for meshing. * \cgalParamEnd - * \cgalParamBegin{face_proxy_map} property map containing the assigned proxy index of each face of input mesh `tm`. + * \cgalParamBegin{face_proxy_map} a ReadWritePropertyMap with + * `boost::graph_traits::%face_descriptor` as key and `std::size_t` as value type. + * A proxy is a set of connected facets which are placed under the same proxy patch (see \cgalFigureRef{iterations}). + * The proxy-id is contiguous in range [0, number_of_proxies - 1]. * \cgalParamEnd * \cgalParamBegin{proxies} output iterator over proxies. * \cgalParamEnd - * \cgalParamBegin{anchor_vertices} output iterator over anchor vertices, defined on the input mesh `tm`. + * \cgalParamBegin{anchor_points} output iterator over anchor points. * \cgalParamEnd - * \cgalParamBegin{output_mesh} polyhedral surface mesh derived from the indexed facet set. The polyhedron is not empty only - * when the indexed face set represents a 2-manifold, oriented surface triangle mesh. + * \cgalParamBegin{indexed_triangles} output iterator over indexed triangles. * \cgalParamEnd * \cgalNamedParamsEnd */ -template -bool vsa_mesh_approximation(const TriangleMesh &tm, - AnchorPointOutputIterator apts_out_itr, - IndexedTriangleOutputIterator tris_out_itr, - const NamedParameters &np) +template +bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) { using boost::get_param; using boost::choose_param; @@ -119,6 +110,7 @@ bool vsa_mesh_approximation(const TriangleMesh &tm, << ", #relx = " << nb_of_relaxations << std::endl; #endif + // get proxy map typedef typename boost::lookup_named_param_def< internal_np::facet_proxy_map_t, NamedParameters, @@ -127,26 +119,7 @@ bool vsa_mesh_approximation(const TriangleMesh &tm, get_param(np, internal_np::facet_proxy_map), internal_np::vsa_no_output); get_proxy_map(approx, fproxymap); - typedef CGAL::Polyhedron_3 PolyhedronSurface; - PolyhedronSurface tmp_poly; - PolyhedronSurface * const tm_out = choose_param(get_param(np, internal_np::output_mesh), &tmp_poly); - const FT chord_error = choose_param(get_param(np, internal_np::mesh_chord_error), FT(5.0)); - const bool is_manifold = approx.extract_mesh(*tm_out, chord_error); - - // get anchor points - approx.anchor_points(apts_out_itr); - - // get indexed triangles - approx.indexed_triangles(tris_out_itr); - - typedef typename boost::lookup_named_param_def< - internal_np::anchor_vertices_t, - NamedParameters, - internal_np::vsa_no_output_t>::type AnchorVertexOutItr; - AnchorVertexOutItr avtx_out_itr = choose_param( - get_param(np, internal_np::anchor_vertices) , internal_np::vsa_no_output); - get_anchor_vertices(approx, avtx_out_itr); - + // get proxies typedef typename boost::lookup_named_param_def < internal_np::proxies_t, NamedParameters, @@ -155,6 +128,28 @@ bool vsa_mesh_approximation(const TriangleMesh &tm, get_param(np, internal_np::proxies), internal_np::vsa_no_output); get_proxies(approx, pxies_out_itr); + // meshing + const FT chord_error = choose_param(get_param(np, internal_np::mesh_chord_error), FT(5.0)); + const bool is_manifold = approx.extract_mesh(chord_error); + + // get anchor points + typedef typename boost::lookup_named_param_def< + internal_np::anchor_points_t, + NamedParameters, + internal_np::vsa_no_output_t>::type Anchor_point_output_iterator; + Anchor_point_output_iterator apts_out_itr = choose_param( + get_param(np, internal_np::anchor_points) , internal_np::vsa_no_output); + get_anchor_points(approx, apts_out_itr); + + // get indexed triangles + typedef typename boost::lookup_named_param_def< + internal_np::indexed_triangles_t, + NamedParameters, + internal_np::vsa_no_output_t>::type Indexed_triangles_output_iterator; + Indexed_triangles_output_iterator tris_out_itr = choose_param( + get_param(np, internal_np::indexed_triangles) , internal_np::vsa_no_output); + get_indexed_triangles(approx, tris_out_itr); + return is_manifold; } diff --git a/Surface_mesh_approximation/include/CGAL/vsa_mesh_segmentation.h b/Surface_mesh_approximation/include/CGAL/vsa_mesh_segmentation.h deleted file mode 100644 index 59f6fe0f573..00000000000 --- a/Surface_mesh_approximation/include/CGAL/vsa_mesh_segmentation.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H -#define CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H - -#include - - -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace CGAL { - -/*! - * \ingroup PkgTSMA - * @brief Function segments the input mesh into planar parts. - * This function segments the input triangle surface mesh by the Variational Shape Approximation algorithm. - * It fills a property map which associates a segment-id (in [0, number_of_segments -1]) - * or a proxy-id (in [0, number_of_proxies - 1]) to each facet. - * A segment is a set of connected facets which are placed under the same proxy patch (see \cgalFigureRef{iterations}). - * - * @tparam TriangleMesh model of `FaceListGraph`. - * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, - * and no `face_index_map` is given - * as a named parameter, then the internal one should be initialized - * @tparam SegmentPropertyMap a ReadWritePropertyMap with - * `boost::graph_traits::%face_descriptor` as key and `std::size_t` as value type - * @tparam NamedParameters a sequence of \ref namedparameters - * - * @param tm a triangle surface mesh to be segmented - * @param[out] segment_ids the segment or proxy id of each facet - * @param np optional sequence of \ref namedparameters among the ones listed below - * - * \cgalNamedParamsBegin - * \cgalParamBegin{geom_traits} a geometric traits class instance, model of `Kernel`. - * Exact constructions kernels are not supported by this function. - * \cgalParamEnd - * \cgalParamBegin{vertex_point_map} property map with the points associated - * to the vertices of `tm`. Instance of a class model of `ReadWritePropertyMap`. - * \cgalParamEnd - * \cgalParamBegin{seeding_method} selection of seeding method. - * \cgalParamEnd - * \cgalParamBegin{max_nb_proxies} maximum number of proxies to approximate the geometry. - * \cgalParamEnd - * \cgalParamBegin{min_error_drop} minimum error drop of the approximation. - * \cgalParamEnd - * \cgalParamBegin{nb_of_iterations} number of partitioning and fitting iterations after seeding. - * \cgalParamEnd - * \cgalParamBegin{nb_of_relaxations} number of relaxations interleaved within seeding. - * \cgalParamEnd - * \cgalParamBegin{proxies} output iterator over proxies - * \cgalParamEnd - * \cgalNamedParamsEnd - */ -template -void vsa_mesh_segmentation(const TriangleMesh &tm, - const SegmentPropertyMap segment_ids, const NamedParameters &np) -{ - using boost::get_param; - using boost::choose_param; - - typedef typename GetGeomTraits::type Geom_traits; - typedef typename Geom_traits::FT FT; - - typedef typename GetVertexPointMap::type Vertex_point_map; - Vertex_point_map point_pmap = choose_param(get_param(np, internal_np::vertex_point), - get_property_map(vertex_point, const_cast(tm))); - - typedef CGAL::VSA_approximation L21_approx; - typedef typename L21_approx::Error_metric L21_metric; - typedef typename L21_approx::Proxy_fitting L21_proxy_fitting; - - L21_approx approx(tm, point_pmap); - L21_metric l21_metric(tm); - L21_proxy_fitting l21_fitting(tm); - approx.set_metric(l21_metric, l21_fitting); - - // default hierarchical seeding - CGAL::Approximation_seeding_tag method = choose_param( - get_param(np, internal_np::seeding_method), CGAL::Hierarchical); - boost::optional max_nb_proxies = choose_param( - get_param(np, internal_np::max_nb_proxies), boost::optional()); - boost::optional min_error_drop = choose_param( - get_param(np, internal_np::min_error_drop), boost::optional()); - std::size_t nb_of_relaxations = choose_param(get_param(np, internal_np::nb_of_relaxations), 5); - approx.seeding(method, max_nb_proxies, min_error_drop, nb_of_relaxations); - - // reasonable default number of iterations - std::size_t nb_of_iterations_default = max_nb_proxies ? num_faces(tm) / *max_nb_proxies : 30; - nb_of_iterations_default = (std::min)((std::max)( - nb_of_iterations_default, static_cast(20)), static_cast(60)); - const std::size_t nb_of_iterations = choose_param( - get_param(np, internal_np::nb_of_iterations), nb_of_iterations_default); - - approx.run(nb_of_iterations); - -#ifdef CGAL_SURFACE_MESH_APPROXIMATION_DEBUG - std::cout << "#px = " << approx.get_proxies_sizes() - << ", #itr = " << nb_of_iterations - << ", #relx = " << nb_of_relaxations << std::endl; -#endif - - approx.proxy_map(segment_ids); - - typedef typename boost::lookup_named_param_def < - internal_np::proxies_t, - NamedParameters, - internal_np::vsa_no_output_t>::type ProxiesOutItr; - ProxiesOutItr pxies_out_itr = choose_param( - get_param(np, internal_np::proxies), internal_np::vsa_no_output); - get_proxies(approx, pxies_out_itr); -} - -} // end namespace CGAL - -#endif // CGAL_SURFACE_MESH_APPROXIMATION_VSA_MESH_SEGMENTATION_H diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp index f894e9e8789..cf9d54cb97b 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_class_interface_test.cpp @@ -89,8 +89,7 @@ int main() // extract the approximation polyhedron std::cout << "meshing" << std::endl; - Polyhedron out_mesh; - if (approx.extract_mesh(out_mesh, FT(1.0))) + if (approx.extract_mesh(FT(1.0))) std::cout << "manifold." << std::endl; else std::cout << "non-manifold" << std::endl; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp index 154484b2fb9..5cc27698f36 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_kernel_test.cpp @@ -10,7 +10,7 @@ #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; typedef CGAL::Simple_cartesian Sckernel; @@ -29,14 +29,13 @@ int test() { std::vector points; std::vector > triangles; - CGAL::vsa_mesh_approximation(tm, - std::back_inserter(points), - std::back_inserter(triangles), + CGAL::mesh_approximation(tm, CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(6). nb_of_iterations(30). nb_of_relaxations(5). mesh_chord_error(0.5). - output_mesh(&out_mesh)); + anchor_points(std::back_inserter(points)). + indexed_triangles(std::back_inserter(triangles))); return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_approximation_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_approximation_test.cpp index dddd127cda9..f7c2a044933 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_approximation_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_approximation_test.cpp @@ -5,13 +5,13 @@ #include #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; /** - * This file tests the free function CGAL::vsa_mesh_approximation. + * This file tests the free function CGAL::mesh_approximation. */ int main() { @@ -23,16 +23,13 @@ int main() } Polyhedron out_mesh; - std::vector > triangles; - std::vector points; - std::list anchors; - std::vector > proxies; std::map fidxmap; boost::associative_property_map > fpxmap(fidxmap); + std::vector > proxies; + std::vector points; + std::vector > triangles; - CGAL::vsa_mesh_approximation(mesh, - std::back_inserter(points), - std::back_inserter(triangles), + CGAL::mesh_approximation(mesh, CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Incremental). max_nb_proxies(6). nb_of_iterations(30). @@ -40,14 +37,13 @@ int main() mesh_chord_error(0.5). facet_proxy_map(fpxmap). proxies(std::back_inserter(proxies)). - anchor_vertices(std::back_inserter(anchors)). - output_mesh(&out_mesh)); + anchor_points(std::back_inserter(points)). + indexed_triangles(std::back_inserter(triangles))); - std::cout << "#triangles " << triangles.size() << std::endl; - std::cout << "#vertices " << points.size() << std::endl; - std::cout << "#anchor_vertices " << anchors.size() << std::endl; - std::cout << "#proxies " << proxies.size() << std::endl; std::cout << "#fpxmap " << fidxmap.size() << std::endl; + std::cout << "#proxies " << proxies.size() << std::endl; + std::cout << "#vertices " << points.size() << std::endl; + std::cout << "#triangles " << triangles.size() << std::endl; return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_segmentation_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_segmentation_test.cpp index ca26e2a105c..4ed1ed0a204 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_segmentation_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_mesh_segmentation_test.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Plane_proxy Plane_proxy; @@ -13,7 +13,7 @@ typedef boost::unordered_map Facet_index_map; typedef boost::associative_property_map Facet_proxy_pmap; /** - * This file tests the free function CGAL::vsa_mesh_segmentation. + * This file tests the free function CGAL::mesh_approximation. */ int main() { @@ -32,13 +32,13 @@ int main() std::vector proxies; // free function interface with named parameters - CGAL::vsa_mesh_segmentation(input, - fpxmap, // output indexed face set + CGAL::mesh_approximation(input, CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding max_nb_proxies(200). // both maximum number of proxies stop criterion, min_error_drop(0.05). // and minimum error drop stop criterion are specified nb_of_iterations(30). // number of clustering iterations after seeding nb_of_relaxations(5). // number of relaxations in seeding + facet_proxy_map(fpxmap). // output indexed face set proxies(std::back_inserter(proxies))); // number of iterations after seeding return EXIT_SUCCESS; diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp index fff06175e29..60c34ec6c90 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_meshing_manifold_test.cpp @@ -43,8 +43,7 @@ bool test_manifold(const char *file_name, const FT drop = FT(1e-8)) std::cout << "#proxies " << approx.proxies_size() << std::endl; // meshing - Polyhedron mesh_out; - if (approx.extract_mesh(mesh_out)) { + if (approx.extract_mesh()) { std::cout << "Succeeded." << std::endl; return true; } diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp index 5e2ba08a5f3..d340b07882b 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/vsa_metric_test.cpp @@ -104,10 +104,9 @@ int main() if (approx.proxies_size() != 20) return EXIT_FAILURE; - // extract the approximation polyhedron + // extract the approximation std::cout << "meshing" << std::endl; - Polyhedron out_mesh; - if (approx.extract_mesh(out_mesh)) + if (approx.extract_mesh()) std::cout << "manifold." << std::endl; else std::cout << "non-manifold" << std::endl;