![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
A LineSet contains points and lines joining them and optionally attributes on the points and lines. More...
#include <LineSet.h>
Public Member Functions | |
| LineSet (const core::Device &device=core::Device("CPU:0")) | |
| Construct an empty LineSet on the provided device. More... | |
| LineSet (const core::Tensor &point_positions, const core::Tensor &line_indices) | |
| virtual | ~LineSet () override |
| LineSet | To (const core::Device &device, bool copy=false) const |
| LineSet | Clone () const |
| Returns copy of the line set on the same device. More... | |
| std::string | ToString () const |
| Text description. More... | |
| const TensorMap & | GetPointAttr () const |
| Getter for point_attr_ TensorMap. Used in Pybind. More... | |
| TensorMap & | GetPointAttr () |
| Getter for point_attr_ TensorMap. More... | |
| core::Tensor & | GetPointAttr (const std::string &key) |
| core::Tensor & | GetPointPositions () |
| const TensorMap & | GetLineAttr () const |
| Getter for line_attr_ TensorMap. Used in Pybind. More... | |
| TensorMap & | GetLineAttr () |
| Getter for line_attr_ TensorMap. More... | |
| core::Tensor & | GetLineAttr (const std::string &key) |
| core::Tensor & | GetLineIndices () |
| core::Tensor & | GetLineColors () |
| const core::Tensor & | GetPointAttr (const std::string &key) const |
| void | RemovePointAttr (const std::string &key) |
| const core::Tensor & | GetPointPositions () const |
| const core::Tensor & | GetLineAttr (const std::string &key) const |
| void | RemoveLineAttr (const std::string &key) |
| const core::Tensor & | GetLineIndices () const |
| const core::Tensor & | GetLineColors () const |
| void | SetPointAttr (const std::string &key, const core::Tensor &value) |
| void | SetPointPositions (const core::Tensor &value) |
| void | SetLineAttr (const std::string &key, const core::Tensor &value) |
| void | SetLineIndices (const core::Tensor &value) |
| Set the value of the "indices" attribute in line_attr_. More... | |
| void | SetLineColors (const core::Tensor &value) |
| bool | HasPointAttr (const std::string &key) const |
| bool | HasPointPositions () const |
| bool | HasLineAttr (const std::string &key) const |
| bool | HasLineIndices () const |
| bool | HasLineColors () const |
| LineSet & | Clear () override |
| Clear all data in the line set. More... | |
| bool | IsEmpty () const override |
| Returns !HasPointPositions(), line indices are ignored. More... | |
| core::Tensor | GetMinBound () const |
| Returns the max bound for point coordinates. More... | |
| core::Tensor | GetMaxBound () const |
| Returns the max bound for point coordinates. More... | |
| core::Tensor | GetCenter () const |
| Returns the center for point coordinates. More... | |
| LineSet & | Transform (const core::Tensor &transformation) |
| Transforms the points and lines of the LineSet. More... | |
| LineSet & | Translate (const core::Tensor &translation, bool relative=true) |
| Translates the points and lines of the LineSet. More... | |
| LineSet & | Scale (double scale, const core::Tensor ¢er) |
| Scales the points and lines of the LineSet. More... | |
| LineSet & | Rotate (const core::Tensor &R, const core::Tensor ¢er) |
| Rotates the points and lines of the line set. Custom attributes (e.g.: point or line normals) are not transformed. More... | |
| LineSet & | PaintUniformColor (const core::Tensor &color) |
| Assigns uniform color to all lines of the LineSet. More... | |
| core::Device | GetDevice () const override |
| Returns the device attribute of this LineSet. More... | |
| cloudViewer::geometry::LineSet | ToLegacy () const |
| Convert to a legacy CloudViewer LineSet. More... | |
| AxisAlignedBoundingBox | GetAxisAlignedBoundingBox () const |
| Create an axis-aligned bounding box from point attribute "positions". More... | |
| OrientedBoundingBox | GetOrientedBoundingBox () const |
| Create an oriented bounding box from point attribute "positions". More... | |
| TriangleMesh | ExtrudeRotation (double angle, const core::Tensor &axis, int resolution=16, double translation=0.0, bool capping=true) const |
| TriangleMesh | ExtrudeLinear (const core::Tensor &vector, double scale=1.0, bool capping=true) const |
Public Member Functions inherited from cloudViewer::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... | |
| std::string | GetName () const |
| void | SetName (const std::string &name) |
Public Member Functions inherited from cloudViewer::core::IsDevice | |
| IsDevice ()=default | |
| virtual | ~IsDevice ()=default |
| bool | IsCPU () const |
| bool | IsCUDA () const |
| bool | IsSYCL () const |
Public Member Functions inherited from cloudViewer::t::geometry::DrawableGeometry | |
| 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::LineSet | FromLegacy (const cloudViewer::geometry::LineSet &lineset_legacy, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0")) |
| static LineSet | CreateCameraVisualization (int view_width_px, int view_height_px, const core::Tensor &intrinsic, const core::Tensor &extrinsic, double scale, const core::Tensor &color={}) |
Protected Attributes | |
| core::Device | device_ = core::Device("CPU:0") |
| TensorMap | point_attr_ |
| TensorMap | line_attr_ |
Additional Inherited Members | |
Public Types inherited from cloudViewer::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 cloudViewer::t::geometry::Geometry | |
| Geometry (GeometryType type, int dimension) | |
| Parameterized Constructor. More... | |
A LineSet contains points and lines joining them and optionally attributes on the points and lines.
The LineSet 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 Tensor containing the attribute data.
By default, there are two sets of dictionaries: point_attr_ and line_attr_. In most cases, the length of an attribute should be equal to the length of the data corresponding to the primary key. For instance, point_attr_["colors"] should have the same length as point_attr_["positions"].
Although the attributes are all stored in a key-value pair dictionary, the attributes have different levels:
Note that {Get|Set|Has}{Point|Line}Attr() functions also work "positions" and "indices".
| cloudViewer::t::geometry::LineSet::LineSet | ( | const core::Device & | device = core::Device("CPU:0") | ) |
Construct an empty LineSet on the provided device.
| cloudViewer::t::geometry::LineSet::LineSet | ( | const core::Tensor & | point_positions, |
| const core::Tensor & | line_indices | ||
| ) |
Construct a LineSet from points and lines.
The input tensors will be directly used as the underlying storage of the line set (no memory copy). If the tensor is created in-place from a pre-allocated buffer, the tensor has a fixed size and thus the resulting LineSet will have a fixed size and calling to functions like SynchronizedPushBack will raise an exception.
The resulting LineSet will have the same dtype and device as the tensor. The device for points must be consistent with lines.
| point_positions | A tensor with element shape {3}. |
| line_indices | A tensor with element shape {2} and Int DtypeCode. |
References AssertTensorDevice, and cloudViewer::core::Tensor::GetDevice().
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Clear all data in the line set.
Implements cloudViewer::t::geometry::Geometry.
References line_attr_, and point_attr_.
|
inline |
Returns copy of the line set on the same device.
References GetDevice(), and To().
|
static |
Factory function to create a LineSet from intrinsic and extrinsic matrices.
| view_width_px | The width of the view, in pixels. |
| view_height_px | The height of the view, in pixels. |
| intrinsic | The intrinsic matrix {3,3} shape. |
| extrinsic | The extrinsic matrix {4,4} shape. |
| scale | camera scale |
| color | tensor with float32 dtype and shape {3}. Default is blue. |
References AssertTensorShape, color, cloudViewer::core::Float32, points, cloudViewer::core::Tensor::Slice(), and cloudViewer::core::Tensor::To().
| TriangleMesh cloudViewer::t::geometry::LineSet::ExtrudeLinear | ( | const core::Tensor & | vector, |
| double | scale = 1.0, |
||
| bool | capping = true |
||
| ) | const |
Sweeps the line set along a direction vector.
| vector | The direction vector. |
| scale | Scalar factor which essentially scales the direction vector. |
| capping | If true adds caps to the mesh. |
References cloudViewer::t::geometry::vtkutils::ExtrudeLinearTriangleMesh().
| TriangleMesh cloudViewer::t::geometry::LineSet::ExtrudeRotation | ( | double | angle, |
| const core::Tensor & | axis, | ||
| int | resolution = 16, |
||
| double | translation = 0.0, |
||
| bool | capping = true |
||
| ) | const |
Sweeps the line set rotationally about an axis.
| angle | The rotation angle in degree. |
| axis | The rotation axis. |
| resolution | The resolution defines the number of intermediate sweeps about the rotation axis. |
| translation | The translation along the rotation axis. |
| capping | If true adds caps to the mesh. |
References cloudViewer::t::geometry::vtkutils::ExtrudeRotationTriangleMesh().
|
static |
Create a LineSet from a legacy CloudViewer LineSet.
| lineset_legacy | Legacy CloudViewer LineSet. |
| float_dtype | Float32 or Float64, used to store floating point values, e.g. points, normals, colors. |
| int_dtype | Int32 or Int64, used to store index values, e.g. line indices. |
| device | The device where the resulting LineSet resides. |
References cloudViewer::geometry::LineSet::colors_, cloudViewer::core::eigen_converter::EigenVector2iVectorToTensor(), cloudViewer::core::eigen_converter::EigenVector3dVectorToTensor(), cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::geometry::LineSet::HasColors(), cloudViewer::geometry::LineSet::HasLines(), cloudViewer::geometry::LineSet::HasPoints(), cloudViewer::core::Int32, cloudViewer::core::Int64, cloudViewer::geometry::LineSet::lines_, LogError, LogWarning, cloudViewer::geometry::LineSet::points_, SetLineColors(), SetLineIndices(), SetPointPositions(), and cloudViewer::core::Dtype::ToString().
| AxisAlignedBoundingBox cloudViewer::t::geometry::LineSet::GetAxisAlignedBoundingBox | ( | ) | const |
Create an axis-aligned bounding box from point attribute "positions".
References cloudViewer::t::geometry::AxisAlignedBoundingBox::CreateFromPoints(), and GetPointPositions().
|
inline |
Returns the center for point coordinates.
References GetPointPositions(), and cloudViewer::core::Tensor::Mean().
Referenced by Translate().
|
inlineoverridevirtual |
Returns the device attribute of this LineSet.
Implements cloudViewer::t::geometry::Geometry.
References device_.
Referenced by Clone(), PaintUniformColor(), Scale(), To(), ToString(), and Translate().
|
inline |
Getter for line_attr_ TensorMap.
References line_attr_.
|
inline |
Getter for line_attr_ TensorMap. Used in Pybind.
References line_attr_.
Referenced by cloudViewer::t::geometry::vtkutils::CreateLineSetFromVtkPolyData(), cloudViewer::io::rpc::GeometryToMeshData(), GetLineColors(), GetLineIndices(), and HasLineAttr().
|
inline |
Get line attributes in line_attr_. Throws exception if the attribute does not exist.
| key | Attribute name. |
References line_attr_.
|
inline |
Get line attributes in line_attr_. Throws exception if the attribute does not exist.
| key | Attribute name. |
References line_attr_.
|
inline |
Get the value of the "colors" attribute in line_attr_. Convenience function.
References GetLineAttr().
Referenced by cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), and ToLegacy().
|
inline |
Get the value of the "colors" attribute in line_attr_. Convenience function.
References GetLineAttr().
|
inline |
Get the value of the "indices" attribute in line_attr_. Convenience function.
References GetLineAttr().
Referenced by HasLineAttr(), PaintUniformColor(), cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), ToLegacy(), and ToString().
|
inline |
Get the value of the "indices" attribute in line_attr_. Convenience function.
References GetLineAttr().
|
inline |
Returns the max bound for point coordinates.
References GetPointPositions(), and cloudViewer::core::Tensor::Max().
Referenced by cloudViewer::visualization::rendering::TLineSetBuffersBuilder::ComputeAABB().
|
inline |
Returns the max bound for point coordinates.
References GetPointPositions(), and cloudViewer::core::Tensor::Min().
Referenced by cloudViewer::visualization::rendering::TLineSetBuffersBuilder::ComputeAABB().
| OrientedBoundingBox cloudViewer::t::geometry::LineSet::GetOrientedBoundingBox | ( | ) | const |
Create an oriented bounding box from point attribute "positions".
References cloudViewer::t::geometry::OrientedBoundingBox::CreateFromPoints(), and GetPointPositions().
|
inline |
Getter for point_attr_ TensorMap.
References point_attr_.
|
inline |
Getter for point_attr_ TensorMap. Used in Pybind.
References point_attr_.
Referenced by cloudViewer::t::geometry::vtkutils::CreateLineSetFromVtkPolyData(), cloudViewer::io::rpc::GeometryToMeshData(), GetPointPositions(), and HasPointAttr().
|
inline |
Get point attributes in point_attr_. Throws exception if the attribute does not exist.
| key | Attribute name. |
References point_attr_.
|
inline |
Get point attributes. Throws exception if the attribute does not exist.
| key | Attribute name. |
References point_attr_.
|
inline |
Get the value of the "positions" attribute in point_attr_. Convenience function.
References GetPointAttr().
Referenced by GetAxisAlignedBoundingBox(), GetCenter(), GetMaxBound(), GetMinBound(), GetOrientedBoundingBox(), HasPointAttr(), Rotate(), Scale(), cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), ToLegacy(), ToString(), Transform(), and Translate().
|
inline |
Get the value of the "positions" attribute in point_attr_. Convenience function.
References GetPointAttr().
|
inline |
Returns true if all of the following are true in line_attr_: 1) attribute key exist 2) attribute's length as "indices"'s length 3) attribute's length > 0
References cloudViewer::t::geometry::TensorMap::Contains(), cloudViewer::core::Tensor::GetLength(), GetLineAttr(), GetLineIndices(), and line_attr_.
Referenced by HasLineColors(), and HasLineIndices().
|
inline |
Returns true if all of the following are true in line_attr_: 1) attribute "colors" exist 2) attribute "colors"'s length as "indices"'s length 3) attribute "colors"'s length > 0 Convenience function.
References HasLineAttr().
Referenced by cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), and ToLegacy().
|
inline |
Check if the "indices" attribute's value in line_attr_ has length > 0. Convenience function.
References HasLineAttr().
Referenced by cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), and ToLegacy().
|
inline |
Returns true if all of the following are true in point_attr_: 1) attribute key exist 2) attribute's length as "points"'s length 3) attribute's length > 0
References cloudViewer::t::geometry::TensorMap::Contains(), cloudViewer::core::Tensor::GetLength(), GetPointAttr(), GetPointPositions(), and point_attr_.
Referenced by HasPointPositions().
|
inline |
Check if the "positions" attribute's value in point_attr_ has length > 0. Convenience function.
References HasPointAttr().
Referenced by IsEmpty(), and ToLegacy().
|
inlineoverridevirtual |
Returns !HasPointPositions(), line indices are ignored.
Implements cloudViewer::t::geometry::Geometry.
References HasPointPositions().
| LineSet & cloudViewer::t::geometry::LineSet::PaintUniformColor | ( | const core::Tensor & | color | ) |
Assigns uniform color to all lines of the LineSet.
| color | RGB color for the LineSet. {3,} shaped Tensor. Floating color values are clipped between 0.0 and 1.0. |
References cloudViewer::core::Tensor::AsRvalue(), AssertTensorShape, color, cloudViewer::core::Tensor::Empty(), cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::core::Tensor::GetLength(), GetLineIndices(), and SetLineColors().
|
inline |
Removes line attribute by key value. Primary attribute "indices" cannot be removed. Throws warning if attribute key does not exists.
| key | Attribute name. |
References cloudViewer::t::geometry::TensorMap::Erase(), and line_attr_.
|
inline |
Removes point attribute by key value. Primary attribute "positions" cannot be removed. Throws warning if attribute key does not exists.
| key | Attribute name. |
References cloudViewer::t::geometry::TensorMap::Erase(), and point_attr_.
| LineSet & cloudViewer::t::geometry::LineSet::Rotate | ( | const core::Tensor & | R, |
| const core::Tensor & | center | ||
| ) |
Rotates the points and lines of the line set. Custom attributes (e.g.: point or line normals) are not transformed.
| R | Rotation [Tensor of shape {3,3}]. |
| center | Center [Tensor of shape {3}] about which the LineSet is to be scaled. |
References AssertTensorShape, GetPointPositions(), and cloudViewer::t::geometry::kernel::transform::RotatePoints().
| LineSet & cloudViewer::t::geometry::LineSet::Scale | ( | double | scale, |
| const core::Tensor & | center | ||
| ) |
Scales the points and lines of the LineSet.
| scale | Scale magnitude. |
| center | Center [Tensor of shape {3}] about which the LineSet is |
References cloudViewer::core::Tensor::Add_(), AssertTensorShape, GetDevice(), GetPointPositions(), cloudViewer::core::Tensor::Mul_(), cloudViewer::core::Tensor::Sub_(), and cloudViewer::core::Tensor::To().
|
inline |
Set line 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. |
References AssertTensorDevice, device_, and line_attr_.
Referenced by SetLineColors(), SetLineIndices(), and To().
|
inline |
Set the value of the "colors" attribute in line_attr_. This is a convenience function.
References AssertTensorShape, cloudViewer::utility::nullopt, and SetLineAttr().
Referenced by FromLegacy(), and PaintUniformColor().
|
inline |
Set the value of the "indices" attribute in line_attr_.
References AssertTensorShape, cloudViewer::utility::nullopt, and SetLineAttr().
Referenced by FromLegacy().
|
inline |
Set point 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. |
References AssertTensorDevice, device_, and point_attr_.
Referenced by SetPointPositions(), and To().
|
inline |
Set the value of the "positions" attribute in point_attr_. Convenience function.
References AssertTensorShape, cloudViewer::utility::nullopt, and SetPointAttr().
Referenced by FromLegacy().
| LineSet cloudViewer::t::geometry::LineSet::To | ( | const core::Device & | device, |
| bool | copy = false |
||
| ) | const |
Transfer the line set to a specified device.
| device | The targeted device to convert to. |
| copy | If true, a new line set is always created; if false, the copy is avoided when the original line set is already on the targeted device. |
References copy, GetDevice(), line_attr_, point_attr_, SetLineAttr(), and SetPointAttr().
Referenced by Clone(), and cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder().
| cloudViewer::geometry::LineSet cloudViewer::t::geometry::LineSet::ToLegacy | ( | ) | const |
Convert to a legacy CloudViewer LineSet.
References cloudViewer::geometry::LineSet::colors_, GetLineColors(), GetLineIndices(), GetPointPositions(), HasLineColors(), HasLineIndices(), HasPointPositions(), cloudViewer::geometry::LineSet::lines_, cloudViewer::geometry::LineSet::points_, cloudViewer::core::eigen_converter::TensorToEigenVector2iVector(), and cloudViewer::core::eigen_converter::TensorToEigenVector3dVector().
| std::string cloudViewer::t::geometry::LineSet::ToString | ( | ) | const |
Text description.
References format, GetDevice(), GetLineIndices(), GetPointPositions(), line_attr_, and point_attr_.
| LineSet & cloudViewer::t::geometry::LineSet::Transform | ( | const core::Tensor & | transformation | ) |
Transforms the points and lines of the LineSet.
Custom attributes (e.g.: point or line normals) are not transformed.
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 shape {4,4}]. |
References AssertTensorShape, GetPointPositions(), and cloudViewer::t::geometry::kernel::transform::TransformPoints().
| LineSet & cloudViewer::t::geometry::LineSet::Translate | ( | const core::Tensor & | translation, |
| bool | relative = true |
||
| ) |
Translates the points and lines of the LineSet.
| translation | Translation tensor of shape {3} |
| relative | If true (default) translates relative to center of LineSet. |
References AssertTensorShape, GetCenter(), GetDevice(), GetPointPositions(), and cloudViewer::core::Tensor::To().
|
protected |
Referenced by GetDevice(), SetLineAttr(), and SetPointAttr().
|
protected |
Referenced by Clear(), GetLineAttr(), HasLineAttr(), RemoveLineAttr(), SetLineAttr(), To(), and ToString().
|
protected |
Referenced by Clear(), GetPointAttr(), HasPointAttr(), RemovePointAttr(), SetPointAttr(), To(), and ToString().