Commit 08c00bc6 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Change order of arguments and check number of ref. positions

parent d54b7e10
......@@ -70,20 +70,20 @@ struct ShackHartmannSensor{T,
S<:AbstractWavefrontSensorMeasure{T},
A<:AbstractWavefrontSensorAlgorithm{S},
C<:AbstractCamera{T}} <: AbstractWavefrontSensor{S}
alg::A # wavefront sensor algorithm
geom::ShackHartmannGeometry
cam::C # image provider connected to the wavefront sensor camera
alg::A # wavefront sensor algorithm
ref::Vector{Point{T}} # WFS reference positions
geom::ShackHartmannGeometry
# To avoid (re)allocations, the wavefront sensor measurements are stored in
# an array that is owned by the wavefront sensor object (much like the
# image provider which caches the pre-processed image and its weights).
meas::Vector{S} # cached measurements
function ShackHartmannSensor{T,S,A,C}(alg::A,
function ShackHartmannSensor{T,S,A,C}(geom::ShackHartmannGeometry,
cam::C,
ref::AbstractVector{Point{<:Real}},
geom::ShackHartmannGeometry,
alg::A,
ref::AbstractVector{<:Point{<:Real}},
meas::AbstractVector{S}) where {
T,
S<:AbstractWavefrontSensorMeasure{T},
......@@ -91,21 +91,24 @@ struct ShackHartmannSensor{T,
C<:AbstractCamera{T}
}
# Minimal check to make sure that indices are not out of bounds.
length(meas) == length(geom) || error("invalid number of measurements")
new{T,S,A,C}(alg, cam, ref, geom, meas)
len = length(geom)
length(ref) == len || error("invalid number of reference positions")
length(meas) == len || error("invalid number of measurements")
new{T,S,A,C}(geom, cam, alg, ref, meas)
end
end
# Constructors.
function ShackHartmannSensor(alg::A,
function ShackHartmannSensor(geom::ShackHartmannGeometry,
cam::C,
ref::AbstractVector{Point{<:Real}},
geom::ShackHartmannGeometry) where {
alg::A,
ref::AbstractVector{<:Point{<:Real}}) where {
T<:AbstractFloat,
S<:AbstractWavefrontSensorMeasure{T},
A<:AbstractWavefrontSensorAlgorithm{S},
C<:AbstractCamera{T}}
ShackHartmannSensor{T,S,A,C}(alg, cam, ref, geom, Vector{S}(undef, cnt))
ShackHartmannSensor{T,S,A,C}(geom, cam, alg, ref,
Vector{S}(undef, length(ref)))
end
# Implement API of a wavefront-sensor.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment