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
716ab0e9
Commit
716ab0e9
authored
Sep 07, 2011
by
Kliment Yanev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fast plater
parent
88a7b10c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
10 deletions
+69
-10
plater.py
plater.py
+69
-10
No files found.
plater.py
View file @
716ab0e9
...
...
@@ -69,8 +69,12 @@ class showstl(wx.Window):
name
=
dlg
.
GetPath
()
facets
=
[]
for
i
in
self
.
models
.
values
():
if
i
.
offsets
!=
[
0
,
0
,
0
]:
i
=
i
.
translate
(
i
.
offsets
)
r
=
i
.
rot
o
=
i
.
offsets
if
r
!=
0
:
i
=
i
.
rotate
([
0
,
0
,
-
r
])
if
o
!=
[
0
,
0
,
0
]:
i
=
i
.
translate
([
o
[
0
],
-
o
[
1
],
o
[
2
]])
facets
+=
i
.
facets
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
print
"wrote "
,
name
...
...
@@ -95,6 +99,46 @@ class showstl(wx.Window):
c
+=
1
self
.
models
[
newname
]
=
stltool
.
stl
(
name
)
self
.
models
[
newname
]
.
offsets
=
[
0
,
0
,
0
]
self
.
models
[
newname
]
.
rot
=
0
minx
,
miny
,
minz
,
maxx
,
maxy
,
maxz
=
(
10000
,
10000
,
10000
,
0
,
0
,
0
)
for
i
in
self
.
models
[
newname
]
.
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
]
self
.
models
[
newname
]
.
dims
=
[
minx
,
maxx
,
miny
,
maxy
,
minz
,
maxz
]
#if minx<0:
# self.models[newname].offsets[0]=-minx
#if miny<0:
# self.models[newname].offsets[1]=-miny
self
.
models
[
newname
]
.
bitmap
=
wx
.
EmptyBitmap
(
800
,
800
,
32
)
dc
=
wx
.
MemoryDC
()
dc
.
SelectObject
(
self
.
models
[
newname
]
.
bitmap
)
dc
.
SetBackground
(
wx
.
Brush
((
0
,
0
,
0
,
0
)))
dc
.
SetBrush
(
wx
.
Brush
((
0
,
0
,
0
,
255
)))
#dc.DrawRectangle(-1,-1,10000,10000)
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
128
,
128
)))
m
=
self
.
models
[
newname
]
#m.offsets=[10,10,0]
print
m
.
offsets
,
m
.
dims
scale
=
2
for
i
in
m
.
facets
:
#random.sample(m.facets,min(100000,len(m.facets))):
dc
.
DrawPolygon
([
wx
.
Point
(
400
+
scale
*
p
[
0
],(
400
+
scale
*
p
[
1
]))
for
p
in
i
[
1
]])
#if(time.time()-t)>5:
# break
dc
.
SelectObject
(
wx
.
NullBitmap
)
m
.
bitmap
.
SetMask
(
wx
.
Mask
(
m
.
bitmap
,
wx
.
Colour
(
0
,
0
,
0
,
255
)))
#print time.time()-t
self
.
l
.
Append
([
stlwrap
(
self
.
models
[
newname
],
newname
)])
i
=
self
.
l
.
GetFirstSelected
()
...
...
@@ -134,16 +178,19 @@ class showstl(wx.Window):
else
:
event
.
Skip
()
def
cr
(
self
):
time
.
sleep
(
0.01
)
def
rotateafter
(
self
):
if
(
self
.
i
!=
self
.
previ
):
i
=
self
.
l
.
GetFirstSelected
()
if
i
!=
-
1
:
o
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
offsets
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
rotate
([
0
,
0
,
5
*
(
self
.
i
-
self
.
previ
)]
)
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
offsets
=
o
#
o=self.models[self.l.GetItemText(i)].offsets
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
rot
+=
5
*
(
self
.
i
-
self
.
previ
)
#
self.models[self.l.GetItemText(i)].offsets=o
self
.
previ
=
self
.
i
wx
.
CallAfter
(
self
.
Refresh
)
self
.
Refresh
()
def
cr
(
self
):
time
.
sleep
(
0.01
)
wx
.
CallAfter
(
self
.
rotateafter
)
self
.
triggered
=
0
def
rot
(
self
,
event
):
...
...
@@ -181,9 +228,21 @@ class showstl(wx.Window):
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
128
,
128
)))
t
=
time
.
time
()
dcs
=
wx
.
MemoryDC
()
for
m
in
self
.
models
.
values
():
for
i
in
m
.
facets
:
#random.sample(m.facets,min(100000,len(m.facets))):
dc
.
DrawPolygon
([
wx
.
Point
(
offset
[
0
]
+
scale
*
m
.
offsets
[
0
]
+
scale
*
p
[
0
],
400
-
(
offset
[
1
]
+
scale
*
m
.
offsets
[
1
]
+
scale
*
p
[
1
]))
for
p
in
i
[
1
]])
b
=
m
.
bitmap
#print b
im
=
b
.
ConvertToImage
()
#print im
imgc
=
wx
.
Point
(
im
.
GetWidth
()
/
2
,
im
.
GetHeight
()
/
2
)
#print math.radians(5*(self.i-self.previ))
im
=
im
.
Rotate
(
math
.
radians
(
m
.
rot
),
imgc
,
0
)
bm
=
wx
.
BitmapFromImage
(
im
)
dcs
.
SelectObject
(
bm
)
bsz
=
bm
.
GetSize
()
dc
.
Blit
(
scale
*
m
.
offsets
[
0
]
-
bsz
[
0
]
/
2
,
400
-
(
scale
*
m
.
offsets
[
1
]
+
bsz
[
1
]
/
2
),
bsz
[
0
],
bsz
[
1
],
dcs
,
0
,
0
,
useMask
=
1
)
#for i in m.facets:#random.sample(m.facets,min(100000,len(m.facets))):
# dc.DrawPolygon([wx.Point(offset[0]+scale*m.offsets[0]+scale*p[0],400-(offset[1]+scale*m.offsets[1]+scale*p[1])) for p in i[1]])
#if(time.time()-t)>5:
# break
del
dc
...
...
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