File: 0010-Add-option-WITH_EMBREE.patch

package info (click to toggle)
open3d 0.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 83,236 kB
  • sloc: cpp: 206,501; python: 27,254; ansic: 8,356; javascript: 1,883; sh: 1,527; makefile: 259; xml: 69
file content (185 lines) | stat: -rw-r--r-- 6,935 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Tue, 14 Dec 2021 21:07:08 +0100
Subject: Add option WITH_EMBREE

Forwarded: not-needed
---
 3rdparty/find_dependencies.cmake       |  2 ++
 CMakeLists.txt                         |  1 +
 cpp/open3d/t/geometry/CMakeLists.txt   |  2 +-
 cpp/open3d/t/geometry/TriangleMesh.cpp | 16 ++++++++++++++++
 cpp/pybind/t/geometry/CMakeLists.txt   |  5 ++++-
 cpp/pybind/t/geometry/geometry.cpp     |  4 ++++
 cpp/pybind/t/geometry/geometry.h       |  2 ++
 7 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake
index 8b88f4c..91fe59c 100644
--- a/3rdparty/find_dependencies.cmake
+++ b/3rdparty/find_dependencies.cmake
@@ -1894,6 +1894,7 @@ if (BUILD_CUDA_MODULE)
 endif ()
 
 # embree
+if(WITH_EMBREE)
 if(USE_SYSTEM_EMBREE)
     open3d_find_package_3rdparty_library(3rdparty_embree
         PACKAGE embree
@@ -1914,6 +1915,7 @@ if(NOT USE_SYSTEM_EMBREE)
     )
 endif()
 list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_embree)
+endif()
 
 # WebRTC
 if(BUILD_WEBRTC)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 354125d..55e7202 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -132,6 +132,7 @@ endif()
 
 option(PREFER_OSX_HOMEBREW        "Prefer Homebrew libs over frameworks"     ON )
 option(WITH_MINIZIP               "Enable MiniZIP"                           OFF)
+option(WITH_EMBREE                "Enable Embree"                            OFF)
 
 # Sensor options
 option(BUILD_LIBREALSENSE         "Build support for Intel RealSense camera" OFF)
diff --git a/cpp/open3d/t/geometry/CMakeLists.txt b/cpp/open3d/t/geometry/CMakeLists.txt
index e345c81..b461f47 100644
--- a/cpp/open3d/t/geometry/CMakeLists.txt
+++ b/cpp/open3d/t/geometry/CMakeLists.txt
@@ -19,7 +19,7 @@ if (BUILD_SYCL_MODULE)
     open3d_sycl_target_sources(tgeometry PRIVATE
         RaycastingScene.cpp
     )
-else()
+elseif(WITH_EMBREE)
     target_sources(tgeometry PRIVATE
         RaycastingScene.cpp
     )
diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp
index 938f733..53f7df2 100644
--- a/cpp/open3d/t/geometry/TriangleMesh.cpp
+++ b/cpp/open3d/t/geometry/TriangleMesh.cpp
@@ -43,7 +43,9 @@
 #include "open3d/core/nns/NearestNeighborSearch.h"
 #include "open3d/t/geometry/LineSet.h"
 #include "open3d/t/geometry/PointCloud.h"
+#ifdef WITH_EMBREE
 #include "open3d/t/geometry/RaycastingScene.h"
+#endif
 #include "open3d/t/geometry/VtkUtils.h"
 #include "open3d/t/geometry/kernel/IPPImage.h"
 #include "open3d/t/geometry/kernel/Metrics.h"
