DeepSDFStruct.utils#
Utility Functions#
This module provides general utility functions used throughout DeepSDFStruct, including logging configuration and color scheme definitions.
Functions#
- configure_logging
Set up logging for the DeepSDFStruct package with customizable output format and destinations.
- with_float32_lattice
Run a callable with a lattice structure temporarily cast to float32.
Constants#
- _TUWIEN_COLOR_SCHEME
TU Wien corporate color scheme for consistent visualization styling.
Functions
|
Configure logging for the DeepSDFStruct package. |
|
Run |
- DeepSDFStruct.utils.configure_logging(level=20, logfile=None)#
Configure logging for the DeepSDFStruct package.
Sets up a logger with a standard format and optional file output. This is called automatically when DeepSDFStruct is imported.
- Parameters:
level (int, default logging.INFO) – Logging level (e.g., logging.DEBUG, logging.INFO, logging.WARNING).
logfile (str, optional) – Path to log file. If provided, logs are written to both console and file. If None, logs only to console.
Examples
>>> from DeepSDFStruct.utils import configure_logging >>> import logging >>> >>> # Set debug level and log to file >>> configure_logging(level=logging.DEBUG, logfile='deepsdf.log')
Notes
The log format is: “HH:MM:SS message” All log messages are prefixed with a timestamp for easy debugging.
- DeepSDFStruct.utils.with_float32_lattice(lattice_struct, bounds, fn)#
Run
fn(bounds_f32)with lattice_struct temporarily cast to float32.The DeepSDF decoder and FlexiCubes mesh extraction only run in float32, while a downstream shape optimizer may hold the lattice parameters in float64. This helper performs the cast locally around
fnand restores the original dtypes afterwards, so callers never have to leave the lattice in a downgraded state.- Parameters:
lattice_struct (LatticeSDFStruct) – Structure whose parametrization parameters and
boundsbuffer are cast for the duration of the call.bounds (torch.Tensor) – Bounds tensor handed to
fnas float32. Not modified in place.fn (Callable[[torch.Tensor], Any]) – Called once, with the float32
bounds. Its return value is passed through.
- Returns:
Whatever
fnreturned.- Return type:
Any
Examples
>>> from DeepSDFStruct.utils import with_float32_lattice >>> from DeepSDFStruct.mesh import create_3D_mesh >>> mesh = with_float32_lattice( ... struct, ... struct.bounds, ... lambda b: create_3D_mesh(struct, 32, bounds=b, mesh_type="surface"), ... )