Skip to content
Snippets Groups Projects
Commit 0b93088e authored by Stephan Hilb's avatar Stephan Hilb
Browse files

fix inconsistent triangle inside check

parent 3cbc9488
No related branches found
No related tags found
No related merge requests found
......@@ -340,18 +340,19 @@ function _sample(f::FeFunction)
A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}(
view(mesh.vertices, :, view(mesh.cells, :, cell)))
# TODO: cleanup when minimum/maximum on StaticArrays becomes
# TODO: cleanup when minimum/maximum with dims on StaticArrays becomes
# type-stable
I0 = round.(Int, SVector(minimum(A[1, :]), minimum(A[2, :])) .- m0)
I1 = round.(Int, SVector(maximum(A[1, :]), maximum(A[2, :])) .- m0)
I0 = round.(Int, SVector(minimum(A[1, :]), minimum(A[2, :])) .- m0) .+ 1
I1 = round.(Int, SVector(maximum(A[1, :]), maximum(A[2, :])) .- m0) .+ 1
for I in CartesianIndex(I0[1], I0[2]):CartesianIndex(I1[1], I1[2])
x = SVector(Tuple(I) .+ m0)
x = SVector(Tuple(I) .- m0)
# TODO: move to global-to-local function or inside-triangle test
xloc = (A[:, SUnitRange(2, 3)] .- A[:, 1])::SArray \
(x .- A[:, 1])
if all(xloc .>= 0) && sum(xloc) <= 1
out[fcolon..., I + CartesianIndex(1, 1)] .= evaluate(f, xloc)
ε = eps()
if all(xloc .>= -ε) && sum(xloc) <= 1 + ε
out[fcolon..., I] .= evaluate(f, xloc)
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment