Skip to content

Commit f72f9c8

Browse files
authored
Merge pull request #275 from suchitalad/xcosblocks
Updated XmlParser for Splitblock geometry
2 parents 8a6ba8e + c855660 commit f72f9c8

File tree

2 files changed

+41
-31
lines changed

2 files changed

+41
-31
lines changed

blocks/Xcos/XmlParser.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ def mergeLinks(vertex, key1, graph_link, removable_link):
508508
mergeLinks(sourceVertex, key1, graph_link, removable_link)
509509
mergeLinks(targetVertex, key1, graph_link, removable_link)
510510

511+
511512
except BaseException:
512513
traceback.print_exc()
513514
sys.exit(103)
@@ -532,52 +533,56 @@ def mergeLinks(vertex, key1, graph_link, removable_link):
532533
print(f"removable link: k: {k}, link: {r_link_0}")
533534
node = nodeList[r_link_0]
534535
link_data = edgeDict[r_link_0] # small removed link
536+
print("#LINKDATA#:", link_data)
537+
print("#NODEATTRIB#:", node.attrib)
538+
539+
sourceVertex = link_data[1] # small link
540+
targetVertex = link_data[2] # small link
541+
# sourceVertex = node.attrib.get('sourceVertex')
542+
# targetVertex = node.attrib.get('targetVertex')
543+
# print("#SV & #TV:", sourceVertex, targetVertex)
535544

536-
sourceVertex = node.attrib.get('sourceVertex') # small link
537-
targetVertex = node.attrib.get('targetVertex') # small link
538545

539546
if sourceVertex in link:
540547
node2 = nodeList[sourceVertex]
541548
link_data2 = edgeDict[sourceVertex] # big removed link
542549

543550
thisVertex = sourceVertex
544-
thisx = node.attrib.get('tarx', '0')
545-
thisy = node.attrib.get('tary', '0')
551+
thisx = link_data[8]['x']
552+
thisy = link_data[8]['y']
546553

547554
otherVertex = targetVertex
548-
otherx = node.attrib.get('tar2x', '0')
549-
othery = node.attrib.get('tar2y', '0')
550-
551-
tar2x = node2.attrib.get('tar2x', '0')
552-
tar2y = node2.attrib.get('tar2y', '0')
555+
otherx = link_data[9]['x']
556+
othery = link_data[9]['y']
553557

554-
tarx = node2.attrib.get('tarx', '0')
555-
tary = node2.attrib.get('tary', '0')
556-
557-
split_point = link_data[9]
558+
split_point = link_data[8]
558559

559560
elif targetVertex in link:
560561
node2 = nodeList[targetVertex]
561562
link_data2 = edgeDict[targetVertex] # big removed link
562563

564+
thisVertex = targetVertex
565+
thisx = link_data[9]['x']
566+
thisy = link_data[9]['y']
567+
563568
otherVertex = sourceVertex
564-
otherx = node.attrib.get('tarx', '0')
565-
othery = node.attrib.get('tary', '0')
569+
otherx = link_data[8]['x']
570+
othery = link_data[8]['y']
566571

567-
thisVertex = targetVertex
568-
thisx = node.attrib.get('tar2x', '0')
569-
thisy = node.attrib.get('tar2y', '0')
572+
split_point = link_data[9]
570573

571-
tarx = node2.attrib.get('tarx', '0')
572-
tary = node2.attrib.get('tary', '0')
574+
sourceVertex2 = link_data2[1] # big link
575+
targetVertex2 = link_data2[2] # big link
576+
577+
tarx = link_data2[8]['x']
578+
tary = link_data2[8]['y']
573579

574-
tar2x = node2.attrib.get('tar2x', '0')
575-
tar2y = node2.attrib.get('tar2y', '0')
580+
tar2x = link_data2[9]['x']
581+
tar2y = link_data2[9]['y']
576582

577-
split_point = link_data[8]
583+
print("TARX & TARY:", tarx, tary, tar2x, tar2y)
584+
578585

579-
sourceVertex2 = node2.attrib.get('sourceVertex') # big link 2
580-
targetVertex2 = node2.attrib.get('targetVertex') # big link 3
581586

582587
root.remove(node)
583588
root.remove(node2)
@@ -586,15 +591,19 @@ def mergeLinks(vertex, key1, graph_link, removable_link):
586591
tType = IDLIST[otherVertex]
587592
sType2 = IDLIST[sourceVertex2]
588593
tType2 = IDLIST[targetVertex2]
589-
height = 7
590-
width = 7
591-
print("LINKDATA:", link_data)
594+
height = '7.0'
595+
width = '7.0'
596+
# print("LINKDATA:", link_data)
597+
# print("LINKDATA2:", link_data2)
598+
# print("#NODEATTRIB2#:", node2.attrib)
599+
# print("@SV & @TV:", sourceVertex2, targetVertex2)
592600
waypoints = link_data[6] # small link
593601
waypoints2 = link_data2[6] # big link
594602
# split_point = link_data[9]
595603
biglinkid = link_data2[0]
596604
smalllinkid = link_data[0]
597-
print('waypoints2, split_point', biglinkid, waypoints2, split_point)
605+
print('waypoints2, split_point:', biglinkid, waypoints2, split_point)
606+
print("SV & TV:", sourceVertex, targetVertex, sourceVertex2, targetVertex2)
598607
result, left_array, right_array = check_point_on_array(waypoints2, split_point)
599608
print('left_array, right_array:', left_array, right_array)
600609
array3 = waypoints

blocks/Xcos/blocks/SplitBlock.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ def SplitBlock(outroot, attribid, ordering, geometry, parameters, parent=1, styl
3030
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, [])
3131
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_EQUATIONS, [])
3232
addNode(outnode, 'mxGeometry', **{'as': 'geometry'},
33-
height=geometry['height'], width=geometry['width'],
34-
x=geometry['x'], y=geometry['y'])
33+
x=geometry['x'], y=geometry['y'],
34+
width=geometry['width'], height=geometry['height']
35+
)
3536

3637
return outnode
3738

0 commit comments

Comments
 (0)