Open3D (C++ API)  0.18.0
Public Member Functions | Static Public Member Functions | Protected Attributes
open3d::t::geometry::TriangleMesh Class Reference

A triangle mesh contains vertices and triangles. More...

#include <TriangleMesh.h>

Inheritance diagram for open3d::t::geometry::TriangleMesh:
open3d::t::geometry::Geometry open3d::t::geometry::DrawableGeometry open3d::core::IsDevice

Public Member Functions

 TriangleMesh (const core::Device &device=core::Device("CPU:0"))
 
 TriangleMesh (const core::Tensor &vertex_positions, const core::Tensor &triangle_indices)
 
virtual ~TriangleMesh () override
 
std::string ToString () const
 Text description. More...
 
TriangleMesh To (const core::Device &device, bool copy=false) const
 
TriangleMesh Clone () const
 Returns copy of the triangle mesh on the same device. More...
 
const TensorMapGetVertexAttr () const
 Getter for vertex_attr_ TensorMap. Used in Pybind. More...
 
TensorMapGetVertexAttr ()
 Getter for vertex_attr_ TensorMap. More...
 
core::TensorGetVertexAttr (const std::string &key)
 
core::TensorGetVertexPositions ()
 
core::TensorGetVertexColors ()
 
core::TensorGetVertexNormals ()
 
const TensorMapGetTriangleAttr () const
 Getter for triangle_attr_ TensorMap. Used in Pybind. More...
 
TensorMapGetTriangleAttr ()
 Getter for triangle_attr_ TensorMap. More...
 
core::TensorGetTriangleAttr (const std::string &key)
 
core::TensorGetTriangleIndices ()
 
core::TensorGetTriangleNormals ()
 
core::TensorGetTriangleColors ()
 
const core::TensorGetVertexAttr (const std::string &key) const
 
void RemoveVertexAttr (const std::string &key)
 
const core::TensorGetVertexPositions () const
 
const core::TensorGetVertexColors () const
 
const core::TensorGetVertexNormals () const
 
const core::TensorGetTriangleAttr (const std::string &key) const
 
void RemoveTriangleAttr (const std::string &key)
 
const core::TensorGetTriangleIndices () const
 
const core::TensorGetTriangleNormals () const
 
const core::TensorGetTriangleColors () const
 
void SetVertexAttr (const std::string &key, const core::Tensor &value)
 
void SetVertexPositions (const core::Tensor &value)
 
void SetVertexColors (const core::Tensor &value)
 
void SetVertexNormals (const core::Tensor &value)
 
void SetTriangleAttr (const std::string &key, const core::Tensor &value)
 
void SetTriangleIndices (const core::Tensor &value)
 Set the value of the "indices" attribute in triangle_attr_. More...
 
void SetTriangleNormals (const core::Tensor &value)
 
void SetTriangleColors (const core::Tensor &value)
 
bool HasVertexAttr (const std::string &key) const
 
bool HasVertexPositions () const
 
bool HasVertexColors () const
 
bool HasVertexNormals () const
 
bool HasTriangleAttr (const std::string &key) const
 
bool HasTriangleIndices () const
 
bool HasTriangleNormals () const
 
bool HasTriangleColors () const
 
TriangleMeshClear () override
 Clear all data in the trianglemesh. More...
 
bool IsEmpty () const override
 Returns !HasVertexPositions(), triangles are ignored. More...
 
core::Tensor GetMinBound () const
 
core::Tensor GetMaxBound () const
 
core::Tensor GetCenter () const
 
TriangleMeshTransform (const core::Tensor &transformation)
 Transforms the VertexPositions, VertexNormals and TriangleNormals (if exist) of the TriangleMesh. More...
 
TriangleMeshTranslate (const core::Tensor &translation, bool relative=true)
 Translates the VertexPositions of the TriangleMesh. More...
 
TriangleMeshScale (double scale, const core::Tensor &center)
 Scales the VertexPositions of the TriangleMesh. More...
 
TriangleMeshRotate (const core::Tensor &R, const core::Tensor &center)
 Rotates the VertexPositions, VertexNormals and TriangleNormals (if exists). More...
 
TriangleMeshNormalizeNormals ()
 Normalize both triangle normals and vertex normals to length 1. More...
 
TriangleMeshComputeTriangleNormals (bool normalized=true)
 Function to compute triangle normals, usually called before rendering. More...
 
TriangleMeshComputeVertexNormals (bool normalized=true)
 Function to compute vertex normals, usually called before rendering. More...
 
double GetSurfaceArea () const
 Function that computes the surface area of the mesh, i.e. the sum of the individual triangle surfaces. More...
 
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. Parts of the mesh on the positive side of the plane will be kept and triangles intersected by the plane will be cut. More...
 
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 specific contour values defined by the specified plane. More...
 
