Commit 43541aa0 authored by Whitham D. Reeve II's avatar Whitham D. Reeve II

Remove old commented out code.

parent c8d5feb1
...@@ -50,7 +50,6 @@ def _process_one_triangle((model, cutter, up_vector, triangle, z)): ...@@ -50,7 +50,6 @@ def _process_one_triangle((model, cutter, up_vector, triangle, z)):
# Case 1a # Case 1a
return result, None return result, None
# ignore triangles pointing upwards or downwards # ignore triangles pointing upwards or downwards
#if triangle.normal.cross(up_vector).norm == 0:
if pnorm(pcross(triangle.normal, up_vector)) == 0: if pnorm(pcross(triangle.normal, up_vector)) == 0:
# Case 1b # Case 1b
return result, None return result, None
...@@ -344,14 +343,12 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -344,14 +343,12 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
for index in range(3): for index in range(3):
edge = Line(proj_points[index - 1], proj_points[index]) edge = Line(proj_points[index - 1], proj_points[index])
# the edge should be clockwise around the model # the edge should be clockwise around the model
#if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0: if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
edge = Line(edge.p2, edge.p1) edge = Line(edge.p2, edge.p1)
edges.append((edge, proj_points[index - 2])) edges.append((edge, proj_points[index - 2]))
outer_edges = [] outer_edges = []
for edge, other_point in edges: for edge, other_point in edges:
# pick only edges, where the other point is on the right side # pick only edges, where the other point is on the right side
#if other_point.sub(edge.p1).cross(edge.dir).dot(up_vector) > 0:
if pdot(pcross(psub(other_point, edge.p1), edge.dir), up_vector) > 0: if pdot(pcross(psub(other_point, edge.p1), edge.dir), up_vector) > 0:
outer_edges.append(edge) outer_edges.append(edge)
if len(outer_edges) == 0: if len(outer_edges) == 0:
...@@ -364,7 +361,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -364,7 +361,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
outer_edges = [long_edge] outer_edges = [long_edge]
else: else:
edge = Line(proj_points[0], proj_points[1]) edge = Line(proj_points[0], proj_points[1])
#if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0: if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
edge = Line(edge.p2, edge.p1) edge = Line(edge.p2, edge.p1)
outer_edges = [edge] outer_edges = [edge]
...@@ -402,7 +398,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -402,7 +398,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
elif len(points_above) == 1: elif len(points_above) == 1:
other_point = points_above[0] other_point = points_above[0]
dot = pdot(pcross(psub(other_point, waterline.p1), waterline.dir), up_vector) dot = pdot(pcross(psub(other_point, waterline.p1), waterline.dir), up_vector)
#dot = other_point.sub(waterline.p1).cross(waterline.dir).dot(up_vector)
if dot > 0: if dot > 0:
# Case (2b) # Case (2b)
outer_edges = [waterline] outer_edges = [waterline]
...@@ -413,7 +408,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -413,7 +408,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
edges.append(Line(waterline.p2, other_point)) edges.append(Line(waterline.p2, other_point))
outer_edges = [] outer_edges = []
for edge in edges: for edge in edges:
#if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0: if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
outer_edges.append(Line(edge.p2, edge.p1)) outer_edges.append(Line(edge.p2, edge.p1))
else: else:
...@@ -427,7 +421,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -427,7 +421,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
edges.append(Line(waterline.p2, other_point)) edges.append(Line(waterline.p2, other_point))
edges.sort(key=lambda x: x.len) edges.sort(key=lambda x: x.len)
edge = edges[-1] edge = edges[-1]
#if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0: if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
outer_edges = [Line(edge.p2, edge.p1)] outer_edges = [Line(edge.p2, edge.p1)]
else: else:
...@@ -436,7 +429,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -436,7 +429,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
# two points above # two points above
other_point = points_above[0] other_point = points_above[0]
dot = pdot(pcross(psub(other_point, waterline.p1), waterline.dir), up_vector) dot = pdot(pcross(psub(other_point, waterline.p1), waterline.dir), up_vector)
#dot = other_point.sub(waterline.p1).cross(waterline.dir).dot(up_vector)
if dot > 0: if dot > 0:
# Case (2b) # Case (2b)
# the other two points are on the right side # the other two points are on the right side
...@@ -444,7 +436,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -444,7 +436,6 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
elif dot < 0: elif dot < 0:
# Case (3a) # Case (3a)
edge = Line(points_above[0], points_above[1]) edge = Line(points_above[0], points_above[1])
#if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0: if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
outer_edges = [Line(edge.p2, edge.p1)] outer_edges = [Line(edge.p2, edge.p1)]
else: else:
...@@ -479,22 +470,19 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z): ...@@ -479,22 +470,19 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
if direction is None: if direction is None:
continue continue
direction = pmul(direction, max_length) direction = pmul(direction, max_length)
#direction = direction.mul(max_length)
edge_dir = psub(edge.p2, edge.p1) edge_dir = psub(edge.p2, edge.p1)
#edge_dir = edge.p2.sub(edge.p1)
# TODO: Adapt the number of potential starting positions to the length # TODO: Adapt the number of potential starting positions to the length
# of the line. Don't use 0.0 and 1.0 - this could result in ambiguous # of the line. Don't use 0.0 and 1.0 - this could result in ambiguous
# collisions with triangles sharing these vertices. # collisions with triangles sharing these vertices.
for factor in (0.5, epsilon, 1.0 - epsilon, 0.25, 0.75): for factor in (0.5, epsilon, 1.0 - epsilon, 0.25, 0.75):
start = padd(edge.p1, pmul(edge_dir, factor)) start = padd(edge.p1, pmul(edge_dir, factor))
#start = edge.p1.add(edge_dir.mul(factor))
# We need to use the triangle collision algorithm here - because we # We need to use the triangle collision algorithm here - because we
# need the point of collision in the triangle. # need the point of collision in the triangle.
collisions = get_free_paths_triangles([model], cutter, start, padd(start, direction), return_triangles=True) collisions = get_free_paths_triangles([model], cutter, start, padd(start, direction), return_triangles=True)
for index, coll in enumerate(collisions): for index, coll in enumerate(collisions):
if (index % 2 == 0) and (not coll[1] is None) \ if (index % 2 == 0) and (not coll[1] is None) \
and (not coll[2] is None) \ and (not coll[2] is None) \
and (pdot(psub(coll[0], start), direction) > 0): #and (coll[0].sub(start).dot(direction) > 0): and (pdot(psub(coll[0], start), direction) > 0):
cl, hit_t, cp = coll cl, hit_t, cp = coll
break break
else: else:
......
...@@ -26,8 +26,7 @@ from pycam.Utils import ProgressCounter ...@@ -26,8 +26,7 @@ from pycam.Utils import ProgressCounter
from pycam.Utils.threading import run_in_parallel from pycam.Utils.threading import run_in_parallel
import pycam.Geometry.Model import pycam.Geometry.Model
import pycam.Utils.log import pycam.Utils.log
#import pprint
#pp = pprint.PrettyPrinter(indent=4)
log = pycam.Utils.log.get_logger() log = pycam.Utils.log.get_logger()
......
...@@ -129,7 +129,6 @@ class PushCutter(object): ...@@ -129,7 +129,6 @@ class PushCutter(object):
p1, p2 = line p1, p2 = line
# calculate the required calculation depth (recursion) # calculate the required calculation depth (recursion)
distance = pnorm(psub(p2, p1)) distance = pnorm(psub(p2, p1))
#distance = p2.sub(p1).norm
# TODO: accessing cutter.radius here is slightly ugly # TODO: accessing cutter.radius here is slightly ugly
depth = math.log(accuracy * distance / cutter.radius) / math.log(2) depth = math.log(accuracy * distance / cutter.radius) / math.log(2)
depth = min(max(ceil(depth), 4), max_depth) depth = min(max(ceil(depth), 4), max_depth)
......
...@@ -65,11 +65,8 @@ def get_free_paths_triangles(models, cutter, p1, p2, return_triangles=False): ...@@ -65,11 +65,8 @@ def get_free_paths_triangles(models, cutter, p1, p2, return_triangles=False):
return all_results return all_results
backward = pnormalized(psub(p1, p2)) backward = pnormalized(psub(p1, p2))
#backward = p1.sub(p2).normalized()
forward = pnormalized(psub(p2, p1)) forward = pnormalized(psub(p2, p1))
#forward = p2.sub(p1).normalized()
xyz_dist = pnorm(psub(p2, p1)) xyz_dist = pnorm(psub(p2, p1))
#xyz_dist = p2.sub(p1).norm
minx = min(p1[0], p2[0]) minx = min(p1[0], p2[0])
maxx = max(p1[0], p2[0]) maxx = max(p1[0], p2[0])
...@@ -255,9 +252,7 @@ def get_max_height_triangles(model, cutter, x, y, minz, maxz): ...@@ -255,9 +252,7 @@ def get_max_height_triangles(model, cutter, x, y, minz, maxz):
def _check_deviance_of_adjacent_points(p1, p2, p3, min_distance): def _check_deviance_of_adjacent_points(p1, p2, p3, min_distance):
straight = psub(p3, p1) straight = psub(p3, p1)
#straight = p3.sub(p1)
added = pnorm(psub(p2, p1)) + pnorm(psub(p3, p2)) added = pnorm(psub(p2, p1)) + pnorm(psub(p3, p2))
#added = p2.sub(p1).norm + p3.sub(p2).norm
# compare only the x/y distance of p1 and p3 with min_distance # compare only the x/y distance of p1 and p3 with min_distance
if straight[0] ** 2 + straight[1] ** 2 < min_distance ** 2: if straight[0] ** 2 + straight[1] ** 2 < min_distance ** 2:
# the points are too close together # the points are too close together
......
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