88function _get_pts_voxel (stl_model:: STLInfo3D , h:: Real , fill:: Bool )
99 # inputs check
1010 h > 0 || error (" h must be a positive number" )
11- step = h * 0.25
12- offsets = np. array ([- 1 1 1 ; - 1 1 - 1 ; 1 1 1 ; 1 1 - 1
13- - 1 - 1 1 ; - 1 - 1 - 1 ; 1 - 1 1 ; 1 - 1 - 1 ]) * step
14- py_all = pyslice (nothing , nothing , nothing )
11+ # step = h * 0.25
12+ # offsets = np.array([-1 1 1; -1 1 -1; 1 1 1; 1 1 -1
13+ # -1 -1 1; -1 -1 -1; 1 -1 1; 1 -1 -1]) * step
14+ # py_all = pyslice(nothing, nothing, nothing)
1515
1616 # convert to trimesh
1717 vertices = stl_model. py_vertices
@@ -23,17 +23,18 @@ function _get_pts_voxel(stl_model::STLInfo3D, h::Real, fill::Bool)
2323 pts_cen = filled_vox. points
2424
2525 if fill # filling mode
26- expanded = pts_cen[py_all, np. newaxis, py_all] + offsets[np. newaxis, py_all, py_all]
27- return PyArray (expanded. reshape (- 1 , 3 ))
26+ # expanded = pts_cen[py_all, np.newaxis, py_all] + offsets[np.newaxis, py_all, py_all]
27+ # PyArray(expanded.reshape(-1, 3))
28+ return filling_pts (PyArray (pts_cen), h)
2829 else
2930 return PyArray (pts_cen)
3031 end
3132end
3233
33- function _get_pts_ray (stl_model:: STLInfo3D , h:: Real , fill:: Bool , ϵ :: String )
34+ function _get_pts_ray (stl_model:: STLInfo3D , h:: Real , fill:: Bool )
3435 # inputs check
3536 h > 0 || error (" h must be a positive number" )
36- points, pts2 = prepareprojection (stl_model, h, ϵ )
37+ points, pts2 = prepareprojection (stl_model, h)
3738 @info " generating pts at h = $h "
3839 edges = projectionlist (stl_model, points)
3940 pts_cen = fill_particles (edges, pts2, h)
@@ -44,19 +45,19 @@ function _get_pts_ray(stl_model::STLInfo3D, h::Real, fill::Bool, ϵ::String)
4445 end
4546end
4647
47- function prepareprojection (stl_model:: STLInfo3D , h:: Real , ϵ )
48- T = ϵ == " FP32 " ? Float32 : Float64
48+ function prepareprojection (stl_model:: STLInfo3D , h:: Real )
49+ T = Float64
4950 pts2 = meshbuilder (stl_model. vmin[1 ]- 1.5 h : h : stl_model. vmax[1 ]+ 1.5 h,
50- stl_model. vmin[2 ]- 1.5 h : h : stl_model. vmax[2 ]+ 1.5 h, ϵ = ϵ )
51+ stl_model. vmin[2 ]- 1.5 h : h : stl_model. vmax[2 ]+ 1.5 h)
5152 vzlimit = T (stl_model. vmin[3 ] - 10 h)
52- points = vcat (pts2, vzlimit .* ones (T, 1 , size (pts2, 2 )))
53+ points = hcat (pts2, vzlimit .* ones (T, size (pts2, 1 )))
5354 return points, pts2
5455end
5556
5657function projectionlist (stl_model:: STLInfo3D , points:: AbstractArray{T} ) where T
5758 # inputs check
58- pts = points' ; n, m = size (pts)
59- m == 3 || error (" points must be a 3xN array" )
59+ pts = points; n, m = size (pts)
60+ m == 3 || error (" points must be a Nx3 array" )
6061
6162 mesh = stl_model. mesh
6263 pts = np. asarray (pts, dtype= np. float32)
@@ -88,7 +89,7 @@ function fill_particles(edges::AbstractArray, pts::AbstractMatrix{T}, h::Real) w
8889 @inbounds for i in eachindex (edges)
8990 v = edges[i]
9091 if ! isempty (v) && iseven (length (v)) && any (! iszero, v)
91- sort! (v); xi, yi = pts[1 , i ], pts[2 , i ]
92+ sort! (v); xi, yi = pts[i, 1 ], pts[i, 2 ]
9293 for j in 1 : 2 : (length (v) - 1 )
9394 for z in v[j]: h: v[j + 1 ]
9495 push! (x_all, xi)
@@ -98,9 +99,9 @@ function fill_particles(edges::AbstractArray, pts::AbstractMatrix{T}, h::Real) w
9899 end
99100 end
100101 end
101- xyz = Matrix {T} (undef, 3 , length (x_all))
102- xyz[1 , : ] .= x_all
103- xyz[2 , : ] .= y_all
104- xyz[3 , : ] .= z_all
102+ xyz = Matrix {T} (undef, length (x_all), 3 )
103+ xyz[:, 1 ] .= x_all
104+ xyz[:, 2 ] .= y_all
105+ xyz[:, 3 ] .= z_all
105106 return xyz
106107end
0 commit comments