Skip to content
Snippets Groups Projects
Commit db8efe51 authored by mehtank's avatar mehtank
Browse files

Connect edge lists in reverse order to allow more universal connectivity

parent 75e5726a
2 merge requests!25Merge v0.2 changes into v0.3,!21Connect edge lists in reverse order to allow more universal connectivity
......@@ -37,18 +37,21 @@ class EdgePort(Port):
if isinstance(toPort, EdgePort):
label1 = self.getEdges()
label2 = toPort.getEdges()
numedges = len(label1)
# XXX associate ports with specific composables so this isn't necessary
for i in range(len(label1)):
for i in range(numedges):
if label1[i] not in (e.name for e in graph.edges):
return
if label2[i] not in (e.name for e in graph.edges):
return
for i in range(len(label1)):
for i in range(numedges):
newargs = {}
for key, value in kwargs.items():
if isinstance(value, (list, tuple)):
newargs[key] = value[i]
else:
newargs[key] = value
graph.mergeEdge(label1[i], label2[i], **newargs)
graph.mergeEdge(label1[i], label2[numedges-i-1], **newargs)
......@@ -43,10 +43,10 @@ c.addConstConstraint(("right","flip"), True)
# connections
c.addConnection(("brain", "topedge0"),
("right", "botedge0"),
("right", "topedge0"),
angle=-90)
c.addConnection(("brain", "botedge0"),
("left", "topedge0"),
("left", "botedge0"),
angle=-90)
# Sheath
......@@ -65,7 +65,7 @@ c.addConstraint(("sheathsplit","botlength"), ("driveservo", "width"),
x[1] - 2*getDim(x[0],'motorheight'), \
getDim(x[0],'motorheight'))")
c.addConnection(("left", "botedge1"),
c.addConnection(("left", "topedge1"),
("sheathsplit", "botedge2"),
angle=180)
......@@ -76,7 +76,7 @@ c.addConnection(("right", "botedge1"),
'''
c.addConnection(("sheathsplit", "topedge0"),
("sheath", "topedge1"))
("sheath", "botedge1"))
# Tail
c.addSubcomponent("tail", "Tail", inherit=("flapwidth", "tailwidth"), prefix=None)
......@@ -85,14 +85,14 @@ c.addConstraint(("tail","height"), *depthfn(["height"], "%s/2.+x[2]"))
c.addConstraint(("tail","depth"), *depthfn(["battery"], "%s+x[2]"))
c.addConnection(("tail", "topedge"),
("sheath", "botedge1"),
("sheath", "topedge1"),
angle=90)
c.addSubcomponent("tailsplit", "SplitEdge")
c.addConstraint(("tailsplit","toplength"), "width", "(x,)")
c.addConstraint(("tailsplit","botlength"), ("width", "flapwidth"), "(x[0]*(1-x[1])/2., x[0]*x[1], x[0]*(1-x[1])/2.)")
c.addConnection(("sheath", "botedge3"),
c.addConnection(("sheath", "topedge3"),
("tailsplit", "topedge0"))
c.addConnection(("tail", "flapedge"),
......
......@@ -3,17 +3,17 @@ connections:
- - brain
- topedge0
- - right
- botedge0
- topedge0
- angle: -90
connection1:
- - brain
- botedge0
- - left
- topedge0
- botedge0
- angle: -90
connection2:
- - left
- botedge1
- topedge1
- - sheathsplit
- botedge2
- angle: 180
......@@ -21,17 +21,17 @@ connections:
- - sheathsplit
- topedge0
- - sheath
- topedge1
- botedge1
- {}
connection4:
- - tail
- topedge
- - sheath
- botedge1
- topedge1
- angle: 90
connection5:
- - sheath
- botedge3
- topedge3
- - tailsplit
- topedge0
- {}
......
......@@ -10,8 +10,8 @@ class SimpleRectBeam(FoldedComponent):
self.addParameter("addTabs", True, valueType="bool")
for i in range(4):
self.addEdgeInterface("topedge%d" % i, "r%d.e0" % i, ["width", "depth"][i % 2])
self.addEdgeInterface("botedge%d" % i, "r%d.e2" % i, ["width", "depth"][i % 2])
self.addEdgeInterface("topedge%d" % i, "r%d.e2" % i, ["width", "depth"][i % 2])
self.addEdgeInterface("botedge%d" % i, "r%d.e0" % i, ["width", "depth"][i % 2])
self.addFaceInterface("face%d" % i, "r%d" % i)
self.addEdgeInterface("slotedge", "r3.e1", "length")
self.addEdgeInterface("tabedge", "r0.e3", "length")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment