This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemo.py
83 lines (67 loc) · 2.92 KB
/
demo.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
'''
Copyright (C) Saeed Gholami Shahbandi. All rights reserved.
Author: Saeed Gholami Shahbandi
This file is part of Arrangement Library.
The of Arrangement Library is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>
'''
from __future__ import print_function
import sys
import time
import arrangement.arrangement as arr
import arrangement.plotting as aplt
if __name__ == '__main__':
'''
list of supported parameters
----------------------------
--multiprocessing
example
-------
python demo.py --file_name 'tests/testCases/example_01.yaml' --multiprocessing 4
'''
args = sys.argv
# fetching options from input arguments
# options are marked with single dash
options = []
for arg in args[1:]:
if len(arg)>1 and arg[0] == '-' and arg[1] != '-':
options += [arg[1:]]
# fetching parameters from input arguments
# parameters are marked with double dash,
# the value of a parameter is the next argument
listiterator = args[1:].__iter__()
while 1:
try:
item = next( listiterator )
if item[:2] == '--':
exec(item[2:] + ' = next( listiterator )')
except:
break
# multiprocessing parameters (number of processes or False)
multiprocessing = int(multiprocessing) if 'multiprocessing' in locals() else False
# if input file is svg, convert to yaml and load yaml file
if file_name.split('.')[-1] == 'svg':
raise( NameError('SVG support is not available yet... Sorry') )
# file_name = arr.utls.svg_to_ymal(file_name, convert_segment_2_infinite_line=True)
# load traits from yaml file
data = arr.utls.load_data_from_yaml( file_name )
traits = data['traits']
# deploying arrangement (and decomposition)
print( '\nstart decomposition:', file_name)
tic = time.time()
config = {'multi_processing':4, 'end_point':False, 'timing':False}
arrange = arr.Arrangement(traits, config)
print( 'Arrangement time: {:.5f}'.format( time.time() - tic) )
# results
print( 'nodes:\t\t {:d}'.format( len(arrange.graph.nodes()) ) )
print( 'edges:\t\t {:d}'.format( len(arrange.graph.edges()) ) )
print( 'faces:\t\t {:d}'.format( len(arrange.decomposition.faces) ) )
print( 'subGraphs:\t {:d}'.format( len(arrange._subDecompositions) ) )
aplt.animate_face_patches(arrange, timeInterval = .5* 1000)