17 #pragma warning(disable : 4715)
25 py::native_enum<cloudViewer::TRIANGULATION_TYPES>(
26 m,
"TriangulationType",
"enum.Enum",
27 "Method for mesh triangulation types.")
28 .value(
"DELAUNAY_2D_AXIS_ALIGNED",
30 "Triangulation types.")
31 .value(
"DELAUNAY_2D_BEST_LS_PLANE",
33 "Triangulation types.")
36 py::class_<GenericMesh, PyGenericMesh<GenericMesh>,
37 std::shared_ptr<GenericMesh>>
38 meshbase(m,
"GenericMesh",
39 "GenericMesh class. Triangle mesh contains vertices. "
40 "Optionally, the mesh "
41 "may also contain vertex normals and vertex colors.");
43 py::native_enum<GenericMesh::SimplificationContraction>(
44 m,
"SimplificationContraction",
"enum.Enum",
45 "Method for mesh simplification contraction.")
47 "The vertex positions are computed by the averaging.")
49 "The vertex positions are computed by minimizing the "
50 "distance to the adjacent triangle planes.")
53 py::native_enum<GenericMesh::FilterScope>(m,
"FilterScope",
"enum.Enum",
54 "Scope for mesh filtering.")
56 "All properties (color, normal, vertex position) are "
59 "Only the color values are filtered.")
61 "Only the normal values are filtered.")
63 "Only the vertex positions are filtered.")
66 py::native_enum<GenericMesh::DeformAsRigidAsPossibleEnergy>(
67 m,
"DeformAsRigidAsPossibleEnergy",
"enum.Enum",
68 "Energy model for the as-rigid-as-possible mesh deformation.")
70 "Is the original energy as formulated in orkine and Alexa, "
71 "\"As-Rigid-As-Possible Surface Modeling\", 2007.")
74 "Adds a rotation smoothing term to the rotations.")
78 meshbase.def(
"__repr__",
80 return std::string(
"GenericMesh with ") +
85 "Returns whether triangles are empty.")
94 "Returns the mesh bounding-box.")
102 "[GenericMesh] does not have next "
106 "Returns the next triangle (relatively to the global "
107 "iterator position).")
108 .def(
"place_iterator_at_beginning",
110 "Places the mesh iterator at the beginning.");
117 "place_iterator_at_beginning");
119 py::class_<GenericTriangle, std::shared_ptr<GenericTriangle>>
120 genericTriangle(m,
"GenericTriangle",
121 "GenericTriangle, a generic triangle interface.");
128 "Returns the first vertex (A).")
134 "Returns second vertex (B).")
140 "Returns the third vertex (C).");
147 std::shared_ptr<cloudViewer::VerticesIndexes>>
148 verticesindexes(m,
"VerticesIndexes",
149 "VerticesIndexes, Triangle described by the "
150 "indexes of its 3 vertices.");
151 py::detail::bind_default_constructor<cloudViewer::VerticesIndexes>(
153 py::detail::bind_copy_functions<cloudViewer::VerticesIndexes>(
155 verticesindexes.def(py::init<>())
156 .def(py::init([](
unsigned i1,
unsigned i2,
unsigned i3) {
159 "Constructor with specified indexes",
"i1"_a,
"i2"_a,
"i3"_a);
163 std::shared_ptr<cloudViewer::GenericIndexedMesh>,
166 m,
"GenericIndexedMesh",
167 "GenericIndexedMesh with index-based vertex access.");
171 return std::string(
"GenericIndexedMesh with ") +
177 size_t triangle_index) {
178 if (mesh._getTriangle(
179 static_cast<unsigned>(triangle_index))) {
180 return std::ref(*mesh._getTriangle(
181 static_cast<unsigned>(triangle_index)));
184 "[cloudViewer::GenericIndexedMesh] does "
185 "not have triangle!");
188 "Returns the ith triangle.",
"triangle_index"_a)
190 "get_vertice_indexes",
192 size_t triangle_index) {
193 if (mesh.getTriangleVertIndexes(
194 static_cast<unsigned>(triangle_index))) {
195 return std::ref(*mesh.getTriangleVertIndexes(
196 static_cast<unsigned>(triangle_index)));
199 "[cloudViewer::GenericIndexedMesh] does "
200 "not have vertice indexes!");
203 "Returns the indexes of the vertices of a given triangle.",
206 "get_triangle_vertices",
208 size_t triangle_index) {
210 mesh.getTriangleVertices(
211 static_cast<unsigned>(triangle_index), A, B, C);
216 "Returns the vertices of a given triangle.",
219 "get_next_vertice_indexes",
221 if (mesh.getNextTriangleVertIndexes()) {
222 return std::ref(*mesh.getNextTriangleVertIndexes());
225 "[cloudViewer::GenericIndexedMesh] does "
226 "not have next vertice indexes!");
229 "Returns the indexes of the vertices of the next triangle "
230 "(relatively to the global iterator position).");
234 "get_triangle_vertices");
236 "get_vertice_indexes");
238 "get_next_vertice_indexes");
240 py::class_<ccGenericMesh, PyGeometry<ccGenericMesh>,
243 genericMesh(m,
"ccGenericMesh", py::multiple_inheritance(),
244 "ccGenericMesh class. Generic mesh interface.");
248 return std::string(
"ccGenericMesh with ") +
252 "get_associated_cloud",
254 if (mesh.getAssociatedCloud()) {
255 return std::ref(*mesh.getAssociatedCloud());
258 "[ccGenericMesh] does not have associated "
262 "Returns the associated cloud.")
264 "Forces bounding-box update.")
267 "Returns whether the mesh has materials/textures.")
269 "Returns whether textures are available for this mesh.")
271 "Returns whether the mesh has per-triangle normals.")
273 "get_triangle_normal_indexes",
276 mesh.getTriangleNormalIndexes(triangle_index, i1, i2,
278 return std::make_tuple(i1, i2, i3);
280 "Returns a triplet of normal indexes for a given triangle "
284 "get_triangle_normals",
286 Eigen::Vector3d Na, Nb, Nc;
287 mesh.getTriangleNormals(triangle_index, Na, Nb, Nc);
288 return std::make_tuple(Na, Nb, Nc);
290 "Returns a given triangle normal.",
"triangle_index"_a)
292 "interpolate_normals",
294 const Eigen::Vector3d&
point) {
296 mesh.interpolateNormals(triangle_index,
point,
normal);
299 "Interpolates normal(s) inside a given triangle.",
300 "triangle_index"_a,
"point"_a)
302 "compute_interpolation_weights",
304 const Eigen::Vector3d&
point) {
306 mesh.computeInterpolationWeights(triangle_index,
point,
310 "Returns the (barycentric) interpolation weights for a "
312 "triangle_index"_a,
"point"_a)
314 "interpolate_colors",
316 const Eigen::Vector3d&
point) {
318 bool success = mesh.interpolateColors(triangle_index,
320 return std::make_tuple(success,
323 "Interpolates RGB colors inside a given triangle.",
324 "triangle_index"_a,
"point"_a)
326 "get_color_from_material",
328 const Eigen::Vector3d&
point,
329 bool interpolate_color_if_no_texture) {
331 bool success = mesh.getColorFromMaterial(
333 interpolate_color_if_no_texture);
334 return std::make_tuple(success,
337 "Returns RGB color from a given triangle material/texture.",
338 "triangle_index"_a,
"point"_a,
339 "interpolate_color_if_no_texture"_a)
341 "get_vertex_color_from_material",
344 bool return_color_if_no_texture) {
346 bool success = mesh.getVertexColorFromMaterial(
348 return_color_if_no_texture);
349 return std::make_tuple(success,
352 "Returns RGB color of a vertex from a given triangle "
354 "triangle_index"_a,
"vertex_index"_a,
355 "return_color_if_no_texture"_a)
357 "Returns whether the mesh is displayed as wired or with plain "
360 "Sets whether mesh should be displayed as a wire or with "
364 "Returns whether the mesh is displayed as wired or with plain "
367 "Sets whether mesh should be displayed as a point cloud or "
368 "with plain facets.",
371 "Returns whether per-triangle normals are shown or not .")
373 "Sets whether to show or not per-triangle normals.",
"state"_a)
375 "Sets whether textures/material should be displayed or not.")
377 "Sets whether textures should be displayed or not.",
"state"_a)
379 "Returns whether polygon stippling is enabled or not.")
381 "Enables polygon stippling.",
"state"_a)
385 double sampling_parameter,
bool with_normals,
386 bool with_rgb,
bool with_texture) {
388 density_based, sampling_parameter, with_normals,
389 with_rgb, with_texture,
nullptr);
390 return std::shared_ptr<ccPointCloud>(cloud);
392 "Samples points on a mesh.",
"density_based"_a,
393 "sampling_parameter"_a,
"with_normals"_a,
"with_rgb"_a,
396 "import_parameters_from",
398 mesh.importParametersFrom(&source);
400 "Imports the parameters from another mesh.",
"source"_a);
410 m,
"ccGenericMesh",
"get_triangle_normal_indexes",
411 {{
"triangle_index",
"triIndex triangle index"}});
413 m,
"ccGenericMesh",
"interpolate_normals",
414 {{
"triangle_index",
"triIndex triangle index"},
416 "point where to interpolate (should be inside the triangle!)"}});
418 m,
"ccGenericMesh",
"interpolate_colors",
419 {{
"triangle_index",
"triIndex triangle index"},
421 "point where to interpolate (should be inside the triangle!)"}});
423 "compute_interpolation_weights");
425 m,
"ccGenericMesh",
"get_color_from_material",
426 {{
"triangle_index",
"triIndex triangle index"},
428 "point where to grab color (should be inside the triangle!)"},
429 {
"interpolate_color_if_no_texture",
430 "whether to return the color interpolated from the RGB field if "
431 "no texture/material is associated to the given triangles"}});
433 m,
"ccGenericMesh",
"get_vertex_color_from_material",
434 {{
"triangle_index",
"triIndex triangle index"},
435 {
"vertex_index",
"vertex index inside triangle (i.e. 0, 1 or 2!)"},
436 {
"return_color_if_no_texture",
437 "whether to return the color from the vertex RGB field if no "
438 "texture/material is associated to the given triangle"}});
451 "import_parameters_from");
453 py::class_<ecvMeshBase, PyGeometry<ecvMeshBase>,
456 meshbase2(m,
"ecvMeshBase",
457 "ecvMeshBase class. Triangle mesh contains vertices. "
458 "Optionally, the mesh "
459 "may also contain vertex normals and vertex colors.");
460 py::detail::bind_default_constructor<ecvMeshBase>(meshbase2);
461 py::detail::bind_copy_functions<ecvMeshBase>(meshbase2);
466 return std::string(
"ecvMeshBase with ") +
469 .def(py::self + py::self)
470 .def(py::self += py::self)
472 "Returns ``True`` if the mesh contains vertices.")
474 "Returns ``True`` if the mesh contains vertex normals.")
476 "Returns ``True`` if the mesh contains vertex colors.")
478 "Normalize vertex normals to length 1.")
480 "Assigns each vertex in the ecvMeshBase the same color.",
483 "Computes the convex hull of the triangle mesh.")
485 "``float64`` array of shape ``(num_vertices, 3)``, "
486 "use ``numpy.asarray()`` to access data: Vertex "
489 "``float64`` array of shape ``(num_vertices, 3)``, "
490 "use ``numpy.asarray()`` to access data: Vertex "
494 "``float64`` array of shape ``(num_vertices, 3)``, "
495 "range ``[0, 1]`` , use ``numpy.asarray()`` to access "
496 "data: RGB colors of vertices.");
499 m,
"ecvMeshBase",
"has_vertex_normals",
501 "Set to ``True`` to normalize the normal to length 1."}});
505 {{
"color",
"RGB colors of vertices."}});
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
virtual void showPoints(bool state)
virtual bool materialsShown() const
Sets whether textures/material should be displayed or not.
virtual bool hasTextures() const =0
Returns whether textures are available for this mesh.
virtual void showWired(bool state)
Sets whether mesh should be displayed as a wire or with plain facets.
virtual bool triNormsShown() const
Returns whether per-triangle normals are shown or not.
virtual bool isShownAsWire() const
Returns whether the mesh is displayed as wired or with plain facets.
virtual bool hasTriNormals() const =0
Returns whether the mesh has per-triangle normals.
void enableStippling(bool state)
Enables polygon stippling.
virtual void showMaterials(bool state)
Sets whether textures should be displayed or not.
virtual bool isShownAsPoints() const
Returns whether the mesh is displayed as wired or with plain facets.
virtual unsigned capacity() const =0
Returns max capacity.
virtual void refreshBB()=0
Forces bounding-box update.
virtual bool stipplingEnabled() const
Returns whether polygon stippling is enabled or not.
virtual bool hasMaterials() const =0
virtual void showTriNorms(bool state)
Sets whether to show or not per-triangle normals.
Hierarchical CLOUDVIEWER Object.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
A generic mesh with index-based vertex access.
virtual unsigned size() const =0
Returns the number of triangles.
virtual void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax)=0
Returns the mesh bounding-box.
virtual GenericTriangle * _getNextTriangle()=0
Returns the next triangle (relatively to the global iterator position)
virtual void placeIteratorAtBeginning()=0
Places the mesh iterator at the beginning.
virtual bool hasTriangles() const
A generic triangle interface.
virtual const CCVector3 * _getA() const =0
Returns the first vertex (A)
virtual const CCVector3 * _getC() const =0
Returns the third vertex (C)
virtual const CCVector3 * _getB() const =0
Returns the second vertex (B)
ecvMeshBase & PaintUniformColor(const Eigen::Vector3d &color)
Assigns each vertex in the TriangleMesh the same color.
bool HasVertices() const
Returns True if the mesh contains vertices.
bool HasVertexColors() const
Returns True if the mesh contains vertex colors.
std::tuple< std::shared_ptr< ccMesh >, std::vector< size_t > > ComputeConvexHull() const
Function that computes the convex hull of the triangle mesh using qhull.
bool HasVertexNormals() const
Returns True if the mesh contains vertex normals.
ecvMeshBase & NormalizeNormals()
Normalize vertex normals to length 1.
std::vector< Eigen::Vector3d > vertex_normals_
Vertex normals.
std::vector< Eigen::Vector3d > vertices_
Vertex coordinates.
std::vector< Eigen::Vector3d > vertex_colors_
RGB colors of vertices.
static Eigen::Vector3d ToEigen(const Type col[3])
void ClassMethodDocInject(py::module &pybind_module, const std::string &class_name, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
void pybind_meshbase_methods(py::module &m)
void pybind_meshbase(py::module &m)
Generic file read and write utility for python interface.
@ DELAUNAY_2D_BEST_LS_PLANE
@ DELAUNAY_2D_AXIS_ALIGNED
std::string to_string(const T &n)
Triangle described by the indexes of its 3 vertices.