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
7cfcf617
Commit
7cfcf617
authored
Apr 05, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ground work to make a stl cutting tool in stlplater
parent
f6876d40
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
0 deletions
+104
-0
stlplater.py
printrun/stlplater.py
+2
-0
stlview.py
printrun/stlview.py
+102
-0
No files found.
printrun/stlplater.py
View file @
7cfcf617
...
@@ -225,6 +225,8 @@ class StlPlater(Plater):
...
@@ -225,6 +225,8 @@ class StlPlater(Plater):
parent
=
None
,
build_dimensions
=
None
,
circular_platform
=
False
,
parent
=
None
,
build_dimensions
=
None
,
circular_platform
=
False
,
simarrange_path
=
None
,
antialias_samples
=
0
):
simarrange_path
=
None
,
antialias_samples
=
0
):
super
(
StlPlater
,
self
)
.
__init__
(
filenames
,
size
,
callback
,
parent
,
build_dimensions
)
super
(
StlPlater
,
self
)
.
__init__
(
filenames
,
size
,
callback
,
parent
,
build_dimensions
)
self
.
cutting
=
False
self
.
cutting_axis
=
None
if
glview
:
if
glview
:
viewer
=
stlview
.
StlViewPanel
(
self
,
(
580
,
580
),
viewer
=
stlview
.
StlViewPanel
(
self
,
(
580
,
580
),
build_dimensions
=
self
.
build_dimensions
,
build_dimensions
=
self
.
build_dimensions
,
...
...
printrun/stlview.py
View file @
7cfcf617
...
@@ -318,6 +318,53 @@ class StlViewPanel(wxGLPanel):
...
@@ -318,6 +318,53 @@ class StlViewPanel(wxGLPanel):
model
.
batch
.
draw
()
model
.
batch
.
draw
()
glPopMatrix
()
glPopMatrix
()
glPopMatrix
()
glPopMatrix
()
# Draw cutting plane
if
self
.
parent
.
cutting
:
# FIXME: make this a proper Actor
axis
=
self
.
parent
.
cutting_axis
dist
,
plane_width
,
plane_height
=
self
.
get_cutting_plane
(
axis
)
if
dist
is
not
None
:
glPushMatrix
()
if
axis
==
"x"
:
glRotatef
(
90
,
0
,
1
,
0
)
glRotatef
(
90
,
0
,
0
,
1
)
glTranslatef
(
0
,
0
,
dist
)
elif
axis
==
"y"
:
glRotatef
(
90
,
1
,
0
,
0
)
glTranslatef
(
0
,
0
,
-
dist
)
elif
axis
==
"z"
:
glTranslatef
(
0
,
0
,
dist
)
glDisable
(
GL_CULL_FACE
)
glBegin
(
GL_TRIANGLES
)
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.9
,
0.15
,
0.3
))
glNormal3f
(
0
,
0
,
1
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
0
,
0
,
0
)
glVertex3f
(
plane_width
,
0
,
0
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
0
,
0
,
0
)
glEnd
()
glEnable
(
GL_CULL_FACE
)
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINE
)
glEnable
(
GL_LINE_SMOOTH
)
orig_linewidth
=
(
GLfloat
)()
glGetFloatv
(
GL_LINE_WIDTH
,
orig_linewidth
)
glLineWidth
(
4.0
)
glBegin
(
GL_LINE_LOOP
)
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.8
,
0.15
,
1
))
glNormal3f
(
0
,
0
,
1
)
glVertex3f
(
0
,
0
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
plane_width
,
0
,
0
)
glEnd
()
glLineWidth
(
orig_linewidth
)
glDisable
(
GL_LINE_SMOOTH
)
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
glPopMatrix
()
glPopMatrix
()
glPopMatrix
()
# ==========================================================================
# ==========================================================================
...
@@ -338,6 +385,61 @@ class StlViewPanel(wxGLPanel):
...
@@ -338,6 +385,61 @@ class StlViewPanel(wxGLPanel):
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
return
mvmat
return
mvmat
def
get_cutting_plane
(
self
,
cutting_axis
):
ref_sizes
=
{
"x"
:
self
.
platform
.
width
,
"y"
:
self
.
platform
.
depth
,
"z"
:
self
.
platform
.
height
,
}
ref_planes
=
{
"x"
:
(
0
,
0
,
1
),
"y"
:
(
0
,
0
,
1
),
"z"
:
(
0
,
1
,
0
)
}
ref_offsets
=
{
"x"
:
0
,
"y"
:
0
,
"z"
:
-
self
.
platform
.
depth
/
2
}
translate_axis
=
{
"x"
:
0
,
"y"
:
1
,
"z"
:
2
}
fallback_ref_planes
=
{
"x"
:
(
0
,
1
,
0
),
"y"
:
(
1
,
0
,
0
),
"z"
:
(
1
,
0
,
0
)
}
fallback_ref_offsets
=
{
"x"
:
-
self
.
platform
.
height
/
2
,
"y"
:
-
self
.
platform
.
width
/
2
,
"z"
:
-
self
.
platform
.
width
/
2
,
}
cutting_plane_sizes
=
{
"x"
:
(
self
.
platform
.
depth
,
self
.
platform
.
height
),
"y"
:
(
self
.
platform
.
width
,
self
.
platform
.
height
),
"z"
:
(
self
.
platform
.
width
,
self
.
platform
.
depth
)}
ref_size
=
ref_sizes
[
cutting_axis
]
ref_plane
=
ref_planes
[
cutting_axis
]
ref_offset
=
ref_offsets
[
cutting_axis
]
plane_width
,
plane_height
=
cutting_plane_sizes
[
cutting_axis
]
inter
=
self
.
mouse_to_plane
(
self
.
mousepos
[
0
],
self
.
mousepos
[
1
],
plane_normal
=
ref_plane
,
plane_offset
=
ref_offset
,
local_transform
=
False
)
max_size
=
max
((
self
.
platform
.
width
,
self
.
platform
.
depth
,
self
.
platform
.
height
))
dist
=
None
if
inter
is
not
None
and
numpy
.
fabs
(
inter
)
.
max
()
+
max_size
/
2
<
2
*
max_size
:
dist
=
inter
[
translate_axis
[
cutting_axis
]]
if
dist
is
None
or
dist
<
-
0.5
*
ref_size
or
dist
>
1.5
*
ref_size
:
ref_plane
=
fallback_ref_planes
[
cutting_axis
]
ref_offset
=
fallback_ref_offsets
[
cutting_axis
]
inter
=
self
.
mouse_to_plane
(
self
.
mousepos
[
0
],
self
.
mousepos
[
1
],
plane_normal
=
ref_plane
,
plane_offset
=
ref_offset
,
local_transform
=
False
)
if
inter
is
not
None
and
numpy
.
fabs
(
inter
)
.
max
()
+
max_size
/
2
<
2
*
max_size
:
dist
=
inter
[
translate_axis
[
cutting_axis
]]
if
dist
is
not
None
:
dist
=
min
(
1.5
*
ref_size
,
max
(
-
0.5
*
ref_size
,
dist
))
return
dist
,
plane_width
,
plane_height
def
main
():
def
main
():
app
=
wx
.
App
(
redirect
=
False
)
app
=
wx
.
App
(
redirect
=
False
)
frame
=
wx
.
Frame
(
None
,
-
1
,
"GL Window"
,
size
=
(
400
,
400
))
frame
=
wx
.
Frame
(
None
,
-
1
,
"GL Window"
,
size
=
(
400
,
400
))
...
...
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