Open3D (C++ API)  0.18.0+252c867
HalfEdgeTriangleMesh.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <unordered_map>
12 
15 
16 namespace open3d {
17 namespace geometry {
18 
25 public:
30  class HalfEdge {
31  public:
36  : next_(-1),
37  twin_(-1),
38  vertex_indices_(-1, -1),
39  triangle_index_(-1) {}
40  HalfEdge(const Eigen::Vector2i &vertex_indices,
41  int triangle_index,
42  int next,
43  int twin);
46  bool IsBoundary() const { return twin_ == -1; }
47 
48  public:
50  int next_;
52  int twin_;
54  Eigen::Vector2i vertex_indices_;
57  };
58 
59 public:
65 
66  virtual HalfEdgeTriangleMesh &Clear() override;
67 
69  bool HasHalfEdges() const;
70 
73  std::vector<int> BoundaryHalfEdgesFromVertex(int vertex_index) const;
74 
77  std::vector<int> BoundaryVerticesFromVertex(int vertex_index) const;
78 
80  std::vector<std::vector<int>> GetBoundaries() const;
81 
83 
85 
88  static std::shared_ptr<HalfEdgeTriangleMesh> CreateFromTriangleMesh(
89  const TriangleMesh &mesh);
90 
91 protected:
98 
102  int NextHalfEdgeFromVertex(int init_half_edge_index) const;
103  int NextHalfEdgeOnBoundary(int curr_half_edge_index) const;
104 
105 public:
107  std::vector<Eigen::Vector3i> triangles_;
109  std::vector<Eigen::Vector3d> triangle_normals_;
111  std::vector<HalfEdge> half_edges_;
112 
115  std::vector<std::vector<int>> ordered_half_edge_from_vertex_;
116 };
117 
118 } // namespace geometry
119 } // namespace open3d
math::float4 next
Definition: LineSetBuffers.cpp:44
The base geometry class.
Definition: Geometry.h:18
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:23
HalfEdge class contains vertex, triangle info about a half edge, as well as relations of next and twi...
Definition: HalfEdgeTriangleMesh.h:30
HalfEdge()
Default Constructor.
Definition: HalfEdgeTriangleMesh.h:35
int next_
Index of the next HalfEdge in the same triangle.
Definition: HalfEdgeTriangleMesh.h:50
bool IsBoundary() const
Definition: HalfEdgeTriangleMesh.h:46
int twin_
Index of the twin HalfEdge.
Definition: HalfEdgeTriangleMesh.h:52
Eigen::Vector2i vertex_indices_
Index of the ordered vertices forming this half edge.
Definition: HalfEdgeTriangleMesh.h:54
int triangle_index_
Index of the triangle containing this half edge.
Definition: HalfEdgeTriangleMesh.h:56
HalfEdgeTriangleMesh inherits TriangleMesh class with the addition of HalfEdge data structure for eac...
Definition: HalfEdgeTriangleMesh.h:24
std::vector< Eigen::Vector3d > triangle_normals_
List of triangle normals in the mesh.
Definition: HalfEdgeTriangleMesh.h:109
std::vector< int > BoundaryVerticesFromVertex(int vertex_index) const
Definition: HalfEdgeTriangleMesh.cpp:70
int NextHalfEdgeFromVertex(int init_half_edge_index) const
Definition: HalfEdgeTriangleMesh.cpp:40
HalfEdgeTriangleMesh(Geometry::GeometryType type)
Parameterized Constructor.
Definition: HalfEdgeTriangleMesh.h:97
HalfEdgeTriangleMesh operator+(const HalfEdgeTriangleMesh &mesh) const
Definition: HalfEdgeTriangleMesh.cpp:280
std::vector< int > BoundaryHalfEdgesFromVertex(int vertex_index) const
Definition: HalfEdgeTriangleMesh.cpp:50
std::vector< Eigen::Vector3i > triangles_
List of triangles in the mesh.
Definition: HalfEdgeTriangleMesh.h:107
HalfEdgeTriangleMesh()
Default Constructor.
Definition: HalfEdgeTriangleMesh.h:63
virtual HalfEdgeTriangleMesh & Clear() override
Clear all elements in the geometry.
Definition: HalfEdgeTriangleMesh.cpp:28
std::vector< std::vector< int > > ordered_half_edge_from_vertex_
Definition: HalfEdgeTriangleMesh.h:115
std::vector< HalfEdge > half_edges_
List of HalfEdge in the mesh.
Definition: HalfEdgeTriangleMesh.h:111
bool HasHalfEdges() const
Returns true if half-edges have already been computed.
Definition: HalfEdgeTriangleMesh.cpp:35
std::vector< std::vector< int > > GetBoundaries() const
Returns a vector of boundaries. A boundary is a vector of vertices.
Definition: HalfEdgeTriangleMesh.cpp:82
int NextHalfEdgeOnBoundary(int curr_half_edge_index) const
Definition: HalfEdgeTriangleMesh.cpp:106
static std::shared_ptr< HalfEdgeTriangleMesh > CreateFromTriangleMesh(const TriangleMesh &mesh)
Definition: HalfEdgeTriangleMesh.cpp:137
HalfEdgeTriangleMesh & operator+=(const HalfEdgeTriangleMesh &mesh)
Definition: HalfEdgeTriangleMesh.cpp:273
MeshBash Class.
Definition: MeshBase.h:32
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:35
char type
Definition: FilePCD.cpp:41
Definition: PinholeCameraIntrinsic.cpp:16