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
362207d6
Commit
362207d6
authored
Apr 04, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compute stl dims in stltool
parent
d73b1100
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
22 deletions
+29
-22
stlplater.py
printrun/stlplater.py
+0
-21
stltool.py
printrun/stltool.py
+29
-1
No files found.
printrun/stlplater.py
View file @
362207d6
...
...
@@ -307,27 +307,6 @@ class StlPlater(Plater):
model
.
rot
=
rotation
model
.
scale
=
list
(
scale
)
model
.
filename
=
name
minx
=
float
(
"inf"
)
miny
=
float
(
"inf"
)
minz
=
float
(
"inf"
)
maxx
=
float
(
"-inf"
)
maxy
=
float
(
"-inf"
)
maxz
=
float
(
"-inf"
)
for
i
in
model
.
facets
:
for
j
in
i
[
1
]:
if
j
[
0
]
<
minx
:
minx
=
j
[
0
]
if
j
[
1
]
<
miny
:
miny
=
j
[
1
]
if
j
[
2
]
<
minz
:
minz
=
j
[
2
]
if
j
[
0
]
>
maxx
:
maxx
=
j
[
0
]
if
j
[
1
]
>
maxy
:
maxy
=
j
[
1
]
if
j
[
2
]
>
maxz
:
maxz
=
j
[
2
]
model
.
dims
=
[
minx
,
maxx
,
miny
,
maxy
,
minz
,
maxz
]
self
.
add_model
(
name
,
model
)
model
.
centeroffset
=
[
-
(
model
.
dims
[
1
]
+
model
.
dims
[
0
])
/
2
,
-
(
model
.
dims
[
3
]
+
model
.
dims
[
2
])
/
2
,
...
...
printrun/stltool.py
View file @
362207d6
...
...
@@ -89,6 +89,35 @@ def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
class
stl
(
object
):
_dims
=
None
def
_get_dims
(
self
):
if
self
.
_dims
is
None
:
minx
=
float
(
"inf"
)
miny
=
float
(
"inf"
)
minz
=
float
(
"inf"
)
maxx
=
float
(
"-inf"
)
maxy
=
float
(
"-inf"
)
maxz
=
float
(
"-inf"
)
for
normal
,
facet
in
self
.
facets
:
for
vert
in
facet
:
if
vert
[
0
]
<
minx
:
minx
=
vert
[
0
]
if
vert
[
1
]
<
miny
:
miny
=
vert
[
1
]
if
vert
[
2
]
<
minz
:
minz
=
vert
[
2
]
if
vert
[
0
]
>
maxx
:
maxx
=
vert
[
0
]
if
vert
[
1
]
>
maxy
:
maxy
=
vert
[
1
]
if
vert
[
2
]
>
maxz
:
maxz
=
vert
[
2
]
self
.
_dims
=
[
minx
,
maxx
,
miny
,
maxy
,
minz
,
maxz
]
return
self
.
_dims
dims
=
property
(
_get_dims
)
def
__init__
(
self
,
filename
=
None
):
self
.
facet
=
[[
0
,
0
,
0
],
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
[
0
,
0
,
0
]]]
self
.
facets
=
[]
...
...
@@ -145,7 +174,6 @@ class stl(object):
return
self
.
transform
(
matrix
)
def
rotate
(
self
,
v
=
[
0
,
0
,
0
]):
import
math
z
=
v
[
2
]
matrix1
=
[[
math
.
cos
(
math
.
radians
(
z
)),
-
math
.
sin
(
math
.
radians
(
z
)),
0
,
0
],
[
math
.
sin
(
math
.
radians
(
z
)),
math
.
cos
(
math
.
radians
(
z
)),
0
,
0
],
...
...
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