Open3D (C++ API)  0.15.1
TetraMesh.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <Eigen/Core>
30#include <Eigen/StdVector>
31#include <memory>
32#include <vector>
33
37
38namespace open3d {
39namespace geometry {
40
41class PointCloud;
42class TriangleMesh;
43
48class TetraMesh : public MeshBase {
49public:
57 TetraMesh(const std::vector<Eigen::Vector3d> &vertices,
58 const std::vector<Eigen::Vector4i, utility::Vector4i_allocator>
59 &tetras)
61 tetras_(tetras) {}
62 ~TetraMesh() override {}
63
64public:
65 TetraMesh &Clear() override;
66
67public:
68 TetraMesh &operator+=(const TetraMesh &mesh);
69 TetraMesh operator+(const TetraMesh &mesh) const;
70
74
79
83
88
90 bool HasTetras() const {
91 return vertices_.size() > 0 && tetras_.size() > 0;
92 }
93
100 std::shared_ptr<TriangleMesh> ExtractTriangleMesh(
101 const std::vector<double> &values, double level);
102
108 static std::tuple<std::shared_ptr<TetraMesh>, std::vector<size_t>>
109 CreateFromPointCloud(const PointCloud &point_cloud);
110
111protected:
112 // Forward child class type to avoid indirect nonvirtual base
114
115public:
117 std::vector<Eigen::Vector4i, utility::Vector4i_allocator> tetras_;
118};
119
120} // namespace geometry
121} // namespace open3d
The base geometry class.
Definition: Geometry.h:37
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
MeshBash Class.
Definition: MeshBase.h:51
std::vector< Eigen::Vector3d > vertices_
Vertex coordinates.
Definition: MeshBase.h:149
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition: PointCloud.h:55
Tetra mesh contains vertices and tetrahedra represented by the indices to the vertices.
Definition: TetraMesh.h:48
TetraMesh()
Default Constructor.
Definition: TetraMesh.h:51
TetraMesh & RemoveUnreferencedVertices()
This function removes vertices from the tetra mesh that are not referenced in any tetrahedron of the ...
Definition: TetraMesh.cpp:133
static std::tuple< std::shared_ptr< TetraMesh >, std::vector< size_t > > CreateFromPointCloud(const PointCloud &point_cloud)
Function that creates a tetrahedral mesh (TetraMeshFactory.cpp). from a point cloud.
Definition: TetraMeshFactory.cpp:36
TetraMesh & RemoveDuplicatedTetras()
Function that removes duplicated tetrahedra, i.e., removes tetrahedra that reference the same four ve...
Definition: TetraMesh.cpp:103
TetraMesh & RemoveDegenerateTetras()
Function that removes degenerate tetrahedra, i.e., tetrahedra that reference a single vertex multiple...
Definition: TetraMesh.cpp:170
TetraMesh(Geometry::GeometryType type)
Definition: TetraMesh.h:113
std::shared_ptr< TriangleMesh > 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...
Definition: TetraMesh.cpp:190
TetraMesh operator+(const TetraMesh &mesh) const
Definition: TetraMesh.cpp:63
TetraMesh & operator+=(const TetraMesh &mesh)
Definition: TetraMesh.cpp:48
TetraMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector4i, utility::Vector4i_allocator > &tetras)
Parameterized Constructor.
Definition: TetraMesh.h:57
~TetraMesh() override
Definition: TetraMesh.h:62
TetraMesh & RemoveDuplicatedVertices()
Function that removes duplicated verties, i.e., vertices that have identical coordinates.
Definition: TetraMesh.cpp:67
bool HasTetras() const
Returns true if the mesh contains tetras.
Definition: TetraMesh.h:90
std::vector< Eigen::Vector4i, utility::Vector4i_allocator > tetras_
List of tetras denoted by the index of points forming the tetra.
Definition: TetraMesh.h:117
TetraMesh & Clear() override
Clear all elements in the geometry.
Definition: TetraMesh.cpp:42
char type
Definition: FilePCD.cpp:60
Definition: PinholeCameraIntrinsic.cpp:35