With Armin Meiwes it was argued that the victim couldn't consent to being killed because he wasn't mentally sound. And he wasn't mentally sound because he consented to being killed.
I could imagine that if you could convince a court that you are mentally sound beforehand, you could have someone legally murder you.
The whole eating thing is actually treated somewhat separately because that falls under disturbing the dead