From b047bac49f3f2a32ec4c6a4b10b6b7cb09116425 Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 12:41:08 +0800 Subject: [PATCH 1/6] RTree class --- core/rtree.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/rtree.h b/core/rtree.h index c8e3df6..036dd86 100644 --- a/core/rtree.h +++ b/core/rtree.h @@ -64,10 +64,10 @@ class RTree public: RTree(); ~RTree(); - // RTree(const RTree&) = delete; - // RTree& operator=(const RTree&) = delete; - // RTree(RTree&&) = delete; - // RTree& operator=(RTree&&) = delete; + RTree(const RTree&) = delete; + RTree& operator=(const RTree&) = delete; + RTree(RTree&&) = delete; + RTree& operator=(RTree&&) = delete; void insert(const Box2 &box, int id); void erase(int id); void update(int id, const Box2 &new_box); From f35f9f41f534d8e882f6f3ee112cecce6fb620dd Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 13:16:07 +0800 Subject: [PATCH 2/6] removed unused method for python binding --- binding/pybind.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/binding/pybind.cpp b/binding/pybind.cpp index 45023e6..c94901d 100644 --- a/binding/pybind.cpp +++ b/binding/pybind.cpp @@ -30,13 +30,7 @@ PYBIND11_MODULE(rtse, m) py::return_value_policy::reference_internal) .def_property_readonly("max", &rtse::Box2::max, py::return_value_policy::reference_internal) - .def_property_readonly("is_empty", &rtse::Box2::is_empty) - .def_static("from_point", &rtse::Box2::from_point, py::arg("p")) - .def("area", &rtse::Box2::area) .def("overlap", &rtse::Box2::overlap, py::arg("other")) - .def_static("merge", &rtse::Box2::merge, py::arg("box1"), - py::arg("box2")) - .def("enlarge_area", &rtse::Box2::enlarge_area, py::arg("other")) .def(py::self == py::self) .def(py::self != py::self) .def("__repr__", From 1bf907169a5d8d5190ca99f9f7a4ffb46eaec90c Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 13:20:37 +0800 Subject: [PATCH 3/6] let run_test.sh executable --- binding/pybind.cpp | 2 +- script/run_test.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 script/run_test.sh diff --git a/binding/pybind.cpp b/binding/pybind.cpp index c94901d..cc96089 100644 --- a/binding/pybind.cpp +++ b/binding/pybind.cpp @@ -25,7 +25,7 @@ PYBIND11_MODULE(rtse, m) py::class_(m, "Box2", "Axis-aligned bounding box [min, max].") .def(py::init<>()) .def(py::init(), - py::arg("pmin"), py::arg("pmax")) + py::arg("min"), py::arg("max")) .def_property_readonly("min", &rtse::Box2::min, py::return_value_policy::reference_internal) .def_property_readonly("max", &rtse::Box2::max, diff --git a/script/run_test.sh b/script/run_test.sh old mode 100644 new mode 100755 From 44a87843cc8666e5c88ded14410730378dbb0328 Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 13:51:34 +0800 Subject: [PATCH 4/6] remove unused tests --- CMakeLists.txt | 13 ------------- tests/test_box2.cpp | 13 ------------- tests/test_dummy.cpp | 9 --------- 3 files changed, 35 deletions(-) delete mode 100644 tests/test_box2.cpp delete mode 100644 tests/test_dummy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8523300..f19b1fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,32 +14,19 @@ FetchContent_Declare( URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) -set(INSTALL_GTEST OFF) FetchContent_MakeAvailable(googletest) include(GoogleTest) add_library(rtse_core STATIC core/rtree.cpp ) -set_target_properties(rtse_core PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories(rtse_core PUBLIC ${PROJECT_SOURCE_DIR}/core) pybind11_add_module(rtse binding/pybind.cpp) target_link_libraries(rtse PRIVATE rtse_core) -target_include_directories(rtse PRIVATE ${pybind11_INCLUDE_DIRS}) set_target_properties(rtse PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) -add_custom_command(TARGET rtse POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - ${CMAKE_BINARY_DIR}/$ -) - -add_executable(dummy tests/test_dummy.cpp) -set_target_properties(dummy PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" -) add_executable(test_rtree tests/test_rtree.cpp) target_link_libraries(test_rtree PRIVATE GTest::gtest_main) diff --git a/tests/test_box2.cpp b/tests/test_box2.cpp deleted file mode 100644 index 03143d6..0000000 --- a/tests/test_box2.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../core/rtree.h" -#include - -int main() -{ - rtse::Box2 box1(rtse::Point2(0, 0), rtse::Point2(1, 1)); - rtse::Box2 box2(rtse::Point2(0.5, 0.5), rtse::Point2(2, 2)); - assert(box1.overlap(box2)); - assert(box1.area() == 1.0); - auto box3 = rtse::Box2::merge(box1, box2); - assert(box3.max.x == 2 && box3.max.y == 2); - assert(box1.enlarge_area(box2) > 0); -} \ No newline at end of file diff --git a/tests/test_dummy.cpp b/tests/test_dummy.cpp deleted file mode 100644 index a21959e..0000000 --- a/tests/test_dummy.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int main() -{ - std::cout << "Dummy test running..." << std::endl; - std::cout << "Dummy test passed!" << std::endl; - return 0; -} \ No newline at end of file From 18d06beb9d39dccac274e497d46cfc02a00d46c3 Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 13:58:54 +0800 Subject: [PATCH 5/6] add a target property for rtse_core --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f19b1fc..016a9d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(rtse_core STATIC core/rtree.cpp ) target_include_directories(rtse_core PUBLIC ${PROJECT_SOURCE_DIR}/core) +set_target_properties(rtse_core PROPERTIES POSITION_INDEPENDENT_CODE ON) pybind11_add_module(rtse binding/pybind.cpp) target_link_libraries(rtse PRIVATE rtse_core) From 2e74441fb6979227e0c4881ba0cd896cb2c630fc Mon Sep 17 00:00:00 2001 From: haoyu Date: Thu, 11 Dec 2025 14:10:50 +0800 Subject: [PATCH 6/6] modify the order of CMakeLists.txt --- CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 016a9d4..074294f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,16 +7,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(PYBIND11_FINDPYTHON ON) find_package(pybind11 REQUIRED) -enable_testing() -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip - DOWNLOAD_EXTRACT_TIMESTAMP TRUE -) -FetchContent_MakeAvailable(googletest) -include(GoogleTest) - add_library(rtse_core STATIC core/rtree.cpp ) @@ -29,11 +19,20 @@ set_target_properties(rtse PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ) +enable_testing() +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) +FetchContent_MakeAvailable(googletest) +include(GoogleTest) + add_executable(test_rtree tests/test_rtree.cpp) target_link_libraries(test_rtree PRIVATE GTest::gtest_main) target_link_libraries(test_rtree PRIVATE rtse_core) set_target_properties(test_rtree PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/" ) - gtest_discover_tests(test_rtree) \ No newline at end of file