I tried with having a Vector of abstract types. Like this:
abstract type AbstractPlacement{T<:AbstractFloat} end
#---Volume-------------------------------------------------------------------------
struct Volume{T<:AbstractFloat, S<:AbstractShape{T}, M<:AbstractMaterial}
label::String
shape::S # Reference to the actual shape
material::M # Reference to material
daughters::Vector{AbstractPlacement{T}}
end
#---PlacedVolume-------------------------------------------------------------------
struct PlacedVolume{T<:AbstractFloat,S<:AbstractShape{T}, M<:AbstractMaterial} <: AbstractPlacement{T}
transformation::Transformation3D{T}
volume::Volume{T,S,M}
end
Volume{T}(label::String, shape::S, material::M) where {T,S,M} = Volume{T,S,M}(label, shape, material, Vector{AbstractPlacement{T}}())
The performance is twice worst than what I had originally.