3. Polylines

3.1. ccPolyline

All the inherited members are given here for convenience. Most of the time, this class is used rather than the bases classes.

class cloudComPy.ccPolyline

Bases: Polyline, ccShiftedObject

The polyline is considered as a cloud of points (in a specific order) with a open/closed state information.

Constructor:

Parameters

associatedCloud (GenericIndexedCloudPersist) – the associated point cloud (i.e. the vertices)

addChild(self: _cloudComPy.ccHObject, child: _cloudComPy.ccHObject, dependencyFlags: int = <DEPENDENCY_FLAGS.DP_NONE: 0>, insertIndex: int = -1) bool

Adds a child.

warning the C++ default for DEPENDENCY_FLAGS (DP_PARENT_OF_OTHER) is replaced by DP_NONE in Python: The other values may induce a delete of the original child object in C++, not handled correctly on the Python side.

Parameters
  • child (ccHObject) – child instance to append to the child list

  • dependencyFlags (DEPENDENCY_FLAGS,optional) – dependency flags, default DP_NONE

  • insertIndex (int,optional) – insertion index, default -1: if <0, child is simply appended to the children list.

Returns

success

Return type

bool

addPointIndex(self: _cloudComPy.ReferenceCloud, arg0: int, arg1: int) bool

Point global index insertion mechanism (range), thread safe.

Parameters
  • firstIndex (int) – first point global index of range

  • lastIndex (int) – last point global index of range (excluded)

Returns

false if not enough memory

Return type

bool

addPointIndexGlobal(self: _cloudComPy.ReferenceCloud, arg0: int) bool

Point global index insertion mechanism, Thread safe.

Parameters

globalIndex (int) – a point global index

Returns

false if not enough memory

Return type

bool

colorsShown(self: _cloudComPy.ccHObject) bool

Returns True if the colors are shown, False otherwise. It is used to prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Returns

whether the colors are shown.

Return type

bool

computeLength(self: _cloudComPy.ccPolyline) float

Computes the polyline length.

Returns

sum of segments length

Return type

float

enableScalarField(self: _cloudComPy.ReferenceCloud) bool

Enables the scalar field associated to the cloud.

If the scalar field structure is not yet initialized/allocated, this method gives the signal for its creation. Otherwise, if possible the structure size should be pre-reserved with the same number of elements as the point cloud.

Warning If the cloud is empty, the scalar field will be empty as well. The scalar field will be reserved with the same capacity as the cloud.

Returns

success

Return type

bool

forwardIterator(self: _cloudComPy.ReferenceCloud) None

Forwards the local element iterator.

getAssociatedCloud(self: _cloudComPy.ReferenceCloud) _cloudComPy.GenericIndexedCloudPersist

Returns the associated (source) cloud.

Returns

the source cloud

Return type

GenericIndexedCloudPersist

getBoundingBox(self: _cloudComPy.ReferenceCloud) List[Vector3Tpl<T>]

Returns the octree bounding box.

Method to request the octree bounding box limits.

Return limits

((Xmin,Ymin,Zmin), (Xmax,Ymax,Zmax))

Return type

tuple

getChild(self: _cloudComPy.ccHObject, arg0: int) _cloudComPy.ccHObject

Get child by index.

Parameters

index (int) – index of child, see getChildrenNumber().

Returns

child object

Return type

ccHObject

getChildCountRecursive(self: _cloudComPy.ccHObject) int

Get the number of children of this object, recursively.

Returns

number of children, recursively

Return type

int

getChildrenNumber(self: _cloudComPy.ccHObject) int

Get the number of direct children of this object.

Returns

number of direct children

Return type

int

getClassID(self: _cloudComPy.ccHObject) int

Get the type of this object.

Returns

type

Return type

CC_TYPE

getCurrentPointCoordinates(self: _cloudComPy.ReferenceCloud) Vector3Tpl<T>

Returns the coordinates of the point pointed by the current element.

Returns

coordinates

Return type

tuple

getCurrentPointGlobalIndex(self: _cloudComPy.ReferenceCloud) int

Returns the global index of the point pointed by the current element.

Returns

