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

A TriangleMesh contains vertices and triangles. More...

#include <TriangleMesh.h>

Inheritance diagram for open3d::t::geometry::TriangleMesh:
open3d::t::geometry::Geometry

Public Member Functions

 TriangleMesh (const core::Device &device=core::Device("CPU:0"))
 Construct an empty trianglemesh. More...
 
 TriangleMesh (const core::Tensor &vertices, const core::Tensor &triangles)
 
virtual ~TriangleMesh () override
 
const TensorMapGetVertexAttr () const
 Getter for vertex_attr_ TensorMap. Used in Pybind. More...
 
core::TensorGetVertexAttr (const std::string &key)
 
core::TensorGetVertices ()
 
core::TensorGetVertexColors ()
 
core::TensorGetVertexNormals ()
 
const TensorMapGetTriangleAttr () const
 Getter for triangle_attr_ TensorMap. Used in Pybind. More...
 
core::TensorGetTriangleAttr (const std::string &key)
 
core::TensorGetTriangles ()
 
core::TensorGetTriangleNormals ()
 
core::TensorGetTriangleColors ()
 
const core::TensorGetVertexAttr (const std::string &key) const
 
const core::TensorGetVertices () const
 
const core::TensorGetVertexColors () const
 
const core::TensorGetVertexNormals () const
 
const core::TensorGetTriangleAttr (const std::string &key) const
 
const core::TensorGetTriangles () const
 
const core::TensorGetTriangleNormals () const
 
const core::TensorGetTriangleColors () const
 
void SetVertexAttr (const std::string &key, const core::Tensor &value)
 
void SetVertices (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 SetTriangles (const core::Tensor &value)
 Set the vlaue of the "triangles" 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 HasVertices () const
 
bool HasVertexColors () const
 
bool HasVertexNormals () const
 
bool HasTriangleAttr (const std::string &key) const
 
bool HasTriangles () const
 
bool HasTriangleNormals () const
 
bool HasTriangleColors () const
 
TriangleMeshClear () override
 Clear all data in the trianglemesh. More...
 
bool IsEmpty () const override
 Returns !HasVertices(), triangles are ignored. More...
 
core::Tensor GetMinBound () const
 
core::Tensor GetMaxBound () const
 
core::Tensor GetCenter () const
 
TriangleMeshTransform (const core::Tensor &transformation)
 
TriangleMeshTranslate (const core::Tensor &translation, bool relative=true)
 
TriangleMeshScale (double scale, const core::Tensor &center)
 
TriangleMeshRotate (const core::Tensor &R, const core::Tensor &center)
 
core::Device GetDevice () const
 
open3d::geometry::TriangleMesh ToLegacyTriangleMesh () 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)
 

Static Public Member Functions

static geometry::TriangleMesh FromLegacyTriangleMesh (const open3d::geometry::TriangleMesh &mesh_legacy, core::Dtype float_dtype=core::Dtype::Float32, core::Dtype int_dtype=core::Dtype::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  GeometryType {
  GeometryType::Unspecified = 0, GeometryType::PointCloud = 1, GeometryType::VoxelGrid = 2, GeometryType::Octree = 3,
  GeometryType::LineSet = 4, GeometryType::MeshBase = 5, GeometryType::TriangleMesh = 6, GeometryType::HalfEdgeTriangleMesh = 7,
  GeometryType::Image = 8, GeometryType::RGBDImage = 9, GeometryType::TetraMesh = 10, GeometryType::OrientedBoundingBox = 11,
  GeometryType::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 TriangleMesh contains vertices and triangles.

The TriangleMesh class stores the attribute data in key-value pairs for flexibility, where the key is a string representing the attribute name and value is a Tensor containing the attribute data.

By default, there are two sets of dictionaries, i.e. vertex_attr_ and triangle_attr_. In most cases, the length of an attribute should be equal to the length of the the data corresponding to the master key. For instance vertex_attr_["normals"] should have the same length as vertex_attr_["vertices"].

Although the attributes are all stored in a key-value pair dictionary, the attributes have different levels:

Note that the level 0 and level 1 convenience functions can also be achieved via the generalized helper functions.

Constructor & Destructor Documentation

◆ TriangleMesh() [1/2]

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

Construct an empty trianglemesh.

◆ TriangleMesh() [2/2]

open3d::t::geometry::TriangleMesh::TriangleMesh ( const core::Tensor vertices,
const core::Tensor triangles 
)

Construct a trianglemesh from vertices and triangles.

The input tensors will be directly used as the underlying storage of the trianglemsh (no memory copy). If the tensor is created in-place from a pre-allocated buffer, the tensor has a fixed size and thus the resulting trianglemesh will have a fixed size and calling to functions like SynchronizedPushBack will raise an exception.

The resulting trianglemesh will have the same dtype and device as the tensor. The device for vertices must be consistent with triangles.

Parameters
verticesA tensor with element shape (3,).
trianglesA 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.

◆ FromLegacyTriangleMesh()

geometry::TriangleMesh open3d::t::geometry::TriangleMesh::FromLegacyTriangleMesh ( const open3d::geometry::TriangleMesh mesh_legacy,
core::Dtype  float_dtype = core::Dtype::Float32,
core::Dtype  int_dtype = core::Dtype::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.

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

◆ GetTriangles() [1/2]

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

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

◆ GetTriangles() [2/2]

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

Get the value of the "triangles" 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.

◆ GetVertices() [1/2]

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

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

◆ GetVertices() [2/2]

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

Get the value of the "vertices" 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.

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

◆ HasTriangles()

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

Check if the "triangles" attribute's value in triangle_attr_ has 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.

◆ HasVertices()

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

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

◆ IsEmpty()

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

Returns !HasVertices(), triangles are ignored.

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

◆ Rotate()

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

◆ Scale()

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

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

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

◆ SetTriangles()

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

Set the vlaue of the "triangles" attribute in triangle_attr_.

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

◆ SetVertices()

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

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

◆ ToLegacyTriangleMesh()

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

Convert to a legacy Open3D TriangleMesh.

◆ Transform()

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

◆ Translate()

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

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: