mesh¶
occulus.mesh
¶
Surface reconstruction from point clouds.
All reconstruction functions delegate to Open3D (optional dependency).
Import this module only when open3d is installed (pip install occulus[viz]).
Available functions
- :func:
poisson_mesh— Screened Poisson reconstruction (watertight, requires normals) - :func:
ball_pivoting_mesh— Ball Pivoting Algorithm (respects boundaries, requires normals) - :func:
alpha_shape_mesh— Alpha shape (concave, normals optional)
Each function returns a :class:MeshResult wrapping the Open3D TriangleMesh.
MeshResult
dataclass
¶
Result of surface reconstruction.
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
NDArray[float64]
|
Mesh vertices as (V, 3) array. |
faces |
NDArray[int32]
|
Triangle face indices as (F, 3) array. |
vertex_normals |
NDArray[float64] | None
|
Per-vertex normals as (V, 3) array, or |
vertex_colors |
NDArray[float64] | None
|
Per-vertex colors as (V, 3) float64 array in [0, 1], or |
Source code in src/occulus/mesh/__init__.py
n_faces
property
¶
Number of triangle faces.
n_vertices
property
¶
Number of mesh vertices.
to_open3d()
¶
Convert to an Open3D TriangleMesh.
Returns:
| Type | Description |
|---|---|
TriangleMesh
|
The mesh in Open3D format. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If Open3D is not installed. |
Source code in src/occulus/mesh/__init__.py
alpha_shape_mesh(cloud, *, alpha=1.0)
¶
Alpha shape surface reconstruction.
Computes the alpha-shape (generalised convex hull) of the point cloud. Produces non-watertight meshes that respect concavities. Normals are not required but are computed on the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
alpha
|
float
|
Alpha parameter controlling concavity. Smaller values produce tighter, more concave meshes, by default 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
MeshResult
|
Reconstructed mesh. |
Raises:
| Type | Description |
|---|---|
OcculusMeshError
|
If reconstruction fails or produces an empty mesh. |
ImportError
|
If Open3D is not installed. |
Source code in src/occulus/mesh/__init__.py
ball_pivoting_mesh(cloud, *, radii=None, radii_factor=3.0)
¶
Ball Pivoting Algorithm (BPA) surface reconstruction.
Rolls a virtual ball of the specified radius across the point cloud. Normals are required. Unlike Poisson, BPA does not fill holes and handles boundary regions more naturally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input cloud with normals. |
required |
radii
|
list[float] | None
|
Ball radii to use. Multiple radii help fill gaps at different scales.
If |
None
|
radii_factor
|
float
|
When auto-computing radii, multiply the mean NN distance by this factor to produce three candidate radii, by default 3.0. |
3.0
|
Returns:
| Type | Description |
|---|---|
MeshResult
|
Reconstructed mesh. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If the cloud has no normals. |
OcculusMeshError
|
If reconstruction fails or produces an empty mesh. |
ImportError
|
If Open3D is not installed. |
Source code in src/occulus/mesh/__init__.py
poisson_mesh(cloud, *, depth=8, width=0.0, scale=1.1, linear_fit=False, density_threshold_quantile=0.01)
¶
Screened Poisson surface reconstruction.
Produces a watertight mesh suitable for volume computation and rendering. Normals are required on the input cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input cloud with normals. Run :func: |
required |
depth
|
int
|
Octree depth controlling mesh resolution, by default 8. Higher values produce finer meshes at higher cost. |
8
|
width
|
float
|
Target octree cell width (overrides |
0.0
|
scale
|
float
|
Ratio of the solving domain diameter to the bounding-box diameter, by default 1.1. |
1.1
|
linear_fit
|
bool
|
Use linear interpolation for iso-surface extraction, by default |
False
|
density_threshold_quantile
|
float | None
|
Fraction (0–1) of low-density vertices to remove after reconstruction.
Set to |
0.01
|
Returns:
| Type | Description |
|---|---|
MeshResult
|
Reconstructed mesh. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If the cloud has no normals. |
OcculusMeshError
|
If reconstruction fails or produces an empty mesh. |
ImportError
|
If Open3D is not installed. |
Source code in src/occulus/mesh/__init__.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |