API

UserAPI

class SSD.Core.Rendering.UserAPI.UserAPI(database: Database | None = None, database_dir: str = '', database_name: str | None = None, remove_existing: bool = False, non_storing: bool = False, idx_instance: int = 0)[source]
__init__(database: Database | None = None, database_dir: str = '', database_name: str | None = None, remove_existing: bool = False, non_storing: bool = False, idx_instance: int = 0)[source]

The UserAPI is a Factory used to easily create and update visual objects in the Visualizer.

Parameters:
  • database – Database to connect to.

  • database_dir – Directory that contains the Database file (used if ‘database’ is not defined).

  • database_name – Name of the Database file (used if ‘database’ is not defined).

  • remove_existing – If True, overwrite any existing Database file with the same path.

  • non_storing – If True, the Database will not be stored.

  • idx_instance – If several Factories are connected to the same Visualizer, specify the index of instances.

add_arrows(positions: ndarray, vectors: ndarray, at: int = 0, alpha: float = 1.0, c: str = 'green', colormap: str = 'jet', scalar_field: ndarray = array([], dtype=float64), res: int = 12) int[source]

Add new Arrows to the Factory.

Parameters:
  • positions – Positions of the Arrows DOFs.

  • vectors – Vectors of the Arrows.

  • at – Index of the window in which to Mesh will be rendered.

  • alpha – Arrows opacity.

  • c – Arrows color.

  • colormap – Colormap scheme name.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

  • res – Circular resolution of the arrows.

add_markers(normal_to: int, indices: ndarray, at: int = 0, alpha: float = 1.0, c: str = 'green', colormap: str = 'jet', scalar_field: ndarray = array([], dtype=float64), symbol: str = 'o', size: float = 1.0, filled: bool = True) int[source]

Add new Markers to the Factory.

Parameters:
  • normal_to – Index of the object that defines normals of the Markers.

  • indices – Indices of the DOFs of the object where the Markers will be centered.

  • at – Index of the window in which to Mesh will be rendered.

  • alpha – Markers opacity.

  • c – Markers color.

  • colormap – Colormap scheme name.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

  • symbol – Symbol of a Marker.

  • size – Size of a Marker.

  • filled – If True, the symbol is filled.

add_mesh(positions: ndarray, cells: ndarray, at: int = 0, alpha: float = 1.0, c: str = 'green', colormap: str = 'jet', scalar_field: ndarray = array([], dtype=float64), wireframe: bool = False, line_width: float = -1.0) int[source]

Add a new Mesh to the Factory.

Parameters:
  • positions – Positions of the Mesh DOFs.

  • cells – Faces of the Mesh.

  • at – Index of the window in which to Mesh will be rendered.

  • alpha – Mesh opacity.

  • c – Mesh color.

  • colormap – Colormap scheme name.

  • scalar_field – Scalar values used to color the Mesh regarding the colormap.

  • wireframe – If True, the Mesh will be rendered as wireframe.

  • line_width – Width of the edges of the faces.

add_points(positions: ndarray, at: int = 0, alpha: float = 1.0, c: str = 'green', colormap: str = 'jet', scalar_field: ndarray = array([], dtype=float64), point_size: int = 4) int[source]

Add a new Point Cloud to the Factory.

Parameters:
  • positions – Positions of the Point Cloud DOFs.

  • at – Index of the window in which to Mesh will be rendered.

  • alpha – Point Cloud opacity.

  • c – Point cloud color.

  • colormap – Colormap scheme name.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

  • point_size – Size of the points.

add_text(content: str, at: int = 0, corner: str = 'BR', c: str = 'black', font: str = '', size: int = -1, bold: bool = False, italic: bool = False)[source]

Add new 2D Text to the Factory.

Parameters:
  • content – Content of the Text.

  • at – Index of the window in which the Text will be rendered.

  • corner – Horizontal and vertical positions of the Text between T (top), M (middle) and B (bottom) - for instance, ‘BR’ stands for ‘bottom-right’.

  • c – Text color.

  • font – Font of the Text.

  • size – Size of the font.

  • bold – Apply bold style to the Text.

  • italic – Apply italic style to the Text.

close()[source]

Close the Visualization.

connect_visualizer(offscreen: bool = False)[source]

Connect the Factory to an existing Visualizer.

Parameters:

offscreen – If True, the visualization is done offscreen.

get_database() Database[source]

Get the Database instance.

get_database_path() Tuple[str][source]

Get the path to the Database.

launch_visualizer(backend: str = 'vedo', offscreen: bool = False, fps: int = 20) None[source]

Launch the Visualizer.

Parameters:
  • backend – The name of the Visualizer to use (either ‘vedo’ or ‘open3d’).

  • offscreen – If True, the visualization is done offscreen.

  • fps – Max frame rate.

render() None[source]

Render the current state of visual objects.

