ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvTetraMesh.h
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 #pragma once
9 
10 #include <Eigen/Core>
11 #include <Eigen/StdVector>
12 #include <memory>
13 #include <vector>
14 
15 // LOCAL
16 #include "ecvMeshBase.h"
17 
18 // CV_CORE_LIB
19 #include <Eigen.h>
20 #include <Helper.h>
21 
22 namespace cloudViewer {
23 namespace geometry {
24 
30 public:
32 
34  TetraMesh(const char *name = "TetraMesh") : ecvMeshBase(name) {}
35 
42  const std::vector<Eigen::Vector3d> &vertices,
43  const std::vector<Eigen::Vector4i,
45  const char *name = "TetraMesh")
46  : ecvMeshBase(name), tetras_(tetras) {}
47 
48  ~TetraMesh() override {}
49 
50  // inherited methods (ccHObject)
51  virtual bool isSerializable() const override { return true; }
52  virtual CV_CLASS_ENUM getClassID() const override {
53  return CV_TYPES::TETRA_MESH;
54  }
55 
56 public:
57  virtual TetraMesh &clear() override;
58 
59 public:
60  inline std::size_t TetraSize() const { return tetras_.size(); }
61 
63  TetraMesh operator+(const TetraMesh &mesh) const;
64 
68 
73 
77 
82 
84  bool HasTetras() const {
85  return vertices_.size() > 0 && tetras_.size() > 0;
86  }
87 
94  std::shared_ptr<ccMesh> ExtractTriangleMesh(
95  const std::vector<double> &values, double level);
96 
102  static std::tuple<std::shared_ptr<TetraMesh>, std::vector<size_t>>
103  CreateFromPointCloud(const ccPointCloud &point_cloud);
104 
105 public:
107  std::vector<Eigen::Vector4i, cloudViewer::utility::Vector4i_allocator>
109 };
110 
111 } // namespace geometry
112 } // namespace cloudViewer
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
#define CV_DB_LIB_API
Definition: CV_db.h:15
std::string name
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Tetra mesh contains vertices and tetrahedra represented by the indices to the vertices.
Definition: ecvTetraMesh.h:29
TetraMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector4i, cloudViewer::utility::Vector4i_allocator > &tetras, const char *name="TetraMesh")
Parameterized Constructor.
Definition: ecvTetraMesh.h:41
virtual TetraMesh & clear() override
std::size_t TetraSize() const
Definition: ecvTetraMesh.h:60
TetraMesh(const char *name="TetraMesh")
Default ccMesh constructor.
Definition: ecvTetraMesh.h:34
std::vector< Eigen::Vector4i, cloudViewer::utility::Vector4i_allocator > tetras_
List of tetras denoted by the index of points forming the tetra.
Definition: ecvTetraMesh.h:108
std::shared_ptr< ccMesh > ExtractTriangleMesh(const std::vector< double > &values, double level)
Function to extract a triangle mesh of the specified iso-surface at a level This method applies prima...
TetraMesh & RemoveDuplicatedTetras()
Function that removes duplicated tetrahedra, i.e., removes tetrahedra that reference the same four ve...
virtual CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvTetraMesh.h:52
TetraMesh & RemoveUnreferencedVertices()
This function removes vertices from the tetra mesh that are not referenced in any tetrahedron of the ...
TetraMesh & RemoveDegenerateTetras()
Function that removes degenerate tetrahedra, i.e., tetrahedra that reference a single vertex multiple...
TetraMesh & operator+=(const TetraMesh &mesh)
TetraMesh & RemoveDuplicatedVertices()
Function that removes duplicated verties, i.e., vertices that have identical coordinates.
bool HasTetras() const
Returns true if the mesh contains tetras.
Definition: ecvTetraMesh.h:84
static std::tuple< std::shared_ptr< TetraMesh >, std::vector< size_t > > CreateFromPointCloud(const ccPointCloud &point_cloud)
Function that creates a tetrahedral mesh (TetraMeshFactory.cpp). from a point cloud.
virtual bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvTetraMesh.h:51
TetraMesh operator+(const TetraMesh &mesh) const
Helper functions for the ml ops.
@ TETRA_MESH
Definition: CVTypes.h:149
Eigen::aligned_allocator< Eigen::Vector4i > Vector4i_allocator
Definition: Eigen.h:129
Generic file read and write utility for python interface.
Eigen::Matrix< Index, 4, 1 > Vector4i
Definition: knncpp.h:31