10.11. pointCloud

class itom.pointCloud(type=point.PointInvalid)
class itom.pointCloud(pointCloud, indices=None) pointCloud
class itom.pointCloud(width, height, point=None) pointCloud
class itom.pointCloud(singlePoint) pointCloud

Creates new point cloud.

Possible point types of this point cloud are:

  • point.PointXYZ

  • point.PointXYZI

  • point.PointXYZRGBA

  • point.PointXYZNormal

  • point.PointXYZINormal

  • point.PointXYZRGBNormal

Parameters
typeint, optional

The type of this point cloud.

pointCloudpointCloud

Creates a point cloud from this pointCloud.

indicessequence of int or iterable of int, optional

Only the indices of the given pointCloud are used to create this cloud object.

widthint

Width of the new point cloud.

heightint

Height of the new point cloud (the point cloud is dense if height > 1).

pointpoint, optional

If a width and / or height is given, this optional point is used to initialize every point in the cloud with this value. If the constructor overload with one point argument is used, this cloud only consists of this one point. If no point is given, by a width and height, an invalid cloud type will be initialized.

singlePointpoint

Creates a point cloud with this singlePoint. The type is also derived from the type of the singlePoint.

Returns
cloudpointCloud

the initialized point cloud

append(pointCloud) None
append(point) None
append(xyz) None
append(xyzi) None
append(xyz, rgba) None
append(xyz_normal_curvature) None
append(xyz_i_normal_curvature) None
append(xyz_normal_curvature, rgba) None

Appends another point cloud or a point, e.g. given by its coordinates etc., to this cloud.

In all cases, the type of the point or pointCloud, or the correct overload must fit to the type of this point cloud. Else a RuntimeError is thrown. If this cloud has an invalid type and a point or a pointCloud is given, the type of this arguments is used to initialize this point cloud.

Parameters
pointCloudpointCloud

is another pointCloud, appended to this cloud. If this cloud was uninitialized yet (type = pointCloud.PointInvalid), the type of the given pointCloud is used.

pointpoint

is another point, appended to this cloud. If this cloud was uninitialized yet (type = pointCloud.PointInvalid), the type of the given point is used.

xyzsequence of float or iterable of float

Only possible if type = pointCloud.PointXYZ or pointCloud.PointXYZRGBA: A point with the given (x, y, z) tuple, list, sequence, array… is added to this point cloud.

xyzisequence of float or iterable of float

Only possible if type = pointCloud.PointXYZI: A point with the given (x, y, z, intensity) tuple, list, sequence, array… is added to this point cloud.

xyz_normal_curvaturesequence of float or iterable of float

Only possible if type = pointCloud.PointXYZNormal or pointCloud.PointXYZRGBNormal: A point with the given (x, y, z, nx, ny, nz, curvature) tuple, list, sequence, array… is added to this point cloud.

xyz_i_normal_curvaturesequence of float or iterable of float

Only possible if type = pointCloud.PointXYZINormal: A point with the given (x, y, z, intensity, nx, ny, nz, curvature) tuple, list, sequence, array… is added to this point cloud.

rgbasequence of float or iterable of float

Only possible if type = pointCloud.PointXYZRGBA or pointCloud.PointXYZRGBNormal: The added point gets the color defined by this (red, green, blue, alpha) tuple…

clear()

Clears the whole point cloud.

copy() pointCloud

Returns a deep copy of this point cloud.

Returns
cloudpointCloud

An exact copy if this point cloud.

dense

bool : Gets or sets if all points have finite coordinates (True), or if some might contain Inf / NaN values (False).

empty

bool : Returns true if this cloud is empty (size = 0).

erase(indices)

Erases the points in point clouds indicated by indices.

Parameters
indicesint or slice

Single index or slice of indices whose corresponding points should be deleted.

Notes

This method is the same than typing del myPointCloud[indices].

fields

list of str : Gets a list of all available field names of this point cloud.

This property returns a list of field names that are contained in this cloud, e.g. [‘x’, ‘y’, ‘z’].

static fromTopography(topography, intensity=None, deleteNaN=False, color=None) pointCloud

Creates a point cloud from a given topography dataObject.

Creates a point cloud from the 2.5D data set given by the topography dataObject. The x and y-components of each point are taken from the regular grid, spanned by the coordinate system of topography (considering the scaling and offset of the object). The corresponding z-value is the topography’s value itself.

Parameters
topographydataObject

M x N, float32dataObject are the topography values.

intensitydataObject, optional

a M x N, float32 dataObject. If given, a point.PointXYZI pointCloud is created whose intensity values are determined by this argument (cannot be used together with color).

deleteNaNbool, optional

If True, NaN or Inf z-coordiantes in the topography object will not be copied into the point cloud (the point cloud is not organized any more).

colordataObject, optional

a M x N, rgba32 dataObject. If given, a point.PointXYZRGBA pointCloud is created whose color values are determined by this argument (cannot be used together with intensity).

Returns
pointCloud

the newly created pointCloud (either of type point.POINTXYZI or point.PointXYZRGBA.

static fromXYZ(X, Y, Z, deleteNaN=False) pointCloud
static fromXYZ(XYZ, deleteNaN=False) pointCloud

Creates a point cloud from three X,Y,Z dataObjects or from one 3xMxN or Mx3 dataObject.

The created point cloud is not organized (height = 1) and dense, if no NaN or Inf values are within the pointCloud. dense is True forever, if deleteNaN = True.

Parameters
XdataObject

A M x N float32 dataObject with the x-coordinates of all points.

YdataObject

A M x N float32 dataObject with the y-coordinates of all points.

ZdataObject

A M x N float32 dataObject with the z-coordinates of all points.

XYZdataObject

Either a 3 x M x N float32 dataObject, where the first plane [0,:,:] contains the x-coordiantes, the 2nd plane [1,:,:] the y-coordinates and the 3rd plane the z-coordinates. Or a M x 3 float32 dataObject, where each row represents one point, that consists of the x-, y- and z-coordinates.

deleteNaNbool

if True all points, whose coordinate has at least one NaN component, will be skipped. Else, they are also put to the cloud, however it is not dense anymore.

Returns
pointCloud

The newly created point cloud of the type point.PointXYZ.

Notes

The dataObject X, Y, Z, XYZ are recommended to have the dtype float32. However, it is possible to pass any real data type, that is then implicitly converted to float32.

static fromXYZI(X, Y, Z, I, deleteNaN=False) pointCloud
static fromXYZI(XYZ, I, deleteNaN=False) pointCloud

Creates a point cloud from four X, Y, Z, I dataObjects or from one 3xMxN or Mx3 dataObject and one I dataObject.

The created point cloud is not organized (height = 1) and dense, if no NaN or Inf values are within the pointCloud. dense is True forever, if deleteNaN = True.

Parameters
XdataObject

A M x N float32 dataObject with the x-coordinates of all points.

YdataObject

A M x N float32 dataObject with the y-coordinates of all points.

ZdataObject

A M x N float32 dataObject with the z-coordinates of all points.

XYZdataObject

Either a 3 x M x N float32 dataObject, where the first plane [0,:,:] contains the x-coordiantes, the 2nd plane [1,:,:] the y-coordinates and the 3rd plane the z-coordinates. Or a M x 3 float32 dataObject, where each row represents one point, that consists of the x-, y- and z-coordinates.

IdataObject

A M x N float32 dataObject with the intensity values of all points.

deleteNaNbool

if True all points, whose coordinate has at least one NaN component, will be skipped. Else, they are also put to the cloud, however it is not dense anymore.

Returns
pointCloud

The newly created point cloud of the type point.PointXYZI.

Notes

The dataObject X, Y, Z, XYZ and I are recommended to have the dtype float32. However, it is possible to pass any real data type, that is then implicitly converted to float32.

static fromXYZRGBA(X, Y, Z, color, deleteNaN=False) pointCloud
static fromXYZRGBA(XYZ, color, deleteNaN=False) pointCloud

Creates a point cloud from three X, Y, Z, color dataObjects or from one 3xMxN or Mx3 dataObject and one color dataObject.

The created point cloud is not organized(height = 1) and dense, if no NaN or Inf values are within the : class :pointCloud. : attr : dense is True forever, if deleteNaN = True.

Parameters
XdataObject

A M x N float32 :class :dataObject with the x - coordinates of all points.

YdataObject

A M x N float32 :class :dataObject with the y - coordinates of all points.

ZdataObject

A M x N float32 :class :dataObject with the z - coordinates of all points.

XYZdataObject

Either a 3 x M x N float32 :class :dataObject, where the first plane [0, :, : ] contains the x - coordiantes, the 2nd plane [1, :, : ] the y - coordinates and the 3rd plane the z - coordinates.Or a M x 3 float32 :class :dataObject, where each row represents one point, that consists of the x - , y - and z - coordinates.

colordataObject

M x N dataObject with the colors for each point, type: rgba32.

deleteNaNbool

if True all points, whose coordinate has at least one NaN component, will be skipped.Else, they are also put to the cloud, however it is not dense anymore.

Returns
pointCloud

The newly created point cloud of the type point.PointXYZRGBA.

Notes

The dataObject X, Y, Z, XYZ are recommended to have the dtype float32. However, it is possible to pass any real data type, that is then implicitly converted to float32.

height

int : Gets the height of this point cloud if it is organized as regular grid, else 1.

The height of a point cloud is equal to 1, if the points in the point cloud are not organized. If the cloud is organized, all points are assumed to lie on a regular grid, such that neighbouring points in the grid are adjacent in space, too. In this case, the height is the number of rows in this grid. The total number of points is then height * width.

insert(index, values)

Inserts a single point or a sequence of points before position given by index.

By this method, a point or a sequence of points is inserted into the existing pointCloud.

The new points are inserted before the existing value at the index-th position.

The type of the inserted points must fit to the type of the point cloud.

Parameters
indexint

the new point(s) is / are inserted before the existing value at the index-th position. index must be in range [0, size of point cloud - 1]. Negative values signify a count from the end of the existing cloud.

valuespoint or sequence of point

point or sequence of point that should be inserted.

moveXYZ(x=0.0, y=0.0, z=0.0)

Moves the x, y and z components of every point by the given offsets.

Parameters
xfloat, optional

offset value for the x-component

yfloat, optional

offset value for the y-component

zfloat, optional

offset value for the z-component

name() str

Returns the name of this object.

Returns
str

returns the name of this object: PointCloud.

organized

bool : returns True if this point cloud is organized, else False.

Points in an organized point cloud are assumed to lie on a regular grid, defined by height and width. Neighbouring points in this grid are the neighbours in space, too. An unorganized point cloud has always a height equal to 1 and width equal to the total number of points.

scaleXYZ(x=1.0, y=1.0, z=1.0)

Scales the x, y and z components of every point by the given values.

Parameters
xfloat, optional

scaling factor for the x-component.

yfloat, optional

scaling factor for the y-component.

zfloat, optional

scaling factor for the z-component.

size

int : Gets the total number of points in this point cloud

toDataObject() dataObject

Returns a P x N float32 dataObject with all point data, where P depends on the point type and N is the number of points.

The output has at least 3 components per point. The first three rows contain always the (x, y, z) coordinates of each point.

If this cloud has normals defined, these will be added in the next 4 rows as (nx, ny, nz, curvature). For types, that contain intensity values, the next row contains this intensity value. Point types, that contain colour information for each point will put this information in the upcoming 4 rows, as (red, green, blue, alpha).

To sum up, row column patterns are: (x,y,z), (x,y,z,intensity), (x,y,z,r,g,b,a), (x,y,z,nx,ny,nz,curvature), (x,y,z,nx,ny,nz,curvature,intensity], among others.

Returns
dObjdataObject

A float32 dataObject of size P x N (N is equal to self.size).

type

int : Gets the point type of this point cloud.

Point types can be:

  • point.PointInvalid = 0x00

  • point.PointXYZ = 0x01

  • point.PointXYZI = 0x02

  • point.PointXYZRGBA = 0x04

  • point.PointXYZNormal = 0x08

  • point.PointXYZINormal = 0x10

  • point.PointXYZRGBNormal 0x20

width

int : Gets the width of point cloud (if the cloud is not organized, since is equal to size).

The width of a point cloud is equal to the number of total points, if the points in the point cloud are not organized. If it is organized, all points are assumed to lie on a regular grid, such that neighbouring points in the grid are adjacent in space, too. In this case, the width is the number of columns in this grid. The total number of points is then height * width.