Commit 6716dab0 authored by Lars Kruse's avatar Lars Kruse

replaced some few remaining occourences of old Point-class methods

parent 9b939792
......@@ -163,7 +163,7 @@ class BaseCutter(IDGenerator):
self.axis, self.distance_radius, self.distance_radiussq, direction, point)
# offset intersection
if ccp:
cl = cp.add(start.sub(ccp))
cl = padd(start, psub(cp, ccp))
return (cl, ccp, cp, l)
return (None, None, None, INFINITE)
......
......@@ -171,7 +171,7 @@ class SphericalCutter(BaseCutter):
# offset intersection
cl = None
if cp:
cl = start.add(direction.mul(l))
cl = padd(start, pmul(direction, l))
return (cl, ccp, cp, l)
def intersect_sphere_vertex(self, direction, point, start=None):
......
......@@ -212,7 +212,6 @@ class ToroidalCutter(BaseCutter):
# offset intersection
if ccp:
cl = padd(start, psub(cp, ccp))
#cl = start.add(cp.sub(ccp))
return (cl, ccp, cp, l)
return (None, None, None, INFINITE)
......
......@@ -183,9 +183,9 @@ class GCodeGenerator(object):
if position is None:
self.append("G28.1 (store current position for touch off)")
else:
self.append("#5161=%f (touch off position: x)" % position.x)
self.append("#5162=%f (touch off position: y)" % position.y)
self.append("#5163=%f (touch off position: z)" % position.z)
self.append("#5161=%f (touch off position: x)" % position[0])
self.append("#5162=%f (touch off position: y)" % position[1])
self.append("#5163=%f (touch off position: z)" % position[2])
def set_speed(self, feedrate=None, spindle_speed=None):
if not feedrate is None:
......
......@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam import VERSION
from pycam.Geometry.PointUtils import pnormalized
import datetime
import os
......@@ -50,13 +51,13 @@ class STLExporter(object):
yield """solid "%s"; Produced by %s (v%s), %s""" \
% (self.name, self.created_by, VERSION, date)
for triangle in self.model.triangles():
norm = triangle.normal.normalized()
yield "facet normal %f %f %f" % (norm.x, norm.y, norm.z)
norm = pnormalized(triangle.normal)
yield "facet normal %f %f %f" % (norm[0], norm[1], norm[2])
yield " outer loop"
# Triangle vertices are stored in clockwise order - thus we need
# to reverse the order (STL expects counter-clockwise orientation).
for point in (triangle.p1, triangle.p3, triangle.p2):
yield " vertex %f %f %f" % (point.x, point.y, point.z)
yield " vertex %f %f %f" % (point[0], point[1], point[2])
yield " endloop"
yield "endfacet"
yield "endsolid"
......
......@@ -87,7 +87,7 @@ class SVGExporter(object):
self.output.write(l)
def AddPoint(self, p):
self.AddDot(p.x, p.y)
self.AddDot(p[0], p[1])
def AddPath(self, path):
self.AddLines(path.points)
......@@ -100,7 +100,7 @@ class SVGExporter(object):
l += "M "
else:
l += " L "
l += "%.8f %.8f" % (p.x, -p.y)
l += "%.8f %.8f" % (p[0], -p[1])
l += "'/>\n"
self.output.write(l)
......
......@@ -33,7 +33,7 @@ try:
import INVALID_IMPORT
from collections import namedtuple
tuple_point = namedtuple("TuplePoint", "x y z")
get_point_object = lambda point: tuple_point(point.x, point.y, point.z)
get_point_object = lambda point: tuple_point(point[0], point[1], point[2])
except ImportError:
# dummy for python < v2.6 (consumes more memory)
get_point_object = lambda point: point
......@@ -59,7 +59,7 @@ class Path(IDGenerator):
first = False
else:
text += "-"
text += "%d(%g,%g,%g)" % (point.id, point.x, point.y, point.z)
text += "%d(%g,%g,%g)" % (id(point), point[0], point[1], point[2])
return text
def insert(self, index, point):
......
......@@ -1236,7 +1236,7 @@ class Polygon(TransformableContainer):
def get_plane_projection(self, plane):
if plane == self.plane:
return self
elif plane.n.dot(self.plane.n) == 0:
elif pdot(plane.n, self.plane.n) == 0:
log.warn("Polygon projection onto plane: orthogonal projection " \
+ "is not possible")
return None
......@@ -1247,7 +1247,7 @@ class Polygon(TransformableContainer):
p2 = plane.get_point_projection(line.p2)
result.append(Line(p1, p2))
# check if the projection would revert the direction of the polygon
if plane.n.dot(self.plane.n) < 0:
if pdot(plane.n, self.plane.n) < 0:
result.reverse_direction()
return result
......
......@@ -455,7 +455,7 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
edges.append(Line(p1, p2))
edges.sort(key=lambda x: x.len)
edge = edges[-1]
if edge.dir.cross(triangle.normal).dot(up_vector) < 0:
if pdot(pcross(edge.dir, triangle.normal), up_vector) < 0:
outer_edges = [Line(edge.p2, edge.p1)]
else:
outer_edges = [edge]
......@@ -466,7 +466,7 @@ def get_collision_waterline_of_triangle(model, cutter, up_vector, triangle, z):
max_length = sqrt(x_dim ** 2 + y_dim ** 2 + z_dim ** 2)
result = []
for edge in outer_edges:
direction = up_vector.cross(edge.dir).normalized()
direction = pnormalized(up_vector.cross(edge.dir))
if direction is None:
continue
direction = pmul(direction, max_length)
......@@ -516,9 +516,9 @@ def get_shifted_waterline(up_vector, waterline, cutter_location):
if offset < epsilon:
return wl_proj
# shift both ends of the waterline towards the cutter location
shift = cutter_location.sub(wl_proj.closest_point(cutter_location))
shift = psub(cutter_location, wl_proj.closest_point(cutter_location))
# increase the shift width slightly to avoid "touch" collisions
shift = shift.mul(1.0 + epsilon)
shifted_waterline = Line(wl_proj.p1.add(shift), wl_proj.p2.add(shift))
shift = pmul(shift, 1.0 + epsilon)
shifted_waterline = Line(padd(wl_proj.p1, shift), padd(wl_proj.p2, shift))
return shifted_waterline
......@@ -73,7 +73,7 @@ def convert_triangles_to_vertices_faces(triangles):
for p in (t.p1, t.p3, t.p2):
# add the point to the id/index mapping, if necessary
if not id_index_map.has_key(p.id):
corners.append((p.x, p.y, p.z))
corners.append((p[0], p[1], p[2]))
id_index_map[p.id] = len(corners) - 1
coords.append(id_index_map[p.id])
faces.append(coords)
......
......@@ -256,10 +256,8 @@ def get_spiral_layer(minx, maxx, miny, maxy, z, line_distance, step_width,
for index, (start, end) in enumerate(lines):
radius = 0.5 * min(line_distance_x, line_distance_y)
edge_vector = psub(end,start)
#edge_vector = end.sub(start)
# TODO: ellipse would be better than arc
offset = pmul(pnormalized(edge_vector), radius)
#offset = edge_vector.normalized().mul(radius)
if previous:
start = padd(start, offset)
center = padd(previous, offset)
......@@ -280,7 +278,7 @@ def get_spiral_layer(minx, maxx, miny, maxy, z, line_distance, step_width,
p2 = (p2_coord[0], p2_coord[1], z)
rounded_lines.append((p1, p2))
if index != len(lines) - 1:
end = end.sub(offset)
end = psub(end, offset)
previous = end
rounded_lines.append((start, end))
lines = rounded_lines
......
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