Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jayant Khatkar
tempaware
Commits
2166e877
Commit
2166e877
authored
Oct 08, 2021
by
Jayant Khatkar
Browse files
visualise individual voxels and contours passing through them
parent
e60aa5c7
Changes
3
Show whitespace changes
Inline
Side-by-side
main.jl
View file @
2166e877
...
...
@@ -18,11 +18,11 @@ tdfast = tempdecay(215, 25, 0.08)
### LOAD IN DATA
obj
=
"/Users/jayant/phd/tempaware/"
*
"M
1
"
obj
=
"/Users/jayant/phd/tempaware/
models/
"
*
"M
5
"
contours
=
clean_contour
.
(
contour
.
(
JSON
.
parse
(
open
(
obj
*
"contours.json"
))))
cdata
=
contourdata
(
contours
,
5
,
5
)
# contour data
cdata
=
contourdata
(
contours
,
20
,
5
)
# contour data
@time
vd
=
voxdata
(
obj
*
"_voxels.csv"
,
cdata
)
stress_multiplier!
(
vd
.
voxels
,
10
)
#
stress_multiplier!(vd.voxels, 10)
rl
=
random_rollout
(
cdata
)
### CONSTRUCT COST FUNCTION GIVEN MODEL ADN MATERIAL
...
...
@@ -70,7 +70,7 @@ end
# single local search
rl
=
random_rollout
(
cdata
)
cost_f
(
rl
)
max_iterations
=
1
0
max_iterations
=
5
0
@time
local_search!
(
rl
,
max_iterations
)
# run many times
...
...
@@ -96,3 +96,6 @@ data_strain = .√(vd.voxels.Txy.^2 + vd.voxels.Tyz.^2 + vd.voxels.Txz.^2)
data
=
data_stress
histogram
(
data
)
# vast majority of voxels near 0 stress - can ignore
histogram!
(
sort
(
data
,
rev
=
true
)[
1
:
4000
])
# vast majority of voxels near 0 stress - can ignore
### Visualise voxmap
plot
(
vd
,
35
,
cdata
)
\ No newline at end of file
utils.jl
View file @
2166e877
...
...
@@ -7,6 +7,7 @@ using Statistics
using
BenchmarkTools
using
Plots
using
LinearAlgebra
import
Plots
:
plot
,
plot!
struct
material
...
...
@@ -571,3 +572,22 @@ function construct_cost(cdata::contourdata, vd::voxdata, mat::material, td::temp
end
return
eval
(
a
)
end
function
plot
(
vd
::
voxdata
,
i
::
Int
,
cdata
::
contourdata
)
vm
=
vd
.
maps
[
i
]
loc
=
Array
(
vd
.
voxels
[
i
,
[
"x"
,
"y"
,
"z"
]])
w
=
vd
.
width
/
2
sq_x
=
[
loc
[
1
]
-
w
,
loc
[
1
]
-
w
,
loc
[
1
]
+
w
,
loc
[
1
]
+
w
,
loc
[
1
]
-
w
]
sq_y
=
[
loc
[
2
]
+
w
,
loc
[
2
]
-
w
,
loc
[
2
]
-
w
,
loc
[
2
]
+
w
,
loc
[
2
]
+
w
]
plt
=
plot
(
sq_x
,
sq_y
,
aspect_ratio
=:
equal
,
label
=
"Voxel"
,
lw
=
3
,
color
=
"black"
)
for
(
c
,
l
)
in
zip
(
vm
.
segcontours
,
vm
.
seglen
)
plot!
(
plt
,
cdata
.
contours
[
c
]
.
pos
[
:
,
1
],
cdata
.
contours
[
c
]
.
pos
[
:
,
2
],
label
=
l
)
end
plt
end
\ No newline at end of file
voxelise.py
View file @
2166e877
...
...
@@ -110,13 +110,13 @@ def contour2dict(c):
if
__name__
==
'__main__'
:
obj
=
'models/M
1
'
obj
=
'models/M
5
'
#check_data(obj + '.stl', obj + '_raw.csv')
out
=
voxelised_csv
(
obj
+
'.stl'
,
obj
+
'_raw.csv'
,
voxels
=
obj
+
'_vox_centers.csv'
)
out
.
to_csv
(
obj
+
'_voxels.csv'
)
visualise_voxels
(
obj
+
'_voxels.csv'
)
#
contours = gc.decode_gcode(obj + '.gcode')
#
outfile = open(obj + 'contours.json','w')
#
json.dump([contour2dict(c) for c in contours], outfile)
#
outfile.close()
#
out = voxelised_csv(obj + '.stl', obj + '_raw.csv', voxels=obj+'_vox_centers.csv')
#
out.to_csv(obj + '_voxels.csv')
#
visualise_voxels(obj + '_voxels.csv')
contours
=
gc
.
decode_gcode
(
obj
+
'.gcode'
)
outfile
=
open
(
obj
+
'contours.json'
,
'w'
)
json
.
dump
([
contour2dict
(
c
)
for
c
in
contours
],
outfile
)
outfile
.
close
()
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