GeometryOperations#

class GeometryOperations[source]#

Bases: object

Registry for geometry operation functions.

Methods

GeometryOperations.cluster(geometry, method)

Partition points into clusters.

GeometryOperations.compute_normals(geometry)

Compute, flip, or remove point normals.

GeometryOperations.downsample(geometry[, method])

Downsample point cloud.

GeometryOperations.duplicate(geometry, **kwargs)

Duplicate a geometry.

GeometryOperations.fit(geometry, method, ...)

Fit a model to a point cloud.

GeometryOperations.register(operation_name, func)

Register an operation function.

GeometryOperations.remesh(geometry, method, ...)

Remesh by edge length, vertex count, or subdivision.

GeometryOperations.remove_outliers(geometry)

Remove statistical outliers from point cloud.

GeometryOperations.sample(geometry, ...[, ...])

Sample points from a fitted model.

GeometryOperations.skeletonize(geometry[, ...])

Extract structural skeleton from point cloud.

GeometryOperations.smooth(geometry, method, ...)

Smooth a triangle mesh.

GeometryOperations.visibility(geometry[, ...])

Change geometry visibility.

static cluster(geometry, method, drop_noise=False, use_points=True, use_normals=False, **kwargs)#

Partition points into clusters.

Parameters:
geometryGeometry or GeometryData

Input data.

methodstr

Clustering method to use. Options are: - ‘Connected Components’ : Connected components by spatial proximity - ‘Envelope’ : Envelope-based connected components - ‘Leiden’ : Leiden graph-based clustering - ‘DBSCAN’ : DBSCAN density-based clustering - ‘K-Means’ : K-Means partitioning - ‘Birch’ : Birch hierarchical clustering

drop_noisebool, optional

If True, drop noise points (label -1) from results. Default is False.

use_pointsbool, optional

If True, use point coordinates for clustering. Default is True.

use_normalsbool, optional

If True, include normal vectors in clustering features. Default is False.

**kwargs

Additional arguments passed to the chosen clustering method.

Returns:
List[mosaic.geometry.GeometryData]

List of geometries, one per cluster.

Raises:
ValueError

If unsupported clustering method is specified or too many clusters found.

static compute_normals(geometry, method='Compute', k=15, **kwargs)#

Compute, flip, or remove point normals.

Parameters:
geometryGeometry or GeometryData

Input data.

methodstr, optional

Normal computation method. Options are: - ‘Compute’ : Calculate new normals from point neighborhoods - ‘Flip’ : Reverse existing normal directions - ‘Remove’ : Clear any existing normal vectors Default is ‘Compute’.

kint, optional

Number of neighbors to consider for normal computation. Only used when method=’Compute’. Default is 15.

**kwargs

Additional parameters for normal computation.

Returns:
Geometry

A duplicate of the input geometry with updated normals.

static downsample(geometry, method='radius', **kwargs)#

Downsample point cloud.

Parameters:
geometryGeometry or GeometryData

Input data.

methodstr, optional

Method to use. Options are: - ‘radius’ : Uniform voxel grid downsampling - ‘center_of_mass’ : Replace nearby points by their centroid - ‘number’ : Random subsampling to target count Default is ‘radius’.

**kwargs

Additional arguments passed to the chosen method: - For ‘radius’: voxel_size parameter for open3d.voxel_down_sample - For ‘number’: size parameter specifying target number of points

Returns:
mosaic.geometry.GeometryData

Downsampled geometry.

static duplicate(geometry, **kwargs)#

Duplicate a geometry.

Parameters:
geometryGeometry or GeometryData

Geometry to duplicate.

Returns:
mosaic.geometry.GeometryData

Duplicated geometry.

static fit(geometry, method, **kwargs)#

Fit a model to a point cloud.

Parameters:
geometryGeometry or GeometryData

Input point cloud geometry.

methodstr

