homcloud.paraview_interface module

This module provides the paraview interface from homcloud.interface module.

The basic model of this module is “pipeline” model. A data object is filtered by the chain of pipeline nodes, and the result is shown. The objects of PipelineNode correspond the node of the pipeline, and you can adjust visualization by these objects.

You can use many methods of PipelineNode to adjust the visualization, and you can construct a new pipeline node by the following methods:

Todo:

  • Add clip_box method
class homcloud.paraview_interface.PipelineNode(parent=None)[source]

Bases: object

This class represents elements in a pipeline in ParaView.

This class is the base class for paraview interface classes. You should not create an instance of this class directly.

clip_sphere(center, radius, inside_out=True)[source]

Create a new pipeline node to clip the object with a sphere shape.

Parameters:
  • center (tuple[float, float, float]) – The center of the clipping sphere
  • radius (float) – The radius of the clipping sphere
  • inside_out (bool) – If True, only the elements in the shpere are shown. If False, only the elements outside of the sphere is shown.
Returns:

A new PipelineNode object for sphere clipping.

Return type:

SphereClip

color_by(field, range=None)[source]

Set the coloring by field name.

Parameters:
  • field (string or int) – The name of the field.
  • range (tuple[float, float] or None) – The upper and lower bounds of the colorbar. If None, the minimal and maximal values of the field are used.
Returns:

self

set_color(color)[source]

Set the color.

Parameters:color (tuple[float, float, float]) – The RGB values (0.0 to 1.0)
Returns:self
set_linewidth(width)[source]

Set the linewidth.

Parameters:width (float) – The width of the lines
Returns:self
set_opacity(opacity)[source]

Set the opacity.

  • 0.0 - completely transparent
  • 1.0 - completely opaque
Parameters:opacity (float) – The opacity.
Returns:self
set_pointsize(size)[source]

Set the pointsize.

Parameters:pointsize (float) – The size of the points
Returns:self
threshold(field, range)[source]

Create a new pipeline node for thresholding whose parent is self.

Only the elements whose field are in the range when the returned object is passed to show().

Parameters:
  • field (string) – The name of the field which have the thresholded value.
  • range (tuple[float, float] or float) – The upper and lower bounds of the values. If an float number is given, the threshold is (range, range).
Returns:

A new PipelineNode object for thresholding.

Return type:

Threshold

to_paraview_node()[source]

Returns self.

class homcloud.paraview_interface.PointCloud(path, dim=3, delimiters=' ', gui_name=None)[source]

Bases: homcloud.paraview_interface.PipelineNode

This class represents a pointcloud data source in paraview.

Parameters:
  • path (string) – The filepath of the pointcloud.
  • dim (int) – The dimension of the space in which the pointcloud lives.
  • delimiter (string) – The delimiter of elements in a pointcloud file. If you want to show a CSV file, please specify “,”.
  • gui_name (string or None) – The name shown in Pipeline Browser in paraview’s GUI.

Notes

This is constructed by CSVReader and TableToPoints.

static from_array(array, dim=3, gui_name=None)[source]

Construct a pipeline node for pointcloud from an ndarray object.

Parameters:
  • array (nupmy.ndarray) – The pointcloud data.
  • dim (int) – The dimension of the space in which the pointcloud lives.
  • gui_name (string) – The name shown in Pipeline Browser in paraview’s GUI.
Returns:

A pipeline node object.

Return type:

PointCloud

class homcloud.paraview_interface.SphereClip(parent, center, radius, inside_out=True)[source]

Bases: homcloud.paraview_interface.PipelineNode

This class represents a pipeline node for sphere clipping.

You should construct the instance of this class by PipelineNode.clip_sphere().

class homcloud.paraview_interface.Threshold(parent, field, range)[source]

Bases: homcloud.paraview_interface.PipelineNode

This class represents a pipeline node for thresholding.

You should construct the instance of this class by PipelineNode.threshold().

class homcloud.paraview_interface.VTK(path, gui_name=None)[source]

Bases: homcloud.paraview_interface.PipelineNode

This class represents a VTK data source in paraview.

homcloud.paraview_interface.VoxelData(array, gui_name=None)[source]

Returns PipelineNode object representing a voxel data.

Parameters:
  • array (numpy.ndarray) – An array.
  • gui_name (string or None) – The name shown in Pipeline Browser in paraview’s GUI.
Returns:

A pipeline node object

Return type:

VTK

homcloud.paraview_interface.show(sources, path=None, wait=True)[source]

Shows sources by invoking paraview.

Parameters:
  • sources (list of PipelineNode) – Pipeline nodes to be output.
  • path (string or None) – The output filename. If this parameter is None, a temporary filepath is generated and use it.
  • wait (bool) – If True, this function returns after paraview stops. If False, this function returns immediately after paraview is invoked by using backgroup process mechanism.
homcloud.paraview_interface.write_python_code(out, sources)[source]

Write a python code generated by sources to out.

Parameters:
  • out (io-like) – The output IO object.
  • sources (list of PipelineNode) – Pipeline nodes to be output.