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.

is_read_only: bool
property facets: FacetArray

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: ColourArray

A 2D numpy array containing the colours of the facets.

property facet_selection: BooleanArray

A 1D numpy array representing which facets are selected.

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

property facet_count: int

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 (npt.ArrayLike) – The index of the facet to remove or a list of indices of facets to remove. Indices should only contain 32-bit unsigned integer (They should be greater than or equal to 0 and less than 2**32). Any index greater than or equal to the facet count is ignored. Passing an index less than zero is not supported. It 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: PrimitiveAttributes

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.