ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::t::geometry::vtkutils Namespace Reference

Classes

struct  VtkToTensorType
 
struct  VtkToTensorType< long long >
 

Functions

int DtypeToVtkType (const core::Dtype &dtype)
 
static core::Tensor CreateTensorFromVtkDataArray (vtkDataArray *array, bool copy=false)
 
static vtkSmartPointer< vtkDataArray > CreateVtkDataArrayFromTensor (core::Tensor &tensor, bool copy)
 
static vtkSmartPointer< vtkPoints > CreateVtkPointsFromTensor (core::Tensor &tensor, bool copy=false)
 
CLOUDVIEWER_LOCAL vtkSmartPointer< vtkImageData > CreateVtkImageDataFromTensor (core::Tensor &tensor, bool copy)
 
static vtkSmartPointer< vtkCellArray > CreateVtkCellArrayFromTensor (core::Tensor &tensor, bool copy=false)
 
static core::Tensor CreateTensorFromVtkCellArray (vtkCellArray *cells, bool copy=false)
 
static void AddVtkFieldDataToTensorMap (TensorMap &tmap, vtkFieldData *field_data, bool copy)
 
static void AddTensorMapToVtkFieldData (vtkFieldData *field_data, TensorMap &tmap, bool copy, std::unordered_set< std::string > include, std::unordered_set< std::string > exclude={})
 
vtkSmartPointer< vtkPolyData > CreateVtkPolyDataFromGeometry (const Geometry &geometry, const std::unordered_set< std::string > &point_attr_include, const std::unordered_set< std::string > &face_attr_include, const std::unordered_set< std::string > &point_attr_exclude, const std::unordered_set< std::string > &face_attr_exclude, bool copy)
 
TriangleMesh CreateTriangleMeshFromVtkPolyData (vtkPolyData *polydata, bool copy)
 
CLOUDVIEWER_LOCAL LineSet CreateLineSetFromVtkPolyData (vtkPolyData *polydata, bool copy)
 
static vtkSmartPointer< vtkPolyData > ExtrudeRotationPolyData (const Geometry &geometry, const double angle, const core::Tensor &axis, int resolution, double translation, bool capping)
 
CLOUDVIEWER_LOCAL TriangleMesh ExtrudeRotationTriangleMesh (const Geometry &geometry, const double angle, const core::Tensor &axis, int resolution, double translation, bool capping)
 
CLOUDVIEWER_LOCAL LineSet ExtrudeRotationLineSet (const PointCloud &pointcloud, const double angle, const core::Tensor &axis, int resolution, double translation, bool capping)
 
static vtkSmartPointer< vtkPolyData > ExtrudeLinearPolyData (const Geometry &geometry, const core::Tensor &vector, double scale, bool capping)
 
CLOUDVIEWER_LOCAL TriangleMesh ExtrudeLinearTriangleMesh (const Geometry &geometry, const core::Tensor &vector, double scale, bool capping)
 
CLOUDVIEWER_LOCAL LineSet ExtrudeLinearLineSet (const PointCloud &pointcloud, const core::Tensor &vector, double scale, bool capping)
 
CLOUDVIEWER_LOCAL TriangleMesh ComputeNormals (const TriangleMesh &mesh, bool vertex_normals, bool face_normals, bool consistency, bool auto_orient_normals, bool splitting, double feature_angle_deg)
 

Function Documentation

◆ AddTensorMapToVtkFieldData()

static void cloudViewer::t::geometry::vtkutils::AddTensorMapToVtkFieldData ( vtkFieldData *  field_data,
TensorMap tmap,
bool  copy,
std::unordered_set< std::string >  include,
std::unordered_set< std::string >  exclude = {} 
)
static

Adds attribute tensors to vtkFieldData. Primary key tensors will be ignored by this function.

Parameters
field_dataThe destination vtkFieldData.
tmapThe source TensorMap.
copyIf true always create a copy for attribute arrays.
includeA set of keys to select which attributes should be added.
excludeA set of keys for which attributes will not be added to the vtkFieldData. The exclusion set has precedence over the included keys.

Definition at line 332 of file VtkUtils.cpp.

Referenced by CreateVtkPolyDataFromGeometry().

◆ AddVtkFieldDataToTensorMap()

static void cloudViewer::t::geometry::vtkutils::AddVtkFieldDataToTensorMap ( TensorMap tmap,
vtkFieldData *  field_data,
bool  copy 
)
static

Adds point or cell attribute arrays to a TensorMap.

Parameters
tmapThe destination TensorMap.
field_dataThe source vtkFieldData.
copyIf true always create a copy for attribute arrays.

Definition at line 312 of file VtkUtils.cpp.

References copy, and CreateTensorFromVtkDataArray().

Referenced by CreateLineSetFromVtkPolyData(), and CreateTriangleMeshFromVtkPolyData().

