Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type instability in Torus constructor #287

Open
lmh91 opened this issue May 6, 2022 · 0 comments
Open

Type instability in Torus constructor #287

lmh91 opened this issue May 6, 2022 · 0 comments

Comments

@lmh91
Copy link
Collaborator

lmh91 commented May 6, 2022

This came up in #285.

The construction of a Torus is not entirely type stable as some parametric types of Torus
depend on the values and not the types of the input arguments to the constructor:

@inferred CSG.Torus{Float64}=π,θ=(π,2π)) # -> error

The parametric types which cause the issue are TT1 and TT2 of the Torus: https://github.com/SebastianRuffert/SolidStateDetectors.jl/blob/de2af27789cf8883f74ad0599acc60fc11aadd9a/src/ConstructiveSolidGeometry/VolumePrimitives/Torus.jl#L69.
These define the types of two surfaces of the Torus. If we just remove TT1 and TT2 from the Torus we would shift the type instability into the function surfaces(t::Torus).

I think the best solution would be if we would came up with a way to remove the :inwards and :outwards parametric types of (all) surface primitives. Maybe by defining some field to those structs which only hold +1 or -1 in order to define the direction of surfaces like for the ConeMantle or TorusMantle.

However, we would still have the issue of the :flat case for the Torus.
Here, one (or two) of the surfaces of the Torus become not a ConeMantle but an
EllipticalSurface: see TorusThetaSurface.
We would need to come up with a way to define these "flat" surfaces still as ConeMantle. In its current implementation of ConeMantle, this is not possible as hZ would be 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant