Open3D (C++ API)  0.17.0
TriangleMesh.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 <memory>
12 #include <numeric>
13 #include <tuple>
14 #include <unordered_map>
15 #include <unordered_set>
16 #include <vector>
17 
18 #include "open3d/geometry/Image.h"
20 #include "open3d/utility/Helper.h"
21 
22 namespace open3d {
23 namespace geometry {
24 
25 class PointCloud;
26 class TetraMesh;
27 
35 class TriangleMesh : public MeshBase {
36 public:
43  TriangleMesh(const std::vector<Eigen::Vector3d> &vertices,
44  const std::vector<Eigen::Vector3i> &triangles)
46  triangles_(triangles) {}
47  ~TriangleMesh() override {}
48 
49 public:
50  virtual TriangleMesh &Clear() override;
51  virtual TriangleMesh &Transform(
52  const Eigen::Matrix4d &transformation) override;
53  virtual TriangleMesh &Rotate(const Eigen::Matrix3d &R,
54  const Eigen::Vector3d &center) override;
55 
56 public:
57  TriangleMesh &operator+=(const TriangleMesh &mesh);
58  TriangleMesh operator+(const TriangleMesh &mesh) const;
59 
61  bool HasTriangles() const {
62  return vertices_.size() > 0 && triangles_.size() > 0;
63  }
64 
66  bool HasTriangleNormals() const {
67  return HasTriangles() && triangles_.size() == triangle_normals_.size();
68  }
69 
71  bool HasAdjacencyList() const {
72  return vertices_.size() > 0 &&
73  adjacency_list_.size() == vertices_.size();
74  }
75 
76  bool HasTriangleUvs() const {
77  return HasTriangles() && triangle_uvs_.size() == 3 * triangles_.size();
78  }
79 
81  bool HasTextures() const {
82  bool is_all_texture_valid = std::accumulate(
83  textures_.begin(), textures_.end(), true,
84  [](bool a, const Image &b) { return a && !b.IsEmpty(); });
85  return !textures_.empty() && is_all_texture_valid;
86  }
87 
88  bool HasMaterials() const { return !materials_.empty(); }
89 
90  bool HasTriangleMaterialIds() const {
91  return HasTriangles() &&
92  triangle_material_ids_.size() == triangles_.size();
93  }
94 
98  for (size_t i = 0; i < triangle_normals_.size(); i++) {
99  triangle_normals_[i].normalize();
100  if (std::isnan(triangle_normals_[i](0))) {
101  triangle_normals_[i] = Eigen::Vector3d(0.0, 0.0, 1.0);
102  }
103  }
104  return *this;
105  }
106 
109  TriangleMesh &ComputeTriangleNormals(bool normalized = true);
110 
113  TriangleMesh &ComputeVertexNormals(bool normalized = true);
114 
118 
122 
127 
131 
137 
143 
150  TriangleMesh &MergeCloseVertices(double eps);
151 
161  std::shared_ptr<TriangleMesh> FilterSharpen(
162  int number_of_iterations,
163  double strength,
164  FilterScope scope = FilterScope::All) const;
165 
174  std::shared_ptr<TriangleMesh> FilterSmoothSimple(
175  int number_of_iterations,
176  FilterScope scope = FilterScope::All) const;
177 
189  std::shared_ptr<TriangleMesh> FilterSmoothLaplacian(
190  int number_of_iterations,
191  double lambda_filter,
192  FilterScope scope = FilterScope::All) const;
193 
204  std::shared_ptr<TriangleMesh> FilterSmoothTaubin(
205  int number_of_iterations,
206  double lambda_filter = 0.5,
207  double mu = -0.53,
208  FilterScope scope = FilterScope::All) const;
209 
213  int EulerPoincareCharacteristic() const;
214 
218  std::vector<Eigen::Vector2i> GetNonManifoldEdges(
219  bool allow_boundary_edges = true) const;
220 
225  bool IsEdgeManifold(bool allow_boundary_edges = true) const;
226 
230  std::vector<int> GetNonManifoldVertices() const;
231 
235  bool IsVertexManifold() const;
236 
239  std::vector<Eigen::Vector2i> GetSelfIntersectingTriangles() const;
240 
243  bool IsSelfIntersecting() const;
244 
247  bool IsBoundingBoxIntersecting(const TriangleMesh &other) const;
248 
251  bool IsIntersecting(const TriangleMesh &other) const;
252 
256  bool IsOrientable() const;
257 
261  bool IsWatertight() const;
262 
266  bool OrientTriangles();
267 
270  std::unordered_map<Eigen::Vector2i,
271  std::vector<int>,
273  GetEdgeToTrianglesMap() const;
274 
277  std::unordered_map<Eigen::Vector2i,
278  std::vector<int>,
280  GetEdgeToVerticesMap() const;
281 
283  static double ComputeTriangleArea(const Eigen::Vector3d &p0,
284  const Eigen::Vector3d &p1,
285  const Eigen::Vector3d &p2);
286 
289  double GetTriangleArea(size_t triangle_idx) const;
290 
291  static inline Eigen::Vector3i GetOrderedTriangle(int vidx0,
292  int vidx1,
293  int vidx2) {
294  if (vidx0 > vidx2) {
295  std::swap(vidx0, vidx2);
296  }
297  if (vidx0 > vidx1) {
298  std::swap(vidx0, vidx1);
299  }
300  if (vidx1 > vidx2) {
301  std::swap(vidx1, vidx2);
302  }
303  return Eigen::Vector3i(vidx0, vidx1, vidx2);
304  }
305 
308  double GetSurfaceArea() const;
309 
312  double GetSurfaceArea(std::vector<double> &triangle_areas) const;
313 
318  double GetVolume() const;
319 
323  static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0,
324  const Eigen::Vector3d &p1,
325  const Eigen::Vector3d &p2);
326 
329  Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const;
330 
332  static inline Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1) {
333  return Eigen::Vector2i(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
334  }
335 
338  std::shared_ptr<PointCloud> SamplePointsUniformlyImpl(
339  size_t number_of_points,
340  std::vector<double> &triangle_areas,
341  double surface_area,
342  bool use_triangle_normal);
343 
350  std::shared_ptr<PointCloud> SamplePointsUniformly(
351  size_t number_of_points, bool use_triangle_normal = false);
352 
365  std::shared_ptr<PointCloud> SamplePointsPoissonDisk(
366  size_t number_of_points,
367  double init_factor = 5,
368  const std::shared_ptr<PointCloud> pcl_init = nullptr,
369  bool use_triangle_normal = false);
370 
376  std::shared_ptr<TriangleMesh> SubdivideMidpoint(
377  int number_of_iterations) const;
378 
384  std::shared_ptr<TriangleMesh> SubdivideLoop(int number_of_iterations) const;
385 
392  std::shared_ptr<TriangleMesh> SimplifyVertexClustering(
393  double voxel_size,
394  SimplificationContraction contraction =
396 
406  std::shared_ptr<TriangleMesh> SimplifyQuadricDecimation(
407  int target_number_of_triangles,
408  double maximum_error,
409  double boundary_weight) const;
410 
420  std::shared_ptr<TriangleMesh> SelectByIndex(
421  const std::vector<size_t> &indices, bool cleanup = true) const;
422 
427  std::shared_ptr<TriangleMesh> Crop(
428  const AxisAlignedBoundingBox &bbox) const;
429 
434  std::shared_ptr<TriangleMesh> Crop(const OrientedBoundingBox &bbox) const;
435 
442  std::tuple<std::vector<int>, std::vector<size_t>, std::vector<double>>
444 
451  void RemoveTrianglesByIndex(const std::vector<size_t> &triangle_indices);
452 
459  void RemoveTrianglesByMask(const std::vector<bool> &triangle_mask);
460 
467  void RemoveVerticesByIndex(const std::vector<size_t> &vertex_indices);
468 
475  void RemoveVerticesByMask(const std::vector<bool> &vertex_mask);
476 
490  std::shared_ptr<TriangleMesh> DeformAsRigidAsPossible(
491  const std::vector<int> &constraint_vertex_indices,
492  const std::vector<Eigen::Vector3d> &constraint_vertex_positions,
493  size_t max_iter,
496  double smoothed_alpha = 0.01) const;
497 
509  static std::shared_ptr<TriangleMesh> CreateFromPointCloudAlphaShape(
510  const PointCloud &pcd,
511  double alpha,
512  std::shared_ptr<TetraMesh> tetra_mesh = nullptr,
513  std::vector<size_t> *pt_map = nullptr);
514 
528  static std::shared_ptr<TriangleMesh> CreateFromPointCloudBallPivoting(
529  const PointCloud &pcd, const std::vector<double> &radii);
530 
553  static std::tuple<std::shared_ptr<TriangleMesh>, std::vector<double>>
555  size_t depth = 8,
556  float width = 0.0f,
557  float scale = 1.1f,
558  bool linear_fit = false,
559  int n_threads = -1);
560 
566  static std::shared_ptr<TriangleMesh> CreateTetrahedron(
567  double radius = 1.0, bool create_uv_map = false);
568 
574  static std::shared_ptr<TriangleMesh> CreateOctahedron(
575  double radius = 1.0, bool create_uv_map = false);
576 
581  static std::shared_ptr<TriangleMesh> CreateIcosahedron(
582  double radius = 1.0, bool create_uv_map = false);
583 
588  static std::shared_ptr<TriangleMesh> CreateFromOrientedBoundingBox(
589  const OrientedBoundingBox &obox,
590  const Eigen::Vector3d &scale = Eigen::Vector3d::Ones(),
591  bool create_uv_map = false);
592 
601  static std::shared_ptr<TriangleMesh> CreateBox(
602  double width = 1.0,
603  double height = 1.0,
604  double depth = 1.0,
605  bool create_uv_map = false,
606  bool map_texture_to_each_face = false);
607 
618  static std::shared_ptr<TriangleMesh> CreateSphere(
619  double radius = 1.0,
620  int resolution = 20,
621  bool create_uv_map = false);
622 
634  static std::shared_ptr<TriangleMesh> CreateCylinder(
635  double radius = 1.0,
636  double height = 2.0,
637  int resolution = 20,
638  int split = 4,
639  bool create_uv_map = false);
640 
651  static std::shared_ptr<TriangleMesh> CreateCone(double radius = 1.0,
652  double height = 2.0,
653  int resolution = 20,
654  int split = 1,
655  bool create_uv_map = false);
656 
670  static std::shared_ptr<TriangleMesh> CreateTorus(
671  double torus_radius = 1.0,
672  double tube_radius = 0.5,
673  int radial_resolution = 30,
674  int tubular_resolution = 20);
675 
686  //
700  static std::shared_ptr<TriangleMesh> CreateArrow(
701  double cylinder_radius = 1.0,
702  double cone_radius = 1.5,
703  double cylinder_height = 5.0,
704  double cone_height = 4.0,
705  int resolution = 20,
706  int cylinder_split = 4,
707  int cone_split = 1);
708 
714  static std::shared_ptr<TriangleMesh> CreateCoordinateFrame(
715  double size = 1.0,
716  const Eigen::Vector3d &origin = Eigen::Vector3d(0.0, 0.0, 0.0));
717 
728  static std::shared_ptr<TriangleMesh> CreateMobius(int length_split = 70,
729  int width_split = 15,
730  int twists = 1,
731  double radius = 1,
732  double flatness = 1,
733  double width = 1,
734  double scale = 1);
735 
736 protected:
737  // Forward child class type to avoid indirect nonvirtual base
739 
741  std::shared_ptr<TriangleMesh> &mesh,
742  const std::vector<Eigen::Vector3d> &prev_vertices,
743  const std::vector<Eigen::Vector3d> &prev_vertex_normals,
744  const std::vector<Eigen::Vector3d> &prev_vertex_colors,
745  const std::vector<std::unordered_set<int>> &adjacency_list,
746  double lambda_filter,
747  bool filter_vertex,
748  bool filter_normal,
749  bool filter_color) const;
750 
759  std::unordered_map<Eigen::Vector2i,
760  double,
763  const std::unordered_map<Eigen::Vector2i,
764  std::vector<int>,
766  &edges_to_vertices,
767  double min_weight = std::numeric_limits<double>::lowest()) const;
768 
769 public:
771  std::vector<Eigen::Vector3i> triangles_;
773  std::vector<Eigen::Vector3d> triangle_normals_;
776  std::vector<std::unordered_set<int>> adjacency_list_;
778  std::vector<Eigen::Vector2d> triangle_uvs_;
779 
780  struct Material {
782  float f4[4] = {0};
783 
785  f4[0] = 0;
786  f4[1] = 0;
787  f4[2] = 0;
788  f4[3] = 0;
789  }
790 
791  MaterialParameter(const float v1,
792  const float v2,
793  const float v3,
794  const float v4) {
795  f4[0] = v1;
796  f4[1] = v2;
797  f4[2] = v3;
798  f4[3] = v4;
799  }
800 
801  MaterialParameter(const float v1, const float v2, const float v3) {
802  f4[0] = v1;
803  f4[1] = v2;
804  f4[2] = v3;
805  f4[3] = 1;
806  }
807 
808  MaterialParameter(const float v1, const float v2) {
809  f4[0] = v1;
810  f4[1] = v2;
811  f4[2] = 0;
812  f4[3] = 0;
813  }
814 
815  explicit MaterialParameter(const float v1) {
816  f4[0] = v1;
817  f4[1] = 0;
818  f4[2] = 0;
819  f4[3] = 0;
820  }
821 
822  static MaterialParameter CreateRGB(const float r,
823  const float g,
824  const float b) {
825  return {r, g, b, 1.f};
826  }
827 
828  float r() const { return f4[0]; }
829  float g() const { return f4[1]; }
830  float b() const { return f4[2]; }
831  float a() const { return f4[3]; }
832  };
833 
835  float baseMetallic = 0.f;
836  float baseRoughness = 1.f;
837  float baseReflectance = 0.5f;
838  float baseClearCoat = 0.f;
840  float baseAnisotropy = 0.f;
841 
842  std::shared_ptr<Image> albedo;
843  std::shared_ptr<Image> normalMap;
844  std::shared_ptr<Image> ambientOcclusion;
845  std::shared_ptr<Image> metallic;
846  std::shared_ptr<Image> roughness;
847  std::shared_ptr<Image> reflectance;
848  std::shared_ptr<Image> clearCoat;
849  std::shared_ptr<Image> clearCoatRoughness;
850  std::shared_ptr<Image> anisotropy;
851 
852  std::unordered_map<std::string, MaterialParameter> floatParameters;
853  std::unordered_map<std::string, Image> additionalMaps;
854  };
855 
856  std::unordered_map<std::string, Material> materials_;
857 
859  std::vector<int> triangle_material_ids_;
861  std::vector<Image> textures_;
862 };
863 
864 } // namespace geometry
865 } // namespace open3d
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:159
The base geometry class.
Definition: Geometry.h:18
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:23
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:34
MeshBash Class.
Definition: MeshBase.h:32
std::vector< Eigen::Vector3d > vertices_
Vertex coordinates.
Definition: MeshBase.h:149
DeformAsRigidAsPossibleEnergy
Definition: MeshBase.h:57
SimplificationContraction
Indicates the method that is used for mesh simplification if multiple vertices are combined to a sing...
Definition: MeshBase.h:42
MeshBase & NormalizeNormals()
Normalize vertex normals to length 1.
Definition: MeshBase.h:118
FilterScope
Indicates the scope of filter operations.
Definition: MeshBase.h:51
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:25
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition: PointCloud.h:36
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:35
virtual TriangleMesh & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
Definition: TriangleMesh.cpp:46
bool IsBoundingBoxIntersecting(const TriangleMesh &other) const
Definition: TriangleMesh.cpp:1393
TriangleMesh(Geometry::GeometryType type)
Definition: TriangleMesh.h:738
TriangleMesh & RemoveNonManifoldEdges()
Function that removes all non-manifold edges, by successively deleting triangles with the smallest su...
Definition: TriangleMesh.cpp:830
std::vector< Image > textures_
Textures of the image.
Definition: TriangleMesh.h:861
static double ComputeTriangleArea(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Function that computes the area of a mesh triangle.
Definition: TriangleMesh.cpp:1148
std::shared_ptr< TriangleMesh > SubdivideMidpoint(int number_of_iterations) const
Definition: TriangleMeshSubdivide.cpp:18
std::shared_ptr< PointCloud > SamplePointsUniformlyImpl(size_t number_of_points, std::vector< double > &triangle_areas, double surface_area, bool use_triangle_normal)
Definition: TriangleMesh.cpp:434
std::tuple< std::vector< int >, std::vector< size_t >, std::vector< double > > ClusterConnectedTriangles() const
Function that clusters connected triangles, i.e., triangles that are connected via edges are assigned...
Definition: TriangleMesh.cpp:1421
double GetVolume() const
Definition: TriangleMesh.cpp:1185
std::shared_ptr< TriangleMesh > SubdivideLoop(int number_of_iterations) const
Definition: TriangleMeshSubdivide.cpp:96
static std::shared_ptr< TriangleMesh > CreateIcosahedron(double radius=1.0, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:85
TriangleMesh & operator+=(const TriangleMesh &mesh)
Definition: TriangleMesh.cpp:53
std::shared_ptr< TriangleMesh > FilterSmoothTaubin(int number_of_iterations, double lambda_filter=0.5, double mu=-0.53, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh using method of Taubin, "Curve and Surface Smoothing Without Shrinka...
Definition: TriangleMesh.cpp:386
std::shared_ptr< PointCloud > SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false)
Definition: TriangleMesh.cpp:501
std::vector< Eigen::Vector2i > GetSelfIntersectingTriangles() const
Definition: TriangleMesh.cpp:1344
std::shared_ptr< PointCloud > SamplePointsPoissonDisk(size_t number_of_points, double init_factor=5, const std::shared_ptr< PointCloud > pcl_init=nullptr, bool use_triangle_normal=false)
Definition: TriangleMesh.cpp:518
bool IsVertexManifold() const
Definition: TriangleMesh.cpp:1340
TriangleMesh & RemoveDuplicatedVertices()
Function that removes duplicated verties, i.e., vertices that have identical coordinates.
Definition: TriangleMesh.cpp:662
std::vector< std::unordered_set< int > > adjacency_list_
Definition: TriangleMesh.h:776
static std::shared_ptr< TriangleMesh > CreateMobius(int length_split=70, int width_split=15, int twists=1, double radius=1, double flatness=1, double width=1, double scale=1)
Definition: TriangleMeshFactory.cpp:800
bool IsEdgeManifold(bool allow_boundary_edges=true) const
Definition: TriangleMesh.cpp:1271
void RemoveTrianglesByIndex(const std::vector< size_t > &triangle_indices)
This function removes the triangles with index in triangle_indices. Call RemoveUnreferencedVertices t...
Definition: TriangleMesh.cpp:1487
static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Definition: TriangleMesh.cpp:1218
bool HasTriangles() const
Returns true if the mesh contains triangles.
Definition: TriangleMesh.h:61
TriangleMesh & ComputeVertexNormals(bool normalized=true)
Function to compute vertex normals, usually called before rendering.
Definition: TriangleMesh.cpp:127
void RemoveVerticesByIndex(const std::vector< size_t > &vertex_indices)
This function removes the vertices with index in vertex_indices. Note that also all triangles associa...
Definition: TriangleMesh.cpp:1538
static std::shared_ptr< TriangleMesh > CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:539
static std::tuple< std::shared_ptr< TriangleMesh >, std::vector< double > > CreateFromPointCloudPoisson(const PointCloud &pcd, size_t depth=8, float width=0.0f, float scale=1.1f, bool linear_fit=false, int n_threads=-1)
Function that computes a triangle mesh from an oriented PointCloud pcd. This implements the Screened ...
Definition: SurfaceReconstructionPoisson.cpp:719
virtual TriangleMesh & Clear() override
Clear all elements in the geometry.
Definition: TriangleMesh.cpp:27
TriangleMesh & MergeCloseVertices(double eps)
Function that will merge close by vertices to a single one. The vertex position, normal and color wil...
Definition: TriangleMesh.cpp:910
static Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1)
Helper function to get an edge with ordered vertex indices.
Definition: TriangleMesh.h:332
static std::shared_ptr< TriangleMesh > CreateFromPointCloudAlphaShape(const PointCloud &pcd, double alpha, std::shared_ptr< TetraMesh > tetra_mesh=nullptr, std::vector< size_t > *pt_map=nullptr)
Alpha shapes are a generalization of the convex hull. With decreasing alpha value the shape schrinks ...
Definition: SurfaceReconstructionAlphaShape.cpp:25
std::shared_ptr< TriangleMesh > SimplifyVertexClustering(double voxel_size, SimplificationContraction contraction=SimplificationContraction::Average) const
Definition: TriangleMeshSimplification.cpp:72
int EulerPoincareCharacteristic() const
Definition: TriangleMesh.cpp:1242
std::shared_ptr< TriangleMesh > SelectByIndex(const std::vector< size_t > &indices, bool cleanup=true) const
Definition: TriangleMesh.cpp:1599
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToTrianglesMap() const
Definition: TriangleMesh.cpp:1113
bool HasTriangleMaterialIds() const
Definition: TriangleMesh.h:90
void RemoveVerticesByMask(const std::vector< bool > &vertex_mask)
This function removes the vertices that are masked in vertex_mask. Note that also all triangles assoc...
Definition: TriangleMesh.cpp:1555
static std::shared_ptr< TriangleMesh > CreateFromPointCloudBallPivoting(const PointCloud &pcd, const std::vector< double > &radii)
Definition: SurfaceReconstructionBallPivoting.cpp:737
std::vector< Eigen::Vector2d > triangle_uvs_
List of uv coordinates per triangle.
Definition: TriangleMesh.h:778
void FilterSmoothLaplacianHelper(std::shared_ptr< TriangleMesh > &mesh, const std::vector< Eigen::Vector3d > &prev_vertices, const std::vector< Eigen::Vector3d > &prev_vertex_normals, const std::vector< Eigen::Vector3d > &prev_vertex_colors, const std::vector< std::unordered_set< int >> &adjacency_list, double lambda_filter, bool filter_vertex, bool filter_normal, bool filter_color) const
Definition: TriangleMesh.cpp:293
~TriangleMesh() override
Definition: TriangleMesh.h:47
virtual TriangleMesh & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: TriangleMesh.cpp:40
static std::shared_ptr< TriangleMesh > CreateTetrahedron(double radius=1.0, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:15
bool IsOrientable() const
Definition: TriangleMesh.cpp:1094
std::unordered_map< Eigen::Vector2i, double, utility::hash_eigen< Eigen::Vector2i > > ComputeEdgeWeightsCot(const std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i >> &edges_to_vertices, double min_weight=std::numeric_limits< double >::lowest()) const
Function that computes for each edge in the triangle mesh and passed as parameter edges_to_vertices t...
Definition: TriangleMesh.cpp:1683
std::vector< Eigen::Vector3i > triangles_
List of triangles denoted by the index of points forming the triangle.
Definition: TriangleMesh.h:771
bool HasTextures() const
Returns true if the mesh has texture.
Definition: TriangleMesh.h:81
bool OrientTriangles()
Definition: TriangleMesh.cpp:1103
bool HasTriangleUvs() const
Definition: TriangleMesh.h:76
std::shared_ptr< TriangleMesh > Crop(const AxisAlignedBoundingBox &bbox) const
Definition: TriangleMesh.cpp:1659
std::vector< Eigen::Vector3d > triangle_normals_
Triangle normals.
Definition: TriangleMesh.h:773
static std::shared_ptr< TriangleMesh > CreateOctahedron(double radius=1.0, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:52
TriangleMesh & RemoveDuplicatedTriangles()
Function that removes duplicated triangles, i.e., removes triangles that reference the same three ver...
Definition: TriangleMesh.cpp:705
static std::shared_ptr< TriangleMesh > CreateFromOrientedBoundingBox(const OrientedBoundingBox &obox, const Eigen::Vector3d &scale=Eigen::Vector3d::Ones(), bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:142
std::vector< Eigen::Vector2i > GetNonManifoldEdges(bool allow_boundary_edges=true) const
Definition: TriangleMesh.cpp:1257
std::unordered_map< std::string, Material > materials_
Definition: TriangleMesh.h:856
TriangleMesh & RemoveDegenerateTriangles()
Function that removes degenerate triangles, i.e., triangles that reference a single vertex multiple t...
Definition: TriangleMesh.cpp:800
std::shared_ptr< TriangleMesh > DeformAsRigidAsPossible(const std::vector< int > &constraint_vertex_indices, const std::vector< Eigen::Vector3d > &constraint_vertex_positions, size_t max_iter, DeformAsRigidAsPossibleEnergy energy=DeformAsRigidAsPossibleEnergy::Spokes, double smoothed_alpha=0.01) const
This function deforms the mesh using the method by Sorkine and Alexa, "As-Rigid-As-Possible Surface M...
Definition: TriangleMeshDeformation.cpp:19
static std::shared_ptr< TriangleMesh > CreateArrow(double cylinder_radius=1.0, double cone_radius=1.5, double cylinder_height=5.0, double cone_height=4.0, int resolution=20, int cylinder_split=4, int cone_split=1)
Definition: TriangleMeshFactory.cpp:718
TriangleMesh & RemoveUnreferencedVertices()
This function removes vertices from the triangle mesh that are not referenced in any triangle of the ...
Definition: TriangleMesh.cpp:757
std::shared_ptr< TriangleMesh > SimplifyQuadricDecimation(int target_number_of_triangles, double maximum_error, double boundary_weight) const
Definition: TriangleMeshSimplification.cpp:246
bool HasTriangleNormals() const
Returns true if the mesh contains triangle normals.
Definition: TriangleMesh.h:66
static std::shared_ptr< TriangleMesh > CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:383
bool IsWatertight() const
Definition: TriangleMesh.cpp:1099
bool HasAdjacencyList() const
Returns true if the mesh contains adjacency normals.
Definition: TriangleMesh.h:71
bool IsIntersecting(const TriangleMesh &other) const
Definition: TriangleMesh.cpp:1398
TriangleMesh & NormalizeNormals()
Normalize both triangle normals and vertex normals to length 1.
Definition: TriangleMesh.h:96
double GetTriangleArea(size_t triangle_idx) const
Definition: TriangleMesh.cpp:1157
static std::shared_ptr< TriangleMesh > CreateTorus(double torus_radius=1.0, double tube_radius=0.5, int radial_resolution=30, int tubular_resolution=20)
Definition: TriangleMeshFactory.cpp:666
TriangleMesh & ComputeAdjacencyList()
Function to compute adjacency list, call before adjacency list is needed.
Definition: TriangleMesh.cpp:142
TriangleMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector3i > &triangles)
Parameterized Constructor.
Definition: TriangleMesh.h:43
static Eigen::Vector3i GetOrderedTriangle(int vidx0, int vidx1, int vidx2)
Definition: TriangleMesh.h:291
std::shared_ptr< TriangleMesh > FilterSharpen(int number_of_iterations, double strength, FilterScope scope=FilterScope::All) const
Function to sharpen triangle mesh.
Definition: TriangleMesh.cpp:156
std::vector< int > triangle_material_ids_
List of material ids.
Definition: TriangleMesh.h:859
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToVerticesMap() const
Definition: TriangleMesh.cpp:1132
Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const
Definition: TriangleMesh.cpp:1234
std::shared_ptr< TriangleMesh > FilterSmoothSimple(int number_of_iterations, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh with simple neighbour average.
Definition: TriangleMesh.cpp:227
TriangleMesh operator+(const TriangleMesh &mesh) const
Definition: TriangleMesh.cpp:108
TriangleMesh()
Default Constructor.
Definition: TriangleMesh.h:38
bool IsSelfIntersecting() const
Definition: TriangleMesh.cpp:1389
static std::shared_ptr< TriangleMesh > CreateBox(double width=1.0, double height=1.0, double depth=1.0, bool create_uv_map=false, bool map_texture_to_each_face=false)
Definition: TriangleMeshFactory.cpp:154
std::shared_ptr< TriangleMesh > FilterSmoothLaplacian(int number_of_iterations, double lambda_filter, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh using Laplacian.
Definition: TriangleMesh.cpp:345
TriangleMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
Definition: TriangleMesh.cpp:112
double GetSurfaceArea() const
Definition: TriangleMesh.cpp:1165
std::vector< int > GetNonManifoldVertices() const
Definition: TriangleMesh.cpp:1284
void RemoveTrianglesByMask(const std::vector< bool > &triangle_mask)
This function removes the triangles that are masked in triangle_mask. Call RemoveUnreferencedVertices...
Definition: TriangleMesh.cpp:1504
static std::shared_ptr< TriangleMesh > CreateCoordinateFrame(double size=1.0, const Eigen::Vector3d &origin=Eigen::Vector3d(0.0, 0.0, 0.0))
Definition: TriangleMeshFactory.cpp:761
static std::shared_ptr< TriangleMesh > CreateSphere(double radius=1.0, int resolution=20, bool create_uv_map=false)
Definition: TriangleMeshFactory.cpp:216
bool HasMaterials() const
Definition: TriangleMesh.h:88
int width
Definition: FilePCD.cpp:52
int size
Definition: FilePCD.cpp:40
int height
Definition: FilePCD.cpp:53
char type
Definition: FilePCD.cpp:41
Definition: PinholeCameraIntrinsic.cpp:16
void swap(open3d::core::SmallVectorImpl< T > &LHS, open3d::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1370
float b() const
Definition: TriangleMesh.h:830
float g() const
Definition: TriangleMesh.h:829
float r() const
Definition: TriangleMesh.h:828
MaterialParameter(const float v1, const float v2, const float v3, const float v4)
Definition: TriangleMesh.h:791
static MaterialParameter CreateRGB(const float r, const float g, const float b)
Definition: TriangleMesh.h:822
MaterialParameter(const float v1, const float v2, const float v3)
Definition: TriangleMesh.h:801
MaterialParameter(const float v1, const float v2)
Definition: TriangleMesh.h:808
MaterialParameter(const float v1)
Definition: TriangleMesh.h:815
float a() const
Definition: TriangleMesh.h:831
Definition: TriangleMesh.h:780
std::shared_ptr< Image > anisotropy
Definition: TriangleMesh.h:850
std::shared_ptr< Image > normalMap
Definition: TriangleMesh.h:843
std::shared_ptr< Image > clearCoatRoughness
Definition: TriangleMesh.h:849
std::shared_ptr< Image > roughness
Definition: TriangleMesh.h:846
float baseAnisotropy
Definition: TriangleMesh.h:840
std::unordered_map< std::string, Image > additionalMaps
Definition: TriangleMesh.h:853
float baseClearCoat
Definition: TriangleMesh.h:838
float baseRoughness
Definition: TriangleMesh.h:836
std::unordered_map< std::string, MaterialParameter > floatParameters
Definition: TriangleMesh.h:852
std::shared_ptr< Image > reflectance
Definition: TriangleMesh.h:847
MaterialParameter baseColor
Definition: TriangleMesh.h:834
std::shared_ptr< Image > metallic
Definition: TriangleMesh.h:845
std::shared_ptr< Image > ambientOcclusion
Definition: TriangleMesh.h:844
std::shared_ptr< Image > albedo
Definition: TriangleMesh.h:842
float baseReflectance
Definition: TriangleMesh.h:837
float baseMetallic
Definition: TriangleMesh.h:835
std::shared_ptr< Image > clearCoat
Definition: TriangleMesh.h:848
float baseClearCoatRoughness
Definition: TriangleMesh.h:839
Definition: Helper.h:71