global index in the cloud

Return type

int

getCurrentPointScalarValue(self: _cloudComPy.ReferenceCloud) float

Returns the current point associated scalar value.

Returns

scalar value

Return type

float

getGlobalScale(self: _cloudComPy.ccShiftedObject) float

Returns the scale applied to original coordinates.

Returns

the scale applied to original coordinates.

Return type

double

getGlobalShift(self: _cloudComPy.ccShiftedObject) Vector3Tpl<T>

Returns the shift applied to original coordinates.

Original coordinates are equal to ‘(P/scale - shift)’ The shift is typically used when saving to a file.

Returns

applied shift (x, y, z)

Return type

tuple

getName(self: _cloudComPy.ccPolyline) QString

Get the name of the polyline.

Returns

name

Return type

str

getNextPoint(self: _cloudComPy.ReferenceCloud) Vector3Tpl<T>

Returns the next point (relatively to the global iterator position).

Virtual method to handle the cloud global iterator. Global iterator position should be increased by one each time this method is called.

Warning:

  • the returned object may not be persistent!

  • THIS METHOD MAY NOT BE COMPATIBLE WITH PARALLEL STRATEGIES

(see the DgmOctree::executeFunctionForAllCellsAtLevel_MT and DgmOctree::executeFunctionForAllCellsAtStartingLevel_MT methods).

Returns

coordinates of next point (TODO: what if no more?)

Return type

tuple

getParent(self: _cloudComPy.ccHObject) _cloudComPy.ccHObject

Get the parent of this object.

Returns

parent object

Return type

ccHObject

getPoint(self: _cloudComPy.ReferenceCloud, arg0: int) Vector3Tpl<T>

Returns the ith point.

Method to request a point with a specific index.

WARNINGS:

  • the returned object may not be persistent!

  • THIS METHOD MAY NOT BE COMPATIBLE WITH PARALLEL STRATEGIES

(see the DgmOctree::executeFunctionForAllCellsAtLevel_MT and DgmOctree::executeFunctionForAllCellsAtStartingLevel_MT methods). Consider the other version of getPoint instead or the GenericIndexedCloudPersist class.

Parameters

index (int) – index of the requested point (between 0 and the cloud size minus 1)

Returns

the requested point coordinates (undefined behavior if index is invalid)

Return type

tuple

getPointGlobalIndex(self: _cloudComPy.ReferenceCloud, arg0: int) int

Returns global index (i.e. relative to the associated cloud) of a given element.

Parameters

localIndex (int) – local index (i.e. relative to the internal index container)

Returns

global index

Return type

int

getPointScalarValue(self: _cloudComPy.ReferenceCloud, arg0: int) float

Returns the ith point associated scalar value.

Parameters

index (int) – local index

Returns

scalar value

Return type

float

hasColors(self: _cloudComPy.ccHObject) bool

Returns True if the entity has colors, False otherwise.

Returns

whether the entity has colors

Return type

bool

hasNormals(self: _cloudComPy.ccHObject) bool

Returns True if the entity has normals, False otherwise.

Returns

whether the entity has normals

Return type

bool

hasScalarFields(self: _cloudComPy.ccHObject) bool

Returns True if the entity has ScalarFields, False otherwise.

Returns

whether the entity has ScalarFields

Return type

bool

is2DMode(self: _cloudComPy.ccPolyline) bool

Returns whether the polyline is considered as 2D or 3D.

Returns

whether the polyline is considered as 2D

Return type

bool

isA(self: _cloudComPy.ccHObject, arg0: int) bool

Check the type of object.

Parameters

type (CC_TYPES) – type to check

Returns

OK if object is of this type

Return type

bool

isClosed(self: _cloudComPy.Polyline) bool

Returns whether the polyline is closed or not.

Returns

whether the polyline is closed

Return type

bool

isKindOf(self: _cloudComPy.ccHObject, arg0: int) bool

Check the type of object.

Parameters

type (CC_TYPES) – type to check

Returns

OK if object is a kind of this type

Return type

bool

isScalarFieldEnabled(self: _cloudComPy.ReferenceCloud) bool

