Commit 50e2f2ba authored by sumpfralle's avatar sumpfralle

separated handling of LineGroups (for contour classes)

skip unnecessary double-check of line collisions
moved "MODEL_TRANSFORMATIONS" from pycam.Geometry.Model to pycam.Geometry.Matrix (as "TRANSFORMATIONS")
fixed accidental reversion of contour model direction caused by some model transformations


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@523 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b829ff3e
This diff is collapsed.
......@@ -27,6 +27,20 @@ from pycam.Geometry.Point import Point
import math
TRANSFORMATIONS = {
"normal": ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0)),
"x": ((1, 0, 0, 0), (0, 0, 1, 0), (0, -1, 0, 0)),
"y": ((0, 0, -1, 0), (0, 1, 0, 0), (1, 0, 0, 0)),
"z": ((0, 1, 0, 0), (-1, 0, 0, 0), (0, 0, 1, 0)),
"xy": ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0)),
"xz": ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0)),
"yz": ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0)),
"x_swap_y": ((0, 1, 0, 0), (1, 0, 0, 0), (0, 0, 1, 0)),
"x_swap_z": ((0, 0, 1, 0), (0, 1, 0, 0), (1, 0, 0, 0)),
"y_swap_z": ((1, 0, 0, 0), (0, 0, 1, 0), (0, 1, 0, 0)),
}
def get_dot_product(a, b):
""" calculate the dot product of two 3d vectors
......@@ -158,7 +172,35 @@ def multiply_vector_matrix(v, m):
@rtype: tuple(float)
@return: a tuple of 3 floats as the matrix product
"""
if len(m) == 9:
m = ((m[0], m[1], m[2]), (m[3], m[4], m[5]), (m[6], m[7], m[8]))
return (v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2],
v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2],
v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2])
def multiply_matrix_matrix(m1, m2):
def multi(row1, col2):
return (m1[row1][0] * m2[0][col2] + m1[row1][1] * m2[1][col2] \
+ m1[row1][2] * m2[2][col2])
return ((multi(0, 0), multi(0, 1), multi(0, 2)),
(multi(1, 0), multi(1, 1), multi(1, 2)),
(multi(2, 0), multi(2, 1), multi(2, 2)))
def get_inverse_matrix(m):
_a = m[1][1] * m[2][2] - m[1][2] * m[2][1]
_b = m[0][2] * m[2][1] - m[0][1] * m[2][2]
_c = m[0][1] * m[1][2] - m[0][2] * m[1][1]
_d = m[1][2] * m[2][0] - m[1][0] * m[2][2]
_e = m[0][0] * m[2][2] - m[0][2] * m[2][0]
_f = m[0][2] * m[1][0] - m[0][0] * m[1][2]
_g = m[1][0] * m[2][1] - m[1][1] * m[2][0]
_h = m[0][1] * m[2][0] - m[0][0] * m[2][1]
_k = m[0][0] * m[1][1] - m[0][1] * m[1][0]
det = m[0][0] * _a + m[0][1] * _d + m[0][2] * _g
if det == 0:
return None
else:
return ((_a / det, _b / det, _c / det),
(_d / det, _e / det, _f / det),
(_g / det, _h / det, _k / det))
This diff is collapsed.
......@@ -78,7 +78,7 @@ class EngraveCutter:
break
for line_group in line_groups:
for line in line_group:
for line in line_group.next():
self.GenerateToolPathLinePush(self.pa_push, line, z,
draw_callback)
if progress_counter.increment():
......@@ -107,7 +107,7 @@ class EngraveCutter:
for line_group in self.contour_model.get_line_groups():
self.pa_drop.new_direction(0)
self.pa_drop.new_scanline()
for line in line_group:
for line in line_group.get_lines():
self.GenerateToolPathLineDrop(self.pa_drop, line, minz, maxz,
horiz_step, draw_callback=draw_callback)
if progress_counter.increment():
......
......@@ -157,8 +157,8 @@ def generate_toolpath(model, tool_settings=None,
if (not contour_model is None) and (engrave_offset > 0):
if not callback is None:
callback(text="Preparing contour model with offset ...")
progress_callback = ProgressCounter(len(contour_model.get_lines()),
callback).increment
progress_callback = ProgressCounter(
len(contour_model.get_line_groups()), callback).increment
else:
progress_callback = None
contour_model = contour_model.get_offset_model(engrave_offset,
......
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