Cuds module

A module containing tvtk dataset wrappers to simphony CUDS containers.

Classes

VTKParticles(name[, data, data_set, mappings]) Constructor.
VTKMesh(name[, data, data_set, mappings]) Constructor.
VTKLattice(name, primitive_cell, data_set[, ...]) Constructor.

Description

class simphony_mayavi.cuds.vtk_particles.VTKParticles(name, data=None, data_set=None, mappings=None)[source]

Bases: simphony.cuds.abc_particles.ABCParticles

Constructor.

Parameters:
  • name (string) – The name of the container.
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
  • data_set (tvtk.DataSet) – The dataset to wrap in the CUDS api. Default is None which will create a tvtk.PolyData
  • mappings (dict) – A dictionary of mappings for the particle2index, index2particle, bond2index and bond2element. Should be provided if the particles and bonds described in data_set are already assigned uids. Default is None and will result in the uid <-> index mappings being generated at construction.
bond2index = None

The mapping from uid to bond index

count_of(item_type)[source]

Return the count of item_type in the container.

Parameters:item_type (CUDSItem) – The CUDSItem enum of the type of the items to return the count of.
Returns:count (int) – The number of items of item_type in the dataset.
Raises:ValueError – If the type of the item is not supported in the current dataset.
data

Easy access to the vtk CellData structure

data_set = None

The vtk.PolyData dataset

classmethod from_dataset(name, data_set, data=None)[source]

Wrap a plain dataset into a new VTKParticles.

The constructor makes some sanity checks to make sure that the tvtk.DataSet is compatible and all the information can be properly used.

Parameters:
  • name (str) – The name of the container.
  • data_set (tvtk.DataSet) – The dataset to wrap in the CUDS api. Default is None which will create a tvtk.PolyData
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
Raises:

TypeError – When the sanity checks fail.

classmethod from_particles(particles, particle_keys=None, bond_keys=None)[source]

Create a new VTKParticles copy from a CUDS particles instance.

Parameters:
  • particles (ABCParticles) – CUDS Particles dataset
  • particle_keys (list) – A list of point CUBA keys that we want to copy, and only those. If None, all available and compatible keys will be copied.
  • bond_keys (list) – A list of cell CUBA keys that we want to copy, and only those. If None, all available and compatible keys will be copied.
index2bond = None

The reverse mapping from index to bond uid

index2particle = None

The reverse mapping from index to point uid

is_connected(bond)[source]

Test if the connectivity described in bonds is valid i.e. the particles are part of the container

Parameters:bond (Bond) –
Returns:valid (bool)
particle2index = None

The mapping from uid to point index

supported_cuba = None

The currently supported and stored CUBA keywords.

class simphony_mayavi.cuds.vtk_mesh.VTKMesh(name, data=None, data_set=None, mappings=None)[source]

Bases: simphony.cuds.abc_mesh.ABCMesh

Constructor.

Parameters:
  • name (string) – The name of the container
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
  • data_set (tvtk.DataSet) – The dataset to wrap in the CUDS api. Default is None which will create a tvtk.UnstructuredGrid.
  • mappings (dict) – A dictionary of mappings for the point2index, index2point, element2index and index2element. Should be provided if the points and elements described in data_set are already assigned uids. Default is None and will result in the uid <-> index mappings being generated at construction.
count_of(item_type)[source]

Return the count of item_type in the container.

Parameters:item_type (CUDSItem) – The CUDSItem enum of the type of the items to return the count of.
Returns:count (int) – The number of items of item_type in the dataset.
Raises:ValueError – If the type of the item is not supported in the current dataset.
data

Easy access to the vtk PointData structure

data_set = None

The vtk.PolyData dataset

element2index = None

The mapping from uid to bond index

element_data = None

Easy access to the vtk CellData structure

classmethod from_dataset(name, data_set, data=None)[source]

Wrap a plain dataset into a new VTKMesh.

The constructor makes some sanity checks to make sure that the tvtk.DataSet is compatible and all the information can be properly used.

Parameters:
  • name (string) – The name of the container
  • data_set (tvtk.DataSet) – The dataset to wrap in the CUDS api. Default is None which will create a tvtk.UnstructuredGrid.
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
Raises:

TypeError – When the sanity checks fail.

classmethod from_mesh(mesh, point_keys=None, cell_keys=None)[source]

Create a new VTKMesh copy from a CUDS mesh instance.

Parameters:
  • mesh (ABCMesh) – The original mesh to create the new one.
  • point_keys (list) – A list of point CUBA keys that we want to copy, and only those. If None, all available and compatible keys will be copied.
  • cell_keys (list) – A list of cell CUBA keys that we want to copy, and only those. If None, all available and compatible keys will be copied.
index2element = None

The reverse mapping from index to bond uid

index2point = None

The reverse mapping from index to point uid

point2index = None

The mapping from uid to point index

supported_cuba = None

The currently supported and stored CUBA keywords.

class simphony_mayavi.cuds.vtk_lattice.VTKLattice(name, primitive_cell, data_set, data=None)[source]

Bases: simphony.cuds.abc_lattice.ABCLattice

Constructor.

Parameters:
  • name (string) – The name of the container.
  • primitive_cell (PrimitiveCell) – primitive cell specifying the 3D Bravais lattice
  • data_set (tvtk.DataSet) – The dataset to wrap in the CUDS api. If it is a tvtk.PolyData, the points are assumed to be arranged in C-contiguous order so that the first point is the origin and the last point is furthest away from the origin
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
count_of(item_type)[source]

Return the count of item_type in the container.

Parameters:item_type (CUDSItem) – The CUDSItem enum of the type of the items to return the count of.
Returns:count (int) – The number of items of item_type in the dataset.
Raises:ValueError – If the type of the item is not supported in the current dataset.
data

The container data

classmethod empty(name, primitive_cell, size, origin, data=None)[source]

Create a new empty Lattice.

Parameters:
  • name (string) – The name of the container.
  • primitive_cell (PrimitiveCell) – Primitive cell specifying the 3D Bravais lattice
  • size (tuple) – lattice dimensions (nx, ny, nz)
  • origin (tuple) – lattice origin (x, y, z)
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
Returns:

lattice (VTKLattice)

classmethod from_dataset(name, data_set, data=None)[source]

Create a new Lattice and try to guess the primitive_cell

Parameters:
  • name (str) –
  • data_set (tvtk.ImageData or tvtk.PolyData) – The dataset to wrap in the CUDS api. If it is a PolyData, the points are assumed to be arranged in C-contiguous order
  • data (DataContainer) – The data attribute to attach to the container. Default is None.
Returns:

lattice (VTKLattice)

Raises:

TypeError – If data_set is not either tvtk.ImageData or tvtk.PolyData

IndexError:
If the lattice nodes are not arranged in C-contiguous order
classmethod from_lattice(lattice, node_keys=None)[source]

Create a new Lattice from the provided one.

Parameters:
  • lattice (simphony.cuds.lattice.Lattice) –
  • node_keys (list) – A list of point CUBA keys that we want to copy, and only those. If None, all available and compatible keys will be copied.
Returns:

lattice (VTKLattice)

Raises:
ValueError
  • if bravais_lattice attribute of the primitive cell indicates a cubic/tetragonal/orthorhombic lattice but the primitive vectors are inconsistent with this attribute
  • if bravais_lattice is not a member of BravaisLattice
get_coordinate(ind)[source]

Get coordinate of the given index coordinate.

ind : int[3]
node index coordinate
Returns:

coordinates : float[3]

origin

lattice origin (x, y, z)

point_data = None

Easy access to the vtk PointData structure

primitive_cell

Primitive cell specifying the 3D Bravais lattice

size

lattice dimensions (nx, ny, nz)

supported_cuba = None

The currently supported and stored CUBA keywords.