mapteksdk.data.primitives.facet_properties module

Support for facet primitives.

A facet is a triangle defined by three points. In Python, a facet is represented as a numpy array containing three integers representing the indices of the points which make up the three corners of the triangle. For example, the facet [0, 1, 2] indicates the triangle defined by the 0th, 1st and 2nd points. Because facets are defined based on points, all objects which inherit from FacetProperties must also inherit from PointProperties.

class FacetProperties

Bases: object

Mixin class which provides spatial objects support for facet primitives.

A facet is a triangle drawn between three points. For example, the facet [i, j, k] is the triangle drawn between object.points[i], object.points[j] and object.points[k].

Functions and properties defined on this class are available on all classes which support facets.

property facets

A 2D numpy array of facets in the object. This is of the form: [[i0, j0, k0], [i1, j1, k1], …, [iN, jN, kN]] where N is the number of facets. Each i, j and k value is the index of the point in Objects.points for the point used to define the facet.

property facet_colours

A 2D numpy array containing the colours of the facets. When setting the colour you may use a list of RGB or greyscale colours.

When facet colours are set, if there are more colours than facets then the excess colours are silently ignored. If there are fewer colours than facets the uncoloured facets are coloured green. If only a single colour is specified, instead of padding with green all of the facets are coloured with that colour. ie: object.facet_colours = [[Red, Green, Blue]] will set all facets to be the colour [Red, Green, Blue].

property facet_selection

A 1D numpy array representing which facets are selected.

If object.facet_selection[i] = True then the ith facet is selected.

property facet_count

The number of facets in the object.

remove_facets(facet_indices, update_immediately=True)

Remove one or more facets. This is done directly in the project and thus changes made by this function will be saved even if save() is not called.

Parameters
  • facet_indices (array or int) – 1D array of uint32 indices of edges to remove or a single uint32 of index of facet to remove.

  • update_immediately (bool) – Applies changes to project and re-loads numpy arrays and properties immediately. May be disabled for large datasets.

Returns

True if successful.

Return type

bool

Notes

Immediately reconciling changes on arrays is recommended.

property facet_attributes

Access the custom facet attributes. These are arrays of values of the same type with one value for each facet.

Use Object.facet_attributes[attribute_name] to access a facet attribute called attribute_name. See PrimitiveAttributes for valid operations on facet attributes.

Returns

Access to the facet attributes.

Return type

PrimitiveAttributes

Raises

ValueError – If the type of the attribute is not supported.

save_facet_attribute(attribute_name, data)

Create new and/or edit the values of the facet attribute attribute_name.

This is equivalent to Object.facet_attributes[attribute_name] = data.

Parameters
  • attribute_name (str) – The name of attribute.

  • data (array) – A numpy array of a base type data to store for the attribute per-primitive.

delete_facet_attribute(attribute_name)

Delete a facet attribute by name.

This is equivalent to: facet_attributes.delete_attribute(attribute_name)

Parameters

attribute_name (str) – The name of attribute.

Raises

Exception – If the object is opened in read-only mode.