From bbeb21a33232a5ed9d176c4fede67ad4770c3435 Mon Sep 17 00:00:00 2001 From: Ernesto Rodriguez Date: Thu, 4 Jul 2024 08:18:02 +0000 Subject: [PATCH 1/8] Allow compiling open3d-cpu python package on NixOs 24.05 * Remove the use of deprecated functions in ImGui * CMake option to exclude uvatlas as dependency as a single function leads to the inclusion of many libraries. * CMake option to override the desktop install path --- 3rdparty/find_dependencies.cmake | 21 +++++----- CMakeLists.txt | 1 + cpp/apps/CMakeLists.txt | 4 +- cpp/open3d/t/geometry/TriangleMesh.cpp | 6 +++ cpp/open3d/t/geometry/TriangleMesh.h | 3 +- cpp/open3d/t/geometry/kernel/CMakeLists.txt | 44 ++++++++++++++------- cpp/open3d/visualization/gui/ListView.cpp | 8 ++-- cpp/pybind/t/geometry/trianglemesh.cpp | 3 ++ 8 files changed, 59 insertions(+), 31 deletions(-) diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index 1db3494e3ed..238f03d773a 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -1523,16 +1523,17 @@ endif() list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_vtk) # UVAtlas -include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) -open3d_import_3rdparty_library(3rdparty_uvatlas - HIDDEN - INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} - LIB_DIR ${UVATLAS_LIB_DIR} - LIBRARIES ${UVATLAS_LIBRARIES} - DEPENDS ext_uvatlas -) -list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) - +if(WITH_UV_ATLAS) + include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) + open3d_import_3rdparty_library(3rdparty_uvatlas + HIDDEN + INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} + LIB_DIR ${UVATLAS_LIB_DIR} + LIBRARIES ${UVATLAS_LIBRARIES} + DEPENDS ext_uvatlas + ) + list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) +endif() if(BUILD_SYCL_MODULE) add_library(3rdparty_sycl INTERFACE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5784bb4aa..0ff19438b85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,7 @@ if(LINUX_AARCH64) else() option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) endif() +option(WITH_UV_ATLAS "Include the TriangleMesh::ComputeUVAtlas function (requires uvatlas and DirectX)." ON) option(PREFER_OSX_HOMEBREW "Prefer Homebrew libs over frameworks" ON ) option(WITH_MINIZIP "Enable MiniZIP" OFF) diff --git a/cpp/apps/CMakeLists.txt b/cpp/apps/CMakeLists.txt index 8b718c9968c..8d5bc944480 100644 --- a/cpp/apps/CMakeLists.txt +++ b/cpp/apps/CMakeLists.txt @@ -54,7 +54,9 @@ macro(open3d_add_app_gui SRC_DIR APP_NAME TARGET_NAME) install(DIRECTORY "${APP_DIR}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" USE_SOURCE_PERMISSIONS) - if (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") + if (DEFINED OVERRIDE_DESKTOP_INSTALL_DIR) + set(DESKTOP_INSTALL_DIR "${OVERRIDE_DESKTOP_INSTALL_DIR}") + elseif (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") set(DESKTOP_INSTALL_DIR "/usr/share") else() set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share") diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index 4342c0a2d9e..40fbac9955d 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -32,7 +32,10 @@ #include "open3d/t/geometry/kernel/PointCloud.h" #include "open3d/t/geometry/kernel/Transform.h" #include "open3d/t/geometry/kernel/TriangleMesh.h" + +#ifdef WITH_UV_ATLAS #include "open3d/t/geometry/kernel/UVUnwrapping.h" +#endif #include "open3d/utility/ParallelScan.h" namespace open3d { @@ -746,6 +749,8 @@ TriangleMesh TriangleMesh::FillHoles(double hole_size) const { return CreateTriangleMeshFromVtkPolyData(result); } +#ifdef WITH_UV_ATLAS + std::tuple TriangleMesh::ComputeUVAtlas( size_t size, float gutter, @@ -756,6 +761,7 @@ std::tuple TriangleMesh::ComputeUVAtlas( max_stretch, parallel_partitions, nthreads); } +#endif namespace { /// Bakes vertex or triangle attributes to a texure. diff --git a/cpp/open3d/t/geometry/TriangleMesh.h b/cpp/open3d/t/geometry/TriangleMesh.h index c2916c987ca..9d9149d3cb6 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.h +++ b/cpp/open3d/t/geometry/TriangleMesh.h @@ -859,12 +859,13 @@ class TriangleMesh : public Geometry, public DrawableGeometry { /// \return Tuple with (max stretch, num_charts, num_partitions) storing the /// actual amount of stretch, the number of created charts, and the number /// of parallel partitions created. +#ifdef WITH_UV_ATLAS std::tuple ComputeUVAtlas(size_t size = 512, float gutter = 1.0f, float max_stretch = 1.f / 6, int parallel_partitions = 1, int nthreads = 0); - +#endif /// Bake vertex attributes into textures. /// /// This function assumes a triangle attribute with name 'texture_uvs'. diff --git a/cpp/open3d/t/geometry/kernel/CMakeLists.txt b/cpp/open3d/t/geometry/kernel/CMakeLists.txt index 081d24a6b96..582d5136c04 100644 --- a/cpp/open3d/t/geometry/kernel/CMakeLists.txt +++ b/cpp/open3d/t/geometry/kernel/CMakeLists.txt @@ -1,19 +1,35 @@ open3d_ispc_add_library(tgeometry_kernel OBJECT) -target_sources(tgeometry_kernel PRIVATE - Image.cpp - ImageCPU.cpp - PCAPartition.cpp - PointCloud.cpp - PointCloudCPU.cpp - TriangleMesh.cpp - TriangleMeshCPU.cpp - Transform.cpp - TransformCPU.cpp - UVUnwrapping.cpp - VoxelBlockGrid.cpp - VoxelBlockGridCPU.cpp -) +if (WITH_UV_ATLAS) + target_sources(tgeometry_kernel PRIVATE + Image.cpp + ImageCPU.cpp + PCAPartition.cpp + PointCloud.cpp + PointCloudCPU.cpp + TriangleMesh.cpp + TriangleMeshCPU.cpp + Transform.cpp + TransformCPU.cpp + UVUnwrapping.cpp + VoxelBlockGrid.cpp + VoxelBlockGridCPU.cpp + ) +else() + target_sources(tgeometry_kernel PRIVATE + Image.cpp + ImageCPU.cpp + PCAPartition.cpp + PointCloud.cpp + PointCloudCPU.cpp + TriangleMesh.cpp + TriangleMeshCPU.cpp + Transform.cpp + TransformCPU.cpp + VoxelBlockGrid.cpp + VoxelBlockGridCPU.cpp + ) +endif() if (BUILD_CUDA_MODULE) target_sources(tgeometry_kernel PRIVATE diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 4d77f0bd1cd..582cfbb901a 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -116,15 +116,13 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { ImGui::PushStyleColor(ImGuiCol_HeaderActive, // click-hold color colorToImgui(context.theme.list_selected_color)); - int height_in_items = - int(std::floor(frame.height / ImGui::GetFrameHeight())); auto result = Widget::DrawResult::NONE; auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; DrawImGuiPushEnabledState(); - if (ImGui::ListBoxHeader(impl_->imgui_id_.c_str(), - int(impl_->items_.size()), height_in_items)) { + ImVec2 initial_size(0, ImGui::GetFrameHeight()); + if (ImGui::BeginListBox(impl_->imgui_id_.c_str(), initial_size)) { for (size_t i = 0; i < impl_->items_.size(); ++i) { bool is_selected = (int(i) == impl_->selected_index_); // ImGUI's list wants to hover over items, which is not done by @@ -155,7 +153,7 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { } ImGui::PopStyleColor(); } - ImGui::ListBoxFooter(); + ImGui::EndListBox(); if (new_selected_idx != impl_->selected_index_ || is_double_click) { impl_->selected_index_ = new_selected_idx; diff --git a/cpp/pybind/t/geometry/trianglemesh.cpp b/cpp/pybind/t/geometry/trianglemesh.cpp index 3227b3e63db..3958a4248f2 100644 --- a/cpp/pybind/t/geometry/trianglemesh.cpp +++ b/cpp/pybind/t/geometry/trianglemesh.cpp @@ -696,6 +696,8 @@ This function always uses the CPU device. o3d.visualization.draw([{'name': 'filled', 'geometry': ans}]) )"); +#ifdef WITH_UV_ATLAS + triangle_mesh.def( "compute_uvatlas", &TriangleMesh::ComputeUVAtlas, "size"_a = 512, "gutter"_a = 1.f, "max_stretch"_a = 1.f / 6, @@ -746,6 +748,7 @@ This function always uses the CPU device. mesh.material.texture_maps['albedo'] = o3d.t.io.read_image(texture_data.albedo_texture_path) o3d.visualization.draw(mesh) )"); +#endif triangle_mesh.def("bake_vertex_attr_textures", &TriangleMesh::BakeVertexAttrTextures, "size"_a, From b2d2e87192feef8f3d52f77bf0d81aeb174ddcc7 Mon Sep 17 00:00:00 2001 From: Ernesto Rodriguez Date: Thu, 4 Jul 2024 08:55:48 +0000 Subject: [PATCH 2/8] Set the frame size as initial item heights in the ListView. --- cpp/open3d/visualization/gui/ListView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 582cfbb901a..5caf53e732c 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -121,7 +121,7 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; DrawImGuiPushEnabledState(); - ImVec2 initial_size(0, ImGui::GetFrameHeight()); + ImVec2 initial_size(0, frame.height); if (ImGui::BeginListBox(impl_->imgui_id_.c_str(), initial_size)) { for (size_t i = 0; i < impl_->items_.size(); ++i) { bool is_selected = (int(i) == impl_->selected_index_); From ce0cff24b912801d0e5ab5c3ba8fcdb0d91633b4 Mon Sep 17 00:00:00 2001 From: Ernesto Rodriguez Date: Thu, 4 Jul 2024 08:18:02 +0000 Subject: [PATCH 3/8] Allow compiling open3d-cpu python package on NixOs 24.05 * Remove the use of deprecated functions in ImGui * CMake option to exclude uvatlas as dependency as a single function leads to the inclusion of many libraries. * CMake option to override the desktop install path --- 3rdparty/find_dependencies.cmake | 21 +++++----- CMakeLists.txt | 1 + cpp/apps/CMakeLists.txt | 4 +- cpp/open3d/t/geometry/TriangleMesh.cpp | 6 +++ cpp/open3d/t/geometry/TriangleMesh.h | 3 +- cpp/open3d/t/geometry/kernel/CMakeLists.txt | 44 ++++++++++++++------- cpp/open3d/visualization/gui/ListView.cpp | 8 ++-- cpp/pybind/t/geometry/trianglemesh.cpp | 3 ++ 8 files changed, 59 insertions(+), 31 deletions(-) diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index 1db3494e3ed..238f03d773a 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -1523,16 +1523,17 @@ endif() list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_vtk) # UVAtlas -include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) -open3d_import_3rdparty_library(3rdparty_uvatlas - HIDDEN - INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} - LIB_DIR ${UVATLAS_LIB_DIR} - LIBRARIES ${UVATLAS_LIBRARIES} - DEPENDS ext_uvatlas -) -list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) - +if(WITH_UV_ATLAS) + include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) + open3d_import_3rdparty_library(3rdparty_uvatlas + HIDDEN + INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} + LIB_DIR ${UVATLAS_LIB_DIR} + LIBRARIES ${UVATLAS_LIBRARIES} + DEPENDS ext_uvatlas + ) + list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) +endif() if(BUILD_SYCL_MODULE) add_library(3rdparty_sycl INTERFACE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e4781e7e72..acd901c30b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,7 @@ if(LINUX_AARCH64) else() option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) endif() +option(WITH_UV_ATLAS "Include the TriangleMesh::ComputeUVAtlas function (requires uvatlas and DirectX)." ON) option(PREFER_OSX_HOMEBREW "Prefer Homebrew libs over frameworks" ON ) option(WITH_MINIZIP "Enable MiniZIP" OFF) diff --git a/cpp/apps/CMakeLists.txt b/cpp/apps/CMakeLists.txt index 8b718c9968c..8d5bc944480 100644 --- a/cpp/apps/CMakeLists.txt +++ b/cpp/apps/CMakeLists.txt @@ -54,7 +54,9 @@ macro(open3d_add_app_gui SRC_DIR APP_NAME TARGET_NAME) install(DIRECTORY "${APP_DIR}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" USE_SOURCE_PERMISSIONS) - if (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") + if (DEFINED OVERRIDE_DESKTOP_INSTALL_DIR) + set(DESKTOP_INSTALL_DIR "${OVERRIDE_DESKTOP_INSTALL_DIR}") + elseif (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") set(DESKTOP_INSTALL_DIR "/usr/share") else() set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share") diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index 4342c0a2d9e..40fbac9955d 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -32,7 +32,10 @@ #include "open3d/t/geometry/kernel/PointCloud.h" #include "open3d/t/geometry/kernel/Transform.h" #include "open3d/t/geometry/kernel/TriangleMesh.h" + +#ifdef WITH_UV_ATLAS #include "open3d/t/geometry/kernel/UVUnwrapping.h" +#endif #include "open3d/utility/ParallelScan.h" namespace open3d { @@ -746,6 +749,8 @@ TriangleMesh TriangleMesh::FillHoles(double hole_size) const { return CreateTriangleMeshFromVtkPolyData(result); } +#ifdef WITH_UV_ATLAS + std::tuple TriangleMesh::ComputeUVAtlas( size_t size, float gutter, @@ -756,6 +761,7 @@ std::tuple TriangleMesh::ComputeUVAtlas( max_stretch, parallel_partitions, nthreads); } +#endif namespace { /// Bakes vertex or triangle attributes to a texure. diff --git a/cpp/open3d/t/geometry/TriangleMesh.h b/cpp/open3d/t/geometry/TriangleMesh.h index c2916c987ca..9d9149d3cb6 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.h +++ b/cpp/open3d/t/geometry/TriangleMesh.h @@ -859,12 +859,13 @@ class TriangleMesh : public Geometry, public DrawableGeometry { /// \return Tuple with (max stretch, num_charts, num_partitions) storing the /// actual amount of stretch, the number of created charts, and the number /// of parallel partitions created. +#ifdef WITH_UV_ATLAS std::tuple ComputeUVAtlas(size_t size = 512, float gutter = 1.0f, float max_stretch = 1.f / 6, int parallel_partitions = 1, int nthreads = 0); - +#endif /// Bake vertex attributes into textures. /// /// This function assumes a triangle attribute with name 'texture_uvs'. diff --git a/cpp/open3d/t/geometry/kernel/CMakeLists.txt b/cpp/open3d/t/geometry/kernel/CMakeLists.txt index 081d24a6b96..582d5136c04 100644 --- a/cpp/open3d/t/geometry/kernel/CMakeLists.txt +++ b/cpp/open3d/t/geometry/kernel/CMakeLists.txt @@ -1,19 +1,35 @@ open3d_ispc_add_library(tgeometry_kernel OBJECT) -target_sources(tgeometry_kernel PRIVATE - Image.cpp - ImageCPU.cpp - PCAPartition.cpp - PointCloud.cpp - PointCloudCPU.cpp - TriangleMesh.cpp - TriangleMeshCPU.cpp - Transform.cpp - TransformCPU.cpp - UVUnwrapping.cpp - VoxelBlockGrid.cpp - VoxelBlockGridCPU.cpp -) +if (WITH_UV_ATLAS) + target_sources(tgeometry_kernel PRIVATE + Image.cpp + ImageCPU.cpp + PCAPartition.cpp + PointCloud.cpp + PointCloudCPU.cpp + TriangleMesh.cpp + TriangleMeshCPU.cpp + Transform.cpp + TransformCPU.cpp + UVUnwrapping.cpp + VoxelBlockGrid.cpp + VoxelBlockGridCPU.cpp + ) +else() + target_sources(tgeometry_kernel PRIVATE + Image.cpp + ImageCPU.cpp + PCAPartition.cpp + PointCloud.cpp + PointCloudCPU.cpp + TriangleMesh.cpp + TriangleMeshCPU.cpp + Transform.cpp + TransformCPU.cpp + VoxelBlockGrid.cpp + VoxelBlockGridCPU.cpp + ) +endif() if (BUILD_CUDA_MODULE) target_sources(tgeometry_kernel PRIVATE diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 4d77f0bd1cd..582cfbb901a 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -116,15 +116,13 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { ImGui::PushStyleColor(ImGuiCol_HeaderActive, // click-hold color colorToImgui(context.theme.list_selected_color)); - int height_in_items = - int(std::floor(frame.height / ImGui::GetFrameHeight())); auto result = Widget::DrawResult::NONE; auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; DrawImGuiPushEnabledState(); - if (ImGui::ListBoxHeader(impl_->imgui_id_.c_str(), - int(impl_->items_.size()), height_in_items)) { + ImVec2 initial_size(0, ImGui::GetFrameHeight()); + if (ImGui::BeginListBox(impl_->imgui_id_.c_str(), initial_size)) { for (size_t i = 0; i < impl_->items_.size(); ++i) { bool is_selected = (int(i) == impl_->selected_index_); // ImGUI's list wants to hover over items, which is not done by @@ -155,7 +153,7 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { } ImGui::PopStyleColor(); } - ImGui::ListBoxFooter(); + ImGui::EndListBox(); if (new_selected_idx != impl_->selected_index_ || is_double_click) { impl_->selected_index_ = new_selected_idx; diff --git a/cpp/pybind/t/geometry/trianglemesh.cpp b/cpp/pybind/t/geometry/trianglemesh.cpp index 3227b3e63db..3958a4248f2 100644 --- a/cpp/pybind/t/geometry/trianglemesh.cpp +++ b/cpp/pybind/t/geometry/trianglemesh.cpp @@ -696,6 +696,8 @@ This function always uses the CPU device. o3d.visualization.draw([{'name': 'filled', 'geometry': ans}]) )"); +#ifdef WITH_UV_ATLAS + triangle_mesh.def( "compute_uvatlas", &TriangleMesh::ComputeUVAtlas, "size"_a = 512, "gutter"_a = 1.f, "max_stretch"_a = 1.f / 6, @@ -746,6 +748,7 @@ This function always uses the CPU device. mesh.material.texture_maps['albedo'] = o3d.t.io.read_image(texture_data.albedo_texture_path) o3d.visualization.draw(mesh) )"); +#endif triangle_mesh.def("bake_vertex_attr_textures", &TriangleMesh::BakeVertexAttrTextures, "size"_a, From 1c253fd92c539f46219af481adc4ef18da8ad9d5 Mon Sep 17 00:00:00 2001 From: Ernesto Rodriguez Date: Thu, 4 Jul 2024 08:55:48 +0000 Subject: [PATCH 4/8] Set the frame size as initial item heights in the ListView. --- cpp/open3d/visualization/gui/ListView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 582cfbb901a..5caf53e732c 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -121,7 +121,7 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; DrawImGuiPushEnabledState(); - ImVec2 initial_size(0, ImGui::GetFrameHeight()); + ImVec2 initial_size(0, frame.height); if (ImGui::BeginListBox(impl_->imgui_id_.c_str(), initial_size)) { for (size_t i = 0; i < impl_->items_.size(); ++i) { bool is_selected = (int(i) == impl_->selected_index_); From 781000b3cb611356fd0a0ff64077ea7dd25b63d7 Mon Sep 17 00:00:00 2001 From: netogallo Date: Thu, 11 Jul 2024 09:30:49 +0200 Subject: [PATCH 5/8] Fix style errors and disable the 'uvatlas' tests when the feature is not enabled. --- CMakeLists.txt | 2 +- cpp/open3d/visualization/gui/ListView.cpp | 1 - python/test/t/geometry/test_trianglemesh.py | 6 ++++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acd901c30b8..d6c2b4c006e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ if(LINUX_AARCH64) else() option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) endif() -option(WITH_UV_ATLAS "Include the TriangleMesh::ComputeUVAtlas function (requires uvatlas and DirectX)." ON) +option(WITH_UV_ATLAS "Include the TriangleMesh::ComputeUVAtlas function (requires uvatlas and DirectX)." ON ) option(PREFER_OSX_HOMEBREW "Prefer Homebrew libs over frameworks" ON ) option(WITH_MINIZIP "Enable MiniZIP" OFF) diff --git a/cpp/open3d/visualization/gui/ListView.cpp b/cpp/open3d/visualization/gui/ListView.cpp index 5caf53e732c..94ba7e8cf9d 100644 --- a/cpp/open3d/visualization/gui/ListView.cpp +++ b/cpp/open3d/visualization/gui/ListView.cpp @@ -116,7 +116,6 @@ Widget::DrawResult ListView::Draw(const DrawContext &context) { ImGui::PushStyleColor(ImGuiCol_HeaderActive, // click-hold color colorToImgui(context.theme.list_selected_color)); - auto result = Widget::DrawResult::NONE; auto new_selected_idx = impl_->selected_index_; bool is_double_click = false; diff --git a/python/test/t/geometry/test_trianglemesh.py b/python/test/t/geometry/test_trianglemesh.py index 679c65f3582..f626cb4dc89 100644 --- a/python/test/t/geometry/test_trianglemesh.py +++ b/python/test/t/geometry/test_trianglemesh.py @@ -661,6 +661,12 @@ def test_hole_filling(): def test_uvatlas(): + if not o3d._build_config['WITH_UV_ATLAS']: + # Open3d was compiled without support + # for the uvatlas function in TriangleMesh. + # This test cannot be performed with that + # configuration + return box = o3d.t.geometry.TriangleMesh.create_box() box.compute_uvatlas() assert box.triangle["texture_uvs"].shape == (12, 3, 2) From 37ff34d6ade2da28ec7f7721e5ebfc1447333837 Mon Sep 17 00:00:00 2001 From: Benjamin Ummenhofer Date: Thu, 19 Dec 2024 05:02:50 -0800 Subject: [PATCH 6/8] make DESKTOP_INSTALL_DIR a CACHE variable to allow setting it on the cmdline --- cpp/apps/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cpp/apps/CMakeLists.txt b/cpp/apps/CMakeLists.txt index e4f33cb4407..93fc823ae70 100644 --- a/cpp/apps/CMakeLists.txt +++ b/cpp/apps/CMakeLists.txt @@ -54,12 +54,10 @@ macro(open3d_add_app_gui SRC_DIR APP_NAME TARGET_NAME) install(DIRECTORY "${APP_DIR}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" USE_SOURCE_PERMISSIONS) - if (DEFINED OVERRIDE_DESKTOP_INSTALL_DIR) - set(DESKTOP_INSTALL_DIR "${OVERRIDE_DESKTOP_INSTALL_DIR}") - elseif (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") - set(DESKTOP_INSTALL_DIR "/usr/share") + if (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") + set(DESKTOP_INSTALL_DIR "/usr/share" CACHE PATH) else() - set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share") + set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share" CACHE PATH) endif() configure_file("${SOURCE_DIR}/${TARGET_NAME}.desktop.in" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${APP_NAME}.desktop") From 5c55a75788e070a9017705cbe0723c875ae09e15 Mon Sep 17 00:00:00 2001 From: Benjamin Ummenhofer Date: Thu, 19 Dec 2024 05:20:14 -0800 Subject: [PATCH 7/8] keep compute_uvatlas in the core feature set --- 3rdparty/find_dependencies.cmake | 21 ++++++++++----------- CMakeLists.txt | 1 - cpp/open3d/t/geometry/TriangleMesh.cpp | 6 ------ cpp/open3d/t/geometry/TriangleMesh.h | 3 +-- cpp/open3d/t/geometry/kernel/CMakeLists.txt | 6 +----- cpp/pybind/t/geometry/trianglemesh.cpp | 3 --- python/test/t/geometry/test_trianglemesh.py | 6 ------ 7 files changed, 12 insertions(+), 34 deletions(-) diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index 8682e464ad8..d2afbe405c9 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -1521,17 +1521,16 @@ endif() list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_vtk) # UVAtlas -if(WITH_UV_ATLAS) - include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) - open3d_import_3rdparty_library(3rdparty_uvatlas - HIDDEN - INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} - LIB_DIR ${UVATLAS_LIB_DIR} - LIBRARIES ${UVATLAS_LIBRARIES} - DEPENDS ext_uvatlas - ) - list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) -endif() +include(${Open3D_3RDPARTY_DIR}/uvatlas/uvatlas.cmake) +open3d_import_3rdparty_library(3rdparty_uvatlas + HIDDEN + INCLUDE_DIRS ${UVATLAS_INCLUDE_DIRS} + LIB_DIR ${UVATLAS_LIB_DIR} + LIBRARIES ${UVATLAS_LIBRARIES} + DEPENDS ext_uvatlas +) +list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_uvatlas) + if(BUILD_SYCL_MODULE) add_library(3rdparty_sycl INTERFACE) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd9bc3a001d..e1bd4706288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,6 @@ if(LINUX_AARCH64) else() option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) endif() -option(WITH_UV_ATLAS "Include the TriangleMesh::ComputeUVAtlas function (requires uvatlas and DirectX)." ON ) option(PREFER_OSX_HOMEBREW "Prefer Homebrew libs over frameworks" ON ) option(WITH_MINIZIP "Enable MiniZIP" OFF) diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index fee48dde3e2..05e8cc7b66f 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -35,10 +35,7 @@ #include "open3d/t/geometry/kernel/PointCloud.h" #include "open3d/t/geometry/kernel/Transform.h" #include "open3d/t/geometry/kernel/TriangleMesh.h" - -#ifdef WITH_UV_ATLAS #include "open3d/t/geometry/kernel/UVUnwrapping.h" -#endif #include "open3d/utility/ParallelScan.h" namespace open3d { @@ -758,8 +755,6 @@ TriangleMesh TriangleMesh::FillHoles(double hole_size) const { return CreateTriangleMeshFromVtkPolyData(result); } -#ifdef WITH_UV_ATLAS - std::tuple TriangleMesh::ComputeUVAtlas( size_t size, float gutter, @@ -770,7 +765,6 @@ std::tuple TriangleMesh::ComputeUVAtlas( max_stretch, parallel_partitions, nthreads); } -#endif namespace { /// Bakes vertex or triangle attributes to a texure. diff --git a/cpp/open3d/t/geometry/TriangleMesh.h b/cpp/open3d/t/geometry/TriangleMesh.h index a33ee147883..2b324751004 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.h +++ b/cpp/open3d/t/geometry/TriangleMesh.h @@ -874,13 +874,12 @@ class TriangleMesh : public Geometry, public DrawableGeometry { /// \return Tuple with (max stretch, num_charts, num_partitions) storing the /// actual amount of stretch, the number of created charts, and the number /// of parallel partitions created. -#ifdef WITH_UV_ATLAS std::tuple ComputeUVAtlas(size_t size = 512, float gutter = 1.0f, float max_stretch = 1.f / 6, int parallel_partitions = 1, int nthreads = 0); -#endif + /// Bake vertex attributes into textures. /// /// This function assumes a triangle attribute with name 'texture_uvs'. diff --git a/cpp/open3d/t/geometry/kernel/CMakeLists.txt b/cpp/open3d/t/geometry/kernel/CMakeLists.txt index 0b711053dbf..aa651596b6d 100644 --- a/cpp/open3d/t/geometry/kernel/CMakeLists.txt +++ b/cpp/open3d/t/geometry/kernel/CMakeLists.txt @@ -11,14 +11,10 @@ target_sources(tgeometry_kernel PRIVATE TriangleMeshCPU.cpp Transform.cpp TransformCPU.cpp + UVUnwrapping.cpp VoxelBlockGrid.cpp VoxelBlockGridCPU.cpp ) -if (WITH_UV_ATLAS) - target_sources(tgeometry_kernel PRIVATE - UVUnwrapping.cpp - ) -endif() if (BUILD_CUDA_MODULE) target_sources(tgeometry_kernel PRIVATE diff --git a/cpp/pybind/t/geometry/trianglemesh.cpp b/cpp/pybind/t/geometry/trianglemesh.cpp index 91be38335d3..3f56bb52d8b 100644 --- a/cpp/pybind/t/geometry/trianglemesh.cpp +++ b/cpp/pybind/t/geometry/trianglemesh.cpp @@ -766,8 +766,6 @@ This function always uses the CPU device. o3d.visualization.draw([{'name': 'filled', 'geometry': ans}]) )"); -#ifdef WITH_UV_ATLAS - triangle_mesh.def( "compute_uvatlas", &TriangleMesh::ComputeUVAtlas, "size"_a = 512, "gutter"_a = 1.f, "max_stretch"_a = 1.f / 6, @@ -817,7 +815,6 @@ This function always uses the CPU device. mesh.material.texture_maps['albedo'] = o3d.t.io.read_image(texture_data.albedo_texture_path) o3d.visualization.draw(mesh) )"); -#endif triangle_mesh.def("bake_vertex_attr_textures", &TriangleMesh::BakeVertexAttrTextures, "size"_a, diff --git a/python/test/t/geometry/test_trianglemesh.py b/python/test/t/geometry/test_trianglemesh.py index bc1cd21db3c..88678e3f877 100644 --- a/python/test/t/geometry/test_trianglemesh.py +++ b/python/test/t/geometry/test_trianglemesh.py @@ -674,12 +674,6 @@ def test_hole_filling(): def test_uvatlas(): - if not o3d._build_config['WITH_UV_ATLAS']: - # Open3d was compiled without support - # for the uvatlas function in TriangleMesh. - # This test cannot be performed with that - # configuration - return box = o3d.t.geometry.TriangleMesh.create_box() box.compute_uvatlas() assert box.triangle["texture_uvs"].shape == (12, 3, 2) From 4408259f2b62fec8a8b790ea1dac0276f8ac1d60 Mon Sep 17 00:00:00 2001 From: Benjamin Ummenhofer Date: Thu, 19 Dec 2024 05:59:18 -0800 Subject: [PATCH 8/8] add missing docstring --- cpp/apps/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/apps/CMakeLists.txt b/cpp/apps/CMakeLists.txt index 93fc823ae70..1d12f58cc24 100644 --- a/cpp/apps/CMakeLists.txt +++ b/cpp/apps/CMakeLists.txt @@ -55,9 +55,9 @@ macro(open3d_add_app_gui SRC_DIR APP_NAME TARGET_NAME) DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" USE_SOURCE_PERMISSIONS) if (CMAKE_INSTALL_PREFIX MATCHES "^(/usr/local|/opt)") - set(DESKTOP_INSTALL_DIR "/usr/share" CACHE PATH) + set(DESKTOP_INSTALL_DIR "/usr/share" CACHE PATH "The install directory for the desktop apps") else() - set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share" CACHE PATH) + set(DESKTOP_INSTALL_DIR "$ENV{HOME}/.local/share" CACHE PATH "The install directory for the desktop apps") endif() configure_file("${SOURCE_DIR}/${TARGET_NAME}.desktop.in" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${APP_NAME}.desktop")