Modules¶
PolyscopeApp
¶
Source code in yumo/app.py
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 76 77 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
callback()
¶
The main callback loop for Polyscope.
Source code in yumo/app.py
prepare_data_and_init_structures()
¶
Load data from files, create structures.
Source code in yumo/app.py
run()
¶
Initialize and run the Polyscope application.
Source code in yumo/app.py
update_all_scalar_quantities_colormap()
¶
Update colormaps on all structures (including slices).
Structure
¶
Bases: ABC
Abstract base class for a visualizable structure in Polyscope.
Source code in yumo/base_structure.py
polyscope_structure
abstractmethod
property
¶
Get the underlying Polyscope structure object.
add_prepared_quantities()
¶
Adds all prepared scalar quantities to the registered Polyscope structure.
Source code in yumo/base_structure.py
callback()
abstractmethod
¶
is_valid()
abstractmethod
¶
prepare_quantities()
abstractmethod
¶
register(force=False)
¶
Registers the structure's geometry with Polyscope. (Called every frame, but runs once).
Source code in yumo/base_structure.py
set_enabled(enabled)
¶
ui()
abstractmethod
¶
update_all_quantities_colormap()
¶
Updates the colormap and range for all managed quantities.
bake_to_texture(sample_uvs, values, H, W)
¶
Bake scalar values into a texture map using scatter-add.
UV space (0,0 bottom-left) is converted to image space (0,0 top-left).
Source code in yumo/geometry_utils.py
blur(texture, sigma=1.0, mask=None, **kwargs)
¶
Apply Gaussian blur to a texture while ignoring zero-padding.
This function performs a mask-aware Gaussian filter: both the texture and a binary mask are smoothed, and then the results are normalized to prevent padded zeros from biasing the blur.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texture
|
ndarray
|
Input texture array. Padding regions should be zeros. Can be 2D (H, W) or 3D (H, W, C). |
required |
sigma
|
float
|
Standard deviation of the Gaussian kernel. Defaults to 1.0. |
1.0
|
mask
|
ndarray
|
(0) Padding (1) Islands. |
None
|
**kwargs
|
Useless. For compatibility only. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Blurred texture with padding ignored. Same shape as input. |
Source code in yumo/geometry_utils.py
denoise_texture(texture, method='nearest_and_gaussian', **kwargs)
¶
Fill missing (zero) values in a sparse 2D texture map using interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texture
|
ndarray
|
A 2D NumPy array representing the texture map. Zero entries are treated as missing data to be filled. |
required |
method
|
str
|
Interpolation method to use. Options are: - "gaussian": Simple gaussian filter. - "nearest_and_gaussian": Fill using nearest-neighbour then gaussian blur. - "nearest": Fill using nearest-neighbor interpolation. Defaults to "linear". |
'nearest_and_gaussian'
|
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray:
A 2D NumPy array of the same shape as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in yumo/geometry_utils.py
generate_slice_mesh(center, h, w, rh, rw)
¶
Generate a slice plane mesh in the XY-plane, centered on center.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
ndarray
|
3D coordinate where the center of the mesh will be placed (shape (3,)) |
required |
h
|
float
|
physical height of the plane |
required |
w
|
float
|
physical width of the plane |
required |
rh
|
int
|
resolution along height (number of vertices) |
required |
rw
|
int
|
resolution along width (number of vertices) |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: vertices: (N, 3) array of 3D coordinates faces: (M, 3) array of integer indices into vertices |
Source code in yumo/geometry_utils.py
map_to_uv(uvs, faces_unwrapped, barycentric_coord, indices)
¶
Vectorized barycentric interpolation in UV space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uvs
|
ndarray
|
(V, 2) UV coordinates. |
required |
faces_unwrapped
|
ndarray
|
(M, 3) indices into uvs. |
required |
barycentric_coord
|
ndarray
|
(L, 3) barycentric weights. |
required |
indices
|
ndarray
|
(L,) face index ids. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
sample_uvs |
ndarray
|
(L, 2). |
Source code in yumo/geometry_utils.py
nearest_and_blur(texture, blur_sigma=1.0, max_dist=16, mask=None, **kwargs)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texture
|
|
required | |
blur_sigma
|
|
1.0
|
|
max_dist
|
|
16
|
|
mask
|
ndarray
|
(0) Padding (1) Islands. |
None
|
**kwargs
|
|
{}
|
Returns:
Source code in yumo/geometry_utils.py
nearest_fill(texture, max_dist=16, mask=None, **kwargs)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texture
|
|
required | |
max_dist
|
|
16
|
|
mask
|
ndarray
|
(0) Padding (1) Islands. |
None
|
**kwargs
|
|
{}
|
Returns:
Source code in yumo/geometry_utils.py
query_scalar_field(points_coord, data_points, cache=True)
¶
Query scalar field f(x,y,z) in vectorized form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_coord
|
ndarray
|
(L, 3). |
required |
data_points
|
ndarray
|
(data_len, 4) xyz,value |
required |
cache
|
bool
|
Enable cache for cKDTree construction. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
values |
ndarray
|
(L,). |
Source code in yumo/geometry_utils.py
sample_surface(vertices, faces, points_per_area=10.0, rng=None)
¶
Vectorized surface sampling on a triangular mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
ndarray
|
(N, 3). Vertex positions. |
required |
faces
|
ndarray
|
(M, 3). Triangle vertex indices. |
required |
points_per_area
|
float
|
Density (points per unit area). |
10.0
|
rng
|
Generator
|
Random generator to use. If None, defaults to np.random. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
points_coord |
ndarray
|
(L, 3). Sampled 3D points. |
barycentric_coord |
ndarray
|
(L, 3). Barycentric coords. |
indices |
ndarray
|
(L,). Face index for each point. |
Source code in yumo/geometry_utils.py
unwrap_uv(vertices, faces, padding=16, brute_force=False)
¶
Performs UV unwrapping for a given 3D mesh using the xatlas library with padding settings to reduce UV bleeding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
ndarray
|
(N, 3) float array of mesh vertex positions. |
required |
faces
|
ndarray
|
(M, 3) int array of triangular face indices. |
required |
padding
|
int
|
Padding in pixels between UV islands (default=16px). |
16
|
brute_force
|
bool
|
Slower, but gives the best result. If false, use random chart placement. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Tuple containing: |
int
|
|
int
|
|
ndarray
|
|
ndarray
|
|
ndarray
|
|
ndarray
|
|
tuple[ndarray, int, int, ndarray, ndarray, ndarray, ndarray]
|
|
Source code in yumo/geometry_utils.py
uv_mask(uvs, faces_unwrapped, texture_width, texture_height, dilation=2, supersample=4)
¶
Creates a binary (or soft) mask indicating which parts of the texture atlas are occupied by the mesh (True) and which are empty (False).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uvs
|
ndarray
|
(N,2) UV coordinates in [0,1]. |
required |
faces_unwrapped
|
ndarray
|
(F,3) triangle indices into uvs. |
required |
texture_width
|
int
|
target texture width in pixels. |
required |
texture_height
|
int
|
target texture height in pixels. |
required |
dilation
|
int
|
number of pixels to expand the mask after rasterization. |
2
|
supersample
|
int
|
supersampling factor for more accurate rasterization. |
4
|
Source code in yumo/geometry_utils.py
MeshStructure
¶
Bases: Structure
Represents a surface mesh structure.
Source code in yumo/mesh.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 76 77 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
add_prepared_quantities()
¶
Adds all prepared scalar quantities to the registered Polyscope structure.
Source code in yumo/mesh.py
bake_texture(sampler_func)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampler_func
|
Callable[[ndarray], ndarray]
|
Takes in sample query points (N, 3), outputs values (N,) |
required |
Returns:
Source code in yumo/mesh.py
prepare_quantities()
¶
We preview the resolution first before proceeding to actual data sampling in update_data_texture.
ui()
¶
Mesh related UI
Source code in yumo/mesh.py
update_data_texture()
¶
Sample the data points and update texture map
Source code in yumo/mesh.py
update_resolution_preview()
¶
Add a preview quantity of the surface sampling resolution using bake_texture
Source code in yumo/mesh.py
PointCloudStructure
¶
Bases: Structure
Represents a point cloud structure.
Source code in yumo/point_cloud.py
15 16 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 44 45 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 76 77 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 | |
Slice
¶
Bases: Structure
Source code in yumo/slices.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 44 45 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 76 77 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
prepare_quantities()
¶
Prepare the scalar data from the 4th column of the points array.
Source code in yumo/slices.py
ui_combo(label, current_value)
¶
A context manager for creating an ImGui combo box.
ui_tree_node(label, open_first_time=True)
¶
A context manager for creating a collapsible ImGui tree node.
This correctly handles the ImGui pattern of checking the return of TreeNode and calling TreePop conditionally, while ensuring the context manager protocol is always followed.
Source code in yumo/ui.py
convert_power_of_10_to_scientific(x)
¶
Convert 10^x to scientific notation a*10^b where b is an integer
data_transform(points, method)
¶
Preprocess the last column of (N, 4) points array using data transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Array of shape (N, 4). The first three columns are coordinates, the last column is the scalar value to be transformed. |
required |
method
|
str
|
Preprocessing method. One of {"identity", "log_e", "log_10"}. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Preprocessed points with the same shape. |
Source code in yumo/utils.py
estimate_densest_point_distance(points, k=1000, quantile=0.01)
¶
Estimate the densest distance between points and their nearest neighbors.
This function samples k points from the input dataset, finds their nearest neighbors, and calculates the average distance after filtering outliers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Array of shape (n, d) containing n points in d-dimensional space. |
required |
k
|
int
|
Number of points to sample for the estimation. Default is 1000. |
1000
|
quantile
|
float
|
Quantile threshold for outlier removal. Default is 0.01. Only distances in the range [min, quantile] are considered. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float64
|
Estimated densest distance to nearest neighbor after outlier filtering. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If points is empty or not a 2D array. |
Source code in yumo/utils.py
export_camera_view(view_mat)
¶
Export a 4x4 camera view matrix to a JSON string (list of lists).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_mat
|
ndarray
|
A 4x4 numpy matrix. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON-formatted string representing the matrix. |
Source code in yumo/utils.py
fmtn(vec, n, precision=2)
¶
Format the first n components of a vector with fixed precision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vec
|
ndarray | list[float] | tuple[float, ...]
|
Vector (numpy array, list, or tuple of floats). |
required |
n
|
int
|
Number of components to format. |
required |
precision
|
int
|
Decimal precision. |
2
|
Returns:
| Type | Description |
|---|---|
str
|
A string like "(x1, x2, ..., xn)" with formatted floats. |
Source code in yumo/utils.py
format_scientific(x)
¶
generate_colorbar_image(colorbar_height, colorbar_width, cmap, c_min, c_max, method='identity', loaded_cmaps=None, font='Arial.ttf', font_size=12)
¶
Generate a colorbar image as a numpy array with different labeling methods.
Source code in yumo/utils.py
inverse_data_transform(points_or_values, method)
¶
Invert the preprocessing applied by data_transform on the last column or on a single scalar value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_or_values
|
ndarray or float
|
Either - Array of shape (N, 4) that has been transformed, or - A single transformed scalar value. |
required |
method
|
str
|
One of {"identity", "log_e", "log_10"}. |
required |
Returns:
| Type | Description |
|---|---|
ndarray | float
|
np.ndarray or float: Inverse-transformed array or scalar. |
Source code in yumo/utils.py
load_camera_view(json_str)
¶
Load a 4x4 camera view matrix from a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_str
|
str
|
JSON string representing the matrix. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A 4x4 numpy matrix. |
Source code in yumo/utils.py
write_plt_file(path, points)
¶
Write points to a Tecplot ASCII .plt file (FEPOINT format).