Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
Fix AxisymmetricOpticalSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
mattderstine committed Nov 24, 2021
1 parent b66f2e5 commit b7277e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/AsphericSurface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct AsphericSurface{T,N,Q,M} <: ParametricSurface{T,N}
@assert one(T) - (1 / radius)^2 * (conic + one(T)) * semidiameter^2 > 0 "Invalid surface (conic/radius combination: $radius, $conic)"

acs = []
if aspherics===nothing || aspherics == [] #AxisymmetricOpticalSystem sends a null array
if aspherics===nothing #|| aspherics == [] #AxisymmetricOpticalSystem sends a null array
M = CONIC
else
asphericTerms = [i for (i, ) in aspherics]
Expand Down
23 changes: 17 additions & 6 deletions src/Optical/OpticalSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ function get_front_back_property(prescription::DataFrame, rownum::Int, property:
return replace(properties, missing => default)
end

turnEmptyIntoNothing(list) = length(list)==0 ? Nothing : list

"""
AxisymmetricOpticalSystem{T,C<:CSGOpticalSystem{T}} <: AbstractOpticalSystem{T}
Expand Down Expand Up @@ -374,12 +376,21 @@ struct AxisymmetricOpticalSystem{T,C<:CSGOpticalSystem{T}} <: AbstractOpticalSys
frontaspherics::Vector{Pair{Int,T}}, backaspherics::Vector{Pair{Int,T}} = [
[parse(Int, k) => v for (k, v) in params] for params in [frontparams, backparams]
]

newelement = AsphericLens(
material, vertices[i-1], frontradius, frontconic, frontaspherics, backradius, backconic,
backaspherics, thickness, semidiameter; lastmaterial, nextmaterial, frontsurfacereflectance,
backsurfacereflectance
)()

fa = turnEmptyIntoNothing(frontaspherics)
ba = turnEmptyIntoNothing(backaspherics)
if fa === nothing && ba === nothing #it should be a CONIC. Note: if aspheric terms are present but all zero then an AshpericLens will be created
newelement = ConicLens(
material, vertices[i-1], frontradius, frontconic, backradius, backconic, thickness,
semidiameter; lastmaterial, nextmaterial, frontsurfacereflectance, backsurfacereflectance
)()
else
newelement = AsphericLens(
material, vertices[i-1], frontradius, frontconic, fa, backradius, backconic,
ba, thickness, semidiameter; lastmaterial, nextmaterial, frontsurfacereflectance,
backsurfacereflectance
)()
end
else
error(
"Unsupported surface type \"$surface_type\". If you'd like to add support for this surface, ",
Expand Down

0 comments on commit b7277e3

Please sign in to comment.