ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::t::geometry::TensorMap Class Reference

#include <TensorMap.h>

Inheritance diagram for cloudViewer::t::geometry::TensorMap:
Collaboration diagram for cloudViewer::t::geometry::TensorMap:

Public Member Functions

 TensorMap (const std::string &primary_key)
 Create empty TensorMap and set primary key. More...
 
 TensorMap ()
 
template<class InputIt >
 TensorMap (const std::string &primary_key, InputIt first, InputIt last)
 
 TensorMap (const std::string &primary_key, const std::unordered_map< std::string, core::Tensor > &tensor_map)
 
 TensorMap (const std::string &primary_key, std::initializer_list< value_type > init)
 
 TensorMap (const TensorMap &other)
 Copy constructor performs a "shallow" copy of the Tensors. More...
 
 TensorMap (TensorMap &&other)
 Move constructor performs a "shallow" copy of the Tensors. More...
 
std::size_t Erase (const std::string key)
 Erase elements for the TensorMap by key value, if the key exists. If the key does not exists, a warning is thrown. Also primary_key cannot be deleted. It is based on size_type unordered_map::erase(const key_type& k);. More...
 
std::pair< iterator, bool > insert (const value_type &value)
 
template<class P >
std::pair< iterator, bool > insert (P &&value)
 
iterator insert (const_iterator hint, const value_type &value)
 
template<class P >
iterator insert (const_iterator hint, P &&value)
 
template<class InputIt >
void insert (InputIt first, InputIt last)
 
void insert (std::initializer_list< value_type > ilist)
 
TensorMapoperator= (const TensorMap &)=default
 
TensorMapoperator= (TensorMap &&)=default
 
std::string GetPrimaryKey () const
 Returns the primary key of the TensorMap. More...
 
std::unordered_set< std::string > GetKeySet () const
 Returns a set with all keys. More...
 
bool IsSizeSynchronized () const
 Returns true if all tensors in the map have the same size. More...
 
void AssertSizeSynchronized () const
 Assert IsSizeSynchronized(). More...
 
bool IsContiguous () const
 
TensorMap Contiguous () const
 
bool Contains (const std::string &key) const
 
std::string ToString () const
 Print the TensorMap to string. More...
 

Static Public Member Functions

static std::unordered_set< std::string > GetReservedKeys ()
 Get reserved keys for the map. A map cannot contain any of these keys. More...
 

Detailed Description

TensorMap is a unordered_map<string, Tensor> with a primary key. It is typically used as a container for geometry attributes.

e.g. tensor_map.primary_key: "positions" tensor_map["positions"] : Tensor of shape {100, 3}. tensor_map["colors"] : Tensor of shape {100, 3}. tensor_map["normals"] : Tensor of shape {100, 3}.

Typically, tensors in the TensorMap should have the same length (the first dimension of shape) and device as the primary tensor.

Definition at line 31 of file TensorMap.h.

Constructor & Destructor Documentation

