CMLibs Exporter
CMLibs Exporter is a Python package for exporting Argon documents to different formats. The exporter can export an Argon document to the following formats:
webGL
VTK
Wavefront
STL
Thumbnail
Image
webGL
The webGL export takes scenes described in an Argon document and produces a JSON description of the scenes. The JSON description is exported to a format @abi-software/scaffoldvuer can read and create a visualisation in the browser.
Usage:
from cmlibs.exporter import webgl
argon_document = "argon-document.json"
output_directory = "."
exporter = webgl.ArgonSceneExporter(output_target=output_directory)
exporter.load(argon_document)
exporter.export()
It is also possible to use the WebGL exporter to produce a JSON description of a Zinc scene without embedding it in an Argon document.
This can be achieved with the export_webgl_from_scene
method. This method has one required parameter (scene
) and one
optional parameter (scene_filter
). The scene
parameter is the Zinc Scene object to be exported. The scene_filter
parameter is a Zinc Scenefilter object associated with the Zinc scene and gives the user the option to filter which graphics are included
in the export.
Usage:
exporter = webgl.ArgonSceneExporter(output_target=output_directory)
exporter.export_webgl_from_scene(scene)
VTK
The VTK export takes scenes described in an Argon document and produces a VTK document for each of the scenes. The VTK export does not currently support time varying scenes. If an Argon document describes a time varying scene then VTK document(s) will be created only at the default time.
Usage:
from cmlibs.exporter import vtk
argon_document = "argon-document.json"
output_directory = "."
exporter = vtk.ArgonSceneExporter(output_target=output_directory)
exporter.load(argon_document)
exporter.export()
Wavefront
The wavefront export takes scenes described in an Argon document and produces a main wavefront file that references wavefront files for each of the scenes. The wavefront export does not currently support time varying scenes. If an Argon document describes a time varying scene then wavefront file(s) will only be created at the default time.
Usage:
from cmlibs.exporter import wavefront
argon_document = "argon-document.json"
output_directory = "."
exporter = wavefront.ArgonSceneExporter(output_target=output_directory)
exporter.load(argon_document)
exporter.export()
STL
The STL export takes scenes described in an Argon document and produces an STL document for the scene. The STL export does not currently support time varying scenes. If an Argon document describes a time varying scene then an STL file will only be created at the default time.
Usage:
from cmlibs.exporter import stl
argon_document = "argon-document.json"
output_directory = "."
exporter = stl.ArgonSceneExporter(output_target=output_directory)
exporter.load(argon_document)
exporter.export()
Thumbnail
The thumbnail export takes scenes described in an Argon document and produces a JPEG thumbnail for each of the scenes. The thumbnail export does not currently support time varying scenes. If an Argon document describes a time varying scene then only one thumbnail will be created and that will be done at the default time.
Usage:
from cmlibs.exporter import thumbnail
argon_document = "argon-document.json"
output_directory = "."
exporter = thumbnail.ArgonSceneExporter(output_target=output_directory)
exporter.load(argon_document)
exporter.export()
Image
The image export takes scenes described in an Argon document and produces a JPEG image of width x height for each of the scenes. The image export does not currently support time varying scenes. If an Argon document describes a time varying scene then only one image will be created and that will be done at the default time.
Usage:
from cmlibs.exporter import image
argon_document = "argon-document.json"
output_directory = "."
exporter = image.ArgonSceneExporter(2000, 3000, output_target=output_directory)
exporter.load(argon_document)
exporter.export()
Package API
webGL Module
Export an Argon document to WebGL documents suitable for scaffoldvuer.
- class cmlibs.exporter.webgl.ArgonSceneExporter(output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to webGL.
- export(output_target=None)
Export the current document to output_target. If no output_target is given then the output_target set at initialisation is used.
If there is no current document then one will be loaded from the current filename.
- Parameters:
output_target – Output directory location.
- export_view()
Export sceneviewer parameters to JSON format
- export_webgl()
Export graphics into JSON format, one json export represents one Zinc graphics.
- export_webgl_from_scene(scene, scene_filter=None)
Export graphics from a Zinc Scene into WebGL JSON format.
- Parameters:
scene – The Zinc Scene object to be exported.
scene_filter – Optional; A Zinc Scenefilter object associated with the Zinc scene, allowing the user to filter which graphics are included in the export.
VTK Module
Export an Argon document to VTK.
- class cmlibs.exporter.vtk.ArgonSceneExporter(output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to VTK.
- export(output_target=None)
Export the current document to output_target. If no output_target is given then the output_target set at initialisation is used.
If there is no current document then one will be loaded from the current filename.
- Parameters:
output_target – Output directory location.
- export_vtk()
Export surface and line graphics into VTK format.
- export_vtk_from_scene(scene, scene_filter=None)
Export graphics from a Zinc Scene into VTK format.
- Parameters:
scene – The Zinc Scene object to be exported.
scene_filter – Optional; A Zinc Scenefilter object associated with the Zinc scene, allowing the user to filter which graphics are included in the export.
Wavefront Module
Export an Argon document to Wavefront documents.
- class cmlibs.exporter.wavefront.ArgonSceneExporter(output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to Wavefront.
- export(output_target=None)
Export the current document to output_target. If no output_target is given then the output_target set at initialisation is used.
If there is no current document then one will be loaded from the current filename.
- Parameters:
output_target – Output directory location.
- export_wavefront()
Export graphics into Wavefront format, one Wavefront export represents one Zinc graphics.
- export_wavefront_from_scene(scene, scene_filter=None)
Export graphics from a Zinc Scene into Wavefront format.
- Parameters:
scene – The Zinc Scene object to be exported.
scene_filter – Optional; A Zinc Scenefilter object associated with the Zinc scene, allowing the user to filter which graphics are included in the export.
STL Module
Export an Argon document to an STL document.
- class cmlibs.exporter.stl.ArgonSceneExporter(output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to STL.
- export(output_target=None)
Export the current document to output_target. If no output_target is given then the output_target set at initialisation is used.
If there is no current document then one will be loaded from the current filename.
- Parameters:
output_target – Output directory location.
- export_stl()
Export surface and line graphics into STL format.
- export_stl_from_scene(scene, scene_filter=None)
Export graphics from a Zinc Scene into STL format.
- Parameters:
scene – The Zinc Scene object to be exported.
scene_filter – Optional; A Zinc Scenefilter object associated with the Zinc scene, allowing the user to filter which graphics are included in the export.
Thumbnail Module
Export an Argon document to a JPEG file of size 512x512.
- class cmlibs.exporter.thumbnail.ArgonSceneExporter(output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to JPEG thumbnail. See the BaseImageExporter for rendering options.
Image Module
Export an Argon document to a JPEG file of size Width x Height.
- class cmlibs.exporter.image.ArgonSceneExporter(width, height, output_target=None, output_prefix=None)
Export a visualisation described by an Argon document to JPEG image. See the BaseImageExporter for rendering options.
Base Module
- class cmlibs.exporter.base.BaseExporter(output_prefix)
- load(filename)
Loads the named Argon file and on success sets filename as the current location. Emits documentChange separately if new document loaded, including if existing document cleared due to load failure.
- Returns:
True on success, otherwise False.
- set_document(document)
Set the document to export.
- Parameters:
document – Set the document to export.
- set_filename(filename)
Set filename.
- Parameters:
filename – The filename for the Argon document.
- set_parameters(parameters)
Set the parameters for this exporter. The parameters must have values for:
numberOfTimeSteps
initialTime
finishTime
prefix
- Parameters:
parameters – A dict of parameters.
Base Image Module
Base class for exporting an Argon document to a JPEG image.
- class cmlibs.exporter.baseimage.BaseImageExporter(width, height, name_postfix, output_target=None, output_prefix=None)
A base class for exporting visualisation described by an Argon document to JPEG. By default the export will be use PySide6 to render the scene. An alternative is to use OSMesa for software rendering. To use OSMesa as the renderer either set the environment variable OC_EXPORTER_RENDERER to ‘osmesa’ or not have PySide6 available in the calling environment.
- export(output_target=None)
Export the current document to output_target. If no output_target is given then the output_target set at initialisation is used.
If there is no current document then one will be loaded from the current filename.
- Parameters:
output_target – Output directory location.
- export_image()
Export graphics into an image format.