5. Meshes

5.1. ccMesh

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

class cloudComPy.ccMesh

Bases: ccGenericMesh

A triangular mesh based on a cloud of vertices.

IndexesToNpArray(self: _cloudComPy.ccMesh) numpy.ndarray

Wrap the indexes of nodes per triangle in the mesh into a numpy Array, without copy.

Returns a numpy Array of shape (number of triangles, 3). Data is not copied, the numpy Array object does not own the data.

WARNING No automatic action on the Python side on the variables referencing the C++ object in case of destruction!

Returns:

numpy Array of shape (number of triangles, 3)

Return type:

ndarray

IndexesToNpArray_copy(self: _cloudComPy.ccMesh) numpy.ndarray

Wrap the indexes of nodes per triangle in the mesh into a numpy Array, with copy.

Returns a numpy Array of shape (number of triangles, 3). Data is copied, the numpy Array object owns its data. Ownership is transfered to Python: the numpy Array object and its data will be handled by the Python Garbage Collector.

Returns:

numpy Array of shape (number of triangles, 3)

Return type:

ndarray

__init__(*args, **kwargs)
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

clearTriNormals(self: _cloudComPy.ccMesh) None

Removes per-triangle normals.

cloneMesh(self: _cloudComPy.ccMesh) _cloudComPy.ccMesh

Clones this entity.

All the main features of the entity are cloned, except from the octree

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

computeMeshArea(self: _cloudComPy.ccGenericMesh) float

Compute the area of the mesh (sum of the triangles areas).

Returns:

mesh area

Return type:

float

computeMeshVolume(self: _cloudComPy.ccMesh) tuple

Compute the volume inside the mesh.

If the mesh is not closed, with holes or non manifold, a warning is issued. Stats are available to get:

edgesCount: Total number of edges

edgesNotShared: Edges not shared (i.e. used by only one triangle) ==> hole or non closed

edgesSharedByTwo: Edges shared by exactly two triangles ==> non manifold

edgesSharedByMore: Edges shared by more than two triangles ==> non manifold

Returns:

tuple (volume, isWarning, stats)

Return type:

(float, bool, EdgeConnectivityStats)

countRef(self: object) int

Get the value of the Python reference counter. Do not use, for debug and tests only.

crop2D(self: _cloudComPy.ccMesh, arg0: _cloudComPy.ccPolyline, arg1: int, arg2: bool) _cloudComPy.ccMesh

Crop the mesh using a 2D polyline.

Parameters:
  • poly (ccPolyline) – polyline object

  • orthoDim (int) – normal plane, value in (0, 1, 2) 0 = oY, 1 = oX, 2 = oZ

  • inside (bool) – boolean

Returns:

the cropped cloud. Points are copied, the original cloud is not modified.

Return type:

ccPointCloud

decRef(self: object) None

Decrement the Python reference counter. Do not use, for debug and tests only.

flagVerticesByType(self: _cloudComPy.ccGenericMesh) bool

Flag the vertices of a mesh by type (normal, border, non manifold)

A new scalar field ‘Vertex type’ is created on the mesh associated cloud.

Returns:

success

Return type:

bool

flipTriangles(self: _cloudComPy.ccMesh) None

Flip the triangles of the mesh (reverse the node order).

getAssociatedCloud(self: _cloudComPy.ccMesh) _cloudComPy.ccGenericPointCloud

Returns the cloud corresponding to the mesh vertices.

Returns:

the associated cloud

Return type:

ccGenericPointCloud

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

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.ccHObject) QString

Get the name of the entity

Returns:

entity name

Return type:

str

getParent(self: _cloudComPy.ccHObject) _cloudComPy.ccHObject

Get the parent of this object.

Returns:

parent object

Return type:

ccHObject

getTriangleVertIndexes(self: _cloudComPy.ccMesh, arg0: int) Tuple3Tpl<T>

Returns the 3 indexes of the nodes of a given triangle index.

Parameters:

index (int) – triangle index

Returns:

a tuple with 3 nodes indexes

Return type:

tuple

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

incRef(self: object) None

Increment the Python reference counter. Do not use, for debug and tests only.

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

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

isShifted(self: _cloudComPy.ccShiftedObject) bool

Returns whether the cloud is shifted or not

Returns:

whether the cloud is shifted or not

Return type:

bool

laplacianSmooth(self: _cloudComPy.ccMesh, nbIteration: int = 20, factor: float = 0.2) bool

Laplacian smoothing.

Parameters:
  • nbIteration (int,optional) – smoothing iterations, default 20

  • factor (float,optional) – smoothing ‘force’, default 0.2

Returns:

success

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

samplePoints(self: _cloudComPy.ccGenericMesh, densityBased: bool, samplingParameter: float, withNormals: bool = True, withRGB: bool = True, withTexture: bool = True, pDLg: CCCoreLib::GenericProgressCallback = None) _cloudComPy.ccPointCloud

Samples points on a mesh.

Parameters:
  • densityBased (bool) – whether the sampling method is based on a surface density or a number of points

  • samplingParameter (float) – either the surface density or the number of points

  • withNormals (bool,optional) – default True

  • withRGB (bool,optional) – default True

  • withTexture (bool,optional) – default True

  • progdiag (progressDialog,optional) – progress dialog, default None, use None!

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.ccHObject, arg0: QString) None

Set the name of the entity

Parameters:

name (str) – entity name

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.ccMesh) int

Returns the number of triangles in the mesh.