◆ TensorMap() [1/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( const std::string &  primary_key)
inlineexplicit

Create empty TensorMap and set primary key.

Definition at line 34 of file TensorMap.h.

◆ TensorMap() [2/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( )
inlineexplicit

A primary key is always required. This constructor can be marked as delete in C++, but it is needed for pybind to bind as a generic python map interface.

Definition at line 44 of file TensorMap.h.

References LogError.

◆ TensorMap() [3/7]

template<class InputIt >
cloudViewer::t::geometry::TensorMap::TensorMap ( const std::string &  primary_key,
InputIt  first,
InputIt  last 
)
inline

Definition at line 49 of file TensorMap.h.

◆ TensorMap() [4/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( const std::string &  primary_key,
const std::unordered_map< std::string, core::Tensor > &  tensor_map 
)
inline

Definition at line 56 of file TensorMap.h.

◆ TensorMap() [5/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( const std::string &  primary_key,
std::initializer_list< value_type >  init 
)
inline

Definition at line 63 of file TensorMap.h.

◆ TensorMap() [6/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( const TensorMap other)
inline

Copy constructor performs a "shallow" copy of the Tensors.

Definition at line 72 of file TensorMap.h.

◆ TensorMap() [7/7]

cloudViewer::t::geometry::TensorMap::TensorMap ( TensorMap &&  other)
inline

Move constructor performs a "shallow" copy of the Tensors.

Definition at line 80 of file TensorMap.h.

Member Function Documentation

◆ AssertSizeSynchronized()

◆ Contains()

◆ Contiguous()

◆ Erase()

std::size_t cloudViewer::t::geometry::TensorMap::Erase ( const std::string  key)
inline

Erase elements for the TensorMap by key value, if the key exists. If the key does not exists, a warning is thrown. Also primary_key cannot be deleted. It is based on size_type unordered_map::erase(const key_type& k);.

Returns
The number of elements deleted. [0 if key was not present].

Definition at line 92 of file TensorMap.h.

References Contains(), LogError, and LogWarning.

Referenced by cloudViewer::t::geometry::LineSet::RemoveLineAttr(), cloudViewer::t::geometry::LineSet::RemovePointAttr(), cloudViewer::t::geometry::PointCloud::RemovePointAttr(), cloudViewer::t::geometry::TriangleMesh::RemoveTriangleAttr(), and cloudViewer::t::geometry::TriangleMesh::RemoveVertexAttr().

◆ GetKeySet()

std::unordered_set<std::string> cloudViewer::t::geometry::TensorMap::GetKeySet ( ) const
inline

Returns a set with all keys.

Definition at line 162 of file TensorMap.h.

Referenced by cloudViewer::t::geometry::vtkutils::ComputeNormals().

◆ GetPrimaryKey()

std::string cloudViewer::t::geometry::TensorMap::GetPrimaryKey ( ) const
inline

◆ GetReservedKeys()

std::unordered_set< std::string > cloudViewer::t::geometry::TensorMap::GetReservedKeys ( )
static

Get reserved keys for the map. A map cannot contain any of these keys.

Definition at line 83 of file TensorMap.cpp.

Referenced by cloudViewer::t::geometry::bind_tensor_map(), insert(), and cloudViewer::t::geometry::pybind_tensormap().

◆ insert() [1/6]

std::pair<iterator, bool> cloudViewer::t::geometry::TensorMap::insert ( const value_type &  value)
inline

Definition at line 102 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ insert() [2/6]

iterator cloudViewer::t::geometry::TensorMap::insert ( const_iterator  hint,
const value_type &  value 
)
inline

Definition at line 118 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ insert() [3/6]

template<class P >
iterator cloudViewer::t::geometry::TensorMap::insert ( const_iterator  hint,
P &&  value 
)
inline

Definition at line 127 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ insert() [4/6]

template<class InputIt >
void cloudViewer::t::geometry::TensorMap::insert ( InputIt  first,
InputIt  last 
)
inline

Definition at line 136 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ insert() [5/6]

template<class P >
std::pair<iterator, bool> cloudViewer::t::geometry::TensorMap::insert ( P &&  value)
inline

Definition at line 110 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ insert() [6/6]

void cloudViewer::t::geometry::TensorMap::insert ( std::initializer_list< value_type >  ilist)
inline

Definition at line 145 of file TensorMap.h.

References count, GetReservedKeys(), and LogError.

◆ IsContiguous()

bool cloudViewer::t::geometry::TensorMap::IsContiguous ( ) const

Returns True if the underlying memory buffers of all the Tensors in the TensorMap is contiguous.

Definition at line 65 of file TensorMap.cpp.

◆ IsSizeSynchronized()

bool cloudViewer::t::geometry::TensorMap::IsSizeSynchronized ( ) const

Returns true if all tensors in the map have the same size.

Definition at line 21 of file TensorMap.cpp.

Referenced by AssertSizeSynchronized(), and cloudViewer::t::geometry::pybind_tensormap().

◆ operator=() [1/2]

TensorMap& cloudViewer::t::geometry::TensorMap::operator= ( const TensorMap )
default

◆ operator=() [2/2]

TensorMap& cloudViewer::t::geometry::TensorMap::operator= ( TensorMap &&  )
default

◆ ToString()


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