I have finished the implementation of the algorithm to remove the redundant vertices :
@Override
protected final boolean performTaskOnCurrentlyVisitedCell(){
Full3DCell cell=getCurrentlyVisitedCell();
ArrayList<List<float[]>> wallsVerticesListList=new ArrayList<List<float[]>>();
wallsVerticesListList.add(cell.getBottomWalls());
wallsVerticesListList.add(cell.getCeilWalls());
wallsVerticesListList.add(cell.getFloorWalls());
wallsVerticesListList.add(cell.getLeftWalls());
wallsVerticesListList.add(cell.getRightWalls());
wallsVerticesListList.add(cell.getTopWalls());
//create the both tables
LinkedHashMap<Integer,Integer> duplicateToUniqueIndexationTable=new LinkedHashMap<Integer,Integer>();
LinkedHashMap<VertexData,Integer> vertexDataToUniqueIndexationTable=new LinkedHashMap<VertexData,Integer>();
//local variables used in the loop
int portalVertexIndex,currentPortalVertexIndex,uniqueVertexIndex;
int uniqueVerticesIndicesCount=0;
int duplicateVerticesIndicesCount=0;
Integer knownUniqueVertexIndex;
Full3DCell neighborCell;
Map.Entry<LinkedHashMap<Integer,Integer>,LinkedHashMap<VertexData,Integer>> neighborCellEntry;
LinkedHashMap<VertexData,Integer> neighBorVertexDataToUniqueIndexationTable;
//for each vertex
for(List<float[]> wallsVerticesList:wallsVerticesListList)
for(float[] wallVertex:wallsVerticesList)
{currentPortalVertexIndex=0;
//-1 is used to know that no vertex equal with this
//vertex of wall has been found
portalVertexIndex=-1;
//look for this vertex in the vertices contained in the portals
for(float[] portalVertex:cell.getNeighboursPortalsList())
{//remind: T2_V3 (2 texture coordinates + 3 vertex coordinates)
if(portalVertex[2]==wallVertex[2]&&portalVertex[3]==wallVertex[3]&&portalVertex[4]==wallVertex[4])
{portalVertexIndex=currentPortalVertexIndex;
break;
}
currentPortalVertexIndex++;
}
//if the vertex is in a portal
if(portalVertexIndex!=-1)
{//get the cell that is linked to this portal
neighborCell=cell.getNeighboursCellsList().get(portalVertexIndex/4);
//use the table of cellular maps to get the tables of the neighbor cell if any
neighborCellEntry=cellularMapsTable.get(neighborCell);
//if these tables exist
if(neighborCellEntry!=null)
{//get the second table of the neighbor cell
neighBorVertexDataToUniqueIndexationTable=neighborCellEntry.getValue();
//get the unique index by using this second table
knownUniqueVertexIndex=neighBorVertexDataToUniqueIndexationTable.get(new VertexData(wallVertex));
//store the unique index
uniqueVertexIndex=knownUniqueVertexIndex.intValue();
}
//else (in this case, the neighbor cell has not yet been visited)
else
{//compute and store this new unique index
uniqueVertexIndex=uniqueVerticesIndicesCount;
//increment it in order to ensure the attributed value is really unique
uniqueVerticesIndicesCount++;
//put it into the second table
vertexDataToUniqueIndexationTable.put(new VertexData(wallVertex),Integer.valueOf(uniqueVertexIndex));
}
}
//else
else
{//if the second table already contains this vertex
if((knownUniqueVertexIndex=vertexDataToUniqueIndexationTable.get(new VertexData(wallVertex)))!=null)
{//store the unique index
uniqueVertexIndex=knownUniqueVertexIndex.intValue();
}
//else
else
{//compute and store this new unique index
uniqueVertexIndex=uniqueVerticesIndicesCount;
//increment it in order to ensure the attributed value is really unique
uniqueVerticesIndicesCount++;
//put it into the second table
vertexDataToUniqueIndexationTable.put(new VertexData(wallVertex),Integer.valueOf(uniqueVertexIndex));
}
}
//fill the first table with the new duplicate index and the unique index
duplicateToUniqueIndexationTable.put(Integer.valueOf(duplicateVerticesIndicesCount),Integer.valueOf(uniqueVertexIndex));
//update the count of duplicate vertices
duplicateVerticesIndicesCount++;
}
//put the both tables in the table of cellular maps
cellularMapsTable.put(cell,new SimpleEntry<LinkedHashMap<Integer,Integer>,LinkedHashMap<VertexData,Integer>>(duplicateToUniqueIndexationTable,vertexDataToUniqueIndexationTable));
//go on visiting the network
return(true);
}
Watch the class tools.NetworkSet if you want to see the whole inner class. I need to implement something more simple for the texture coordinates as I said.