pchandler.scalar_fields.scalar_field_manager
ScalarFieldManager: container for the per-point scalar fields of a PointCloudData.
Module Attributes
|
Base scalar field TypeAlias |
|
Scalar Field like TypeAlias, also supporting other arrays of similar shape |
|
RGB like TypeAlias |
|
Normal like TypeAlias |
|
ScalarFieldManager like dict TypeAlias |
Classes
Manages scalar fields associated with a point cloud. |
- class pchandler.scalar_fields.scalar_field_manager.ScalarFieldManager
Bases:
objectManages scalar fields associated with a point cloud.
Contains mechanisms for adding, changing and removing scalar fields as well as validating lengths with respect to a parent point cloud object.
- Parameters:
fields (dict[str, ScalarField|NormalFields|RGBFields])
_parent (weakref.ReferenceType[PointCloudData] | None)
- __init__(fields=None, *, parent=None)
Initialise the scalar field manager.
Ensures all fields passed are converted to
ScalarField(or the appropriateRGBFields/NormalFields) objects. If a parent point cloud is provided, it is stored as aweakrefand scalar-field lengths will be validated against it.- Parameters:
fields (dict[str, ScalarField | NormalFields | RGBFields | np.ndarray] | ScalarFieldManager | None) – Initial scalar fields, either as raw dict, another manager, or
None(empty manager).parent (PointCloudData, optional) – Owning point cloud; stored as a weakref so that length validation can be performed.
- validate_lengths()
Check that every scalar field’s length matches the parent point cloud’s point count.
- Raises:
ValueError – If any scalar field’s length differs from the parent point count.
- values()
Return the scalar field values stored in the manager.
- Return type:
ValuesView[SF_T]
- items()
Return the scalar field names and values stored in the manager.
- Return type:
ItemsView[str, SF_T]
- property parent: PointCloudData | None
Return the parent point cloud object.
- Return type:
PointCloudData | None
- property shape: tuple[int, int]
Return the shape of the scalar field manager.
The shape will be in the form (num_points, num_fields).
- property num_points: int
Return the number of points in the parent point cloud, or
-1if no parent is set.- Returns:
Parent point count, or
-1.- Return type:
- property normals: NormalFields | None
Get the normals fields.
- Return type:
NormalFields | None
- property intensity: ScalarField | None
Get the intensity field, or
Noneif not set.- Returns:
Intensity field, or
None.- Return type:
ScalarField | None
- property reflectance: ScalarField | None
Get the reflectance field.
- Return type:
ScalarField | None
- sample(mask)
Sample the scalar fields based on a mask.
- Parameters:
mask (IndexLike) – The mask corresponds to indexing the rows or points in the parent point cloud.
- Return type:
- reduce(mask)
Reduce every scalar field in place to the rows selected by
mask.- Parameters:
mask (IndexLike) – The mask corresponds to indexing the rows or points in the parent point cloud.
- extract(mask)
Return a new manager carrying the selected rows; also reduces
selfto the complement.- Parameters:
mask (IndexLike) – The mask corresponds to indexing the rows or points in the parent point cloud.
- Returns:
New manager containing the rows selected by
mask.- Return type:
- add_field(sf_field)
Add a new scalar field to the manager (keyed by
sf_field.name).- Parameters:
sf_field (SF_T) – Scalar field to add.
- remove_field(field_name)
Remove a scalar field from the manager by name.
- Parameters:
field_name (LowerStr) – Name of the field to remove.
- create_field(name, data)
Create a scalar field from a name and an array, then add it to the manager.
Supports
Array_Nx3_Tfor the creation of RGB or Normals fields.- Parameters:
name (str) – Name of the new field.
data (VectorT | Array_Nx3_T) – Field data.
- classmethod merge(scalar_field_managers)
Merge a list of scalar-field managers, keeping only the fields they all share.
- Parameters:
scalar_field_managers (Iterable[ScalarFieldManager]) – Managers to merge.
- Returns:
New manager containing every commonly-named scalar field concatenated along axis 0.
- Return type:
- Raises:
ValueError – If
scalar_field_managersis empty.
- as_struct_array()
Return the scalar fields packed into a single numpy structured array.