sdf_utils
This module provides utility functions for working with SDF volumes.
mesh_from_sdf(sdf_volume, level=0, complete_mesh=False)
Compute mesh from sdf using marching cubes algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sdf_volume |
array
|
the SDF volume to convert, shape (M, M, M) |
required |
level |
Optional[float]
|
the isosurface level to extract the mesh for |
0
|
complete_mesh |
bool
|
if True, the SDF will be padded with positive values prior to converting it to a mesh. This ensures a watertight mesh is created. |
False
|
Returns: The resulting mesh.
Source code in sdfest/vae/sdf_utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
mesh_to_sdf(mesh, cells_per_dim, padding=0)
Convert mesh to discretized signed distance field.
The mesh will be stretched, so that its longest extend fills out the unit cube leaving the specified padding empty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh |
Trimesh
|
The mesh to convert. |
required |
cells_per_dim |
int
|
The number of cells along each dimension. |
required |
padding |
Optional[int]
|
Number of empty space cells. |
0
|
Returns: The discretized signed distance field.
Source code in sdfest/vae/sdf_utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
plot_mesh(mesh, polar_angle=np.pi / 4, azimuth=0, camera_distance=2.5, plot_object=None, transform=None)
Render a mesh with camera pointing at its center.
Note that in pyrender z-axis is up, x,y form the polar_angle=0 plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh |
Trimesh
|
The mesh to render. |
required |
polar_angle |
Polar angle of the camera. For 0 the camera will look down the z-axis. |
pi / 4
|
|
azimuth |
Azimuth of the camera. For 0, polar_anlge=pi/2 the camera will look down the x axis. |
0
|
|
camera_distance |
Distance of camera to the origin. |
2.5
|
|
plot_object |
Optional[Axes]
|
Axis to plot the image. Will use plt if not provided. |
None
|
transform |
Optional[array]
|
Transform of the object. Identity by default. |
None
|
Source code in sdfest/vae/sdf_utils.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 |
|
visualize_sdf_batch_columns(sdfs, show=False)
Visualize batch of sdfs, with one per column (mesh + cross-views).
Source code in sdfest/vae/sdf_utils.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|