diff options
author | Thomas White <taw@physics.org> | 2023-11-06 15:47:55 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | 92c95e86a747c661d755431a258bdecf25f819fd (patch) | |
tree | 95e16ed6101db7543dfc42661d778ab15794d45e | |
parent | 79304d62e3fc25ceae0268cf4e293fafd1b5a2b5 (diff) |
Julia: RefList: basic subscripting
-rw-r--r-- | julia/CrystFEL/src/reflists.jl | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/julia/CrystFEL/src/reflists.jl b/julia/CrystFEL/src/reflists.jl index 0ac1e1f5..7905416d 100644 --- a/julia/CrystFEL/src/reflists.jl +++ b/julia/CrystFEL/src/reflists.jl @@ -13,15 +13,15 @@ mutable struct InternalReflection end mutable struct InternalRefListIterator end # The Julian exposed types -mutable struct RefList - internalptr::Ptr{InternalRefList} - symmetry::SymOpList -end - mutable struct Reflection internalptr::Ptr{InternalReflection} end +mutable struct RefList <: AbstractArray{Reflection, 3} + internalptr::Ptr{InternalRefList} + symmetry::SymOpList +end + mutable struct RefListIterator reflist::RefList lastrefl::Ptr{InternalReflection} @@ -79,10 +79,25 @@ end Base.IteratorEltype(::RefListIterator) = Reflection - Base.isdone(iter::RefListIterator) = ((iter.internalptr == C_NULL) && (iter.lastrefl != C_NULL)) +IndexStyle(::RefList) = IndexCartesian() + +function Base.getindex(reflist::RefList, h, k, l) + + refl = ccall((:find_refl, libcrystfel), + Ptr{InternalReflection}, (Ptr{InternalRefList},Cint,Cint,Cint), + reflist.internalptr, h, k, l) + + if refl == C_NULL + return nothing + else + return Reflection(refl) + end +end + + function loadreflist(filename::AbstractString) psym = Ref{Cstring}() |