core::Device GetDevice () const override
 Returns the device of the geometry. More...
 
open3d::geometry::TriangleMesh ToLegacy () const
 Convert to a legacy Open3D TriangleMesh. More...
 
TriangleMesh ComputeConvexHull (bool joggle_inputs=false) const
 
TriangleMesh SimplifyQuadricDecimation (double target_reduction, bool preserve_volume=true) const
 
TriangleMesh BooleanUnion (const TriangleMesh &mesh, double tolerance=1e-6) const
 
TriangleMesh BooleanIntersection (const TriangleMesh &mesh, double tolerance=1e-6) const
 
TriangleMesh BooleanDifference (const TriangleMesh &mesh, double tolerance=1e-6) const
 
AxisAlignedBoundingBox GetAxisAlignedBoundingBox () const
 Create an axis-aligned bounding box from vertex attribute "positions". More...
 
OrientedBoundingBox GetOrientedBoundingBox () const
 Create an oriented bounding box from vertex attribute "positions". More...
 
TriangleMesh FillHoles (double hole_size=1e6) const
 
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)
 
std::unordered_map< std::string, core::TensorBakeVertexAttrTextures (int size, const std::unordered_set< std::string > &vertex_attr={}, double margin=2., double fill=0., bool update_material=true)
 
std::unordered_map< std::string, core::TensorBakeTriangleAttrTextures (int size, const std::unordered_set< std::string > &triangle_attr={}, double margin=2., double fill=0., bool update_material=true)
 
TriangleMesh ExtrudeRotation (double angle, const core::Tensor &axis, int resolution=16, double translation=0.0, bool capping=true) const
 
TriangleMesh ExtrudeLinear (const core::Tensor &vector, double scale=1.0, bool capping=true) const
 
int PCAPartition (int max_faces)
 
TriangleMesh SelectFacesByMask (const core::Tensor &mask) const
 
TriangleMesh SelectByIndex (const core::Tensor &indices) const
 
- Public Member Functions inherited from open3d::t::geometry::Geometry
virtual ~Geometry ()
 
GeometryType GetGeometryType () const
 Returns one of registered geometry types. More...
 
int Dimension () const
 Returns whether the geometry is 2D or 3D. More...
 
std::string GetName () const
 
void SetName (const std::string &name)
 
- Public Member Functions inherited from open3d::core::IsDevice
 IsDevice ()=default
 
virtual ~IsDevice ()=default
 
bool IsCPU () const
 
bool IsCUDA () const
 
- Public Member Functions inherited from open3d::t::geometry::DrawableGeometry
 DrawableGeometry ()
 
 ~DrawableGeometry ()
 
bool HasMaterial () const
 Check if a material has been applied to this Geometry with SetMaterial. More...
 
visualization::rendering::MaterialGetMaterial ()
 Get material associated with this Geometry. More...
 
const visualization::rendering::MaterialGetMaterial () const
 Get const reference to material associated with this Geometry. More...
 
void SetMaterial (const visualization::rendering::Material &material)
 Set the material properties associate with this Geometry. More...
 

Static Public Member Functions

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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 
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"))
 

Protected Attributes

core::Device device_ = core::Device("CPU:0")
 
TensorMap vertex_attr_
 
TensorMap triangle_attr_
 

Additional Inherited Members

- Public Types inherited from open3d::t::geometry::Geometry
enum class  GeometryType {
  Unspecified = 0 , PointCloud = 1 , VoxelGrid = 2 , Octree = 3 ,
  LineSet = 4 , MeshBase = 5 , TriangleMesh = 6 , HalfEdgeTriangleMesh = 7 ,
  Image = 8 , RGBDImage = 9 , TetraMesh = 10 , OrientedBoundingBox = 11 ,
  AxisAlignedBoundingBox = 12
}
 Specifies possible geometry types. More...
 
- Protected Member Functions inherited from open3d::t::geometry::Geometry
 Geometry (GeometryType type, int dimension)
 Parameterized Constructor. More...
 

Detailed Description

A triangle mesh contains vertices and triangles.

The triangle mesh class stores the attribute data in key-value maps. There are two maps: the vertex attributes map, and the triangle attribute map.

Note that the we can also use the generalized helper functions for the default and common attributes.

Constructor & Destructor Documentation

◆ TriangleMesh() [1/2]

open3d::t::geometry::TriangleMesh::TriangleMesh ( const core::Device device = core::Device("CPU:0"))

Construct an empty trianglemesh on the provided device.

Parameters
deviceThe device on which to initialize the trianglemesh (default: 'CPU:0').

