Open3D (C++ API)  0.20.0+2ce4f7e
Loading...
Searching...
No Matches
TriangleMesh.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2026 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
10#include <Eigen/Core>
11#include <cstdint>
12#include <memory>
13#include <numeric>
14#include <tuple>
15#include <unordered_map>
16#include <unordered_set>
17#include <vector>
18
19#include "open3d/Macro.h"
24
25namespace open3d {
26namespace geometry {
27
28namespace detail {
29
30inline void AssertTriangleIndicesInRange(const Eigen::Vector3i &triangle,
31 int64_t vertex_count) {
33 triangle.minCoeff() >= 0 &&
34 static_cast<int64_t>(triangle.maxCoeff()) < vertex_count,
35 "Triangle vertex index is out of range.");
36}
37
39 const std::vector<Eigen::Vector3i> &triangles, int64_t vertex_count) {
40 for (const Eigen::Vector3i &triangle : triangles) {
41 AssertTriangleIndicesInRange(triangle, vertex_count);
42 }
43}
44
45} // namespace detail
46
47class PointCloud;
48class TetraMesh;
49
57class TriangleMesh : public MeshBase {
58public:
65 TriangleMesh(const std::vector<Eigen::Vector3d> &vertices,
66 const std::vector<Eigen::Vector3i> &triangles)
68 triangles_(triangles) {}
69 ~TriangleMesh() override {}
70
71public:
72 virtual TriangleMesh &Clear() override;
73 virtual TriangleMesh &Transform(
74 const Eigen::Matrix4d &transformation) override;
75 virtual TriangleMesh &Rotate(const Eigen::Matrix3d &R,
76 const Eigen::Vector3d &center) override;
77
78public:
80 TriangleMesh operator+(const TriangleMesh &mesh) const;
81
83 bool HasTriangles() const {
84 return vertices_.size() > 0 && triangles_.size() > 0;
85 }
86
88 bool HasTriangleNormals() const {
89 return HasTriangles() && triangles_.size() == triangle_normals_.size();
90 }
91
93 bool HasAdjacencyList() const {
94 return vertices_.size() > 0 &&
95 adjacency_list_.size() == vertices_.size();
96 }
97
98 bool HasTriangleUvs() const {
99 return HasTriangles() && triangle_uvs_.size() == 3 * triangles_.size();
100 }
101
103 bool HasTextures() const {
104 bool is_all_texture_valid = std::accumulate(
105 textures_.begin(), textures_.end(), true,
106 [](bool a, const Image &b) { return a && !b.IsEmpty(); });
107 return !textures_.empty() && is_all_texture_valid;
108 }
109
110 bool HasMaterials() const { return !materials_.empty(); }
111
113 return HasTriangles() &&
114 triangle_material_ids_.size() == triangles_.size();
115 }
116
120 for (size_t i = 0; i < triangle_normals_.size(); i++) {
121 triangle_normals_[i].normalize();
122 if (std::isnan(triangle_normals_[i](0))) {
123 triangle_normals_[i] = Eigen::Vector3d(0.0, 0.0, 1.0);
124 }
125 }
126 return *this;
127 }
128
131 TriangleMesh &ComputeTriangleNormals(bool normalized = true);
132
135 TriangleMesh &ComputeVertexNormals(bool normalized = true);
136
140
144
149
153
159
165
172 TriangleMesh &MergeCloseVertices(double eps);
173
183 std::shared_ptr<TriangleMesh> FilterSharpen(
184 int number_of_iterations,
185 double strength,
186 FilterScope scope = FilterScope::All) const;
187
196 std::shared_ptr<TriangleMesh> FilterSmoothSimple(
197 int number_of_iterations,
198 FilterScope scope = FilterScope::All) const;
199
214 std::shared_ptr<TriangleMesh> FilterSmoothLaplacian(
215 int number_of_iterations,
216 double lambda_filter,
217 FilterScope scope = FilterScope::All) const;
218
231 std::shared_ptr<TriangleMesh> FilterSmoothTaubin(
232 int number_of_iterations,
233 double lambda_filter = 0.5,
234 double mu = -0.53,
235 FilterScope scope = FilterScope::All) const;
236
240 int EulerPoincareCharacteristic() const;
241
245 std::vector<Eigen::Vector2i> GetNonManifoldEdges(
246 bool allow_boundary_edges = true) const;
247
252 bool IsEdgeManifold(bool allow_boundary_edges = true) const;
253
257 std::vector<int> GetNonManifoldVertices() const;
258
262 bool IsVertexManifold() const;
263
266 std::vector<Eigen::Vector2i> GetSelfIntersectingTriangles() const;
267
270 bool IsSelfIntersecting() const;
271
274 bool IsBoundingBoxIntersecting(const TriangleMesh &other) const;
275
278 bool IsIntersecting(const TriangleMesh &other) const;
279
283 bool IsOrientable() const;
284
288 bool IsWatertight() const;
289
293 bool OrientTriangles();
294
297 std::unordered_map<Eigen::Vector2i,
298 std::vector<int>,
300 GetEdgeToTrianglesMap() const;
301
304 std::unordered_map<Eigen::Vector2i,
305 std::vector<int>,
307 GetEdgeToVerticesMap() const;
308
310 static double ComputeTriangleArea(const Eigen::Vector3d &p0,
311 const Eigen::Vector3d &p1,
312 const Eigen::Vector3d &p2);
313
316 double GetTriangleArea(size_t triangle_idx) const;
317
318 static inline Eigen::Vector3i GetOrderedTriangle(int vidx0,
319 int vidx1,
320 int vidx2) {
321 if (vidx0 > vidx2) {
322 std::swap(vidx0, vidx2);
323 }
324 if (vidx0 > vidx1) {
325 std::swap(vidx0, vidx1);
326 }
327 if (vidx1 > vidx2) {
328 std::swap(vidx1, vidx2);
329 }
330 return Eigen::Vector3i(vidx0, vidx1, vidx2);
331 }
332
335 double GetSurfaceArea() const;
336
339 double GetSurfaceArea(std::vector<double> &triangle_areas) const;
340
345 double GetVolume() const;
346
350 static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0,
351 const Eigen::Vector3d &p1,
352 const Eigen::Vector3d &p2);
353
356 Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const;
357
359 static inline Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1) {
360 return Eigen::Vector2i(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
361 }
362
365 std::shared_ptr<PointCloud> SamplePointsUniformlyImpl(
366 size_t number_of_points,
367 const std::vector<double> &triangle_areas,
368 bool use_triangle_normal);
369
376 std::shared_ptr<PointCloud> SamplePointsUniformly(
377 size_t number_of_points, bool use_triangle_normal = false);
378
391 std::shared_ptr<PointCloud> SamplePointsPoissonDisk(
392 size_t number_of_points,
393 double init_factor = 5,
394 const std::shared_ptr<PointCloud> pcl_init = nullptr,
395 bool use_triangle_normal = false);
396
402 std::shared_ptr<TriangleMesh> SubdivideMidpoint(
403 int number_of_iterations) const;
404
410 std::shared_ptr<TriangleMesh> SubdivideLoop(int number_of_iterations) const;
411
418 std::shared_ptr<TriangleMesh> SimplifyVertexClustering(
419 double voxel_size,
420 SimplificationContraction contraction =
422
432 std::shared_ptr<TriangleMesh> SimplifyQuadricDecimation(
433 int target_number_of_triangles,
434 double maximum_error,
435 double boundary_weight) const;
436
446 std::shared_ptr<TriangleMesh> SelectByIndex(
447 const std::vector<size_t> &indices, bool cleanup = true) const;
448
453 std::shared_ptr<TriangleMesh> Crop(
454 const AxisAlignedBoundingBox &bbox) const;
455
460 std::shared_ptr<TriangleMesh> Crop(const OrientedBoundingBox &bbox) const;
461
468 std::tuple<std::vector<int>, std::vector<size_t>, std::vector<double>>
470
477 void RemoveTrianglesByIndex(const std::vector<size_t> &triangle_indices);
478
485 void RemoveTrianglesByMask(const std::vector<bool> &triangle_mask);
486
493 void RemoveVerticesByIndex(const std::vector<size_t> &vertex_indices);
494
501 void RemoveVerticesByMask(const std::vector<bool> &vertex_mask);
502
516 std::shared_ptr<TriangleMesh> DeformAsRigidAsPossible(
517 const std::vector<int> &constraint_vertex_indices,
518 const std::vector<Eigen::Vector3d> &constraint_vertex_positions,
519 size_t max_iter,
522 double smoothed_alpha = 0.01) const;
523
535 static std::shared_ptr<TriangleMesh> CreateFromPointCloudAlphaShape(
536 const PointCloud &pcd,
537 double alpha,
538 std::shared_ptr<TetraMesh> tetra_mesh = nullptr,
539 std::vector<size_t> *pt_map = nullptr);
540
554 static std::shared_ptr<TriangleMesh> CreateFromPointCloudBallPivoting(
555 const PointCloud &pcd, const std::vector<double> &radii);
556
595 static std::tuple<std::shared_ptr<TriangleMesh>, std::vector<double>>
597 size_t depth = 8,
598 float width = 0.0f,
599 float scale = 1.1f,
600 bool linear_fit = false,
601 int n_threads = -1,
602 int full_depth = 5,
603 float samples_per_node = 1.5f,
604 float point_weight = 2.0f);
605
611 static std::shared_ptr<TriangleMesh> CreateTetrahedron(
612 double radius = 1.0, bool create_uv_map = false);
613
619 static std::shared_ptr<TriangleMesh> CreateOctahedron(
620 double radius = 1.0, bool create_uv_map = false);
621
626 static std::shared_ptr<TriangleMesh> CreateIcosahedron(
627 double radius = 1.0, bool create_uv_map = false);
628
633 static std::shared_ptr<TriangleMesh> CreateFromOrientedBoundingBox(
634 const OrientedBoundingBox &obox,
635 const Eigen::Vector3d &scale = Eigen::Vector3d::Ones(),
636 bool create_uv_map = false);
637
644 static std::shared_ptr<TriangleMesh> CreateFromOrientedBoundingEllipsoid(
645 const OrientedBoundingEllipsoid &obel,
646 const Eigen::Vector3d &scale = Eigen::Vector3d::Ones(),
647 int resolution = 20,
648 bool create_uv_map = false);
649
658 static std::shared_ptr<TriangleMesh> CreateBox(
659 double width = 1.0,
660 double height = 1.0,
661 double depth = 1.0,
662 bool create_uv_map = false,
663 bool map_texture_to_each_face = false);
664
675 static std::shared_ptr<TriangleMesh> CreateSphere(
676 double radius = 1.0,
677 int resolution = 20,
678 bool create_uv_map = false);
679
687 static std::shared_ptr<TriangleMesh> CreateEllipsoid(
688 double radius_x = 1.0,
689 double radius_y = 1.0,
690 double radius_z = 1.0,
691 int resolution = 20,
692 bool create_uv_map = false);
693
705 static std::shared_ptr<TriangleMesh> CreateCylinder(
706 double radius = 1.0,
707 double height = 2.0,
708 int resolution = 20,
709 int split = 4,
710 bool create_uv_map = false);
711
722 static std::shared_ptr<TriangleMesh> CreateCone(double radius = 1.0,
723 double height = 2.0,
724 int resolution = 20,
725 int split = 1,
726 bool create_uv_map = false);
727
741 static std::shared_ptr<TriangleMesh> CreateTorus(
742 double torus_radius = 1.0,
743 double tube_radius = 0.5,
744 int radial_resolution = 30,
745 int tubular_resolution = 20);
746
757 //
771 static std::shared_ptr<TriangleMesh> CreateArrow(
772 double cylinder_radius = 1.0,
773 double cone_radius = 1.5,
774 double cylinder_height = 5.0,
775 double cone_height = 4.0,
776 int resolution = 20,
777 int cylinder_split = 4,
778 int cone_split = 1);
779
785 static std::shared_ptr<TriangleMesh> CreateCoordinateFrame(
786 double size = 1.0,
787 const Eigen::Vector3d &origin = Eigen::Vector3d(0.0, 0.0, 0.0));
788
799 static std::shared_ptr<TriangleMesh> CreateMobius(int length_split = 70,
800 int width_split = 15,
801 int twists = 1,
802 double radius = 1,
803 double flatness = 1,
804 double width = 1,
805 double scale = 1);
806
807protected:
808 // Forward child class type to avoid indirect nonvirtual base
810
819 std::unordered_map<Eigen::Vector2i,
820 double,
823 const std::unordered_map<Eigen::Vector2i,
824 std::vector<int>,
826 &edges_to_vertices,
827 double min_weight = std::numeric_limits<double>::lowest()) const;
828
829public:
831 std::vector<Eigen::Vector3i> triangles_;
833 std::vector<Eigen::Vector3d> triangle_normals_;
836 std::vector<std::unordered_set<int>> adjacency_list_;
838 std::vector<Eigen::Vector2d> triangle_uvs_;
839
840 struct Material {
842 float f4[4] = {0};
843
845 f4[0] = 0;
846 f4[1] = 0;
847 f4[2] = 0;
848 f4[3] = 0;
849 }
850
851 MaterialParameter(const float v1,
852 const float v2,
853 const float v3,
854 const float v4) {
855 f4[0] = v1;
856 f4[1] = v2;
857 f4[2] = v3;
858 f4[3] = v4;
859 }
860
861 MaterialParameter(const float v1, const float v2, const float v3) {
862 f4[0] = v1;
863 f4[1] = v2;
864 f4[2] = v3;
865 f4[3] = 1;
866 }
867
868 MaterialParameter(const float v1, const float v2) {
869 f4[0] = v1;
870 f4[1] = v2;
871 f4[2] = 0;
872 f4[3] = 0;
873 }
874
875 explicit MaterialParameter(const float v1) {
876 f4[0] = v1;
877 f4[1] = 0;
878 f4[2] = 0;
879 f4[3] = 0;
880 }
881
882 static MaterialParameter CreateRGB(const float r,
883 const float g,
884 const float b) {
885 return {r, g, b, 1.f};
886 }
887
888 float r() const { return f4[0]; }
889 float g() const { return f4[1]; }
890 float b() const { return f4[2]; }
891 float a() const { return f4[3]; }
892 };
893
895 float baseMetallic = 0.f;
896 float baseRoughness = 1.f;
897 float baseReflectance = 0.5f;
898 float baseClearCoat = 0.f;
900 float baseAnisotropy = 0.f;
901
902 std::shared_ptr<Image> albedo;
903 std::shared_ptr<Image> normalMap;
904 std::shared_ptr<Image> ambientOcclusion;
905 std::shared_ptr<Image> metallic;
906 std::shared_ptr<Image> roughness;
907 std::shared_ptr<Image> reflectance;
908 std::shared_ptr<Image> clearCoat;
909 std::shared_ptr<Image> clearCoatRoughness;
910 std::shared_ptr<Image> anisotropy;
911
912 std::unordered_map<std::string, MaterialParameter> floatParameters;
913 std::unordered_map<std::string, Image> additionalMaps;
914 };
915
916 std::vector<std::pair<std::string, Material>> materials_;
917
919 std::vector<int> triangle_material_ids_;
921 std::vector<Image> textures_;
922};
923
924} // namespace geometry
925} // namespace open3d
#define OPEN3D_ASSERT(...)
Definition Macro.h:58
std::vector< int > indices
Definition PointCloudSmoothing.cpp:133
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
Definition BoundingVolume.h:285
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:33
std::vector< Eigen::Vector3d > vertices_
Vertex coordinates.
Definition MeshBase.h:158
MeshBase & NormalizeNormals()
Normalize vertex normals to length 1.
Definition MeshBase.h:127
DeformAsRigidAsPossibleEnergy
Definition MeshBase.h:58
SimplificationContraction
Indicates the method that is used for mesh simplification if multiple vertices are combined to a sing...
Definition MeshBase.h:43
FilterScope
Indicates the scope of filter operations.
Definition MeshBase.h:52
A bounding box oriented along an arbitrary frame of reference.
Definition BoundingVolume.h:138
Definition BoundingVolume.h:20
A point cloud consists of point coordinates, and optionally point colors and point normals.
Definition PointCloud.h:36
Tetra mesh contains vertices and tetrahedra represented by the indices to the vertices.
Definition TetraMesh.h:29
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition TriangleMesh.h:57
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:51
bool IsBoundingBoxIntersecting(const TriangleMesh &other) const
Definition TriangleMesh.cpp:1456
TriangleMesh(Geometry::GeometryType type)
Definition TriangleMesh.h:809
TriangleMesh & RemoveNonManifoldEdges()
Function that removes all non-manifold edges, by successively deleting triangles with the smallest su...
Definition TriangleMesh.cpp:865
std::vector< Image > textures_
Textures of the image.
Definition TriangleMesh.h:921
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:1189
std::vector< std::pair< std::string, Material > > materials_
Definition TriangleMesh.h:916
std::shared_ptr< TriangleMesh > SubdivideMidpoint(int number_of_iterations) const
Definition TriangleMeshSubdivide.cpp:18
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:1488
double GetVolume() const
Definition TriangleMesh.cpp:1228
std::shared_ptr< TriangleMesh > SubdivideLoop(int number_of_iterations) const
Definition TriangleMeshSubdivide.cpp:99
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:58
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.
Definition TriangleMesh.cpp:375
std::shared_ptr< PointCloud > SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false)
Definition TriangleMesh.cpp:525
std::vector< Eigen::Vector2i > GetSelfIntersectingTriangles() const
Definition TriangleMesh.cpp:1396
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:542
bool IsVertexManifold() const
Definition TriangleMesh.cpp:1392
TriangleMesh & RemoveDuplicatedVertices()
Function that removes duplicated vertices, i.e., vertices that have identical coordinates.
Definition TriangleMesh.cpp:693
std::vector< std::unordered_set< int > > adjacency_list_
Definition TriangleMesh.h:836
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:1041
bool IsEdgeManifold(bool allow_boundary_edges=true) const
Definition TriangleMesh.cpp:1321
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:1558
static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Definition TriangleMesh.cpp:1266
bool HasTriangles() const
Returns true if the mesh contains triangles.
Definition TriangleMesh.h:83
TriangleMesh & ComputeVertexNormals(bool normalized=true)
Function to compute vertex normals, usually called before rendering.
Definition TriangleMesh.cpp:138
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:1609
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:780
static std::shared_ptr< TriangleMesh > CreateEllipsoid(double radius_x=1.0, double radius_y=1.0, double radius_z=1.0, int resolution=20, bool create_uv_map=false)
Definition TriangleMeshFactory.cpp:398
virtual TriangleMesh & Clear() override
Clear all elements in the geometry.
Definition TriangleMesh.cpp:32
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:945
static Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1)
Helper function to get an edge with ordered vertex indices.
Definition TriangleMesh.h:359
std::shared_ptr< PointCloud > SamplePointsUniformlyImpl(size_t number_of_points, const std::vector< double > &triangle_areas, bool use_triangle_normal)
Definition TriangleMesh.cpp:448
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:1292
std::shared_ptr< TriangleMesh > SelectByIndex(const std::vector< size_t > &indices, bool cleanup=true) const
Definition TriangleMesh.cpp:1673
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToTrianglesMap() const
Definition TriangleMesh.cpp:1154
bool HasTriangleMaterialIds() const
Definition TriangleMesh.h:112
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:1626
static std::shared_ptr< TriangleMesh > CreateFromPointCloudBallPivoting(const PointCloud &pcd, const std::vector< double > &radii)
Definition SurfaceReconstructionBallPivoting.cpp:740
std::vector< Eigen::Vector2d > triangle_uvs_
List of uv coordinates per triangle.
Definition TriangleMesh.h:838
~TriangleMesh() override
Definition TriangleMesh.h:69
virtual TriangleMesh & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition TriangleMesh.cpp:45
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:1135
std::vector< Eigen::Vector3i > triangles_
List of triangles denoted by the index of points forming the triangle.
Definition TriangleMesh.h:831
bool HasTextures() const
Returns true if the mesh has texture.
Definition TriangleMesh.h:103
bool OrientTriangles()
Definition TriangleMesh.cpp:1144
bool HasTriangleUvs() const
Definition TriangleMesh.h:98
std::shared_ptr< TriangleMesh > Crop(const AxisAlignedBoundingBox &bbox) const
Definition TriangleMesh.cpp:1739
std::vector< Eigen::Vector3d > triangle_normals_
Triangle normals.
Definition TriangleMesh.h:833
static std::shared_ptr< TriangleMesh > CreateOctahedron(double radius=1.0, bool create_uv_map=false)
Definition TriangleMeshFactory.cpp:52
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, int full_depth=5, float samples_per_node=1.5f, float point_weight=2.0f)
Function that computes a triangle mesh from an oriented PointCloud pcd. This implements the Screened ...
Definition SurfaceReconstructionPoisson.cpp:698
TriangleMesh & RemoveDuplicatedTriangles()
Function that removes duplicated triangles, i.e., removes triangles that reference the same three ver...
Definition TriangleMesh.cpp:738
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:1307
TriangleMesh & RemoveDegenerateTriangles()
Function that removes degenerate triangles, i.e., triangles that reference a single vertex multiple t...
Definition TriangleMesh.cpp:835
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:21
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:959
TriangleMesh & RemoveUnreferencedVertices()
This function removes vertices from the triangle mesh that are not referenced in any triangle of the ...
Definition TriangleMesh.cpp:790
std::shared_ptr< TriangleMesh > SimplifyQuadricDecimation(int target_number_of_triangles, double maximum_error, double boundary_weight) const
Definition TriangleMeshSimplification.cpp:252
bool HasTriangleNormals() const
Returns true if the mesh contains triangle normals.
Definition TriangleMesh.h:88
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:624
static std::shared_ptr< TriangleMesh > CreateFromOrientedBoundingEllipsoid(const OrientedBoundingEllipsoid &obel, const Eigen::Vector3d &scale=Eigen::Vector3d::Ones(), int resolution=20, bool create_uv_map=false)
Definition TriangleMeshFactory.cpp:153
bool IsWatertight() const
Definition TriangleMesh.cpp:1140
bool HasAdjacencyList() const
Returns true if the mesh contains adjacency normals.
Definition TriangleMesh.h:93
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:1763
bool IsIntersecting(const TriangleMesh &other) const
Definition TriangleMesh.cpp:1461
double GetTriangleArea(size_t triangle_idx) const
Definition TriangleMesh.cpp:1198
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:907
TriangleMesh & ComputeAdjacencyList()
Function to compute adjacency list, call before adjacency list is needed.
Definition TriangleMesh.cpp:157
TriangleMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector3i > &triangles)
Parameterized Constructor.
Definition TriangleMesh.h:65
static Eigen::Vector3i GetOrderedTriangle(int vidx0, int vidx1, int vidx2)
Definition TriangleMesh.h:318
TriangleMesh & NormalizeNormals()
Normalize both triangle normals and vertex normals to length 1.
Definition TriangleMesh.h:118
std::shared_ptr< TriangleMesh > FilterSharpen(int number_of_iterations, double strength, FilterScope scope=FilterScope::All) const
Function to sharpen triangle mesh.
Definition TriangleMesh.cpp:173
std::vector< int > triangle_material_ids_
List of material ids.
Definition TriangleMesh.h:919
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToVerticesMap() const
Definition TriangleMesh.cpp:1173
Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const
Definition TriangleMesh.cpp:1282
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:244
TriangleMesh operator+(const TriangleMesh &mesh) const
Definition TriangleMesh.cpp:117
TriangleMesh()
Default Constructor.
Definition TriangleMesh.h:60
bool IsSelfIntersecting() const
Definition TriangleMesh.cpp:1452
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:169
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:310
TriangleMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
Definition TriangleMesh.cpp:121
double GetSurfaceArea() const
Definition TriangleMesh.cpp:1208
std::vector< int > GetNonManifoldVertices() const
Definition TriangleMesh.cpp:1334
void RemoveTrianglesByMask(const std::vector< bool > &triangle_mask)
This function removes the triangles that are masked in triangle_mask. Call RemoveUnreferencedVertices...
Definition TriangleMesh.cpp:1575
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:1002
static std::shared_ptr< TriangleMesh > CreateSphere(double radius=1.0, int resolution=20, bool create_uv_map=false)
Definition TriangleMeshFactory.cpp:231
bool HasMaterials() const
Definition TriangleMesh.h:110
int width
Definition FilePCD.cpp:53
int size
Definition FilePCD.cpp:41
int height
Definition FilePCD.cpp:54
char type
Definition FilePCD.cpp:42
void AssertTriangleIndicesInRange(const Eigen::Vector3i &triangle, int64_t vertex_count)
Definition TriangleMesh.h:30
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:1371
float b() const
Definition TriangleMesh.h:890
float g() const
Definition TriangleMesh.h:889
float r() const
Definition TriangleMesh.h:888
MaterialParameter(const float v1, const float v2, const float v3, const float v4)
Definition TriangleMesh.h:851
static MaterialParameter CreateRGB(const float r, const float g, const float b)
Definition TriangleMesh.h:882
MaterialParameter(const float v1, const float v2, const float v3)
Definition TriangleMesh.h:861
MaterialParameter(const float v1, const float v2)
Definition TriangleMesh.h:868
MaterialParameter(const float v1)
Definition TriangleMesh.h:875
float a() const
Definition TriangleMesh.h:891
Definition TriangleMesh.h:840
std::shared_ptr< Image > anisotropy
Definition TriangleMesh.h:910
std::shared_ptr< Image > normalMap
Definition TriangleMesh.h:903
std::shared_ptr< Image > clearCoatRoughness
Definition TriangleMesh.h:909
std::shared_ptr< Image > roughness
Definition TriangleMesh.h:906
float baseAnisotropy
Definition TriangleMesh.h:900
std::unordered_map< std::string, Image > additionalMaps
Definition TriangleMesh.h:913
float baseClearCoat
Definition TriangleMesh.h:898
float baseRoughness
Definition TriangleMesh.h:896
std::unordered_map< std::string, MaterialParameter > floatParameters
Definition TriangleMesh.h:912
std::shared_ptr< Image > reflectance
Definition TriangleMesh.h:907
MaterialParameter baseColor
Definition TriangleMesh.h:894
std::shared_ptr< Image > metallic
Definition TriangleMesh.h:905
std::shared_ptr< Image > ambientOcclusion
Definition TriangleMesh.h:904
std::shared_ptr< Image > albedo
Definition TriangleMesh.h:902
float baseReflectance
Definition TriangleMesh.h:897
float baseMetallic
Definition TriangleMesh.h:895
std::shared_ptr< Image > clearCoat
Definition TriangleMesh.h:908
float baseClearCoatRoughness
Definition TriangleMesh.h:899
Definition Helper.h:71