graphics Package

base Module

class Axes(pos=(0, 0, 0), rot=None, cylinder_radius=0.05)[source]

Bases: ars.graphics.base.Entity

class Body(center, rot)[source]

Bases: ars.graphics.base.Entity

Entity representing a defined body with a given color.

get_color()[source]
set_color(color)[source]
class Box(size, pos, rot=None)[source]

Bases: ars.graphics.base.Body

class Capsule(length, radius, center, rot=None, resolution=10)[source]

Bases: ars.graphics.base.Body

class Cone(height, radius, center, rot=None, resolution=100)[source]

Bases: ars.graphics.base.Body

Constructor.

Parameters:resolution (int) – it is the circumferential number of facets
class Cylinder(length, radius, center, rot=None, resolution=10)[source]

Bases: ars.graphics.base.Body

class Engine(*args, **kwargs)[source]

Bases: object

Abstract class. Not coupled (at all) with VTK or any other graphics library

add_object(obj)[source]

Add obj to the visualization controlled by this adapter.

Parameters:obj (Body) –
add_objects_list(obj_list)[source]
finalize_window()[source]

Finalize window and remove/clear associated resources.

remove_object(obj)[source]

Remove obj from the visualization controlled by this adapter.

Parameters:obj (Body) –
reset()[source]
restart_window()[source]
start_window(on_idle_callback, on_reset_callback, on_key_press_callback)[source]
class Entity(pos, rot)[source]

Bases: object

Renderable and movable object.

It has position and orientation. The underlying object is actor, which connects to the real entity handled by the graphics library in use.

actor
adapter = None
set_pose(pos, rot)[source]
class ScreenshotRecorder(base_filename)[source]

Bases: object

calc_filename(index=1)[source]

Calculate a filename using index for a new image.

Parameters:index (int) – image’s index to use for filename calculation
Returns:image’s filename
Return type:str
file_extension = None
write(index, time)[source]

Write render-window’s currently displayed image to a file.

The image format (thus the file extension too) to use must be defined by the implementation.

Image’s filename is determined by calc_filename().

Parameters:
  • index (int) – image’s index to use for filename calculation
  • time
class Sphere(radius, center, rot=None, phi_resolution=50, theta_resolution=50)[source]

Bases: ars.graphics.base.Body

Constructor.

Parameters:
  • phi_resolution (int) – resolution in the latitude (phi) direction
  • theta_resolution (int) – resolution in the longitude (theta) direction
class Trimesh(vertices, faces, pos=None, rot=None)[source]

Bases: ars.graphics.base.Body

vtk_adapter Module

class Axes(pos=(0, 0, 0), rot=None, cylinder_radius=0.05)[source]

Bases: ars.graphics.vtk_adapter.Entity, ars.graphics.base.Axes

class Body(*args, **kwargs)[source]

Bases: ars.graphics.vtk_adapter.Entity

get_color()[source]

Returns the color of the body. If it is an assembly, it is not checked whether all the objects’ colors are equal.

set_color(color)[source]

Sets the color of the body. If it is an assembly, all the objects’ color is set.

class Box(size, pos, rot=None)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Box

class Capsule(length, radius, center, rot=None, resolution=20)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Capsule

class Cone(height, radius, center, rot=None, resolution=20)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Cone

class Cylinder(length, radius, center, rot=None, resolution=20)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Cylinder

class Engine(title, pos=None, size=(1000, 600), zoom=1.0, cam_position=(10, 8, 10), background_color=(0.1, 0.1, 0.4), **kwargs)[source]

Bases: ars.graphics.base.Engine

Graphics adapter to the Visualization Toolkit (VTK) library

add_object(obj)[source]
finalize_window()[source]

Finalize and delete renderer, render_window and interactor.

remove_object(obj)[source]
reset()[source]
restart_window()[source]
start_window(on_idle_callback=None, on_reset_callback=None, on_key_press_callback=None)[source]
class Entity(*args, **kwargs)[source]

Bases: object

adapter

alias of Engine

class ScreenshotRecorder(base_filename='screenshot_', graphics_adapter=None)[source]

Bases: ars.graphics.base.ScreenshotRecorder

Based on an official example script, very simple: http://www.vtk.org/Wiki/VTK/Examples/Python/Screenshot

file_extension = 'png'
write(index=1, time=None)[source]

Note

Image files format is PNG, and extension is .png.

class Sphere(radius, center, rot=None, phi_resolution=20, theta_resolution=20)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Sphere

VTK: sphere (represented by polygons) of specified radius centered at the origin. The resolution (polygonal discretization) in both the latitude (phi) and longitude (theta) directions can be specified.

class Trimesh(vertices, faces, pos, rot=None)[source]

Bases: ars.graphics.vtk_adapter.Body, ars.graphics.base.Trimesh