Skip to content

Commit

Permalink
for instead of while
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas committed Jul 19, 2024
1 parent 24af5f8 commit 2c767de
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/preprocessing/shapes/triangle_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ struct TriangleMesh{NDIMS, ELTYPE}

# Since it's only sorted by the first entry, `v1` might be one of the following vertices
vertex_id1 = searchsortedfirst(vertices, v1 .- 1e-14)
while vertex_id1 < length(vertices) && !isapprox(vertices[vertex_id1], v1)
vertex_id1 += 1
@inbounds for vertex_id in eachindex(vertices)[vertex_id1:end]
if isapprox(vertices[vertex_id], v1)
vertex_id1 = vertex_id
break
end
end

# Since it's only sorted by the first entry, `v2` might be one of the following vertices
vertex_id2 = searchsortedfirst(vertices, v2 .- 1e-14)
while vertex_id2 < length(vertices) && !isapprox(vertices[vertex_id2], v2)
vertex_id2 += 1
@inbounds for vertex_id in eachindex(vertices)[vertex_id2:end]
if isapprox(vertices[vertex_id], v2)
vertex_id2 = vertex_id
break
end
end

# Since it's only sorted by the first entry, `v3` might be one of the following vertices
vertex_id3 = searchsortedfirst(vertices, v3 .- 1e-14)
while vertex_id3 < length(vertices) && !isapprox(vertices[vertex_id3], v3)
vertex_id3 += 1
@inbounds for vertex_id in eachindex(vertices)[vertex_id3:end]
if isapprox(vertices[vertex_id], v3)
vertex_id3 = vertex_id
break
end
end

face_vertices_ids[i] = (vertex_id1, vertex_id2, vertex_id3)
Expand Down

0 comments on commit 2c767de

Please sign in to comment.