Returns True if the scalar field is enabled, False otherwise

Returns

is the ScalarField enabled?

Return type

bool

isShifted(self: _cloudComPy.ccShiftedObject) bool

Returns whether the cloud is shifted or not

Returns

whether the cloud is shifted or not

Return type

bool

normalsShown(self: _cloudComPy.ccHObject) bool

Returns True if the normals are shown, False otherwise. It is used to prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Returns

whether the normals are shown

Return type

bool

placeIteratorAtBeginning(self: _cloudComPy.ReferenceCloud) None

Sets the cloud iterator at the beginning.

Virtual method to handle the cloud global iterator

segmentCount(self: _cloudComPy.ccPolyline) int

Returns the number of segments.

Returns

the number of segments

Return type

int

set2DMode(self: _cloudComPy.ccPolyline, arg0: bool) None

Defines if the polyline is considered as 2D or 3D.

Parameters

state (bool) – if True, the polyline is set 2D

setClosed(self: _cloudComPy.Polyline, arg0: bool) None

Sets whether the polyline is closed or not.

Parameters

state (bool) – if True, the polyline is set closed

setCurrentPointScalarValue(self: _cloudComPy.ReferenceCloud, arg0: float) None

Sets the current point associated scalar value.

Parameters

value (float) – scalar value

setGlobalScale(self: _cloudComPy.ccShiftedObject, arg0: float) None

Sets the scale applied to original coordinates (information storage only).

Parameters

scale (double) – scale applied

setGlobalShift(self: _cloudComPy.ccShiftedObject, arg0: float, arg1: float, arg2: float) None

Sets shift applied to original coordinates (information storage only)

Such a shift can typically be applied at loading time. Original coordinates are equal to ‘(P/scale - shift)’

Parameters
  • x (double) – x shift

  • y (double) – y shift

  • z (double) – z shift

setName(self: _cloudComPy.ccPolyline, arg0: QString) None

Defines the polyline name.

Parameters

name (str) – the name to give to the polyline

setPointScalarValue(self: _cloudComPy.ReferenceCloud, arg0: int, arg1: float) None

Sets the ith point associated scalar value.

Parameters
  • index (int) – local index

  • value (float) – scalar value

sfShown(self: _cloudComPy.ccHObject) bool

Returns True if the scalar fields are shown, False otherwise. It is used to prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Returns

whether the scalar fields are shown

Return type

bool

showColors(self: _cloudComPy.ccHObject, arg0: bool) None

Prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Parameters

isShown (bool) – whether to show or not the colors.

showNormals(self: _cloudComPy.ccHObject, arg0: bool) None

Prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Parameters

isShown (bool) – whether to show or not the normals.

showSF(self: _cloudComPy.ccHObject, arg0: bool) None

Prepare the state of the entity when it is saved in a .bin format, for reopening in the GUI in a predefined state (colors, normal, scalarFields).

Parameters

isShown (bool) – whether to show or not the ScalarFields.

size(self: _cloudComPy.ccPolyline) int

Return the number of points.

Returns

the number of points in the polyline

Return type

int

smoothChaikin(self: _cloudComPy.ccPolyline, arg0: float, arg1: int) _cloudComPy.ccPolyline

Smoothes the polyline (Chaikin algorithm).

Parameters
  • ratio (float) – between 0 and 0.5 (excluded)

  • iteration (int) – Count of iteration

Returns

smoothed polyline

Return type

ccPolyline

3.2. bases classes for ccPolyline

class cloudComPy.Polyline

Bases: ReferenceCloud

A simple polyline class (base class)

The polyline is considered as a cloud of points (in a specific order) with a open/closed state information.

Constructor:

Parameters

associatedCloud (GenericIndexedCloudPersist) – the associated point cloud (i.e. the vertices)

isClosed(self: _cloudComPy.Polyline) bool

Returns whether the polyline is closed or not.

Returns

whether the polyline is closed

Return type

bool

setClosed(self: _cloudComPy.Polyline, arg0: bool) None

Sets whether the polyline is closed or not.

Parameters

state (bool) – if True, the polyline is set closed