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
b4793bd7
Commit
b4793bd7
authored
Mar 30, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial attempt at progressively loading 3D visualization #423
parent
510f85cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
actors.py
printrun/gl/libtatlin/actors.py
+33
-14
No files found.
printrun/gl/libtatlin/actors.py
View file @
b4793bd7
...
@@ -676,14 +676,21 @@ class GcodeModelLight(Model):
...
@@ -676,14 +676,21 @@ class GcodeModelLight(Model):
def
load_data
(
self
,
model_data
,
callback
=
None
):
def
load_data
(
self
,
model_data
,
callback
=
None
):
t_start
=
time
.
time
()
t_start
=
time
.
time
()
vertex_list
=
[]
color_list
=
[]
self
.
layer_idxs_map
=
{}
self
.
layer_idxs_map
=
{}
self
.
layer_stops
=
[
0
]
self
.
layer_stops
=
[
0
]
prev_pos
=
(
0
,
0
,
0
)
prev_pos
=
(
0
,
0
,
0
)
layer_idx
=
0
layer_idx
=
0
vertices
=
self
.
vertices
=
numpy
.
zeros
(
len
(
model_data
)
*
6
,
dtype
=
GLfloat
)
vertex_k
=
0
colors
=
self
.
colors
=
numpy
.
zeros
(
len
(
model_data
)
*
8
,
dtype
=
GLfloat
)
color_k
=
0
self
.
printed_until
=
-
1
self
.
only_current
=
False
while
layer_idx
<
len
(
model_data
.
all_layers
):
while
layer_idx
<
len
(
model_data
.
all_layers
):
if
len
(
model_data
)
*
6
!=
vertices
.
size
:
self
.
vertices
.
resize
(
len
(
model_data
)
*
6
,
refcheck
=
False
)
self
.
colors
.
resize
(
len
(
model_data
)
*
8
,
refcheck
=
False
)
layer
=
model_data
.
all_layers
[
layer_idx
]
layer
=
model_data
.
all_layers
[
layer_idx
]
has_movement
=
False
has_movement
=
False
for
gline
in
layer
:
for
gline
in
layer
:
...
@@ -692,19 +699,36 @@ class GcodeModelLight(Model):
...
@@ -692,19 +699,36 @@ class GcodeModelLight(Model):
if
gline
.
x
is
None
and
gline
.
y
is
None
and
gline
.
z
is
None
:
if
gline
.
x
is
None
and
gline
.
y
is
None
and
gline
.
z
is
None
:
continue
continue
has_movement
=
True
has_movement
=
True
vertex_list
.
extend
(
prev_pos
)
vertices
[
vertex_k
]
=
prev_pos
[
0
]
vertices
[
vertex_k
+
1
]
=
prev_pos
[
1
]
vertices
[
vertex_k
+
2
]
=
prev_pos
[
2
]
current_pos
=
(
gline
.
current_x
,
gline
.
current_y
,
gline
.
current_z
)
current_pos
=
(
gline
.
current_x
,
gline
.
current_y
,
gline
.
current_z
)
vertex_list
.
extend
(
current_pos
)
vertices
[
vertex_k
+
3
]
=
current_pos
[
0
]
vertices
[
vertex_k
+
4
]
=
current_pos
[
1
]
vertices
[
vertex_k
+
5
]
=
current_pos
[
2
]
vertex_k
+=
6
vertex_color
=
self
.
movement_color
(
gline
)
vertex_color
=
self
.
movement_color
(
gline
)
color_list
.
extend
(
vertex_color
+
vertex_color
)
colors
[
color_k
]
=
vertex_color
[
0
]
colors
[
color_k
+
1
]
=
vertex_color
[
1
]
colors
[
color_k
+
2
]
=
vertex_color
[
2
]
colors
[
color_k
+
3
]
=
vertex_color
[
3
]
colors
[
color_k
+
4
]
=
vertex_color
[
0
]
colors
[
color_k
+
5
]
=
vertex_color
[
1
]
colors
[
color_k
+
6
]
=
vertex_color
[
2
]
colors
[
color_k
+
7
]
=
vertex_color
[
3
]
color_k
+=
8
prev_pos
=
current_pos
prev_pos
=
current_pos
gline
.
gcview_end_vertex
=
len
(
vertex_list
)
/
3
gline
.
gcview_end_vertex
=
vertex_k
/
3
if
has_movement
:
if
has_movement
:
self
.
layer_stops
.
append
(
len
(
vertex_list
)
/
3
)
self
.
layer_stops
.
append
(
vertex_k
/
3
)
self
.
layer_idxs_map
[
layer_idx
]
=
len
(
self
.
layer_stops
)
-
1
self
.
layer_idxs_map
[
layer_idx
]
=
len
(
self
.
layer_stops
)
-
1
self
.
max_layers
=
len
(
self
.
layer_stops
)
-
1
self
.
num_layers_to_draw
=
self
.
max_layers
+
1
self
.
initialized
=
False
self
.
loaded
=
True
if
callback
:
if
callback
:
callback
(
layer_idx
+
1
)
callback
(
layer_idx
+
1
)
...
@@ -716,15 +740,10 @@ class GcodeModelLight(Model):
...
@@ -716,15 +740,10 @@ class GcodeModelLight(Model):
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
self
.
vertices
=
numpy
.
fromiter
(
vertex_list
,
dtype
=
GLfloat
,
self
.
vertices
.
resize
(
vertex_k
,
refcheck
=
False
)
count
=
len
(
vertex_list
))
self
.
colors
.
resize
(
color_k
,
refcheck
=
False
)
self
.
colors
=
numpy
.
fromiter
(
color_list
,
dtype
=
GLfloat
,
count
=
len
(
color_list
))
self
.
max_layers
=
len
(
self
.
layer_stops
)
-
1
self
.
max_layers
=
len
(
self
.
layer_stops
)
-
1
self
.
num_layers_to_draw
=
self
.
max_layers
+
1
self
.
num_layers_to_draw
=
self
.
max_layers
+
1
self
.
printed_until
=
-
1
self
.
only_current
=
False
self
.
initialized
=
False
self
.
initialized
=
False
self
.
loaded
=
True
self
.
loaded
=
True
...
...
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