ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GenericIndexedCloud.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 <pybind11/pybind11.h>
9 
10 #include <GenericIndexedCloud.h>
11 
12 namespace py = pybind11;
13 using namespace pybind11::literals;
14 
15 void define_GenericIndexedCloud(py::module &cccorelib)
16 {
17  py::class_<cloudViewer::GenericIndexedCloud, cloudViewer::GenericCloud>(cccorelib, "GenericIndexedCloud")
18  .def(
19  "getPoint",
20  [](cloudViewer::GenericIndexedCloud &self, const unsigned index)
21  {
22  if (index < self.size())
23  {
24  return *self.getPoint(index);
25  }
26  else
27  {
28  throw std::out_of_range(std::string("index ") + std::to_string(index) +
29  " is out of range");
30  }
31  },
32  py::return_value_policy::reference)
33  .def(
34  "getPoint",
35  [](cloudViewer::GenericIndexedCloud &self, const unsigned index, CCVector3 &P)
36  {
37  if (index < self.size())
38  {
39  self.getPoint(index, P);
40  }
41  else
42  {
43  throw std::out_of_range(std::string("index ") + std::to_string(index) +
44  " is out of range");
45  }
46  },
47  py::return_value_policy::reference);
48 }
int size
void define_GenericIndexedCloud(py::module &cccorelib)
A generic 3D point cloud with index-based point access.
std::string to_string(const T &n)
Definition: Common.h:20