porescene.scene module¶
- class porescene.scene.Scene(extent)[source]¶
Bases:
object- classmethod from_json(extent, pth_config)[source]¶
Creates a
Sceneinstance sized to the given physical domain dimensions, configured from a PoreScene JSON configuration file.- Parameters:
extent (
ndarray) – Physical extent of the domain along x, y and z, used to derive the scene’sscale,shiftandaspect.pth_config (
Path) – Path to the PoreScene JSON configuration file. Its optional"axes"and"image"sections populateconfig_axesandconfig_image, respectively.
- Returns:
Sceneinstance created from the given dimensions and configuration file.- Return type:
Self
- apply_colors(name_mesh, colors, frame=0)[source]¶
Sets the colors for all items in a collection for given frame.
- Return type:
Self
- create_cells(pos, vtx_cv, p_selection=None, merge_dist=0, style='CELL_DEFAULT')[source]¶
- Return type:
Self
- create_clusters(pth, style='CLUSTER_DEFAULT')[source]¶
Adds pore clusters to the scene.
- Return type:
Self
- create_cylinders(pos, r, name='Cylinders', style='STRUCTURE_DEFAULT')[source]¶
Places a cylinder for each throat in the scene.
- Return type:
Self
- create_spheres(pos, r, name='Spheres', style='STRUCTURE_DEFAULT')[source]¶
Places a sphere for each pore in the scene.
- Return type:
Self
- create_void(pth, style='ICE', name='void')[source]¶
Adds a 3D object of the void space to the scene.
- Return type:
Self
- remove_defaults()[source]¶
Deletes the default cube and light of the blender scene.
- Return type:
Self
- render(pth_render, trim=True)[source]¶
Renders the current scene to an image file.
The render uses Blender’s Cycles engine at the width and height taken from the scene’s image configuration (
config_image) and writes the result topth_render.- Parameters:
- Returns:
The output path the render was written to (
pth_render).- Return type:
- rotate_azimuth(ang_rot)[source]¶
Rotates the camera and all lights around the scene’s vertical (Z) axis by the given azimuth angle
ang_rot(in degrees), orbiting them around the scene’s center while keeping the camera aimed there.The axes are literal rulers built along fixed edges of the (stationary) bounding box, so they can’t simply follow the camera’s continuous rotation without drifting off the box they are meant to measure. The x and y rulers each stay on whichever of their two parallel edges currently faces the camera – the x ruler flips between the front/back edge, the y ruler between the left/right edge – by mirroring to that edge and turning their ticks and labels 180 degrees, so ticks keep pointing outward and label text stays legible, rather than rotating the whole ruler (which would swap their x/y labeling, see the fixed bug this replaced). The main ruler bar itself is left unrotated since it’s symmetric along its own length. The z ruler sits at the corner shared by the current x and y edges, so it is snapped there in 90-degree steps the same way the whole assembly used to move.
- Return type:
Self
- property aspect: tuple[float, float, float]¶
Relative proportions of the domain along x, y and z, each normalized by the largest of the three so the longest axis is
1. Set byfrom_json()from the given physicaldims.
- property config_axes: AxesConfiguration¶
Configuration controlling how
create_axes()draws axis lines, ticks and labels.
- property config_image: ImageConfiguration¶
Configuration controlling how rendered images are post-processed.
- property config_scene: SceneConfiguration¶
Configuration controlling general scene appearance, such as which items are rendered and their styling.
- property has_axes: bool¶
Whether axes with ticks and labels have been added to the scene, via
create_axes().
- property has_clusters: bool¶
Whether pore clusters have been added to the scene, via
create_clusters().
- property has_cylinders: bool¶
Whether throat cylinders have been added to the scene, via
create_cylinders().
- property has_lights: bool¶
Whether lights have been added to the scene, via
create_lights().
- property has_solid: bool¶
Whether the solid object has been added to the scene, via
create_solid().
- property has_spheres: bool¶
Whether pore spheres have been added to the scene, via
create_spheres().
- property has_void: bool¶
Whether the void-space object has been added to the scene, via
create_void().