nanomesh.region_markers

Classes:

RegionMarker(label, point[, name, constraint])

Data class to store region info.

RegionMarkerList([iterable])

Collection of region markers.

class nanomesh.region_markers.RegionMarker(label: int, point: Union[Tuple[float, ...], ndarray[Any, dtype[ScalarType]]], name: Optional[str] = None, constraint: float = 0)[source]

Bases: object

Data class to store region info.

A region is typically an area or volume bounded by segments or cells.

label

Label used to identify the region.

Type

int

point

Point inside the region.

Type

tuple[float]

name

Name of the region.

Type

str, optional

constraint

This value can be used to set the maximum size constraint for cells in the region during meshing.

Type

float, default=0

Attributes:

constraint

label

name

point

Methods:

update(**kwargs)

constraint: float = 0
label: int
name: Optional[str] = None
point: Union[Tuple[float, ...], ndarray[Any, dtype[ScalarType]]]
update(**kwargs) RegionMarker[source]
class nanomesh.region_markers.RegionMarkerList(iterable=(), /)[source]

Bases: List[RegionMarker]

Collection of region markers.

Sub-classes list().

Methods:

label_sequentially()

Re-label a set of regions sequentially.

relabel()

Relabel a sub-group of region markers.

Attributes:

labels

Return all unique region labels.

names

Return all unique region names.

label_sequentially(old: Callable, fmt_name: str = None)[source]
label_sequentially(old: Sequence, *args, **kwargs)
label_sequentially(old: int, *args, **kwargs)

Re-label a set of regions sequentially.

old matches a sub-group of region markers and assigns new labels. The new labels are incremented sequentially. E.g.: [1,1,1,2] -> [3,4,5,6]

Parameters
  • old (callable or list or int) – The old label(s) to replace. The value can be of type: - int, matches this exact label - list, matches all labels in this list - callable, returns True if label is a match

  • fmt_name (str, optional) – Optional format string for the label name, e.g. ‘feature{}’. The placeholder ({}) will be substituted by the new label.

Returns

New list of region markers with updated labels.

Return type

RegionMarkerList

property labels: set

Return all unique region labels.

property names: set

Return all unique region names.

relabel(old: Callable, new: int, name: str = None) RegionMarkerList[source]
relabel(old: Sequence, new: int, *args, **kwargs)
relabel(old: int, new: int, *args, **kwargs)

Relabel a sub-group of region markers.

Parameters
  • old (callable or list or int) – The old label(s) to replace. The value can be of type: - int, matches this exact label - list, matches all labels in this list - callable, returns True if label is a match

  • new (int) – New label to assign

  • name (str, optional) – Optional name to assign to the new region markers.

Returns

New list of region markers with updated labels.

Return type

RegionMarkerList