Commit f0cbf0d4 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

infill zig zagging but in straight line

parent cc94368a
......@@ -78,17 +78,17 @@ class solver:
return float(self.layer.subs([(self.x, x), (self.y, y), (self.cz, layer*self.dz)]))
def def_prism(self, x_min = -0.05, x_max = 0.05,
y_min = -0.05, y_max = 0.05,
z_min = 0., z_max = 0.1):
def def_prism(self, x_range = (-0.05, 0.05),
y_range = (-0.05, 0.05),
z_range = (0., 0.1)):
"""
save the prism size
"""
self.range = {
self.x: (x_min, x_max),
self.y: (y_min, y_max),
self.z: (z_min, z_max),
self.x: x_range,
self.y: y_range,
self.z: z_range,
}
......@@ -116,7 +116,7 @@ class solver:
return v1, zs
def trim_contour(self, c, zlims):
def trim_contour(self, c):
"""
take a contour and split it at z limits
......@@ -126,6 +126,7 @@ class solver:
will be split
"""
zlims = self.range[self.z]
c_out = []
j = 0 # index of last intersection with limit
state = zlims[0] < c.pos[0][2] < zlims[1]
......@@ -157,29 +158,25 @@ class solver:
expr1 = self.plane_intersection(self.x, self.range[self.x][0], layer = n)
ys, zs = self.sample(expr1, self.y)
contours += self.trim_contour(
contour([Position(self.range[self.x][0],ys[i],zs[i]) for i in range(len(ys))], 0),
self.range[self.z]
contour([Position(self.range[self.x][0],ys[i],zs[i]) for i in range(len(ys))], 0)
)
expr2 = self.plane_intersection(self.x, self.range[self.x][1], layer = n)
ys, zs = self.sample(expr2, self.y)
contours += self.trim_contour(
contour([Position(self.range[self.x][1],ys[i],zs[i]) for i in range(len(ys))], 0),
self.range[self.z]
contour([Position(self.range[self.x][1],ys[i],zs[i]) for i in range(len(ys))], 0)
)
expr3 = self.plane_intersection(self.y, self.range[self.y][0], layer = n)
xs, zs = self.sample(expr3, self.x)
contours += self.trim_contour(
contour([Position(xs[i],self.range[self.y][0],zs[i]) for i in range(len(ys))], 0),
self.range[self.z]
contour([Position(xs[i],self.range[self.y][0],zs[i]) for i in range(len(ys))], 0)
)
expr4 = self.plane_intersection(self.y, self.range[self.y][1], layer = n)
xs, zs = self.sample(expr4, self.x)
contours += self.trim_contour(
contour([Position(xs[i],self.range[self.y][1],zs[i]) for i in range(len(ys))], 0),
self.range[self.z]
contour([Position(xs[i],self.range[self.y][1],zs[i]) for i in range(len(ys))], 0)
)
# TODO Join adjacent contours into one
......@@ -206,18 +203,35 @@ class solver:
# do the first row
expr1 = self.plane_intersection(main, main_vals[0], layer = n)
os, zs = self.sample(expr1, other)
poses = [Position(self.range[main][0],os[i],zs[i]) for i in range(len(os))]
if main is self.x:
poses = [Position(main_vals[0], os[i], zs[i]) for i in range(len(os))]
else:
poses = [Position(os[i], main_vals[0], zs[i]) for i in range(len(os))]
# loop through th remaining rows, linking them
direction = True
for row in main_vals[1:]:
# TODO link to the next row
# TODO do the next row (need to reverse directions each time)
expr1 = self.plane_intersection(main, row, layer = n)
os, zs = self.sample(expr1, other)
poses = [Position(self.range[main][0],os[i],zs[i]) for i in range(len(os))]
# Reverse direction each time to get zig-zagging
if direction:
direction = False
os = os[::-1]
zs = zs[::-1]
else:
direction = True
# Join the next row
if main is self.x:
poses += [Position(row, os[i], zs[i]) for i in range(len(os))]
else:
poses += [Position(os[i], row, zs[i]) for i in range(len(os))]
return self.trim_contour(contour(poses, 0))
def show(self):
......
Markdown is supported
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