Graphical representation of MTG

PlantFrame

This module implement a solver to build 3D representation of a plant mockup based on various infomation.

Principles:

Use topologic information and associated properties to reconstruct a 3D representation of a plant. The 3D representation must satisfy all the intra and inter topological constraints and the properties defined by the user.

Algorithm:

Examples:

Todo

  • define a set of algorithms that can be used independently (as plug’in).

  • for each algo:
    • Decompose the problem into subproblems by computing the frontere. =>define a color based on the properties and the semantic. => define a partial order for solving each problems

    • Solve each subproblems and assemble the solutions

    • Return the solution as properties

  • define a generic method (or methods) to build a geometric object for computed values and properties.

  • diameter

  • length vs points

  • angles

  • remove noise from points

  • translate the branch at the extremities of the cylinder.

class openalea.mtg.plantframe.plantframe.PlantFrame(g, *args, **kwds)[source]

Bases: object

Engine to compute the geometry of a plant based on its topological description and parameters.

advanced_algo_diameter(power, default_diameter=None)[source]

Compute the pipe model on the entire mtg.

There are 4 cases:
for each component:
  • traverse in a post_order way all the vertices
    • compute strands and diameter

    • compute the difference at the root

    • compute a diameter value for the strands

  • fix problem with wrong power value:

    The diameter has to be decreasing.

  • if no value for the root, compute the total strands for the tree.

  • Then divide by the defined radius values obtain from step 1.

May be improved by a filtering pass. Select all the segment without ramification (linear) and interpolate the radius.

advanced_algo_diameter2(power, default_diameter=None)[source]

Compute the pipe model on the entire mtg.

There are 4 cases:
for each component:
  • traverse in a post_order way all the vertices
    • compute strands and diameter

    • compute the difference at the root

    • compute a diameter value for the strands

  • fix problem with wrong power value:

    The diameter has to be decreasing.

  • if no value for the root, compute the total strands for the tree.

  • Then divide by the defined radius values obtain from step 1.

May be improved by a filtering pass. Select all the segment without ramification (linear) and interpolate the radius.

algo_diameter(mode=1, power=2)[source]

Compute the radius for each vertices.

Cases:

  1. No radius values at all : pipe model

  2. Linear interpolation of radius on axes.

  3. Pipe model

algo_length(default_length=None)[source]

Compute the length of each vertex. The length of a complex is the sum of the length of its components. Length can be computed from points or is given as a property.

algo_length_without_points(default_length=None)[source]
build_mtg_from_radius()[source]

Decompose the tree (mtg at finest scale) into sub systems by creating complex which do not have interior nodes with a given values. Every complex have a defined frontier or are free.

compute_diameter(vid=None)[source]

Return the diameter of a vertex or for all vertices.

compute_length(vid=None, default_length=None)[source]

Return the length of a vertex.

If no vertex has been defined, return the length of all vertices.

compute_segmentvec(vid=None)[source]

Return the segment (i.e. direction with a length) of a vertex or for all vertices.

compute_surface(vid=None)[source]

Return the surface of a vertex or for all vertices.

The surface is for a tapered is .. math:

\pi (R_{t} + R_b)*h
compute_volume(vid=None)[source]

Return the volume of a vertex or for all vertices.

The volume is for a tapered is .. math:

V =

rac{pi h}{3}(R_1^2+R_2^2+R_1 R_2)

decompose_radius()[source]

Decompose the tree (mtg at finest scale) into sub trees which contains all the free nodes (nodes without radius). by creating complex which do not have interior nodes with a given values. Every tree have a defined frontier or are free.

default_algo_diameter(power)[source]

Compute the pipe model on the entire mtg. When a node has no values, take the deafult value.

static is_linear(g, cid)[source]

A complex is linear iff there is only there is only one extremity in it.

linear_diameter(power=2)[source]

Traverse all the axes order by order. The higher order are traversed first.

Retrieve all the defined radius on an axis. Define a parrameter for each define radius. Then interpolate and extrapolate

plot(*args, **kwds)[source]

Plot a MTG.

Optional Parameters:
  • origins : list of 3D points

  • visitora function f(g, v, turtle)

    This function is called for each vertex of the MTG.

  • gc : (bool) generalised cylinder

  • turtle: specify the turtle object

plot_property(prop, **kwds)[source]

Plot properties of MTG

Example:
>>> pf.plot_property('length')
propagate_constraints()[source]

Propagate the properties into the whole MTG.

run(scale=-1)[source]

Compute the geometry of the plant.

static strahler_order(g, vid)[source]

DressingData

Data and default geometric parameters used to compute the geometric interpretation of a MTG (i.e. PlantFrame)

Description:

The dressing data contains the default data that are used to define the geometry of an MTG vertices (i.e. of a plant entities) and to compute their geometric parameters when inference algorithms cannot be applied. These data are basically constant values and may be redefined in the dressing file. If no dressing file is defined, default (hard-coded) values are used (see Dressing files). The dressing file .drf , if it exists in the current directory, is always used as a default dressing file.

Objects of type DRESSING_DATA is used by primitive Plantframe. It may also be used by primitive Plot when VIRTUAL_PATTERNs are plotted.

Examples:
>>> g = MTG('a_MTG') 
>>> d = DressingData('file') 
>>> pf = PlantFrame(1, Scale=3, DressingData=d) 
>>> Plot(pf) 
class openalea.mtg.plantframe.dresser.DressingData(**kwds)[source]

Bases: object

Data and default geometric parameters.

The dressing data are the default data that are used to define the geometric models associated with geometric entities and to compute their geometric parameters when inference algorithms cannot be applied. These data are basically constant values and may be redefined by the user.

3D Plot

Plot a PlantFrame.

Download the source files ../../src/mtg/plantframe/plantframe.py, ../../src/mtg/plantframe/dresser.py, ../../src/mtg/plantframe/turtle.py,