◆ ComputeNormals()

TriangleMesh cloudViewer::t::geometry::vtkutils::ComputeNormals ( const TriangleMesh mesh,
bool  vertex_normals,
bool  face_normals,
bool  consistency,
bool  auto_orient_normals,
bool  splitting,
double  feature_angle_deg = 30 
)

Computes the normals for a mesh. In addition to computing the normals this function can fix the face vertex order and orient the normals to point outwards. This function can be applied to non-manifold or non-closed meshes but without any guarantees to correctness or quality for the result.

Parameters
meshA point cloud.
vertex_normalsIf true compute the vertex normals.
face_normalsIf true compute the face normals.
consistencyIf true the algorithm fixes the vertex order of faces.
auto_orient_normalsIf true normals will be flipped to point outwards
splittingIf true allows splitting of edges to account for sharp edges. Splitting an edge will create new vertices.
feature_angle_degThe angle in degrees that defines sharp edges for splitting.
Returns
A new mesh with the computed normals.

Definition at line 596 of file VtkUtils.cpp.

References CreateTriangleMeshFromVtkPolyData(), CreateVtkPolyDataFromGeometry(), cloudViewer::t::geometry::TensorMap::GetKeySet(), cloudViewer::t::geometry::TriangleMesh::GetVertexAttr(), and normals.

◆ CreateLineSetFromVtkPolyData()

LineSet cloudViewer::t::geometry::vtkutils::CreateLineSetFromVtkPolyData ( vtkPolyData *  polydata,
bool  copy = false 
)

Creates a LineSet a vtkPolyData object. The returned LineSet may directly use the memory of the data arrays in the vtkPolyData object. The returned LineSet will hold references to the arrays and it is not necessary to keep other references to the vtkPolyData object or its arrays alive.

Parameters
polydataInput polyData object.
copyIf true always create a copy of the data.

Definition at line 473 of file VtkUtils.cpp.

References AddVtkFieldDataToTensorMap(), copy, CreateTensorFromVtkCellArray(), CreateTensorFromVtkDataArray(), cloudViewer::t::geometry::LineSet::GetLineAttr(), cloudViewer::t::geometry::LineSet::GetPointAttr(), cloudViewer::core::Tensor::GetShape(), and cloudViewer::core::Tensor::Reshape().

Referenced by ExtrudeLinearLineSet(), ExtrudeRotationLineSet(), and cloudViewer::t::geometry::TriangleMesh::SlicePlane().

◆ CreateTensorFromVtkCellArray()

static core::Tensor cloudViewer::t::geometry::vtkutils::CreateTensorFromVtkCellArray ( vtkCellArray *  cells,
bool  copy = false 
)
static

Creates a tensor from a vtkCellArray. The returned Tensor may directly use the memory of the array if device (CPU) and memory layout are compatible. The returned Tensor will hold a reference to the array and it is not necessary to keep other references to the array alive. Note that cell arrays with varying cell sizes cannot be converted and the function will throw an exception.

Parameters
arrayThe source array.
copyIf true always create a copy of the data.

Definition at line 283 of file VtkUtils.cpp.

References copy, CreateTensorFromVtkDataArray(), LogError, and result.

Referenced by CreateLineSetFromVtkPolyData(), and CreateTriangleMeshFromVtkPolyData().

◆ CreateTensorFromVtkDataArray()

static core::Tensor cloudViewer::t::geometry::vtkutils::CreateTensorFromVtkDataArray ( vtkDataArray *  array,
bool  copy = false 
)
static

Creates a tensor from a vtkDataArray. The returned Tensor may directly use the memory of the array if device (CPU) and memory layout are compatible. The returned Tensor will hold a reference to the array and it is not necessary to keep other references to the array alive.

Parameters
arrayThe source array.
copyIf true always create a copy of the data.

Definition at line 122 of file VtkUtils.cpp.

References copy, and Execute().

Referenced by AddVtkFieldDataToTensorMap(), CreateLineSetFromVtkPolyData(), CreateTensorFromVtkCellArray(), CreateTriangleMeshFromVtkPolyData(), and CreateVtkDataArrayFromTensor().

◆ CreateTriangleMeshFromVtkPolyData()

TriangleMesh cloudViewer::t::geometry::vtkutils::CreateTriangleMeshFromVtkPolyData ( vtkPolyData *  polydata,
bool  copy = false 
)

◆ CreateVtkCellArrayFromTensor()

static vtkSmartPointer<vtkCellArray> cloudViewer::t::geometry::vtkutils::CreateVtkCellArrayFromTensor ( core::Tensor tensor,
bool  copy = false 
)
static

Creates a vtkCellArray from a Tensor. The returned array may directly use the memory of the tensor and the tensor must be kept alive until the returned vtkPoints is deleted.

Parameters
tensorThe source tensor.
copyIf true always create a copy of the data.

Definition at line 237 of file VtkUtils.cpp.

References AssertTensorDtypes, AssertTensorShape, copy, CreateVtkDataArrayFromTensor(), Execute(), cloudViewer::core::Tensor::GetDataPtr(), cloudViewer::core::Tensor::GetShape(), cloudViewer::core::Int32, cloudViewer::core::Int64, cloudViewer::core::None, cloudViewer::core::Tensor::NumElements(), and cloudViewer::core::Tensor::Reshape().

Referenced by CreateVtkPolyDataFromGeometry().

◆ CreateVtkDataArrayFromTensor()

static vtkSmartPointer<vtkDataArray> cloudViewer::t::geometry::vtkutils::CreateVtkDataArrayFromTensor ( core::Tensor tensor,
bool  copy 
)
static

Creates a vtkDataArray from a Tensor. The returned array may directly use the memory of the tensor and the tensor must be kept alive until the returned vtkDataArray is deleted.

Parameters
tensorThe source tensor.
copyIf true always create a copy of the data.

Definition at line 138 of file VtkUtils.cpp.

References AssertTensorShape, cloudViewer::core::Bool, copy, CreateTensorFromVtkDataArray(), data_array, DtypeToVtkType(), cloudViewer::core::Tensor::GetDataPtr(), cloudViewer::core::Tensor::GetDevice(), cloudViewer::core::Tensor::GetDtype(), cloudViewer::core::Tensor::GetShape(), cloudViewer::core::Tensor::IsContiguous(), LogError, cloudViewer::core::None, and cloudViewer::core::Tensor::NumElements().

Referenced by CreateVtkCellArrayFromTensor(), CreateVtkImageDataFromTensor(), and CreateVtkPointsFromTensor().

◆ CreateVtkImageDataFromTensor()

vtkSmartPointer< vtkImageData > cloudViewer::t::geometry::vtkutils::CreateVtkImageDataFromTensor ( core::Tensor tensor,
bool  copy = false 
)

Creates a vtkImageData object from a Tensor. The returned object may directly use the memory of the tensor and the tensor must be kept alive until the returned vtkImageData is deleted.

Parameters
tensorThe source tensor.
copyIf true always create a copy of the data.

Definition at line 186 of file VtkUtils.cpp.

References AssertTensorDtypes, copy, CreateVtkDataArrayFromTensor(), data_array, cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::core::Tensor::GetDataPtr(), cloudViewer::core::Tensor::GetShape(), LogError, cloudViewer::core::Tensor::NumDims(), cloudViewer::core::Tensor::NumElements(), cloudViewer::core::Tensor::Reshape(), size, and cloudViewer::core::UInt8.

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

◆ CreateVtkPointsFromTensor()

static vtkSmartPointer<vtkPoints> cloudViewer::t::geometry::vtkutils::CreateVtkPointsFromTensor ( core::Tensor tensor,
bool  copy = false 
)
static

Creates a vtkPoints object from a Tensor. The returned array may directly use the memory of the tensor and the tensor must be kept alive until the returned vtkPoints is deleted.

Parameters
tensorThe source tensor.
copyIf true always create a copy of the data.

Definition at line 175 of file VtkUtils.cpp.

References AssertTensorDtypes, AssertTensorShape, copy, CreateVtkDataArrayFromTensor(), data_array, cloudViewer::core::Float32, cloudViewer::core::Float64, and cloudViewer::core::None.

Referenced by CreateVtkPolyDataFromGeometry().

◆ CreateVtkPolyDataFromGeometry()

vtkSmartPointer< vtkPolyData > cloudViewer::t::geometry::vtkutils::CreateVtkPolyDataFromGeometry ( const Geometry geometry,
const std::unordered_set< std::string > &  point_attr_include,
const std::unordered_set< std::string > &  face_attr_include,
const std::unordered_set< std::string > &  point_attr_exclude = {},
const std::unordered_set< std::string > &  face_attr_exclude = {},
bool  copy = false 
)

Creates a vtkPolyData object from a point cloud or triangle mesh. The returned vtkPolyData object may directly use the memory of the tensors stored inside the Geometry object. Therefore, the Geometry object must be kept alive until the returned vtkPolyData object is deleted.

Parameters
geometryCloudViewer geometry object, e.g., a TriangleMesh.
copyIf true always create a copy of the data.
point_attr_includeA set of keys to select which point/vertex attributes should be added. Note that the primary key may be included and will silently be ignored.
face_attr_includeA set of keys to select which face attributes should be added. Note that the primary key may be included and will silently be ignored.
point_attr_excludeA set of keys for which point/vertex attributes will not be added to the vtkPolyData. The exclusion set has precedence over the included keys.
face_attr_excludeA set of keys for which face attributes will not be added to the vtkPolyData. The exclusion set has precedence over the included keys.

Definition at line 369 of file VtkUtils.cpp.

References AddTensorMapToVtkFieldData(), copy, CreateVtkCellArrayFromTensor(), CreateVtkPointsFromTensor(), cloudViewer::t::geometry::Geometry::GetGeometryType(), cloudViewer::t::geometry::Geometry::LineSet, LogError, cloudViewer::t::geometry::Geometry::PointCloud, cloudViewer::t::geometry::PointCloud::SetPoints(), and cloudViewer::t::geometry::Geometry::TriangleMesh.

Referenced by cloudViewer::t::geometry::TriangleMesh::ClipPlane(), ComputeNormals(), ExtrudeLinearPolyData(), ExtrudeRotationPolyData(), cloudViewer::t::geometry::TriangleMesh::FillHoles(), cloudViewer::t::geometry::TriangleMesh::SimplifyQuadricDecimation(), and cloudViewer::t::geometry::TriangleMesh::SlicePlane().

◆ DtypeToVtkType()

◆ ExtrudeLinearLineSet()

LineSet cloudViewer::t::geometry::vtkutils::ExtrudeLinearLineSet ( const PointCloud pointcloud,
const core::Tensor vector,
double  scale,
bool  capping 
)

Sweeps the geometry along a direction vector.

Parameters
pointcloudA point cloud.
vectorThe direction vector.
scaleScalar factor which essentially scales the direction vector.
cappingIf true adds caps to the mesh.
Returns
A triangle mesh with the result of the sweep operation.

Definition at line 588 of file VtkUtils.cpp.

References CreateLineSetFromVtkPolyData(), and ExtrudeLinearPolyData().

Referenced by cloudViewer::t::geometry::PointCloud::ExtrudeLinear().

◆ ExtrudeLinearPolyData()

static vtkSmartPointer<vtkPolyData> cloudViewer::t::geometry::vtkutils::ExtrudeLinearPolyData ( const Geometry geometry,
const core::Tensor vector,
double  scale,
bool  capping 
)
static

◆ ExtrudeLinearTriangleMesh()

TriangleMesh cloudViewer::t::geometry::vtkutils::ExtrudeLinearTriangleMesh ( const Geometry geometry,
const core::Tensor vector,
double  scale,
bool  capping 
)

Sweeps the geometry along a direction vector.

Parameters
geometryCloudViewer geometry object, e.g., a TriangleMesh.
vectorThe direction vector.
scaleScalar factor which essentially scales the direction vector.
cappingIf true adds caps to the mesh.
Returns
A triangle mesh with the result of the sweep operation.

Definition at line 580 of file VtkUtils.cpp.

References CreateTriangleMeshFromVtkPolyData(), and ExtrudeLinearPolyData().

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

◆ ExtrudeRotationLineSet()

LineSet cloudViewer::t::geometry::vtkutils::ExtrudeRotationLineSet ( const PointCloud pointcloud,
double  angle,
const core::Tensor axis,
int  resolution = 16,
double  translation = 0.0,
bool  capping = true 
)

Sweeps the geometry rotationally about an axis.

Parameters
pointcloudA point cloud.
angleThe rotation angle in degree.
axisThe rotation axis.
resolutionThe resolution defines the number of intermediate sweeps about the rotation axis.
translationThe translation along the rotation axis.
cappingIf true adds caps to the mesh.
Returns
A line set with the result of the sweep operation.

Definition at line 540 of file VtkUtils.cpp.

References CreateLineSetFromVtkPolyData(), and ExtrudeRotationPolyData().

Referenced by cloudViewer::t::geometry::PointCloud::ExtrudeRotation().

◆ ExtrudeRotationPolyData()

static vtkSmartPointer<vtkPolyData> cloudViewer::t::geometry::vtkutils::ExtrudeRotationPolyData ( const Geometry geometry,
const double  angle,
const core::Tensor axis,
int  resolution,
double  translation,
bool  capping 
)
static

◆ ExtrudeRotationTriangleMesh()

TriangleMesh cloudViewer::t::geometry::vtkutils::ExtrudeRotationTriangleMesh ( const Geometry geometry,
double  angle,
const core::Tensor axis,
int  resolution = 16,
double  translation = 0.0,
bool  capping = true 
)

Sweeps the geometry rotationally about an axis.

Parameters
geometryCloudViewer geometry object, e.g., a TriangleMesh.
angleThe rotation angle in degree.
axisThe rotation axis.
resolutionThe resolution defines the number of intermediate sweeps about the rotation axis.
translationThe translation along the rotation axis.
cappingIf true adds caps to the mesh.
Returns
A triangle mesh with the result of the sweep operation.

Definition at line 529 of file VtkUtils.cpp.

References CreateTriangleMeshFromVtkPolyData(), and ExtrudeRotationPolyData().

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