示例#1
0
def check(fn):
    " Compare result with the AML library. "

    g = wrap.MTG(fn)
    g1 = aml.MTG(fn)

    # Test root
    compare('MTGRoot')

    nb_scales = g.nb_scales()

    # Test VtxList at each scale
    for scale in range(1, nb_scales):
        compare('VtxList', Scale=scale)

    # Test VtxList at all scales
    compare('VtxList')

    vtxs = aml.VtxList()

    methods = """
    Class
    Index
    Scale

    Rank
    Height
    Order

    Defined
    Father
    Successor
    Predecessor
    Complex
    Sons
    Ancestors
    ComponentRoots
    Descendants
    Extremities
    Root
    Axis
    Components
    """.split()

    methods = [m for m in methods if [basename(fn), m] not in excludes]
    """
    Trunk
    Location
    Path # require 2 arguments
    """
    i = vtxs.index(g.root)
    del vtxs[i]
    for v in vtxs:
        for m in methods:
            compare(m, v)
    return g
示例#2
0
def check(g, s, fn):
    res = True
    f = open('tmp.mtg', 'w')
    f.write(s)
    f.close()
    try:
        g1 = aml.MTG('tmp.mtg')
    except Exception, e:
        os.remove('tmp.mtg')
        assert False, fn
示例#3
0
MT = trees.Tree("sample_mtg.txt")
print MT.Display()
MT.Save("sample_mtg_save.txt", True)
# reading a Tree from a MTG with filter and custom attributes
print "Read tree from MTG file 'sample_mtg.txt' using a filter ", \
      "and custom attributes:"
f = lambda x: amlPy.Feature(x, "length") * amlPy.Feature(x, "fruits")
# filter=lambda x: x != 2
filter = lambda x: x < 6
attributes = ["anything"]
MT = trees.Tree("sample_mtg.txt", filter, attributes, [f], scale=1)
print MT.Display()

import openalea.aml as amlPy

MSTG = amlPy.MTG("sample_mtg.txt")
DR = amlPy.DressingData("dressing.drf")


def Longueur(x):
    return 20 * amlPy.Feature(x, "length")


def Rayon(x):
    return 1


P = amlPy.PlantFrame(amlPy.MTGRoot(),
                     Scale=1,
                     DressingData=DR,
                     Length=Longueur,