@@ -874,6 +876,7 @@ void ComputePrimitiveInfoTexture(int size,
                                  core::Tensor &primitive_uvs,
                                  core::Tensor &sqrdistance,
                                  const core::Tensor &texture_uvs) {
+#ifdef WITH_EMBREE
     const int64_t num_triangles = texture_uvs.GetLength();
 
     // Generate vertices for each triangle using (u,v,0) as position.
@@ -925,6 +928,9 @@ void ComputePrimitiveInfoTexture(int size,
             (closest_points_map - query_points_map).colwise().squaredNorm();
     primitive_ids = ans["primitive_ids"];
     primitive_uvs = ans["primitive_uvs"];
+#else
+    utility::LogError("ComputePrimitiveInfoTexture unsupported without Embree");
+#endif
 }
 void UpdateMaterialTextures(
         std::unordered_map<std::string, core::Tensor> &textures,
@@ -1447,6 +1453,7 @@ Image TriangleMesh::ProjectImagesToAlbedo(
         const std::vector<core::Tensor> &extrinsic_matrices,
         int tex_size /*=1024*/,
         bool update_material /*=true*/) {
+#ifdef WITH_EMBREE
     if (!GetDevice().IsCPU() || !Image::HAVE_IPP) {
         utility::LogError(
                 "ProjectImagesToAlbedo is only supported on x86_64 CPU "
@@ -1624,6 +1631,10 @@ Image TriangleMesh::ProjectImagesToAlbedo(
         GetMaterial().SetAlbedoMap(albedo_texture);
     }
     return albedo_texture;
+#else
+    utility::LogError("ProjectImagesToAlbedo unsupported without Embree");
+    return Image();
+#endif
 }
 
 namespace {
@@ -1863,6 +1874,7 @@ PointCloud TriangleMesh::SamplePointsUniformly(
 core::Tensor TriangleMesh::ComputeMetrics(const TriangleMesh &mesh2,
                                           std::vector<Metric> metrics,
                                           MetricParameters params) const {
+#if HAVE_EMBREE
     if (IsEmpty() || mesh2.IsEmpty()) {
         utility::LogError("One or both input triangle meshes are empty!");
     }
@@ -1888,6 +1900,10 @@ core::Tensor TriangleMesh::ComputeMetrics(const TriangleMesh &mesh2,
     core::Tensor distance12 = scene2.ComputeDistance(points1);
 
     return ComputeMetricsCommon(distance12, distance21, metrics, params);
+#else
+    utility::LogError("ComputeMetrics is unsupported without Embree");
+    return core::Tensor();
+#endif
 }
 
 }  // namespace geometry
diff --git a/cpp/pybind/t/geometry/CMakeLists.txt b/cpp/pybind/t/geometry/CMakeLists.txt
index acc0339..0b60899 100644
--- a/cpp/pybind/t/geometry/CMakeLists.txt
+++ b/cpp/pybind/t/geometry/CMakeLists.txt
@@ -5,8 +5,11 @@ target_sources(pybind PRIVATE
     lineset.cpp
     pointcloud.cpp
     boundingvolume.cpp
-    raycasting_scene.cpp
     tensormap.cpp
     trianglemesh.cpp
     voxel_block_grid.cpp
 )
+if(WITH_EMBREE)
+    target_compile_definitions(pybind PRIVATE WITH_EMBREE=1)
+    target_sources(pybind PRIVATE raycasting_scene.cpp)
+endif()
diff --git a/cpp/pybind/t/geometry/geometry.cpp b/cpp/pybind/t/geometry/geometry.cpp
index f6c5712..ce7358c 100644
--- a/cpp/pybind/t/geometry/geometry.cpp
+++ b/cpp/pybind/t/geometry/geometry.cpp
@@ -71,7 +71,9 @@ void pybind_geometry_declarations(py::module& m) {
     pybind_image_declarations(m_geometry);
     pybind_boundingvolume_declarations(m_geometry);
     pybind_voxel_block_grid_declarations(m_geometry);
+#ifdef WITH_EMBREE
     pybind_raycasting_scene_declarations(m_geometry);
+#endif
 }
 
 void pybind_geometry_definitions(py::module& m) {
@@ -120,7 +122,9 @@ void pybind_geometry_definitions(py::module& m) {
     pybind_image_definitions(m_geometry);
     pybind_boundingvolume_definitions(m_geometry);
     pybind_voxel_block_grid_definitions(m_geometry);
+#ifdef WITH_EMBREE
     pybind_raycasting_scene_definitions(m_geometry);
+#endif
 }
 
 }  // namespace geometry
diff --git a/cpp/pybind/t/geometry/geometry.h b/cpp/pybind/t/geometry/geometry.h
index 1776a28..1a0b07f 100644
--- a/cpp/pybind/t/geometry/geometry.h
+++ b/cpp/pybind/t/geometry/geometry.h
@@ -56,7 +56,9 @@ void pybind_trianglemesh_definitions(py::module& m);
 void pybind_image_definitions(py::module& m);
 void pybind_boundingvolume_definitions(py::module& m);
 void pybind_voxel_block_grid_definitions(py::module& m);
+#ifdef WITH_EMBREE
 void pybind_raycasting_scene_definitions(py::module& m);
+#endif
 
 }  // namespace geometry
 }  // namespace t