ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccGenericMesh.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 <ecvMaterialSet.h>
14 #include <ecvPointCloud.h>
15 
16 namespace py = pybind11;
17 using namespace pybind11::literals;
18 
19 void define_ccGenericMesh(py::module &m)
20 {
21  py::class_<ccGenericMesh, cloudViewer::GenericIndexedMesh, ccHObject>(m, "ccGenericMesh")
22  .def("getAssociatedCloud",
24  py::return_value_policy::reference)
25  .def("refreshBB", &ccGenericMesh::refreshBB)
26  .def("capacity", &ccGenericMesh::capacity)
27  .def("hasMaterials", &ccGenericMesh::hasMaterials)
28  .def("getMaterialSet", &ccGenericMesh::getMaterialSet, py::return_value_policy::reference)
29  .def("getTriangleMtlIndex", &ccGenericMesh::getTriangleMtlIndex, "triangleIndex"_a)
30  .def("hasTextures", &ccGenericMesh::hasTextures)
31  .def("getTexCoordinatesTable",
33  py::return_value_policy::reference)
34  .def(
35  "getTriangleTexCoordinates",
36  [](ccGenericMesh &self, unsigned triIndex)
37  {
38  TexCoords2D *tx1, *tx2, *tx3;
39  self.getTriangleTexCoordinates(triIndex, tx1, tx2, tx3);
40  return py::make_tuple(tx1, tx2, tx2);
41  },
42  "triIndex"_a,
43  py::return_value_policy::reference)
44  .def("hasPerTriangleTexCoordinates", &ccGenericMesh::hasPerTriangleTexCoordIndexes)
45  .def(
46  "getTriangleTexCoordinatesIndexes",
47  [](ccGenericMesh &self, unsigned triangleIndex)
48  {
49  int i1, i2, i3;
50  self.getTriangleTexCoordinatesIndexes(triangleIndex, i1, i2, i3);
51  return py::make_tuple(i1, i2, i3);
52  },
53  "triangleIndex"_a)
54  .def("hasTriNormals", &ccGenericMesh::hasTriNormals)
55  .def(
56  "getTriangleNormalIndexes",
57  [](ccGenericMesh &self, unsigned triangleIndex)
58  {
59  int i1, i2, i3;
60  self.getTriangleNormalIndexes(triangleIndex, i1, i2, i3);
61  return py::make_tuple(i1, i2, i3);
62  },
63  "triangleIndex"_a)
64  .def(
65  "getTriangleNormals",
66  [](ccGenericMesh &self, unsigned triangleIndex)
67  {
68  CCVector3 Na, Nb, Nc;
69  self.getTriangleNormals(triangleIndex, Na, Nb, Nc);
70  return py::make_tuple(Na, Nb, Nc);
71  },
72  "triangleIndex"_a);
73  // FIXME blocked by NormsIndexesTableType not being wrappable due to link errors
74  //.def("getTriNormsTable", &ccGenericMesh::getTriNormsTable,
75  // py::return_value_policy::reference);
76  // TODD compute interpolation weights and following
77 }
void define_ccGenericMesh(py::module &m)
Generic mesh interface.
virtual TextureCoordsContainer * getTexCoordinatesTable() const =0
Returns per-triangle texture coordinates array.
virtual bool hasTextures() const =0
Returns whether textures are available for this mesh.
virtual bool hasPerTriangleTexCoordIndexes() const =0
Returns whether this mesh as per-triangle triplets of tex coords indexes.
virtual const ccMaterialSet * getMaterialSet() const =0
virtual bool hasTriNormals() const =0
Returns whether the mesh has per-triangle normals.
virtual int getTriangleMtlIndex(unsigned triangleIndex) const =0
Returns a given triangle material indexes.
virtual ccGenericPointCloud * getAssociatedCloud() const =0
Returns the vertices cloud.
virtual unsigned capacity() const =0
Returns max capacity.
virtual void refreshBB()=0
Forces bounding-box update.
virtual bool hasMaterials() const =0
2D texture coordinates