A 3D multi-mode geometry-independent RMP optimization method and its application to TCV