ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::eigen_converter Namespace Reference

Functions

template<typename func_t >
static void LaunchIndexFillKernel (const Indexer &indexer, const func_t &func)
 
template<typename T >
static Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrix (const core::Tensor &tensor)
 
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXd (const core::Tensor &tensor)
 Converts a 2D tensor to Eigen::MatrixXd of same shape. Regardless of the tensor dtype, the output will be converted to double. More...
 
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXf (const core::Tensor &tensor)
 Converts a 2D tensor to Eigen::MatrixXf of same shape. Regardless of the tensor dtype, the output will be converted to float. More...
 
Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXi (const core::Tensor &tensor)
 Converts a 2D tensor to Eigen::MatrixXi of same shape. Regardless of the tensor dtype, the output will be converted to int. More...
 
template<typename T , int N>
static std::vector< Eigen::Matrix< T, N, 1 > > TensorToEigenVectorNxVector (const core::Tensor &tensor)
 
template<typename T , int N>
static core::Tensor EigenVectorNxVectorToTensor (const std::vector< Eigen::Matrix< T, N, 1 >> &values, core::Dtype dtype, const core::Device &device)
 
std::vector< Eigen::Vector2d > TensorToEigenVector2dVector (const core::Tensor &tensor)
 Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2d>. An exception will be thrown if the tensor shape is not (N, 2). Regardless of the tensor dtype, the output will be converted to double. More...
 
std::vector< Eigen::Vector3d > TensorToEigenVector3dVector (const core::Tensor &tensor)
 Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3d>. An exception will be thrown if the tensor shape is not (N, 3). Regardless of the tensor dtype, the output will be converted to double. More...
 
std::vector< Eigen::Vector3i > TensorToEigenVector3iVector (const core::Tensor &tensor)
 Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3i>. An exception will be thrown if the tensor shape is not (N, 3). Regardless of the tensor dtype, the output will be converted to int. More...
 
std::vector< Eigen::Vector2i > TensorToEigenVector2iVector (const core::Tensor &tensor)
 Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2i>. An exception will be thrown if the tensor shape is not (N, 2). Regardless of the tensor dtype, the output will be converted to int. More...
 
core::Tensor EigenVector3dVectorToTensor (const std::vector< Eigen::Vector3d > &values, core::Dtype dtype, const core::Device &device)
 Converts a vector of Eigen::Vector3d to a (N, 3) tensor. This function also takes care of dtype conversion and device transfer if necessary. More...
 
core::Tensor EigenVector2dVectorToTensor (const std::vector< Eigen::Vector2d > &values, core::Dtype dtype, const core::Device &device)
 Converts a vector of Eigen::Vector2d to a (N, 2) tensor. This function also takes care of dtype conversion and device transfer if necessary. More...
 
core::Tensor EigenVector3iVectorToTensor (const std::vector< Eigen::Vector3i > &values, core::Dtype dtype, const core::Device &device)
 Converts a vector of Eigen::Vector3i to a (N, 3) tensor. This function also takes care of dtype conversion and device transfer if necessary. More...
 
core::Tensor EigenVector2iVectorToTensor (const std::vector< Eigen::Vector2i > &values, core::Dtype dtype, const core::Device &device)
 Converts a vector of Eigen::Vector2i to a (N, 2) tensor. This function also takes care of dtype conversion and device transfer if necessary. More...
 
template<class Derived >
core::Tensor EigenMatrixToTensor (const Eigen::MatrixBase< Derived > &matrix)
 Converts a eigen matrix of shape (M, N) with alignment A and type T to a tensor. More...
 

Function Documentation

◆ EigenMatrixToTensor()

template<class Derived >
core::Tensor cloudViewer::core::eigen_converter::EigenMatrixToTensor ( const Eigen::MatrixBase< Derived > &  matrix)

◆ EigenVector2dVectorToTensor()

core::Tensor cloudViewer::core::eigen_converter::EigenVector2dVectorToTensor ( const std::vector< Eigen::Vector2d > &  values,
core::Dtype  dtype,
const core::Device device 
)

Converts a vector of Eigen::Vector2d to a (N, 2) tensor. This function also takes care of dtype conversion and device transfer if necessary.

