Skip to content

Commit

Permalink
Code tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandeep committed Nov 19, 2019
1 parent c197665 commit c528c68
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ os:
- osx
julia:
- 1.0
- 1.1
- 1.2
- nightly
notifications:
email: false
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.1
- julia_version: 1.2
- julia_version: nightly

platform:
Expand Down
9 changes: 4 additions & 5 deletions src/sparse_voxels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SparseVoxelGrid(points::Vector{T1}, voxel_size::SVector{3, T2}) where {
# In order to avoid allocating a vector for each voxel, we construct the data structure in a backward-looking order.

# Assign each point to a voxel id
voxel_ids = Vector{VoxelId}(undef,npoints)
voxel_ids = Vector{VoxelId}(undef, npoints)
for j = 1:npoints
@inbounds voxel_ids[j] = make_voxel_id(points[j], voxel_size)
end
Expand All @@ -66,7 +66,7 @@ function SparseVoxelGrid(points::Vector{T1}, voxel_size::SVector{3, T2}) where {
end

# Place indices for points into the appropriate index range for the associated voxel
point_indices = Vector{Int}(undef,npoints)
point_indices = Vector{Int}(undef, npoints)
for j = 1:npoints
id = voxel_ids[j]
index_in_group = group_counts[id]
Expand All @@ -79,7 +79,7 @@ end
function SparseVoxelGrid(points::Matrix{T1}, voxel_size) where T1 <: Real
ndims, npoints = size(points)
@assert ndims == 3
new_data = reshape(reinterpret(SVector{3,T1}, vec(points)),(length(points) ÷ 3, ))
new_data = reshape(reinterpret(SVector{3, T1}, vec(points)), (length(points) ÷ 3, ))
SparseVoxelGrid(new_data[1:end], get_voxel_size(voxel_size))
end

Expand All @@ -104,7 +104,7 @@ end

"""
make_voxel_id(point::AbstractVector, voxel_size::SVector{3,AbstractFloat})
=(v.voxel_info)
Create the voxel id for a given point and voxel size.
"""
@inline function make_voxel_id(point::AbstractVector, voxel_size::SVector{3, T}) where T <: Real
Expand All @@ -129,7 +129,6 @@ end

Base.eltype(::SparseVoxelGrid) = Voxel


function Base.getindex(grid::SparseVoxelGrid, id::VoxelId)
Voxel(id, grid.voxel_info[id], grid.point_indices)
end
Expand Down

0 comments on commit c528c68

Please sign in to comment.