Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/contributed/sumopy/agilepy/lib_base/test_classman_classes.py
169689 views
1
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
2
# Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.
3
# SUMOPy module
4
# Copyright (C) 2012-2021 University of Bologna - DICAM
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file test_classman_classes.py
16
# @author Joerg Schweizer
17
# @date 2012
18
19
"""
20
Test for callsman
21
Provides test classes and some test functions for plugin.
22
"""
23
24
from classman import *
25
from arrayman import *
26
import xmlman as xm
27
28
29
def on_event_delattr(attrconfig):
30
print 'EVENT: Attribute', attrconfig.attrname, 'will be deleted!!'
31
32
33
def on_event_setattr(attrconfig):
34
print 'EVENT: Attribute', attrconfig.attrname, 'has been set to a new value', attrconfig.format_value()
35
36
37
def on_event_getattr(attrconfig):
38
print 'EVENT: Attribute', attrconfig.attrname, 'has been retrieved the value', attrconfig.format_value()
39
40
41
def on_event_additem(attrconfig, keys):
42
print 'EVENT: Attribute', attrconfig.attrname, ':added keys:', keys
43
44
45
def on_event_delitem(attrconfig, keys):
46
print 'EVENT: Attribute', attrconfig.attrname, ':delete keys:', keys
47
48
49
def on_event_setitem(attrconfig, keys):
50
print 'EVENT: Attribute', attrconfig.attrname, ':set keys:', keys
51
52
53
def on_event_getitem(attrconfig, keys):
54
print 'EVENT: Attribute', attrconfig.attrname, ':get keys:', keys
55
56
57
class Segments(ArrayObjman):
58
59
def __init__(self, ident='segments', parent=None, **kwargs):
60
61
self._init_objman(ident, parent=parent, xmltag=('segments', 'segment', 'ids_ref'), **kwargs)
62
63
self.add_col(ArrayConf('ids_ref', '',
64
dtype='object',
65
perm='r',
66
is_index=True,
67
name='ID Ref',
68
info='Ref ID',
69
xmltag='id_ref',
70
))
71
72
self.add_col(ArrayConf('vertices', np.zeros((2, 3), float),
73
groupnames=['internal'],
74
perm='rw',
75
name='Vertex',
76
is_save=True,
77
info='Vertex coordinate vectors of points. with format [[[x11,y11,z11],[x12,y12,z12]],[[x21,y21,z21],[x22,y22,z122]],...]',
78
xmltag='vertex',
79
))
80
81
self.add_col(IdsArrayConf('ids_parent', parent,
82
groupnames=['state'],
83
is_save=True,
84
name='ID '+parent.get_ident(),
85
info='ID of '+parent.get_name()+' object.',
86
xmltag='id_poly',
87
))
88
89
90
class Polylines (ArrayObjman):
91
def __init__(self, ident='polyline', parent=None, name='Polyline',
92
info='Polyline [ segid11, segid12,...]', **kwargs):
93
self._init_objman(ident, parent=parent, xmltag=('polylines', 'polyline', 'ids_osm'), **kwargs)
94
# print '__init__',self.get_name(),self.format_ident()
95
96
self.add_col(ArrayConf('ids_osm', '',
97
dtype='object',
98
perm='r',
99
is_index=True,
100
name='ID OSM',
101
info='Edge ID of OSM',
102
xmltag='id_osm',
103
))
104
105
# initialize line segments
106
segments = Segments(parent=self)
107
self.add(ObjConf(segments, groupnames=['drawobjects']))
108
109
# print ' segments',segments
110
# print ' self.segments',self.segments,type(self.segments)
111
# create table with id lists to segments
112
self.add_col(IdlistsArrayConf('ids_segments', segments,
113
groupnames=['elements'],
114
is_save=True,
115
name='IDs Segs',
116
info='List with IDs to Line segments.',
117
xmltag='segments',
118
))
119
120
def draw(self, pointvertices, id_osm):
121
"""
122
pointvertices = [
123
[0.0,0.0,0.0],
124
[0.2,0.0,0.0],
125
]
126
"""
127
vertices = []
128
print 'draw', self.ident
129
for i in xrange(1, len(pointvertices)):
130
vertices.append([pointvertices[i-1], pointvertices[i]])
131
n_vert = len(vertices)
132
_id = self.add_row(ids_osm=id_osm)
133
cod = []
134
#import string
135
clist = np.array(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'], np.object)
136
print ' ', len(vertices), clist[:len(vertices)]
137
ids = self.segments.value.suggest_ids(len(vertices))
138
ids_segs = self.segments.value.add_rows(ids=ids, vertices=vertices, ids_parent=n_vert*[_id], ids_ref=clist[ids])
139
self.ids_segments[_id] = list(ids_segs) # put here list, otherwise numpy thinks it is a numeric array
140
return _id
141
142
143
class Lines(ArrayObjman):
144
145
def __init__(self, ident, parent=None, **kwargs):
146
147
self._init_objman(ident, parent=parent, **kwargs)
148
149
self.add_col(ArrayConf('vertices', np.zeros((2, 3), float),
150
groupnames=['internal'],
151
perm='rw',
152
name='Vertex',
153
is_save=True,
154
info='Vertex coordinate vectors of points. with format [[[x11,y11,z11],[x12,y12,z12]],[[x21,y21,z21],[x22,y22,z122]],...]',
155
))
156
157
self.add_col(ArrayConf('ids_sumo', '',
158
dtype='object',
159
perm='r',
160
is_index=True,
161
name='ID SUMO',
162
info='Edge ID of SUMO network',
163
))
164
165
166
class Selection(ArrayObjman):
167
def __init__(self, ident, parent=None, **kwargs):
168
self._init_objman(ident, parent=parent, **kwargs)
169
self.add_col(TabIdsArrayConf('obj_ids',
170
name='Object[id]',
171
info='Draw obj and ids',
172
))
173
174
175
class Collection(ArrayObjman):
176
def __init__(self, ident, parent=None, **kwargs):
177
self._init_objman(ident, parent=parent, **kwargs)
178
self.add_col(TabIdListArrayConf('tab_id_lists',
179
name='[Tab1[id1],Tab2[id1],...]',
180
info='Collection of different items from different tables.',
181
))
182
183
184
class TestClass(BaseObjman):
185
def __init__(self, ident='testobj', parent=None, name='Test Object'):
186
self._init_objman(ident, parent=parent, name=name, xmltag=ident)
187
attrsman = self.set_attrsman(Attrsman(self))
188
189
self.netfilepath = attrsman.add(AttrConf('netfilepath', 'pathtofile',
190
groupnames=['state'],
191
perm='rw',
192
is_save=True,
193
name='Network file',
194
metatype='filepath',
195
info='Network file path',
196
xmltag='netfilepath',
197
))
198
199
self.workdirpath = attrsman.add(AttrConf('workdirpath', 'pathtodir',
200
groupnames=['state'],
201
perm='rw',
202
is_save=True,
203
name='Workdir',
204
metatype='dirpath',
205
info='Working directory.',
206
xmltag='workdirpath',
207
))
208
209
self.access = attrsman.add(ListConf('access', ['bus', 'bike', 'tram'],
210
groupnames=['state'],
211
perm='rw',
212
is_save=True,
213
name='Access list',
214
info='List with vehicle classes that have access',
215
xmltag='access',
216
))
217
218
self.allowed = attrsman.add(AttrConf('allowed', 0, choices={'bus': 0, 'bike': 1, 'tram': 2},
219
groupnames=['state'],
220
perm='rw',
221
is_save=True,
222
name='Access list',
223
info='List with vehicle classes that have access',
224
xmltag='allowed',
225
))
226
227
self.emissiontype = attrsman.add(AttrConf('emissiontype', 'Euro 0',
228
groupnames=['state'],
229
perm='rw',
230
is_save=True,
231
name='Emission type',
232
info='Emission type of vehicle',
233
xmltag='emissiontype',
234
))
235
236
self.x = attrsman.add(NumConf('x', 1.0,
237
digits_integer=None, digits_fraction=4,
238
minval=0.0, maxval=None,
239
groupnames=['state'],
240
perm='rw',
241
is_save=True,
242
unit='m',
243
is_plugin=True,
244
name='position',
245
info='Test object x position',
246
xmltag='x',
247
))
248
249
self.x_thresh = attrsman.add(NumConf('x_thresh', 0.0,
250
digits_integer=None, digits_fraction=4,
251
minval=0.0, maxval=None,
252
groupnames=['state'],
253
perm='rw',
254
is_save=True,
255
unit='m',
256
is_plugin=True,
257
name='position threshold',
258
info='Test object x position threshold',
259
xmltag='x_thesh',
260
))
261
262
self.is_pos_ok = attrsman.add(FuncConf('is_pos_ok', 'on_is_pos_ok', False,
263
groupnames=['state'],
264
name='Pos OK',
265
info='True if position greater than thhreshold.',
266
))
267
self.testlist = attrsman.add(ListConf('testlist', ['1', 'dd', 'cvc'],
268
groupnames=['state'],
269
choices=['1', 'dd', 'cvc', 'dddd', 'eeeee'],
270
perm='rw',
271
is_save=True,
272
name='Test list',
273
info='This is a test list',
274
xmltag='testList',
275
))
276
277
self.testlist_dict = attrsman.add(ListConf('testlist_dict', [1, 2, 3],
278
groupnames=['state'],
279
choices={'aa': 1, 'bb': 2, 'ccc': 3, 'dddd': 4, 'eeeee': 5},
280
perm='rw',
281
is_save=True,
282
name='Dictchoice Test list',
283
info='This is a Dictchoice test list',
284
xmltag='testList',
285
))
286
287
self.testlist_read = attrsman.add(ListConf('testlist_read', [1, 2, 3],
288
groupnames=['state'],
289
choices={'aa': 1, 'bb': 2, 'ccc': 3, 'dddd': 4, 'eeeee': 5},
290
perm='r',
291
is_save=True,
292
name='Readonly Test list',
293
info='This is a readonly test list',
294
xmltag='testList',
295
))
296
297
attrsman.print_attrs()
298
299
def on_is_pos_ok(self):
300
"""
301
True if position greater than thhreshold.
302
"""
303
print 'on_is_pos_ok', self.x > self.x_thresh
304
return self.x > self.x_thresh
305
306
307
class TestClass3(BaseObjman):
308
def __init__(self, ident='testobj3', parent=None, name='Test Object3'):
309
self._init_objman(ident=ident, parent=parent, name=name, xmltag='testobj3')
310
attrsman = self.set_attrsman(Attrsman(self))
311
312
self.child1 = attrsman.add(ObjConf(parent.child1, is_child=False))
313
314
self.y = attrsman.add(AttrConf('y', 0.0,
315
groupnames=['state'],
316
perm='r',
317
is_save=True,
318
unit='m',
319
metatype='length',
320
is_plugin=True,
321
name='position',
322
info='Test object y position',
323
))
324
325
326
class TestClass2(BaseObjman):
327
def __init__(self, ident='testobj2', parent=None, name='Test Object2', xmltag='testobj2'):
328
self._init_objman(ident, parent=parent, name=name, xmltag=xmltag)
329
attrsman = self.set_attrsman(Attrsman(self))
330
331
self.child1 = attrsman.add(ObjConf(TestClass('child1', self))
332
)
333
334
print 'TestClass2.child1', self.child1
335
336
self.child3 = attrsman.add(ObjConf(TestClass3('child3', self))
337
)
338
339
340
class TestTabman(BaseObjman):
341
def __init__(self, ident='test_tabman', parent=None, name='Test Table manage'):
342
self._init_objman(ident, parent=parent, name=name)
343
tm = Tabman(obj=self)
344
self.set_attrsman(tm)
345
self.surname = attrsman.add_col(ColConf('surname', 'xx',
346
groupnames=['state'],
347
perm='rw',
348
is_save=True,
349
name='Family name',
350
info='Name of Family',
351
))
352
353
self.streetname = attrsman.add_col(ColConf('streetname', 'via della...',
354
groupnames=['state'],
355
perm='rw',
356
is_save=False,
357
name='Street name',
358
info='Name of the street',
359
))
360
361
#_id = attrsman.suggest_id()
362
# print '_id =',_id
363
# self.attrman.add(_id)
364
365
# print 'self.streetname',self.streetname,type(self.streetname)
366
# self.streetname[1]='yyy'
367
# print 'self.streetname',self.streetname,type(self.streetname)
368
attrsman.add_rows(5)
369
attrsman.streetname[3] = 'ssss'
370
attrsman.streetname[[1, 2]] = ['aa', 55]
371
print 'test get', attrsman.streetname[[1, 2]]
372
# self.streetname[1]+='zzz'
373
attrsman.del_rows([1, 3])
374
attrsman.del_row(5)
375
# attrsman.delete('streetname')
376
377
378
class TestTableObjMan(TableObjman):
379
def __init__(self, ident='test_tableobjman_simple', parent=None, name='Test Table Object Manager'):
380
self._init_objman(ident, parent=parent, name=name, xmltag=('testtab', 'row', None))
381
382
# ATTENTION!!
383
# do not use x = self.add(...) or self.add_col(...)
384
# This would overwrite the configuration with the value
385
# because the attribute is the configuration, which is set by Attrman
386
# While the add method is returning the value
387
self.add(AttrConf('x', 0.0,
388
groupnames=['state'],
389
perm='r',
390
is_save=True,
391
unit='m',
392
metatype='length',
393
is_plugin=False,
394
name='position',
395
info='Test object x position',
396
xmltag='pos',
397
))
398
399
self.add(AttrConf('is_pos_ok', False,
400
groupnames=['state'],
401
perm='rw',
402
is_save=True,
403
name='Pos OK',
404
info='True if position is OK',
405
xmltag='pos_ok',
406
))
407
408
self.add_col(ColConf('surname', 'xx',
409
groupnames=['state'],
410
perm='r',
411
is_save=True,
412
name='Family name',
413
info='Name of Family',
414
xmltag='surname',
415
))
416
417
self.add_col(ColConf('streetname', 'via della...',
418
groupnames=['state'],
419
perm='rw',
420
is_save=True,
421
name='Street name',
422
info='Name of the street',
423
xmltag='streetname',
424
))
425
426
fruits = ['allpes', 'bananas', 'oranges']
427
self.add_col(ColConf('fruits', fruits[0],
428
groupnames=['state'],
429
choices=fruits,
430
perm='rw',
431
is_save=False,
432
name='Fruits',
433
info='Choose a fruit.',
434
))
435
436
self.add_col(NumcolConf('distances', 0.0,
437
digits_integer=None, digits_fraction=4,
438
minval=0.0, maxval=None,
439
groupnames=['state'],
440
perm='rw',
441
is_save=True,
442
name='Distance',
443
unit='m',
444
info='Distance of the street',
445
xmltag='distances',
446
))
447
448
self.add(FuncConf('new_row', 'on_new_row', None,
449
groupnames=['rowfunctions', '_private'],
450
name='New row',
451
info='Add a new row.',
452
))
453
self.add(FuncConf('delete_row', 'on_del_row', None,
454
groupnames=['rowfunctions', '_private'],
455
name='Del row',
456
#info = 'Delete a row.',
457
))
458
459
#_id = attrsman.suggest_id()
460
# print '_id =',_id
461
# self.attrman.add(_id)
462
463
# print 'self.streetname',self.streetname,type(self.streetname)
464
# self.streetname[1]='yyy'
465
# print 'self.streetname',self.streetname,type(self.streetname)
466
self.add_rows(5)
467
self.streetname[3] = 'ssss'
468
self.surname[[1, 2, 3, 4]] = ['a', 'bb', 'ccc', 'dddd']
469
self.streetname[[1, 2]] = ['vv', 'dd']
470
# print '\n\ntest get',self.streetname[[1,2,3]]
471
# self.streetname[1]+='zzz'
472
# self.del_rows([1,3])
473
# self.del_row(5)
474
# self.delete('streetname')
475
# self.delete('is_pos_ok')
476
# print 'dir',dir(self)
477
478
def on_new_row(self, ids):
479
"""
480
True if position greater than thhreshold.
481
"""
482
self.add_row()
483
484
def on_del_row(self, id_row):
485
"""
486
True if position greater than thhreshold.
487
"""
488
print 'on_del_row', id_row
489
self.del_row(id_row)
490
print ' ids after del', self.get_ids()
491
492
493
class TestTableObjManNocols(TableObjman):
494
"""
495
Table manager without columns...for test purposes
496
"""
497
498
def __init__(self, ident='test_tableobjman_simple_nocols', parent=None, name='Test Table Object Manager'):
499
self._init_objman(ident, parent=parent, name=name)
500
501
# ATTENTION!!
502
# do not use x = self.add(...) or c=self.add_col(...)
503
# This would overwrite the configuration with the value
504
# because the attribute is the configuration, which is set by Attrman
505
# While the add method is returning the value
506
self.add(AttrConf('x', 0.0,
507
groupnames=['state'],
508
perm='r',
509
is_save=True,
510
unit='m',
511
metatype='length',
512
is_plugin=False,
513
name='position',
514
info='Test object x position',
515
))
516
517
self.add(AttrConf('is_pos_ok', False,
518
groupnames=['state'],
519
perm='rw',
520
is_save=True,
521
name='Pos OK',
522
info='True if position is OK',
523
))
524
525
526
class ZonesTab(ArrayObjman):
527
def __init__(self, ident, parent=None, **kwargs):
528
self._init_objman(ident, parent=parent, **kwargs)
529
530
self.add_col(ColConf('zonetypes', 0,
531
choices={
532
"priority": 0,
533
"traffic_light": 1,
534
"right_before_left": 2,
535
"unregulated": 3,
536
"priority_stop": 4,
537
"traffic_light_unregulated": 5,
538
"allway_stop": 6,
539
"rail_signal": 7,
540
"zipper": 8,
541
"traffic_light_right_on_red": 9,
542
"rail_crossing": 10,
543
},
544
is_plugin=True,
545
#dtype = np.int32,
546
perm='rw',
547
#is_index = True,
548
name='Type',
549
info='Zone type.',
550
))
551
552
self.add_col(NumcolConf('shapes', [],
553
groupnames=['state'],
554
perm='rw',
555
is_plugin=True,
556
is_save=True,
557
name='Shape',
558
info='Shape of zone which is a list of (x,y) coordinates',
559
))
560
561
562
class OdTripsTab(ArrayObjman):
563
def __init__(self, ident, parent, zones, **kwargs):
564
self._init_objman(ident, parent=parent, **kwargs)
565
566
self.add_col(IdsArrayConf('ids_orig', zones,
567
groupnames=['state'],
568
is_save=True,
569
name='ID Orig',
570
info='ID of traffic assignment zone of origin of trip.',
571
))
572
573
self.add_col(IdsConf('ids_dest', zones,
574
groupnames=['state'],
575
is_save=True,
576
name='ID Dest',
577
info='ID of traffic assignment zone of destination of trip.',
578
))
579
580
self.add_col(NumArrayConf('tripnumbers', 0,
581
groupnames=['state'],
582
perm='rw',
583
is_save=True,
584
name='Trip number',
585
info='Number of trips from zone with ID Orig to zone with ID Dest.',
586
))
587
588
589
class OdModesTab(ArrayObjman):
590
def __init__(self, ident, parent=None, **kwargs):
591
self._init_objman(ident, parent=parent, **kwargs)
592
593
self.add_col(ObjsConf('odtrips',
594
groupnames=['state'],
595
is_save=True,
596
name='OD matrix',
597
info='Matrix with trips from origin to destintion',
598
))
599
600
601
class OdIntervalsTab(ArrayObjman):
602
def __init__(self, ident, parent=None, **kwargs):
603
self._init_objman(ident, parent=parent, **kwargs)
604
605
self.add_col(NumArrayConf('t_start', 0.0,
606
groupnames=['state'],
607
perm='rw',
608
is_save=True,
609
name='Start time',
610
unit='s',
611
info='Start time of interval',
612
))
613
614
self.add_col(NumArrayConf('t_end', 3600.0,
615
groupnames=['state'],
616
perm='rw',
617
is_save=True,
618
name='End time',
619
unit='s',
620
info='End time of interval',
621
))
622
623
self.add_col(ObjsConf('odmodes',
624
groupnames=['state'],
625
is_save=True,
626
name='Modes',
627
info='Transport mode',
628
))
629
630
###########################################################################
631
# Instance creation
632
633
634
demand = BaseObjman('demand')
635
636
zones = ZonesTab('zones', parent=demand)
637
demand.zones = demand.get_attrsman().add(ObjConf(zones))
638
EVTDELITEM = 20 # delete attribute
639
EVTSETITEM = 21 # set attribute
640
EVTGETITEM = 22 # get attribute
641
EVTADDITEM = 23 # add/create attribute
642
zones.shapes.plugin.add_event(EVTADDITEM, on_event_additem)
643
shapes = [[(0.0, 10.0), (10.0, 10.0), (10.0, 0.0)],
644
[(10.0, 20.0), (20.0, 20.0), (20.0, 10.0)],
645
[(20.0, 30.0), (30.0, 20.0), (30.0, 20.0)],
646
]
647
zones.add_rows(3, shapes=shapes)
648
649
odintervals = OdIntervalsTab('odintervals', parent=demand, info='OD data for different time intervals')
650
demand.odintervals = demand.get_attrsman().add(ObjConf(odintervals))
651
odintervals.add_rows(2, t_start=[0, 3600], t_end=[3600, 7200])
652
for id_odmodes in odintervals.get_ids():
653
odmodes = OdModesTab((odintervals.odmodes.attrname, id_odmodes), parent=odintervals)
654
odintervals.odmodes[id_odmodes] = odmodes
655
656
odmodes.add_rows(2)
657
for id_odtrips in odmodes.get_ids():
658
odtrips = OdTripsTab((odmodes.odtrips.attrname, id_odtrips), odmodes, zones)
659
odtrips.add_rows(3, ids_orig=[3, 2, 1], ids_dest=[3, 3, 3], tripnumbers=[10, 200, 555])
660
odmodes.odtrips[id_odtrips] = odtrips
661
662
# demand.attrsman.print_attrs()
663
# odintervals.print_attrs()
664
665
# -------------------------------------------------------------------------------
666
667
668
# vertices = [ [0.0,10.0,10.0,10.0,10.0,0.0],
669
# [10.0,20.0,20.0,20.0,20.0,10.0],
670
# [20.0,30.0,30.0,20.0,30.0,20.0],
671
# ]
672
673
# vertices = [ [(0.0,10.0),(10.0,10.0)],
674
# [(10.0,20.0),(20.0,20.0)],
675
# [(20.0,30.0),(30.0,20.0)],
676
# ]
677
vertices = [
678
[[0.0, 0.0, 0.0], [0.2, 0.0, 0.0]], # 0
679
[[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]], # 1
680
[[0.5, 0.0, 0.1], [1.9, 0.0, 0.0]], # 2
681
]
682
polygons = [
683
np.array([[0.0, 0.0, 0.0], [0.2, 0.0, 0.0], [0.2, 0.0, 0.1], [0.3, 0.3, 0.3]]), # 0
684
np.array([[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]]), # 1
685
np.array([[0.5, 0.0, 0.1], [1.9, 0.0, 0.0], [0.2, 0.2, 0.2]]), # 2
686
]
687
ids_sumo = ['aa10', 'bb22', 'cc333']
688
# lines.add_rows(3)
689
drawing = BaseObjman('drawing')
690
691
lines = Lines('lines', parent=drawing)
692
drawing.lines = drawing.get_attrsman().add(ObjConf(lines))
693
lines.add_rows(3, vertices=vertices, polygons=polygons, ids_sumo=ids_sumo)
694
695
triangles = Lines('triangles', parent=drawing)
696
drawing.triangles = drawing.get_attrsman().add(ObjConf(triangles))
697
triangles.add_rows(3, vertices=2*vertices, polygons=polygons, ids_sumo=['xxx10', 'xx22', 'xx333'])
698
699
selection = Selection('selection', parent=drawing)
700
drawing.selection = drawing.get_attrsman().add(ObjConf(selection))
701
selection.add_rows(2, obj_ids=[(lines, 2), (triangles, 1)])
702
703
collections = Collection('collections', parent=drawing)
704
drawing.collections = drawing.get_attrsman().add(ObjConf(collections))
705
collections.add_rows(2, tab_id_lists=[[(lines, 2), (triangles, 1)],
706
[(lines, 2), (triangles, 1), (lines, 1)]]
707
)
708
709
# -------------------------------------------------------------------------------
710
711
pointvertices = [
712
[0.0, 0.0, 0.0],
713
[0.2, 0.0, 0.0],
714
[0.3, 0.5, 0.0],
715
[0.2, 0.5, 0.0],
716
[0.0, 0.5, 0.1],
717
[-1.5, -0.5, 0.0],
718
]
719
720
pointvertices2 = [
721
[0.0, 0.3, 0.0],
722
[0.2, 0.3, 0.0],
723
[0.3, 0.8, 0.0],
724
[0.2, 0.8, 0.0],
725
[0.0, 0.8, 0.1],
726
[-1.5, -0.8, 0.0],
727
]
728
729
pointvertices3 = [
730
[0.5, 0.3, 0.0],
731
[-1.5, -0.8, 0.0],
732
]
733
734
735
polylines = Polylines()
736
polylines.draw(pointvertices, 'aa10&1')
737
polylines.draw(pointvertices2, 'bb2210&1')
738
polylines.draw(pointvertices3, '5b2310&1')
739
polylines.print_attrs()
740
xm.write_obj_to_xml(polylines, 'test_polylines.xml')
741
742