How to connect triangles in a Trimesh? (set index)

Hi! I need a little help here…

This function returns a TriMesh. After a polygon be divided in triangles (VTK), it tries do create a Trimesh be connecting these triangles. What I need is a way to set the index of the Trimesh.

Now, the index is this way: (0,1,2), (3,4,5), … The visualisation has some holes and the triangles are not very well connected.

    public TriMesh getJMEOutput(String name) throws Problem {       
       if (polyData == null) return null;
       int total = 3 * polyData.GetNumberOfCells();
       Vector3f[] verts = new Vector3f[total];
        Vector3f[] normalsT = new Vector3f[total];
       int index[] = new int[total];         
       double coords[] = new double[3];
       vtkCell tri;
       int count = 0;
       for (int i=0; i< polyData.GetNumberOfCells();i++) {
          try {
             tri = (vtkCell)polyData.GetCell(i);
          catch (Exception ex) {
             throw new Problem("Only triangles can be used as results! Use triangulate if necessary.");              
          vtkPoints points = tri.GetPoints();
          Vector3f[] vertN = new Vector3f[3];
          for (int j=0; j < 3; j++) {
              points.GetPoint(j, coords);
              verts[count]= new Vector3f((float)coords[0], (float)coords[1], (float)coords[2]);
              vertN[j]= new Vector3f((float)coords[0], (float)coords[1], (float)coords[2]);

                       index [count] = count;  /*here.. how to set the index..?*/                                         

           * Normal attribution
          Vector3f normT = calcNormal(vertN);
                for (int l = (count-3); l < count; l++) {
                  normalsT[l] = normT;
       if (name == null) name = "mesh" + newObjectId();

       TriMesh mesh = new TriMesh(name);

       return mesh;