Parameters
valuesA vector of Eigen::Vector2d values, e.g. a list of UV coordinates.
dtypeDtype of the output tensor.
deviceDevice of the output tensor.
Returns
A tensor of shape (N, 2) with the specified dtype and device.

Definition at line 172 of file EigenConverter.cpp.

References EigenVectorNxVectorToTensor().

Referenced by cloudViewer::t::geometry::TriangleMesh::FromLegacy().

◆ EigenVector2iVectorToTensor()

core::Tensor cloudViewer::core::eigen_converter::EigenVector2iVectorToTensor ( const std::vector< Eigen::Vector2i > &  values,
core::Dtype  dtype,
const core::Device device 
)

Converts a vector of Eigen::Vector2i to a (N, 2) tensor. This function also takes care of dtype conversion and device transfer if necessary.

Parameters
valuesA vector of Eigen::Vector2i values, e.g. a list of 2D points / indices.
dtypeDtype of the output tensor.
deviceDevice of the output tensor.
Returns
A tensor of shape (N, 2) with the specified dtype and device.

Definition at line 185 of file EigenConverter.cpp.

References EigenVectorNxVectorToTensor().

Referenced by cloudViewer::t::geometry::LineSet::FromLegacy().

◆ EigenVector3dVectorToTensor()

core::Tensor cloudViewer::core::eigen_converter::EigenVector3dVectorToTensor ( const std::vector< Eigen::Vector3d > &  values,
core::Dtype  dtype,
const core::Device device 
)

Converts a vector of Eigen::Vector3d to a (N, 3) tensor. This function also takes care of dtype conversion and device transfer if necessary.

Parameters
valuesA vector of Eigen::Vector3d values, e.g. a list of 3D points.
dtypeDtype of the output tensor.
deviceDevice of the output tensor.
Returns
A tensor of shape (N, 3) with the specified dtype and device.

Definition at line 165 of file EigenConverter.cpp.

References EigenVectorNxVectorToTensor().

Referenced by cloudViewer::t::geometry::TriangleMesh::FromLegacy(), cloudViewer::t::geometry::LineSet::FromLegacy(), and cloudViewer::t::geometry::PointCloud::FromLegacy().

◆ EigenVector3iVectorToTensor()

core::Tensor cloudViewer::core::eigen_converter::EigenVector3iVectorToTensor ( const std::vector< Eigen::Vector3i > &  values,
core::Dtype  dtype,
const core::Device device 
)

Converts a vector of Eigen::Vector3i to a (N, 3) tensor. This function also takes care of dtype conversion and device transfer if necessary.

Parameters
valuesA vector of Eigen::Vector3i values, e.g. a list of 3D points.
dtypeDtype of the output tensor.
deviceDevice of the output tensor.
Returns
A tensor of shape (N, 3) with the specified dtype and device.

Definition at line 179 of file EigenConverter.cpp.

References EigenVectorNxVectorToTensor().

Referenced by cloudViewer::t::geometry::TriangleMesh::FromLegacy().

◆ EigenVectorNxVectorToTensor()

template<typename T , int N>
static core::Tensor cloudViewer::core::eigen_converter::EigenVectorNxVectorToTensor ( const std::vector< Eigen::Matrix< T, N, 1 >> &  values,
core::Dtype  dtype,
const core::Device device 
)
static

◆ LaunchIndexFillKernel()

template<typename func_t >
static void cloudViewer::core::eigen_converter::LaunchIndexFillKernel ( const Indexer indexer,
const func_t &  func 
)
static

Fills tensor[:][i] with func(i).

Parameters
indexerThe input tensor and output tensor to the indexer are the same (as a hack), since the tensor are filled in-place.
funcA function that takes pointer location and workload index i, computes the value to fill, and fills the value at the pointer location.

Definition at line 28 of file EigenConverter.cpp.

References indexer, and cloudViewer::core::ParallelFor().

Referenced by EigenVectorNxVectorToTensor().

◆ TensorToEigenMatrix()

template<typename T >
static Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> cloudViewer::core::eigen_converter::TensorToEigenMatrix ( const core::Tensor tensor)
static