Returns:

number of triangles

Return type:

int

subdivide(self: _cloudComPy.ccMesh, arg0: float) _cloudComPy.ccMesh

Subdivides mesh (so as to ensure that all triangles are falls below ‘maxArea’.

Parameters:

maxArea (float) – maximal triangle area to obtain afer subdivision

Returns:

subdivided mesh (if successful)

Return type:

ccMesh

static triangulate(cloud: _cloudComPy.ccGenericPointCloud, type: _cloudComPy.TRIANGULATION_TYPES, updateNormals: bool = False, maxEdgeLength: float = 0, dim: int = 2) _cloudComPy.ccMesh

Creates a Delaunay 2.5D mesh from a point cloud.

The triangulation can be either computed on the points projected in the XY plane, or projected on the best least-square fitting plane. The triangulation is in 2D (in the plane) but the 3D points are connected, so it’s a kind of 2.5D triangulation (that may present however several topological aberrations ;).

Parameters:
  • cloud (ccGenericPointCloud) – a point cloud

  • type (TRIANGULATION_TYPES) – the triangulation strategy

  • updateNormals (bool,optional) – (default False)

  • maxEdgeLength (float,optional) – max edge length for output triangles (default 0 = ignored)

  • dim (int,optional) – projection dimension (for axis-aligned meshes) (default 2)

Returns:

triangles mesh (if successful)

Return type:

ccMesh

static triangulateTwoPolylines(p1: _cloudComPy.ccPolyline, p2: _cloudComPy.ccPolyline, projectionDir: Vector3Tpl<T> = None) _cloudComPy.ccMesh

Creates a Delaunay 2.5D mesh from two polylines.

Parameters:
  • p1 (ccPolyline) – first polyline

  • p2 (ccPolyline) – second polyline

  • projectionDir (CCVector3,optional) – projection direction, default None (use the best fit plane (normal))

Returns:

triangles mesh (if successful)

Return type:

ccMesh

5.2. bases classes for Meshes

class cloudComPy.ccGenericMesh

Bases: GenericIndexedMesh, ccShiftedObject

__init__(*args, **kwargs)
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

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

computeMeshArea(self: _cloudComPy.ccGenericMesh) float

Compute the area of the mesh (sum of the triangles areas).

Returns:

mesh area

Return type:

float

countRef(self: object) int

Get the value of the Python reference counter. Do not use, for debug and tests only.

decRef(self: object) None

Decrement the Python reference counter. Do not use, for debug and tests only.

flagVerticesByType(self: _cloudComPy.ccGenericMesh) bool

Flag the vertices of a mesh by type (normal, border, non manifold)

A new scalar field ‘Vertex type’ is created on the mesh associated cloud.

Returns:

success

Return type:

bool

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

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.ccHObject) QString

Get the name of the entity

Returns:

entity name

Return type:

str

getParent(self: _cloudComPy.ccHObject) _cloudComPy.ccHObject

Get the parent of this object.

Returns:

parent object

Return type:

ccHObject

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

incRef(self: object) None

Increment the Python reference counter. Do not use, for debug and tests only.

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

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

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

samplePoints(self: _cloudComPy.ccGenericMesh, densityBased: bool, samplingParameter: float, withNormals: bool = True, withRGB: bool = True, withTexture: bool = True, pDLg: CCCoreLib::GenericProgressCallback = None) _cloudComPy.ccPointCloud

Samples points on a mesh.

Parameters:
  • densityBased (bool) – whether the sampling method is based on a surface density or a number of points

  • samplingParameter (float) – either the surface density or the number of points

  • withNormals (bool,optional) – default True

  • withRGB (bool,optional) – default True

  • withTexture (bool,optional) – default True

  • progdiag (progressDialog,optional) – progress dialog, default None, use None!

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.ccHObject, arg0: QString) None

Set the name of the entity

Parameters:

name (str) – entity name

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.

class cloudComPy.GenericIndexedMesh

Bases: pybind11_object

__init__(*args, **kwargs)
class cloudComPy.TRIANGULATION_TYPES

” Triangulation types.

  • DELAUNAY_2D_AXIS_ALIGNED Delaunay 2D triangulation in an axis-aligned plane.

  • DELAUNAY_2D_BEST_LS_PLANE Delaunay 2D with points projected on the best least square fitting plane

Members:

DELAUNAY_2D_AXIS_ALIGNED

DELAUNAY_2D_BEST_LS_PLANE

DELAUNAY_2D_AXIS_ALIGNED = <TRIANGULATION_TYPES.DELAUNAY_2D_AXIS_ALIGNED: 1>
DELAUNAY_2D_BEST_LS_PLANE = <TRIANGULATION_TYPES.DELAUNAY_2D_BEST_LS_PLANE: 2>
__init__(self: _cloudComPy.TRIANGULATION_TYPES, value: int) None
property name
property value
class cloudComPy.EdgeConnectivityStats

Statistics on edge connectivity for the mesh.

Variables:
  • edgesCount (int) – Total number of edges

  • edgesNotShared (int) – Edges not shared (i.e. used by only one triangle) ==> hole or non closed

  • edgesSharedByTwo (int) – Edges shared by exactly two triangles ==> non manifold

  • edgesSharedByMore (int) – Edges shared by more than two triangles ==> non manifold

__init__(*args, **kwargs)
property edgesCount
property edgesNotShared
property edgesSharedByMore
property edgesSharedByTwo