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 Geometry3D {
45 public:
47  ~TetraMesh() override {}
48 
49 public:
50  TetraMesh &Clear() override;
51  bool IsEmpty() const override;
52  Eigen::Vector3d GetMinBound() const override;
53  Eigen::Vector3d GetMaxBound() const override;
54  Eigen::Vector3d GetCenter() const override;
57  TetraMesh &Transform(const Eigen::Matrix4d &transformation) override;
58  TetraMesh &Translate(const Eigen::Vector3d &translation,
59  bool relative = true) override;
60  TetraMesh &Scale(const double scale, bool center = true) override;
61  TetraMesh &Rotate(const Eigen::Vector3d &rotation,
62  bool center = true,
64 
65 public:
66  TetraMesh &operator+=(const TetraMesh &mesh);
67  TetraMesh operator+(const TetraMesh &mesh) const;
68 
72 
76 
80 
85 
86  bool HasVertices() const { return vertices_.size() > 0; }
87 
88  bool HasTetras() const {
89  return vertices_.size() > 0 && tetras_.size() > 0;
90  }
91 
96  std::shared_ptr<TriangleMesh> ExtractTriangleMesh(
97  const std::vector<double> &values, double level);
98 
102  static std::shared_ptr<TetraMesh> CreateFromPointCloud(
103  const PointCloud &point_cloud);
104 
105 protected:
106  // Forward child class type to avoid indirect nonvirtual base
108 
109 public:
110  std::vector<Eigen::Vector3d> vertices_;
111  std::vector<Eigen::Vector4i, utility::Vector4i_allocator> tetras_;
112 };
113 
114 } // namespace geometry
115 } // namespace open3d
TetraMesh & Rotate(const Eigen::Vector3d &rotation, bool center=true, RotationType type=RotationType::XYZ) override
Definition: TetraMesh.cpp:123
std::shared_ptr< TriangleMesh > ExtractTriangleMesh(const std::vector< double > &values, double level)
Definition: TetraMesh.cpp:286
TetraMesh & RemoveDuplicatedVertices()
Definition: TetraMesh.cpp:161
TetraMesh operator+(const TetraMesh &mesh) const
Definition: TetraMesh.cpp:157
Definition: Geometry.h:32
Eigen::Vector3d GetMinBound() const override
Definition: TetraMesh.cpp:50
TetraMesh & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Definition: TetraMesh.cpp:100
Definition: BoundingVolume.h:90
Definition: BoundingVolume.h:38
Definition: PointCloud.h:50
TetraMesh & RemoveUnreferencedVertices()
Definition: TetraMesh.cpp:229
TetraMesh & Transform(const Eigen::Matrix4d &transformation) override
Definition: TetraMesh.cpp:90
TetraMesh & RemoveDuplicatedTetras()
Definition: TetraMesh.cpp:198
RotationType
Definition: Geometry3D.h:43
TetraMesh()
Definition: TetraMesh.h:46
bool HasTetras() const
Definition: TetraMesh.h:88
TetraMesh & operator+=(const TetraMesh &mesh)
Definition: TetraMesh.cpp:137
~TetraMesh() override
Definition: TetraMesh.h:47
Definition: Geometry3D.h:41
bool IsEmpty() const override
Definition: TetraMesh.cpp:48
TetraMesh & Scale(const double scale, bool center=true) override
Definition: TetraMesh.cpp:112
static std::shared_ptr< TetraMesh > CreateFromPointCloud(const PointCloud &point_cloud)
Definition: TetraMeshFactory.cpp:35
Eigen::Vector3d GetCenter() const override
Definition: TetraMesh.cpp:72
TetraMesh & RemoveDegenerateTetras()
Definition: TetraMesh.cpp:266
std::vector< Eigen::Vector4i, utility::Vector4i_allocator > tetras_
Definition: TetraMesh.h:111
OrientedBoundingBox GetOrientedBoundingBox() const override
Definition: TetraMesh.cpp:86
TetraMesh & Clear() override
Definition: TetraMesh.cpp:42
Definition: TetraMesh.h:44
Eigen::Vector3d GetMaxBound() const override
Definition: TetraMesh.cpp:61
char type
Definition: FilePCD.cpp:56
Definition: PinholeCameraIntrinsic.cpp:34
std::vector< Eigen::Vector3d > vertices_
Definition: TetraMesh.h:110
GeometryType
Definition: Geometry.h:34
TetraMesh(Geometry::GeometryType type)
Definition: TetraMesh.h:107
bool HasVertices() const
Definition: TetraMesh.h:86
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const override
Definition: TetraMesh.cpp:82