Open3D (C++ API)  0.11.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 (core::Dtype vertex_dtype=core::Dtype::Float32, core::Dtype triangle_dtype=core::Dtype::Int64, const core::Device &device=core::Device("CPU:0"))
 Construct an empty trianglemesh. More...
 
 TriangleMesh (const core::TensorList &vertices, const core::TensorList &triangles)
 
virtual ~TriangleMesh () override
 
core::TensorListGetVertexAttr (const std::string &key)
 
core::TensorListGetVertices ()
 
core::TensorListGetVertexColors ()
 
core::TensorListGetVertexNormals ()
 
core::TensorListGetTriangleAttr (const std::string &key)
 
core::TensorListGetTriangles ()
 
core::TensorListGetTriangleNormals ()
 
core::TensorListGetTriangleColors ()
 
const core::TensorListGetVertexAttr (const std::string &key) const
 
const core::TensorListGetVertices () const
 
const core::TensorListGetVertexColors () const
 
const core::TensorListGetVertexNormals () const
 
const core::TensorListGetTriangleAttr (const std::string &key) const
 
const core::TensorListGetTriangles () const
 
const core::TensorListGetTriangleNormals () const
 
const core::TensorListGetTriangleColors () const
 
void SetVertexAttr (const std::string &key, const core::TensorList &value)
 
void SetVertices (const core::TensorList &value)
 
void SetVertexColors (const core::TensorList &value)
 
void SetVertexNormals (const core::TensorList &value)
 
void SetTriangleAttr (const std::string &key, const core::TensorList &value)
 
void SetTriangles (const core::TensorList &value)
 Set the vlaue of the "triangles" attribute in triangle_attr_. More...
 
void SetTriangleNormals (const core::TensorList &value)
 
void SetTriangleColors (const core::TensorList &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
 
void VertexSynchronizedPushBack (const std::unordered_map< std::string, core::Tensor > &map_keys_to_tensors)
 
void TriangleSynchronizedPushBack (const std::unordered_map< std::string, core::Tensor > &map_keys_to_tensors)
 
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
 
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...
 

Static Public Member Functions

static geometry::TriangleMesh FromLegacyTrangleMesh (const geometry::TriangleMesh &mesh_legacy, core::Dtype dtype=core::Dtype::Float32, const core::Device &device=core::Device("CPU:0"))
 Create a TriangleMesh from a legacy Open3D TriangleMesh. More...
 

Protected Attributes

core::Device device_ = core::Device("CPU:0")
 
TensorListMap vertex_attr_
 
TensorListMap 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 TensorList 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 ( core::Dtype  vertex_dtype = core::Dtype::Float32,
core::Dtype  triangle_dtype = core::Dtype::Int64,
const core::Device device = core::Device("CPU:0") 
)

Construct an empty trianglemesh.

◆ TriangleMesh() [2/2]

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

Construct a trianglemesh from vertices and triangles.

The input tensorlists will be directly used as the underlying storage of the trianglemsh (no memory copy). If the tensorlist is created in-place from a pre-allocated buffer, the tensorlist 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 tensorlist. The device for vertices must be consistent with triangles.

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

◆ FromLegacyTrangleMesh()

static geometry::TriangleMesh open3d::t::geometry::TriangleMesh::FromLegacyTrangleMesh ( const geometry::TriangleMesh mesh_legacy,
core::Dtype  dtype = core::Dtype::Float32,
const core::Device device = core::Device("CPU:0") 
)
inlinestatic

Create a TriangleMesh from a legacy Open3D TriangleMesh.

◆ 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/2]

core::TensorList& 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() [2/2]

const core::TensorList& 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::TensorList& open3d::t::geometry::TriangleMesh::GetTriangleColors ( )
inline

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

◆ GetTriangleColors() [2/2]

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

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

◆ GetTriangleNormals() [1/2]

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

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

◆ GetTriangleNormals() [2/2]

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

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

◆ GetTriangles() [1/2]

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

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

◆ GetTriangles() [2/2]

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

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

◆ GetVertexAttr() [1/2]

core::TensorList& 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() [2/2]

const core::TensorList& 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::TensorList& open3d::t::geometry::TriangleMesh::GetVertexColors ( )
inline

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

◆ GetVertexColors() [2/2]

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

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

◆ GetVertexNormals() [1/2]

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

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

◆ GetVertexNormals() [2/2]

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

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

◆ GetVertices() [1/2]

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

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

◆ GetVertices() [2/2]

const core::TensorList& 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::TensorList 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 tensorlist.

◆ SetTriangleColors()

void open3d::t::geometry::TriangleMesh::SetTriangleColors ( const core::TensorList 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::TensorList 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::TensorList 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::TensorList 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 tensorlist.

◆ SetVertexColors()

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

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

◆ SetVertexNormals()

void open3d::t::geometry::TriangleMesh::SetVertexNormals ( const core::TensorList 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::TensorList value)
inline

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

◆ ToLegacyTriangleMesh()

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

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

◆ TriangleSynchronizedPushBack()

void open3d::t::geometry::TriangleMesh::TriangleSynchronizedPushBack ( const std::unordered_map< std::string, core::Tensor > &  map_keys_to_tensors)
inline

Synchronized push back to the triangle_attr_, data will be copied. Before push back, all existing tensorlists must have the same length.

Parameters
map_keys_to_tensorsThe keys and values to be pushed back. It must contain the same keys and each corresponding tensor must have the same dtype and device.

◆ VertexSynchronizedPushBack()

void open3d::t::geometry::TriangleMesh::VertexSynchronizedPushBack ( const std::unordered_map< std::string, core::Tensor > &  map_keys_to_tensors)
inline

Synchronized push back to the vertex_attr_, data will be copied. Before push back, all existing tensorlists must have the same length.

Parameters
map_keys_to_tensorsThe keys and values to be pushed back. It must contain the same keys and each corresponding tensor must have the same dtype and device.

Field Documentation

◆ device_

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

◆ triangle_attr_

TensorListMap open3d::t::geometry::TriangleMesh::triangle_attr_
protected

◆ vertex_attr_

TensorListMap open3d::t::geometry::TriangleMesh::vertex_attr_
protected

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