...
 
Commits (3)
......@@ -516,20 +516,3 @@ class Component(Parameterized):
def addSemanticConstraint(self, lhs, op, rhs):
self.semanticConstraints.append([lhs, op, rhs])
def toProtoBuf(self, filedir):
from svggen.api import proto_conversion3
from google.protobuf import text_format
"""
print 'begin symbolicization of parameters'
for p in self.parameters:
print p
self.symbolicize(p)
"""
proto = proto_conversion3.componentToNewTemplateProto(self)
text_format.PrintMessage(proto, open(filedir + '/template.asciiproto', 'w'), 2)
open(filedir + '/template.proto', 'wb').write(proto.SerializeToString())
self.composables['graph'].unplace()
package FabByExample.proto.symbolic;
message Parameter {
optional int32 id = 1;
optional string name = 2; // optional, for user friendliness
optional double default = 3;
}
message LinearExpr {
repeated int32 parameter_id = 1;
repeated double coeff = 2;
optional double const = 3;
}
message Point2S {
optional LinearExpr x = 1;
optional LinearExpr y = 2;
}
message Point3S {
optional LinearExpr x = 1;
optional LinearExpr y = 2;
optional LinearExpr z = 3;
}
message Vertex2S {
optional int32 id = 1; // required (for referencing)
optional string name = 2;
optional Point2S point = 3;
}
message Edge2S {
optional int32 id = 1;
optional string name = 2;
optional int32 vertex1_id = 3;
optional int32 vertex2_id = 4;
}
message Face2S {
optional int32 id = 1;
optional string name = 2;
repeated int32 vertex_id = 3; // required
repeated int32 edge_id = 4; // optional
}
message Drawing2S {
optional int32 id = 1;
optional string name = 2;
repeated Vertex2S vertex = 3; // required (for referencing)
repeated Edge2S edge = 4; // optional
repeated Face2S face = 5; // required
}
message Vertex3S {
optional int32 id = 1; // required (for referencing)
optional string name = 2;
optional Point3S point = 3;
}
message Edge3S {
optional int32 id = 1;
optional string name = 2;
optional int32 vertex1_id = 3;
optional int32 vertex2_id = 4;
}
message Face3S {
optional int32 id = 1;
optional string name = 2;
repeated int32 vertex_id = 3; // required
repeated int32 edge_id = 4; // optional
}
message Mesh3S {
optional int32 id = 1;
optional int32 name = 2;
repeated Vertex3S vertex = 3; // required (for referencing)
repeated Edge3S edge = 4; // optional
repeated Face3S face = 5; // required
}
// 3x4 matrix, column major
message AffineMatrix3S {
repeated LinearExpr value = 1;
}
message Transform{
enum TransformType{
REVOLUTE_TRANSFORM = 1;
PRISMATIC_TRANSFORM = 2;
}
optional Control control = 1;
optional Point3S axis =2; //Is a vector
optional TransformType type =3;
optional double minVal =4; //REALLY optional
optional double maxVal =5; //REALLY optional
}
message Control{
optional int32 id =1;
optional string name =2;
optional ControlMappingFunction inputs = 3;
}
message ControlMappingFunction {
optional LinearMappingFuction1D linear_1 =1;
}
message LinearMappingFuction1D {
optional LinearExpr linearTimeMap = 1;
}
package FabByExample.proto;
import "symbolic.proto";
// A set of templates so that we can encode children without nesting
message TemplateSet {
repeated Template template = 1;
optional int32 root_template_id = 2;
}
message Template {
optional int32 id = 1; // required
optional string name = 2;
repeated symbolic.Parameter parameter = 3;
optional MappingFunction mapping_function = 4;
optional FeasibleSet feasible_set = 5;
repeated int32 child_template_id = 6;
repeated Connection connection = 7;
repeated Patch patch = 8;
}
message Patch{
optional int32 id = 1;
optional Edge2SPatch edge2SPatch = 2;
}
message Edge2SPatch{
optional int32 edgeId = 1;
}
message Connection {
repeated int32 patchRef = 1;
optional ConnectionMode connectionMode = 2;
}
message ConnectionMode {
optional FoldConnection foldConnection = 1;
optional BendConnection bendConnection = 2;
optional FlexConnection flexConnection = 3;
optional JointConnection jointConnection = 4;
// should also have JointConnection and FixedConnection
}
message FoldConnection {
optional double angle = 1;
}
message JointConnection {
optional double angle = 1;
repeated Articulation articulations = 2;
}
message BendConnection {
optional double angle = 1;
}
message FlexConnection {
optional double angle = 1;
}
// Abstractly, a function that takes a list of parameters and returns
// a mesh or a 2D drawing
message MappingFunction {
optional LinearMappingFunction3 linear_3 = 1;
optional LinearMappingFunction2 linear_2 = 2;
optional CompositionMappingFunction composition = 3;
optional ExternalMeshAffineMappingFunction external_mesh_affine = 4;
}
// A mapping function that returns the mesh after some transformation
message ExternalMeshAffineMappingFunction {
optional string stl_filename = 1;
optional bytes stl_data = 2;
optional symbolic.AffineMatrix3S transform = 3;
}
// A mapping function that returns the composition of the outputs of
// other templates (e.x. children templates)
message CompositionMappingFunction {
repeated int32 template_id = 1;
}
// A mapping function that represents the mesh as a linear combination
// of the parameters. For this mapping function, there must be at least
// three parameters, and the first three should mean the translation.
message LinearMappingFunction3 {
optional symbolic.Mesh3S mesh = 1;
}
// A mapping function that represents the 2D drawing as a linear
// combination of the parameters.
message LinearMappingFunction2 {
optional symbolic.Drawing2S drawing = 1;
}
// Abstractly, the set of allowed vectors of parameters for the template
message FeasibleSet {
optional ConstraintList constraint_list = 1;
}
// A feasible set represented as a list of constraints
message ConstraintList {
repeated Constraint constraint = 1;
repeated int32 inherited_template_id = 2;
}
// A single constraint
message Constraint {
optional LinearConstraint linear_constraint = 1;
}
// A linear constraint, which represents either linear_expr = 0 or
// linear_expr < 0
message LinearConstraint {
enum Type {
EQUALITY = 1;
LESS_THAN_ZERO = 2;
}
optional symbolic.LinearExpr expr = 1;
optional Type type = 2;
}
message Articulation{
repeated symbolic.Transform transforms = 1;
optional symbolic.Point3S center = 2;
}
from svggen.api.component import Component
c = Component()
# BOX
c.addParameter("depth", 50)
c.addParameter("width", 60)
c.addParameter("height", 30)
c.addSubcomponent("top","Rectangle")
c.addSubcomponent("fore","Rectangle")
c.addSubcomponent("rear","Rectangle")
c.addSubcomponent("port","Rectangle")
c.addSubcomponent("star","Rectangle")
c.addConstraint(("top","w"), "depth")
c.addConstraint(("top","l"), "width")
c.addConstraint(("fore","w"), "height")
c.addConstraint(("fore","l"), "width")
c.addConstraint(("rear","w"), "height")
c.addConstraint(("rear","l"), "width")
c.addConnection(("rear", "t"), ("top", "b"), angle=90)
c.addConnection(("top", "t"), ("fore", "b"), angle=90)
c.addConstraint(("port","w"), "depth")
c.addConstraint(("port","l"), "height")
c.addConstraint(("star","w"), "depth")
c.addConstraint(("star","l"), "height")
c.addConnection(("port", "r"), ("top", "l"), angle=90)
c.addConnection(("top", "r"), ("star", "l"), angle=90)
# Interface to floats
c.addParameter("length", 200)
c.addSubcomponent("portsplit","SplitEdge")
c.addSubcomponent("starsplit","SplitEdge")
c.addConstraint(("portsplit","botlength"), ("length", "depth"), "[sum(x)]")
c.addConstraint(("portsplit","toplength"), ("length", "depth"), "[x[0]/2., x[1], x[0]/2.]")
c.addConnection(("portsplit", "topedge1"), ("port", "l"))
c.addConstraint(("starsplit","botlength"), ("length", "depth"), "[sum(x)]")
c.addConstraint(("starsplit","toplength"), ("length", "depth"), "[x[0]/2., x[1], x[0]/2.]")
c.addConnection(("starsplit", "topedge1"), ("star", "r"))
c.inheritInterface("portedge", ("portsplit", "botedge0"))
c.inheritInterface("staredge", ("starsplit", "botedge0"))
c.toYaml("library/Cabin.yaml")
from svggen.api.component import Component
c = Component()
# BOX
c.addSubcomponent("boat","BoatBase", inherit=True, prefix=None)
c.addParameter("n", 3)
c.addSubcomponent("portsplit","SplitEdge")
c.addSubcomponent("starsplit","SplitEdge")
c.addConstraint(("portsplit","botlength"), ("length", "n"), "[x[0]]")
c.addConstraint(("portsplit","toplength"), ("length", "n"), "[x[0]/(2.*x[1]+1.)] * (2*x[1]+1)")
c.addConstraint(("starsplit","toplength"), ("length", "n"), "[x[0]]")
c.addConstraint(("starsplit","botlength"), ("length", "n"), "[x[0]/(2.*x[1]+1.)] * (2*x[1]+1)")
c.addConnection(("portsplit", "botedge0"), ("boat", "portedge"), angle=90)
c.addConnection(("starsplit", "topedge0"), ("boat", "staredge"), angle=90, tabWidth=10)
for i in range(10):
nm = "seat%d"%i
c.addSubcomponent(nm, "Rectangle")
c.addConstraint((nm, "l"), ("width", "n"), "(%d < x[1]) and x[0] or 0" % i)
c.addConstraint((nm, "w"), ("length", "n"), "x[0]/(2.*x[1]+1.)")
c.addConnection(("portsplit", "topedge%d" % (2*i+1)), (nm, "l"))
c.addConnection(("starsplit", "botedge%d" % (2*i+1)), (nm, "r"))
c.toYaml("library/Canoe.yaml")
from svggen.api.component import Component
c = Component()
# BOX
c.addSubcomponent("cabin","Cabin", inherit=True, prefix=None, invert=True)
c.addSubcomponent("port","BoatBase")
c.addSubcomponent("star","BoatBase")
c.addConstraint(("port","length"), ("length", "depth"), "sum(x)")
c.addConstraint(("port","width"), ("length", "depth"), "sum(x)/10.")
c.addConstraint(("port","depth"), ("length", "depth"), "sum(x)/20.")
c.addConstraint(("port","bow"), "length", "x/2.")
c.addConstraint(("port","stern"), "length", "x/8.")
c.addConstraint(("star","length"), ("length", "depth"), "sum(x)")
c.addConstraint(("star","width"), ("length", "depth"), "sum(x)/10.")
c.addConstraint(("star","depth"), ("length", "depth"), "sum(x)/20.")
c.addConstraint(("star","bow"), "length", "x/2.")
c.addConstraint(("star","stern"), "length", "x/8.")
c.addConnection(("cabin", "portedge"), ("port", "staredge"))
c.addConnection(("cabin", "staredge"), ("star", "portedge"))
c.toYaml("library/Catamaran.yaml")
......@@ -57,5 +57,5 @@ f.setParameter("leg.beamwidth", 5)
f.setParameter("depth", tgy1370a.getParameter('motorwidth'))
f.setParameter("width", tgy1370a.getParameter('motorheight') + 5)
f.makeOutput("output/smalllegs", protobuf=False, display=True)
f.makeOutput("output/smalllegs", display=True)
'''
from svggen.api.component import Component
c = Component()
# BOX
c.addParameter("n", 6)
c.addParameter("spacing", 25)
for i in range(3):
c.addSubcomponent("boat%d"%i,"BoatBase", inherit=True, prefix=None)
c.addSubcomponent("portsplit%d"%i,"SplitEdge")
c.addSubcomponent("starsplit%d"%i,"SplitEdge")
c.addConstraint(("portsplit%d"%i,"botlength"), ("length", "n"), "[x[0]]")
c.addConstraint(("portsplit%d"%i,"toplength"), ("length", "n"), "[x[0]/(1.*x[1])] * x[1]")
c.addConstraint(("starsplit%d"%i,"toplength"), ("length", "n"), "[x[0]]")
c.addConstraint(("starsplit%d"%i,"botlength"), ("length", "n"), "[x[0]/(1.*x[1])] * x[1]")
c.addConnection(("portsplit%d"%i, "botedge0"), ("boat%d"%i, "portedge"), angle=-90)
c.addConnection(("starsplit%d"%i, "topedge0"), ("boat%d"%i, "staredge"), angle=-90)
for i in range(10):
nm = "seat%d"%i
c.addSubcomponent(nm, "Rectangle")
c.addConstraint((nm, "l"), ("spacing", "n"), "(%d < x[1]) and x[0] or 0" % i)
c.addConstraint((nm, "w"), ("length", "n"), "x[0]/(1.*x[1])")
if (i % 2):
c.addConnection(("starsplit0", "botedge%d" % i), (nm, "l"))
c.addConnection(("portsplit1", "topedge%d" % i), (nm, "r"))
else:
c.addConnection(("starsplit1", "botedge%d" % i), (nm, "l"))
c.addConnection(("portsplit2", "topedge%d" % i), (nm, "r"))
c.toYaml("library/Trimaran.yaml")
from svggen.api.component import Component
c = Component()
# BOX
c.addSubcomponent("cabin","Cabin", inherit=True, prefix=None)
c.addSubcomponent("boat","BoatBase")
c.addConstraint(("boat","length"), ("length", "depth"), "sum(x)")
c.addConstraint(("boat","width"), "width")
c.addConstraint(("boat","depth"), "width", "x/3.")
c.addConstraint(("boat","bow"), "length", "x/2.")
c.addConstraint(("boat","stern"), "length", "x/8.")
c.addConnection(("cabin", "portedge"), ("boat", "portedge"), angle=0)
c.addConnection(("cabin", "staredge"), ("boat", "staredge"), angle=0, tabWidth=10)
c.toYaml("library/Tug.yaml")
......@@ -56,5 +56,5 @@ f.setParameter("length", 40)
f.setParameter("dl", 10)
f.setParameter("leg.beamwidth", 5)
f.makeOutput("output/fourbar", protobuf=False, display=True)
f.makeOutput("output/fourbar", display=True)
'''
from svggen.api.component import Component
from svggen.api.composables.graph.Face import Face, Rectangle, RightTriangle
from svggen.api.composables.GraphComposable import Graph
from svggen.api.ports.EdgePort import EdgePort
import svggen.utils.mymath as math
class BoatBase(Component):
_test_params = { }
def define(self):
self.addParameter("length", 250)
self.addParameter("width", 50)
self.addParameter("depth", 20)
self.addParameter("bow", 45)
self.addParameter("stern", 0)
self.addInterface("staredge", EdgePort(self, None))
self.addInterface("portedge", EdgePort(self, None))
def assemble(self):
l = self.getParameter("length")
w = self.getParameter("width")
h = self.getParameter("depth")
b = self.getParameter("bow")
s = self.getParameter("stern")
graph = Graph()
bottom = Rectangle("", l, w)
graph.addFace(bottom, "bt")
lt = Rectangle("", l, h)
graph.attachFace("bt.e0", lt, "e2", prefix="lt", angle=90)
rt = Rectangle("", l, h)
graph.attachFace("bt.e2", rt, "e0", prefix="rt", angle=90)
def point(lbl, d, edge, flip=False):
lb = math.sqrt(h*h+d*d)
ab = math.rad2deg(math.arctan2(h,d))
f = Face("", ((w/2.,0), (0, lb), (-w/2., 0)))
graph.attachFace("bt."+edge, f, "e0", prefix=lbl, angle=ab)
lb = math.sqrt(w*w/4.+d*d)
ab = math.rad2deg(math.arctan2(w/2.,d))
f1 = RightTriangle("", h, lb); e1 = "e0"
#f1a = Face("", ((h, 0), (0, lb), (0,0*lb/2.)))
#f1b = Face("", ((lb, 0), (0, h), (0*lb/2.,0)))
f2 = RightTriangle("", lb, h); e2 = "e2"
#f2a = Face("", ((lb, 0), (0, h), (0*lb/2.,0)))
#f2b = Face("", ((h, 0), (0, lb), (0,0*lb/2.)))
if flip:
f1, f2 = f2, f1
#f1a, f2a = f2a, f1a
#f1b, f2b = f2b, f1b
e1, e2 = e2, e1
#graph.attachFace(lbl+".e2", f1, "e1", prefix=lbl+"rt", angle=ab)
graph.attachFace("rt."+edge, f1, e1, prefix=lbl+"rt", angle=ab)
#graph.attachFace(lbl+"rt.e1", f1a, "e1", prefix=lbl+"rta", angle=180)
#graph.attachFace(lbl+"rta."+e2, f1b, e1, prefix=lbl+"rtb", angle=-180)
#graph.attachFace(lbl+".e1", f2, "e1", prefix=lbl+"lt", angle=ab)
graph.attachFace("lt."+edge, f2, e2, prefix=lbl+"lt", angle=ab)
#graph.attachFace(lbl+"lt.e1", f2a, "e1", prefix=lbl+"lta", angle=180)
#graph.attachFace(lbl+"lta."+e1, f2b, e2, prefix=lbl+"ltb", angle=-180)
point("bow", b, "e1")
point("stern", s, "e3", flip=True)
self.composables["graph"] = graph
self.setInterface("staredge", EdgePort(self, "rt.e2"))
self.setInterface("portedge", EdgePort(self, "lt.e0"))
if __name__ == "__main__":
h = BoatBase()
h._make_test()
connections:
connection0:
- [rear, t]
- [top, b]
- {angle: 90}
connection1:
- [top, t]
- [fore, b]
- {angle: 90}
connection2:
- [port, r]
- [top, l]
- {angle: 90}
connection3:
- [top, r]
- [star, l]
- {angle: 90}
connection4:
- [portsplit, topedge1]
- [port, l]
- {}
connection5:
- [starsplit, topedge1]
- [star, r]
- {}
interfaces:
portedge: {interface: botedge0, subcomponent: portsplit}
staredge: {interface: botedge0, subcomponent: starsplit}
metadata:
depth: {default: 50}
height: {default: 30}
length: {default: 200}
width: {default: 60}
parameters: {depth: 50, height: 30, length: 200, width: 60}
subcomponents:
fore:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: width}
w: {parameter: height}
port:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: height}
w: {parameter: depth}
portsplit:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[sum(x)]'
parameter: [length, depth]
toplength:
function: '[x[0]/2., x[1], x[0]/2.]'
parameter: [length, depth]
rear:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: width}
w: {parameter: height}
star:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: height}
w: {parameter: depth}
starsplit:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[sum(x)]'
parameter: [length, depth]
toplength:
function: '[x[0]/2., x[1], x[0]/2.]'
parameter: [length, depth]
top:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: width}
w: {parameter: depth}
connections:
connection0:
- [portsplit, botedge0]
- [boat, portedge]
- {angle: 90}
connection1:
- [starsplit, topedge0]
- [boat, staredge]
- {angle: 90, tabWidth: 10}
connection10:
- [portsplit, topedge9]
- [seat4, l]
- {}
connection11:
- [starsplit, botedge9]
- [seat4, r]
- {}
connection12:
- [portsplit, topedge11]
- [seat5, l]
- {}
connection13:
- [starsplit, botedge11]
- [seat5, r]
- {}
connection14:
- [portsplit, topedge13]
- [seat6, l]
- {}
connection15:
- [starsplit, botedge13]
- [seat6, r]
- {}
connection16:
- [portsplit, topedge15]
- [seat7, l]
- {}
connection17:
- [starsplit, botedge15]
- [seat7, r]
- {}
connection18:
- [portsplit, topedge17]
- [seat8, l]
- {}
connection19:
- [starsplit, botedge17]
- [seat8, r]
- {}
connection2:
- [portsplit, topedge1]
- [seat0, l]
- {}
connection20:
- [portsplit, topedge19]
- [seat9, l]
- {}
connection21:
- [starsplit, botedge19]
- [seat9, r]
- {}
connection3:
- [starsplit, botedge1]
- [seat0, r]
- {}
connection4:
- [portsplit, topedge3]
- [seat1, l]
- {}
connection5:
- [starsplit, botedge3]
- [seat1, r]
- {}
connection6:
- [portsplit, topedge5]
- [seat2, l]
- {}
connection7:
- [starsplit, botedge5]
- [seat2, r]
- {}
connection8:
- [portsplit, topedge7]
- [seat3, l]
- {}
connection9:
- [starsplit, botedge7]
- [seat3, r]
- {}
interfaces: {}
metadata:
bow: {default: 45}
depth: {default: 20}
length: {default: 250}
n: {default: 3}
stern: {default: 0}
width: {default: 50}
parameters: {bow: 45, depth: 20, length: 250, n: 3, stern: 0, width: 50}
subcomponents:
boat:
classname: BoatBase
kwargs: {}
parameters:
bow: {parameter: bow}
depth: {parameter: depth}
length: {parameter: length}
stern: {parameter: stern}
width: {parameter: width}
portsplit:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]]'
parameter: [length, n]
toplength:
function: '[x[0]/(2.*x[1]+1.)] * (2*x[1]+1)'
parameter: [length, n]
seat0:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (0 < x[1]) and x[0] or 0
parameter: &id001 [width, n]
w:
function: x[0]/(2.*x[1]+1.)
parameter: &id002 [length, n]
seat1:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (1 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat2:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (2 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat3:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (3 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat4:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (4 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat5:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (5 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat6:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (6 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat7:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (7 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat8:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (8 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
seat9:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (9 < x[1]) and x[0] or 0
parameter: *id001
w:
function: x[0]/(2.*x[1]+1.)
parameter: *id002
starsplit:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]/(2.*x[1]+1.)] * (2*x[1]+1)'
parameter: [length, n]
toplength:
function: '[x[0]]'
parameter: [length, n]
connections:
connection0:
- [cabin, portedge]
- [port, staredge]
- {}
connection1:
- [cabin, staredge]
- [star, portedge]
- {}
interfaces: {}
metadata:
depth: {default: 50}
height: {default: 30}
length: {default: 200}
width: {default: 60}
parameters: {depth: 50, height: 30, length: 200, width: 60}
subcomponents:
cabin:
classname: Cabin
kwargs: {invert: true}
parameters:
depth: {parameter: depth}
height: {parameter: height}
length: {parameter: length}
width: {parameter: width}
port:
classname: BoatBase
kwargs: {}
parameters:
bow: {function: x/2., parameter: length}
depth:
function: sum(x)/20.
parameter: [length, depth]
length:
function: sum(x)
parameter: [length, depth]
stern: {function: x/8., parameter: length}
width:
function: sum(x)/10.
parameter: [length, depth]
star:
classname: BoatBase
kwargs: {}
parameters:
bow: {function: x/2., parameter: length}
depth:
function: sum(x)/20.
parameter: [length, depth]
length:
function: sum(x)
parameter: [length, depth]
stern: {function: x/8., parameter: length}
width:
function: sum(x)/10.
parameter: [length, depth]
connections:
connection0:
- [portsplit0, botedge0]
- [boat0, portedge]
- {angle: -90}
connection1:
- [starsplit0, topedge0]
- [boat0, staredge]
- {angle: -90}
connection10:
- [starsplit1, botedge2]
- [seat2, l]
- {}
connection11:
- [portsplit2, topedge2]
- [seat2, r]
- {}
connection12:
- [starsplit0, botedge3]
- [seat3, l]
- {}
connection13:
- [portsplit1, topedge3]
- [seat3, r]
- {}
connection14:
- [starsplit1, botedge4]
- [seat4, l]
- {}
connection15:
- [portsplit2, topedge4]
- [seat4, r]
- {}
connection16:
- [starsplit0, botedge5]
- [seat5, l]
- {}
connection17:
- [portsplit1, topedge5]
- [seat5, r]
- {}
connection18:
- [starsplit1, botedge6]
- [seat6, l]
- {}
connection19:
- [portsplit2, topedge6]
- [seat6, r]
- {}
connection2:
- [portsplit1, botedge0]
- [boat1, portedge]
- {angle: -90}
connection20:
- [starsplit0, botedge7]
- [seat7, l]
- {}
connection21:
- [portsplit1, topedge7]
- [seat7, r]
- {}
connection22:
- [starsplit1, botedge8]
- [seat8, l]
- {}
connection23:
- [portsplit2, topedge8]
- [seat8, r]
- {}
connection24:
- [starsplit0, botedge9]
- [seat9, l]
- {}
connection25:
- [portsplit1, topedge9]
- [seat9, r]
- {}
connection3:
- [starsplit1, topedge0]
- [boat1, staredge]
- {angle: -90}
connection4:
- [portsplit2, botedge0]
- [boat2, portedge]
- {angle: -90}
connection5:
- [starsplit2, topedge0]
- [boat2, staredge]
- {angle: -90}
connection6:
- [starsplit1, botedge0]
- [seat0, l]
- {}
connection7:
- [portsplit2, topedge0]
- [seat0, r]
- {}
connection8:
- [starsplit0, botedge1]
- [seat1, l]
- {}
connection9:
- [portsplit1, topedge1]
- [seat1, r]
- {}
interfaces: {}
metadata:
bow: {default: 45}
depth: {default: 20}
length: {default: 250}
n: {default: 6}
spacing: {default: 25}
stern: {default: 0}
width: {default: 50}
parameters: {bow: 45, depth: 20, length: 250, n: 6, spacing: 25, stern: 0, width: 50}
subcomponents:
boat0:
classname: BoatBase
kwargs: {}
parameters:
bow: {parameter: bow}
depth: {parameter: depth}
length: {parameter: length}
stern: {parameter: stern}
width: {parameter: width}
boat1:
classname: BoatBase
kwargs: {}
parameters:
bow: {parameter: bow}
depth: {parameter: depth}
length: {parameter: length}
stern: {parameter: stern}
width: {parameter: width}
boat2:
classname: BoatBase
kwargs: {}
parameters:
bow: {parameter: bow}
depth: {parameter: depth}
length: {parameter: length}
stern: {parameter: stern}
width: {parameter: width}
portsplit0:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]]'
parameter: &id001 [length, n]
toplength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: &id002 [length, n]
portsplit1:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]]'
parameter: *id001
toplength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: *id002
portsplit2:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]]'
parameter: *id001
toplength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: *id002
seat0:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (0 < x[1]) and x[0] or 0
parameter: &id003 [spacing, n]
w:
function: x[0]/(1.*x[1])
parameter: &id004 [length, n]
seat1:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (1 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat2:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (2 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat3:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (3 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat4:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (4 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat5:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (5 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat6:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (6 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat7:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (7 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat8:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (8 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
seat9:
classname: Rectangle
kwargs: {}
parameters:
l:
function: (9 < x[1]) and x[0] or 0
parameter: *id003
w:
function: x[0]/(1.*x[1])
parameter: *id004
starsplit0:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: &id005 [length, n]
toplength:
function: '[x[0]]'
parameter: &id006 [length, n]
starsplit1:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: *id005
toplength:
function: '[x[0]]'
parameter: *id006
starsplit2:
classname: SplitEdge
kwargs: {}
parameters:
botlength:
function: '[x[0]/(1.*x[1])] * x[1]'
parameter: *id005
toplength:
function: '[x[0]]'
parameter: *id006
connections:
connection0:
- [cabin, portedge]
- [boat, portedge]
- {angle: 0}
connection1:
- [cabin, staredge]
- [boat, staredge]
- {angle: 0, tabWidth: 10}
interfaces: {}
metadata:
depth: {default: 50}
height: {default: 30}
length: {default: 200}
width: {default: 60}
parameters: {depth: 50, height: 30, length: 200, width: 60}
subcomponents:
boat:
classname: BoatBase
kwargs: {}
parameters:
bow: {function: x/2., parameter: length}
depth: {function: x/3., parameter: width}
length:
function: sum(x)
parameter: [length, depth]
stern: {function: x/8., parameter: length}
width: {parameter: width}
cabin:
classname: Cabin
kwargs: {}
parameters:
depth: {parameter: depth}
height: {parameter: height}
length: {parameter: length}
width: {parameter: width}
from svggen.library import getComponent
def test_make(display=False):
f = getComponent("Cabin")
f.makeOutput("output/cabin", tree=True, display=display)
if __name__ == '__main__':
test_make(display=False)
from svggen.library import getComponent
def test_make(display=False):
f = getComponent("Canoe")
f.makeOutput("output/canoe", tree=True, display=display)
if __name__ == '__main__':
test_make(display=False)
from svggen.library import getComponent
def test_make(display=False):
f = getComponent("Catamaran")
f.makeOutput("output/catamaran", tree=True, display=display)
if __name__ == '__main__':
test_make(display=False)
from svggen.library import getComponent
def test_make(display=False):
f = getComponent("Trimaran")
f.makeOutput("output/trimaran", tree=True, display=display)
if __name__ == '__main__':
test_make(display=False)
from svggen.library import getComponent
def test_make(display=False):
f = getComponent("Tug")
f.makeOutput("output/tug", tree=True, display=display)
if __name__ == '__main__':
test_make(display=False)