From 37b02012b6bf85cd4ea0bc3ca54dced696eda3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 7 Sep 2011 09:04:52 +0000 Subject: [PATCH] fix const-correctness issue in the spatial searching package. In particular this remove all mutable member variable and leave only one const_cast in the kd-kdtree private function const_build. This function is called in const predicates when the tree is not already internally built. The documentation has been update and a few typos fixed at the same time. --- Installation/changes.html | 14 ++++ Number_types/test/Number_types/CMakeLists.txt | 42 +++++----- .../Euclidean_distance.tex | 12 +-- .../Euclidean_distance_sphere_point.tex | 10 +-- .../doc_tex/Spatial_searching_ref/Fair.tex | 9 --- .../Spatial_searching_ref/FuzzyQueryItem.tex | 6 +- .../Spatial_searching_ref/Fuzzy_iso_box_d.tex | 6 +- .../Spatial_searching_ref/Fuzzy_sphere_d.tex | 6 +- .../Spatial_searching_ref/GeneralDistance.tex | 8 +- .../Incremental_neighbor_search.tex | 6 +- .../K_neighbor_search.tex | 8 +- .../doc_tex/Spatial_searching_ref/Kd_tree.tex | 24 +++--- .../Spatial_searching_ref/Kd_tree_node.tex | 21 ++--- .../Kd_tree_rectangle.tex | 10 +-- .../Manhattan_distance_iso_box_point.tex | 10 +-- .../Median_of_max_spread.tex | 4 - .../Median_of_rectangle.tex | 7 -- .../Midpoint_of_max_spread.tex | 3 - .../Midpoint_of_rectangle.tex | 4 - .../OrthogonalDistance.tex | 12 +-- ...Orthogonal_incremental_neighbor_search.tex | 8 +- .../Orthogonal_k_neighbor_search.tex | 6 +- .../Spatial_searching_ref/Plane_separator.tex | 4 +- .../Spatial_searching_ref/Point_container.tex | 41 ++++++---- .../Spatial_searching_ref/SearchTraits.tex | 2 +- .../Spatial_searching_ref/Splitter.tex | 4 +- .../Weighted_Minkowski_distance.tex | 12 +-- .../CGAL/Incremental_neighbor_search.h | 24 +++--- .../include/CGAL/K_neighbor_search.h | 6 +- Spatial_searching/include/CGAL/Kd_tree.h | 76 ++++++++++++------- Spatial_searching/include/CGAL/Kd_tree_node.h | 29 +++++-- .../Orthogonal_incremental_neighbor_search.h | 14 ++-- .../CGAL/Orthogonal_k_neighbor_search.h | 4 +- .../include/CGAL/Point_container.h | 33 +++++--- Spatial_searching/include/CGAL/Splitters.h | 16 ++-- .../CGAL/Weighted_Minkowski_distance.h | 2 +- .../include/CGAL/internal/K_neighbor_search.h | 5 +- 37 files changed, 280 insertions(+), 228 deletions(-) diff --git a/Installation/changes.html b/Installation/changes.html index 11776392008..641b4de60f8 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -98,6 +98,20 @@ Number of lines of code of CGAL

+

Release 3.10

+
+

Release date: XXX 2011

+ +

+CGAL 3.10 offers the following improvements and new functionality :

+ +

Spatial Searching

+ +

Release 3.9

Release date: XXX 2011

diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index fb319075b7f..ba56cfab4d9 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -1,9 +1,8 @@ -# based on a script created by cgal_create_cmake_script -# TODO: currently, everything depends on CORE, it would be nice to break -# that dependency so as to test all the number types not depending on CORE -# when it is not installed +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. -project( Number_types_test ) + +project( Number_types_example ) cmake_minimum_required(VERSION 2.6.2) if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) @@ -14,16 +13,20 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) endif() endif() -find_package( CGAL QUIET COMPONENTS Core ) +find_package(CGAL QUIET COMPONENTS Core ) if ( CGAL_FOUND ) include( ${CGAL_USE_FILE} ) + include( CGAL_CreateSingleSourceCGALProgram ) - include( CGAL_VersionUtils ) - find_package( MPFI ) - include_directories( BEFORE ../../include include ) + + include_directories (BEFORE ../../include) + + include_directories (BEFORE include) + create_single_source_cgal_program( "bench_interval.cpp" ) + create_single_source_cgal_program( "Coercion_traits.cpp" ) create_single_source_cgal_program( "constant.cpp" ) create_single_source_cgal_program( "CORE_BigFloat.cpp" ) create_single_source_cgal_program( "CORE_BigInt.cpp" ) @@ -34,6 +37,8 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "doubletst.cpp" ) create_single_source_cgal_program( "float.cpp" ) create_single_source_cgal_program( "floattst.cpp" ) + create_single_source_cgal_program( "Gmpfi.cpp" ) + create_single_source_cgal_program( "Gmpfr_bug.cpp" ) create_single_source_cgal_program( "Gmpfr.cpp" ) create_single_source_cgal_program( "Gmpq.cpp" ) create_single_source_cgal_program( "Gmpq_new.cpp" ) @@ -62,6 +67,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "NT_checker.cpp" ) create_single_source_cgal_program( "Quotient.cpp" ) create_single_source_cgal_program( "quotient_io.cpp" ) + create_single_source_cgal_program( "Quotient_new.cpp" ) create_single_source_cgal_program( "root_of_2.cpp" ) create_single_source_cgal_program( "Root_of_traits.cpp" ) create_single_source_cgal_program( "rounding_modes.cpp" ) @@ -71,18 +77,10 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "_test_valid_finite_float.cpp" ) create_single_source_cgal_program( "to_interval_test.cpp" ) create_single_source_cgal_program( "utilities.cpp" ) - if( MPFI_FOUND ) - include( ${MPFI_USE_FILE} ) - endif( MPFI_FOUND ) - # all the programs below will be linked against MPFI in case it is present - create_single_source_cgal_program( "Gmpfi.cpp" ) - create_single_source_cgal_program( "Gmpfr_bug.cpp" ) - create_single_source_cgal_program( "Quotient_new.cpp" ) - create_single_source_cgal_program( "Coercion_traits.cpp" ) -else( CGAL_FOUND ) +else() + + message(STATUS "This program requires the CGAL library, and will not be compiled.") + +endif() - message(STATUS - "These tests require the CGAL library and will not be compiled.") - -endif( CGAL_FOUND ) diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance.tex index e57b73e9bef..0dbf7bb9120 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance.tex @@ -49,22 +49,22 @@ Expects for the first template argument a model of the concept \ccOperations -\ccMethod{FT transformed_distance(Query_item q, Point_d p);}{Returns the squared Euclidean distance between~\ccc{q} and~\ccc{p}.} +\ccMethod{FT transformed_distance(Query_item q, Point_d p) const;}{Returns the squared Euclidean distance between~\ccc{q} and~\ccc{p}.} -\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r);} +\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r) const;} {Returns the squared Euclidean distance between \ccc{q} and the point on the boundary of \ccc{r} closest to \ccc{q}.} -\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r;);} +\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r;) const;} {Returns the squared Euclidean distance, where $d$ denotes the distance between \ccc{q} and the point on the boundary of \ccc{r} farthest to \ccc{q}.} -\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension);} {Updates the squared \ccc{dist} incrementally +\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension) const;} {Updates the squared \ccc{dist} incrementally and returns the updated squared distance.} -\ccMethod{FT transformed_distance(FT d);} {Returns $d^2$.} +\ccMethod{FT transformed_distance(FT d) const;} {Returns $d^2$.} -\ccMethod{FT inverse_of_transformed_distance(FT d);} {Returns $d^{1/2}$.} +\ccMethod{FT inverse_of_transformed_distance(FT d) const;} {Returns $d^{1/2}$.} \ccSeeAlso diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance_sphere_point.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance_sphere_point.tex index d922ee25822..147dfbfb144 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance_sphere_point.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Euclidean_distance_sphere_point.tex @@ -52,19 +52,19 @@ for example \ccc{CGAL::Cartesian_d}. \ccOperations -\ccMethod{NT transformed_distance(Query_item s, Point_d p);}{Returns the distance between \ccc{s} and \ccc{p}.} +\ccMethod{NT transformed_distance(Query_item s, Point_d p) const;}{Returns the distance between \ccc{s} and \ccc{p}.} -\ccMethod{NT min_distance_to_rectangle(Query_item s, Kd_tree_rectangle r);} +\ccMethod{NT min_distance_to_rectangle(Query_item s, Kd_tree_rectangle r) const;} {Returns the minimal distance between a point from the sphere \ccc{s} and a point from \ccc{r}.} -\ccMethod{NT max_distance_to_rectangle(Query_item s, Kd_tree_rectangle r);} +\ccMethod{NT max_distance_to_rectangle(Query_item s, Kd_tree_rectangle r) const;} {Returns the maximal distance between the sphere \ccc{s} and a point from \ccc{r} furthest to \ccc{s}. } -\ccMethod{NT transformed_distance(NT d);} {Returns $d^2$.} +\ccMethod{NT transformed_distance(NT d) const;} {Returns $d^2$.} -\ccMethod{NT inverse_of_transformed_distance(NT d);} {Returns $d^{1/2}$.} +\ccMethod{NT inverse_of_transformed_distance(NT d) const;} {Returns $d^{1/2}$.} \ccSeeAlso diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Fair.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Fair.tex index 07adfb6bff6..7edbd56c472 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Fair.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Fair.tex @@ -56,15 +56,6 @@ Splitter \ccConstructor{ Fair(unsigned int bucket_size, FT aspect_ratio=FT(3))}{Constructor.} -\ccOperations - - -\ccMethod{FT aspect_ratio();}{Returns the maximal ratio between the largest and smallest side -of a cell allowed for fair splitting.} - -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} - - \ccSeeAlso \ccc{Splitter},\\ diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/FuzzyQueryItem.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/FuzzyQueryItem.tex index 384e4f8f96a..d34ec91f7b7 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/FuzzyQueryItem.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/FuzzyQueryItem.tex @@ -36,13 +36,13 @@ The concept \ccRefName\ describes the requirements for fuzzy $d$-dimensional spa \ccOperations -\ccMethod{bool contains(Point_d p); const}{test whether $q$ contains $p$.} +\ccMethod{bool contains(Point_d p) const;}{test whether $q$ contains $p$.} -\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle); const} +\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle) const;} {test whether the inner approximation of the spatial object intersects a rectangle associated with a node of a tree. } -\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle); const} +\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle) const;} {test whether the outer approximation of the spatial object encloses the rectangle associated with a node of a tree.} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_iso_box_d.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_iso_box_d.tex index 05c87259bcb..9546ed64fe9 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_iso_box_d.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_iso_box_d.tex @@ -50,13 +50,13 @@ specified by the minimal iso box containing \ccc{p} and \ccc{q} and fuzziness va \ccOperations -\ccMethod{bool contains(Point_d p);}{test whether \ccVar\ contains \ccc{p}.} +\ccMethod{bool contains(Point_d p) const;}{test whether \ccVar\ contains \ccc{p}.} -\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle);} +\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle) const;} {test whether the inner box intersects the rectangle associated with a node of a tree.} -\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle);} +\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle) const;} {test whether the outer box encloses the rectangle associated with a node of a tree.} \ccSeeAlso diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_sphere_d.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_sphere_d.tex index 19d106696b8..fe68b0e6fb0 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_sphere_d.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Fuzzy_sphere_d.tex @@ -49,13 +49,13 @@ centered at \ccc{center} with radius \ccc{radius} and fuzziness value \ccc{epsil \ccOperations -\ccMethod{bool contains(const Point_d& p); const}{test whether $s$ contains $p$.} +\ccMethod{bool contains(const Point_d& p) const;}{test whether $s$ contains $p$.} -\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle); const} +\ccMethod{bool inner_range_intersects(const Kd_tree_rectangle& rectangle) const;} {test whether the inner sphere intersects the rectangle associated with a node of a tree.} -\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle); const} +\ccMethod{bool outer_range_contains(const Kd_tree_rectangle& rectangle) const;} {test whether the outer sphere encloses the rectangle associated with a node of a tree.} \ccSeeAlso diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/GeneralDistance.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/GeneralDistance.tex index 55ec26251f6..9d63692c4f5 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/GeneralDistance.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/GeneralDistance.tex @@ -42,17 +42,17 @@ Euclidean distance. \ccMethod{FT transformed_distance(Query_item q, Point_d r);}{Returns the transformed distance between \ccc{q} and~\ccc{r}.} -\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r);} +\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r) const;} {Returns the transformed distance between \ccc{q} and the point on the boundary of \ccc{r} closest to \ccc{q}.} -\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r);} +\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r) const;} {Returns the transformed distance between \ccc{q} and the point on the boundary of \ccc{r} furthest to \ccc{q}.} -\ccMethod{FT transformed_distance(FT d);} {Returns the transformed distance.} +\ccMethod{FT transformed_distance(FT d) const;} {Returns the transformed distance.} -\ccMethod{FT inverse_of_transformed_distance(FT d);} {Returns the inverse of the transformed distance.} +\ccMethod{FT inverse_of_transformed_distance(FT d) const;} {Returns the inverse of the transformed distance.} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Incremental_neighbor_search.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Incremental_neighbor_search.tex index f5f4b1c41a5..b470f48087e 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Incremental_neighbor_search.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Incremental_neighbor_search.tex @@ -47,7 +47,7 @@ template argument \ccc{CGAL::Tag_false} makes that the tree is built with unexte \ccTypedef{Traits::NT NT;}{Number type.} \ccTypedef{GeneralDistance Distance;}{Distance type.} \ccTypedef{std::pair Point_with_transformed_distance;}{Pair of point and transformed distance. } -\ccNestedType{iterator}{Input iterator with value type \ccc{Point_with_transformed_distance} +\ccNestedType{iterator}{Const input iterator with value type \ccc{Point_with_transformed_distance} for enumerating approximate neighbors.} \ccTypedef{GeneralDistance::Query_item Query_item;}{Query item type.} @@ -67,9 +67,9 @@ in the points stored \ccc{tree} using a distance \ccc{d} and approximation facto \ccOperations -\ccMethod{iterator begin();}{Returns an iterator to the approximate nearest or furthest neighbor.} +\ccMethod{iterator begin() const;}{Returns a const iterator to the approximate nearest or furthest neighbor.} -\ccMethod{iterator end();}{Past-the-end iterator.} +\ccMethod{iterator end() const;}{Past-the-end const iterator.} \begin{ccAdvanced} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/K_neighbor_search.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/K_neighbor_search.tex index b4c1a341238..d646bc3b4d4 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/K_neighbor_search.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/K_neighbor_search.tex @@ -47,7 +47,7 @@ template argument \ccc{CGAL::Tag_false} makes that the tree is built with unexte \ccTypedef{GeneralDistance Distance;}{Distance type.} \ccTypedef{std::pair Point_with_transformed_distance;}{Pair of point and transformed distance.} -\ccNestedType{iterator}{Bidirectional iterator with value type \ccc{Point_with_distance} +\ccNestedType{iterator}{Bidirectional const iterator with value type \ccc{Point_with_distance} for enumerating approximate neighbors.} \ccTypedef{GeneralDistance::Query_item Query_item;}{Query item type.} @@ -60,7 +60,7 @@ template argument \ccc{CGAL::Tag_false} makes that the tree is built with unexte \def\ccLongParamLayout{\ccTrue} -\ccConstructor{K_neighbor_search(Tree& tree, Query_item q, unsigned int k=1, FT eps=FT(0.0), +\ccConstructor{K_neighbor_search(const Tree& tree, Query_item q, unsigned int k=1, FT eps=FT(0.0), bool search_nearest=true, GeneralDistance d=GeneralDistance(),bool sorted=true);} {Constructor for searching approximately $k$ neighbors of the query item \ccc{q} in the points stored in \ccc{tree} using @@ -73,9 +73,9 @@ if the computed sequence of $k$-nearest neighbors needs to be sorted.} %OutputIterator the_k_neighbors(OutputIterator res);} %{Writes \ccc{k} elements of type \ccc{Point_with_distance} to \ccc{res}.} -\ccMethod{iterator begin();}{Returns an iterator to the approximate neighbors.} +\ccMethod{iterator begin() const;}{Returns a const iterator to the approximate neighbors.} -\ccMethod{iterator end();}{Past-the-end iterator.} +\ccMethod{iterator end() const;}{Past-the-end const iterator.} \begin{ccAdvanced} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree.tex index aaec0d7c30b..6da29244f19 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree.tex @@ -1,4 +1,4 @@ -% +------------------------------------------------------------------------+ +s% +------------------------------------------------------------------------+ % | Reference manual page: Kd_tree.tex % +------------------------------------------------------------------------+ % | 1.07.2001 Johan W.H. Tangelder @@ -38,12 +38,13 @@ tree shall be built with extended nodes, and \ccc{CGAL::Tag_false} otherwise. \ccTypedef{Traits::FT FT;}{Number type.} \ccNestedType{Splitter}{Splitter type.} -\ccNestedType{iterator}{Bidirectional iterator with value type \ccc{Point_d} that allows +\ccNestedType{iterator}{Bidirectional const iterator with value type \ccc{Point_d} that allows to enumerate all points in the tree.} \begin{ccAdvanced} \ccNestedType{Node_handle}{A handle with value type \ccc{Kd_tree_node}.} -\ccNestedType{Point_d_iterator} {Random access iterator +\ccNestedType{Node_const_handle}{A const handle with value type \ccc{Kd_tree_node}.} +\ccNestedType{Point_d_iterator} {Random access const iterator with value type \ccc{Point_d*}.} \end{ccAdvanced} @@ -72,19 +73,19 @@ The value type of the \ccc{InputIterator} must be \ccc{Point_d}.} \ccMethod{ template -OutputIterator search(OutputIterator it, FuzzyQueryItem q);} +OutputIterator search(OutputIterator it, FuzzyQueryItem q) const;} {Reports the points that are approximately contained by~\ccc{q}. The types \ccc{FuzzyQueryItem::Point_d} and \ccc{Point_d} must be equivalent. To use this function \ccc{Traits} must be a model of the concept \ccc{RangeSearchTraits}. } -\ccMethod{iterator begin();}{Returns an iterator to the first point in the tree.} -\ccMethod{iterator end();}{Returns the corresponding past-the-end iterator.} +\ccMethod{iterator begin() const;}{Returns a const iterator to the first point in the tree.} +\ccMethod{iterator end() const;}{Returns the corresponding past-the-end const iterator.} -\ccMethod{void clear() const;}{Removes all points from the $k$-$d$ tree.} +\ccMethod{void clear();}{Removes all points from the $k$-$d$ tree.} -\ccMethod{unsigned int size();} +\ccMethod{unsigned int size() const;} {Returns the number of points that are stored in the tree.} \ccMethod{Traits traits() const;}{return the instance of the traits used to construct the tree.} @@ -94,10 +95,13 @@ To use this function \ccc{Traits} must be a model of the concept \ccc{RangeSearc \ccMethod{Node_handle root();} {Returns a handle to the root node of the tree.} -\ccMethod{const Kd_tree_rectangle& bounding_box();}{returns a const reference +\ccMethod{Node_const_handle root() const;} +{Returns a const handle to the root node of the tree.} + +\ccMethod{const Kd_tree_rectangle& bounding_box() const;}{returns a const reference to the bounding box of the root node of the tree.} -\ccMethod{std::ostream& statistics(std::ostream& s);} +\ccMethod{std::ostream& statistics(std::ostream& s) const;} { Inserts statistics of the tree into the output stream \ccc{s}. } diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_node.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_node.tex index 893cf0e3c54..58724cad8d9 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_node.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_node.tex @@ -42,8 +42,9 @@ for example \ccc{CGAL::Search_traits_2 >}, or \ccc{CGAL: \ccTypedef{Traits::FT FT;}{Number type.} \ccTypedef{Traits::Point_d Point_d;}{Point type.} \ccTypedef{Splitter::Separator Separator;}{Separator type.} -\ccTypedef{Kd_tree::Point_d_iterator Point_d_iterator;}{Iterator over points.} +\ccTypedef{Kd_tree::Point_d_iterator Point_d_iterator;}{Const iterator over points.} \ccTypedef{Kd_tree::Node_handle Node_handle;}{Node handle.} +\ccTypedef{Kd_tree::Node_const_handle Node_const_handle;}{Const node handle.} \ccCreation @@ -55,24 +56,26 @@ for example \ccc{CGAL::Search_traits_2 >}, or \ccc{CGAL: \ccMethod{ template -OutputIterator search(OutputIterator it, FuzzyQueryItem q);} +OutputIterator search(OutputIterator it, FuzzyQueryItem q) const;} {Reports the points from the subtree of the node, that are approximately contained by q.} \ccMethod{ template -OutputIterator tree_points(OutputIterator it);} +OutputIterator tree_items(OutputIterator it) const;} {Reports all the points contained by the subtree of the node.} -\ccMethod{bool is_leaf();}{Indicates whether a node is a leaf node.} -\ccMethod{int size();}{Returns the number of items stored in a leaf node.} -\ccMethod{Point_d_iterator begin();}{Returns the iterator to the first item in a leaf node.} -\ccMethod{Point_d_iterator end();}{Returns the past-the-end iterator in a leaf node.} +\ccMethod{bool is_leaf() const;}{Indicates whether a node is a leaf node.} +\ccMethod{unsigned int size() const;}{Returns the number of items stored in a leaf node.} +\ccMethod{Point_d_iterator begin() const;}{Returns a const iterator to the first item in a leaf node.} +\ccMethod{Point_d_iterator end() const;}{Returns a past-the-end const iterator in a leaf node.} \ccMethod{Node_handle lower();}{Returns a handle to the lower child of an internal node.} \ccMethod{Node_handle upper();}{Returns a handle to the upper child of an internal node.} +\ccMethod{Node_const_handle lower() const;}{Returns a const handle to the lower child of an internal node.} +\ccMethod{Node_const_handle upper() const;}{Returns a const handle to the upper child of an internal node.} \ccMethod{Separator& separator();}{Returns a reference to the separator.} -\ccMethod{FT low_val();}{Returns the lower limit of an extended node's rectangle +\ccMethod{FT low_value() const;}{Returns the lower limit of an extended node's rectangle along the node's cutting dimension.} -\ccMethod{FT high_val();}{Returns the upper limit of an extended node's rectangle +\ccMethod{FT high_value() const;}{Returns the upper limit of an extended node's rectangle along the node's cutting dimension.} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_rectangle.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_rectangle.tex index 2871d3afda7..6cc224e86ea 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_rectangle.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Kd_tree_rectangle.tex @@ -47,10 +47,10 @@ to define iterators with value type \ccc{FT}.} \ccOperations -\ccMethod{FT min_coord(int i);} +\ccMethod{FT min_coord(int i) const;} {Returns the lower bound of the rectangle in dimension~\ccc{i}.} -\ccMethod{FT max_coord(int i);} +\ccMethod{FT max_coord(int i) const;} {Returns the upper bound of the rectangle in dimension~\ccc{i}.} @@ -62,13 +62,13 @@ to define iterators with value type \ccc{FT}.} {Sets lower bound in dimension \ccc{i} to \ccc{x}.} -\ccMethod{FT max_span();} +\ccMethod{FT max_span() const;} {Returns the maximal span of the rectangle.} -\ccMethod{FT max_span_coord();} +\ccMethod{FT max_span_coord() const;} {Returns the smallest coordinate for which the rectangle has its maximal span.} -\ccMethod{int dimension();} +\ccMethod{int dimension() const;} {Returns the dimension of the rectangle.} \ccMethod{void split(Kd_tree_rectangle& r, int d, FT value);} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Manhattan_distance_iso_box_point.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Manhattan_distance_iso_box_point.tex index 5c5100c29b6..7014e9c5c3e 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Manhattan_distance_iso_box_point.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Manhattan_distance_iso_box_point.tex @@ -49,19 +49,19 @@ Expects for the template argument a model for the concept \ccOperations -\ccMethod{FT transformed_distance(Query_item b, Point_d p);}{Returns the transformed +\ccMethod{FT transformed_distance(Query_item b, Point_d p) const;}{Returns the transformed distance between \ccc{b} and \ccc{p}.} -\ccMethod{FT transformed_distance(FT d);} {Returns the transformed value of of $d$.} +\ccMethod{FT transformed_distance(FT d) const;} {Returns the transformed value of of $d$.} -\ccMethod{FT inverse_of_transformed_distance(FT d);} {Returns the value of the inverse +\ccMethod{FT inverse_of_transformed_distance(FT d) const;} {Returns the value of the inverse of the transform function applied to $d$.} -\ccMethod{FT min_distance_to_rectangle(Query_item b, Kd_tree_rectangle r);} +\ccMethod{FT min_distance_to_rectangle(Query_item b, Kd_tree_rectangle r) const;} {Returns the minimal distance between a point from \ccc{b} and a point from \ccc{r}.} -\ccMethod{FT max_distance_to_rectangle(Query_item b, Kd_tree_rectangle r);} +\ccMethod{FT max_distance_to_rectangle(Query_item b, Kd_tree_rectangle r) const;} {Returns the maximal distance between the iso-box \ccc{b} and a point from \ccc{r} furthest to \ccc{b}.} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_max_spread.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_max_spread.tex index a9d5b4aca79..31e1a1e050b 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_max_spread.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_max_spread.tex @@ -43,10 +43,6 @@ the type, \ccc{CGAL::Plane_separator}. \ccConstructor{Median_of_max_spread();}{Default constructor.} \ccConstructor{Median_of_max_spread(unsigned int bucket_size);}{Constructor.} -\ccOperations -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} - - \ccSeeAlso \ccc{Splitter},\\ diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_rectangle.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_rectangle.tex index 4ad9287fc68..3899d2fe7d0 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_rectangle.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Median_of_rectangle.tex @@ -41,13 +41,6 @@ the type, \ccc{CGAL::Plane_separator}. \ccConstructor{Median_of_rectangle();}{Default constructor.} \ccConstructor{Median_of_rectangle(unsigned int bucket_size);}{Constructor.} -\ccOperations -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} - - - - - \ccSeeAlso \ccc{Splitter},\\ diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_max_spread.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_max_spread.tex index 608549ec02e..5dfe2e45cab 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_max_spread.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_max_spread.tex @@ -44,9 +44,6 @@ the type, \ccc{CGAL::Plane_separator} \ccConstructor{Midpoint_of_max_spread();}{Default constructor.} \ccConstructor{Midpoint_of_max_spread(unsigned int bucket_size);}{Constructor.} -\ccOperations -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} - \ccSeeAlso \ccc{Splitter},\\ diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_rectangle.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_rectangle.tex index 1f3408476b3..52df9764fda 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_rectangle.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Midpoint_of_rectangle.tex @@ -43,10 +43,6 @@ the type, \ccc{CGAL::Plane_separator} \ccConstructor{Midpoint_of_rectangle_spread();}{Default constructor.} \ccConstructor{Midpoint_of_rectangle(unsigned int bucket_size);}{Constructor.} -\ccOperations -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} - - \ccSeeAlso \ccc{Splitter},\\ diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/OrthogonalDistance.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/OrthogonalDistance.tex index b558ec4ee10..77b37cff8ce 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/OrthogonalDistance.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/OrthogonalDistance.tex @@ -44,21 +44,21 @@ E.g., for an Euclidean distance the transformed distance is the squared Euclidea \ccOperations -\ccMethod{FT transformed_distance(Query_item q, Point_d r);}{Returns the transformed distance between \ccc{q} and~\ccc{r}.} +\ccMethod{FT transformed_distance(Query_item q, Point_d r) const;}{Returns the transformed distance between \ccc{q} and~\ccc{r}.} -\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r);} +\ccMethod{FT min_distance_to_rectangle(Query_item q, Kd_tree_rectangle r) const;} {Returns the transformed distance between \ccc{q} and the point on the boundary of \ccc{r} closest to \ccc{q}.} -\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r);} +\ccMethod{FT max_distance_to_rectangle(Query_item q, Kd_tree_rectangle r) const;} {Returns the transformed distance between \ccc{q} and the point on the boundary of \ccc{r} farthest to \ccc{q}.} -\ccMethod{FT transformed_distance(FT d);} {Returns the transformed distance.} +\ccMethod{FT transformed_distance(FT d) const;} {Returns the transformed distance.} -\ccMethod{FT inverse_of_transformed_distance(FT d);} {Returns the inverse of the transformed distance.} +\ccMethod{FT inverse_of_transformed_distance(FT d) const;} {Returns the inverse of the transformed distance.} -\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension);} {Updates +\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension) const;} {Updates \ccc{dist} incrementally and returns the updated distance.} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_incremental_neighbor_search.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_incremental_neighbor_search.tex index 39ed40c85f7..8d5d0895a44 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_incremental_neighbor_search.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_incremental_neighbor_search.tex @@ -48,7 +48,7 @@ kd tree nodes. \ccTypedef{OrthogonalDistance Distance;}{Distance type.} \ccTypedef{OrthogonalDistance::Query_item Query_item;}{Query item.} \ccTypedef{std::pair Point_with_transformed_distance;}{Pair of point and transformed distance.} -\ccNestedType{iterator}{Input iterator with value type \ccc{Point_with_transformed_distance} +\ccNestedType{iterator}{Const input iterator with value type \ccc{Point_with_transformed_distance} for enumerating approximate neighbors.} \ccTypedef{SpatialTree Tree;}{The tree type.} @@ -64,13 +64,13 @@ in the points stored \ccc{tree} using a distance \ccc{d} and approximation facto \ccOperations -\ccMethod{iterator begin();}{Returns an iterator to the approximate neighbors.} +\ccMethod{iterator begin() const;}{Returns a const iterator to the approximate neighbors.} -\ccMethod{iterator end();}{Returns the corresponding past-the-end iterator.} +\ccMethod{iterator end() const;}{Returns the corresponding past-the-end const iterator.} \ \begin{ccAdvanced} -\ccMethod{std::ostream& statistics(std::ostream& s);} +\ccMethod{std::ostream& statistics(std::ostream& s) const;} { Inserts statistics of the search process into the output stream~\ccc{s}. } diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_k_neighbor_search.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_k_neighbor_search.tex index 03fa43ae5da..dc47c10fe37 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_k_neighbor_search.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Orthogonal_k_neighbor_search.tex @@ -55,7 +55,7 @@ kd tree nodes. \ccTypedef{GeneralDistance::Query_item Query_item;}{Query item.} \ccTypedef{std::pair Point_with_transformed_distance;}{Pair of point and transformed distance.} -\ccNestedType{iterator}{Bidirectional iterator with value type \ccc{Point_with_transformed_distance} +\ccNestedType{iterator}{Bidirectional const iterator with value type \ccc{Point_with_transformed_distance} for enumerating approximate neighbors.} \ccTypedef{SpatialTree Tree;}{The tree type.} @@ -76,9 +76,9 @@ if the computed sequence of $k$-nearest neighbors needs to be sorted.} %OutputIterator the_k_neighbors(OutputIterator res);} %{Writes \ccc{k} elements of type \ccc{Point_with_distance} to \ccc{res}.} -\ccMethod{iterator begin();}{Returns an iterator to the approximate neighbors.} +\ccMethod{iterator begin() const;}{Returns a const iterator to the approximate neighbors.} -\ccMethod{iterator end();}{Past-the-end iterator.} +\ccMethod{iterator end() const;}{Past-the-end const iterator.} \begin{ccAdvanced} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Plane_separator.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Plane_separator.tex index cf76459a86b..0e68e2401e8 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Plane_separator.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Plane_separator.tex @@ -52,9 +52,9 @@ void set_cutting_dimension(int d);} void set_cutting_value(FT v);} {Sets the cutting value to \ccc{v}. } -\ccMethod{int cutting_dimension();}{Returns the number of the cutting dimension.} +\ccMethod{int cutting_dimension() const;}{Returns the number of the cutting dimension.} -\ccMethod{FT cutting_value();}{Returns the cutting value.} +\ccMethod{FT cutting_value() const;}{Returns the cutting value.} % \ccMethod{template % bool has_on_negative_side(SpatialPoint p);} diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Point_container.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Point_container.tex index 725b3b66e49..c429e3f7966 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Point_container.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Point_container.tex @@ -41,6 +41,7 @@ $d$-dimensional points of the concept \ccc{SearchTraits}, for example \ccTypedef{Traits::FT FT;}{Number type.} \ccTypedef{Traits::Point_d Point_d;}{Point type.} \ccNestedType{iterator}{An iterator with value type \ccc{Point_d*}.} +\ccNestedType{const_iterator}{A const iterator with value type \ccc{const Point_d*}.} %---------------------------------------- \ccCreation @@ -87,34 +88,44 @@ Return an iterator pointing to the pointer to the first point. Return the iterator to the corresponding past-the-end iterator. } +\ccMethod{const_iterator begin() const;} +{ +Return a const iterator pointing to the pointer to the first point. +} + +\ccMethod{const_iterator end() const;} +{ +Return a const iterator to the corresponding past-the-end iterator. +} + \ccMethod{int dimension() const;} { Return the dimension. } -\ccMethod{int built_coordinate();} +\ccMethod{int built_coordinate() const;} { Return coordinate for which the pointer list is built. } -\ccMethod{int max_span_coord();} +\ccMethod{int max_span_coord() const;} { Return coordinate where the associated rectangle has maximal span. } -\ccMethod{int max_tight_span_coord();} +\ccMethod{int max_tight_span_coord() const;} { Return coordinate where the point coordinates have maximal span. } -\ccMethod{FT max_span_lower();} +\ccMethod{FT max_span_lower() const;} { Return lower value of the interval corresponding to \ccc{max_span_coord()}. } -\ccMethod{FT max_tight_span_lower();} +\ccMethod{FT max_tight_span_lower() const;} { Return lower value of the interval corresponding to \ccc{max_tight_span_coord()}. That is, the smallest @@ -123,47 +134,47 @@ Return lower value of the interval corresponding to } -\ccMethod{FT max_span_upper();} +\ccMethod{FT max_span_upper() const;} { Return upper value of the interval corresponding to \ccc{max_span_coord()}. } -\ccMethod{FT max_span_upper_without_dim(int d);} +\ccMethod{FT max_span_upper_without_dim(int d) const;} { Return upper value of the interval over all dimensions without taking dimension \ccc{d} into account. } -\ccMethod{FT max_tight_span_upper();} +\ccMethod{FT max_tight_span_upper() const;} { Return upper value of the interval corresponding to \ccc{max_tight_span_coord()}. } -\ccMethod{FT max_spread();} +\ccMethod{FT max_spread() const;} { Return the size of the interval corresponding to \ccc{max_span_coord()}. } -\ccMethod{FT max_tight_spread();} +\ccMethod{FT max_tight_spread() const;} { Return the size of the interval corresponding to \ccc{max_tight_span_coord()}. } -\ccMethod{FT median(int split_coord);} +\ccMethod{FT median(int split_coord) const;} { Return the median value of the points stored in the container for dimension \ccc{split_coord}. } -\ccMethod{const Kd_tree_rectangle & bounding_box();} +\ccMethod{const Kd_tree_rectangle & bounding_box() const;} {Return the associated rectangle.} \ccMethod{const Kd_tree_rectangle & tight_bounding_box();} {Return the bounding box of the items in associated rectangle.} -\ccMethod{int max_tight_span_coord_balanced(FT aspect_ratio);} +\ccMethod{int max_tight_span_coord_balanced(FT aspect_ratio) const;} {Return the dimension with the maximal point spread, for which after fair splitting the ratio of the length of the longest side and the smallest side of the bounding box of the items in associated rectangle, @@ -175,12 +186,12 @@ does not exceed \ccc{aspect_ratio}.} \ccMethod{FT balanced_sliding_fair(int d, FT aspect_ratio);} {Return the splitting value for sliding fair splitting.} -\ccMethod{int size();} +\ccMethod{std::size_t size() const;} { Return the number of points stored. } -\ccMethod{bool empty();} +\ccMethod{bool empty() const;} { Return true if no points are present, false otherwise. } diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/SearchTraits.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/SearchTraits.tex index 6303a076772..4f89e4aaef7 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/SearchTraits.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/SearchTraits.tex @@ -40,7 +40,7 @@ provides the type \ccc{result_type} that must be the same a \ccc{Cartesian_const \ccOperations -\ccMethod{Construct_cartesian_const_iterator_d construct_construct_cartesian_const_iterator_d_object(const Point_d& p);} +\ccMethod{Construct_cartesian_const_iterator_d construct_construct_cartesian_const_iterator_d_object(const Point_d& p) const;} {function used to construct an object of type \ccc{Construct_cartesian_const_iterator_d}.} \ccHasModels diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Splitter.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Splitter.tex index 0ca645ca127..e55021c4392 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Splitter.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Splitter.tex @@ -45,10 +45,10 @@ define the way in which $k$-$d$ tree is constructed. \ccOperations -\ccMethod{FT aspect_ratio();}{Returns the maximal ratio between the largest and smallest side +\ccMethod{FT aspect_ratio() const;}{Returns the maximal ratio between the largest and smallest side of a cell allowed for fair splitting.} -\ccMethod{unsigned int bucket_size();} {Returns the bucket size of the leaf nodes.} +\ccMethod{unsigned int bucket_size() const;} {Returns the bucket size of the leaf nodes.} \ccMethod{void operator()(Separator& sep, Container& c0, Container& c1) const;} { diff --git a/Spatial_searching/doc_tex/Spatial_searching_ref/Weighted_Minkowski_distance.tex b/Spatial_searching/doc_tex/Spatial_searching_ref/Weighted_Minkowski_distance.tex index 238098ba3e1..381e58fb88e 100644 --- a/Spatial_searching/doc_tex/Spatial_searching_ref/Weighted_Minkowski_distance.tex +++ b/Spatial_searching/doc_tex/Spatial_searching_ref/Weighted_Minkowski_distance.tex @@ -56,23 +56,23 @@ The values in the iterator range \ccc{[wb,we)} are the weight. } \ccOperations -\ccMethod{FT transformed_distance(Point_d q, Point_d r);}{Returns $d^{power}$, +\ccMethod{FT transformed_distance(Point_d q, Point_d r) const;}{Returns $d^{power}$, where $d$ denotes the distance between \ccc{q} and~\ccc{r}.} -\ccMethod{FT min_distance_to_rectangle(Point_d q, Kd_tree_rectangle r;);} +\ccMethod{FT min_distance_to_rectangle(Point_d q, Kd_tree_rectangle r;) const;} {Returns $d^{power}$, where $d$ denotes the distance between the query item \ccc{q} and the point on the boundary of \ccc{r} closest to \ccc{q}.} -\ccMethod{FT max_distance_to_rectangle(Point_d q, Kd_tree_rectangle r;);} +\ccMethod{FT max_distance_to_rectangle(Point_d q, Kd_tree_rectangle r;) const;} {Returns $d^{power}$, where $d$ denotes the distance between the query item \ccc{q} and the point on the boundary of \ccc{r} farthest to \ccc{q}.} -\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension);} {Updates \ccc{dist} incrementally +\ccMethod{FT new_distance(FT dist, FT old_off, FT new_off, int cutting_dimension) const;} {Updates \ccc{dist} incrementally and returns the updated distance.} -\ccMethod{FT transformed_distance(FT d);} {Returns $d^p$ for $0 < p <\infty$ . Returns $d$ for $p=\infty$ .} +\ccMethod{FT transformed_distance(FT d) const;} {Returns $d^p$ for $0 < p <\infty$ . Returns $d$ for $p=\infty$ .} -\ccMethod{FT inverse_of_transformed_distance(FT d);} {Returns $d^{1/p}$ for $0 < p <\infty$. +\ccMethod{FT inverse_of_transformed_distance(FT d) const;} {Returns $d^{1/p}$ for $0 < p <\infty$. Returns $d$ for $p=\infty$.} diff --git a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h index 2ca4c2843bb..c7216bd2e23 100644 --- a/Spatial_searching/include/CGAL/Incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Incremental_neighbor_search.h @@ -43,7 +43,7 @@ namespace CGAL { typedef typename SearchTraits::Point_d Point_d; typedef typename SearchTraits::FT FT; typedef typename Tree::Point_d_iterator Point_d_iterator; - typedef typename Tree::Node_handle Node_handle; + typedef typename Tree::Node_const_handle Node_const_handle; typedef typename Tree::Splitter Splitter; typedef Kd_tree_rectangle Node_box; typedef typename Distance::Query_item Query_item; @@ -53,12 +53,12 @@ namespace CGAL { private: Node_box* the_box; - Node_handle the_node; + Node_const_handle the_node; public: // constructor - Cell (Node_box* Nb, Node_handle N) + Cell (Node_box* Nb, Node_const_handle N) :the_box(Nb), the_node(N) {} @@ -68,7 +68,7 @@ namespace CGAL { return the_box; } - Node_handle + Node_const_handle node() { return the_node; @@ -92,7 +92,7 @@ namespace CGAL { public: // constructor - Incremental_neighbor_search(Tree& tree, const Query_item& q, + Incremental_neighbor_search(const Tree& tree, const Query_item& q, FT Eps=FT(0.0), bool search_nearest=true, const Distance& tr=Distance()) { @@ -108,13 +108,13 @@ namespace CGAL { } iterator - begin() + begin() const { return *start; } iterator - end() + end() const { return *past_the_end; } @@ -190,7 +190,7 @@ namespace CGAL { return *this; } - Point_with_transformed_distance& + const Point_with_transformed_distance& operator* () const { return *(*ptr); @@ -360,8 +360,8 @@ namespace CGAL { } // * operator - Point_with_transformed_distance& - operator* () + const Point_with_transformed_distance& + operator* () const { return *(Item_PriorityQueue.top()); } @@ -386,7 +386,7 @@ namespace CGAL { // Print statistics of the general priority search process. std::ostream& - statistics (std::ostream& s) + statistics (std::ostream& s) const { s << "General priority search statistics:" << std::endl; s << "Number of internal nodes visited:" << @@ -443,7 +443,7 @@ namespace CGAL { while ((!next_neighbour_found) && (!PriorityQueue.empty())) { Cell_with_distance* The_node_top = PriorityQueue.top(); - Node_handle N = The_node_top->first->node(); + Node_const_handle N = The_node_top->first->node(); Node_box* B = The_node_top->first->box(); PriorityQueue.pop(); delete The_node_top->first; diff --git a/Spatial_searching/include/CGAL/K_neighbor_search.h b/Spatial_searching/include/CGAL/K_neighbor_search.h index 1796b0aae21..0970349b127 100644 --- a/Spatial_searching/include/CGAL/K_neighbor_search.h +++ b/Spatial_searching/include/CGAL/K_neighbor_search.h @@ -34,7 +34,7 @@ class K_neighbor_search: public internal::K_neighbor_search& r) + compute_neighbors_general(typename Base::Node_const_handle N, const Kd_tree_rectangle& r) { if (!(N->is_leaf())) { this->number_of_internal_nodes_visited++; diff --git a/Spatial_searching/include/CGAL/Kd_tree.h b/Spatial_searching/include/CGAL/Kd_tree.h index 9672cda3641..b56fb5c8064 100644 --- a/Spatial_searching/include/CGAL/Kd_tree.h +++ b/Spatial_searching/include/CGAL/Kd_tree.h @@ -44,30 +44,34 @@ public: typedef typename SearchTraits::FT FT; typedef Kd_tree_node Node; typedef Kd_tree Tree; + typedef Kd_tree Self; typedef typename Compact_container::iterator Node_handle; - typedef typename std::vector::iterator Point_d_iterator; + typedef typename Compact_container::const_iterator Node_const_handle; + typedef typename std::vector::const_iterator Point_d_iterator; + typedef typename std::vector::const_iterator Point_d_const_iterator; typedef typename Splitter::Separator Separator; typedef typename std::vector::const_iterator iterator; + typedef typename std::vector::const_iterator const_iterator; private: SearchTraits traits_; - mutable Splitter split; - mutable Compact_container nodes; + Splitter split; + Compact_container nodes; - mutable Node_handle tree_root; + Node_handle tree_root; - mutable Kd_tree_rectangle* bbox; - mutable std::vector pts; + Kd_tree_rectangle* bbox; + std::vector pts; // Instead of storing the points in arrays in the Kd_tree_node // we put all the data in a vector in the Kd_tree. // and we only store an iterator range in the Kd_tree_node. // - mutable std::vector data; + std::vector data; - mutable bool built_; + bool built_; // protected copy constructor Kd_tree(const Tree& tree) @@ -81,7 +85,7 @@ private: // The leaf node Node_handle - create_leaf_node(Point_container& c) const + create_leaf_node(Point_container& c) { Node_handle nh = nodes.emplace(static_cast(c.size()), Node::LEAF); @@ -93,13 +97,13 @@ private: // The internal node Node_handle - create_internal_node(Point_container& c, const Tag_true&) const + create_internal_node(Point_container& c, const Tag_true&) { return create_internal_node_use_extension(c); } Node_handle - create_internal_node(Point_container& c, const Tag_false&) const + create_internal_node(Point_container& c, const Tag_false&) { return create_internal_node(c); } @@ -111,7 +115,7 @@ private: // It is not proper yet, but the goal was to see if there is // a potential performance gain through the Compact_container Node_handle - create_internal_node_use_extension(Point_container& c) const + create_internal_node_use_extension(Point_container& c) { Node_handle nh = nodes.emplace(Node::EXTENDED_INTERNAL); @@ -144,7 +148,7 @@ private: // Note also that I duplicated the code to get rid if the if's for // the boolean use_extension which was constant over the construction Node_handle - create_internal_node(Point_container& c) const + create_internal_node(Point_container& c) { Node_handle nh = nodes.emplace(Node::INTERNAL); @@ -185,7 +189,7 @@ public: } void - build() const + build() { const Point_d& p = *pts.begin(); typename SearchTraits::Construct_cartesian_const_iterator_d ccci=traits_.construct_cartesian_const_iterator_d_object(); @@ -205,6 +209,13 @@ public: built_ = true; } +private: + //any call to this function is for the moment not threadsafe + void const_build() const { + const_cast(this)->build(); //THIS IS NOT THREADSAFE + } +public: + bool is_built() const { return built_; @@ -244,12 +255,12 @@ public: template OutputIterator - search(OutputIterator it, const FuzzyQueryItem& q) + search(OutputIterator it, const FuzzyQueryItem& q) const { if(! pts.empty()){ if(! is_built()){ - build(); + const_build(); } Kd_tree_rectangle b(*bbox); tree_root->search(it,q,b); @@ -264,17 +275,26 @@ public: } - SearchTraits + const SearchTraits& traits() const { return traits_; } - Node_handle + Node_const_handle root() const { if(! is_built()){ - build(); + const_build(); + } + return tree_root; + } + + Node_handle + root() + { + if(! is_built()){ + const_build(); } return tree_root; } @@ -283,7 +303,7 @@ public: print() const { if(! is_built()){ - build(); + const_build(); } root()->print(); } @@ -292,18 +312,18 @@ public: bounding_box() const { if(! is_built()){ - build(); + const_build(); } return *bbox; } - iterator + const_iterator begin() const { return pts.begin(); } - iterator + const_iterator end() const { return pts.end(); @@ -317,17 +337,17 @@ public: // Print statistics of the tree. std::ostream& - statistics(std::ostream& s) + statistics(std::ostream& s) const { if(! is_built()){ - build(); + const_build(); } s << "Tree statistics:" << std::endl; s << "Number of items stored: " - << tree_root->num_items() << std::endl; + << root()->num_items() << std::endl; s << "Number of nodes: " - << tree_root->num_nodes() << std::endl; - s << " Tree depth: " << tree_root->depth() << std::endl; + << root()->num_nodes() << std::endl; + s << " Tree depth: " << root()->depth() << std::endl; return s; } diff --git a/Spatial_searching/include/CGAL/Kd_tree_node.h b/Spatial_searching/include/CGAL/Kd_tree_node.h index 9295436421d..a5cf52f952c 100644 --- a/Spatial_searching/include/CGAL/Kd_tree_node.h +++ b/Spatial_searching/include/CGAL/Kd_tree_node.h @@ -34,6 +34,7 @@ namespace CGAL { friend class Kd_tree; typedef typename Kd_tree::Node_handle Node_handle; + typedef typename Kd_tree::Node_const_handle Node_const_handle; enum Node_type {LEAF, INTERNAL, EXTENDED_INTERNAL}; typedef typename TreeTraits::Point_d Point_d; @@ -94,7 +95,7 @@ namespace CGAL { } inline - Point_d_iterator + Point_d_iterator begin() const { return data; @@ -110,18 +111,32 @@ namespace CGAL { // members for internal node and extended internal node inline - Node_handle + Node_const_handle lower() const { return lower_ch; } inline - Node_handle + Node_const_handle upper() const { return upper_ch; } + + inline + Node_handle + lower() + { + return lower_ch; + } + + inline + Node_handle + upper() + { + return upper_ch; + } // inline Separator& separator() {return sep; } // use instead @@ -164,7 +179,7 @@ namespace CGAL { std::size_t - num_items() + num_items() const { if (is_leaf()) return size(); else @@ -172,7 +187,7 @@ namespace CGAL { } std::size_t - num_nodes() + num_nodes() const { if (is_leaf()) return 1; else @@ -198,7 +213,7 @@ namespace CGAL { template OutputIterator - tree_items(OutputIterator it) { + tree_items(OutputIterator it) const { if (is_leaf()) { if (n>0) @@ -248,7 +263,7 @@ namespace CGAL { template OutputIterator search(OutputIterator it, const FuzzyQueryItem& q, - Kd_tree_rectangle& b) + Kd_tree_rectangle& b) const { if (is_leaf()) { if (n>0) diff --git a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h index 0c50506cf1e..f200f66b670 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_incremental_neighbor_search.h @@ -43,10 +43,10 @@ namespace CGAL { typedef typename Distance::Query_item Query_item; typedef typename SearchTraits::FT FT; typedef typename Tree::Point_d_iterator Point_d_iterator; - typedef typename Tree::Node_handle Node_handle; + typedef typename Tree::Node_const_handle Node_const_handle; typedef std::pair Point_with_transformed_distance; - typedef std::pair Node_with_distance; + typedef std::pair Node_with_distance; typedef std::vector Node_with_distance_vector; typedef std::vector Point_with_transformed_distance_vector; @@ -132,7 +132,7 @@ namespace CGAL { // constructor - Iterator_implementation(Tree& tree,const Query_item& q, const Distance& tr, + Iterator_implementation(const Tree& tree,const Query_item& q, const Distance& tr, FT Eps=FT(0.0), bool search_nearest=true) : traits(tree.traits()),number_of_neighbours_computed(0), number_of_internal_nodes_visited(0), number_of_leaf_nodes_visited(0), number_of_items_visited(0), @@ -163,7 +163,7 @@ namespace CGAL { } // * operator - Point_with_transformed_distance& + const Point_with_transformed_distance& operator* () const { return *(Item_PriorityQueue.top()); @@ -247,7 +247,7 @@ namespace CGAL { // otherwise browse the tree further while ((!next_neighbour_found) && (!PriorityQueue.empty())) { Node_with_distance* The_node_top=PriorityQueue.top(); - Node_handle N= The_node_top->first; + Node_const_handle N= The_node_top->first; PriorityQueue.pop(); delete The_node_top; FT copy_rd=rd; @@ -350,7 +350,7 @@ namespace CGAL { public: // constructor - Orthogonal_incremental_neighbor_search(Tree& tree, + Orthogonal_incremental_neighbor_search(const Tree& tree, const Query_item& q, FT Eps = FT(0.0), bool search_nearest=true, const Distance& tr=Distance()) : start(tree,q,tr,Eps,search_nearest), @@ -409,7 +409,7 @@ namespace CGAL { } // constructor - iterator(Tree& tree,const Query_item& q, const Distance& tr=Distance(), FT eps=FT(0.0), + iterator(const Tree& tree,const Query_item& q, const Distance& tr=Distance(), FT eps=FT(0.0), bool search_nearest=true) : Ptr_implementation(new Iterator_implementation(tree, q, tr, eps, search_nearest)) {} diff --git a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h index 626043aaa22..e9c32b3fc30 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h @@ -36,7 +36,7 @@ class Orthogonal_k_neighbor_search: public internal::K_neighbor_searchis_leaf())) { diff --git a/Spatial_searching/include/CGAL/Point_container.h b/Spatial_searching/include/CGAL/Point_container.h index d9f119c76d0..4e6f9fbf31c 100644 --- a/Spatial_searching/include/CGAL/Point_container.h +++ b/Spatial_searching/include/CGAL/Point_container.h @@ -37,12 +37,13 @@ class Point_container { private: typedef typename Traits::Point_d Point_d; - typedef std::vector Point_vector; + typedef std::vector Point_vector; public: typedef typename Traits::FT FT; typedef typename Point_vector::iterator iterator; + typedef typename Point_vector::const_iterator const_iterator; private: Traits traits; @@ -203,16 +204,28 @@ public: return *m_e - *m_b; } - inline iterator + inline const_iterator begin() const { return *m_b; } - inline iterator + inline const_iterator end() const { return *m_e; } + + inline iterator + begin() + { + return *m_b; + } + + inline iterator + end() + { + return *m_e; + } inline bool empty() const @@ -244,7 +257,7 @@ public: struct Cmp { typedef typename Traits2::FT FT; typedef typename Traits2::Point_d Point_d; - typedef std::vector Point_vector; + typedef std::vector Point_vector; int split_coord; FT value; @@ -255,7 +268,7 @@ public: {} bool - operator()(Point_d* pt) const + operator()(const Point_d* pt) const { typename Traits2::Cartesian_const_iterator_d ptit; ptit = construct_it(*pt); @@ -268,7 +281,7 @@ public: struct Between { typedef typename Traits2::FT FT; typedef typename Traits2::Point_d Point_d; - typedef std::vector Point_vector; + typedef std::vector Point_vector; int split_coord; FT low, high; @@ -279,7 +292,7 @@ public: {} bool - operator()(Point_d* pt) const + operator()(const Point_d* pt) const { typename Traits2::Cartesian_const_iterator_d ptit; ptit = construct_it(*pt); @@ -313,7 +326,7 @@ public: typename Traits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); Between between(i,tbox.min_coord(i), tbox.max_coord(i), construct_it); - for(iterator it = begin(); it != end(); it++){ + for(const_iterator it = begin(); it != end(); it++){ b = (b && between(*it)); } } @@ -401,10 +414,10 @@ public: FT - median(const int split_coord) + median(const int split_coord) { typename Traits::Construct_cartesian_const_iterator_d construct_it=traits.construct_cartesian_const_iterator_d_object(); - typename Point_vector::iterator mid = begin() + (end() - begin())/2; + iterator mid = begin() + (end() - begin())/2; std::nth_element(begin(), mid, end(),comp_coord_val(split_coord,construct_it)); typename Traits::Cartesian_const_iterator_d mpit = construct_it((*(*mid))); diff --git a/Spatial_searching/include/CGAL/Splitters.h b/Spatial_searching/include/CGAL/Splitters.h index e9935fd308f..8bd46111824 100644 --- a/Spatial_searching/include/CGAL/Splitters.h +++ b/Spatial_searching/include/CGAL/Splitters.h @@ -1,4 +1,4 @@ -// Copyright (c) 2002 Utrecht University (The Netherlands). +// Copyright (c) 2002-2011 Utrecht University (The Netherlands). // All rights reserved. // // This file is part of CGAL (www.cgal.org); you may redistribute it under @@ -79,7 +79,7 @@ namespace CGAL { void operator() (Separator& sep, Container& c0, - Container& c1) + Container& c1) const { sep=Separator(c0.max_tight_span_coord(),FT(0)); sep.set_cutting_value(c0.median(sep.cutting_dimension())); @@ -109,7 +109,7 @@ namespace CGAL { {} void - operator()(Separator& sep, Container& c0, Container& c1) + operator()(Separator& sep, Container& c0, Container& c1) const { // find legal cut with max spread sep=Separator(c0.max_tight_span_coord_balanced(this->aspect_ratio()), @@ -143,7 +143,7 @@ namespace CGAL { {} void - operator() (Separator& sep, Container& c0, Container& c1) + operator() (Separator& sep, Container& c0, Container& c1) const { // find legal cut with max spread @@ -179,7 +179,7 @@ namespace CGAL { {} void - operator()(Separator& sep, Container& c0, Container& c1) + operator()(Separator& sep, Container& c0, Container& c1) const { CGAL_assertion(c0.is_valid()); CGAL_assertion(c1.is_valid()); @@ -227,7 +227,7 @@ namespace CGAL { {} void - operator() (Separator& sep, Container& c0, Container& c1) + operator() (Separator& sep, Container& c0, Container& c1) const { sep = Separator(c0.max_span_coord(),FT(0)); sep.set_cutting_value(c0.median(sep.cutting_dimension())); @@ -257,7 +257,7 @@ namespace CGAL { {} void - operator()(Separator& sep, Container& c0, Container& c1) + operator()(Separator& sep, Container& c0, Container& c1) const { sep = Separator(c0.max_tight_span_coord(), (c0.max_tight_span_upper() + c0.max_tight_span_lower())/FT(2)); @@ -287,7 +287,7 @@ namespace CGAL { {} void - operator()(Separator& sep, Container& c0, Container& c1) + operator()(Separator& sep, Container& c0, Container& c1) const { sep = Separator(c0.max_span_coord(), (c0.max_span_upper() + c0.max_span_lower())/FT(2)); diff --git a/Spatial_searching/include/CGAL/Weighted_Minkowski_distance.h b/Spatial_searching/include/CGAL/Weighted_Minkowski_distance.h index ea7f0b75f7d..09d8a690014 100644 --- a/Spatial_searching/include/CGAL/Weighted_Minkowski_distance.h +++ b/Spatial_searching/include/CGAL/Weighted_Minkowski_distance.h @@ -95,7 +95,7 @@ namespace CGAL { inline FT - transformed_distance(const Query_item& q, const Point_d& p) + transformed_distance(const Query_item& q, const Point_d& p) const { FT distance = FT(0); typename SearchTraits::Construct_cartesian_const_iterator_d construct_it= diff --git a/Spatial_searching/include/CGAL/internal/K_neighbor_search.h b/Spatial_searching/include/CGAL/internal/K_neighbor_search.h index d762a199f2b..9f7bb29702a 100644 --- a/Spatial_searching/include/CGAL/internal/K_neighbor_search.h +++ b/Spatial_searching/include/CGAL/internal/K_neighbor_search.h @@ -1,4 +1,4 @@ -// Copyright (c) 2002 Utrecht University (The Netherlands). +// Copyright (c) 2002,2011 Utrecht University (The Netherlands). // All rights reserved. // // This file is part of CGAL (www.cgal.org); you may redistribute it under @@ -48,11 +48,12 @@ public: typedef std::pair Point_with_transformed_distance; typedef typename Tree::Node_handle Node_handle; + typedef typename Tree::Node_const_handle Node_const_handle; typedef typename Tree::Point_d_iterator Point_d_iterator; //undocumented type - typedef std::pair Point_ptr_with_transformed_distance; + typedef std::pair Point_ptr_with_transformed_distance; protected: // Comparison functor to sort a set of points