◆ TriangleMesh() [2/2]

open3d::t::geometry::TriangleMesh::TriangleMesh ( const core::Tensor vertex_positions,
const core::Tensor triangle_indices 
)

Construct a trianglemesh from vertices and triangles.

The input tensors will be directly used as the underlying storage of the triangle mesh (no memory copy). The device for vertex_positions must be consistent with triangle_indices.

Parameters
vertex_positionsA tensor with element shape {3}.
triangle_indicesA tensor with element shape {3}.

◆ ~TriangleMesh()

virtual open3d::t::geometry::TriangleMesh::~TriangleMesh ( )
inlineoverridevirtual

Member Function Documentation

◆ BakeTriangleAttrTextures()

std::unordered_map< std::string, core::Tensor > open3d::t::geometry::TriangleMesh::BakeTriangleAttrTextures ( int  size,
const std::unordered_set< std::string > &  triangle_attr = {},
double  margin = 2.,
double  fill = 0.,
bool  update_material = true 
)

Bake triangle attributes into textures.

This function assumes a triangle attribute with name 'texture_uvs'.

This function always uses the CPU device.

Parameters
sizeThe width and height of the texture in pixels. Only square textures are supported.
vertex_attrThe vertex attributes for which textures should be generated.
marginThe margin in pixels. The recommended value is 2. The margin are additional pixels around the UV islands to avoid discontinuities.
fillThe value used for filling texels outside the UV islands.
update_materialIf true updates the material of the mesh. Baking a vertex attribute with the name 'albedo' will become the albedo texture in the material. Existing textures in the material will be overwritten.
Returns
A dictionary of textures.

◆ BakeVertexAttrTextures()

std::unordered_map< std::string, core::Tensor > open3d::t::geometry::TriangleMesh::BakeVertexAttrTextures ( int  size,
const std::unordered_set< std::string > &  vertex_attr = {},
double  margin = 2.,
double  fill = 0.,
bool  update_material = true 
)

Bake vertex attributes into textures.

This function assumes a triangle attribute with name 'texture_uvs'. Only float type attributes can be baked to textures.

This function always uses the CPU device.

Parameters
sizeThe width and height of the texture in pixels. Only square textures are supported.
vertex_attrThe vertex attributes for which textures should be generated.
marginThe margin in pixels. The recommended value is 2. The margin are additional pixels around the UV islands to avoid discontinuities.
fillThe value used for filling texels outside the UV islands.
update_materialIf true updates the material of the mesh. Baking a vertex attribute with the name 'albedo' will become the albedo texture in the material. Existing textures in the material will be overwritten.
Returns
A dictionary of textures.

◆ BooleanDifference()

TriangleMesh open3d::t::geometry::TriangleMesh::BooleanDifference ( const TriangleMesh mesh,
double  tolerance = 1e-6 
) const

Computes the mesh that encompasses the volume after subtracting the volume of the second operand. Both meshes should be manifold.

This function always uses the CPU device.

Parameters
meshThis is the second operand for the boolean operation.
toleranceThreshold which determines when point distances are considered to be 0.
Returns
The mesh describing the difference volume.

◆ BooleanIntersection()

TriangleMesh open3d::t::geometry::TriangleMesh::BooleanIntersection ( const TriangleMesh mesh,
double  tolerance = 1e-6 
) const

Computes the mesh that encompasses the intersection of the volumes of two meshes. Both meshes should be manifold.

This function always uses the CPU device.

Parameters
meshThis is the second operand for the boolean operation.
toleranceThreshold which determines when point distances are considered to be 0.
Returns
The mesh describing the intersection volume.

◆ BooleanUnion()

TriangleMesh open3d::t::geometry::TriangleMesh::BooleanUnion ( const TriangleMesh mesh,
double  tolerance = 1e-6 
) const

Computes the mesh that encompasses the union of the volumes of two meshes. Both meshes should be manifold.

This function always uses the CPU device.

Parameters
meshThis is the second operand for the boolean operation.
toleranceThreshold which determines when point distances are considered to be 0.
Returns
The mesh describing the union volume.

◆ Clear()

TriangleMesh& open3d::t::geometry::TriangleMesh::Clear ( )
inlineoverridevirtual

Clear all data in the trianglemesh.

Implements open3d::t::geometry::Geometry.

◆ ClipPlane()

TriangleMesh open3d::t::geometry::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. Parts of the mesh on the positive side of the plane will be kept and triangles intersected by the plane will be cut.

Parameters
pointA point on the plane as [Tensor of dim {3}].
normalThe normal of the plane as [Tensor of dim {3}]. The normal points to the positive side of the plane for which the geometry will be kept.
Returns
New triangle mesh clipped with the plane.

