Commit 2166e877 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

visualise individual voxels and contours passing through them

parent e60aa5c7
......@@ -18,11 +18,11 @@ tdfast = tempdecay(215, 25, 0.08)
### LOAD IN DATA
obj = "/Users/jayant/phd/tempaware/" * "M1"
obj = "/Users/jayant/phd/tempaware/models/" * "M5"
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 = 10
max_iterations = 50
@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
......@@ -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
......@@ -110,13 +110,13 @@ def contour2dict(c):
if __name__ == '__main__':
obj = 'models/M1'
obj = 'models/M5'
#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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment