openalea.plantconvert.vtk#

Functions related to reading on .vtk format#

openalea.plantconvert.vtk.reader.complex_vec(g, vid)[source]#

Get all the complexes of node vid from fine to coarsest scale.

openalea.plantconvert.vtk.reader.header_to_dict(header)[source]#

Read the header as a dictionnary.

openalea.plantconvert.vtk.reader.load_topology(filename)[source]#

Load into a vtk object from the file.

Parameters:

filename (str) – the file to load

Returns:

a tuple (vtk object, header) such that the second element is the header dictionary and the first element is the vtk object.

Return type:

tuple

openalea.plantconvert.vtk.reader.mtg_from_huge_ugrid(filename)[source]#

Build a mtg from a huge unstructured grid.

(see function huge_unstructured_grid in write_vtk).

TODO : the labels are lost in the mtg

Parameters:

filename (str) – the file to load

Returns:

a mtg object built from the unstructured grid

Return type:

mtg.MTG

openalea.plantconvert.vtk.reader.mtg_from_polydata(filename)[source]#

Construct the mtg from a polydata file given by the filename.

The header of the file should be interpreted as a dictionary giving correspondance between label and it’s code.

TODO :

Solve the attributes reading

Parameters:

filename (str) – relative path to the targer file.

Returns:

a mtg object

Return type:

mtg.MTG

Functions related to writing on .vtk format#

openalea.plantconvert.vtk.writer.huge_unstructured_grid(g, mtg_iterator=None)[source]#

Construct a huge unstructured grid that encodes the geo/topo of the mtg.

The geometry is represented by a big unstructured grid obtained by concatenating all the grids of each mtg element.

TODO : rewrite the function with append data set class

The topology is given by the points data of the unstructured grid : for each point of the huge grid, there is given an attribute that indicates the id of the mtg node containing this point. The parent and the complex are also given under the data attribute in order to perfectly specify the topology.

openalea.plantconvert.vtk.writer.polydata(g, **kwargs)[source]#

Convert the topology of mtg into a polydata object.

See the specification of the corresponding polydata object in readme.

Features are stored in a dictionary that associates the features to be written with there type.

VERY IMPORTANT : The method g.reindex() is called, we may lose the correspondance before/after writing the polydata

openalea.plantconvert.vtk.writer.ugrid_from_plantgl(geo_pgl)[source]#

Create an ugrid vtk object equivalent to a plantgl geometry object.

Tesselation is applied.

openalea.plantconvert.vtk.writer.write(filename, data_set, label_dict=None, binary=True, XML=True)[source]#

Export the data set into the given file name.

The extension is managed automatically binary and xml control the output format.