diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index e250857a25c8..60f13acc2023 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -29,7 +29,7 @@ template class Iterator_from_indices : public boost::iterator_facade, - Value_, std::bidirectional_iterator_tag, Ref_> + Value_, std::random_access_iterator_tag, Ref_> { friend class boost::iterator_core_access; //FIXME: use int to save space @@ -53,6 +53,9 @@ class Iterator_from_indices return ca(*cont,index); } public: + Ref_ operator[](std::ptrdiff_t n) const { + return ca(*cont,index+n); + } Iterator_from_indices(){} Iterator_from_indices(Container_& cont_,std::size_t n) : cont(&cont_), index(n) {} diff --git a/Spatial_searching/test/Spatial_searching/CMakeLists.txt b/Spatial_searching/test/Spatial_searching/CMakeLists.txt index e078b954112c..738d29ff28da 100644 --- a/Spatial_searching/test/Spatial_searching/CMakeLists.txt +++ b/Spatial_searching/test/Spatial_searching/CMakeLists.txt @@ -11,6 +11,19 @@ file( GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) + +list(REMOVE_ITEM cppfiles "issue_9534.cpp") + foreach(cppfile ${cppfiles}) create_single_source_cgal_program("${cppfile}") endforeach() + +find_package(Eigen3 QUIET) +include(CGAL_Eigen3_support) + +if(TARGET CGAL::Eigen3_support) + create_single_source_cgal_program("issue_9534.cpp") + target_link_libraries(issue_9534 PRIVATE CGAL::Eigen3_support) +else() + message(STATUS "NOTICE: The test 'issue_9534' requires Eigen3 and will not be compiled.") +endif() diff --git a/Spatial_searching/test/Spatial_searching/issue_9534.cpp b/Spatial_searching/test/Spatial_searching/issue_9534.cpp new file mode 100644 index 000000000000..446088a4e995 --- /dev/null +++ b/Spatial_searching/test/Spatial_searching/issue_9534.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +template +int test() +{ + using Traits = CGAL::Search_traits_d; + using Point = typename Traits::Point_d; + using FT = typename Kernel::FT; + using Tree = CGAL::Kd_tree; + using Fuzzy_iso_box = CGAL::Fuzzy_iso_box; + using Fuzzy_sphere = CGAL::Fuzzy_sphere; + + const std::array c0 = {FT(0), FT(0)}; + const std::array c1 = {FT(1), FT(1)}; + const std::array c2 = {FT(2), FT(2)}; + + const Point p0(2, c0.begin(), c0.end()); + const Point p1(2, c1.begin(), c1.end()); + const Point p2(2, c2.begin(), c2.end()); + + Tree tree; + tree.insert(p0); + tree.insert(p1); + tree.insert(p2); + + const Fuzzy_iso_box box(p0, p2); + std::vector result; + tree.search(std::back_inserter(result), box); + + if (result.empty()) + return 1; + + result.clear(); + + const Fuzzy_sphere sphere(p1, FT(2)); + tree.search(std::back_inserter(result), sphere); + + if (result.empty()) + return 2; + + tree.remove(p1); + + if (tree.size() != 2) + return 3; + + return 0; +} + +int main() +{ + using Static_kernel = CGAL::Epeck_d >; + using Dynamic_kernel = CGAL::Epeck_d; + + int result = test(); + + if (result != 0) + return result; + + result = test(); + + if (result != 0) + return 10 + result; + + return 0; +}