CREATEGRIDMESH Creates a triangular/tetrahedral finite element mesh that consists of pixels/voxels


 DESCRIPTION:

       This function can be used to create a mesh compatible
       for pixel or voxel based input values. The structure of the mesh
       is given in the figure below and has the same idea as the
       native MATLAB function 'meshgrid'


       o-------o--------o
       |       |        |
       |   x   |   x    |
       |       |        |
       o-------o--------o
       |       |        |
       |   x   |   x    |
       |       |        |
       o-------o--------o

       o = mesh cooridinates
       x = grid point (locattion given by xvec, yvec)

       The mesh can be either 2d  (xvec, yvec given) or 3d.
       In 2d, the triangular mesh is constructed in the following fashion

       o--b3---o--b4---o
       | .  t6 | .  t8 |
       b2  .   |   .   b5
       | t2  . |t4   . |
       o-------o-------o
       | .  t5 | .  t7 |
       b1  .   |   .   b6
       | t1  . |t3   . |
       o---b8--o---b7--o

       t_i = triangle
       b_i = boundary segment

       The idea for the 3d mesh is the same. xvec, yvec and zvec
       depict the center location of each cube. Each cube contains 6
       tetrahedrons. The first tetrahedon is in the first cube, the
       second tetrahedron is in the second cube, in ascending
       y-x-z. The second tetrahedron of the first cube is the
       size(xvec)*size(yvec)*size(xvec)+1:th tetrahedron, the third
       tetrahedron of the first cube cube is the
       2*size(xvec)*size(yvec)*size(xvec)+1:th tetrahedron and so on

 USAGE:

       vmcmesh = createGridMesh(xvec, yvec);
       vmcmesh = createGridMesh(xvec, yvec);

 INPUT:

       xvec       - x coordinates for the center location of each pixel/cube
       yvec       - y coordinates for the center location of each pixel/cube

 OPTIONAL INPUT:

       zvec       - z coordinates for the center location of each pixel/cube 

 This function is provided with ValoMC