◆ TensorToEigenMatrixXd()

Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > cloudViewer::core::eigen_converter::TensorToEigenMatrixXd ( const core::Tensor tensor)

Converts a 2D tensor to Eigen::MatrixXd of same shape. Regardless of the tensor dtype, the output will be converted to double.

Parameters
tensorA 2D tensor.
Returns
Eigen::MatrixXd.

Definition at line 67 of file EigenConverter.cpp.

Referenced by cloudViewer::t::geometry::OrientedBoundingBox::ToLegacy().

◆ TensorToEigenMatrixXf()

Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > cloudViewer::core::eigen_converter::TensorToEigenMatrixXf ( const core::Tensor tensor)

Converts a 2D tensor to Eigen::MatrixXf of same shape. Regardless of the tensor dtype, the output will be converted to float.

Parameters
tensorA 2D tensor.
Returns
Eigen::MatrixXf.

Definition at line 72 of file EigenConverter.cpp.

Referenced by cloudViewer::t::pipelines::slac::UpdatePoses().

◆ TensorToEigenMatrixXi()

Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > cloudViewer::core::eigen_converter::TensorToEigenMatrixXi ( const core::Tensor tensor)

Converts a 2D tensor to Eigen::MatrixXi of same shape. Regardless of the tensor dtype, the output will be converted to int.

Parameters
tensorA 2D tensor.
Returns
Eigen::MatrixXi.

Definition at line 77 of file EigenConverter.cpp.

◆ TensorToEigenVector2dVector()

std::vector< Eigen::Vector2d > cloudViewer::core::eigen_converter::TensorToEigenVector2dVector ( const core::Tensor tensor)

Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2d>. An exception will be thrown if the tensor shape is not (N, 2). Regardless of the tensor dtype, the output will be converted to double.

Parameters
tensorA tensor of shape (N, 2).
Returns
A vector of N Eigen::Vector2d values.

Definition at line 145 of file EigenConverter.cpp.

Referenced by cloudViewer::t::geometry::TriangleMesh::ToLegacy().

◆ TensorToEigenVector2iVector()

std::vector< Eigen::Vector2i > cloudViewer::core::eigen_converter::TensorToEigenVector2iVector ( const core::Tensor tensor)

Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2i>. An exception will be thrown if the tensor shape is not (N, 2). Regardless of the tensor dtype, the output will be converted to int.

Parameters
tensorA tensor of shape (N, 2).
Returns
A vector of N Eigen::Vector2i values.

Definition at line 160 of file EigenConverter.cpp.

Referenced by cloudViewer::t::geometry::LineSet::ToLegacy().

◆ TensorToEigenVector3dVector()

std::vector< Eigen::Vector3d > cloudViewer::core::eigen_converter::TensorToEigenVector3dVector ( const core::Tensor tensor)

Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3d>. An exception will be thrown if the tensor shape is not (N, 3). Regardless of the tensor dtype, the output will be converted to double.

Parameters
tensorA tensor of shape (N, 3).
Returns
A vector of N Eigen::Vector3d values.

Definition at line 150 of file EigenConverter.cpp.

Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), cloudViewer::t::geometry::OrientedBoundingBox::CreateFromPoints(), cloudViewer::t::geometry::AxisAlignedBoundingBox::ToLegacy(), cloudViewer::t::geometry::OrientedBoundingBox::ToLegacy(), cloudViewer::t::geometry::LineSet::ToLegacy(), cloudViewer::t::geometry::PointCloud::ToLegacy(), and cloudViewer::t::geometry::TriangleMesh::ToLegacy().

◆ TensorToEigenVector3iVector()

std::vector< Eigen::Vector3i > cloudViewer::core::eigen_converter::TensorToEigenVector3iVector ( const core::Tensor tensor)

Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3i>. An exception will be thrown if the tensor shape is not (N, 3). Regardless of the tensor dtype, the output will be converted to int.

Parameters
tensorA tensor of shape (N, 3).
Returns
A vector of N Eigen::Vector3i values.

Definition at line 155 of file EigenConverter.cpp.

Referenced by cloudViewer::t::pipelines::slac::ControlGrid::Compactify(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), and cloudViewer::t::geometry::TriangleMesh::ToLegacy().

◆ TensorToEigenVectorNxVector()