Open3D (C++ API)  0.19.0
TriangleMesh.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <list>
11 #include <type_traits>
12 #include <unordered_map>
13 
14 #include "open3d/core/Tensor.h"
22 
23 namespace open3d {
24 namespace t {
25 namespace geometry {
26 
27 class LineSet;
28 class PointCloud;
29 class RaycastingScene;
30 
97 class TriangleMesh : public Geometry, public DrawableGeometry {
98 public:
102  TriangleMesh(const core::Device &device = core::Device("CPU:0"));
103 
112  TriangleMesh(const core::Tensor &vertex_positions,
113  const core::Tensor &triangle_indices);
114 
115  virtual ~TriangleMesh() override {}
116 
117 public:
119  std::string ToString() const;
120 
126  TriangleMesh To(const core::Device &device, bool copy = false) const;
127 
129  TriangleMesh Clone() const { return To(GetDevice(), /*copy=*/true); }
130 
132  const TensorMap &GetVertexAttr() const { return vertex_attr_; }
133 
136 
141  core::Tensor &GetVertexAttr(const std::string &key) {
142  return vertex_attr_.at(key);
143  }
144 
147  core::Tensor &GetVertexPositions() { return GetVertexAttr("positions"); }
148 
151  core::Tensor &GetVertexColors() { return GetVertexAttr("colors"); }
152 
155  core::Tensor &GetVertexNormals() { return GetVertexAttr("normals"); }
156 
158  const TensorMap &GetTriangleAttr() const { return triangle_attr_; }
159 
162 
167  core::Tensor &GetTriangleAttr(const std::string &key) {
168  return triangle_attr_.at(key);
169  }
170 
174 
178 
182 
186  const core::Tensor &GetVertexAttr(const std::string &key) const {
187  return vertex_attr_.at(key);
188  }
189 
194  void RemoveVertexAttr(const std::string &key) { vertex_attr_.Erase(key); }
195 
199  return GetVertexAttr("positions");
200  }
201 
204  const core::Tensor &GetVertexColors() const {
205  return GetVertexAttr("colors");
206  }
207 
211  return GetVertexAttr("normals");
212  }
213 
218  const core::Tensor &GetTriangleAttr(const std::string &key) const {
219  return triangle_attr_.at(key);
220  }
221 
226  void RemoveTriangleAttr(const std::string &key) {
227  triangle_attr_.Erase(key);
228  }
229 
233  return GetTriangleAttr("indices");
234  }
235 
239  return GetTriangleAttr("normals");
240  }
241 
245  return GetTriangleAttr("colors");
246  }
247 
253  void SetVertexAttr(const std::string &key, const core::Tensor &value) {
255  vertex_attr_[key] = value;
256  }
257 
260  void SetVertexPositions(const core::Tensor &value) {
261  core::AssertTensorShape(value, {std::nullopt, 3});
262  SetVertexAttr("positions", value);
263  }
264 
267  void SetVertexColors(const core::Tensor &value) {
268  core::AssertTensorShape(value, {std::nullopt, 3});
269  SetVertexAttr("colors", value);
270  }
271 
274  void SetVertexNormals(const core::Tensor &value) {
275  core::AssertTensorShape(value, {std::nullopt, 3});
276  SetVertexAttr("normals", value);
277  }
278 
284  void SetTriangleAttr(const std::string &key, const core::Tensor &value) {
286  triangle_attr_[key] = value;
287  }
288 
290  void SetTriangleIndices(const core::Tensor &value) {
291  core::AssertTensorShape(value, {std::nullopt, 3});
292  SetTriangleAttr("indices", value);
293  }
294 
297  void SetTriangleNormals(const core::Tensor &value) {
298  core::AssertTensorShape(value, {std::nullopt, 3});
299  SetTriangleAttr("normals", value);
300  }
301 
304  void SetTriangleColors(const core::Tensor &value) {
305  core::AssertTensorShape(value, {std::nullopt, 3});
306  SetTriangleAttr("colors", value);
307  }
308 
313  bool HasVertexAttr(const std::string &key) const {
314  return vertex_attr_.Contains(key) &&
315  GetVertexAttr(key).GetLength() > 0 &&
316  GetVertexAttr(key).GetLength() ==
318  }
319 
322  bool HasVertexPositions() const { return HasVertexAttr("positions"); }
323 
329  bool HasVertexColors() const { return HasVertexAttr("colors"); }
330 
336  bool HasVertexNormals() const { return HasVertexAttr("normals"); }
337 
342  bool HasTriangleAttr(const std::string &key) const {
343  return triangle_attr_.Contains(key) &&
344  GetTriangleAttr(key).GetLength() > 0 &&
345  GetTriangleAttr(key).GetLength() ==
347  }
348 
352  bool HasTriangleIndices() const { return HasTriangleAttr("indices"); }
353 
359  bool HasTriangleNormals() const { return HasTriangleAttr("normals"); }
360 
366  bool HasTriangleColors() const { return HasTriangleAttr("colors"); }
367 
378  static TriangleMesh CreateBox(
379  double width = 1.0,
380  double height = 1.0,
381  double depth = 1.0,
382  core::Dtype float_dtype = core::Float32,
383  core::Dtype int_dtype = core::Int64,
384  const core::Device &device = core::Device("CPU:0"));
385 
399  static TriangleMesh CreateSphere(
400  double radius = 1.0,
401  int resolution = 20,
402  core::Dtype float_dtype = core::Float32,
403  core::Dtype int_dtype = core::Int64,
404  const core::Device &device = core::Device("CPU:0"));
405 
418  double radius_x = 1.0,
419  double radius_y = 1.0,
420  double radius_z = 1.0,
421  int resolution = 20,
422  core::Dtype float_dtype = core::Float32,
423  core::Dtype int_dtype = core::Int64,
424  const core::Device &device = core::Device("CPU:0"));
425 
436  double radius = 1.0,
437  core::Dtype float_dtype = core::Float32,
438  core::Dtype int_dtype = core::Int64,
439  const core::Device &device = core::Device("CPU:0"));
440 
451  double radius = 1.0,
452  core::Dtype float_dtype = core::Float32,
453  core::Dtype int_dtype = core::Int64,
454  const core::Device &device = core::Device("CPU:0"));
455 
466  double radius = 1.0,
467  core::Dtype float_dtype = core::Float32,
468  core::Dtype int_dtype = core::Int64,
469  const core::Device &device = core::Device("CPU:0"));
470 
484  double radius = 1.0,
485  double height = 2.0,
486  int resolution = 20,
487  int split = 4,
488  core::Dtype float_dtype = core::Float32,
489  core::Dtype int_dtype = core::Int64,
490  const core::Device &device = core::Device("CPU:0"));
491 
504  static TriangleMesh CreateCone(
505  double radius = 1.0,
506  double height = 2.0,
507  int resolution = 20,
508  int split = 1,
509  core::Dtype float_dtype = core::Float32,
510  core::Dtype int_dtype = core::Int64,
511  const core::Device &device = core::Device("CPU:0"));
512 
526  static TriangleMesh CreateTorus(
527  double torus_radius = 1.0,
528  double tube_radius = 0.5,
529  int radial_resolution = 30,
530  int tubular_resolution = 20,
531  core::Dtype float_dtype = core::Float32,
532  core::Dtype int_dtype = core::Int64,
533  const core::Device &device = core::Device("CPU:0"));
534 
554  static TriangleMesh CreateArrow(
555  double cylinder_radius = 1.0,
556  double cone_radius = 1.5,
557  double cylinder_height = 5.0,
558  double cone_height = 4.0,
559  int resolution = 20,
560  int cylinder_split = 4,
561  int cone_split = 1,
562  core::Dtype float_dtype = core::Float32,
563  core::Dtype int_dtype = core::Int64,
564  const core::Device &device = core::Device("CPU:0"));
565 
575  double size = 1.0,
576  const Eigen::Vector3d &origin = Eigen::Vector3d(0.0, 0.0, 0.0),
577  core::Dtype float_dtype = core::Float32,
578  core::Dtype int_dtype = core::Int64,
579  const core::Device &device = core::Device("CPU:0"));
580 
596  static TriangleMesh CreateMobius(
597  int length_split = 70,
598  int width_split = 15,
599  int twists = 1,
600  double radius = 1,
601  double flatness = 1,
602  double width = 1,
603  double scale = 1,
604  core::Dtype float_dtype = core::Float32,
605  core::Dtype int_dtype = core::Int64,
606  const core::Device &device = core::Device("CPU:0"));
607 
617  static TriangleMesh CreateText(
618  const std::string &text,
619  double depth = 0.0,
620  core::Dtype float_dtype = core::Float32,
621  core::Dtype int_dtype = core::Int64,
622  const core::Device &device = core::Device("CPU:0"));
623 
634  const core::Tensor &volume,
635  const std::vector<double> contour_values = {0.0},
636  const core::Device &device = core::Device("CPU:0"));
637 
648  const OrientedBoundingEllipsoid &ellipsoid,
649  const core::Tensor &scale = core::Tensor::Ones(
650  {3}, core::Float64, core::Device("CPU:0")),
651  int resolution = 20,
652  core::Dtype float_dtype = core::Float32,
653  core::Dtype int_dtype = core::Int64,
654  const core::Device &device = core::Device("CPU:0"));
655 
656 public:
658  TriangleMesh &Clear() override {
659  vertex_attr_.clear();
660  triangle_attr_.clear();
661  return *this;
662  }
663 
665  bool IsEmpty() const override { return !HasVertexPositions(); }
666 
667  core::Tensor GetMinBound() const { return GetVertexPositions().Min({0}); }
668 
669  core::Tensor GetMaxBound() const { return GetVertexPositions().Max({0}); }
670 
671  core::Tensor GetCenter() const { return GetVertexPositions().Mean({0}); }
672 
692  TriangleMesh &Transform(const core::Tensor &transformation);
693 
698  TriangleMesh &Translate(const core::Tensor &translation,
699  bool relative = true);
700 
706  TriangleMesh &Scale(double scale, const core::Tensor &center);
707 
714  TriangleMesh &Rotate(const core::Tensor &R, const core::Tensor &center);
715 
718 
721  TriangleMesh &ComputeTriangleNormals(bool normalized = true);
722 
725  TriangleMesh &ComputeVertexNormals(bool normalized = true);
726 
729  double GetSurfaceArea() const;
730 
735 
746  const core::Tensor &normal) const;
747 
757  const core::Tensor &normal,
758  const std::vector<double> contour_values = {0.0}) const;
759 
760  core::Device GetDevice() const override { return device_; }
761 
771  const open3d::geometry::TriangleMesh &mesh_legacy,
772  core::Dtype float_dtype = core::Float32,
773  core::Dtype int_dtype = core::Int64,
774  const core::Device &device = core::Device("CPU:0"));
775 
778 
794  static std::unordered_map<std::string, geometry::TriangleMesh>
797  core::Dtype float_dtype = core::Float32,
798  core::Dtype int_dtype = core::Int64,
799  const core::Device &device = core::Device("CPU:0"));
800 
815  TriangleMesh ComputeConvexHull(bool joggle_inputs = false) const;
816 
830  TriangleMesh SimplifyQuadricDecimation(double target_reduction,
831  bool preserve_volume = true) const;
832 
845  double tolerance = 1e-6) const;
846 
858  double tolerance = 1e-6) const;
859 
871  double tolerance = 1e-6) const;
872 
875 
878 
881  bool robust = false) const;
882 
891  TriangleMesh FillHoles(double hole_size = 1e6) const;
892 
923  std::tuple<float, int, int> ComputeUVAtlas(size_t size = 512,
924  float gutter = 1.0f,
925  float max_stretch = 1.f / 6,
926  int parallel_partitions = 1,
927  int nthreads = 0);
928 
954  std::unordered_map<std::string, core::Tensor> BakeVertexAttrTextures(
955  int size,
956  const std::unordered_set<std::string> &vertex_attr = {},
957  double margin = 2.,
958  double fill = 0.,
959  bool update_material = true);
960 
985  std::unordered_map<std::string, core::Tensor> BakeTriangleAttrTextures(
986  int size,
987  const std::unordered_set<std::string> &triangle_attr = {},
988  double margin = 2.,
989  double fill = 0.,
990  bool update_material = true);
991 
1000  TriangleMesh ExtrudeRotation(double angle,
1001  const core::Tensor &axis,
1002  int resolution = 16,
1003  double translation = 0.0,
1004  bool capping = true) const;
1005 
1012  TriangleMesh ExtrudeLinear(const core::Tensor &vector,
1013  double scale = 1.0,
1014  bool capping = true) const;
1015 
1021  int PCAPartition(int max_faces);
1022 
1028  TriangleMesh SelectFacesByMask(const core::Tensor &mask) const;
1029 
1042  bool copy_attributes = true) const;
1043 
1047 
1068  const std::vector<Image> &images,
1069  const std::vector<core::Tensor> &intrinsic_matrices,
1070  const std::vector<core::Tensor> &extrinsic_matrices,
1071  int tex_size = 1024,
1072  bool update_material = true);
1073 
1080 
1086  core::Tensor GetNonManifoldEdges(bool allow_boundary_edges = true) const;
1087 
1097  PointCloud SamplePointsUniformly(size_t number_of_points,
1098  bool use_triangle_normal = false);
1099 
1113 
1128 
1137  const TriangleMesh &mesh2,
1138  std::vector<Metric> metrics = {Metric::ChamferDistance},
1139  MetricParameters params = MetricParameters()) const;
1140 
1161  Image ComputeAmbientOcclusion(int tex_width = 256,
1162  int n_rays = 32,
1163  float max_hit_distance = INFINITY,
1164  bool update_material = true);
1165 
1180  void ComputeTangentSpace(bool bake = true, int tex_width = 512);
1181 
1204  Image TransformNormalMap(const Image &normal_map,
1205  bool to_tangent_space = true,
1206  bool update_material = false);
1207 
1208 protected:
1212 };
1213 
1214 } // namespace geometry
1215 } // namespace t
1216 } // namespace open3d
double t
Definition: SurfaceReconstructionPoisson.cpp:172
Point< Real, 3 > point
Definition: SurfaceReconstructionPoisson.cpp:163
#define AssertTensorDevice(tensor,...)
Definition: TensorCheck.h:43
#define AssertTensorShape(tensor,...)
Definition: TensorCheck.h:58
bool copy
Definition: VtkUtils.cpp:74
Definition: Device.h:18
Definition: Dtype.h:20
Definition: Tensor.h:32
static Tensor Ones(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with ones.
Definition: Tensor.cpp:411
int64_t GetLength() const
Definition: Tensor.h:1182
Tensor Min(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1364
Tensor Mean(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1343
Tensor Max(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1371
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:34
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
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
Definition: BoundingVolume.h:46
Mix-in class for geometry types that can be visualized.
Definition: DrawableGeometry.h:19
The base geometry class.
Definition: Geometry.h:23
A LineSet contains points and lines joining them and optionally attributes on the points and lines.
Definition: LineSet.h:84
A bounding box oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:257
A bounding ellipsoid oriented along an arbitrary frame of reference.
Definition: BoundingVolume.h:512
Definition: TensorMap.h:31
std::size_t Erase(const std::string key)
Erase elements for the TensorMap by key value, if the key exists. If the key does not exists,...
Definition: TensorMap.h:92
bool Contains(const std::string &key) const
Definition: TensorMap.h:187
A triangle mesh contains vertices and triangles.
Definition: TriangleMesh.h:97
static TriangleMesh CreateText(const std::string &text, double depth=0.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:262
TriangleMesh ExtrudeRotation(double angle, const core::Tensor &axis, int resolution=16, double translation=0.0, bool capping=true) const
Definition: TriangleMesh.cpp:1104
static 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, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:206
TriangleMesh BooleanDifference(const TriangleMesh &mesh, double tolerance=1e-6) const
Definition: TriangleMesh.cpp:748
core::Tensor ComputeMetrics(const TriangleMesh &mesh2, std::vector< Metric > metrics={Metric::ChamferDistance}, MetricParameters params=MetricParameters()) const
Definition: TriangleMesh.cpp:1903
void SetTriangleIndices(const core::Tensor &value)
Set the value of the "indices" attribute in triangle_attr_.
Definition: TriangleMesh.h:290
TriangleMesh FillHoles(double hole_size=1e6) const
Definition: TriangleMesh.cpp:798
const TensorMap & GetVertexAttr() const
Getter for vertex_attr_ TensorMap. Used in Pybind.
Definition: TriangleMesh.h:132
Image TransformNormalMap(const Image &normal_map, bool to_tangent_space=true, bool update_material=false)
Converts a normal map between world and tangent space.
Definition: TriangleMesh.cpp:2234
core::Tensor & GetTriangleNormals()
Definition: TriangleMesh.h:177
core::Tensor GetMinBound() const
Definition: TriangleMesh.h:667
core::Tensor & GetVertexPositions()
Definition: TriangleMesh.h:147
void SetVertexPositions(const core::Tensor &value)
Definition: TriangleMesh.h:260
void SetVertexAttr(const std::string &key, const core::Tensor &value)
Definition: TriangleMesh.h:253
TriangleMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
Definition: TriangleMesh.cpp:232
static TriangleMesh CreateCoordinateFrame(double size=1.0, const Eigen::Vector3d &origin=Eigen::Vector3d(0.0, 0.0, 0.0), core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:227
const core::Tensor & GetTriangleNormals() const
Definition: TriangleMesh.h:238
TensorMap & GetVertexAttr()
Getter for vertex_attr_ TensorMap.
Definition: TriangleMesh.h:135
void SetVertexColors(const core::Tensor &value)
Definition: TriangleMesh.h:267
TensorMap triangle_attr_
Definition: TriangleMesh.h:1211
void SetTriangleColors(const core::Tensor &value)
Definition: TriangleMesh.h:304
TriangleMesh ExtrudeLinear(const core::Tensor &vector, double scale=1.0, bool capping=true) const
Definition: TriangleMesh.cpp:1114
virtual ~TriangleMesh() override
Definition: TriangleMesh.h:115
double GetSurfaceArea() const
Function that computes the surface area of the mesh, i.e. the sum of the individual triangle surfaces...
Definition: TriangleMesh.cpp:352
bool HasTriangleIndices() const
Definition: TriangleMesh.h:352
Image ProjectImagesToAlbedo(const std::vector< Image > &images, const std::vector< core::Tensor > &intrinsic_matrices, const std::vector< core::Tensor > &extrinsic_matrices, int tex_size=1024, bool update_material=true)
Definition: TriangleMesh.cpp:1480
static TriangleMesh CreateBox(double width=1.0, double height=1.0, double depth=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:22
bool HasVertexColors() const
Definition: TriangleMesh.h:329
static std::unordered_map< std::string, geometry::TriangleMesh > FromTriangleMeshModel(const open3d::visualization::rendering::TriangleMeshModel &model, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMesh.cpp:575
void ComputeTangentSpace(bool bake=true, int tex_width=512)
Definition: TriangleMesh.cpp:2162
void SetTriangleAttr(const std::string &key, const core::Tensor &value)
Definition: TriangleMesh.h:284
core::Device device_
Definition: TriangleMesh.h:1209
std::tuple< float, int, int > ComputeUVAtlas(size_t size=512, float gutter=1.0f, float max_stretch=1.f/6, int parallel_partitions=1, int nthreads=0)
Definition: TriangleMesh.cpp:812
TriangleMesh & Clear() override
Clear all data in the trianglemesh.
Definition: TriangleMesh.h:658
OrientedBoundingBox GetOrientedBoundingBox() const
Create an oriented bounding box from vertex attribute "positions".
Definition: TriangleMesh.cpp:758
void RemoveTriangleAttr(const std::string &key)
Definition: TriangleMesh.h:226
TriangleMesh & ComputeVertexNormals(bool normalized=true)
Function to compute vertex normals, usually called before rendering.
Definition: TriangleMesh.cpp:268
bool HasTriangleNormals() const
Definition: TriangleMesh.h:359
TriangleMesh ComputeConvexHull(bool joggle_inputs=false) const
Definition: TriangleMesh.cpp:608
OrientedBoundingEllipsoid GetOrientedBoundingEllipsoid(bool robust=false) const
Create an oriented bounding ellipsoid from vertex attribute "positions".
Definition: TriangleMesh.cpp:762
bool HasVertexNormals() const
Definition: TriangleMesh.h:336
static geometry::TriangleMesh FromLegacy(const open3d::geometry::TriangleMesh &mesh_legacy, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMesh.cpp:370
void RemoveVertexAttr(const std::string &key)
Definition: TriangleMesh.h:194
TriangleMesh To(const core::Device &device, bool copy=false) const
Definition: TriangleMesh.cpp:594
open3d::geometry::TriangleMesh ToLegacy() const
Convert to a legacy Open3D TriangleMesh.
Definition: TriangleMesh.cpp:458
TriangleMesh & NormalizeNormals()
Normalize both triangle normals and vertex normals to length 1.
Definition: TriangleMesh.cpp:198
TriangleMesh Clone() const
Returns copy of the triangle mesh on the same device.
Definition: TriangleMesh.h:129
core::Device GetDevice() const override
Returns the device of the geometry.
Definition: TriangleMesh.h:760
core::Tensor GetMaxBound() const
Definition: TriangleMesh.h:669
TriangleMesh & Rotate(const core::Tensor &R, const core::Tensor &center)
Rotates the VertexPositions, VertexNormals and TriangleNormals (if exists).
Definition: TriangleMesh.cpp:183
PointCloud SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false)
Definition: TriangleMesh.cpp:1830
TriangleMesh ClipPlane(const core::Tensor &point, const core::Tensor &normal) const
Clip mesh with a plane. This method clips the triangle mesh with the specified plane....
Definition: TriangleMesh.cpp:613
const core::Tensor & GetTriangleAttr(const std::string &key) const
Definition: TriangleMesh.h:218
core::Tensor GetNonManifoldEdges(bool allow_boundary_edges=true) const
Definition: TriangleMesh.cpp:1790
static TriangleMesh CreateIsosurfaces(const core::Tensor &volume, const std::vector< double > contour_values={0.0}, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:305
static TriangleMesh CreateTorus(double torus_radius=1.0, double tube_radius=0.5, int radial_resolution=30, int tubular_resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:188
TriangleMesh SelectFacesByMask(const core::Tensor &mask) const
Definition: TriangleMesh.cpp:1185
static TriangleMesh CreateOctahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:128
core::Tensor & GetTriangleAttr(const std::string &key)
Definition: TriangleMesh.h:167
const core::Tensor & GetTriangleColors() const
Definition: TriangleMesh.h:244
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const
Create an axis-aligned bounding box from vertex attribute "positions".
Definition: TriangleMesh.cpp:754
TriangleMesh BooleanIntersection(const TriangleMesh &mesh, double tolerance=1e-6) const
Definition: TriangleMesh.cpp:741
TriangleMesh RemoveUnreferencedVertices()
Definition: TriangleMesh.cpp:1363
TriangleMesh(const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMesh.cpp:60
int PCAPartition(int max_faces)
Definition: TriangleMesh.cpp:1121
TriangleMesh & Scale(double scale, const core::Tensor &center)
Scales the VertexPositions of the TriangleMesh.
Definition: TriangleMesh.cpp:172
void SetTriangleNormals(const core::Tensor &value)
Definition: TriangleMesh.h:297
core::Tensor & GetVertexColors()
Definition: TriangleMesh.h:151
const core::Tensor & GetVertexPositions() const
Definition: TriangleMesh.h:198
core::Tensor & GetTriangleIndices()
Definition: TriangleMesh.h:173
std::unordered_map< std::string, core::Tensor > BakeTriangleAttrTextures(int size, const std::unordered_set< std::string > &triangle_attr={}, double margin=2., double fill=0., bool update_material=true)
Definition: TriangleMesh.cpp:1050
bool HasTriangleColors() const
Definition: TriangleMesh.h:366
const core::Tensor & GetVertexNormals() const
Definition: TriangleMesh.h:210
TriangleMesh SelectByIndex(const core::Tensor &indices, bool copy_attributes=true) const
Definition: TriangleMesh.cpp:1256
LineSet SlicePlane(const core::Tensor &point, const core::Tensor &normal, const std::vector< double > contour_values={0.0}) const
Extract contour slices given a plane. This method extracts slices as LineSet from the mesh at specifi...
Definition: TriangleMesh.cpp:644
static 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, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:241
const core::Tensor & GetVertexAttr(const std::string &key) const
Definition: TriangleMesh.h:186
const core::Tensor & GetTriangleIndices() const
Definition: TriangleMesh.h:232
bool HasTriangleAttr(const std::string &key) const
Definition: TriangleMesh.h:342
static TriangleMesh CreateFromOrientedBoundingEllipsoid(const OrientedBoundingEllipsoid &ellipsoid, const core::Tensor &scale=core::Tensor::Ones({3}, core::Float64, core::Device("CPU:0")), int resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMesh.cpp:768
static TriangleMesh CreateIcosahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:141
bool HasVertexAttr(const std::string &key) const
Definition: TriangleMesh.h:313
Image ComputeAmbientOcclusion(int tex_width=256, int n_rays=32, float max_hit_distance=INFINITY, bool update_material=true)
Computes an ambient occlusion texture for the mesh.
Definition: TriangleMesh.cpp:1933
TriangleMesh & Transform(const core::Tensor &transformation)
Transforms the VertexPositions, VertexNormals and TriangleNormals (if exist) of the TriangleMesh.
Definition: TriangleMesh.cpp:143
static TriangleMesh CreateSphere(double radius=1.0, int resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:86
void SetVertexNormals(const core::Tensor &value)
Definition: TriangleMesh.h:274
static TriangleMesh CreateEllipsoid(double radius_x=1.0, double radius_y=1.0, double radius_z=1.0, int resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:99
const core::Tensor & GetVertexColors() const
Definition: TriangleMesh.h:204
core::Tensor GetCenter() const
Definition: TriangleMesh.h:671
TensorMap vertex_attr_
Definition: TriangleMesh.h:1210
std::string ToString() const
Text description.
Definition: TriangleMesh.cpp:82
const TensorMap & GetTriangleAttr() const
Getter for triangle_attr_ TensorMap. Used in Pybind.
Definition: TriangleMesh.h:158
TriangleMesh RemoveNonManifoldEdges()
Definition: TriangleMesh.cpp:1706
bool HasVertexPositions() const
Definition: TriangleMesh.h:322
TriangleMesh BooleanUnion(const TriangleMesh &mesh, double tolerance=1e-6) const
Definition: TriangleMesh.cpp:735
static TriangleMesh CreateTetrahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:115
static TriangleMesh CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:154
std::unordered_map< std::string, core::Tensor > BakeVertexAttrTextures(int size, const std::unordered_set< std::string > &vertex_attr={}, double margin=2., double fill=0., bool update_material=true)
Definition: TriangleMesh.cpp:984
core::Tensor & GetTriangleColors()
Definition: TriangleMesh.h:181
TensorMap & GetTriangleAttr()
Getter for triangle_attr_ TensorMap.
Definition: TriangleMesh.h:161
core::Tensor & GetVertexAttr(const std::string &key)
Definition: TriangleMesh.h:141
TriangleMesh & Translate(const core::Tensor &translation, bool relative=true)
Translates the VertexPositions of the TriangleMesh.
Definition: TriangleMesh.cpp:158
static TriangleMesh CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
Definition: TriangleMeshFactory.cpp:171
TriangleMesh & ComputeTriangleAreas()
Function to compute triangle areas and save it as a triangle attribute "areas". Prints a warning,...
Definition: TriangleMesh.cpp:326
TriangleMesh SimplifyQuadricDecimation(double target_reduction, bool preserve_volume=true) const
Definition: TriangleMesh.cpp:682
core::Tensor & GetVertexNormals()
Definition: TriangleMesh.h:155
bool IsEmpty() const override
Returns !HasVertexPositions(), triangles are ignored.
Definition: TriangleMesh.h:665
int width
Definition: FilePCD.cpp:52
int size
Definition: FilePCD.cpp:40
int height
Definition: FilePCD.cpp:53
const Dtype Int64
Definition: Dtype.cpp:47
const Dtype Float64
Definition: Dtype.cpp:43
const Dtype Float32
Definition: Dtype.cpp:42
@ ChamferDistance
Chamfer Distance.
Definition: PinholeCameraIntrinsic.cpp:16
const core::Tensor * indices
Definition: TriangleMesh.cpp:2092