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)

Remove one or more facets from the object.

Calling this function is preferable to altering the facets array because this function also removes the facet properties associated with the removed facets (e.g. facet colours, facet visibility, etc). Additionally, after the removal any points or edges which are not part of a facet will be removed from the object.

This operation is performed directly on the Project and will not be undone if an error occurs.

Parameters

facet_indices (array_like or int) – The index of the facet to remove or a list of indices of facets to remove. Any index which is lower than zero or greater than or equal to the facet count is ignored (i.e. Passing -1 will not delete the last facet).

Returns

If passed a single facet index, True if the facet was removed and False if it was not removed. If passed an iterable of facet indices, True if the object supports removing facets and False otherwise.

Return type

bool

Raises

ReadOnlyError – If called on an object not open for editing. This error indicates an issue with the script and should not be caught.

Warning

Any unsaved changes to the object when this function is called are discarded before any facets are deleted. If you wish to keep these changes, call save() before calling this function.

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.