Open3D (C++ API)  0.20.0
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 <memory>
12#include <numeric>
13#include <tuple>
14#include <unordered_map>
15#include <unordered_set>
16#include <vector>
17
21
22namespace open3d {
23namespace geometry {
24
25class PointCloud;
26class TetraMesh;
27
35class TriangleMesh : public MeshBase {
36public:
43 TriangleMesh(const std::vector<Eigen::Vector3d> &vertices,
44 const std::vector<Eigen::Vector3i> &triangles)
46 triangles_(triangles) {}
47 ~TriangleMesh() override {}
48
49public:
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
56public:
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
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
192 std::shared_ptr<TriangleMesh> FilterSmoothLaplacian(
193 int number_of_iterations,
194 double lambda_filter,
195 FilterScope scope = FilterScope::All) const;
196
209 std::shared_ptr<TriangleMesh> FilterSmoothTaubin(
210 int number_of_iterations,
211 double lambda_filter = 0.5,
212 double mu = -0.53,
213 FilterScope scope = FilterScope::All) const;
214
218 int EulerPoincareCharacteristic() const;
219
223 std::vector<Eigen::Vector2i> GetNonManifoldEdges(
224 bool allow_boundary_edges = true) const;
225
230 bool IsEdgeManifold(bool allow_boundary_edges = true) const;
231
235 std::vector<int> GetNonManifoldVertices() const;
236
240 bool IsVertexManifold() const;
241
244 std::vector<Eigen::Vector2i> GetSelfIntersectingTriangles() const;
245
248 bool IsSelfIntersecting() const;
249
252 bool IsBoundingBoxIntersecting(const TriangleMesh &other) const;
253
256 bool IsIntersecting(const TriangleMesh &other) const;
257
261 bool IsOrientable() const;
262
266 bool IsWatertight() const;
267
271 bool OrientTriangles();
272
275 std::unordered_map<Eigen::Vector2i,
276 std::vector<int>,
278 GetEdgeToTrianglesMap() const;
279
282 std::unordered_map<Eigen::Vector2i,
283 std::vector<int>,
285 GetEdgeToVerticesMap() const;
286
288 static double ComputeTriangleArea(const Eigen::Vector3d &p0,
289 const Eigen::Vector3d &p1,
290 const Eigen::Vector3d &p2);
291
294 double GetTriangleArea(size_t triangle_idx) const;
295
296 static inline Eigen::Vector3i GetOrderedTriangle(int vidx0,
297 int vidx1,
298 int vidx2) {
299 if (vidx0 > vidx2) {
300 std::swap(vidx0, vidx2);
301 }
302 if (vidx0 > vidx1) {
303 std::swap(vidx0, vidx1);
304 }
305 if (vidx1 > vidx2) {
306 std::swap(vidx1, vidx2);
307 }
308 return Eigen::Vector3i(vidx0, vidx1, vidx2);
309 }
310
313 double GetSurfaceArea() const;
314
317 double GetSurfaceArea(std::vector<double> &triangle_areas) const;
318
323 double GetVolume() const;
324
328 static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0,
329 const Eigen::Vector3d &p1,
330 const Eigen::Vector3d &p2);
331
334 Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const;
335
337 static inline Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1) {
338 return Eigen::Vector2i(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
339 }
340
343 std::shared_ptr<PointCloud> SamplePointsUniformlyImpl(
344 size_t number_of_points,
345 const std::vector<double> &triangle_areas,
346 bool use_triangle_normal);
347
354 std::shared_ptr<PointCloud> SamplePointsUniformly(
355 size_t number_of_points, bool use_triangle_normal = false);
356
369 std::shared_ptr<PointCloud> SamplePointsPoissonDisk(
370 size_t number_of_points,
371 double init_factor = 5,
372 const std::shared_ptr<PointCloud> pcl_init = nullptr,
373 bool use_triangle_normal = false);
374
380 std::shared_ptr<TriangleMesh> SubdivideMidpoint(
381 int number_of_iterations) const;
382
388 std::shared_ptr<TriangleMesh> SubdivideLoop(int number_of_iterations) const;
389
396 std::shared_ptr<TriangleMesh> SimplifyVertexClustering(
397 double voxel_size,
398 SimplificationContraction contraction =
400
410 std::shared_ptr<TriangleMesh> SimplifyQuadricDecimation(
411 int target_number_of_triangles,
412 double maximum_error,
413 double boundary_weight) const;
414
424 std::shared_ptr<TriangleMesh> SelectByIndex(
425 const std::vector<size_t> &indices, bool cleanup = true) const;
426
431 std::shared_ptr<TriangleMesh> Crop(
432 const AxisAlignedBoundingBox &bbox) const;
433
438 std::shared_ptr<TriangleMesh> Crop(const OrientedBoundingBox &bbox) const;
439
446 std::tuple<std::vector<int>, std::vector<size_t>, std::vector<double>>
448
455 void RemoveTrianglesByIndex(const std::vector<size_t> &triangle_indices);
456
463 void RemoveTrianglesByMask(const std::vector<bool> &triangle_mask);
464
471 void RemoveVerticesByIndex(const std::vector<size_t> &vertex_indices);
472
479 void RemoveVerticesByMask(const std::vector<bool> &vertex_mask);
480
494 std::shared_ptr<TriangleMesh> DeformAsRigidAsPossible(
495 const std::vector<int> &constraint_vertex_indices,
496 const std::vector<Eigen::Vector3d> &constraint_vertex_positions,
497 size_t max_iter,
500 double smoothed_alpha = 0.01) const;
501
513 static std::shared_ptr<TriangleMesh> CreateFromPointCloudAlphaShape(
514 const PointCloud &pcd,
515 double alpha,
516 std::shared_ptr<TetraMesh> tetra_mesh = nullptr,
517 std::vector<size_t> *pt_map = nullptr);
518
532 static std::shared_ptr<TriangleMesh> CreateFromPointCloudBallPivoting(
533 const PointCloud &pcd, const std::vector<double> &radii);
534
573 static std::tuple<std::shared_ptr<TriangleMesh>, std::vector<double>>
575 size_t depth = 8,
576 float width = 0.0f,
577 float scale = 1.1f,
578 bool linear_fit = false,
579 int n_threads = -1,
580 int full_depth = 5,
581 float samples_per_node = 1.5f,
582 float point_weight = 2.0f);
583
589 static std::shared_ptr<TriangleMesh> CreateTetrahedron(
590 double radius = 1.0, bool create_uv_map = false);
591
597 static std::shared_ptr<TriangleMesh> CreateOctahedron(
598 double radius = 1.0, bool create_uv_map = false);
599
604 static std::shared_ptr<TriangleMesh> CreateIcosahedron(
605 double radius = 1.0, bool create_uv_map = false);
606
611 static std::shared_ptr<TriangleMesh> CreateFromOrientedBoundingBox(
612 const OrientedBoundingBox &obox,
613 const Eigen::Vector3d &scale = Eigen::Vector3d::Ones(),
614 bool create_uv_map = false);
615
622 static std::shared_ptr<TriangleMesh> CreateFromOrientedBoundingEllipsoid(
623 const OrientedBoundingEllipsoid &obel,
624 const Eigen::Vector3d &scale = Eigen::Vector3d::Ones(),
625 int resolution = 20,
626 bool create_uv_map = false);
627
636 static std::shared_ptr<TriangleMesh> CreateBox(
637 double width = 1.0,
638 double height = 1.0,
639 double depth = 1.0,
640 bool create_uv_map = false,
641 bool map_texture_to_each_face = false);
642
653 static std::shared_ptr<TriangleMesh> CreateSphere(
654 double radius = 1.0,
655 int resolution = 20,
656 bool create_uv_map = false);
657
665 static std::shared_ptr<TriangleMesh> CreateEllipsoid(
666 double radius_x = 1.0,
667 double radius_y = 1.0,
668 double radius_z = 1.0,
669 int resolution = 20,
670 bool create_uv_map = false);
671
683 static std::shared_ptr<TriangleMesh> CreateCylinder(
684 double radius = 1.0,
685 double height = 2.0,
686 int resolution = 20,
687 int split = 4,
688 bool create_uv_map = false);
689
700 static std::shared_ptr<TriangleMesh> CreateCone(double radius = 1.0,
701 double height = 2.0,
702 int resolution = 20,
703 int split = 1,
704 bool create_uv_map = false);
705
719 static std::shared_ptr<TriangleMesh> CreateTorus(
720 double torus_radius = 1.0,
721 double tube_radius = 0.5,
722 int radial_resolution = 30,
723 int tubular_resolution = 20);
724
735 //
749 static std::shared_ptr<TriangleMesh> CreateArrow(
750 double cylinder_radius = 1.0,
751 double cone_radius = 1.5,
752 double cylinder_height = 5.0,
753 double cone_height = 4.0,
754 int resolution = 20,
755 int cylinder_split = 4,
756 int cone_split = 1);
757
763 static std::shared_ptr<TriangleMesh> CreateCoordinateFrame(
764 double size = 1.0,
765 const Eigen::Vector3d &origin = Eigen::Vector3d(0.0, 0.0, 0.0));
766
777 static std::shared_ptr<TriangleMesh> CreateMobius(int length_split = 70,
778 int width_split = 15,
779 int twists = 1,
780 double radius = 1,
781 double flatness = 1,
782 double width = 1,
783 double scale = 1);
784
785protected:
786 // Forward child class type to avoid indirect nonvirtual base
788
797 std::unordered_map<Eigen::Vector2i,
798 double,
801 const std::unordered_map<Eigen::Vector2i,
802 std::vector<int>,
804 &edges_to_vertices,
805 double min_weight = std::numeric_limits<double>::lowest()) const;
806
807public:
809 std::vector<Eigen::Vector3i> triangles_;
811 std::vector<Eigen::Vector3d> triangle_normals_;
814 std::vector<std::unordered_set<int>> adjacency_list_;
816 std::vector<Eigen::Vector2d> triangle_uvs_;
817
818 struct Material {
820 float f4[4] = {0};
821
823 f4[0] = 0;
824 f4[1] = 0;
825 f4[2] = 0;
826 f4[3] = 0;
827 }
828
829 MaterialParameter(const float v1,
830 const float v2,
831 const float v3,
832 const float v4) {
833 f4[0] = v1;
834 f4[1] = v2;
835 f4[2] = v3;
836 f4[3] = v4;
837 }
838
839 MaterialParameter(const float v1, const float v2, const float v3) {
840 f4[0] = v1;
841 f4[1] = v2;
842 f4[2] = v3;
843 f4[3] = 1;
844 }
845
846 MaterialParameter(const float v1, const float v2) {
847 f4[0] = v1;
848 f4[1] = v2;
849 f4[2] = 0;
850 f4[3] = 0;
851 }
852
853 explicit MaterialParameter(const float v1) {
854 f4[0] = v1;
855 f4[1] = 0;
856 f4[2] = 0;
857 f4[3] = 0;
858 }
859
860 static MaterialParameter CreateRGB(const float r,
861 const float g,
862 const float b) {
863 return {r, g, b, 1.f};
864 }
865
866 float r() const { return f4[0]; }
867 float g() const { return f4[1]; }
868 float b() const { return f4[2]; }
869 float a() const { return f4[3]; }
870 };
871
873 float baseMetallic = 0.f;
874 float baseRoughness = 1.f;
875 float baseReflectance = 0.5f;
876 float baseClearCoat = 0.f;
878 float baseAnisotropy = 0.f;
879
880 std::shared_ptr<Image> albedo;
881 std::shared_ptr<Image> normalMap;
882 std::shared_ptr<Image> ambientOcclusion;
883 std::shared_ptr<Image> metallic;
884 std::shared_ptr<Image> roughness;
885 std::shared_ptr<Image> reflectance;
886 std::shared_ptr<Image> clearCoat;
887 std::shared_ptr<Image> clearCoatRoughness;
888 std::shared_ptr<Image> anisotropy;
889
890 std::unordered_map<std::string, MaterialParameter> floatParameters;
891 std::unordered_map<std::string, Image> additionalMaps;
892 };
893
894 std::vector<std::pair<std::string, Material>> materials_;
895
897 std::vector<int> triangle_material_ids_;
899 std::vector<Image> textures_;
900};
901
902} // namespace geometry
903} // namespace open3d
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
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:51
bool IsBoundingBoxIntersecting(const TriangleMesh &other) const
Definition TriangleMesh.cpp:1432
TriangleMesh(Geometry::GeometryType type)
Definition TriangleMesh.h:787
TriangleMesh & RemoveNonManifoldEdges()
Function that removes all non-manifold edges, by successively deleting triangles with the smallest su...
Definition TriangleMesh.cpp:853
std::vector< Image > textures_
Textures of the image.
Definition TriangleMesh.h:899
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:1175
std::vector< std::pair< std::string, Material > > materials_
Definition TriangleMesh.h:894
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:1460
double GetVolume() const
Definition TriangleMesh.cpp:1212
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: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:369
std::shared_ptr< PointCloud > SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false)
Definition TriangleMesh.cpp:517
std::vector< Eigen::Vector2i > GetSelfIntersectingTriangles() const
Definition TriangleMesh.cpp:1374
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:534
bool IsVertexManifold() const
Definition TriangleMesh.cpp:1370
TriangleMesh & RemoveDuplicatedVertices()
Function that removes duplicated vertices, i.e., vertices that have identical coordinates.
Definition TriangleMesh.cpp:685
std::vector< std::unordered_set< int > > adjacency_list_
Definition TriangleMesh.h:814
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:1301
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:1530
static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Definition TriangleMesh.cpp:1248
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:136
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:1581
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:933
static Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1)
Helper function to get an edge with ordered vertex indices.
Definition TriangleMesh.h:337
std::shared_ptr< PointCloud > SamplePointsUniformlyImpl(size_t number_of_points, const std::vector< double > &triangle_areas, bool use_triangle_normal)
Definition TriangleMesh.cpp:442
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:1272
std::shared_ptr< TriangleMesh > SelectByIndex(const std::vector< size_t > &indices, bool cleanup=true) const
Definition TriangleMesh.cpp:1642
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToTrianglesMap() const
Definition TriangleMesh.cpp:1140
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:1598
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:816
~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: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:1121
std::vector< Eigen::Vector3i > triangles_
List of triangles denoted by the index of points forming the triangle.
Definition TriangleMesh.h:809
bool HasTextures() const
Returns true if the mesh has texture.
Definition TriangleMesh.h:81
bool OrientTriangles()
Definition TriangleMesh.cpp:1130
bool HasTriangleUvs() const
Definition TriangleMesh.h:76
std::shared_ptr< TriangleMesh > Crop(const AxisAlignedBoundingBox &bbox) const
Definition TriangleMesh.cpp:1708
std::vector< Eigen::Vector3d > triangle_normals_
Triangle normals.
Definition TriangleMesh.h:811
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:728
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:1287
TriangleMesh & RemoveDegenerateTriangles()
Function that removes degenerate triangles, i.e., triangles that reference a single vertex multiple t...
Definition TriangleMesh.cpp:823
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:780
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: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:1126
bool HasAdjacencyList() const
Returns true if the mesh contains adjacency normals.
Definition TriangleMesh.h:71
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:1732
bool IsIntersecting(const TriangleMesh &other) const
Definition TriangleMesh.cpp:1437
double GetTriangleArea(size_t triangle_idx) const
Definition TriangleMesh.cpp:1184
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:153
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:296
TriangleMesh & NormalizeNormals()
Normalize both triangle normals and vertex normals to length 1.
Definition TriangleMesh.h:96
std::shared_ptr< TriangleMesh > FilterSharpen(int number_of_iterations, double strength, FilterScope scope=FilterScope::All) const
Function to sharpen triangle mesh.
Definition TriangleMesh.cpp:167
std::vector< int > triangle_material_ids_
List of material ids.
Definition TriangleMesh.h:897
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen< Eigen::Vector2i > > GetEdgeToVerticesMap() const
Definition TriangleMesh.cpp:1159
Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const
Definition TriangleMesh.cpp:1264
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:238
TriangleMesh operator+(const TriangleMesh &mesh) const
Definition TriangleMesh.cpp:117
TriangleMesh()
Default Constructor.
Definition TriangleMesh.h:38
bool IsSelfIntersecting() const
Definition TriangleMesh.cpp:1428
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:304
TriangleMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
Definition TriangleMesh.cpp:121
double GetSurfaceArea() const
Definition TriangleMesh.cpp:1192
std::vector< int > GetNonManifoldVertices() const
Definition TriangleMesh.cpp:1314
void RemoveTrianglesByMask(const std::vector< bool > &triangle_mask)
This function removes the triangles that are masked in triangle_mask. Call RemoveUnreferencedVertices...
Definition TriangleMesh.cpp:1547
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:88
int width
Definition FilePCD.cpp:53
int size
Definition FilePCD.cpp:41
int height
Definition FilePCD.cpp:54
char type
Definition FilePCD.cpp:42
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:868
float g() const
Definition TriangleMesh.h:867
float r() const
Definition TriangleMesh.h:866
MaterialParameter(const float v1, const float v2, const float v3, const float v4)
Definition TriangleMesh.h:829
static MaterialParameter CreateRGB(const float r, const float g, const float b)
Definition TriangleMesh.h:860
MaterialParameter(const float v1, const float v2, const float v3)
Definition TriangleMesh.h:839
MaterialParameter(const float v1, const float v2)
Definition TriangleMesh.h:846
MaterialParameter(const float v1)
Definition TriangleMesh.h:853
float a() const
Definition TriangleMesh.h:869
Definition TriangleMesh.h:818
std::shared_ptr< Image > anisotropy
Definition TriangleMesh.h:888
std::shared_ptr< Image > normalMap
Definition TriangleMesh.h:881
std::shared_ptr< Image > clearCoatRoughness
Definition TriangleMesh.h:887
std::shared_ptr< Image > roughness
Definition TriangleMesh.h:884
float baseAnisotropy
Definition TriangleMesh.h:878
std::unordered_map< std::string, Image > additionalMaps
Definition TriangleMesh.h:891
float baseClearCoat
Definition TriangleMesh.h:876
float baseRoughness
Definition TriangleMesh.h:874
std::unordered_map< std::string, MaterialParameter > floatParameters
Definition TriangleMesh.h:890
std::shared_ptr< Image > reflectance
Definition TriangleMesh.h:885
MaterialParameter baseColor
Definition TriangleMesh.h:872
std::shared_ptr< Image > metallic
Definition TriangleMesh.h:883
std::shared_ptr< Image > ambientOcclusion
Definition TriangleMesh.h:882
std::shared_ptr< Image > albedo
Definition TriangleMesh.h:880
float baseReflectance
Definition TriangleMesh.h:875
float baseMetallic
Definition TriangleMesh.h:873
std::shared_ptr< Image > clearCoat
Definition TriangleMesh.h:886
float baseClearCoatRoughness
Definition TriangleMesh.h:877
Definition Helper.h:71