contours.z <- -50:50
theta <- seq(0,2*pi, length.out = 100)
contours <- lapply(contours.z,function(z){
if (z<(-25)) return(data.frame(x = (50 + z) * cos(theta),
y = (50 + z) * sin(theta),
z = z))
if (z>25) return(data.frame(x = (50 - z) * cos(theta),
y = (50 - z) * sin(theta),
z = z))
return(data.frame(x = 25 * cos(theta),
y = 25 * sin(theta),
z = z))
})
contours <- contours[!sapply(contours, is.null)]
S <- struct.create(contours, roi.name="myshape",
roi.nb = 1,
roi.color = "#ff0000",
roi.type = "",
ref.pseudo = "ref1",
alias="", description = NULL)
display.3D.contour(S)
Run the code above in your browser using DataLab