Skip to content

Commit 8e43455

Browse files
authored
Changed draw_geometries to use default args instead of overload (#7097)
* 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
1 parent e0f5cdf commit 8e43455

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

cpp/open3d/visualization/utility/DrawGeometry.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool DrawGeometries(const std::vector<std::shared_ptr<const geometry::Geometry>>
3535
Eigen::Vector3d *lookat /* = nullptr */,
3636
Eigen::Vector3d *up /* = nullptr */,
3737
Eigen::Vector3d *front /* = nullptr */,
38-
double *zoom /* = zoom */) {
38+
double *zoom /* = nullptr */) {
3939
Visualizer visualizer;
4040
if (!visualizer.CreateVisualizerWindow(window_name, width, height, left,
4141
top)) {

cpp/pybind/visualization/utility.cpp

+12-25
Original file line numberDiff line numberDiff line change
@@ -114,41 +114,28 @@ void pybind_visualization_utility_definitions(py::module &m) {
114114
&geometry_ptrs,
115115
const std::string &window_name, int width, int height, int left,
116116
int top, bool point_show_normal, bool mesh_show_wireframe,
117-
bool mesh_show_back_face) {
117+
bool mesh_show_back_face,
118+
utility::optional<Eigen::Vector3d> lookat,
119+
utility::optional<Eigen::Vector3d> up,
120+
utility::optional<Eigen::Vector3d> front,
121+
utility::optional<double> zoom) {
118122
std::string current_dir =
119123
utility::filesystem::GetWorkingDirectory();
120124
DrawGeometries(geometry_ptrs, window_name, width, height, left,
121125
top, point_show_normal, mesh_show_wireframe,
122-
mesh_show_back_face);
126+
mesh_show_back_face,
127+
lookat.has_value() ? &lookat.value() : nullptr,
128+
up.has_value() ? &up.value() : nullptr,
129+
front.has_value() ? &front.value() : nullptr,
130+
zoom.has_value() ? &zoom.value() : nullptr);
123131
utility::filesystem::ChangeWorkingDirectory(current_dir);
124132
},
125133
"Function to draw a list of geometry::Geometry objects",
126134
"geometry_list"_a, "window_name"_a = "Open3D", "width"_a = 1920,
127135
"height"_a = 1080, "left"_a = 50, "top"_a = 50,
128136
"point_show_normal"_a = false, "mesh_show_wireframe"_a = false,
129-
"mesh_show_back_face"_a = false);
130-
m.def(
131-
"draw_geometries",
132-
[](const std::vector<std::shared_ptr<const geometry::Geometry>>
133-
&geometry_ptrs,
134-
const std::string &window_name, int width, int height, int left,
135-
int top, bool point_show_normal, bool mesh_show_wireframe,
136-
bool mesh_show_back_face, Eigen::Vector3d lookat,
137-
Eigen::Vector3d up, Eigen::Vector3d front, double zoom) {
138-
std::string current_dir =
139-
utility::filesystem::GetWorkingDirectory();
140-
DrawGeometries(geometry_ptrs, window_name, width, height, left,
141-
top, point_show_normal, mesh_show_wireframe,
142-
mesh_show_back_face, &lookat, &up, &front,
143-
&zoom);
144-
utility::filesystem::ChangeWorkingDirectory(current_dir);
145-
},
146-
"Function to draw a list of geometry::Geometry objects",
147-
"geometry_list"_a, "window_name"_a = "Open3D", "width"_a = 1920,
148-
"height"_a = 1080, "left"_a = 50, "top"_a = 50,
149-
"point_show_normal"_a = false, "mesh_show_wireframe"_a = false,
150-
"mesh_show_back_face"_a = false, "lookat"_a, "up"_a, "front"_a,
151-
"zoom"_a);
137+
"mesh_show_back_face"_a = false, "lookat"_a = py::none(),
138+
"up"_a = py::none(), "front"_a = py::none(), "zoom"_a = py::none());
152139
docstring::FunctionDocInject(m, "draw_geometries",
153140
map_shared_argument_docstrings);
154141

0 commit comments

Comments
 (0)