ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
matrix.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "utility/Matrix.h"
9 
11 #include "pybind/docstring.h"
12 
13 namespace py = pybind11;
14 
15 namespace cloudViewer {
16 namespace utility {
17 
18 void pybind_matrix(py::module &m) {
19  // cloudViewer.registration.TransformationEstimationPointToPoint:
20  // TransformationEstimation
21  py::class_<utility::Matrix<PointCoordinateType>> te_p2p(
22  m, "Matrix", "Class to interface of numpy and std::vector.");
23 
24  py::detail::bind_default_constructor<utility::Matrix<PointCoordinateType>>(
25  te_p2p);
26  py::detail::bind_copy_functions<utility::Matrix<PointCoordinateType>>(
27  te_p2p);
28 
29  te_p2p.def(py::init([](const std::vector<size_t> &shape,
30  const PointCoordinateType *data) {
31  return new utility::Matrix<PointCoordinateType>(shape, data);
32  }),
33  "shape"_a = std::vector<size_t>(0), "data"_a = NULL)
34  .def("__repr__",
35  [](const utility::Matrix<PointCoordinateType> &te) {
36  return std::string("utility::Matrix");
37  })
38  .def(
39  "data",
40  [](const utility::Matrix<PointCoordinateType> &s) {
41  return s.data();
42  },
43  "Function to get matrix internal ptr")
44  .def(
45  "shape",
46  [](const utility::Matrix<PointCoordinateType> &s,
47  size_t ndim = 0) { return s.shape(ndim); },
48  "ndim"_a, "Function to get matrix shape")
49  .def(
50  "strides",
51  [](const utility::Matrix<PointCoordinateType> &s,
52  bool bytes = false) { return s.strides(bytes); },
53  "bytes"_a, "Function to get matrix strides")
54  .def(
55  "ndim",
56  [](const utility::Matrix<PointCoordinateType> &s) {
57  return s.ndim();
58  },
59  "Function to get matrix dimension")
60  .def(
61  "size",
62  [](const utility::Matrix<PointCoordinateType> &s) {
63  return s.size();
64  },
65  "Function to get matrix size");
66 }
67 
68 } // namespace utility
69 } // namespace cloudViewer
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
void * bytes
#define NULL
void pybind_matrix(py::module &m)
Definition: matrix.cpp:18
Generic file read and write utility for python interface.