Factory
Creating a Factory
The Factory is an easy user interface to create and update visual objects such as meshes, point-clouds, etc. The Factory will also automatically store each object in a dedicated Table of a Database. Thus, it requires a Database to connect to (by default, a new Database is created, but an exiting one can be specified):
from SSD.Core import UserAPI
factory = UserAPI(database_dir='my_directory',
database_name='my_database',
remove_existing=True)
Adding an object to the Factory
The Factory provides a specific method to create each of the available objects with add_<object>
.
These methods allow to highly customize the objects rendering style.
Each object will have a unique identifier in the factory, following the order of creation:
# Adding a mesh
idx = factory.add_mesh(positions=position_array,
cells=cells_array)
print(idx)
"""
>> 0
"""
# Adding a point-cloud
idx = factory.add_points(positions=position_array)
print(idx)
"""
>> 1
"""
Updating an object in the Factory
The Factory also provides a specific method to update each of the available objects with update_<object>
.
Object state and some rendering options can be updated depending on the object.
It is important to specify the right identifier in the factory (identifiers follow the order of creation):
# Updating a mesh
factory.update_mesh(object_id=0,
positions=updated_position_array)
# Updating a point-cloud
factory.update_points(object_id=1,
positions=updated_position_array)
Note
You can update a single object several times per time step, meaning that the same raw of data in the Table will
be modified.
A call to render
will synchronize Tables and a new row will be edited next (see Visualizer).
Available objects
The Factory allows to create several visual object types. The visualization data to provide does not depend on the Visualizer you will use.
Mesh
Field |
Type |
Init |
Update |
Description |
---|---|---|---|---|
|
ndarray |
Required |
Optional |
List of vertices. Updated position vector must always have the same size. |
|
ndarray |
Required |
Disabled |
List of connections between vertices. |
|
int |
Optional |
Disabled |
Sub-window in which the Mesh will be rendered. |
|
float |
Optional |
Optional |
Opacity of the Mesh between 0 and 1. |
|
str |
Optional |
Optional |
Uniform color of the Mesh. |
|
str |
Optional |
Disabled |
Name of the color palette that maps a color to a scalar value. |
|
ndarray |
Optional |
Optional |
List of scalar values to define color based on the colormap. |
|
bool |
Optional |
Optional |
Specifies if the Mesh should be rendered as wireframe. |
|
float |
Optional |
Optional |
Width of the edges. |
Example
factory.add_mesh(positions=pos_array,
cells=cells_array,
color_map='jet',
scalar_field=pos_array[:, 1],
wireframe=True,
line_width=1.)
Points
Field |
Type |
Init |
Update |
Description |
---|---|---|---|---|
|
ndarray |
Required |
Optional |
List of vertices. Updated position vector must always have the same size. |
|
int |
Optional |
Disabled |
Sub-window in which the Points will be rendered. |
|
float |
Optional |
Optional |
Opacity of the Points between 0 and 1. |
|
str |
Optional |
Optional |
Uniform color of the Points. |
|
str |
Optional |
Disabled |
Name of the color palette that maps a color to a scalar value. |
|
ndarray |
Optional |
Optional |
List of scalar values to define color based on the colormap. |
|
float |
Optional |
Optional |
Size of the Points. |
Example
factory.add_points(positions=pos_array,
color_map='jet',
scalar_field=pos_array[:, 1],
point_size=5)
Arrows
Field |
Type |
Init |
Update |
Description |
---|---|---|---|---|
|
ndarray |
Required |
Optional |
List of starting positions of the Arrows. |
|
ndarray |
Required |
Optional |
List of vectors defining the Arrows. |
|
int |
Optional |
Disabled |
Sub-window in which the Arrows will be rendered. |
|
float |
Optional |
Optional |
Opacity of the Arrows between 0 and 1. |
|
str |
Optional |
Optional |
Uniform color of the Arrows. |
|
str |
Optional |
Disabled |
Name of the color palette that maps a color to a scalar value. |
|
ndarray |
Optional |
Optional |
List of scalar values to define color based on the colormap. |
|
int |
Optional |
Disabled |
Circular resolution of the Arrows. |
Example
factory.add_arrows(positions=pos_array,
vectors=vec_array,
c='green',
res=15)
Markers
Field |
Type |
Init |
Update |
Description |
---|---|---|---|---|
|
int |
Required |
Optional |
Index of the object in the Factory on which the Markers will be rendered (Mesh or Points). |
|
ndarray |
Required |
Optional |
Indices of the vertices on which the Markers will be rendered. |
|
int |
Optional |
Disabled |
Sub-window in which the Markers will be rendered. |
|
float |
Optional |
Optional |
Opacity of the Markers between 0 and 1. |
|
str |
Optional |
Optional |
Uniform color of the Markers. |
|
str |
Optional |
Disabled |
Name of the color palette that maps a color to a scalar value. |
|
ndarray |
Optional |
Optional |
List of scalar values to define color based on the colormap. |
|
str |
Optional |
Optional |
Symbol of the Markers. |
|
float |
Optional |
Optional |
Size of the Markers. |
|
bool |
Optional |
Optional |
Specifies whether the symbols should be filled or not. |
Example
factory.add_markers(normal_to=0,
indices=[0, 15, 35],
c='red',
symbol='0')
Text
Field |
Type |
Init |
Update |
Description |
---|---|---|---|---|
|
str |
Required |
Optional |
Content of the Text. |
|
int |
Optional |
Disabled |
Sub-window in which the Text will be rendered. |
|
str |
Optional |
Disabled |
Horizontal and vertical positions of the Text between T (top), M (middle), B (bottom), R (right), L (left). |
|
str |
Optional |
Optional |
Uniform color of the Text. |
|
str |
Optional |
Disabled |
Font of the Text. |
|
int |
Optional |
Disabled |
Size of the Text. |
|
bool |
Optional |
Optional |
Apply bold style to the Text. |
|
bool |
Optional |
Optional |
Apply italic style to the Text. |
Example
factory.add_text(content='SSD',
corner='TM',
c='black',
bold=True)