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
6cd53771
Commit
6cd53771
authored
Oct 10, 2021
by
Jayant Khatkar
Browse files
support x,y,z in inches but not automatically
parent
842b9f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
voxelise.py
View file @
6cd53771
...
...
@@ -18,7 +18,8 @@ def voxelised_csv(mesh_file_name,
voxels
=
''
,
skip_lines
=
4
,
voxel_dim
=
3
,
layer_height
=
1
layer_height
=
1
,
from_inches
=
False
):
"""
takes in input from solidworks csv and voxelises.
...
...
@@ -61,6 +62,8 @@ def voxelised_csv(mesh_file_name,
data
=
pd
.
read_csv
(
csv_fname
,
header
=
skip_lines
)
locs
=
data
.
iloc
[:,
1
:
4
].
to_numpy
()
if
from_inches
:
locs
=
locs
*
25.4
locs_pv
=
pv
.
PolyData
(
locs
)
if
'M3'
in
mesh_file_name
:
locs_pv
.
rotate_x
(
-
90
)
...
...
@@ -80,13 +83,15 @@ def voxelised_csv(mesh_file_name,
return
out
def
check_data
(
mesh_file_name
,
csv_fname
):
def
check_data
(
mesh_file_name
,
csv_fname
,
from_inches
=
False
):
mesh
=
pv
.
read
(
mesh_file_name
)
bed_centre
=
[
110
,
110
,
0
]
tu
.
transform_to_bed_centre
(
mesh
,
bed_centre
)
tu
.
transform_to_z0
(
mesh
)
data
=
pd
.
read_csv
(
csv_fname
,
header
=
4
)
locs
=
data
.
iloc
[:,
1
:
4
].
to_numpy
()
if
from_inches
:
locs
=
locs
*
25.4
locs_pv
=
pv
.
PolyData
(
locs
)
#locs_pv.rotate_x(-90) # M3
#locs_pv.rotate_x(90) # M5
...
...
@@ -110,9 +115,9 @@ def contour2dict(c):
if
__name__
==
'__main__'
:
obj
=
'models/M
5
'
#check_data(obj + '.stl', obj + '_raw.csv')
#out = voxelised_csv(obj + '.stl', obj + '_raw.csv', voxels=obj+'_vox_centers.csv')
obj
=
'models/M
8
'
#check_data(obj + '.stl', obj + '_raw.csv'
, from_inches=True
)
#out = voxelised_csv(obj + '.stl', obj + '_raw.csv', voxels=obj+'_vox_centers.csv'
, from_inches=True
)
#out.to_csv(obj + '_voxels.csv')
#visualise_voxels(obj + '_voxels.csv')
...
...
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