ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccMesh.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 #include <pybind11/stl.h>
10 #include <pybind11/stl_bind.h>
11 
12 #include <ecvGenericMesh.h>
13 #include <ecvGenericPointCloud.h>
14 #include <ecvMesh.h>
15 #include <ecvPointCloud.h>
16 
17 namespace py = pybind11;
18 using namespace pybind11::literals;
19 
20 void define_ccMesh(py::module &m)
21 {
22  py::class_<ccMesh, ccGenericMesh>(m, "ccMesh")
23  .def(py::init<ccGenericPointCloud *>(),
24  "vertices"_a,
25  // Keep the cloud (2) alive while the mesh (1) is alive py::keep_alive<1,
26  // 2>())
27  // one could have expected <0, 1> as the mesh is the return value in C++
28  // but in python __init__ there is a self/this as arg 1
29  py::keep_alive<1, 2>())
30  .def("setAssociatedCloud",
32  "cloud"_a,
33  py::keep_alive<1, 2>() /* Keep the cloud (2) alive while the mesh (1) is alive */)
34  .def("addTriangle",
35  py::overload_cast<unsigned, unsigned, unsigned>(&ccMesh::addTriangle),
36  "i1"_a,
37  "i2"_a,
38  "i3"_a,
39  R"pbdoc(
40  Adds a triangle to the mesh
41  Bounding-box validity is broken after a call to this method.
42  However, for the sake of performance, no call to notifyGeometryUpdate
43  is made automatically. Make sure to do so when all modifications are done!
44 
45  Parameters
46  ----------
47  i1 first vertex index (relatively to the vertex cloud)
48  i2 second vertex index (relatively to the vertex cloud)
49  i3 third vertex index (relatively to the vertex cloud)
50  )pbdoc")
51  .def("addTriangle",
52  py::overload_cast<const cloudViewer::VerticesIndexes &>(&ccMesh::addTriangle),
53  "triangle"_a)
54  .def("addTriangles", &ccMesh::addTriangles, "triangles"_a);
55 }
void define_ccMesh(py::module &m)
Definition: ccMesh.cpp:20
void addTriangles(const std::vector< Eigen::Vector3i > &triangles)
Definition: ecvMesh.h:265
void setAssociatedCloud(ccGenericPointCloud *cloud)
Sets the associated vertices cloud (warning)
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.