Geometry#
- class Geometry(points=None, normals=None, quaternions=None, color=(0.7, 0.7, 0.7), sampling_rate=None, meta=None, vtk_actor=None, vertex_properties=None, model=None, polydata=None, **kwargs)[source]#
Bases:
objectVTK-based geometry representation for 3D point clouds and meshes.
- Parameters:
- pointsnp.ndarray, optional
3D point coordinates.
- quaternionsnp.ndarray, optional
Normal vectors for each point (x,y,z).
- quaternionsnp.ndarray, optional
Orientation quaternions for each point (scalar first w,x,y,z).
- colortuple, optional
Base RGB color values, by default (0.7, 0.7, 0.7).
- sampling_ratenp.ndarray, optional
Sampling rates along each axis.
- metadict, optional
Metadata dictionary.
- vtk_actorvtk.vtkActor, optional
Custom VTK actor object.
- vertex_propertiesVertexPropertyContainer, optional
Additional vertex properties.
- model
mosaic.parametrization.Parametrization Model fitted to geometry data.
- **kwargs
Additional keyword arguments including normals.
Attributes
VTK actor object for rendering.
Return a descriptive type of the current instance
Geometry.has_normalsNormal vectors at each point.
3D point coordinates of the geometry.
Orientation quaternions for each point.
Geometry.vertex_propertiesVisibility state of the geometry.
Methods
Hide main actor and show the LOD actor for fast interaction.
Geometry.change_representation([representation])Change the visual representation mode of the geometry.
Geometry.color_points(point_ids, color)Color specific points in the geometry using set_scalars backend.
Restore the main actor and hide the LOD actor.
Get total number of points in the geometry.
Geometry.is_mesh_representation([representation])Geometry.merge(geometries)Merge multiple geometry objects into a single geometry.
Geometry.set_appearance([size, opacity, ...])Set visual appearance properties of the geometry.
Geometry.set_color([color])Set uniform color for all points in the geometry.
Geometry.set_scalars(scalars, color_lut[, ...])Set scalar data for coloring points.
Geometry.set_visibility([visibility])Set geometry visibility in the scene.
Geometry.setup_lod([budget])Build or clear the interaction-LOD actor.
Geometry.subset(idx[, copy])Geometry.swap_data(points[, normals, faces, ...])Replace geometry data with new point cloud or mesh data.
- property actor#
VTK actor object for rendering.
- Returns:
- vtk.vtkActor
VTK actor used for visualization.
- change_representation(representation='pointcloud')[source]#
Change the visual representation mode of the geometry.
- Parameters:
- representationstr, optional
Representation mode, by default “pointcloud”. Supported: “pointcloud”, “gaussian_density”, “pointcloud_normals”, “mesh”, “wireframe”, “normals”, “surface”, “basis”.
- Returns:
- int
Success status (0 for success, -1 for failure).
- Raises:
- ValueError
If representation mode is not supported.
- color_points(point_ids, color)[source]#
Color specific points in the geometry using set_scalars backend.
- Parameters:
- point_idsnp.ndarray
Set of point indices to color
- colortuple of float
RGB color values (0-1) to apply to selected points
- property geometry_type#
Return a descriptive type of the current instance
- get_number_of_points()[source]#
Get total number of points in the geometry.
- Returns:
- int
Number of points.
- classmethod merge(geometries)[source]#
Merge multiple geometry objects into a single geometry.
- Parameters:
- geometrieslist of Geometry
List of geometry objects to merge.
- Returns:
- Geometry
New geometry object containing merged data.
- Raises:
- ValueError
If no geometries provided for merging.
- property normals#
Normal vectors at each point.
- Returns:
- np.ndarray or None
Normal vectors with shape (n_points, 3), or None if not set.
- property points#
3D point coordinates of the geometry.
- Returns:
- np.ndarray
Point coordinates with shape (n_points, 3).
- property quaternions#
Orientation quaternions for each point.
- Returns:
- np.ndarray or None
Quaternions in scalar-first format (n_points, 4), or None if not set.
- set_appearance(size=None, opacity=None, render_spheres=None, ambient=None, diffuse=None, specular=None, base_color=None, **kwargs)[source]#
Set visual appearance properties of the geometry.
- Parameters:
- sizeint, optional
Point size for rendering.
- opacityfloat, optional
Transparency level (0.0 to 1.0).
- render_spheresbool, optional
Whether to render points as spheres.
- ambientfloat, optional
Ambient lighting coefficient.
- diffusefloat, optional
Diffuse lighting coefficient.
- specularfloat, optional
Specular lighting coefficient.
- base_colortuple of float, optional
RGB color values.
- **kwargs
Additional appearance parameters.
- set_color(color=None)[source]#
Set uniform color for all points in the geometry.
- Parameters:
- colortuple of int, optional
RGB color values. Uses base color if None.
- set_scalars(scalars, color_lut, scalar_range=None, use_point=False)[source]#
Set scalar data for coloring points.
- Parameters:
- scalarsarray-like
Scalar values for each point.
- color_lutvtk.vtkLookupTable
Color lookup table for mapping scalars to colors.
- scalar_rangetuple, optional
Min and max scalar range for color mapping.
- use_pointbool, optional
Whether to use point data for scalar mode, by default False.
Notes
Data in scalars can be invalidated during this operation. No-op when in basis representation to preserve per-axis coloring.
- set_visibility(visibility=True)[source]#
Set geometry visibility in the scene.
- Parameters:
- visibilitybool, optional
Whether geometry should be visible, by default True.
- setup_lod(budget=None)[source]#
Build or clear the interaction-LOD actor.
- Parameters:
- budgetint, optional
Maximum points for the LOD representation. When None the global point budget from settings is used (per-geometry fallback; prefer container-level budgets).
- swap_data(points, normals=None, faces=None, quaternions=None, model=None, meta=None, **kwargs)[source]#
Replace geometry data with new point cloud or mesh data.
- Parameters:
- pointsnp.ndarray
New 3D point coordinates.
- normalsnp.ndarray, optional
New normal vectors.
- facesnp.ndarray, optional
New face connectivity indices.
- quaternionsnp.ndarray, optional
New orientation quaternions.
- model
mosaic.parametrization.Parametrization Model fitted to geometry data.
- metadict, optional
New metadata dictionary.
- Returns:
- int
Result of representation change.
- property visible#
Visibility state of the geometry.
- Returns:
- bool
True if geometry is visible, False otherwise.