From 7ce41550b3919d3f888ecf072295ddaf216e9021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 8 Nov 2013 17:06:34 +0100 Subject: [PATCH] rename all the function consistently --- .../timing_benchmark_in_user_manual.cpp | 4 +- .../PackageDescription.txt | 8 +- .../Surface_Mesh_Segmentation.txt | 38 ++-- .../Surface_mesh_segmentation/examples.txt | 8 +- ...ues_example.cpp => sdf_values_example.cpp} | 6 +- ... segmentation_from_sdf_values_example.cpp} | 6 +- ...> segmentation_via_sdf_values_example.cpp} | 2 +- ...via_sdf_values_with_facet_ids_example.cpp} | 4 +- .../Surface_mesh_segmentation/Filters.h | 1 + .../SDF_calculation.h | 1 + .../include/CGAL/mesh_segmentation.h | 197 +++++++++--------- .../Fast_sdf_calculation_test.cpp | 8 +- .../mesh_segmentation_test.cpp | 4 +- ...st_compute_sdf_values_and_segment_gmpq.cpp | 2 +- 14 files changed, 146 insertions(+), 143 deletions(-) rename Surface_mesh_segmentation/examples/Surface_mesh_segmentation/{compute_sdf_values_example.cpp => sdf_values_example.cpp} (87%) rename Surface_mesh_segmentation/examples/Surface_mesh_segmentation/{segment_from_sdf_values_example.cpp => segmentation_from_sdf_values_example.cpp} (92%) rename Surface_mesh_segmentation/examples/Surface_mesh_segmentation/{compute_sdf_values_and_segment_example.cpp => segmentation_via_sdf_values_example.cpp} (93%) rename Surface_mesh_segmentation/examples/Surface_mesh_segmentation/{compute_sdf_values_and_segment_with_facet_ids_example.cpp => segmentation_via_sdf_values_with_facet_ids_example.cpp} (94%) diff --git a/Surface_mesh_segmentation/benchmark/Surface_mesh_segmentation/timing_benchmark_in_user_manual.cpp b/Surface_mesh_segmentation/benchmark/Surface_mesh_segmentation/timing_benchmark_in_user_manual.cpp index 3a3c1107082..95a67358e28 100644 --- a/Surface_mesh_segmentation/benchmark/Surface_mesh_segmentation/timing_benchmark_in_user_manual.cpp +++ b/Surface_mesh_segmentation/benchmark/Surface_mesh_segmentation/timing_benchmark_in_user_manual.cpp @@ -35,7 +35,7 @@ double compute_and_time_sdf(const Polyhedron& mesh, Facet_with_id_pmap min_max_sdf = CGAL::compute_sdf_values(mesh, sdf_values); + std::pair min_max_sdf = CGAL::sdf_values(mesh, sdf_values); timer.stop(); std::cout << " minimum SDF: " << min_max_sdf.first << " maximum SDF: " << min_max_sdf.second << std::endl; std::cout << " SDF Time: " << timer.time() << std::endl; @@ -50,7 +50,7 @@ double compute_and_time_segmentation(const Polyhedron& mesh, Facet_with_id_pmap< CGAL::Timer timer; timer.start(); - int number_of_segments = CGAL::segment_from_sdf_values(mesh, sdf_values, segment_property_map, cluster); + int number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_values, segment_property_map, cluster); timer.stop(); std::cout << " number of segments: " << number_of_segments << std::endl; std::cout << " Segmentation Time with " << cluster << " clusters : " << timer.time() << std::endl; diff --git a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/PackageDescription.txt b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/PackageDescription.txt index 8b453c5bcbd..50a1bc99995 100644 --- a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/PackageDescription.txt +++ b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/PackageDescription.txt @@ -32,9 +32,9 @@ - `#SegmentationGeomTraits` ## Main Functions ## -- `#CGAL::compute_sdf_values()` -- `#CGAL::postprocess_sdf_values()` -- `#CGAL::segment_from_sdf_values()` -- `#CGAL::compute_sdf_values_and_segment()` +- `#CGAL::sdf_values()` +- `#CGAL::sdf_values_postprocessing()` +- `#CGAL::segmentation_from_sdf_values()` +- `#CGAL::segmentation_via_sdf_values()` */ diff --git a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Surface_Mesh_Segmentation.txt b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Surface_Mesh_Segmentation.txt index f23289bce39..21877b5fc00 100644 --- a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Surface_Mesh_Segmentation.txt +++ b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Surface_Mesh_Segmentation.txt @@ -45,7 +45,7 @@ Each ray is truncated into a segment, its endpoints being the apex of the cone a Using the lengths of these truncated rays, which intuitively correspond to a local volume sampling, the raw SDF value is computed by first applying an outlier removal procedure and then taking the average of the lengths. -The raw SDF values are computed through function `compute_sdf_values()`, setting `postprocess` to `false`. +The raw SDF values are computed through function `sdf_values()`, setting `postprocess` to `false`. \note This package also accepts input meshes with holes. In such a case, rays that can not be truncated to segments, or rays that form an obtuse angle with the inward-normal of the first intersected facet are not accepted. @@ -57,7 +57,7 @@ the result of several post-processing steps: - Facets with no raw SDF values are assigned the average raw SDF value of their edge-adjacent neighbors. If there is still a facet having no SDF value, the minimum amongst all the SDF values is assigned to it (this is a deviation from the description of the algorithm in \cgalCite{Shapira2008Consistent}). -The main reason for not assigning 0 to facets with no SDF values is that it can obstruct log-normalization process done at the beginning of `segment_from_sdf_values()`. +The main reason for not assigning 0 to facets with no SDF values is that it can obstruct log-normalization process done at the beginning of `segmentation_from_sdf_values()`. - A bilateral smoothing \cgalCite{Tomasi1998Bilateral} is applied. This smoothing technique removes the noise while trying to keep fast changes on SDF values unchanged since they are natural candidates for segment boundaries. @@ -70,7 +70,7 @@ The main reason for not assigning 0 to facets with no SDF values is that it can Large range parameters make smoothing closer to Gaussian smoothing and may also lead to over-smoothed SDF values. - SDF values are linearly normalized between [0,1]. -These post-processing steps can be applied to raw SDF values (or an alternative set of similar scalar values associated with facets) using the function `postprocess_sdf_values()`. +These post-processing steps can be applied to raw SDF values (or an alternative set of similar scalar values associated with facets) using the function `sdf_values_postprocessing()`. \subsection Surface_mesh_segmentationSoftClustering Soft Clustering @@ -141,7 +141,7 @@ Influence of the smoothness parameter lambda over the segmentation (using 10 clu The hard clustering assigns a cluster id to each facet (see \cgalFigureRef{Cluster_vs_segment} (a)). A segment consists in a set of connected facets in the same cluster (see \cgalFigureRef{Cluster_vs_segment} (b)). -By default the function `segment_from_sdf_values()` assigns to each facet the id of its segment. +By default the function `segmentation_from_sdf_values()` assigns to each facet the id of its segment. It assigns to each facet the id of its cluster when `output_cluster_ids` is set to `true`. @@ -153,16 +153,16 @@ Clusters and segments. The input number of clusters is set to 5. (a) Resu \subsection Surface_mesh_segmentationAPI Summary Four functions are provided: - - `compute_sdf_values()` : computes the SDF value of each facet of an input mesh in either raw or post-processed form. + - `sdf_values()` : computes the SDF value of each facet of an input mesh in either raw or post-processed form. SDF values are associated to facets using a property map (see \ref Chapter_CGAL_and_Boost_Property_Maps "CGAL and Boost Property Maps"). - - `postprocess_sdf_values()` : post-processes raw SDF values. The post-processing is decoupled from - the function `compute_sdf_values()` to allow the use of alternative methods to compute SDF values or additional post-processing step. - - `segment_from_sdf_values()` : computes the mesh segmentation from the SDF values of the facets of an input mesh. + - `sdf_values_postprocessing()` : post-processes raw SDF values. The post-processing is decoupled from + the function `sdf_values()` to allow the use of alternative methods to compute SDF values or additional post-processing step. + - `segmentation_from_sdf_values()` : computes the mesh segmentation from the SDF values of the facets of an input mesh. The input SDF values can be any set of scalar values associated to each facet as long as they have been normalized between 0 and 1. This function allows using the same SDF values with different parameters for the segmentation stage. The segment or cluster ids are associated to the facets using a property map. - - `compute_sdf_values_and_segment()` : combines the three functions above. + - `segmentation_via_sdf_values()` : combines the three functions above. These functions expect as input a triangulated surface mesh bounding a 3D solid object, with the following properties: @@ -181,29 +181,29 @@ This operation is reliable when the `AABBTraits` model provided has exact predic \section SDFExamples Examples \subsection Example_1 Example: Computation of SDF Values -\cgalExample{Surface_mesh_segmentation/compute_sdf_values_example.cpp} +\cgalExample{Surface_mesh_segmentation/sdf_values_example.cpp} \subsection Example_2 Example: Segmentation from SDF Values -\cgalExample{Surface_mesh_segmentation/segment_from_sdf_values_example.cpp} +\cgalExample{Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp} \subsubsection Example_3 Computation of SDF Values and Segmentation -The function `compute_sdf_values_and_segment()` combines the computation of sdf values, the post-processing and the segmentation. +The function `segmentation_via_sdf_values()` combines the computation of sdf values, the post-processing and the segmentation. Note that when computing several segmentations of a mesh with different parameters (i.e. number of levels, and smoothing lambda), -it is advised to first compute the SDF values using `compute_sdf_values()` and use them in calls of the function `segment_from_sdf_values()`. +it is advised to first compute the SDF values using `sdf_values()` and use them in calls of the function `segmentation_from_sdf_values()`. -\cgalExample{Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp} +\cgalExample{Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp} \subsection Surface_mesh_segmentationUsingapolyhedron Using a Polyhedron with an ID per Facet The previous examples use a `std::map` as property maps for storing the SDF values and the segmentation results. This example uses a polyhedron type with a facet type storing an extra ID field, together with a vector, as underlying data structure in the property maps. The main advantage is to decrease from log to constant the complexity for accessing the data associated to facets. -\cgalExample{Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp} +\cgalExample{Surface_mesh_segmentation/segmentation_via_sdf_values_with_facet_ids_example.cpp}
\section Performances Performances - + -The following tables provide the runtime of the functions `compute_sdf_values()` and `segment_from_sdf_values()`. +The following tables provide the runtime of the functions `sdf_values()` and `segmentation_from_sdf_values()`. The results were produced with the release 4.X of \cgal, on an Intel i7 3.2 Ghz laptop with 8 GB RAM, compiled by Visual C++ 2010 with /O2 option. The polyhedron types are using `Polyhedron_items_with_id_3` as item class. The models used for the benchmarks are the dinosaur model with 7,828 facets, the bear model with 20,188 facets and the elephant model with 88,928 facets. @@ -211,7 +211,7 @@ The models used for the benchmarks are the dinosaur model with 7,828 face \todo Update release number as well as first introduced in. -Runtime in seconds of `compute_sdf_values()` with 25 rays showing the cost of the robustness: +Runtime in seconds of `sdf_values()` with 25 rays showing the cost of the robustness:
Number of triangles | `%Simple_cartesian` | `%Exact_predicates_inexact_constructions_kernel` (`EPICK`) @@ -231,7 +231,7 @@ Number of triangles | `%Simple_cartesian` | `%Exact_predicates_inexact_
--> -Runtime in milliseconds of `segment_from_sdf_values()` (using `%Simple_cartesian` or `EPICK` gives the same results), +Runtime in milliseconds of `segmentation_from_sdf_values()` (using `%Simple_cartesian` or `EPICK` gives the same results), the graph-cut part is using the library MaxFlow v2.21:
diff --git a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/examples.txt b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/examples.txt index 4e315d32e2e..2dc6fcada32 100644 --- a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/examples.txt +++ b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/examples.txt @@ -1,4 +1,4 @@ -/// \example Surface_mesh_segmentation/compute_sdf_values_example.cpp -/// \example Surface_mesh_segmentation/segment_from_sdf_values_example.cpp -/// \example Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp -/// \example Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp +/// \example Surface_mesh_segmentation/sdf_values_example.cpp +/// \example Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp +/// \example Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp +/// \example Surface_mesh_segmentation/segmentation_via_sdf_values_with_facet_ids_example.cpp diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/sdf_values_example.cpp similarity index 87% rename from Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp rename to Surface_mesh_segmentation/examples/Surface_mesh_segmentation/sdf_values_example.cpp index 23d12384d24..31cdac0c53f 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/sdf_values_example.cpp @@ -31,14 +31,14 @@ int main() // compute SDF values std::pair min_max_sdf = - CGAL::compute_sdf_values(mesh, sdf_property_map, cone_angle, number_of_rays); + CGAL::sdf_values(mesh, sdf_property_map, cone_angle, number_of_rays); // It is possible to compute the raw SDF values and post-process them through // the following two lines - // CGAL::compute_sdf_values(mesh, sdf_property_map, cone_angle, number_of_rays, false); + // CGAL::sdf_values(mesh, sdf_property_map, cone_angle, number_of_rays, false); // std::pair min_max_sdf = - // CGAL::postprocess_sdf_values(mesh, sdf_property_map); + // CGAL::sdf_values_postprocessing(mesh, sdf_property_map); // print minimum & maximum SDF values std::cout << "minimum SDF: " << min_max_sdf.first diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp similarity index 92% rename from Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp rename to Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp index f53eae594a2..7749f7745a1 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segment_from_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp @@ -27,7 +27,7 @@ int main() boost::associative_property_map sdf_property_map(internal_sdf_map); // compute SDF values using default parameters for number of rays, and cone angle - CGAL::compute_sdf_values(mesh, sdf_property_map); + CGAL::sdf_values(mesh, sdf_property_map); // create a property-map for segment-ids typedef std::map Facet_int_map; @@ -36,7 +36,7 @@ int main() // segment the mesh using default parameters for number of levels, and smoothing lambda // Any other scalar values can be used instead of using SDF values computed using the CGAL function - int number_of_segments = CGAL::segment_from_sdf_values(mesh, sdf_property_map, segment_property_map); + int number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map); std::cout << "Number of segments: " << number_of_segments << std::endl; // print segment-ids @@ -52,6 +52,6 @@ int main() // Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation. // This feature is relevant for segmenting the mesh several times with different parameters. - CGAL::segment_from_sdf_values( + CGAL::segmentation_from_sdf_values( mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda); } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp similarity index 93% rename from Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp rename to Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp index 5447ed4bd7f..ad7a754681c 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp @@ -27,7 +27,7 @@ int main() boost::associative_property_map segment_property_map(internal_segment_map); // calculate SDF values and segment the mesh using default parameters. - int number_of_segments = CGAL::compute_sdf_values_and_segment(mesh, segment_property_map); + int number_of_segments = CGAL::segmentation_via_sdf_values(mesh, segment_property_map); std::cout << "Number of segments: " << number_of_segments << std::endl; diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_with_facet_ids_example.cpp similarity index 94% rename from Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp rename to Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_with_facet_ids_example.cpp index 0e34dab24c1..68b739b2a1a 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/compute_sdf_values_and_segment_with_facet_ids_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_with_facet_ids_example.cpp @@ -55,7 +55,7 @@ int main() std::vector sdf_values(mesh.size_of_facets()); Facet_with_id_pmap sdf_property_map(sdf_values); - CGAL::compute_sdf_values(mesh, sdf_property_map); + CGAL::sdf_values(mesh, sdf_property_map); // access SDF values (with constant-complexity) for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); @@ -68,7 +68,7 @@ int main() std::vector segment_ids(mesh.size_of_facets()); Facet_with_id_pmap segment_property_map(segment_ids); - CGAL::segment_from_sdf_values(mesh, sdf_property_map, segment_property_map); + CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map); // access segment-ids (with constant-complexity) for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h index fce95311ace..2e528a4a696 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/Filters.h @@ -12,6 +12,7 @@ #include #include #include +#include #include diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h index e9a1555e747..de0ec07b5aa 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/Surface_mesh_segmentation/include/CGAL/mesh_segmentation.h b/Surface_mesh_segmentation/include/CGAL/mesh_segmentation.h index 2e3f00827ba..6df29d8dd3f 100644 --- a/Surface_mesh_segmentation/include/CGAL/mesh_segmentation.h +++ b/Surface_mesh_segmentation/include/CGAL/mesh_segmentation.h @@ -20,17 +20,17 @@ template std::pair -compute_sdf_values( const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - bool postprocess = true, - GeomTraits traits = GeomTraits()) +sdf_values( const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + bool postprocess = true, + GeomTraits traits = GeomTraits()) { internal::Surface_mesh_segmentation algorithm(polyhedron, traits); - return algorithm.calculate_sdf_values(cone_angle, number_of_rays, sdf_values, - postprocess); + return algorithm.calculate_sdf_values(cone_angle, number_of_rays, + sdf_values_map, postprocess); } /// @endcond @@ -49,10 +49,10 @@ compute_sdf_values( const Polyhedron& polyhedron, * @tparam GeomTraits a model of SegmentationGeomTraits * * @param polyhedron surface mesh on which SDF values are computed - * @param[out] sdf_values the SDF value of each facet + * @param[out] sdf_values_map the SDF value of each facet * @param cone_angle opening angle in radians for the cone of each facet * @param number_of_rays number of rays picked in the cone of each facet. In our experiments, we observe that increasing the number of rays beyond the default has little effect on the quality of the segmentation result - * @param postprocess if `true`, `CGAL::postprocess_sdf_values` is called on raw SDF value computed. + * @param postprocess if `true`, `CGAL::sdf_values_postprocessing` is called on raw SDF value computed. * @param traits traits class * * @return minimum and maximum raw SDF values if @a postprocess is `true`, otherwise minimum and maximum SDF values (before linear normalization) @@ -63,15 +63,15 @@ template std::pair -compute_sdf_values( const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - bool postprocess = true, - GeomTraits traits = GeomTraits()) +sdf_values( const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + bool postprocess = true, + GeomTraits traits = GeomTraits()) { - return compute_sdf_values - (polyhedron, sdf_values, cone_angle, number_of_rays, postprocess, traits); + return sdf_values + (polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits); } @@ -82,7 +82,7 @@ compute_sdf_values( const Polyhedron& polyhedron, * Post-processing steps applied : * - Facets with -1 SDF values are assigned the average SDF value of their edge-adjacent neighbors. * If there is still a facet having -1 SDF value, the minimum valid SDF value assigned to it. Note that this step is not inherited from the paper. - * The main reason for not assigning 0 to facets with no SDF values (i.e. -1) is that it can obstruct log-normalization process which takes place at the beginning of `CGAL::segment_from_sdf_values`. + * The main reason for not assigning 0 to facets with no SDF values (i.e. -1) is that it can obstruct log-normalization process which takes place at the beginning of `CGAL::segmentation_from_sdf_values`. * - SDF values are smoothed with bilateral filtering. * - SDF values are linearly normalized between [0,1]. * @@ -95,17 +95,18 @@ compute_sdf_values( const Polyhedron& polyhedron, * @tparam SDFPropertyMap a `ReadWritePropertyMap` with `Polyhedron::Facet_const_handle` as key and `double` as value type * * @param polyhedron surface mesh on which SDF values are computed - * @param[in, out] sdf_values the SDF value of each facet + * @param[in, out] sdf_values_map the SDF value of each facet * * @return minimum and maximum SDF values before linear normalization */ template std::pair -postprocess_sdf_values(const Polyhedron& polyhedron, SDFPropertyMap sdf_values) +sdf_values_postprocessing(const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map) { CGAL_precondition(polyhedron.is_pure_triangle()); return internal::Postprocess_sdf_values().postprocess(polyhedron, - sdf_values); + sdf_values_map); } @@ -117,7 +118,7 @@ postprocess_sdf_values(const Polyhedron& polyhedron, SDFPropertyMap sdf_values) * or a cluster-id (in [0, `number_of_clusters` -1]) to each facet. * A segment is a set of connected facets which are placed under the same cluster (see \cgalFigureRef{Cluster_vs_segment}). * - * \note Log-normalization is applied on `sdf_values` before segmentation. + * \note Log-normalization is applied on `sdf_values_map` before segmentation. * As described in the original paper \cgalCite{shapira2008consistent}, * this normalization is done to preserve thin parts of the mesh * by increasing the distance between smaller SDF values and reducing @@ -134,7 +135,7 @@ postprocess_sdf_values(const Polyhedron& polyhedron, SDFPropertyMap sdf_values) * @tparam GeomTraits a model of SegmentationGeomTraits * * @param polyhedron surface mesh corresponding to the SDF values - * @param sdf_values the SDF value of each facet between [0-1] + * @param sdf_values_map the SDF value of each facet between [0-1] * @param[out] segment_ids the segment or cluster id of each facet * @param number_of_clusters number of clusters for the soft clustering * @param smoothing_lambda factor which indicates the importance of the surface features for the energy minimization. It is recommended to choose a value in the interval [0,1]. See the section \ref Surface_mesh_segmentationGraphCut for more details. @@ -150,17 +151,17 @@ template int -segment_from_sdf_values( const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - SegmentPropertyMap segment_ids, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - GeomTraits traits = GeomTraits()) +segmentation_from_sdf_values( const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + SegmentPropertyMap segment_ids, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + GeomTraits traits = GeomTraits()) { internal::Surface_mesh_segmentation algorithm( polyhedron, traits); - return algorithm.partition(number_of_clusters, smoothing_lambda, sdf_values, + return algorithm.partition(number_of_clusters, smoothing_lambda, sdf_values_map, segment_ids, !output_cluster_ids); } @@ -172,14 +173,14 @@ template < bool Fast_sdf_calculation_mode, class Polyhedron, #endif > int -compute_sdf_values_and_segment(const Polyhedron& polyhedron, - SegmentPropertyMap segment_ids, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - GeomTraits traits = GeomTraits()) +segmentation_via_sdf_values(const Polyhedron& polyhedron, + SegmentPropertyMap segment_ids, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + GeomTraits traits = GeomTraits()) { typedef std::map< typename Polyhedron::Facet_const_handle, double> Facet_double_map; @@ -187,9 +188,9 @@ compute_sdf_values_and_segment(const Polyhedron& polyhedron, boost::associative_property_map sdf_property_map( internal_sdf_map); - compute_sdf_values, GeomTraits> + sdf_values, GeomTraits> (polyhedron, sdf_property_map, cone_angle, number_of_rays, true, traits); - return segment_from_sdf_values, SegmentPropertyMap, GeomTraits> + return segmentation_from_sdf_values, SegmentPropertyMap, GeomTraits> (polyhedron, sdf_property_map, segment_ids, number_of_clusters, smoothing_lambda, output_cluster_ids, traits); } @@ -200,14 +201,14 @@ compute_sdf_values_and_segment(const Polyhedron& polyhedron, * \ingroup PkgSurfaceSegmentation * @brief Function computing the segmentation of a surface mesh. * - * This function is equivalent to calling the functions `CGAL::compute_sdf_values()` and - * `CGAL::segment_from_sdf_values()` with the same parameters. + * This function is equivalent to calling the functions `CGAL::sdf_values()` and + * `CGAL::segmentation_from_sdf_values()` with the same parameters. * * \note There is no direct relation between the parameter `number_of_clusters` * and the final number of segments after segmentation. However, setting a large number of clusters will result in a detailed segmentation of the mesh with a large number of segments. * \note For computing segmentations of the mesh with different parameters (i.e. number of levels, and smoothing lambda), - * it is more efficient to first compute the SDF values using `CGAL::compute_sdf_values()` and use them in different calls to - * `CGAL::segment_from_sdf_values()`. + * it is more efficient to first compute the SDF values using `CGAL::sdf_values()` and use them in different calls to + * `CGAL::segmentation_from_sdf_values()`. * * @pre @a polyhedron.is_pure_triangle() * @pre @a number_of_clusters > 0 @@ -233,16 +234,16 @@ template < class Polyhedron, class SegmentPropertyMap, class GeomTraits #endif > int -compute_sdf_values_and_segment(const Polyhedron& polyhedron, - SegmentPropertyMap segment_ids, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - GeomTraits traits = GeomTraits()) +segmentation_via_sdf_values(const Polyhedron& polyhedron, + SegmentPropertyMap segment_ids, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + GeomTraits traits = GeomTraits()) { - return compute_sdf_values_and_segment + return segmentation_via_sdf_values (polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters, smoothing_lambda, output_cluster_ids, traits); } @@ -251,73 +252,73 @@ compute_sdf_values_and_segment(const Polyhedron& polyhedron, #ifdef BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS template std::pair -compute_sdf_values(const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - bool postprocess = true, - typename Polyhedron::Traits traits = typename Polyhedron::Traits()) +sdf_values(const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + bool postprocess = true, + typename Polyhedron::Traits traits = typename Polyhedron::Traits()) { - return compute_sdf_values - (polyhedron, sdf_values, cone_angle, number_of_rays, postprocess, traits); + return sdf_values + (polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits); } template < class Polyhedron, class SDFPropertyMap> std::pair -compute_sdf_values(const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - bool postprocess = true, - typename Polyhedron::Traits traits = typename Polyhedron::Traits()) +sdf_values( const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + bool postprocess = true, + typename Polyhedron::Traits traits = typename Polyhedron::Traits()) { - return compute_sdf_values - (polyhedron, sdf_values, cone_angle, number_of_rays, postprocess, traits); + return sdf_values + (polyhedron, sdf_values_map, cone_angle, number_of_rays, postprocess, traits); } template int -segment_from_sdf_values(const Polyhedron& polyhedron, - SDFPropertyMap sdf_values, - SegmentPropertyMap segment_ids, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - typename Polyhedron::Traits traits = typename Polyhedron::Traits()) +segmentation_from_sdf_values(const Polyhedron& polyhedron, + SDFPropertyMap sdf_values_map, + SegmentPropertyMap segment_ids, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + typename Polyhedron::Traits traits = typename Polyhedron::Traits()) { - return segment_from_sdf_values - (polyhedron, sdf_values, segment_ids, number_of_clusters, smoothing_lambda, + return segmentation_from_sdf_values + (polyhedron, sdf_values_map, segment_ids, number_of_clusters, smoothing_lambda, output_cluster_ids, traits); } template int -compute_sdf_values_and_segment(const Polyhedron& polyhedron, - SegmentPropertyMap segment_ids, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - typename Polyhedron::Traits traits = typename Polyhedron::Traits()) +segmentation_via_sdf_values(const Polyhedron& polyhedron, + SegmentPropertyMap segment_ids, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + typename Polyhedron::Traits traits = typename Polyhedron::Traits()) { - return compute_sdf_values_and_segment< Fast_sdf_calculation_mode, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits> + return segmentation_via_sdf_values< Fast_sdf_calculation_mode, Polyhedron, SegmentPropertyMap, typename Polyhedron::Traits> (polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters, smoothing_lambda, output_cluster_ids, traits); } template int -compute_sdf_values_and_segment(const Polyhedron& polyhedron, - SegmentPropertyMap segment_ids, - double cone_angle = 2.0 / 3.0 * CGAL_PI, - int number_of_rays = 25, - int number_of_clusters = 5, - double smoothing_lambda = 0.26, - bool output_cluster_ids = false, - typename Polyhedron::Traits traits = typename Polyhedron::Traits()) +segmentation_via_sdf_values(const Polyhedron& polyhedron, + SegmentPropertyMap segment_ids, + double cone_angle = 2.0 / 3.0 * CGAL_PI, + int number_of_rays = 25, + int number_of_clusters = 5, + double smoothing_lambda = 0.26, + bool output_cluster_ids = false, + typename Polyhedron::Traits traits = typename Polyhedron::Traits()) { - return compute_sdf_values_and_segment + return segmentation_via_sdf_values (polyhedron, segment_ids, cone_angle, number_of_rays, number_of_clusters, smoothing_lambda, output_cluster_ids, traits); } diff --git a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/Fast_sdf_calculation_test.cpp b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/Fast_sdf_calculation_test.cpp index dcdfc890d6b..d6d3fef2f16 100644 --- a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/Fast_sdf_calculation_test.cpp +++ b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/Fast_sdf_calculation_test.cpp @@ -26,14 +26,14 @@ int main(void) Facet_double_map internal_map; CGAL::Timer timer; timer.start(); - std::pair min_max_sdf = CGAL::compute_sdf_values(mesh, + std::pair min_max_sdf = CGAL::sdf_values(mesh, boost::associative_property_map(internal_map) ); std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl; std::cout << "Calculation time (fast traversal on): *** " << timer.time() << std::endl; timer.reset(); Facet_double_map internal_map_2; - min_max_sdf = CGAL::compute_sdf_values(mesh, + min_max_sdf = CGAL::sdf_values(mesh, boost::associative_property_map(internal_map_2) ); std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl; std::cout << "Calculation time (fast traversal off): *** " << timer.time() << std::endl; @@ -42,7 +42,7 @@ int main(void) typedef std::map Facet_int_map; Facet_int_map internal_segment_map; // calculate SDF values and segment the mesh using default parameters. - int number_of_segments = CGAL::compute_sdf_values_and_segment(mesh, + int number_of_segments = CGAL::segmentation_via_sdf_values(mesh, boost::associative_property_map(internal_segment_map)); std::cout << "Number of segments: " << number_of_segments << std::endl; std::cout << "Calculation time (fast traversal on): *** " << timer.time() << std::endl; @@ -50,7 +50,7 @@ int main(void) timer.reset(); Facet_int_map internal_segment_map_2; // calculate SDF values and segment the mesh using default parameters. - number_of_segments = CGAL::compute_sdf_values_and_segment(mesh, + number_of_segments = CGAL::segmentation_via_sdf_values(mesh, boost::associative_property_map(internal_segment_map_2)); std::cout << "Number of segments: " << number_of_segments << std::endl; std::cout << "Calculation time (fast traversal off): *** " << timer.time() << std::endl; diff --git a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/mesh_segmentation_test.cpp b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/mesh_segmentation_test.cpp index 9b9b9ce279b..1492da20b13 100644 --- a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/mesh_segmentation_test.cpp +++ b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/mesh_segmentation_test.cpp @@ -25,14 +25,14 @@ int main(void) Facet_double_map internal_map; boost::associative_property_map sdf_property_map(internal_map); - std::pair min_max_sdf = CGAL::compute_sdf_values(mesh, sdf_property_map); + std::pair min_max_sdf = CGAL::sdf_values(mesh, sdf_property_map); std::cout << "minimum sdf: " << min_max_sdf.first << " maximum sdf: " << min_max_sdf.second << std::endl; typedef std::map Facet_int_map; Facet_int_map internal_segment_map; boost::associative_property_map segment_property_map(internal_segment_map); - int nb_segments = CGAL::segment_from_sdf_values( + int nb_segments = CGAL::segmentation_from_sdf_values( mesh, sdf_property_map, segment_property_map); if(nb_segments != 3) diff --git a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/test_compute_sdf_values_and_segment_gmpq.cpp b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/test_compute_sdf_values_and_segment_gmpq.cpp index de3cb3a95b8..2108ce20e6c 100644 --- a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/test_compute_sdf_values_and_segment_gmpq.cpp +++ b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/test_compute_sdf_values_and_segment_gmpq.cpp @@ -27,7 +27,7 @@ int main() boost::associative_property_map segment_property_map(internal_segment_map); // calculate SDF values and segment the mesh using default parameters. - int number_of_segments = CGAL::compute_sdf_values_and_segment(mesh, segment_property_map); + int number_of_segments = CGAL::segmentation_via_sdf_values(mesh, segment_property_map); std::cout << "Number of segments: " << number_of_segments << std::endl;