Fitting method. Options are: - ‘alpha_shape’ : Alpha-shape based surface reconstruction - ‘ball_pivoting’ : Ball pivoting surface reconstruction - ‘poisson’ : Poisson surface reconstruction - ‘flying_edges’ : Flying edges isosurface extraction - ‘shrink_wrap’ : Topology-preserving deformation (Reach for the Spheres) - ‘sphere’ : Least-squares sphere - ‘ellipsoid’ : Ellipsoid via eigenvalue decomposition - ‘cylinder’ : Cylinder via PCA and constrained optimization - ‘rbf’ : Radial basis function interpolation - ‘spline’ : Spline curve through control points

Returns:
mosaic.geometry.GeometryData

Geometry with fitted model attached.

Raises:
ValueError

If method is unsupported or point count is insufficient (<50).

classmethod register(operation_name, func, decorator=None)[source]#

Register an operation function.

static remesh(geometry, method, **kwargs)#

Remesh by edge length, vertex count, or subdivision.

Parameters:
geometryGeometry or GeometryData

Input geometry with a TriangularMesh model.

methodstr

Remeshing strategy. Options are: - ‘Decimation’ : Reduce triangle count via decimation - ‘Edge Length’ : Remesh to target edge length - ‘Subdivide’ : Subdivide mesh triangles - ‘Vertex Clustering’ : Simplify via vertex clustering

Returns:
mosaic.geometry.GeometryData or None

Remeshed geometry, or None if input has no mesh model.

static remove_outliers(geometry, method='statistical', **kwargs)#

Remove statistical outliers from point cloud.

Parameters:
geometryGeometry or GeometryData

Input data.

methodstr, optional

Outlier detection method. Options are: - ‘statistical’ : General statistical outlier removal - ‘eigenvalue’ : Eigenvalue-based edge noise removal Default is ‘statistical’.

**kwargs

Additional parameters for outlier removal method.

Returns:
mosaic.geometry.GeometryData or None

Filtered point cloud geometry with outliers removed. Returns None if no points remain after filtering.

static sample(geometry, sampling, method, normal_offset=0.0, bidirectional=False, **kwargs)#

Sample points from a fitted model.

Parameters:
geometryGeometry or GeometryData

Input data.

samplingfloat

Sampling rate or number of points to generate.

methodstr

Sampling method to use: - ‘distance’ : Sample by average inter-point distance - ‘points’ : Sample by total point count

normal_offsetfloat, optional

Point offset along normal vector, defaults to 0.0.

bidirectionalbool, optional

Draw inward and outward facing points at the same time. This doubles the total number of points. Default is False.

Returns:
mosaic.geometry.GeometryData

Sampled geometry.

Raises:
ValueError

If geometry has no fitted model.

static skeletonize(geometry, method='core', sigma=1.0, **kwargs)#

Extract structural skeleton from point cloud.

Parameters:
geometryGeometry or GeometryData

Input data.

method{‘outer’, ‘core’, ‘boundary’}, optional

Structural feature to extract: - ‘core’ : Extract medial axis/centerline through the middle of structures - ‘boundary’ : Extract both inner and outer boundaries for hollow structures - ‘outer’ : Extract outer boundary via skeletonization + convex hull - ‘outer_hull’ : Fast convex hull approximation (no skeletonization)

sigmafloat, optional

Gaussian smoothing for Hessian computation.

**kwargs

Additional arguments passed to the chosen method.

Returns:
mosaic.geometry.GeometryData

Skeletonized point cloud.

Raises:
ValueError

If unsupported method is specified.

static smooth(geometry, method, **kwargs)#

Smooth a triangle mesh.

Parameters:
geometryGeometry or GeometryData

Input geometry with a TriangularMesh model.

methodstr

Smoothing algorithm. Options are: - ‘Taubin’ : Volume-preserving Taubin smoothing - ‘Laplacian’ : Laplacian mesh smoothing - ‘Average’ : Simple neighbor averaging - ‘Fair’ : Polyharmonic mesh deformation

Returns:
mosaic.geometry.GeometryData or None

Smoothed geometry, or None if input has no mesh model.

static visibility(geometry, visible=True, **kwargs)#

Change geometry visibility.

Parameters:
geometryGeometry or GeometryData

Target geometry.

visiblebool, optional

Whether the geometry should be visible. Default is True.