added 3d version and fixed c++ mesh size