This repository was archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from JuliaGeometry/sjk/getindex
Improve codegen for getindex(::Array, ::Face)
- Loading branch information
Showing
6 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Check the `Face` indices to ensure they are in the bounds of the vertex | ||
array of the `AbstractMesh`. | ||
""" | ||
function Base.checkbounds{VT,FT,FD,FO}(m::AbstractMesh{VT,Face{FD,FT,FO}}) | ||
isempty(faces(m)) && return true # nothing to worry about I guess | ||
|
||
# index max and min | ||
const i = one(FO) + FO # normalize face offset | ||
s = length(vertices(m)) + FO | ||
|
||
for face in faces(m) | ||
# I hope this is unrolled | ||
for elt in face | ||
i <= elt && elt <= s || return false | ||
end | ||
end | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
context("faces") do | ||
a = [1,2,3,4] | ||
@fact a[Face{3,Int,0}(1,2,3)] --> (1,2,3) | ||
@fact a[Face{3,Int,-1}(0,1,2)] --> (1,2,3) | ||
@fact a[Face{3,Int,1}(2,3,4)] --> (1,2,3) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters