48 lineset.
SetLineAttr(kv.first, kv.second.To(device,
true));
51 lineset.
SetPointAttr(kv.first, kv.second.To(device,
true));
59 str +=
"[0 points ()] Attributes: None.";
69 if (keyval.first ==
"positions")
continue;
70 str +=
fmt::format(
" {} (dtype = {}, shape = {}),", keyval.first,
71 keyval.second.GetDtype().ToString(),
72 keyval.second.GetShape().ToString());
74 str[str.size() - 1] =
'.';
77 str +=
"\n[0 lines ()] Attributes: None.";
87 if (keyval.first ==
"indices")
continue;
88 str +=
fmt::format(
" {} (dtype = {}, shape = {}),", keyval.first,
89 keyval.second.GetDtype().ToString(),
90 keyval.second.GetShape().ToString());
92 str[str.size() - 1] =
'.';
151 lineset_legacy.
points_, float_dtype, device));
158 lineset_legacy.
lines_, int_dtype, device));
165 lineset_legacy.
colors_, float_dtype, device));
187 return lineset_legacy;
198 bool capping)
const {
199 using namespace vtkutils;
201 translation, capping);
206 bool capping)
const {
207 using namespace vtkutils;
220 clipped_color = clipped_color.Clip(0.0f, 1.0f);
225 ls_colors.
AsRvalue() = clipped_color;
243 float w(view_width_px), h(view_height_px), s(scale);
244 float fx = intrinsic[0][0].Item<
float>(),
245 fy = intrinsic[1][1].Item<float>(),
246 cx = intrinsic[0][2].Item<
float>(),
247 cy = intrinsic[1][2].Item<float>();
256 {cx * s, cy * s, s}});
260 .Matmul(extrinsic.
Slice(0, 0, 3).
Slice(1, 0, 3));
277 if (
color.NumElements() == 3) {
278 lineset.PaintUniformColor(
color);
280 lineset.PaintUniformColor(core::Tensor::Init<float>({0.f, 0.f, 1.f}));
282 auto &lscolors = lineset.GetLineColors();
283 lscolors[8] = core::Tensor::Init<float>({1.f, 0.f, 0.f});
284 lscolors[9] = core::Tensor::Init<float>({0.f, 1.f, 0.f});
285 lscolors[10] = core::Tensor::Init<float>({0.f, 0.f, 1.f});
filament::Texture::InternalFormat format
#define AssertTensorDevice(tensor,...)
#define AssertTensorShape(tensor,...)
std::string ToString() const
int64_t GetLength() const
Tensor Sub_(const Tensor &value)
Tensor Mul_(const Tensor &value)
Tensor Add_(const Tensor &value)
Device GetDevice() const override
static Tensor Empty(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor with uninitialized values.
Tensor Slice(int64_t dim, int64_t start, int64_t stop, int64_t step=1) const
Tensor To(Dtype dtype, bool copy=false) const
LineSet define a sets of lines in 3D. A typical application is to display the point cloud corresponde...
bool HasColors() const
Returns true if the objects lines contains colors.
std::vector< Eigen::Vector3d > points_
Points coordinates.
std::vector< Eigen::Vector3d > colors_
RGB colors of lines.
bool HasLines() const
Returns true if the object contains lines.
std::vector< Eigen::Vector2i > lines_
Lines denoted by the index of points forming the line.
bool HasPoints() const
Returns true if the object contains points.
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
static AxisAlignedBoundingBox CreateFromPoints(const core::Tensor &points)
GeometryType
Specifies possible geometry types.
A LineSet contains points and lines joining them and optionally attributes on the points and lines.
core::Device GetDevice() const override
Returns the device attribute of this LineSet.
core::Tensor & GetLineIndices()
core::Tensor GetCenter() const
Returns the center for point coordinates.
std::string ToString() const
Text description.
LineSet & Translate(const core::Tensor &translation, bool relative=true)
Translates the points and lines of the LineSet.
LineSet & PaintUniformColor(const core::Tensor &color)
Assigns uniform color to all lines of the LineSet.
bool HasPointPositions() const
OrientedBoundingBox GetOrientedBoundingBox() const
Create an oriented bounding box from point attribute "positions".
void SetPointPositions(const core::Tensor &value)
LineSet To(const core::Device &device, bool copy=false) const
TriangleMesh ExtrudeLinear(const core::Tensor &vector, double scale=1.0, bool capping=true) const
TriangleMesh ExtrudeRotation(double angle, const core::Tensor &axis, int resolution=16, double translation=0.0, bool capping=true) const
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={})
LineSet(const core::Device &device=core::Device("CPU:0"))
Construct an empty LineSet on the provided device.
void SetLineAttr(const std::string &key, const core::Tensor &value)
bool HasLineIndices() const
void SetLineColors(const core::Tensor &value)
cloudViewer::geometry::LineSet ToLegacy() const
Convert to a legacy CloudViewer LineSet.
bool HasLineColors() const
core::Tensor & GetPointPositions()
LineSet & Transform(const core::Tensor &transformation)
Transforms the points and lines of the LineSet.
void SetPointAttr(const std::string &key, const core::Tensor &value)
core::Tensor & GetLineColors()
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"))
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const
Create an axis-aligned bounding box from point attribute "positions".
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...
void SetLineIndices(const core::Tensor &value)
Set the value of the "indices" attribute in line_attr_.
LineSet & Scale(double scale, const core::Tensor ¢er)
Scales the points and lines of the LineSet.
A bounding box oriented along an arbitrary frame of reference.
static OrientedBoundingBox CreateFromPoints(const core::Tensor &points, bool robust=false, MethodOBBCreate method=MethodOBBCreate::MINIMAL_APPROX)
A triangle mesh contains vertices and triangles.
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...
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 conve...
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...
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 conve...
CLOUDVIEWER_LOCAL TriangleMesh ExtrudeLinearTriangleMesh(const Geometry &geometry, const core::Tensor &vector, double scale, bool capping)
CLOUDVIEWER_LOCAL TriangleMesh ExtrudeRotationTriangleMesh(const Geometry &geometry, const double angle, const core::Tensor &axis, int resolution, double translation, bool capping)
Generic file read and write utility for python interface.