Package bar :: Package rec :: Module barreconstructor :: Class barReconstructionModule
[hide private]
[frames] | no frames]

Class barReconstructionModule


The class provides an interface to create reconstruction model from a volume.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
{str: function}
__createExportByExt(self, formatInfo)
Create file extension to export method mapping.
 
addRenderWindow(self, renderWindow)
Assign the renderWindow to renWin; add renderer as one of the window renderers.
 
__createMainActor(self)
If no main actor (self.__mainActor == None) create it from the volume self.__sourceVolume (if exists).
 
setReconstructionSource(self, structVol, ct)
Assign requested model colour and source volume for reconstruction.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Clearing methods
 
clearVolume(self)
Remove source volume.
 
clearScene(self)
Remove all actors (main actors as well as context actors) from the scene.
 
__clearCache(self)
Remove all cached result of source volume processing.
 
__removeMainActor(self)
Remove the main actor from the scene.
    Context actor manipulation methods
 
appendContextActor(self, name, filename, color, customProps={})
Add a context actor (actor with a name) loaded from a file to the scene.
 
removeContextActor(self, name)
Remove the context actor from the scene.
float or None
getContextActorOpacity(self, name)
Returns: actors opacity; None if actor not found in the scene
bool
setContextActorTransparent(self, name)
Make the context actor transparent.
bool
hasContextActor(self, name)
Check if the context actor is in the scene.
    Render window refreshing methods
 
refreshRenderWindow(self)
Render the scene to the render window.
 
updateRenderWindow(self, resetCamera=True)
Focus the camera on the scene and render the scene to the render window.
    Export methods
 
exportPipeline(self, filename)
Export an XML representation of the pipeline to a file.
 
__exportToVtkExporter(self, vtkExporterObj, filename)
Export the rendered scene to a file.
 
exportToVRML(self, filename)
Export the rendered scene to a VRML file.
 
exportToSTL(self, filename)
Export the rendered scene to a Wavefront .obj file.
 
exportToX3d(self, filename)
Export the rendered scene to an X3D file.
 
exportToPOVRay(self, filename)
Export the rendered scene to a POV-Ray file.
 
exportScreenshot(self, filename)
Save screenshot of the render window into a PNG file.
 
exportThumbnail(self, filename)
Save scaled screenshot of the render window into a PNG file.
 
__exportToVtkDataExporter(self, vtkDataWriterObj, data, filename)
Export the reconstruction to a file.
 
exportToVolume(self, filename)
Export the reconstructed volume to a VTKstructGrid file.
 
exportToVTKPolydata(self, filename)
Export the reconstructed mesh to a VTKpolyMesh file.
 
exportToNiftii(self, filename)
Export the reconstructed volume to a Niftii file.
 
exportToNumpy(self, filename)
Export the reconstructed volume as an 3D array to a Numpy file.
    Property access methods
 
__getCameraPosition(self)
The cameraPosition property getter.
 
__setCameraPosition(self, position, fp=(0.0, 0.0, 0.0))
The cameraPosition property setter.
 
__setCameraViewUp(self, top)
The top property setter.
 
__getCameraViewUp(self)
The top property getter.
 
__setProjectionParallel(self, parallel)
The parallelProjection property setter.
 
__getProjectionParallel(self)
The parallelProjection property getter.
 
__getPipeline(self)
The pipeline property getter.
 
__setPipeline(self, newPipeline)
The pipeline property setter.
 
__getVtkVolume(self)
The vtkVolume property getter.
 
__setVtkVolume(self, value)
The vtkVolume property setter.
 
__getVtkMesh(self)
The vtkMesh property getter.
 
__setVtkMesh(self, value)
The vtkMesh property setter.
 
__setBackground(self, background)
Background colour setter.
(float, float, float)
__getBackground(self)
Returns: RGB components of background colour
Instance Variables [hide private]
  __mainActorCol
The colour of model to be reconstructed.
dataImporterFromNumpy object __sourceVolume
The source volume to perform reconstruction from.
{str: function} exportSceneByExt
file extension to scene export method mapping
{str: function} exportVolumeByExt
file extension to volume export method mapping
vtkRenderWindow renWin
The window used by the object to render.
VTK renderer renderer
The renderer used by the object.
    Actors
dict(str: VTK actor) __contextActors
The structure name to displayable model mapping.
VTK actor __mainActor
The displayable reconstructed model of structure.
    Cache
  __vtkMesh
The cached result of execution the mesh processing part of the pipeline (self.__meshPipeline) on self.vtkVolume.
  __vtkVolume
The cached result of execution the volumetric part of the pipeline (self.__volumePipeline) on self.__sourceVolume.
    Pipelines
barPipeline object __finalPipeline
The actor creating part of the pipeline.
barPipeline object __meshPipeline
The mesh processing part of the pipeline See pipeline for details.
barPipeline object __pipeline
The pipeline used by the object.
barPipeline object __volumePipeline
The volume processing part of the pipeline.
Properties [hide private]
  pipeline
The reconstruction pipeline used by the object.
  cameraPosition
The direction from the center of the scene to the camera position.
  cameraViewUp
The "up" direction.
  parallelProjection
True if the camera projection is parallel, False if perspective.
  vtkVolume
The result of execution of the volume processing part of the pipeline on the reconstruction source volume.
  vtkMesh
The vtkMesh property getter.
(float, float, float) background
RGB components of background colour.

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__createExportByExt(self, formatInfo)

 

Create file extension to export method mapping.

Parameters:
  • formatInfo ({str: {'ext': str, ...}, ...}) - information about formats to be included in the mapping
Returns: {str: function}
file extension to export method mapping

addRenderWindow(self, renderWindow)

 

Assign the renderWindow to renWin; add renderer as one of the window renderers.

Parameters:
  • renderWindow () - the window to perform rendering.

__createMainActor(self)

 

If no main actor (self.__mainActor == None) create it from the volume self.__sourceVolume (if exists). The colour of main actor is given by self.__mainActorCol

setReconstructionSource(self, structVol, ct)

 

Assign requested model colour and source volume for reconstruction.

Parameters:
  • structVol (VTKStructuredPoints object) - source volume for reconstruction
  • ct - requested colour of reconstructed model

Note: Method removes current reconstruction.

__clearCache(self)

 

Remove all cached result of source volume processing.

Note: the main actor in the scene is also considered as a cached result.

appendContextActor(self, name, filename, color, customProps={})

 

Add a context actor (actor with a name) loaded from a file to the scene.

Parameters:
  • name (str) - the name of the actor
  • filename (str) - path to a file containing the actor
  • color ((float, float, float)) - the requested colour of the actor
  • customProps (dictionary storing additional properties to be applied to the actor (opacity, diffuse color, etc.)) - dict

Note: the method DOES NOT trigger the scene to render

removeContextActor(self, name)

 

Remove the context actor from the scene.

Parameters:
  • name (str) - name of the actor to be removed.

Note: the method DOES NOT trigger the scene to render

getContextActorOpacity(self, name)

 
Parameters:
  • name (str) - name of the context actor
Returns: float or None
actors opacity; None if actor not found in the scene

setContextActorTransparent(self, name)

 

Make the context actor transparent.

Parameters:
  • name (str) - name of the context actor
Returns: bool
False if actor not found in the scene, otherwise True

hasContextActor(self, name)

 

Check if the context actor is in the scene.

Parameters:
  • name (str) - the name of the context actor
Returns: bool
True if the actor named name is in the scene, False otherwise.

updateRenderWindow(self, resetCamera=True)

 

Focus the camera on the scene and render the scene to the render window.

Parameters:
  • resetCamera (bool) - indicates if the camera has to be resetted

Note: if there is no main actor in the scene and the source volume is set, the actor will be created and added to the scene before rendering

exportPipeline(self, filename)

 

Export an XML representation of the pipeline to a file.

Parameters:
  • filename (str) - the name of the file

__exportToVtkExporter(self, vtkExporterObj, filename)

 

Export the rendered scene to a file.

Parameters:
  • vtkExporterObj (vtkExporter) - exporter of the scene to requested file format
  • filename (str) - the name of the file

exportToVRML(self, filename)

 

Export the rendered scene to a VRML file.

Parameters:
  • filename (str) - the name of the file

exportToSTL(self, filename)

 

Export the rendered scene to a Wavefront .obj file.

Parameters:
  • filename (str) - the name of the file

exportToX3d(self, filename)

 

Export the rendered scene to an X3D file.

Parameters:
  • filename (str) - the name of the file

exportToPOVRay(self, filename)

 

Export the rendered scene to a POV-Ray file.

Parameters:
  • filename (str) - the name of the file

Note: some VTK revisions do not implement necessary vtk.vtkPOVExporter.SetFileName method

exportScreenshot(self, filename)

 

Save screenshot of the render window into a PNG file.

Parameters:
  • filename (str) - the name of the file

exportThumbnail(self, filename)

 

Save scaled screenshot of the render window into a PNG file.

Parameters:
  • filename (str) - the name of the file

__exportToVtkDataExporter(self, vtkDataWriterObj, data, filename)

 

Export the reconstruction to a file.

Parameters:
  • data - the reconstruction
  • vtkDataWriterObj (vtkDataWriter object) - the writer of VTK data to the requested file format
  • filename (str) - the name of the file

exportToVolume(self, filename)

 

Export the reconstructed volume to a VTKstructGrid file.

Parameters:
  • filename (str) - the name of the file

exportToVTKPolydata(self, filename)

 

Export the reconstructed mesh to a VTKpolyMesh file.

Parameters:
  • filename (str) - the name of the file

exportToNiftii(self, filename)

 

Export the reconstructed volume to a Niftii file.

Parameters:
  • filename (str) - the name of the file

exportToNumpy(self, filename)

 

Export the reconstructed volume as an 3D array to a Numpy file.

Parameters:
  • filename (str) - the name of the file

__setPipeline(self, newPipeline)

 

The pipeline property setter.

The pipeline is stored in the object as:

__setVtkVolume(self, value)

 

The vtkVolume property setter.

When called raises ValueError.

__setVtkMesh(self, value)

 

The vtkMesh property setter.

When called raises ValueError.

__setBackground(self, background)

 

Background colour setter.

Parameters:
  • background ((float, float, float)) - RGB components of background colour

__getBackground(self)

 
Returns: (float, float, float)
RGB components of background colour

Instance Variable Details [hide private]

__finalPipeline

The actor creating part of the pipeline. See pipeline for details.
Type:
barPipeline object

__mainActor

The displayable reconstructed model of structure. The model is a result of execution the final part of the pipeline (self.__finalPipeline) on self.vtkMesh
Type:
VTK actor

__pipeline

The pipeline used by the object. See pipeline for details.
Type:
barPipeline object

__volumePipeline

The volume processing part of the pipeline. See pipeline for details.
Type:
barPipeline object

Property Details [hide private]

pipeline

The reconstruction pipeline used by the object.

The pipeline is composed of three parts:

  1. volume processing pipeline (ends with the last filter returning vtkImageData object),
  2. mesh processing pipeline (ends with the last filter returning vtkPolyData object)
  3. actor creating pipeline (mapper element of the pipeline - usually vtkPpolyDataMapper)
Get Method:
__getPipeline(self) - The pipeline property getter.
Set Method:
__setPipeline(self, newPipeline) - The pipeline property setter.

cameraPosition

The direction from the center of the scene to the camera position.

Get Method:
__getCameraPosition(self) - The cameraPosition property getter.
Set Method:
__setCameraPosition(self, position, fp=(0.0, 0.0, 0.0)) - The cameraPosition property setter.

cameraViewUp

The "up" direction.

Get Method:
__getCameraViewUp(self) - The top property getter.
Set Method:
__setCameraViewUp(self, top) - The top property setter.

parallelProjection

True if the camera projection is parallel, False if perspective.

Get Method:
__getProjectionParallel(self) - The parallelProjection property getter.
Set Method:
__setProjectionParallel(self, parallel) - The parallelProjection property setter.

vtkVolume

The result of execution of the volume processing part of the pipeline on the reconstruction source volume.

Get Method:
__getVtkVolume(self) - The vtkVolume property getter.
Set Method:
__setVtkVolume(self, value) - The vtkVolume property setter.

vtkMesh

The vtkMesh property getter.

Get Method:
__getVtkMesh(self) - The vtkMesh property getter.
Set Method:
__setVtkMesh(self, value) - The vtkMesh property setter.

background

RGB components of background colour.

Get Method:
__getBackground(self) - Returns: RGB components of background colour
Set Method:
__setBackground(self, background) - Background colour setter.
Type:
(float, float, float)