Skip to content

Commit b90259a

Browse files
committed
Extending curve to 3d and adding in Envy and UFO examples, adding tree generation folder which handles generating n trees
1 parent fd0c6b3 commit b90259a

17 files changed

+246
-423
lines changed

.gitignore

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110+
.pdm.toml
111+
.pdm-python
112+
.pdm-build/
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# PyCharm
158+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160+
# and can be added to the global gitignore or merged into this file. For a more nuclear
161+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162+
#.idea/
163+
164+
dataset*/
165+
.DS_Store
11 Bytes
Binary file not shown.

__pycache__/helper.cpython-39.pyc

-51 Bytes
Binary file not shown.
23 Bytes
Binary file not shown.
-182 Bytes
Binary file not shown.
-176 Bytes
Binary file not shown.
-176 Bytes
Binary file not shown.
-2.27 KB
Binary file not shown.
-2.26 KB
Binary file not shown.

examples/Envy_tie_prune_label.lpy

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Spur(BasicWood):
5353

5454
class Branch(BasicWood):
5555
count = 0
56-
def __init__(self, copy_from = None, max_buds_segment: int = 10, thickness: float = 0.1,\
56+
def __init__(self, copy_from = None, max_buds_segment: int = 20, thickness: float = 0.1,\
5757
thickness_increment: float = 0.01, growth_length: float = 1., max_length: float = 7.,\
5858
tie_axis: tuple = (0,1,1), order: int = 1, prototype_dict: dict = {}, name = None, color = None):
5959

@@ -78,7 +78,7 @@ class Branch(BasicWood):
7878

7979
def create_branch(self):
8080
self.num_buds_segment += 1
81-
if rd.random()>0.6:
81+
if rd.random()>0.4:
8282
new_ob = NonTrunk(copy_from = self.prototype_dict['nontrunk'])
8383
else:
8484
new_ob = Spur(copy_from = self.prototype_dict['spur'])
@@ -106,15 +106,15 @@ class Trunk(BasicWood):
106106

107107
# Every branch gets its own contour when it is constructed to ensure
108108
# branches each having a unique profile curve
109-
self.contour = create_noisy_circle_curve(1, 0.2, 30)
109+
self.contour = create_noisy_circle_curve(3, 0.2, 30)
110110

111111
def is_bud_break(self, num_buds_segment):
112112
if (rd.random() > 0.2*(1 - num_buds_segment/self.max_buds_segment)):
113113
return False
114114
return True
115115

116116
def create_branch(self):
117-
if rd.random() > 0.7:
117+
if rd.random() > 0.8:
118118
return Spur(copy_from = self.prototype_dict['spur'])
119119
else:
120120
return Branch(copy_from = self.prototype_dict['branch'])
@@ -164,7 +164,7 @@ basicwood_prototypes = {}
164164
basicwood_prototypes['trunk'] = Trunk(tie_axis = (0,1,1), max_length = 0.4/growth_length, thickness = 0.01, growth_length = 0.1,thickness_increment = 0.00001, prototype_dict = basicwood_prototypes, color = [255,0,0] )
165165
basicwood_prototypes['branch'] = Branch(tie_axis = (0,1,1), max_length = .22/growth_length, thickness = 0.01, growth_length = 0.1,thickness_increment = 0.00001, prototype_dict = basicwood_prototypes, color = [255,150,0] )
166166
basicwood_prototypes['nontrunk'] = NonTrunk(tie_axis = (0,1,1), max_length = 0.05/growth_length, growth_length = 0.1, thickness = 0.003,thickness_increment = 0.0001, prototype_dict = basicwood_prototypes, color = [255,150,0] )
167-
basicwood_prototypes['spur'] = Spur(tie_axis = (0,1,1), max_length = 0.008/growth_length, thickness = 0.003, growth_length = 0.1, thickness_increment = 0., prototype_dict = basicwood_prototypes, color = [0,255,0] )
167+
basicwood_prototypes['spur'] = Spur(tie_axis = (0,1,1), max_length = 0.02/growth_length, thickness = 0.003, growth_length = 0.1, thickness_increment = 0., prototype_dict = basicwood_prototypes, color = [0,255,0] )
168168

169169

170170
#init
@@ -286,7 +286,7 @@ def reset_contour():
286286
nproduce SetContour(default_curve)
287287

288288

289-
curve = create_bezier_curve(x_range = (-.1, .1), y_range = (-.1, .1), z_range = (0, 10), seed_val=time.time())
289+
curve = create_bezier_curve(x_range = (-1, 1), y_range = (-1, 1), z_range = (0, 10), seed_val=time.time())
290290
Axiom: Attractors(support)SetGuide(curve, trunk_base.max_length)[grow_object(trunk_base)]
291291
derivation length: 105
292292
production:
@@ -320,7 +320,7 @@ grow_object(o) :
320320

321321
if 'Spur' in o.name:
322322
# note that the production of the buds is here with 'spiked_bud(o.thickness)'
323-
produce I(o.growth_length, o.thickness, o) bud(ParameterSet(type=o, num_buds=0)) spiked_bud(o.thickness)grow_object(o)
323+
produce I(o.growth_length, o.thickness, o) bud(ParameterSet(type=o, num_buds=0))grow_object(o) #spiked_bud(o.thickness)grow_object(o)
324324
else:
325325
# If o is a Trunk, Branch, or NonTrunk, simply produce the internodes
326326
produce I(o.growth_length, o.thickness, o) bud(ParameterSet(type=o, num_buds=0)) grow_object(o)
@@ -331,23 +331,25 @@ bud(t) :
331331
new_object = t.type.create_branch()
332332
if new_object == None:
333333
produce *
334-
335-
336-
parent_child_dict[new_object.name] = []
334+
335+
parent_child_dict[new_object.name] = []
337336
parent_child_dict[t.type.name].append(new_object)
338337
#Store new object somewhere
339338
t.num_buds+=1
340339
t.type.num_branches+=1
341340

342-
343341
# Set a curve for tertiary branches to follow as they grow
344342
if 'NonTrunk' in new_object.name:
345343
import time
346-
curve = create_bezier_curve(x_range = (-.1,.1), y_range = (-.1,.1), z_range = (-1,1), num_control_points = 10, seed_val=time.time())
344+
curve = create_bezier_curve(x_range = (-.5,.5), y_range = (-.5,.5), z_range = (-1,1), seed_val=time.time())
345+
nproduce [SetGuide(curve, new_object.max_length)
346+
elif 'Spur' in new_object.name:
347+
import time
348+
curve = create_bezier_curve(x_range = (-.2,.2), y_range = (-.2,.2), z_range = (-1,1), seed_val=time.time())
347349
nproduce [SetGuide(curve, new_object.max_length)
348350
else:
349351
nproduce [
350-
nproduce @RGetPos(new_object.start)C(ParameterSet(type = new_object))/(rd.random()*360)&(rd.random()*90)grow_object(new_object)GetPos(new_object.end)]bud(t)
352+
nproduce @RGetPos(new_object.start)C(ParameterSet(type = new_object))/(rd.random()*360)&(rd.random()*360)grow_object(new_object)GetPos(new_object.end)]bud(t)
351353

352354

353355
# Simple set of productions to build apple bud. This bud is

0 commit comments

Comments
 (0)