Exemplo n.º 1
0
def force_cut(lstring):
    fake_rule = """
    Fake:
      produce Fake"""
    fake_lsys = Lsystem()
    fake_lsys.addRule(fake_rule)
    fake_lsys.axiom = lstring
    return fake_lsys.iterate()
Exemplo n.º 2
0
def lsystem(file_name, axiom='', derivationlength=-1, parameters={}):
    """ Build a lsystem object from file_name """
    l = Lsystem(file_name, parameters)

    if len(axiom):
        l.makeCurrent()
        if type(axiom) != AxialTree:
            axiom = AxialTree(axiom)
        l.axiom = axiom
        #l.done()
    if derivationlength >= 0:
        l.derivationLength = derivationlength

    return l
Exemplo n.º 3
0
def lsystem(file_name, axiom = '', derivationlength = -1, parameters = {}):
    """ Build a lsystem object from file_name """
    l = Lsystem(file_name, parameters)

    if len(axiom):
        l.makeCurrent()
        if type(axiom) != AxialTree:
            axiom = AxialTree(axiom)
        l.axiom = axiom
        #l.done()
    if derivationlength >= 0:
        l.derivationLength = derivationlength

    return l    
Exemplo n.º 4
0
N = 2

derivation length: N

production: 

F(x) :
  produce  F(x/3.0)+F(x/3.0)--F(x/3.0)+F(x/3.0)

endlsystem


'''

lsystem.setCode(str(code), context)
lsystem.axiom = "_(0.01)-(90)F(1)"

print('\n----lsystem:')
print(lsystem)
print('\n----axialtree:', axialtree)

axialtree = lsystem.iterate(3)

print('\n----lsystem:')
print(lsystem)
print('\n----axialtree:', axialtree)

lsystem.getLastIterationNb()  # iterate 4 -> getLastIterationNb == 3
lsystem.derivationLength  # see keyword in lpy code

scene = lsystem.sceneInterpretation(axialtree)
Exemplo n.º 5
0
N = 2

derivation length: N

production: 

F(x) :
  produce  F(x/3.0)+F(x/3.0)--F(x/3.0)+F(x/3.0)

endlsystem


'''

lsystem.setCode(str(code), context)
lsystem.axiom = "_(0.01)-(90)F(1)"

print('\n----lsystem:')
print(lsystem)
print('\n----axialtree:', axialtree)

axialtree = lsystem.iterate(3)

print('\n----lsystem:')
print(lsystem)
print('\n----axialtree:', axialtree)


lsystem.getLastIterationNb()  # iterate 4 -> getLastIterationNb == 3
lsystem.derivationLength  # see keyword in lpy code
Exemplo n.º 6
0
def shoot_grow(g, demand_only=True):
    lsys = Lsystem(str(os.path.join(lsysdir, 'morphogenesis.lpy')), {'demand_only': demand_only})
    lsys.axiom = mtg2lpy(g, lsys, AxialTree())
    axt = lsys.iterate()
    scene = lsys.sceneInterpretation(axt)
    return lpy2mtg(axt, lsys, scene)