◆ Clone()

TriangleMesh open3d::t::geometry::TriangleMesh::Clone ( ) const
inline

Returns copy of the triangle mesh on the same device.

◆ ComputeConvexHull()

TriangleMesh open3d::t::geometry::TriangleMesh::ComputeConvexHull ( bool  joggle_inputs = false) const

Compute the convex hull of the triangle mesh using qhull.

This runs on the CPU.

Parameters
joggle_inputs(default False). Handle precision problems by randomly perturbing the input data. Set to True if perturbing the input iis acceptable but you need convex simplicial output. If False, neighboring facets may be merged in case of precision problems. See QHull docs for more details.
Returns
TriangleMesh representing the convexh hull. This contains an extra vertex property "point_map" that contains the index of the corresponding vertex in the original mesh.

◆ ComputeTriangleNormals()

TriangleMesh & open3d::t::geometry::TriangleMesh::ComputeTriangleNormals ( bool  normalized = true)

Function to compute triangle normals, usually called before rendering.

◆ ComputeUVAtlas()

std::tuple< float, int, int > open3d::t::geometry::TriangleMesh::ComputeUVAtlas ( size_t  size = 512,
float  gutter = 1.0f,
float  max_stretch = 1.f / 6,
int  parallel_partitions = 1,
int  nthreads = 0 
)

Creates an UV atlas and adds it as triangle attr 'texture_uvs' to the mesh.

Input meshes must be manifold for this method to work.

The algorithm is based on:

  • Zhou et al, "Iso-charts: Stretch-driven Mesh Parameterization using Spectral Analysis", Eurographics Symposium on Geometry Processing (2004)
  • Sander et al. "Signal-Specialized Parametrization" Europgraphics 2002

This function always uses the CPU device.

Parameters
sizeThe target size of the texture (size x size). The uv coordinates will still be in the range [0..1] but parameters like gutter use pixels as units.
gutterThis is the space around the uv islands in pixels.
max_stretchThe maximum amount of stretching allowed. The parameter range is [0..1] with 0 meaning no stretch allowed.
parallel_partitionsThe approximate number of partitions created before computing the UV atlas for parallelizing the computation. Parallelization can be enabled with values > 1. Note that parallelization increases the number of UV islands and can lead to results with lower quality.
nthreadsThe number of threads used when parallel_partitions is > 1. Set to 0 for automatic number of thread detection.
Returns
Tuple with (max stretch, num_charts, num_partitions) storing the actual amount of stretch, the number of created charts, and the number of parallel partitions created.

◆ ComputeVertexNormals()

TriangleMesh & open3d::t::geometry::TriangleMesh::ComputeVertexNormals ( bool  normalized = true)

Function to compute vertex normals, usually called before rendering.

◆ CreateArrow()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a arrow triangle mesh.

Parameters
cylinder_radiusdefines the radius of the cylinder.
cone_radiusdefines the radius of the cone.
cylinder_heightdefines the height of the cylinder. The axis of cylinder is from (0, 0, 0) to (0, 0, cylinder_height).
cone_heightdefines the height of the cone. The axis of the cone will be from (0, 0, cylinder_height) to (0, 0, cylinder_height + cone_height).
resolutiondefines the resolution of the cone. The circle will be split into resolution segments.
cylinder_splitdefines the number of segments along the cylinder_height direction.
cone_splitdefines the number of segments along the cone_height direction.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateBox()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a box triangle mesh. One vertex of the box will be placed at the origin and the box aligns with the positive x, y, and z axes.

Parameters
widthis x-directional length.
heightis y-directional length.
depthis z-directional length.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateCone()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a cone triangle mesh.

Parameters
radiusdefines the radius of the cone.
heightdefines the height of the cone. The axis of the cone will be from (0, 0, 0) to (0, 0, height).
resolutiondefines the resolution of the cone. The circle will be split into resolution segments.
splitdefines the number of segments along the height direction.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateCoordinateFrame()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a coordinate frame mesh.

Parameters
sizedefines the size of the coordinate frame.
origindefines the origin of the coordinate frame.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateCylinder()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a cylinder triangle mesh.

Parameters
radiusdefines the radius of the cylinder.
heightdefines the height of the cylinder. The axis of the cylinder will be from (0, 0, -height/2) to (0, 0, height/2).
resolutiondefines the resolution of the cylinder. The circle will be split into resolution segments
splitdefines the number of segments along the height direction.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateIcosahedron()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a icosahedron triangle mesh. The centroid of the mesh will be placed at (0, 0, 0) and the vertices have a distance of radius to the center.

