This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
/
main.py
executable file
·123 lines (78 loc) · 1.96 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from numpy import pi
from modules.growth import spawn
# from modules.growth import spawn_curl
from numpy import zeros
NMAX = 10**6
SIZE = 2800
ONE = 1./SIZE
PROCS = 6
INIT_RAD = 25*ONE
INIT_NUM = 40
STP = ONE*0.4
NEARL = 3*ONE
FARL = 40*ONE
MID = 0.5
LINEWIDTH = 5.*ONE
BACK = [1,1,1,1]
FRONT = [0,0,0,5]
TWOPI = pi*2.
STAT_ITT = 10
EXPORT_ITT = 100
np_verts = zeros((NMAX,2), 'double')
np_edges = zeros((NMAX,4), 'double')
def main():
from time import time
from itertools import count
from iutils.render import Render
from modules.helpers import print_stats
from modules.show import show
# from modules.show import show_closed
from differentialLine import DifferentialLine
from modules.helpers import get_exporter
from numpy.random import random
from fn import Fn
DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS)
fn = Fn(prefix='./res/')
exporter = get_exporter(
NMAX,
{
'nearl': NEARL,
'farl': FARL,
'stp': STP,
'size': SIZE,
'procs': PROCS
}
)
render = Render(SIZE, BACK, FRONT)
render.ctx.set_source_rgba(*FRONT)
render.ctx.set_line_width(LINEWIDTH)
angles = sorted(random(INIT_NUM)*TWOPI)
DF.init_circle_segment(MID,MID,INIT_RAD, angles)
t_start = time()
for i in count():
DF.optimize_position(STP)
# spawn_curl(DF,NEARL)
spawn(DF, NEARL, 0.03)
if i % STAT_ITT == 0:
print_stats(i,time()-t_start,DF)
if i % EXPORT_ITT == 0:
name = fn.name()
num = DF.np_get_edges_coordinates(np_edges)
show(render,np_edges[:num,:],name+'.png')
exporter(
DF,
name+'.2obj'
)
if __name__ == '__main__':
if False:
import pyximport
pyximport.install()
import pstats, cProfile
fn = './profile/profile'
cProfile.runctx("main()", globals(), locals(), fn)
p = pstats.Stats(fn)
p.strip_dirs().sort_stats('cumulative').print_stats()
else:
main()