update_arrows(object_id: int, positions: ndarray | None = None, vectors: ndarray | None = None, alpha: float | None = None, c: str | None = None, scalar_field: ndarray | None = None)[source]

Update existing Arrows in the Factory.

Parameters:
  • object_id – Index of the object (follows the global order of creation).

  • positions – Positions of the Arrows DOFs.

  • vectors – Vectors of the Arrows.

  • alpha – Arrows opacity.

  • c – Arrows color.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

update_markers(object_id: int, normal_to: int | None = None, indices: ndarray | None = None, alpha: float | None = None, c: str | None = None, scalar_field: ndarray | None = None, symbol: str | None = None, size: float | None = None, filled: bool | None = None) None[source]

Update existing Markers in the Factory.

Parameters:
  • object_id – Index of the object (follows the global order of creation).

  • normal_to – Index of the object that defines normals of the Markers.

  • indices – Indices of the DOFs of the object where the Markers will be centered.

  • alpha – Markers opacity.

  • c – Markers color.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

  • symbol – Symbol of a Marker.

  • size – Size of a Marker.

  • filled – If True, the symbol is filled.

update_mesh(object_id: int, positions: ndarray | None = None, alpha: float | None = None, c: str | None = None, scalar_field: ndarray | None = None, wireframe: bool | None = None, line_width: float | None = None) None[source]

Update an existing Mesh in the Factory.

Parameters:
  • object_id – Index of the object (follows the global order of creation).

  • positions – Positions of the Mesh DOFs.

  • alpha – Mesh opacity.

  • c – Mesh color.

  • scalar_field – Scalar values used to color the Mesh regarding the colormap.

  • wireframe – If True, the Mesh will be rendered as wireframe.

  • line_width – Width of the edges of the faces.

update_points(object_id: int, positions: ndarray | None = None, alpha: float | None = None, c: str | None = None, scalar_field: ndarray | None = None, point_size: int | None = None) None[source]

Update an existing Point Cloud in the Factory.

Parameters:
  • object_id – Index of the object (follows the global order of creation).

  • positions – Positions of the Point Cloud DOFs.

  • alpha – Point Cloud opacity.

  • c – Point Cloud color.

  • scalar_field – Scalar values used to color the Point Cloud regarding the colormap.

  • point_size – Size of the points.

update_text(object_id: int, content: str | None = None, c: str | None = None, bold: bool | None = None, italic: bool | None = None)[source]

Update existing Text in the Factory.

Parameters:
  • object_id – Index of the object (follows the global order of creation).

  • content – Content of the Text.

  • c – Text color.

  • bold – Apply bold style to the Text.

  • italic – Apply italic style to the Text.

Visualizer

class SSD.Core.Rendering.Visualizer.Visualizer(backend: str = 'vedo', database: Database | None = None, database_dir: str = '', database_name: str | None = None, remove_existing: bool = False, fps: int = 20, nb_clients: int = 1)[source]
__init__(backend: str = 'vedo', database: Database | None = None, database_dir: str = '', database_name: str | None = None, remove_existing: bool = False, fps: int = 20, nb_clients: int = 1)[source]

The Visualizer is used to launch either the VedoVisualizer either the Open3dVisualizer. It is recommended to launch the visualizer with UserAPI.launch_visualizer() method.

Parameters:
  • backend – The name of the Visualizer to use (either ‘vedo’ or ‘open3d’).

  • database – Database to connect to.

  • database_dir – Directory which contains the Database file (used if ‘database’ is not defined).

  • database_name – Name of the Database (used if ‘database’ is not defined).

  • remove_existing – If True, overwrite a Database with the same path.

  • fps – Max frame rate.

  • nb_clients – Number of Factories to connect to.

get_database() Database[source]

Get the Database instance.

get_database_path() Tuple[str][source]

Get the path to the Database.

static launch(backend: str = 'vedo', database_dir: str = '', database_name: str = '', fps: int = 20, nb_clients: int = 1) None[source]

Launch the Open3dVisualizer in a new process to keep it interactive.

Parameters:
  • backend – The name of the Visualizer to use (either ‘vedo’ or ‘open3d’).

  • database_dir – Directory which contains the Database file (used if ‘database’ is not defined).

  • database_name – Name of the Database (used if ‘database’ is not defined).

  • fps – Max frame rate.

  • nb_clients – Number of Factories to connect to.

Replay

class SSD.Core.Rendering.Replay.Replay(database_name: str, database_dir: str = '', backend: str = 'vedo', fps: int = 20)[source]
__init__(database_name: str, database_dir: str = '', backend: str = 'vedo', fps: int = 20)[source]

Replay a simulation from saved visual data.

Parameters:
  • database_name – Name of the Database.

  • database_dir – Directory of the Database.

  • backend – The name of the Visualizer to use (either ‘vedo’ or ‘open3d’).

  • fps – Max frame rate.

launch()[source]

Initialize the Visualizer: create all Actors and render them in a Plotter.