Open3D (C++ API)
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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) 2019 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 
35 #include "Open3D/Utility/Eigen.h"
36 #include "Open3D/Utility/Helper.h"
37 
38 namespace open3d {
39 namespace geometry {
40 
41 class PointCloud;
42 class TriangleMesh;
43 
44 class TetraMesh : public MeshBase {
45 public:
47  TetraMesh(const std::vector<Eigen::Vector3d> &vertices,
48  const std::vector<Eigen::Vector4i, utility::Vector4i_allocator>
49  &tetras)
50  : MeshBase(Geometry::GeometryType::TetraMesh, vertices),
51  tetras_(tetras) {}
52  ~TetraMesh() override {}
53 
54 public:
55  TetraMesh &Clear() override;
56 
57 public:
58  TetraMesh &operator+=(const TetraMesh &mesh);
59  TetraMesh operator+(const TetraMesh &mesh) const;
60 
64 
68 
72 
77 
78  bool HasTetras() const {
79  return vertices_.size() > 0 && tetras_.size() > 0;
80  }
81 
86  std::shared_ptr<TriangleMesh> ExtractTriangleMesh(
87  const std::vector<double> &values, double level);
88 
92  static std::tuple<std::shared_ptr<TetraMesh>, std::vector<size_t>>
93  CreateFromPointCloud(const PointCloud &point_cloud);
94 
95 protected:
96  // Forward child class type to avoid indirect nonvirtual base
98 
99 public:
100  std::vector<Eigen::Vector4i, utility::Vector4i_allocator> tetras_;
101 };
102 
103 } // namespace geometry
104 } // namespace open3d
std::shared_ptr< TriangleMesh > ExtractTriangleMesh(const std::vector< double > &values, double level)
Definition: TetraMesh.cpp:191
TetraMesh & RemoveDuplicatedVertices()
Definition: TetraMesh.cpp:67
TetraMesh operator+(const TetraMesh &mesh) const
Definition: TetraMesh.cpp:63
The base geometry class.
Definition: Geometry.h:35
Definition: MeshBase.h:45
Definition: PointCloud.h:50
TetraMesh & RemoveUnreferencedVertices()
Definition: TetraMesh.cpp:134
TetraMesh & RemoveDuplicatedTetras()
Definition: TetraMesh.cpp:104
TetraMesh()
Definition: TetraMesh.h:46
bool HasTetras() const
Definition: TetraMesh.h:78
TetraMesh & operator+=(const TetraMesh &mesh)
Definition: TetraMesh.cpp:48
~TetraMesh() override
Definition: TetraMesh.h:52
TetraMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector4i, utility::Vector4i_allocator > &tetras)
Definition: TetraMesh.h:47
TetraMesh & RemoveDegenerateTetras()
Definition: TetraMesh.cpp:171
std::vector< Eigen::Vector4i, utility::Vector4i_allocator > tetras_
Definition: TetraMesh.h:100
TetraMesh & Clear() override
Clear all elements in the geometry.
Definition: TetraMesh.cpp:42
Definition: TetraMesh.h:44
char type
Definition: FilePCD.cpp:57
static std::tuple< std::shared_ptr< TetraMesh >, std::vector< size_t > > CreateFromPointCloud(const PointCloud &point_cloud)
Definition: TetraMeshFactory.cpp:36
Definition: PinholeCameraIntrinsic.cpp:34
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:40
TetraMesh(Geometry::GeometryType type)
Definition: TetraMesh.h:97
std::vector< Eigen::Vector3d > vertices_
Definition: MeshBase.h:125