Parameters
radiusdefines the distance from centroid to mesh vetices.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateMobius()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a Mobius strip.

Parameters
length_splitdefines the number of segments along the Mobius strip.
width_splitdefines the number of segments along the width of the Mobius strip.
twistsdefines the number of twists of the strip.
radiusdefines the radius of the Mobius strip.
flatnesscontrols the height of the strip.
widthcontrols the width of the Mobius strip.
scaleis used to scale the entire Mobius strip.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateOctahedron()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a octahedron triangle mesh. The centroid of the mesh will be placed at (0, 0, 0) and the vertices have a distance of radius to the center.

Parameters
radiusdefines the distance from centroid to mesh vetices.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateSphere()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a sphere triangle mesh. The sphere with radius will be centered at (0, 0, 0). Its axis is aligned with z-axis.

Parameters
radiusdefines the radius of the sphere.
resolutiondefines the resolution of the sphere. The longitudes will be split into resolution segments (i.e. there are resolution + 1 latitude lines including the north and south pole). The latitudes will be split into `2 * resolution segments (i.e. there are 2 * resolution longitude lines.)
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateTetrahedron()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a tetrahedron triangle mesh. The centroid of the mesh will be placed at (0, 0, 0) and the vertices have a distance of radius to the center.

Parameters
radiusdefines the distance from centroid to mesh vetices.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateText()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a text triangle mesh.

Parameters
textThe text for generating the mesh. ASCII characters 32-126 are supported (includes alphanumeric characters and punctuation). In addition the line feed '
' is supported to start a new line.
depthThe depth of the generated mesh. If depth is 0 then a flat mesh will be generated.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ CreateTorus()

TriangleMesh open3d::t::geometry::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") 
)
static

Create a torus triangle mesh.

Parameters
torus_radiusdefines the radius from the center of the torus to the center of the tube.
tube_radiusdefines the radius of the torus tube.
radial_resolutiondefines the number of segments along the radial direction.
tubular_resolutiondefines the number of segments along the tubular direction.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ ExtrudeLinear()

TriangleMesh open3d::t::geometry::TriangleMesh::ExtrudeLinear ( const core::Tensor vector,
double  scale = 1.0,
bool  capping = true 
) const

Sweeps the triangle mesh along a direction vector.

Parameters
vectorThe direction vector.
scaleScalar factor which essentially scales the direction vector.
cappingIf true adds caps to the mesh.
Returns
A triangle mesh with the result of the sweep operation.

◆ ExtrudeRotation()

TriangleMesh open3d::t::geometry::TriangleMesh::ExtrudeRotation ( double  angle,
const core::Tensor axis,
int  resolution = 16,
double  translation = 0.0,
bool  capping = true 
) const

Sweeps the triangle mesh rotationally about an axis.

Parameters
angleThe rotation angle in degree.
axisThe rotation axis.
resolutionThe resolution defines the number of intermediate sweeps about the rotation axis.
translationThe translation along the rotation axis.
cappingIf true adds caps to the mesh.
Returns
A triangle mesh with the result of the sweep operation.

◆ FillHoles()

TriangleMesh open3d::t::geometry::TriangleMesh::FillHoles ( double  hole_size = 1e6) const

Fill holes by triangulating boundary edges.

This function always uses the CPU device.

Parameters
hole_sizeThis is the approximate threshold for filling holes. The value describes the maximum radius of holes to be filled.
Returns
New mesh after filling holes.

◆ FromLegacy()

geometry::TriangleMesh open3d::t::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") 
)
static

Create a TriangleMesh from a legacy Open3D TriangleMesh.

Parameters
mesh_legacyLegacy Open3D TriangleMesh.
float_dtypeFloat32 or Float64, used to store floating point values, e.g. vertices, normals, colors.
int_dtypeInt32 or Int64, used to store index values, e.g. triangles.
deviceThe device where the resulting TriangleMesh resides in.

◆ GetAxisAlignedBoundingBox()

AxisAlignedBoundingBox open3d::t::geometry::TriangleMesh::GetAxisAlignedBoundingBox ( ) const

Create an axis-aligned bounding box from vertex attribute "positions".

◆ GetCenter()

core::Tensor open3d::t::geometry::TriangleMesh::GetCenter ( ) const
inline

◆ GetDevice()

core::Device open3d::t::geometry::TriangleMesh::GetDevice ( ) const
inlineoverridevirtual

Returns the device of the geometry.

Implements open3d::t::geometry::Geometry.

◆ GetMaxBound()

core::Tensor open3d::t::geometry::TriangleMesh::GetMaxBound ( ) const
inline

◆ GetMinBound()

core::Tensor open3d::t::geometry::TriangleMesh::GetMinBound ( ) const
inline

◆ GetOrientedBoundingBox()

OrientedBoundingBox open3d::t::geometry::TriangleMesh::GetOrientedBoundingBox ( ) const

Create an oriented bounding box from vertex attribute "positions".

◆ GetSurfaceArea()

double open3d::t::geometry::TriangleMesh::GetSurfaceArea ( ) const

Function that computes the surface area of the mesh, i.e. the sum of the individual triangle surfaces.

◆ GetTriangleAttr() [1/4]

TensorMap& open3d::t::geometry::TriangleMesh::GetTriangleAttr ( )
inline

Getter for triangle_attr_ TensorMap.

◆ GetTriangleAttr() [2/4]

const TensorMap& open3d::t::geometry::TriangleMesh::GetTriangleAttr ( ) const
inline

Getter for triangle_attr_ TensorMap. Used in Pybind.

◆ GetTriangleAttr() [3/4]

core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleAttr ( const std::string &  key)
inline

Get triangle attributes in triangle_attr_. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetTriangleAttr() [4/4]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleAttr ( const std::string &  key) const
inline

Get triangle attributes in triangle_attr_. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetTriangleColors() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleColors ( )
inline

Get the value of the "colors" attribute in triangle_attr_. Convenience function.

◆ GetTriangleColors() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleColors ( ) const
inline

Get the value of the "colors" attribute in triangle_attr_. Convenience function.

◆ GetTriangleIndices() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleIndices ( )
inline

Get the value of the "indices" attribute in triangle_attr_. Convenience function.

◆ GetTriangleIndices() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleIndices ( ) const
inline

Get the value of the "indices" attribute in triangle_attr_. Convenience function.

◆ GetTriangleNormals() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleNormals ( )
inline

Get the value of the "normals" attribute in triangle_attr_. Convenience function.

◆ GetTriangleNormals() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetTriangleNormals ( ) const
inline

Get the value of the "normals" attribute in triangle_attr_. Convenience function.

◆ GetVertexAttr() [1/4]

TensorMap& open3d::t::geometry::TriangleMesh::GetVertexAttr ( )
inline

Getter for vertex_attr_ TensorMap.

◆ GetVertexAttr() [2/4]

const TensorMap& open3d::t::geometry::TriangleMesh::GetVertexAttr ( ) const
inline

Getter for vertex_attr_ TensorMap. Used in Pybind.

◆ GetVertexAttr() [3/4]

core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexAttr ( const std::string &  key)
inline

Get vertex attributes in vertex_attr_. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetVertexAttr() [4/4]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexAttr ( const std::string &  key) const
inline

Get vertex attributes. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetVertexColors() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexColors ( )
inline

Get the value of the "colors" attribute in vertex_attr_. Convenience function.

◆ GetVertexColors() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexColors ( ) const
inline

Get the value of the "colors" attribute in vertex_attr_. Convenience function.

◆ GetVertexNormals() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexNormals ( )
inline

Get the value of the "normals" attribute in vertex_attr_. Convenience function.

◆ GetVertexNormals() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexNormals ( ) const
inline

Get the value of the "normals" attribute in vertex_attr_. Convenience function.

◆ GetVertexPositions() [1/2]

core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexPositions ( )
inline

Get the value of the "positions" attribute in vertex_attr_. Convenience function.

◆ GetVertexPositions() [2/2]

const core::Tensor& open3d::t::geometry::TriangleMesh::GetVertexPositions ( ) const
inline

Get the value of the "positions" attribute in vertex_attr_. Convenience function.

◆ HasTriangleAttr()

bool open3d::t::geometry::TriangleMesh::HasTriangleAttr ( const std::string &  key) const
inline

Returns true if all of the following are true in triangle_attr_: 1) attribute key exist 2) attribute's length as triangles' length 3) attribute's length > 0

◆ HasTriangleColors()

bool open3d::t::geometry::TriangleMesh::HasTriangleColors ( ) const
inline

Returns true if all of the following are true in triangle_attr_: 1) attribute "colors" exist 2) attribute "colors"'s length as vertices' length 3) attribute "colors"'s length > 0 Convenience function.

◆ HasTriangleIndices()

bool open3d::t::geometry::TriangleMesh::HasTriangleIndices ( ) const
inline

Check if the "indices" attribute's value in triangle_attr_ has length

0.

Convenience function.

◆ HasTriangleNormals()

bool open3d::t::geometry::TriangleMesh::HasTriangleNormals ( ) const
inline

Returns true if all of the following are true in triangle_attr_: 1) attribute "normals" exist 2) attribute "normals"'s length as vertices' length 3) attribute "normals"'s length > 0 Convenience function.

◆ HasVertexAttr()

bool open3d::t::geometry::TriangleMesh::HasVertexAttr ( const std::string &  key) const
inline

Returns true if all of the following are true in vertex_attr_: 1) attribute key exist 2) attribute's length as vertices' length 3) attribute's length > 0

◆ HasVertexColors()

bool open3d::t::geometry::TriangleMesh::HasVertexColors ( ) const
inline

Returns true if all of the following are true in vertex_attr_: 1) attribute "colors" exist 2) attribute "colors"'s length as vertices' length 3) attribute "colors"'s length > 0 Convenience function.

◆ HasVertexNormals()

bool open3d::t::geometry::TriangleMesh::HasVertexNormals ( ) const
inline

Returns true if all of the following are true in vertex_attr_: 1) attribute "normals" exist 2) attribute "normals"'s length as vertices' length 3) attribute "normals"'s length > 0 Convenience function.

◆ HasVertexPositions()

bool open3d::t::geometry::TriangleMesh::HasVertexPositions ( ) const
inline

Check if the "positions" attribute's value in vertex_attr_ has length > 0. Convenience function.

◆ IsEmpty()

bool open3d::t::geometry::TriangleMesh::IsEmpty ( ) const
inlineoverridevirtual

Returns !HasVertexPositions(), triangles are ignored.

Implements open3d::t::geometry::Geometry.

◆ NormalizeNormals()

TriangleMesh & open3d::t::geometry::TriangleMesh::NormalizeNormals ( )

Normalize both triangle normals and vertex normals to length 1.

◆ PCAPartition()

int open3d::t::geometry::TriangleMesh::PCAPartition ( int  max_faces)

Partition the mesh by recursively doing PCA. This function creates a new triangle attribute with the name "partition_ids".

Parameters
max_facesThe maximum allowed number of faces in a partition.
Returns
The number of partitions.

◆ RemoveTriangleAttr()

void open3d::t::geometry::TriangleMesh::RemoveTriangleAttr ( const std::string &  key)
inline

Removes triangle attribute by key value. Primary attribute "indices" cannot be removed. Throws warning if attribute key does not exists.

Parameters
keyAttribute name.

◆ RemoveVertexAttr()

void open3d::t::geometry::TriangleMesh::RemoveVertexAttr ( const std::string &  key)
inline

Removes vertex attribute by key value. Primary attribute "positions" cannot be removed. Throws warning if attribute key does not exists.

Parameters
keyAttribute name.

◆ Rotate()

TriangleMesh & open3d::t::geometry::TriangleMesh::Rotate ( const core::Tensor R,
const core::Tensor center 
)

Rotates the VertexPositions, VertexNormals and TriangleNormals (if exists).

Parameters
RRotation [Tensor of dim {3,3}].
centerCenter [Tensor of dim {3}] about which the TriangleMesh is to be scaled.
Returns
Rotated TriangleMesh

◆ Scale()

TriangleMesh & open3d::t::geometry::TriangleMesh::Scale ( double  scale,
const core::Tensor center 
)

Scales the VertexPositions of the TriangleMesh.

Parameters
scaleScale [double] of dimension
centerCenter [Tensor of dim {3}] about which the TriangleMesh is to be scaled.
Returns
Scaled TriangleMesh

◆ SelectByIndex()

TriangleMesh open3d::t::geometry::TriangleMesh::SelectByIndex ( const core::Tensor indices) const

Returns a new mesh with the vertices selected by a vector of indices. If an item from the indices list exceeds the max vertex number of the mesh or has a negative value, it is ignored.

Parameters
indicesAn integer list of indices. Duplicates are allowed, but ignored. Signed and unsigned integral types are allowed.
Returns
A new mesh with the selected vertices and faces built from the selected vertices. If the original mesh is empty, return an empty mesh.

◆ SelectFacesByMask()

TriangleMesh open3d::t::geometry::TriangleMesh::SelectFacesByMask ( const core::Tensor mask) const

Returns a new mesh with the faces selected by a boolean mask.

Parameters
maskA boolean mask with the shape (N) with N as the number of faces in the mesh.
Returns
A new mesh with the selected faces. If the original mesh is empty, return an empty mesh.

◆ SetTriangleAttr()

void open3d::t::geometry::TriangleMesh::SetTriangleAttr ( const std::string &  key,
const core::Tensor value 
)
inline

Set triangle attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.

Parameters
keyAttribute name.
valueA tensor.

◆ SetTriangleColors()

void open3d::t::geometry::TriangleMesh::SetTriangleColors ( const core::Tensor value)
inline

Set the value of the "colors" attribute in triangle_attr_. This is a convenience function.

◆ SetTriangleIndices()

void open3d::t::geometry::TriangleMesh::SetTriangleIndices ( const core::Tensor value)
inline

Set the value of the "indices" attribute in triangle_attr_.

◆ SetTriangleNormals()

void open3d::t::geometry::TriangleMesh::SetTriangleNormals ( const core::Tensor value)
inline

Set the value of the "normals" attribute in triangle_attr_. This is a convenience function.

◆ SetVertexAttr()

void open3d::t::geometry::TriangleMesh::SetVertexAttr ( const std::string &  key,
const core::Tensor value 
)
inline

Set vertex attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.

Parameters
keyAttribute name.
valueA tensor.

◆ SetVertexColors()

void open3d::t::geometry::TriangleMesh::SetVertexColors ( const core::Tensor value)
inline

Set the value of the "colors" attribute in vertex_attr_. Convenience function.

◆ SetVertexNormals()

void open3d::t::geometry::TriangleMesh::SetVertexNormals ( const core::Tensor value)
inline

Set the value of the "normals" attribute in vertex_attr_. This is a convenience function.

◆ SetVertexPositions()

void open3d::t::geometry::TriangleMesh::SetVertexPositions ( const core::Tensor value)
inline

Set the value of the "positions" attribute in vertex_attr_. Convenience function.

◆ SimplifyQuadricDecimation()

TriangleMesh open3d::t::geometry::TriangleMesh::SimplifyQuadricDecimation ( double  target_reduction,
bool  preserve_volume = true 
) const

Function to simplify mesh using Quadric Error Metric Decimation by Garland and Heckbert.

This function always uses the CPU device.

Parameters
target_reductionThe factor of triangles to delete, i.e., setting this to 0.9 will return a mesh with about 10% of the original triangle count. It is not guaranteed that the target reduction factor will be reached.
preserve_volumeIf set to true this enables volume preservation which reduces the error in triangle normal direction.
Returns
Simplified TriangleMesh.

◆ SlicePlane()

LineSet open3d::t::geometry::TriangleMesh::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 specific contour values defined by the specified plane.

Parameters
pointA point on the plane as [Tensor of dim {3}].
normalThe normal of the plane as [Tensor of dim {3}].
contour_valuesContour values at which slices will be generated. The value describes the signed distance to the plane.
Returns
LineSet with the extracted contours.

◆ To()

TriangleMesh open3d::t::geometry::TriangleMesh::To ( const core::Device device,
bool  copy = false 
) const

Transfer the triangle mesh to a specified device.

Parameters
deviceThe targeted device to convert to.
copyIf true, a new triangle mesh is always created; if false, the copy is avoided when the original triangle mesh is already on the targeted device.

◆ ToLegacy()

open3d::geometry::TriangleMesh open3d::t::geometry::TriangleMesh::ToLegacy ( ) const

Convert to a legacy Open3D TriangleMesh.

◆ ToString()

std::string open3d::t::geometry::TriangleMesh::ToString ( ) const

Text description.

◆ Transform()

TriangleMesh & open3d::t::geometry::TriangleMesh::Transform ( const core::Tensor transformation)

Transforms the VertexPositions, VertexNormals and TriangleNormals (if exist) of the TriangleMesh.

Transformation matrix is a 4x4 matrix. T (4x4) = [[ R(3x3) t(3x1) ], [ O(1x3) s(1x1) ]] (s = 1 for Transformation without scaling)

It applies the following general transform to each positions and normals. |x'| | R(0,0) R(0,1) R(0,2) t(0)| |x| |y'| = | R(1,0) R(1,1) R(1,2) t(1)| @ |y| |z'| | R(2,0) R(2,1) R(2,2) t(2)| |z| |w'| | O(0,0) O(0,1) O(0,2) s | |1|

[x, y, z] = [x', y', z'] / w'

Parameters
transformationTransformation [Tensor of dim {4,4}].
Returns
Transformed TriangleMesh

◆ Translate()

TriangleMesh & open3d::t::geometry::TriangleMesh::Translate ( const core::Tensor translation,
bool  relative = true 
)

Translates the VertexPositions of the TriangleMesh.

Parameters
translationtranslation tensor of dimension {3}
relativeif true (default): translates relative to Center
Returns
Translated TriangleMesh

Field Documentation

◆ device_

core::Device open3d::t::geometry::TriangleMesh::device_ = core::Device("CPU:0")
protected

◆ triangle_attr_

TensorMap open3d::t::geometry::TriangleMesh::triangle_attr_
protected

◆ vertex_attr_

TensorMap open3d::t::geometry::TriangleMesh::vertex_attr_
protected

The documentation for this class was generated from the following files: