porescene.scene module

class porescene.scene.Scene(extent)[source]

Bases: object

classmethod from_json(extent, pth_config)[source]

Creates a Scene instance 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’s scale, shift and aspect.

  • pth_config (Path) – Path to the PoreScene JSON configuration file. Its optional "axes" and "image" sections populate config_axes and config_image, respectively.

Returns:

Scene instance 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_axes()[source]

Adds axes with ticks and labels to the scene.

Return type:

Self

create_camera(view='3D')[source]

Brings camera in position.

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_lights()[source]

Adds all nessecary lightnings to the scene.

Return type:

Self

create_solid(pth, style='SOLID_DEFAULT', name='solid')[source]

Adds the solid into the scene.

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

get_material(style, name)[source]

Creates a new material instance for the given style.

hide_axes()[source]

Hides axes from render scene.

Return type:

Self

hide_clusters()[source]

Hides all spheres from render scene.

Return type:

Self

hide_cylinders()[source]

Hides all cylinders from render scene.

Return type:

Self

hide_solid()[source]

Hides the solid from render scene.

Return type:

Self

hide_spheres()[source]

Hides all spheres from render scene.

Return type:

Self

hide_void()[source]

Hides the void from render scene.

Return type:

Self

load(pth)[source]

Loads the current scene from BLEND file.

Return type:

Self

remove_axes()[source]

Removes the axes from the scene.

Return type:

Self

remove_defaults()[source]

Deletes the default cube and light of the blender scene.

Return type:

Self

remove_solid()[source]

Removes any solid from the scene.

Return type:

Self

remove_void(names='void')[source]

Removes any void from the 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 to pth_render.

Parameters:
  • pth_render (Path) – Output path for the rendered image. Blender appends the file-format extension when the path has none.

  • trim (bool) – If true, the saved image is cropped to its content, removing the surrounding empty margins, by default True.

Returns:

The output path the render was written to (pth_render).

Return type:

Path

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

save(pth)[source]

Saves the current scene as BLEND file.

Return type:

Self

show_axes()[source]

Hides axes from render scene.

Return type:

Self

show_clusters()[source]

Hides all spheres from render scene.

Return type:

Self

show_cylinders()[source]

Shows all cylinders in the render scene.

Return type:

Self

show_solid()[source]

Hides the solid from render scene.

Return type:

Self

show_spheres()[source]

Shows all spheres in the render scene.

Return type:

Self

show_void()[source]

Hides the void from render scene.

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 by from_json() from the given physical dims.

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().