forked from isl-org/Open3D
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTetraMesh.h
More file actions
102 lines (84 loc) · 3.57 KB
/
TetraMesh.h
File metadata and controls
102 lines (84 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ----------------------------------------------------------------------------
// - Open3D: www.open3d.org -
// ----------------------------------------------------------------------------
// Copyright (c) 2018-2024 www.open3d.org
// SPDX-License-Identifier: MIT
// ----------------------------------------------------------------------------
#pragma once
#include <Eigen/Core>
#include <Eigen/StdVector>
#include <memory>
#include <vector>
#include "open3d/geometry/MeshBase.h"
#include "open3d/utility/Eigen.h"
#include "open3d/utility/Helper.h"
namespace open3d {
namespace geometry {
class PointCloud;
class TriangleMesh;
/// \class TetraMesh
///
/// \brief Tetra mesh contains vertices and tetrahedra represented by the
/// indices to the vertices.
class TetraMesh : public MeshBase {
public:
/// \brief Default Constructor.
TetraMesh() : MeshBase(Geometry::GeometryType::TetraMesh) {}
/// \brief Parameterized Constructor.
///
/// \param vertices Vertex coordinates.
/// \param tetras List of tetras denoted by the index of points forming the
/// tetra.
TetraMesh(const std::vector<Eigen::Vector3d> &vertices,
const std::vector<Eigen::Vector4i, utility::Vector4i_allocator>
&tetras)
: MeshBase(Geometry::GeometryType::TetraMesh, vertices),
tetras_(tetras) {}
~TetraMesh() override {}
public:
TetraMesh &Clear() override;
public:
TetraMesh &operator+=(const TetraMesh &mesh);
TetraMesh operator+(const TetraMesh &mesh) const;
/// \brief Function that removes duplicated vertices, i.e., vertices that
/// have identical coordinates.
TetraMesh &RemoveDuplicatedVertices();
/// \brief Function that removes duplicated tetrahedra, i.e., removes
/// tetrahedra that reference the same four vertices, independent of their
/// order.
TetraMesh &RemoveDuplicatedTetras();
/// \brief This function removes vertices from the tetra mesh that are not
/// referenced in any tetrahedron of the mesh.
TetraMesh &RemoveUnreferencedVertices();
/// \brief Function that removes degenerate tetrahedra, i.e., tetrahedra
/// that reference a single vertex multiple times in a single tetrahedron.
/// They are usually the product of removing duplicated vertices.
TetraMesh &RemoveDegenerateTetras();
/// Returns `true` if the mesh contains tetras.
bool HasTetras() const {
return vertices_.size() > 0 && tetras_.size() > 0;
}
/// \brief Function to extract a triangle mesh of the specified iso-surface
/// at a level This method applies primal contouring and generates triangles
/// for each tetrahedron.
///
/// \param level specifies the level.
/// \param values specifies values per-vertex.
std::shared_ptr<TriangleMesh> ExtractTriangleMesh(
const std::vector<double> &values, double level);
/// \brief Function that creates a tetrahedral mesh (TetraMeshFactory.cpp).
/// from a point cloud.
///
/// The method creates the Delaunay triangulation
/// using the implementation from Qhull.
static std::tuple<std::shared_ptr<TetraMesh>, std::vector<size_t>>
CreateFromPointCloud(const PointCloud &point_cloud);
protected:
// Forward child class type to avoid indirect nonvirtual base
TetraMesh(Geometry::GeometryType type) : MeshBase(type) {}
public:
/// List of tetras denoted by the index of points forming the tetra.
std::vector<Eigen::Vector4i, utility::Vector4i_allocator> tetras_;
};
} // namespace geometry
} // namespace open3d