Skip to content

Commit

Permalink
Changed draw_geometries to use default args instead of overload (#7097)
Browse files Browse the repository at this point in the history
* Changed lookat, up, front, and zoom to optional args.
This is in line with the cpp implementation and avoids named args before
positional args.
* Removed overload since default args serve this case already
  • Loading branch information
timohl authored Dec 16, 2024
1 parent e0f5cdf commit 8e43455
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion cpp/open3d/visualization/utility/DrawGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool DrawGeometries(const std::vector<std::shared_ptr<const geometry::Geometry>>
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)) {
Expand Down
37 changes: 12 additions & 25 deletions cpp/pybind/visualization/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,41 +114,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) {
bool mesh_show_back_face,
utility::optional<Eigen::Vector3d> lookat,
utility::optional<Eigen::Vector3d> up,
utility::optional<Eigen::Vector3d> front,
utility::optional<double> 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);
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);
m.def(
"draw_geometries",
[](const std::vector<std::shared_ptr<const geometry::Geometry>>
&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) {
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);
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);

Expand Down

0 comments on commit 8e43455

Please sign in to comment.