From df984e9b59dc0428b9f1d3ae5bbc55229bfe8755 Mon Sep 17 00:00:00 2001 From: Tim Ohliger Date: Sat, 31 Aug 2024 19:36:41 +0200 Subject: [PATCH 1/2] Changed lookat, up, front, and zoom to optional args. This is in line with the cpp implementation and avoids named args before positional args. --- .../visualization/utility/DrawGeometry.cpp | 2 +- cpp/pybind/visualization/utility.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cpp/open3d/visualization/utility/DrawGeometry.cpp b/cpp/open3d/visualization/utility/DrawGeometry.cpp index e057e393f29..858cd514d61 100644 --- a/cpp/open3d/visualization/utility/DrawGeometry.cpp +++ b/cpp/open3d/visualization/utility/DrawGeometry.cpp @@ -35,7 +35,7 @@ bool DrawGeometries(const std::vector> Eigen::Vector3d *lookat /* = nullptr */, Eigen::Vector3d *up /* = nullptr */, Eigen::Vector3d *front /* = nullptr */, - double *zoom /* = zoom */) { + double *zoom /* = nullptr */) { Visualizer visualizer; if (!visualizer.CreateVisualizerWindow(window_name, width, height, left, top)) { diff --git a/cpp/pybind/visualization/utility.cpp b/cpp/pybind/visualization/utility.cpp index 77d63d5e100..70269ab36b1 100644 --- a/cpp/pybind/visualization/utility.cpp +++ b/cpp/pybind/visualization/utility.cpp @@ -133,22 +133,28 @@ void pybind_visualization_utility_definitions(py::module &m) { &geometry_ptrs, const std::string &window_name, int width, int height, int left, int top, bool point_show_normal, bool mesh_show_wireframe, - bool mesh_show_back_face, Eigen::Vector3d lookat, - Eigen::Vector3d up, Eigen::Vector3d front, double zoom) { + bool mesh_show_back_face, + utility::optional lookat, + utility::optional up, + utility::optional front, + utility::optional zoom) { std::string current_dir = utility::filesystem::GetWorkingDirectory(); DrawGeometries(geometry_ptrs, window_name, width, height, left, top, point_show_normal, mesh_show_wireframe, - mesh_show_back_face, &lookat, &up, &front, - &zoom); + mesh_show_back_face, + lookat.has_value() ? &lookat.value() : nullptr, + up.has_value() ? &up.value() : nullptr, + front.has_value() ? &front.value() : nullptr, + zoom.has_value() ? &zoom.value() : nullptr); utility::filesystem::ChangeWorkingDirectory(current_dir); }, "Function to draw a list of geometry::Geometry objects", "geometry_list"_a, "window_name"_a = "Open3D", "width"_a = 1920, "height"_a = 1080, "left"_a = 50, "top"_a = 50, "point_show_normal"_a = false, "mesh_show_wireframe"_a = false, - "mesh_show_back_face"_a = false, "lookat"_a, "up"_a, "front"_a, - "zoom"_a); + "mesh_show_back_face"_a = false, "lookat"_a = py::none(), + "up"_a = py::none(), "front"_a = py::none(), "zoom"_a = py::none()); docstring::FunctionDocInject(m, "draw_geometries", map_shared_argument_docstrings); From a0a3bcba09a2b6fe0a1b36a5975b6c9ac3c0ca9b Mon Sep 17 00:00:00 2001 From: Tim Ohliger Date: Mon, 16 Dec 2024 14:21:03 +0100 Subject: [PATCH 2/2] Removed overload since default args serve this case already --- cpp/pybind/visualization/utility.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/cpp/pybind/visualization/utility.cpp b/cpp/pybind/visualization/utility.cpp index 70269ab36b1..1e0cb09329f 100644 --- a/cpp/pybind/visualization/utility.cpp +++ b/cpp/pybind/visualization/utility.cpp @@ -108,25 +108,6 @@ void pybind_visualization_utility_definitions(py::module &m) { {"up", "The up vector of the camera."}, {"front", "The front vector of the camera."}, {"zoom", "The zoom of the camera."}}; - m.def( - "draw_geometries", - [](const std::vector> - &geometry_ptrs, - const std::string &window_name, int width, int height, int left, - int top, bool point_show_normal, bool mesh_show_wireframe, - bool mesh_show_back_face) { - std::string current_dir = - utility::filesystem::GetWorkingDirectory(); - DrawGeometries(geometry_ptrs, window_name, width, height, left, - top, point_show_normal, mesh_show_wireframe, - mesh_show_back_face); - utility::filesystem::ChangeWorkingDirectory(current_dir); - }, - "Function to draw a list of geometry::Geometry objects", - "geometry_list"_a, "window_name"_a = "Open3D", "width"_a = 1920, - "height"_a = 1080, "left"_a = 50, "top"_a = 50, - "point_show_normal"_a = false, "mesh_show_wireframe"_a = false, - "mesh_show_back_face"_a = false); m.def( "draw_geometries", [](const std::vector>