33 #include <unordered_map> 34 #include <unordered_set> 63 const std::vector<Eigen::Vector3i> &triangles)
71 const Eigen::Matrix4d &transformation)
override;
73 const Eigen::Vector3d ¢er)
override;
101 bool is_all_texture_valid = std::accumulate(
103 [](
bool a,
const Image &b) {
return a && !b.IsEmpty(); });
104 return !
textures_.empty() && is_all_texture_valid;
181 int number_of_iterations,
194 int number_of_iterations,
209 int number_of_iterations,
224 int number_of_iterations,
238 bool allow_boundary_edges =
true)
const;
289 std::unordered_map<Eigen::Vector2i,
296 std::unordered_map<Eigen::Vector2i,
303 const Eigen::Vector3d &p1,
304 const Eigen::Vector3d &p2);
314 std::swap(vidx0, vidx2);
317 std::swap(vidx0, vidx1);
320 std::swap(vidx1, vidx2);
322 return Eigen::Vector3i(vidx0, vidx1, vidx2);
337 const Eigen::Vector3d &p1,
338 const Eigen::Vector3d &p2);
346 return Eigen::Vector2i(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
352 size_t number_of_points,
353 std::vector<double> &triangle_areas,
355 bool use_triangle_normal,
365 size_t number_of_points,
366 bool use_triangle_normal =
false,
381 size_t number_of_points,
382 double init_factor = 5,
383 const std::shared_ptr<PointCloud> pcl_init =
nullptr,
384 bool use_triangle_normal =
false,
393 int number_of_iterations)
const;
400 std::shared_ptr<TriangleMesh>
SubdivideLoop(
int number_of_iterations)
const;
419 int target_number_of_triangles)
const;
426 const std::vector<size_t> &indices)
const;
432 std::shared_ptr<TriangleMesh>
Crop(
447 std::tuple<std::vector<int>, std::vector<size_t>, std::vector<double>>
496 const std::vector<int> &constraint_vertex_indices,
497 const std::vector<Eigen::Vector3d> &constraint_vertex_positions,
501 double smoothed_alpha = 0.01)
const;
517 std::shared_ptr<TetraMesh> tetra_mesh =
nullptr,
518 std::vector<size_t> *pt_map =
nullptr);
534 const PointCloud &pcd,
const std::vector<double> &radii);
557 static std::tuple<std::shared_ptr<TriangleMesh>, std::vector<double>>
562 bool linear_fit =
false);
586 static std::shared_ptr<TriangleMesh>
CreateBox(
double width = 1.0,
599 static std::shared_ptr<TriangleMesh>
CreateSphere(
double radius = 1.0,
600 int resolution = 20);
612 static std::shared_ptr<TriangleMesh>
CreateCylinder(
double radius = 1.0,
626 static std::shared_ptr<TriangleMesh>
CreateCone(
double radius = 1.0,
642 double torus_radius = 1.0,
643 double tube_radius = 0.5,
644 int radial_resolution = 30,
645 int tubular_resolution = 20);
668 double cylinder_radius = 1.0,
669 double cone_radius = 1.5,
670 double cylinder_height = 5.0,
671 double cone_height = 4.0,
673 int cylinder_split = 4,
683 const Eigen::Vector3d &
origin = Eigen::Vector3d(0.0, 0.0, 0.0));
694 static std::shared_ptr<TriangleMesh>
CreateMoebius(
int length_split = 70,
695 int width_split = 15,
707 std::shared_ptr<TriangleMesh> &mesh,
708 const std::vector<Eigen::Vector3d> &prev_vertices,
709 const std::vector<Eigen::Vector3d> &prev_vertex_normals,
710 const std::vector<Eigen::Vector3d> &prev_vertex_colors,
711 const std::vector<std::unordered_set<int>> &adjacency_list,
715 bool filter_color)
const;
725 std::unordered_map<Eigen::Vector2i,
729 const std::unordered_map<Eigen::Vector2i,
733 double min_weight = std::numeric_limits<double>::lowest())
const;
799 return {
r,
g,
b, 1.f};
float g
Definition: TriangleMesh.h:755
std::shared_ptr< Image > anisotropy
Definition: TriangleMesh.h:819
float baseRoughness
Definition: TriangleMesh.h:805
static std::shared_ptr< TriangleMesh > CreateFromPointCloudBallPivoting(const PointCloud &pcd, const std::vector< double > &radii)
Definition: SurfaceReconstructionBallPivoting.cpp:750
bool HasTriangleMaterialIds() const
Definition: TriangleMesh.h:109
bool IsSelfIntersecting() const
Definition: TriangleMesh.cpp:1350
std::shared_ptr< PointCloud > SamplePointsUniformlyImpl(size_t number_of_points, std::vector< double > &triangle_areas, double surface_area, bool use_triangle_normal, int seed)
Definition: TriangleMesh.cpp:432
float f3[3]
Definition: TriangleMesh.h:750
std::vector< Eigen::Vector3i > triangles_
List of triangles denoted by the index of points forming the triangle.
Definition: TriangleMesh.h:737
bool HasMaterials() const
Definition: TriangleMesh.h:107
TriangleMesh & RemoveDuplicatedTriangles()
Function that removes duplicated triangles, i.e., removes triangles that reference the same three ver...
Definition: TriangleMesh.cpp:710
bool IsOrientable() const
Definition: TriangleMesh.cpp:1100
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:1489
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:1506
float baseClearCoatRoughness
Definition: TriangleMesh.h:808
std::shared_ptr< TriangleMesh > SubdivideLoop(int number_of_iterations) const
Definition: TriangleMeshSubdivide.cpp:116
MaterialParameter baseColor
Definition: TriangleMesh.h:803
float baseClearCoat
Definition: TriangleMesh.h:807
The base geometry class.
Definition: Geometry.h:37
std::vector< int > GetNonManifoldVertices() const
Definition: TriangleMesh.cpp:1258
MaterialParameter(const float v1, const float v2, const float v3, const float v4)
Definition: TriangleMesh.h:765
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:229
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:915
float z
Definition: TriangleMesh.h:754
static std::shared_ptr< TriangleMesh > CreateMoebius(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:441
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:164
std::shared_ptr< Image > roughness
Definition: TriangleMesh.h:815
bool HasTextures() const
Returns true if the mesh has texture.
Definition: TriangleMesh.h:100
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen::hash< Eigen::Vector2i > > GetEdgeToTrianglesMap() const
Definition: TriangleMesh.cpp:1119
std::shared_ptr< Image > normalMap
Definition: TriangleMesh.h:812
bool IsBoundingBoxIntersecting(const TriangleMesh &other) const
Definition: TriangleMesh.cpp:1354
TriangleMesh()
Default Constructor.
Definition: TriangleMesh.h:57
Definition: TriangleMesh.h:746
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:1449
std::shared_ptr< TriangleMesh > FilterSharpen(int number_of_iterations, double strength, FilterScope scope=FilterScope::All) const
Function to sharpen triangle mesh.
Definition: TriangleMesh.cpp:158
MeshBash Class.
Definition: MeshBase.h:51
MeshBase & NormalizeNormals()
Normalize vertex normals to length 1.
Definition: MeshBase.h:117
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:44
float w
Definition: TriangleMesh.h:754
std::unordered_map< std::string, MaterialParameter > floatParameters
Definition: TriangleMesh.h:821
A point cloud consists of point coordinates, and optionally point colors and point normals...
Definition: PointCloud.h:54
bool IsEdgeManifold(bool allow_boundary_edges=true) const
Definition: TriangleMesh.cpp:1245
TriangleMesh & ComputeVertexNormals(bool normalized=true)
Function to compute vertex normals, usually called before rendering.
Definition: TriangleMesh.cpp:127
static std::shared_ptr< TriangleMesh > CreateSphere(double radius=1.0, int resolution=20)
Definition: TriangleMeshFactory.cpp:157
bool HasTriangleUvs() const
Definition: TriangleMesh.h:95
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:1154
static Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1)
Helper function to get an edge with ordered vertex indices.
Definition: TriangleMesh.h:345
static std::shared_ptr< TriangleMesh > CreateBox(double width=1.0, double height=1.0, double depth=1.0)
Definition: TriangleMeshFactory.cpp:120
Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const
Definition: TriangleMesh.cpp:1207
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:1382
float r
Definition: TriangleMesh.h:755
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:402
float f
Definition: TriangleMesh.h:752
std::vector< Eigen::Vector2i > GetSelfIntersectingTriangles() const
Definition: TriangleMesh.cpp:1318
TriangleMesh & operator+=(const TriangleMesh &mesh)
Definition: TriangleMesh.cpp:75
std::shared_ptr< TriangleMesh > FilterSmoothLaplacian(int number_of_iterations, double lambda, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh using Laplacian.
Definition: TriangleMesh.cpp:345
static std::tuple< std::shared_ptr< TriangleMesh >, std::vector< double > > CreateFromPointCloudPoisson(const PointCloud &pcd, size_t depth=8, size_t width=0, float scale=1.1f, bool linear_fit=false)
Function that computes a triangle mesh from a oriented PointCloud pcd. This implements the Screened P...
Definition: SurfaceReconstructionPoisson.cpp:729
float f4[4]
Definition: TriangleMesh.h:749
static std::shared_ptr< TriangleMesh > CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4)
Definition: TriangleMeshFactory.cpp:202
int size
Definition: FilePCD.cpp:57
float x
Definition: TriangleMesh.h:754
TriangleMesh & RemoveDegenerateTriangles()
Function that removes degenerate triangles, i.e., triangles that reference a single vertex multiple t...
Definition: TriangleMesh.cpp:805
std::unordered_map< std::string, Material > materials_
Definition: TriangleMesh.h:825
std::shared_ptr< TriangleMesh > Crop(const AxisAlignedBoundingBox &bbox) const
Definition: TriangleMesh.cpp:1635
static std::shared_ptr< TriangleMesh > CreateTetrahedron(double radius=1.0)
Definition: TriangleMeshFactory.cpp:33
bool IsVertexManifold() const
Definition: TriangleMesh.cpp:1314
double voxel_size
Definition: FilePLY.cpp:286
bool IsIntersecting(const TriangleMesh &other) const
Definition: TriangleMesh.cpp:1359
std::unordered_map< Eigen::Vector2i, double, utility::hash_eigen::hash< Eigen::Vector2i > > ComputeEdgeWeightsCot(const std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen::hash< 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:1659
TriangleMesh & ComputeAdjacencyList()
Function to compute adjacency list, call before adjacency list is needed.
Definition: TriangleMesh.cpp:144
MaterialParameter()
Definition: TriangleMesh.h:758
bool IsWatertight() const
Definition: TriangleMesh.cpp:1105
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:38
TriangleMesh & NormalizeNormals()
Normalize both triangle normals and vertex normals to length 1.
Definition: TriangleMesh.h:115
TriangleMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector3i > &triangles)
Parameterized Constructor.
Definition: TriangleMesh.h:62
virtual TriangleMesh & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ...
Definition: TriangleMesh.cpp:68
virtual TriangleMesh & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: TriangleMesh.cpp:62
FilterScope
Indicates the scope of filter operations.
Definition: MeshBase.h:70
SimplificationContraction
Indicates the method that is used for mesh simplification if multiple vertices are combined to a sing...
Definition: MeshBase.h:61
DeformAsRigidAsPossibleEnergy
Definition: MeshBase.h:76
virtual TriangleMesh & Clear() override
Clear all elements in the geometry.
Definition: TriangleMesh.cpp:49
std::vector< Image > textures_
Textures of the image.
Definition: TriangleMesh.h:830
std::shared_ptr< Image > albedo
Definition: TriangleMesh.h:811
std::unordered_map< Eigen::Vector2i, std::vector< int >, utility::hash_eigen::hash< Eigen::Vector2i > > GetEdgeToVerticesMap() const
Definition: TriangleMesh.cpp:1138
void RemoveTrianglesByMask(const std::vector< bool > &triangle_mask)
This function removes the triangles that are masked in triangle_mask. Call RemoveUnreferencedVertices...
Definition: TriangleMesh.cpp:1466
bool HasTriangles() const
Returns true if the mesh contains triangles.
Definition: TriangleMesh.h:80
TriangleMesh operator+(const TriangleMesh &mesh) const
Definition: TriangleMesh.cpp:108
static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Definition: TriangleMesh.cpp:1191
std::shared_ptr< Image > clearCoat
Definition: TriangleMesh.h:817
bool OrientTriangles()
Definition: TriangleMesh.cpp:1109
TriangleMesh & RemoveNonManifoldEdges()
Function that removes all non-manifold edges, by successively deleting triangles with the smallest su...
Definition: TriangleMesh.cpp:835
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:307
char type
Definition: FilePCD.cpp:58
std::shared_ptr< TriangleMesh > SubdivideMidpoint(int number_of_iterations) const
Definition: TriangleMeshSubdivide.cpp:38
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:41
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, bool filter_vertex, bool filter_normal, bool filter_color) const
Definition: TriangleMesh.cpp:295
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:359
bool HasAdjacencyList() const
Returns true if the mesh contains adjacency normals.
Definition: TriangleMesh.h:90
Eigen::Vector3d origin
Definition: FilePLY.cpp:285
std::shared_ptr< Image > ambientOcclusion
Definition: TriangleMesh.h:813
static std::shared_ptr< TriangleMesh > CreateOctahedron(double radius=1.0)
Definition: TriangleMeshFactory.cpp:55
Definition: Open3DViewer.h:29
double GetTriangleArea(size_t triangle_idx) const
Definition: TriangleMesh.cpp:1163
std::vector< Eigen::Vector2i > GetNonManifoldEdges(bool allow_boundary_edges=true) const
Definition: TriangleMesh.cpp:1231
std::shared_ptr< Image > reflectance
Definition: TriangleMesh.h:816
std::shared_ptr< PointCloud > SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false, int seed=-1)
Definition: TriangleMesh.cpp:500
Definition: TriangleMesh.h:747
float b
Definition: TriangleMesh.h:755
GeometryType
Specifies possible geometry types.
Definition: Geometry.h:42
~TriangleMesh() override
Definition: TriangleMesh.h:66
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, int seed=-1)
Definition: TriangleMesh.cpp:520
float y
Definition: TriangleMesh.h:754
std::unordered_map< std::string, Image > additionalMaps
Definition: TriangleMesh.h:822
static std::shared_ptr< TriangleMesh > CreateIcosahedron(double radius=1.0)
Definition: TriangleMeshFactory.cpp:78
int height
Definition: FilePCD.cpp:70
int EulerPoincareCharacteristic() const
Definition: TriangleMesh.cpp:1215
std::vector< std::unordered_set< int > > adjacency_list_
Definition: TriangleMesh.h:742
float a
Definition: TriangleMesh.h:755
std::shared_ptr< TriangleMesh > SelectByIndex(const std::vector< size_t > &indices) const
Definition: TriangleMesh.cpp:1550
std::vector< Eigen::Vector3d > triangle_normals_
Triangle normals.
Definition: TriangleMesh.h:739
MaterialParameter(const float v1, const float v2)
Definition: TriangleMesh.h:782
TriangleMesh(Geometry::GeometryType type)
Definition: TriangleMesh.h:704
TriangleMesh & RemoveUnreferencedVertices()
This function removes vertices from the triangle mesh that are not referenced in any triangle of the ...
Definition: TriangleMesh.cpp:762
bool HasTriangleNormals() const
Returns true if the mesh contains triangle normals.
Definition: TriangleMesh.h:85
std::vector< Eigen::Vector3d > vertices_
Vertex coordinates.
Definition: MeshBase.h:148
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:54
MaterialParameter(const float v1)
Definition: TriangleMesh.h:789
TriangleMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
Definition: TriangleMesh.cpp:112
std::vector< int > triangle_material_ids_
List of material ids.
Definition: TriangleMesh.h:828
TriangleMesh & RemoveDuplicatedVertices()
Function that removes duplicated verties, i.e., vertices that have identical coordinates.
Definition: TriangleMesh.cpp:666
float f2[2]
Definition: TriangleMesh.h:751
double GetSurfaceArea() const
Definition: TriangleMesh.cpp:1171
static MaterialParameter CreateRGB(const float r, const float g, const float b)
Definition: TriangleMesh.h:796
float baseMetallic
Definition: TriangleMesh.h:804
float baseReflectance
Definition: TriangleMesh.h:806
static Eigen::Vector3i GetOrderedTriangle(int vidx0, int vidx1, int vidx2)
Definition: TriangleMesh.h:310
std::shared_ptr< Image > clearCoatRoughness
Definition: TriangleMesh.h:818
static std::shared_ptr< TriangleMesh > CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1)
Definition: TriangleMeshFactory.cpp:254
std::shared_ptr< TriangleMesh > SimplifyVertexClustering(double voxel_size, SimplificationContraction contraction=SimplificationContraction::Average) const
Definition: TriangleMeshSimplification.cpp:92
std::shared_ptr< TriangleMesh > SimplifyQuadricDecimation(int target_number_of_triangles) const
Definition: TriangleMeshSimplification.cpp:267
std::vector< Eigen::Vector2d > triangle_uvs_
List of uv coordinates per triangle.
Definition: TriangleMesh.h:744
The Image class stores image with customizable width, height, num of channels and bytes per channel...
Definition: Image.h:53
float baseAnisotropy
Definition: TriangleMesh.h:809
std::shared_ptr< TriangleMesh > FilterSmoothTaubin(int number_of_iterations, double lambda=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:384
MaterialParameter(const float v1, const float v2, const float v3)
Definition: TriangleMesh.h:775
std::shared_ptr< Image > metallic
Definition: TriangleMesh.h:814
int width
Definition: FilePCD.cpp:69