Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pyMKcam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
pyMKcam
Commits
6716dab0
Commit
6716dab0
authored
Mar 30, 2012
by
Lars Kruse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced some few remaining occourences of old Point-class methods
parent
9b939792
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
22 additions
and
24 deletions
+22
-24
BaseCutter.py
pycam/Cutters/BaseCutter.py
+1
-1
SphericalCutter.py
pycam/Cutters/SphericalCutter.py
+1
-1
ToroidalCutter.py
pycam/Cutters/ToroidalCutter.py
+0
-1
GCodeExporter.py
pycam/Exporters/GCodeExporter.py
+3
-3
STLExporter.py
pycam/Exporters/STLExporter.py
+4
-3
SVGExporter.py
pycam/Exporters/SVGExporter.py
+2
-2
Path.py
pycam/Geometry/Path.py
+2
-2
Polygon.py
pycam/Geometry/Polygon.py
+2
-2
ContourFollow.py
pycam/PathGenerators/ContourFollow.py
+5
-5
ode_physics.py
pycam/Physics/ode_physics.py
+1
-1
MotionGrid.py
pycam/Toolpath/MotionGrid.py
+1
-3
No files found.
pycam/Cutters/BaseCutter.py
View file @
6716dab0
...
...
@@ -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
)
...
...
pycam/Cutters/SphericalCutter.py
View file @
6716dab0
...
...
@@ -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
):
...
...
pycam/Cutters/ToroidalCutter.py
View file @
6716dab0
...
...
@@ -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
)
...
...
pycam/Exporters/GCodeExporter.py
View file @
6716dab0
...
...
@@ -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
:
...
...
pycam/Exporters/STLExporter.py
View file @
6716dab0
...
...
@@ -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"
...
...
pycam/Exporters/SVGExporter.py
View file @
6716dab0
...
...
@@ -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
+=
"
%.8
f
%.8
f"
%
(
p
.
x
,
-
p
.
y
)
l
+=
"
%.8
f
%.8
f"
%
(
p
[
0
],
-
p
[
1
]
)
l
+=
"'/>
\n
"
self
.
output
.
write
(
l
)
...
...
pycam/Geometry/Path.py
View file @
6716dab0
...
...
@@ -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
):
...
...
pycam/Geometry/Polygon.py
View file @
6716dab0
...
...
@@ -1236,7 +1236,7 @@ class Polygon(TransformableContainer):
def
get_plane_projection
(
self
,
plane
):
if
plane
==
self
.
plane
:
return
self
elif
p
lane
.
n
.
dot
(
self
.
plane
.
n
)
==
0
:
elif
p
dot
(
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
p
lane
.
n
.
dot
(
self
.
plane
.
n
)
<
0
:
if
p
dot
(
plane
.
n
,
self
.
plane
.
n
)
<
0
:
result
.
reverse_direction
()
return
result
...
...
pycam/PathGenerators/ContourFollow.py
View file @
6716dab0
...
...
@@ -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
pycam/Physics/ode_physics.py
View file @
6716dab0
...
...
@@ -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
)
...
...
pycam/Toolpath/MotionGrid.py
View file @
6716dab0
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment