Open3D (C++ API)
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
open3d_pybind.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <pybind11/detail/internals.h>
30 #include <pybind11/eigen.h>
31 #include <pybind11/functional.h>
32 #include <pybind11/numpy.h>
33 #include <pybind11/operators.h>
34 #include <pybind11/pybind11.h> // Include first to suppress compiler warnings
35 #include <pybind11/stl.h>
36 #include <pybind11/stl_bind.h>
37 
39 #include "Open3D/Utility/Eigen.h"
40 
41 namespace py = pybind11;
42 using namespace py::literals;
43 
44 typedef std::vector<Eigen::Matrix4d, open3d::utility::Matrix4d_allocator>
46 typedef std::vector<Eigen::Vector4i, open3d::utility::Vector4i_allocator>
48 
49 PYBIND11_MAKE_OPAQUE(std::vector<int>);
50 PYBIND11_MAKE_OPAQUE(std::vector<int64_t>);
51 PYBIND11_MAKE_OPAQUE(std::vector<uint8_t>);
52 PYBIND11_MAKE_OPAQUE(std::vector<float>);
53 PYBIND11_MAKE_OPAQUE(std::vector<double>);
54 PYBIND11_MAKE_OPAQUE(std::vector<Eigen::Vector3d>);
55 PYBIND11_MAKE_OPAQUE(std::vector<Eigen::Vector3i>);
56 PYBIND11_MAKE_OPAQUE(std::vector<Eigen::Vector2d>);
57 PYBIND11_MAKE_OPAQUE(std::vector<Eigen::Vector2i>);
60 PYBIND11_MAKE_OPAQUE(std::vector<open3d::registration::PoseGraphEdge>);
61 PYBIND11_MAKE_OPAQUE(std::vector<open3d::registration::PoseGraphNode>);
62 
63 // some helper functions
64 namespace pybind11 {
65 namespace detail {
66 
67 template <typename T, typename Class_>
68 void bind_default_constructor(Class_ &cl) {
69  cl.def(py::init([]() { return new T(); }), "Default constructor");
70 }
71 
72 template <typename T, typename Class_>
73 void bind_copy_functions(Class_ &cl) {
74  cl.def(py::init([](const T &cp) { return new T(cp); }), "Copy constructor");
75  cl.def("__copy__", [](T &v) { return T(v); });
76  cl.def("__deepcopy__", [](T &v, py::dict &memo) { return T(v); });
77 }
78 
79 } // namespace detail
80 } // namespace pybind11
std::vector< Eigen::Matrix4d, open3d::utility::Matrix4d_allocator > temp_eigen_matrix4d
Definition: open3d_pybind.h:45
Definition: open3d_pybind.h:64
void bind_default_constructor(Class_ &cl)
Definition: open3d_pybind.h:68
PYBIND11_MAKE_OPAQUE(std::vector< int >)
std::vector< Eigen::Vector4i, open3d::utility::Vector4i_allocator > temp_eigen_vector4i
Definition: open3d_pybind.h:47
void bind_copy_functions(Class_ &cl)
Definition: open3d_pybind.h:73