Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
a1d6ad4d
Commit
a1d6ad4d
authored
Apr 05, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add stl cutting functions and plumb it in the plater
parent
681e9989
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
stlplater.py
printrun/stlplater.py
+14
-1
stltool.py
printrun/stltool.py
+25
-0
No files found.
printrun/stlplater.py
View file @
a1d6ad4d
...
@@ -290,7 +290,20 @@ class StlPlater(Plater):
...
@@ -290,7 +290,20 @@ class StlPlater(Plater):
name
=
self
.
l
.
GetSelection
()
name
=
self
.
l
.
GetSelection
()
name
=
self
.
l
.
GetString
(
name
)
name
=
self
.
l
.
GetString
(
name
)
model
=
self
.
models
[
name
]
model
=
self
.
models
[
name
]
print
"Cutting"
,
name
,
self
.
cutting_axis
,
self
.
cutting_direction
,
self
.
cutting_dist
,
model
transformation
=
transformation_matrix
(
model
)
transformed
=
model
.
transform
(
transformation
)
print
_
(
"Cutting
%
s alongside
%
s axis"
)
%
(
name
,
self
.
cutting_axis
)
axes
=
[
"x"
,
"y"
,
"z"
]
cut
=
transformed
.
cut
(
axes
.
index
(
self
.
cutting_axis
),
self
.
cutting_direction
,
self
.
cutting_dist
)
cut
.
offsets
=
[
0
,
0
,
0
]
cut
.
rot
=
0
cut
.
scale
=
model
.
scale
cut
.
filename
=
model
.
filename
cut
.
centeroffset
=
[
0
,
0
,
0
]
self
.
s
.
prepare_model
(
cut
,
2
)
self
.
models
[
name
]
=
cut
self
.
cutconfirmbutton
.
Disable
()
self
.
cutconfirmbutton
.
Disable
()
def
clickcb
(
self
,
event
,
single
=
False
):
def
clickcb
(
self
,
event
,
single
=
False
):
...
...
printrun/stltool.py
View file @
a1d6ad4d
...
@@ -244,6 +244,31 @@ class stl(object):
...
@@ -244,6 +244,31 @@ class stl(object):
newmodel
=
self
.
transform
(
matrix
)
newmodel
=
self
.
transform
(
matrix
)
return
newmodel
return
newmodel
def
cut
(
self
,
axis
,
direction
,
dist
):
s
=
stl
()
s
.
facets
=
[]
f
=
min
if
direction
==
1
else
max
for
_
,
facet
in
self
.
facets
:
minval
=
f
([
vertex
[
axis
]
for
vertex
in
facet
])
if
direction
*
minval
>
direction
*
dist
:
continue
vertices
=
[]
for
vertex
in
facet
:
vertex
=
numpy
.
copy
(
vertex
)
if
direction
*
(
vertex
[
axis
]
-
dist
)
>
0
:
vertex
[
axis
]
=
dist
vertices
.
append
(
vertex
)
s
.
facets
.
append
(
genfacet
(
vertices
))
s
.
insolid
=
0
s
.
infacet
=
0
s
.
inloop
=
0
s
.
facetloc
=
0
s
.
name
=
self
.
name
for
facet
in
s
.
facets
:
s
.
facetsminz
+=
[(
min
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])),
facet
)]
s
.
facetsmaxz
+=
[(
max
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])),
facet
)]
return
s
def
translation_matrix
(
self
,
v
):
def
translation_matrix
(
self
,
v
):
matrix
=
[[
1
,
0
,
0
,
v
[
0
]],
matrix
=
[[
1
,
0
,
0
,
v
[
0
]],
[
0
,
1
,
0
,
v
[
1
]],
[
0
,
1
,
0
,
v
[
1
]],
...
...
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