Open3D (C++ API)
0.14.1
|
A triangle mesh contains vertices and triangles. More...
#include <TriangleMesh.h>
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 ¢er) |
Scales the VertexPositions of the TriangleMesh. More... | |
TriangleMesh & | Rotate (const core::Tensor &R, const core::Tensor ¢er) |
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... | |
![]() | |
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) |
![]() | |
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 | |
![]() | |
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... | |
![]() | |
Geometry (GeometryType type, int dimension) | |
Parameterized Constructor. More... | |
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.
open3d::t::geometry::TriangleMesh::TriangleMesh | ( | const core::Device & | device = core::Device("CPU:0") | ) |
Construct an empty pointcloud on the provided device.
device | The device on which to initialize the trianglemesh (default: 'CPU:0'). |
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
.
vertex_positions | A tensor with element shape {3}. |
triangle_indices | A tensor with element shape {3}. |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Clear all data in the trianglemesh.
Implements open3d::t::geometry::Geometry.
|
inline |
Returns copy of the triangle mesh on the same device.
|
static |
Create a TriangleMesh from a legacy Open3D TriangleMesh.
mesh_legacy | Legacy Open3D TriangleMesh. |
float_dtype | Float32 or Float64, used to store floating point values, e.g. vertices, normals, colors. |
int_dtype | Int32 or Int64, used to store index values, e.g. triangles. |
device | The device where the resulting TriangleMesh resides in. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Getter for triangle_attr_ TensorMap. Used in Pybind.
|
inline |
Get triangle attributes in triangle_attr_. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get triangle attributes in triangle_attr_. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get the value of the "colors" attribute in triangle_attr_. Convenience function.
|
inline |
Get the value of the "colors" attribute in triangle_attr_. Convenience function.
|
inline |
Get the value of the "indices" attribute in triangle_attr_. Convenience function.
|
inline |
Get the value of the "indices" attribute in triangle_attr_. Convenience function.
|
inline |
Get the value of the "normals" attribute in triangle_attr_. Convenience function.
|
inline |
Get the value of the "normals" attribute in triangle_attr_. Convenience function.
|
inline |
Getter for vertex_attr_ TensorMap. Used in Pybind.
|
inline |
Get vertex attributes in vertex_attr_. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get vertex attributes. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get the value of the "colors" attribute in vertex_attr_. Convenience function.
|
inline |
Get the value of the "colors" attribute in vertex_attr_. Convenience function.
|
inline |
Get the value of the "normals" attribute in vertex_attr_. Convenience function.
|
inline |
Get the value of the "normals" attribute in vertex_attr_. Convenience function.
|
inline |
Get the value of the "positions" attribute in vertex_attr_. Convenience function.
|
inline |
Get the value of the "positions" attribute in vertex_attr_. Convenience function.
|
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
|
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.
|
inline |
Check if the "indices" attribute's value in triangle_attr_ has length
0.
Convenience function.
|
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.
|
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
|
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.
|
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.
|
inline |
Check if the "positions" attribute's value in vertex_attr_ has length > 0. Convenience function.
|
inlineoverridevirtual |
Returns !HasVertexPositions(), triangles are ignored.
Implements open3d::t::geometry::Geometry.
|
inline |
Removes triangle attribute by key value. Primary attribute "indices" cannot be removed. Throws warning if attribute key does not exists.
key | Attribute name. |
|
inline |
Removes vertex attribute by key value. Primary attribute "positions" cannot be removed. Throws warning if attribute key does not exists.
key | Attribute name. |
TriangleMesh & open3d::t::geometry::TriangleMesh::Rotate | ( | const core::Tensor & | R, |
const core::Tensor & | center | ||
) |
Rotates the VertexPositions, VertexNormals and TriangleNormals (if exists).
R | Rotation [Tensor of dim {3,3}]. |
center | Center [Tensor of dim {3}] about which the TriangleMesh is to be scaled. |
TriangleMesh & open3d::t::geometry::TriangleMesh::Scale | ( | double | scale, |
const core::Tensor & | center | ||
) |
Scales the VertexPositions of the TriangleMesh.
scale | Scale [double] of dimension |
center | Center [Tensor of dim {3}] about which the TriangleMesh is to be scaled. |
|
inline |
Set triangle attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.
key | Attribute name. |
value | A tensor. |
|
inline |
Set the value of the "colors" attribute in triangle_attr_. This is a convenience function.
|
inline |
Set the vlaue of the "indices" attribute in triangle_attr_.
|
inline |
Set the value of the "normals" attribute in triangle_attr_. This is a convenience function.
|
inline |
Set vertex attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.
key | Attribute name. |
value | A tensor. |
|
inline |
Set the value of the "colors" attribute in vertex_attr_. Convenience function.
|
inline |
Set the value of the "normals" attribute in vertex_attr_. This is a convenience function.
|
inline |
Set the value of the "positions" attribute in vertex_attr_. Convenience function.
TriangleMesh open3d::t::geometry::TriangleMesh::To | ( | const core::Device & | device, |
bool | copy = false |
||
) | const |
Transfer the triangle mesh to a specified device.
device | The targeted device to convert to. |
copy | If 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. |
open3d::geometry::TriangleMesh open3d::t::geometry::TriangleMesh::ToLegacy | ( | ) | const |
Convert to a legacy Open3D TriangleMesh.
std::string open3d::t::geometry::TriangleMesh::ToString | ( | ) | const |
Text description.
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'
transformation | Transformation [Tensor of dim {4,4}]. |
TriangleMesh & open3d::t::geometry::TriangleMesh::Translate | ( | const core::Tensor & | translation, |
bool | relative = true |
||
) |
Translates the VertexPositions of the TriangleMesh.
translation | translation tensor of dimension {3} |
relative | if true (default): translates relative to Center |
|
protected |
|
protected |
|
protected |