Open3D (C++ API)  0.14.1
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

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 TensorMap & GetVertexAttr () const
 Getter for vertex_attr_ TensorMap. Used in Pybind. More...
 
core::Tensor & GetVertexAttr (const std::string &key)
 
core::Tensor & GetVertexPositions ()
 
core::Tensor & GetVertexColors ()
 
core::Tensor & GetVertexNormals ()
 
const TensorMap & GetTriangleAttr () const
 Getter for triangle_attr_ TensorMap. Used in Pybind. More...
 
core::Tensor & GetTriangleAttr (const std::string &key)
 
core::Tensor & GetTriangleIndices ()
 
core::Tensor & GetTriangleNormals ()
 
core::Tensor & GetTriangleColors ()
 
const core::Tensor & GetVertexAttr (const std::string &key) const
 
void RemoveVertexAttr (const std::string &key)
 
const core::Tensor & GetVertexPositions () const
 
const core::Tensor & GetVertexColors () const
 
const core::Tensor & GetVertexNormals () const
 
const core::Tensor & GetTriangleAttr (const std::string &key) const
 
void RemoveTriangleAttr (const std::string &key)
 
const core::Tensor & GetTriangleIndices () const
 
const core::Tensor & GetTriangleNormals () const
 
const core::Tensor & GetTriangleColors () 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 vlaue 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
 
TriangleMesh & Clear () 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
 
TriangleMesh & Transform (const core::Tensor &transformation)
 Transforms the VertexPositions, VertexNormals and TriangleNormals (if exist) of the TriangleMesh. More...
 
TriangleMesh & Translate (const core::Tensor &translation, bool relative=true)
 Translates the VertexPositions of the TriangleMesh. More...
 
TriangleMesh & Scale (double scale, const core::Tensor &center)
 Scales the VertexPositions of the TriangleMesh. More...
 
TriangleMesh & Rotate (const core::Tensor &R, const core::Tensor &center)
 Rotates the VertexPositions, VertexNormals and TriangleNormals (if exists). More...
 
core::Device GetDevice () const
 
open3d::geometry::TriangleMesh ToLegacy () const
 Convert to a legacy Open3D TriangleMesh. More...
 
- 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::t::geometry::DrawableGeometry
 DrawableGeometry ()
 
 ~DrawableGeometry ()
 
bool HasMaterial () const
 Check if a material has been applied to this Geometry with SetMaterial. More...
 
visualization::rendering::Material & GetMaterial ()
 Get material associated with this Geometry. More...
 
const visualization::rendering::Material & GetMaterial () 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 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 pointcloud 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

◆ Clear()

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

Clear all data in the trianglemesh.

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

◆ Clone()

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

Returns copy of the triangle mesh on the same device.

◆ 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.

◆ GetCenter()

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

◆ GetDevice()

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

◆ GetMaxBound()

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

◆ GetMinBound()

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

◆ GetTriangleAttr() [1/3]

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

Getter for triangle_attr_ TensorMap. Used in Pybind.

◆ GetTriangleAttr() [2/3]

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() [3/3]

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/3]

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

Getter for vertex_attr_ TensorMap. Used in Pybind.

◆ GetVertexAttr() [2/3]

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() [3/3]

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 followings 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 followings 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 followings 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 followings 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 followings 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 followings 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.

◆ 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

◆ 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 vlaue 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.

◆ 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: