Index: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h	(revision 2127)
@@ -90,7 +90,4 @@
 			void	JoinVertices(Mesh *mesh);
 
-			MeshSimplificationSequence *
-				WriteRealSimpSeq(MeshSimplificationSequence *simpseq);
-
 			Mesh	*GetMesh();
 	};
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/buffers.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/buffers.h	(revision 2127)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/buffers.h	(revision 2127)
@@ -0,0 +1,46 @@
+#ifndef __interleave_h_
+#define __interleave_h_
+
+#include "GL/glut.h"
+
+#include "color.h"
+#include "mesh.h"
+#include "change.h"
+
+namespace	VMI
+{
+
+typedef struct _VertexIL {
+    float tx, ty;       // texture coordinates
+    GLubyte r, g, b, a; // color
+    float x, y, z;      // position coordinates
+} VertexIL;
+
+typedef struct _Vertex_{
+    float x, y, z;    // position
+} Vertex_;
+
+extern GLuint vertex_buf, color_buf;
+
+extern Vertex_ *buf_vertices;
+extern Color   *buf_colors;
+
+extern Vertex_ *pbuf_vertices;
+extern Color   *pbuf_colors;
+
+extern void saveVertexBuffer(Change *c, VertexIL *dest);
+extern void loadVertexBuffer(VertexIL *src, Change *c);
+
+extern VertexIL *setupInterleave(Mesh *mesh, Color *colors);
+extern void setupVertexArray(Mesh *mesh, Color *colors);
+extern void updateVertexArray(Mesh *mesh, Change *c);
+extern void setupVertexBufferObjects(Mesh *mesh, Color *colors);
+extern void updateVertexBufferObjects(Mesh *mesh, Change *c);
+extern void printInterleave(VertexIL *interleave, int num);
+extern void updateAllColorInterleave(VertexIL *interleave, int num, Color *colors);
+extern void updateColorInterleave(VertexIL *interleave, int num, Color *colors, int begin, int end);
+extern void fillColorInterleave(VertexIL *interleave, int num, int begin, int end, GLubyte color);
+
+}
+
+#endif
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h	(revision 2127)
@@ -7,7 +7,9 @@
 
 typedef struct _Vertex {
-    GLfloat x, y, z;     // Vertex coordinates
-    GLuint numTriangles; // Number of triangles 
-    GLuint *triangles;   // List of triangles
+    float x, y, z;     // Vertex coordinates
+    int numTriangles; // Number of triangles 
+    int *triangles;   // List of triangles
+		int numEdges;
+	  int *edges;
     int enable;
 		int	movable;	//	If vertex is part of a border.
@@ -15,19 +17,16 @@
 
 typedef struct _Edge {
-    GLuint u, v;         // Edge vertices
-    GLuint *triangles;   // Edge triangles
-    GLuint numTriangles; // Number of triangles
+    int u, v;         // Edge vertices
     int enable;
 } Edge;
 
 typedef struct _Triangle {
-    GLuint		id;         // Triangle id
-    GLuint  group;        // Triangle group
-		GLuint		submesh;		// Triangle submesh	
-    GLuint		indices[3]; // Triangle vertices
-    GLuint		edges[3];   // Triangle edges
-    GLfloat		normal[3];  // Triangle normal
-    GLdouble	area;       // Triangle area
-    GLdouble	saliency;   // Triangle saliency
+    int		id;         // Triangle id
+    int  group;        // Triangle group
+		int		submesh;		// Triangle submesh	
+    int		indices[3]; // Triangle vertices
+    float		normal[3];  // Triangle normal
+    double	area;       // Triangle area
+    double	saliency;   // Triangle saliency
     int				enable;
 } Triangle;
@@ -35,20 +34,22 @@
 typedef struct _Mesh {
     Vertex *vertices;           // Mesh vertices
-    GLuint numVertices;         // Number of vertices
-    GLuint currentNumVertices;  // Current number of vertices
+    int numVertices;         // Number of vertices
+    int currentNumVertices;  // Current number of vertices
     Edge *edges;                // Mesh edges
-    GLuint numEdges;            // Number of edges
+    int numEdges;            // Number of edges
     Triangle *triangles;        // Mesh triangles
-    GLuint numTriangles;        // Number of triangles
-    GLuint currentNumTriangles; // Current number of triangles
+    int numTriangles;        // Number of triangles
+    int currentNumTriangles; // Current number of triangles
 } Mesh;
 
 extern GLdouble computeTriangleArea(Vertex *vertices, Triangle *t);
+extern double computeEdgeLength(Vertex *vertices, int u, int v);
 extern void computeTriangleNormal(Vertex *vertices, Triangle *t);
+extern double computeTriangleVolume(Vertex *vertices, Triangle *t);
 
 extern Vertex *addVertex(Vertex *list, int *n, float x, float y, float z, int *pos);
-extern int findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v);
+extern int findEdge(Edge *e, int num, int _u, int _v);
 extern Edge *addEdge(Edge *list, int *n, int u, int v, int *pos);
-extern GLboolean findVertex(GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos);
+extern GLboolean findVertex(float *vertices, int num, float x, float y, float z, int *pos);
 
 extern Mesh *initMesh(GLMmodel* pmodel);
@@ -56,9 +57,8 @@
 extern void printMesh(Mesh *mesh);
 extern void saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh);
-extern void updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles);
+extern void updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles);
 
 extern int *trianglesAdjToEdge(Mesh *mesh, int e, int *n);
 extern int *verticesAdjToVertex(Mesh *mesh, int v, int *n);
-extern int *edgesAdjToVertex(Mesh *mesh, int v, int *n);
 extern int *edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n);
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/simplify.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/simplify.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/simplify.h	(revision 2127)
@@ -19,9 +19,8 @@
 	extern bheap_t *updateHeap(bheap_t *h, Mesh *mesh, Change *c);
 
-	extern void simplifyModel(Mesh *mesh, GLuint numDemandedTri);
+	extern void simplifyModel(Mesh *mesh, int numDemandedTri);
 
 
 	extern void bh_mydump(Mesh *mesh, bheap_t *h);
-	extern GLdouble computeEdgeLength(Vertex *vertices, int u, int v);
 
 	extern void chooseBestEndPoints(Mesh *mesh, int e);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/histogram.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/histogram.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/histogram.h	(revision 2127)
@@ -11,17 +11,17 @@
 {
 
-extern void getSubHistogram(GLuint subHistoGram[][4]);
-extern void copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]);
-extern void printHistogram(GLuint histoGram[][4]);
-extern void plotHistogram(GLuint histoGram[][4]);
+extern void getSubHistogram(int subHistoGram[][4]);
+extern void copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]);
+extern void printHistogram(int histoGram[][4]);
+extern void plotHistogram(int histoGram[][4]);
 
-extern GLuint **initHistogram(GLuint numTriangles, GLuint numCameras);
-extern void deleteHistogram(GLuint **histogram, GLuint numCameras);
-extern void printFullHistogram(GLuint **histogram, GLuint numCameras, GLuint numTriangles);
-extern void getSWHistogram(GLuint *histogram, GLubyte *pixels);
-extern void getSWHistogramWin(GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c);
-extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram);
+extern int **initHistogram(int numTriangles, int numCameras);
+extern void deleteHistogram(int **histogram, int numCameras);
+extern void printFullHistogram(int **histogram, int numCameras, int numTriangles);
+extern void getSWHistogram(int *histogram, GLubyte *pixels);
+extern void getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c);
+extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram);
 
-extern void resetSWHistogram(GLuint *histogram, GLuint numTriangles);
+extern void resetSWHistogram(int *histogram, int numTriangles);
 extern void getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]);
 extern void getWindow(GLfloat min[3], GLfloat max[3], int minw[2], int maxw[2]);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h	(revision 2127)
@@ -60,4 +60,6 @@
 //#define SALIENCY
 
+#define CHECK_LOCAL_INVERSION
+
 // Extension added into the filename
 #ifdef KL // Kullback-Leibler
@@ -73,6 +75,4 @@
 #define EXT "VCS"
 #endif
-
-//#define USE_EDGE_ADJACENCY
 
 #define CHECK_OPENGL_ERROR( cmd ) \
@@ -109,10 +109,10 @@
 
 extern Camera *cameras;
-extern GLuint numCameras;
+extern int numCameras;
 
 extern Color *colors;
 
-extern GLuint **histogram,
-               *queries;
+extern int **histogram;
+extern GLuint *queries;
 
 extern Mesh *mesh;
@@ -122,5 +122,5 @@
 extern GLdouble  radius;
 extern GLdouble  fov;
-extern GLuint    numDemandedTriangles,
+extern int    numDemandedTriangles,
                  cameraType;
 extern GLboolean bBeQuiet,
@@ -138,6 +138,7 @@
 extern void init(void);
 
-extern void renderScene(GLuint **histogram, GLuint numCameras);
-extern void renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c);
+extern void resetProjectedAreas(int **histogram, int numCameras);
+extern void getProjectedAreas(int **histogram, int numCameras);
+extern void getProjectedAreasWin(int **histogram, int numCameras, Change *c);
 
 extern void renderGeometry(void);
@@ -150,4 +151,5 @@
 
 extern void applyHWAcceleration(void);
+extern void updateHWAcceleration(Change *c);
 extern void setOrthographicProjection(void);
 extern void resetPerspectiveProjection(void);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/metrics.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/metrics.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/metrics.h	(revision 2127)
@@ -8,25 +8,21 @@
 namespace	VMI
 {
-extern GLdouble computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam);
-extern GLdouble decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c);
-extern GLdouble incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c);
+extern GLdouble computeMI(Mesh *mesh, int **histogram, int numCameras, int cam);
+extern GLdouble decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c);
+extern GLdouble incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c);
 
-extern GLdouble computeHE(Mesh *mesh, GLuint *histogram);
-extern GLdouble computeKL(Mesh *mesh, GLuint *histogram);
-extern GLdouble computeCS(Mesh *mesh, GLuint *histogram);
+extern GLdouble computeHE(Mesh *mesh, int *histogram);
+extern GLdouble computeKL(Mesh *mesh, int *histogram);
+extern GLdouble computeCS(Mesh *mesh, int *histogram);
 
-extern GLdouble computeMeanProjArea(GLuint **histogram, GLuint numCameras, int t);
-extern GLdouble computeJS(GLuint **histogram, GLuint numCameras, GLuint j, GLuint k);
-extern GLdouble computeEntropy(GLuint **histogram, GLuint numCameras, GLuint k);
-extern GLdouble computeMixedEntropy(GLdouble *mixed, GLuint numCameras);
-extern GLdouble computeMeanProjAreaNoBG(GLuint **histogram, GLuint numCameras, int t);
+extern GLdouble computeMeanProjArea(int **histogram, int numCameras, int t);
+extern GLdouble computeJS(int **histogram, int numCameras, int j, int k);
+extern GLdouble computeEntropy(int **histogram, int numCameras, int k);
+extern GLdouble computeMixedEntropy(GLdouble *mixed, int numCameras);
+extern GLdouble computeMeanProjAreaNoBG(int **histogram, int numCameras, int t);
 
-extern void getProjectedAreas(GLuint **histogram, GLuint numCameras);
-extern void getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c);
-extern void resetProjectedAreas(GLuint **histogram, GLuint numCameras);
-
-extern GLdouble *initIs(GLuint numCameras);
-extern void computeCameraIs(GLuint **histogram, GLuint numCameras, GLdouble *mis);
-extern void printIs(GLdouble *mis, GLuint numCameras);
+extern GLdouble *initIs(int numCameras);
+extern void computeCameraIs(int **histogram, int numCameras, GLdouble *mis);
+extern void printIs(GLdouble *mis, int numCameras);
 }
 #endif
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/saliency.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/saliency.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/saliency.h	(revision 2127)
@@ -13,8 +13,8 @@
 extern double percentile;
 
-extern void computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras);
-extern void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v);
+extern void computeSaliency(Mesh *mesh, int **histogram, int numCameras);
+extern void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v);
 
-extern double computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k);
+extern double computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k);
 
 extern double computeEdgeSaliency(Mesh *mesh, Change *c, double p);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h	(revision 983)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h	(revision 2127)
@@ -13,4 +13,4 @@
 #include "saliency.h"
 #include "simplify.h"
-#include "interleave.h"
+#include "buffers.h"
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/color.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/color.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/color.h	(revision 2127)
@@ -14,11 +14,11 @@
 } Color;
 
-extern Color *initColors(GLuint numColors);
-extern void fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color);
-extern void setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end);
-extern void setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end);
-extern void setColors3(Color *colors, GLuint numColors, GLubyte color);
-extern void setColors4(Color *colors, GLuint numColors);
-extern void viewColors(Color *colors, GLuint numColors);
+extern Color *initColors(int numColors);
+extern void fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color);
+extern void setColors(Color *colors, int numPasses, int begin, int end);
+extern void setColors2(Color *colors, int numColors, int begin, int end);
+extern void setColors3(Color *colors, int numColors, GLubyte color);
+extern void setColors4(Color *colors, int numColors);
+extern void viewColors(Color *colors, int numColors);
 
 }
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h	(revision 2127)
@@ -68,7 +68,7 @@
 	extern void modifyTriangle(Triangle *t, int c, int p);
 	extern int isATriangleToModify(Triangle *t, int c);
-	extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod);
+	extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, int *numMod);
 	extern int isATriangleToDelete(Triangle *t, int c, int p);
-	extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel);
+	extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel);
 
 	extern void modifyTriangles(Mesh *mesh, Change *c);
@@ -85,5 +85,6 @@
 
 	extern void modifyEdges(Mesh *mesh, Change *c);
-  extern void deleteEdges(Mesh *mesh, Change *c);
+  extern int find(int *edges, int num, int v_);
+	extern void updateEdgeAdj(Mesh *mesh, Change *c) ;
 
 	//	Save simplification sequence in Geometry Game Tools format.
@@ -92,6 +93,5 @@
 	//extern std::map<int, INTVECTOR> inversemap;
 	extern void swap(int *i, int *j);
-	extern int hasEdge(Triangle *t, int e);
-	extern void getEdges(Triangle *t, Change *c, int *d, int *a);
+
 }
 #endif
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/camera.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/camera.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/camera.h	(revision 2127)
@@ -18,10 +18,10 @@
 } Camera;
 
-extern Camera *loadCameras(GLdouble radius, char* filename, GLuint *numCameras);
-extern void saveCameras(char* filename, Camera *cameras, GLuint numCameras);
+extern Camera *loadCameras(GLdouble radius, char* filename, int *numCameras);
+extern void saveCameras(char* filename, Camera *cameras, int numCameras);
 extern void copyToCameras(Camera *cameras, int numVertices, GLdouble vertices[][3]);
-extern void setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights);
-extern Camera *setCameras(GLdouble radius, GLuint type, GLuint *numCameras);
-extern void printCameras(Camera *cameras, GLuint numCameras);
+extern void setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights);
+extern Camera *setCameras(GLdouble radius, int type, int *numCameras);
+extern void printCameras(Camera *cameras, int numCameras);
 
 extern void drawSphere(Camera *cameras, GLdouble radius, int slices, int stacks);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/interleave.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/interleave.h	(revision 2090)
+++ 	(revision )
@@ -1,35 +1,0 @@
-#ifndef __interleave_h_
-#define __interleave_h_
-
-#include "GL/glut.h"
-
-#include "color.h"
-#include "mesh.h"
-
-namespace	VMI
-{
-typedef struct _VertexIL {
-    GLfloat tx, ty;     // texture coordinates
-    GLubyte r, g, b, a; // color
-    GLfloat x, y, z;    // position
-} VertexIL;
-
-extern VertexIL *intertwined;
-
-typedef struct _Vertex_{
-    GLfloat x, y, z;    // position
-} Vertex_;
-extern GLuint vertex_buf, color_buf;
-
-extern void setupInterleave(Mesh *mesh, Color *colors);
-extern void setupVertexArray(Mesh *mesh, Color *colorss);
-extern void updateVertexArray(Mesh *mesh);
-extern void setupVertexBufferObjects(Mesh *mesh, Color *colors);
-extern void updateVertexBufferObjects(Mesh *mesh);
-extern void printInterleave(int numTriangles);
-extern void updateAllColorInterleave(Mesh *mesh, Color *colors);
-extern void updateColorInterleave(Mesh *mesh, Color *colors, GLuint begin, GLuint end);
-extern void fillColorInterleave(Mesh *mesh, GLuint begin, GLuint end, GLubyte color);
-
-}
-#endif
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/metrics.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/metrics.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/metrics.cpp	(revision 2127)
@@ -13,6 +13,6 @@
 using namespace	VMI;
 
-GLdouble VMI::computeMeanProjAreaNoBG(GLuint **histogram, GLuint numCameras, int t) {
-    GLuint i;
+GLdouble VMI::computeMeanProjAreaNoBG(int **histogram, int numCameras, int t) {
+    int i;
     GLdouble mean_proj_area = 0.0;
 
@@ -24,6 +24,6 @@
 }
 
-GLdouble VMI::computeMeanProjArea(GLuint **histogram, GLuint numCameras, int t) {
-	GLuint i;
+GLdouble VMI::computeMeanProjArea(int **histogram, int numCameras, int t) {
+	int i;
 	GLdouble mean_proj_area = 0.0, total_proj_area, resolution = width * height;
 
@@ -38,7 +38,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Mutual Information
-GLdouble VMI::computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam) {
+GLdouble VMI::computeMI(Mesh *mesh, int **histogram, int numCameras, int cam) {
     GLdouble I = 0.0, pov, po, total_proj_area = width * height;
-    GLuint i;
+    int i;
     
     for (i=0; i<mesh->numTriangles; i++) { 
@@ -66,5 +66,5 @@
 }
 
-GLdouble VMI::decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) {
+GLdouble VMI::decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) {
     GLdouble newI = I * numCameras, 
              pov = 0.0, po;
@@ -109,12 +109,12 @@
 }
 
-GLdouble VMI::incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) {
+GLdouble VMI::incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) {
     GLdouble newI = I * numCameras, 
              pov = 0.0, po;
     GLsizei total_proj_area = width * height;
-    GLuint i, t;
+    int i, t;
 
     // increase entropy of modified triangles
-    for (i=0; i<(GLuint)c->numMod; i++) { 
+    for (i=0; i<c->numMod; i++) { 
         
         t = c->modified[i].id;
@@ -140,9 +140,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Kullback-Leibler divergence
-GLdouble VMI::computeKL(Mesh *mesh, GLuint *histogram) {
+GLdouble VMI::computeKL(Mesh *mesh, int *histogram) {
     GLdouble I = 0.0, 
              total_real_area = 0.0, pi, tri_area;
     GLsizei  total_proj_area = (width * height) - histogram[0];
-    GLuint   i;
+    int   i;
 
     // Compute total real area of all triangles
@@ -169,9 +169,9 @@
 
 // Hellinger divergence (square root)
-GLdouble VMI::computeHE(Mesh *mesh, GLuint *histogram) {
+GLdouble VMI::computeHE(Mesh *mesh, int *histogram) {
     GLdouble I = 0.0, temp, 
              total_real_area = 0.0, pi, qi;
     GLsizei  total_proj_area = (width * height) - histogram[0];
-    GLuint i;
+    int i;
     
     // Compute total real area of all triangles
@@ -203,9 +203,9 @@
 
 // Chi-Square divergence (square root)
-GLdouble VMI::computeCS(Mesh *mesh, GLuint *histogram) {
+GLdouble VMI::computeCS(Mesh *mesh, int *histogram) {
     GLdouble I = 0.0, 
              total_real_area = 0.0, pi, qi;
     GLsizei  total_proj_area = (width * height) - histogram[0];
-    GLuint i;
+    int i;
     
     /// Compute total real area of all triangles
@@ -231,8 +231,8 @@
 }
 ///////////////////////////////////////////////////////////////////////////////
-GLdouble VMI::computeEntropy(GLuint **histogram, GLuint numCameras, GLuint k) {
+GLdouble VMI::computeEntropy(int **histogram, int numCameras, int k) {
 	GLdouble H = 0.0, POk, pi,
 					 total_proj_area, resolution = width * height, pv = 1.0 / (GLdouble)numCameras;
-	GLuint i;
+	int i;
 
 	for (i=0; i<numCameras; i++) {
@@ -253,7 +253,7 @@
 }
 
-GLdouble VMI::computeMixedEntropy(GLdouble *mixed, GLuint numCameras) {
+GLdouble VMI::computeMixedEntropy(GLdouble *mixed, int numCameras) {
     GLdouble H = 0.0, pi;
-    GLuint i;
+    int i;
     
     for (i=0; i<numCameras; i++) {
@@ -269,9 +269,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Jensen-Shannon divergence
-GLdouble VMI::computeJS(GLuint **histogram, GLuint numCameras, GLuint j, GLuint k) {
+GLdouble VMI::computeJS(int **histogram, int numCameras, int j, int k) {
 	GLdouble js, Wj = 0.0, Wk = 0.0, POj, POk, pj, pk, total_proj_area,
 					 resolution = width * height, pv = 1.0 / (GLdouble)numCameras,
 					 *mixing = (GLdouble *)malloc(numCameras * sizeof(GLdouble));
-	GLuint i;
+	int i;
 
 	POj = computeMeanProjArea(histogram, numCameras, j + 1);
@@ -311,23 +311,6 @@
 }
 ///////////////////////////////////////////////////////////////////////////////
-void VMI::getProjectedAreas(GLuint **histogram, GLuint numCameras) {
-
-    renderScene(histogram, numCameras);
-}
-
-void VMI::getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c) {
-
-    renderSceneWin(histogram, numCameras, c);
-}
-
-void VMI::resetProjectedAreas(GLuint **histogram, GLuint numCameras) {
-    GLuint i = 0;
-
-    // Reset the projected areas for all cameras
-    for (i=0; i<numCameras; i++)
-        resetSWHistogram(histogram[i], mesh->numTriangles);
-}
-
-GLdouble *VMI::initIs(GLuint numCameras) {
+
+GLdouble *VMI::initIs(int numCameras) {
     GLdouble *initialIs;
 
@@ -346,6 +329,6 @@
 }
 
-void VMI::computeCameraIs(GLuint **histogram, GLuint numCameras, GLdouble *mis) {
-    GLuint i = 0;
+void VMI::computeCameraIs(int **histogram, int numCameras, GLdouble *mis) {
+    int i = 0;
     GLdouble meanI = 0.0;
 
@@ -374,6 +357,6 @@
 }
 
-void VMI::printIs(GLdouble *mis, GLuint numCameras) {
-    GLuint i;
+void VMI::printIs(GLdouble *mis, int numCameras) {
+    int i;
 
     printf("\n");
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp	(revision 2127)
@@ -22,6 +22,6 @@
 using namespace VMI;
 
-void VMI::computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras) {
-	GLuint i = 0;
+void VMI::computeSaliency(Mesh *mesh, int **histogram, int numCameras) {
+	int i = 0;
 	double sal;
 
@@ -46,5 +46,5 @@
 }
 
-void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v) {
+void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v) {
 	int i, t;
 
@@ -57,6 +57,6 @@
 }
 
-double VMI::computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k) {
-     GLuint i, l, v0, v1, v2;
+double VMI::computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k) {
+    int i, l, v0, v1, v2;
     int *triangles = NULL, n = 0;
     double sal = 0.0;
@@ -94,5 +94,5 @@
     //printItemList(triangles, n);
     
-    for(i=0; i<(GLuint)n; i++) {
+    for(i=0; i<n; i++) {
         //printf("\n%d %d", k, triangles[i]);
         //sal += computeJS(histogram, numCameras, k, triangles[i]);
@@ -137,5 +137,5 @@
 void VMI::saveSaliencyMap(Mesh *mesh, char* filename) {
     FILE *fp;
-    GLuint i;
+    int i;
 
 
@@ -162,5 +162,5 @@
 void VMI::loadSaliencyMap(Mesh *mesh, char* filename) {
     FILE *fp;
-    unsigned int i, num;
+    int i, num;
     float s;
 
@@ -202,5 +202,5 @@
 
 void VMI::viewSaliency(Mesh *mesh, Camera *cameras, int cam) {
-    GLuint i, v1, v2, v3;
+    int i, v1, v2, v3;
     float r, g, b;
     
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/color.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/color.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/color.cpp	(revision 2127)
@@ -7,5 +7,5 @@
 using namespace VMI;
 
-Color *VMI::initColors(GLuint numColors) {
+Color *VMI::initColors(int numColors) {
     Color *colors;
 
@@ -25,6 +25,6 @@
 }
 
-void VMI::fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color) {
-    GLuint i;
+void VMI::fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color) {
+    int i;
 
     if (end > numColors) return;
@@ -40,6 +40,6 @@
 }
 
-void VMI::setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end) {
-    GLuint i, step = numPasses * MAX_NUM_COLORS;
+void VMI::setColors(Color *colors, int numPasses, int begin, int end) {
+    int i, step = numPasses * MAX_NUM_COLORS;
     GLubyte r = 1,
             g = 1,
@@ -86,6 +86,6 @@
 }
 
-void VMI::setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end) {
-    GLuint i, 
+void VMI::setColors2(Color *colors, int numColors, int begin, int end) {
+    int i, 
         channel = 0,
         step = (numColors < MAX_NUM_COLORS) ? (MAX_NUM_COLORS / numColors) : 1;
@@ -133,6 +133,6 @@
 }
 
-void VMI::setColors3(Color *colors, GLuint numColors, GLubyte color) {
-    GLuint i;
+void VMI::setColors3(Color *colors, int numColors, GLubyte color) {
+    int i;
     
     for (i = 0; i < numColors; i++) {
@@ -148,6 +148,6 @@
 }
 
-void VMI::setColors4(Color *colors, GLuint numColors) {
-    GLuint i, c = 1;
+void VMI::setColors4(Color *colors, int numColors) {
+    int i, c = 1;
     
     for (i = 0; i < numColors; i++) {
@@ -164,6 +164,6 @@
 }
 
-void VMI::viewColors(Color *colors, GLuint numColors) {
-    GLuint i;
+void VMI::viewColors(Color *colors, int numColors) {
+    int i;
 
     printf("\n");
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp	(revision 2127)
@@ -8,10 +8,10 @@
 
 Camera *cameras = NULL;
-GLuint numCameras = 0;
+int numCameras = 0;
 
 Color *colors = NULL;
 
-GLuint **histogram = NULL,
-        *queries = NULL;
+int **histogram = NULL;
+GLuint *queries = NULL;
 
 Mesh *mesh = NULL;
@@ -28,5 +28,5 @@
           bRemoveRedundantVertices = GL_TRUE;
 
-GLuint cameraType = 0,
+int cameraType = 0,
        numDemandedTriangles = 0;
 
@@ -174,4 +174,19 @@
 }
 
+void VMI::updateHWAcceleration(Change *c) {
+   
+#ifdef VERTEX_ARRAY_INTERLEAVE
+    if (interleave != NULL) free(interleave);
+    interleave = setupInterleave(mesh, colors);
+#endif
+#ifdef VERTEX_ARRAY
+    updateVertexArray(mesh, c);
+#endif
+#ifdef VERTEX_BUFFER_OBJECTS
+    updateVertexBufferObjects(mesh, c);
+#endif
+
+}
+
 void VMI::setOrthographicProjection(void) {
     // Switch to projection mode
@@ -208,5 +223,5 @@
 void VMI::renderGeometry(void) {
 #ifdef IMMEDIATE_MODE
-    GLuint i, v1, v2, v3;
+    int i, v1, v2, v3;
 
     // Immediate mode
@@ -228,5 +243,5 @@
 #else
 #ifdef VERTEX_ARRAY
-    glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3);
+    glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
 #endif
 #ifdef VERTEX_ARRAY_INTERLEAVE
@@ -235,5 +250,5 @@
 #endif
 #ifdef VERTEX_BUFFER_OBJECTS
-    glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3);
+    glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
 #endif
 
@@ -264,16 +279,22 @@
     glutSwapBuffers();
 }
-void VMI::renderScene(GLuint **histogram, GLuint numCameras)
-{
-    GLuint i;
+
+void VMI::resetProjectedAreas(int **histogram, int numCameras) {
+    int i = 0;
+
+    // Reset the projected areas for all cameras
+    for (i=0; i<numCameras; i++)
+        resetSWHistogram(histogram[i], mesh->numTriangles);
+}
+
+void VMI::getProjectedAreas(int **histogram, int numCameras)
+{
+    int i;
 
     // draw to the frame buffer
     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
-        
-    // Apply HW acceleration OpenGL Technique
-    applyHWAcceleration(); 
-
-    glDrawBuffer(GL_BACK);
-    glReadBuffer(GL_BACK);
+
+    //glDrawBuffer(GL_BACK);
+    //glReadBuffer(GL_BACK);
 
     // Get the projected areas for all cameras
@@ -312,7 +333,7 @@
     ///////////////////////////////////////////////////////////////////////////
 }
-void VMI::renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c)
-{
-    GLuint i, j, t, background;
+void VMI::getProjectedAreasWin(int **histogram, int numCameras, Change *c)
+{
+    int i, j, t, background;
     int del_area, mod_area;
     GLfloat min[3], max[3];
@@ -325,9 +346,9 @@
     //printf("\n(%f,%f,%f)-(%f,%f,%f)\n", min[0], min[1], min[2], max[0], max[1], max[2]);
     
-    // Apply HW acceleration OpenGL Technique
-    applyHWAcceleration(); 
-
-    glDrawBuffer(GL_BACK);
-    glReadBuffer(GL_BACK);
+    // Update HW acceleration OpenGL Technique
+    updateHWAcceleration(c);
+
+    //glDrawBuffer(GL_BACK);
+    //glReadBuffer(GL_BACK);
 
     // Get the projected areas for all cameras
@@ -355,5 +376,5 @@
         mod_area = 0;
 
-        for (j=0; j<( GLuint)c->numDel; j++) {
+        for (j=0; j<c->numDel; j++) {
             t = c->deleted[j].id;
             del_area += histogram[i][t + 1];
@@ -362,5 +383,5 @@
         }
 
-        for (j=0; j<( GLuint)c->numMod; j++) {
+        for (j=0; j<c->numMod; j++) {
             t = c->modified[j].id;
             del_area += histogram[i][t + 1];
@@ -371,5 +392,5 @@
         getSWHistogramWin(histogram[i], pixels, min, max, c); 
 
-        for (j=0; j<( GLuint)c->numMod; j++) {
+        for (j=0; j<c->numMod; j++) {
             t = c->modified[j].id;
             mod_area += histogram[i][t + 1];
@@ -425,4 +446,18 @@
     
     glDeleteBuffersARB(1, &color_buf);
+
+    //free(pbuf_vertices);
+    //free(pbuf_colors);
+
+		buf_vertices = NULL;
+    buf_colors = NULL;
+
+#endif
+#ifdef VERTEX_ARRAY
+    //free(pbuf_vertices);
+    //free(pbuf_colors);
+
+		buf_vertices = NULL;
+    buf_colors = NULL;
 #endif
 
@@ -457,4 +492,7 @@
 
 	start = clock();
+
+	// Apply HW acceleration OpenGL Technique
+  applyHWAcceleration();
 
 	getProjectedAreas(histogram, numCameras);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp	(revision 2127)
@@ -157,6 +157,6 @@
   if (c->numMod > 0) {
       mesh->vertices[c->v].triangles = 
-          (GLuint *)realloc(mesh->vertices[c->v].triangles, 
-          (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof(GLuint));
+          (int *)realloc(mesh->vertices[c->v].triangles, 
+          (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof(int));
   }
 
@@ -193,39 +193,4 @@
 }
 
-int VMI::hasEdge(Triangle *t, int e) {
-    int e0 = t->edges[0],
-        e1 = t->edges[1],
-        e2 = t->edges[2];
-    
-    if ((e == e0) || (e == e1) || (e == e2)) return TRUE;
-
-    return FALSE;
-}
-
-void VMI::getEdges(Triangle *t, Change *c, int *l, int *r) {
-
-    // Default edges
-    *l = -1;
-    *r = -1;
-
-    // Set edge l and r
-    if ((int)t->edges[0] == c->e) {
-        *l = t->edges[1];
-        *r = t->edges[2];
-        if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)
-            swap(l, r);
-    } else if ((int)t->edges[1] == c->e) {
-        *l = t->edges[0];
-        *r = t->edges[2];
-        if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)
-            swap(l, r);
-    } else if ((int)t->edges[2] == c->e) {
-        *l = t->edges[0];
-        *r = t->edges[1];
-        if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v)
-            swap(l, r);
-    }
-}
-
 void VMI::swap(int *i, int *j) {
     int t;
@@ -238,8 +203,5 @@
 void VMI::deleteTriangles(Mesh *mesh, Change *c)
 {
-	    int i, j, t, v;
-#ifdef USE_EDGE_ADJACENCY
-    int t1, l, r;
-#endif
+	  int i, j, t, v;
     
     for (i=0; i<c->numDel; i++) {
@@ -255,26 +217,4 @@
         }
 
-#ifdef USE_EDGE_ADJACENCY
-        // Update triangle edge adjancency
-        // The modified triangles have to be calculated before
-        // Set edge l and r
-        getEdges(&c->deleted[i], c, &l, &r);
-        //printf("e%d(%d,%d): l:%d r:%d\n", c->e, c->u, c->v, l, r);
-        // Find triangle that contains edge l
-        for (j=0; j<c->numMod; j++)
-            if (hasEdge(&c->modified[j], l)) {
-                // Change edge l by r in the Mesh
-                t1 = c->modified[j].id;
-                //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]);
-                if (mesh->triangles[t1].edges[0] == (GLuint)l) mesh->triangles[t1].edges[0] = r;
-                if (mesh->triangles[t1].edges[1] == (GLuint)l) mesh->triangles[t1].edges[1] = r;
-                if (mesh->triangles[t1].edges[2] == (GLuint)l) mesh->triangles[t1].edges[2] = r;
-                //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]);
-                break;
-            }
-
-        // Delete edge l
-        if (l != -1) mesh->edges[l].enable = FALSE;
-#endif
         mesh->triangles[t].enable = FALSE;
         mesh->currentNumTriangles--;
@@ -301,10 +241,5 @@
             addItem((int *)mesh->vertices[v].triangles,(int *)&mesh->vertices[v].numTriangles,t);
         }
-#ifdef USE_EDGE_ADJACENCY
-        // Enable adjacent edges
-        for (j=0; j<3; j++) {
-            mesh->edges[mesh->triangles[t].edges[j]].enable = TRUE;
-        }
-#endif
+
         mesh->triangles[t].enable = TRUE;
         mesh->currentNumTriangles++;
@@ -312,5 +247,5 @@
 }
 
-Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod) {
+Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, int *numMod) {
   int i, t;
   Triangle *modified = NULL;
@@ -336,5 +271,5 @@
 }
 
-Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel) {
+Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel) {
   int i, t;
   Triangle *deleted = NULL;
@@ -359,96 +294,69 @@
 }
 
-void VMI::deleteEdges(Mesh *mesh, Change *c) {
+void VMI::modifyEdges(Mesh *mesh, Change *c) {
     int i, e;
-#ifndef USE_EDGE_ADJACENCY
-    int n0, n1, n2;
-#else
-    int j, u, v;
-#endif
-
-#ifdef USE_EDGE_ADJACENCY
-    for (i=0; i<c->numDel; i++) {
+
+	for(i = 0; i < mesh->vertices[c->v].numEdges; i++) {
         
-        for (j=0; j<3; j++) {
-            e = c->deleted[i].edges[j];
-            if (e != c->e) {
-                u = mesh->edges[e].u;
-                v = mesh->edges[e].v;
-                if (u == c->u || v == c->u) {
-                    //printf("%d\n",j);
-                    mesh->edges[e].enable = FALSE;
-                }
-            }
-        }
-        //getchar();
-    }
-#else
-    for (i=0; i<c->numDel; i++) {
-
-        n0 = c->deleted[i].indices[0];
-        n1 = c->deleted[i].indices[1];
-        n2 = c->deleted[i].indices[2];
-
-        if ((n0 == c->u && n1 != c->v) || (n1 == c->u && n0 != c->v)) {
-            e = findEdge(mesh->edges, mesh->numEdges, n0, n1);
-
-            //printf("a\n");
-            if (e != -1)
-                mesh->edges[e].enable = FALSE;
-        }
-
-        if ((n1 == c->u && n2 != c->v) || (n2 == c->u && n1 != c->v)) {
-            e = findEdge(mesh->edges, mesh->numEdges, n1, n2);
-            
-            //printf("b\n");
-            if (e != -1)
-                mesh->edges[e].enable = FALSE;
-        }
-
-        if ((n0 == c->u && n2 != c->v) || (n2 == c->u && n0 != c->v)) {
-            e = findEdge(mesh->edges, mesh->numEdges, n0, n2);
-            
-            //printf("c\n");
-            if (e != -1)
-                mesh->edges[e].enable = FALSE;
-        }
-        //getchar();
-    }
-#endif
-}
-
-void VMI::modifyEdges(Mesh *mesh, Change *c) {
-    int e, u, v;
-    
-    // Update mesh and heap
-    for(e = 0; e < (int)mesh->numEdges; e++) {
-        
+		e = mesh->vertices[c->v].edges[i];
+
         if (mesh->edges[e].enable == TRUE) {
             
             // Modify edge
-            if ((int)mesh->edges[e].u == c->u)
+            if (mesh->edges[e].u == c->u)
                 mesh->edges[e].u = c->v;
             
-            if ((int)mesh->edges[e].v == c->u)
+            if (mesh->edges[e].v == c->u)
                 mesh->edges[e].v = c->v;
-            
-            // Check edge
-            u = mesh->edges[e].u;
-            v = mesh->edges[e].v;
-            
-            // if the edge is not valid, we simply delete it
-            if ((u == v) || 
-                (u == c->u) || (v == c->u)) 
-                
-                mesh->edges[e].enable = FALSE;
         }
     }
 }
 
+int VMI::find(int *edges, int num, int v_) {
+	int i;
+
+	int u, v;
+
+
+	for(i=0; i<num; i++) {
+
+		u = mesh->edges[edges[i]].u;
+
+		v = mesh->edges[edges[i]].v;
+
+		if (u == v_ || v == v_) return TRUE;
+
+	}
+
+	return FALSE;
+}
+void VMI::updateEdgeAdj(Mesh *mesh, Change *c) {
+	int i;
+
+	int v, e;
+
+	mesh->vertices[c->v].edges = 
+            (int *)realloc(mesh->vertices[c->v].edges, 
+            (mesh->vertices[c->v].numEdges + mesh->vertices[c->u].numEdges) * sizeof(int));
+
+	for (i=0; i<mesh->vertices[c->u].numEdges; i++) {
+        
+		e = mesh->vertices[c->u].edges[i];
+		if (mesh->edges[e].u == c->u) v =mesh->edges[e].v;
+		else v = mesh->edges[e].u;
+		
+		if (!find(mesh->vertices[c->v].edges, mesh->vertices[c->v].numEdges, v))
+			addItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, e);
+		else mesh->edges[e].enable = FALSE;
+	}
+
+	delItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, c->e);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 // Compute the triangle mesh changes due to a heap node simplification
 void VMI::computeChange(Mesh *mesh, Change *c) {
-  GLuint numMod, numDel;
+  int numMod, numDel;
   Triangle *m = getTrianglesToModify(mesh, c, &numMod),
             *d = getTrianglesToDelete(mesh, c, &numDel);
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp	(revision 2127)
@@ -14,8 +14,8 @@
 //#define DRAW_DEBUG // just for debugging not necessary
 
-Camera *VMI::loadCameras(GLdouble radius, char* filename, GLuint *numCameras) {
+Camera *VMI::loadCameras(GLdouble radius, char* filename, int *numCameras) {
     FILE *fp;
     Camera *cameras;
-    GLuint num, i;
+    int num, i;
     GLfloat eyeX, eyeY, eyeZ,
         centerX, centerY, centerZ,
@@ -118,7 +118,7 @@
 }
 
-void VMI::saveCameras(char* filename, Camera *cameras, GLuint numCameras) {
+void VMI::saveCameras(char* filename, Camera *cameras, int numCameras) {
     FILE *fp;
-    GLuint i;
+    int i;
 
     if((fp= fopen(filename, "wt"))== NULL) {
@@ -170,5 +170,5 @@
 }
 
-Camera *VMI::setCameras(GLdouble radius, GLuint type, GLuint *numCameras) {
+Camera *VMI::setCameras(GLdouble radius, int type, int *numCameras) {
     Camera *cameras = NULL;
 
@@ -221,6 +221,6 @@
 }
 
-void VMI::setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights) {
-    GLuint i;
+void VMI::setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights) {
+    int i;
 
     for (i = 0; i<numCameras; i++) {
@@ -229,6 +229,6 @@
 }
 
-void VMI::printCameras(Camera *cameras, GLuint numCameras) {
-    GLuint i;
+void VMI::printCameras(Camera *cameras, int numCameras) {
+    int i;
     
     printf("\n");
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/buffers.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/buffers.cpp	(revision 2127)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/buffers.cpp	(revision 2127)
@@ -0,0 +1,528 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../include/GL/glew.h"
+
+#include "../include/buffers.h"
+#include "../include/global.h"
+
+namespace	VMI
+{
+Vertex_ *buf_vertices = NULL;
+Color   *buf_colors = NULL;
+
+Vertex_ *pbuf_vertices;
+Color   *pbuf_colors;
+
+GLuint vertex_buf = 0,
+       color_buf = 0;
+
+}
+
+using namespace	VMI;
+
+void VMI::saveVertexBuffer(Change *c, VertexIL *dest) {
+    int j, t, n = 0, m;
+    
+    // Save vertex coordinates and color for deleted triangles
+    for (j=0; j<c->numDel; j++) { 
+        
+        t = c->deleted[j].id;
+        
+        m = 3 * t;
+        
+        dest[n].x = buf_vertices[m + 0].x;
+        dest[n].y = buf_vertices[m + 0].y;
+        dest[n].z = buf_vertices[m + 0].z;
+        dest[n].a = buf_colors[m + 0].a;
+        dest[n].b = buf_colors[m + 0].b;
+        dest[n].r = buf_colors[m + 0].r;
+        dest[n].g = buf_colors[m + 0].g;
+        n++;
+        
+        dest[n].x = buf_vertices[m + 1].x;
+        dest[n].y = buf_vertices[m + 1].y;
+        dest[n].z = buf_vertices[m + 1].z;
+        dest[n].a = buf_colors[m + 1].a;
+        dest[n].b = buf_colors[m + 1].b;
+        dest[n].r = buf_colors[m + 1].r;
+        dest[n].g = buf_colors[m + 1].g;
+        n++;
+        
+        dest[n].x = buf_vertices[m + 2].x;
+        dest[n].y = buf_vertices[m + 2].y;
+        dest[n].z = buf_vertices[m + 2].z;
+        dest[n].a = buf_colors[m + 2].a;
+        dest[n].b = buf_colors[m + 2].b;
+        dest[n].r = buf_colors[m + 2].r;
+        dest[n].g = buf_colors[m + 2].g;
+        n++;
+    }
+    // Save vertex coordinates for modified triangles
+    for (j=0; j<c->numMod; j++) { 
+        
+        t = c->modified[j].id;
+        
+        m = 3 * t;
+        
+        dest[n].x = buf_vertices[m + 0].x;
+        dest[n].y = buf_vertices[m + 0].y;
+        dest[n].z = buf_vertices[m + 0].z;
+        n++;
+        
+        dest[n].x = buf_vertices[m + 1].x;
+        dest[n].y = buf_vertices[m + 1].y;
+        dest[n].z = buf_vertices[m + 1].z;
+        n++;
+        
+        dest[n].x = buf_vertices[m + 2].x;
+        dest[n].y = buf_vertices[m + 2].y;
+        dest[n].z = buf_vertices[m + 2].z;
+        n++;
+    }
+}
+
+void VMI::loadVertexBuffer(VertexIL *src, Change *c) {
+    int j, t, n = 0, m;
+    
+    // Load vertex coordinates and color for deleted triangles
+    for (j=0; j<c->numDel; j++) { 
+        
+        t = c->deleted[j].id;
+        
+        m = 3 * t;
+
+        buf_vertices[m + 0].x = src[n].x;
+        buf_vertices[m + 0].y = src[n].y;
+        buf_vertices[m + 0].z = src[n].z;
+        buf_colors[m + 0].a = src[n].a;
+        buf_colors[m + 0].b = src[n].b;
+        buf_colors[m + 0].r = src[n].r;
+        buf_colors[m + 0].g = src[n].g;
+        n++;
+
+        buf_vertices[m + 1].x = src[n].x;
+        buf_vertices[m + 1].y = src[n].y;
+        buf_vertices[m + 1].z = src[n].z;
+        buf_colors[m + 1].a = src[n].a;
+        buf_colors[m + 1].b = src[n].b;
+        buf_colors[m + 1].r = src[n].r;
+        buf_colors[m + 1].g = src[n].g;
+        n++;
+
+        buf_vertices[m + 2].x = src[n].x;
+        buf_vertices[m + 2].y = src[n].y;
+        buf_vertices[m + 2].z = src[n].z;
+        buf_colors[m + 2].a = src[n].a;
+        buf_colors[m + 2].b = src[n].b;
+        buf_colors[m + 2].r = src[n].r;
+        buf_colors[m + 2].g = src[n].g;
+        n++;
+    }
+    // Load vertex coordinates for modified triangles
+    for (j=0; j<c->numMod; j++) { 
+        
+        t = c->modified[j].id;
+        
+        m = 3 * t;
+
+        buf_vertices[m + 0].x = src[n].x;
+        buf_vertices[m + 0].y = src[n].y;
+        buf_vertices[m + 0].z = src[n].z;
+        n++;
+
+        buf_vertices[m + 1].x = src[n].x;
+        buf_vertices[m + 1].y = src[n].y;
+        buf_vertices[m + 1].z = src[n].z;
+        n++;
+
+        buf_vertices[m + 2].x = src[n].x;
+        buf_vertices[m + 2].y = src[n].y;
+        buf_vertices[m + 2].z = src[n].z;
+        n++;
+    }
+}
+
+void VMI::setupVertexArray(Mesh *mesh, Color *colors)
+{
+    int i, v1, v2, v3, n = 0;
+    GLubyte r, g, b, a;
+
+    if (buf_vertices != NULL) free(buf_vertices);
+    if (buf_colors != NULL) free(buf_colors);
+
+    buf_vertices = (Vertex_ *)malloc(mesh->numTriangles * 3 * sizeof(Vertex_));
+
+    buf_colors = (Color *)malloc(mesh->numTriangles * 3 * sizeof(Color));
+
+    if (buf_vertices == NULL) {
+        fprintf(stderr, "Error allocating memory\n");
+        exit(1);
+    }
+
+    if (buf_colors == NULL) {
+        fprintf(stderr, "Error allocating memory\n");
+        exit(1);
+    }
+
+    for (i=0; i<mesh->numTriangles; i++) {
+
+        v1= mesh->triangles[i].indices[0];
+        v2= mesh->triangles[i].indices[1];
+        v3= mesh->triangles[i].indices[2];
+        
+        if (mesh->triangles[i].enable == TRUE) {
+            
+            r = colors[i].r;
+            g = colors[i].g;
+            b = colors[i].b;
+            a = colors[i].a;
+            
+            buf_colors[n].r = r;
+            buf_colors[n].g = g;
+            buf_colors[n].b = b;
+            buf_colors[n].a = a;
+            buf_vertices[n].x = mesh->vertices[v1].x;
+            buf_vertices[n].y = mesh->vertices[v1].y;
+            buf_vertices[n].z = mesh->vertices[v1].z;
+            n++;
+            
+            buf_colors[n].r = r;
+            buf_colors[n].g = g;
+            buf_colors[n].b = b;
+            buf_colors[n].a = a;
+            buf_vertices[n].x = mesh->vertices[v2].x;
+            buf_vertices[n].y = mesh->vertices[v2].y;
+            buf_vertices[n].z = mesh->vertices[v2].z;
+            n++;
+            
+            buf_colors[n].r = r;
+            buf_colors[n].g = g;
+            buf_colors[n].b = b;
+            buf_colors[n].a = a;
+            buf_vertices[n].x = mesh->vertices[v3].x;
+            buf_vertices[n].y = mesh->vertices[v3].y;
+            buf_vertices[n].z = mesh->vertices[v3].z;
+            n++;
+        } else {
+         
+            buf_colors[n].r = 0;
+            buf_colors[n].g = 0;
+            buf_colors[n].b = 0;
+            buf_colors[n].a = 0;
+            buf_vertices[n].x = 0;
+            buf_vertices[n].y = 0;
+            buf_vertices[n].z = 0;
+            n++;
+            
+            buf_colors[n].r = 0;
+            buf_colors[n].g = 0;
+            buf_colors[n].b = 0;
+            buf_colors[n].a = 0;
+            buf_vertices[n].x = 0;
+            buf_vertices[n].y = 0;
+            buf_vertices[n].z = 0;
+            n++;
+            
+            buf_colors[n].r = 0;
+            buf_colors[n].g = 0;
+            buf_colors[n].b = 0;
+            buf_colors[n].a = 0;
+            buf_vertices[n].x = 0;
+            buf_vertices[n].y = 0;
+            buf_vertices[n].z = 0;
+            n++;
+        }
+    }
+#ifdef VERTEX_ARRAY
+    // Enable the buf_vertices vector
+    glEnableClientState(GL_COLOR_ARRAY);
+    glEnableClientState(GL_VERTEX_ARRAY);
+    
+    glColorPointer(4, GL_UNSIGNED_BYTE, 0, buf_colors);
+    glVertexPointer(3, GL_FLOAT, 0, buf_vertices);
+#endif
+
+    pbuf_colors = buf_colors;
+    pbuf_vertices = buf_vertices;
+}
+
+void VMI::setupVertexBufferObjects(Mesh *mesh, Color *colors) {
+    
+    setupVertexArray(mesh, colors);
+    
+    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
+    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->numTriangles * 3 * 3 * sizeof(float), buf_vertices, GL_STATIC_DRAW_ARB); //upload data
+
+    glVertexPointer(3, GL_FLOAT, 0,0);
+    
+    glBindBufferARB(GL_ARRAY_BUFFER_ARB, color_buf);
+    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->numTriangles * 3 * sizeof(Color), buf_colors, GL_STATIC_DRAW_ARB); //upload data
+    
+    glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
+
+    // Enable the vertex array functionality:
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_COLOR_ARRAY);
+    
+    //free(buf_vertices);
+    //buf_vertices = NULL;
+    
+    //free(buf_colors);
+    //buf_colors = NULL;
+}
+
+void VMI::updateVertexArray(Mesh *mesh, Change *c)
+{
+    int i, v1, v2, v3, t, n;
+
+    // The deleted triangles are now in background color
+    for (i=0; i<c->numDel; i++) {
+        t = c->deleted[i].id;
+
+        n = t * 3;
+
+        buf_colors[n + 0].r = 0;
+        buf_colors[n + 0].g = 0;
+        buf_colors[n + 0].b = 0;
+        buf_colors[n + 0].a = 0;
+
+        buf_colors[n + 1].r = 0;
+        buf_colors[n + 1].g = 0;
+        buf_colors[n + 1].b = 0;
+        buf_colors[n + 1].a = 0;
+
+        buf_colors[n + 2].r = 0;
+        buf_colors[n + 2].g = 0;
+        buf_colors[n + 2].b = 0;
+        buf_colors[n + 2].a = 0;
+
+        buf_vertices[n + 0].x = 0;
+        buf_vertices[n + 0].y = 0;
+        buf_vertices[n + 0].z = 0;
+
+        buf_vertices[n + 1].x = 0;
+        buf_vertices[n + 1].y = 0;
+        buf_vertices[n + 1].z = 0;
+
+        buf_vertices[n + 2].x = 0;
+        buf_vertices[n + 2].y = 0;
+        buf_vertices[n + 2].z = 0;
+    }
+
+    // Update vertex coordinates for modified triangles
+    for (i=0; i<c->numMod; i++) {
+        t = c->modified[i].id;
+
+        n = t * 3;
+
+        v1= mesh->triangles[t].indices[0];
+        v2= mesh->triangles[t].indices[1];
+        v3= mesh->triangles[t].indices[2];
+
+        buf_vertices[n + 0].x = mesh->vertices[v1].x;
+        buf_vertices[n + 0].y = mesh->vertices[v1].y;
+        buf_vertices[n + 0].z = mesh->vertices[v1].z;
+
+        buf_vertices[n + 1].x = mesh->vertices[v2].x;
+        buf_vertices[n + 1].y = mesh->vertices[v2].y;
+        buf_vertices[n + 1].z = mesh->vertices[v2].z;
+
+        buf_vertices[n + 2].x = mesh->vertices[v3].x;
+        buf_vertices[n + 2].y = mesh->vertices[v3].y;
+        buf_vertices[n + 2].z = mesh->vertices[v3].z;
+    }
+}
+
+void VMI::updateVertexBufferObjects(Mesh *mesh, Change *c) {
+    
+    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
+    // Map the buffer object
+	buf_vertices = ( Vertex_ *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY);
+
+    glBindBufferARB(GL_ARRAY_BUFFER_ARB, color_buf);
+    // Map the buffer object
+	buf_colors = (Color   *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY);
+
+    updateVertexArray(mesh, c);
+
+    // Unmap buffers
+    glBindBuffer(GL_ARRAY_BUFFER_ARB, vertex_buf);
+    if (!glUnmapBufferARB(GL_ARRAY_BUFFER_ARB)) {
+        // Handle error case
+    }
+    glBindBuffer(GL_ARRAY_BUFFER_ARB, color_buf);
+    if (!glUnmapBufferARB(GL_ARRAY_BUFFER_ARB)) {
+        // Handle error case
+    }
+}
+
+VertexIL *VMI::setupInterleave(Mesh *mesh, Color *colors)
+{
+    int i, v1, v2, v3, n = 0;
+    GLubyte r, g, b, a;
+    VertexIL *interleave = NULL;
+    
+    interleave = (VertexIL *)malloc(mesh->currentNumTriangles * 3 * sizeof(VertexIL));
+    
+    if (interleave == NULL) {
+        fprintf(stderr, "Error allocating memory\n");
+        exit(1);
+    }
+    
+    for (i=0; i<mesh->numTriangles; i++) {
+        
+        if (mesh->triangles[i].enable == TRUE) {
+            v1= mesh->triangles[i].indices[0];
+            v2= mesh->triangles[i].indices[1];
+            v3= mesh->triangles[i].indices[2];
+            
+            r = colors[i].r;
+            g = colors[i].g;
+            b = colors[i].b;
+            a = colors[i].a;
+            
+            interleave[n].tx = 0.0f;
+            interleave[n].ty = 0.0f;
+            interleave[n].r = r;
+            interleave[n].g = g;
+            interleave[n].b = b;
+            interleave[n].a = a;
+            interleave[n].x = mesh->vertices[v1].x;
+            interleave[n].y = mesh->vertices[v1].y;
+            interleave[n].z = mesh->vertices[v1].z;
+            n++;
+            
+            interleave[n].tx = 0.0f;
+            interleave[n].ty = 0.0f;
+            interleave[n].r = r;
+            interleave[n].g = g;
+            interleave[n].b = b;
+            interleave[n].a = a;
+            interleave[n].x = mesh->vertices[v2].x;
+            interleave[n].y = mesh->vertices[v2].y;
+            interleave[n].z = mesh->vertices[v2].z;
+            n++;
+            
+            interleave[n].tx = 0.0f;
+            interleave[n].ty = 0.0f;
+            interleave[n].r = r;
+            interleave[n].g = g;
+            interleave[n].b = b;
+            interleave[n].a = a;
+            interleave[n].x = mesh->vertices[v3].x;
+            interleave[n].y = mesh->vertices[v3].y;
+            interleave[n].z = mesh->vertices[v3].z;
+            n++;
+        }
+    }
+
+    return interleave;
+}
+
+void VMI::printInterleave(VertexIL *interleave, int num)
+{
+    int i;
+
+    printf("\n");
+    for (i=0; i<num * 3; i++) {
+        printf("Interleave%d (%d, %d, %d ,%d, %f, %f ,%f)\n", i,
+            interleave[i].r, interleave[i].g, interleave[i].b, interleave[i].a,
+            interleave[i].x , interleave[i].y, interleave[i].z);
+    }
+}
+
+void VMI::updateAllColorInterleave(VertexIL *interleave, int num, Color *colors)
+{
+    int i, n = 0;
+    GLubyte r, g, b, a;
+
+    for (i=1; i<=num; i++) { // Triangles start at 1
+
+        r = colors[i].r;
+        g = colors[i].g;
+        b = colors[i].b;
+        a = colors[i].a;
+
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+        n++;
+
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+        n++;
+
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+        n++;
+    }
+}
+
+void VMI::updateColorInterleave(VertexIL *interleave, int num, Color *colors, int begin, int end)
+{
+    int i, n;
+    GLubyte r, g, b, a;
+
+    if (end > num) return;
+
+    for (i=begin; i<end; i++) {
+        
+        n = i * 3;
+
+        r = colors[i].r;
+        g = colors[i].g;
+        b = colors[i].b;
+        a = colors[i].a;
+
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+
+        n++;
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+
+        n++;
+        interleave[n].r = r;
+        interleave[n].g = g;
+        interleave[n].b = b;
+        interleave[n].a = a;
+    }
+}
+
+void VMI::fillColorInterleave(VertexIL *interleave, int num, int begin, int end, GLubyte color)
+{
+    int i, n;
+
+    if (end > num) return;
+
+    for (i=begin; i<end; i++) {
+        
+        n = i * 3;
+        interleave[n].r = color;
+        interleave[n].g = color;
+        interleave[n].b = color;
+        interleave[n].a = color;
+
+        n++;
+        interleave[n].r = color;
+        interleave[n].g = color;
+        interleave[n].b = color;
+        interleave[n].a = color;
+
+        n++;
+        interleave[n].r = color;
+        interleave[n].g = color;
+        interleave[n].b = color;
+        interleave[n].a = color;
+    }
+}
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp	(revision 2127)
@@ -53,6 +53,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
-int VMI::findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v) {
-    GLuint i, u, v;
+int VMI::findEdge(Edge *e, int num, int _u, int _v) {
+    int i, u, v;
     int found = -1; 
 
@@ -85,8 +85,4 @@
 		newList[*n].u = u;
     newList[*n].v = v;
-
-		// This edge has no triangle adjancency
-		newList[*n].numTriangles = 0;
-		newList[*n].triangles = NULL;
 		
 		// Enable the new edge
@@ -102,6 +98,50 @@
 }
 
+double VMI::computeEdgeLength(Vertex *vertices, int u, int v) {
+    float ux, uy, uz, vx, vy ,vz, rx, ry, rz;
+    
+    ux = vertices[u].x;
+    uy = vertices[u].y;
+    uz = vertices[u].z;
+
+    vx = vertices[v].x;
+    vy = vertices[v].y;
+    vz = vertices[v].z;
+
+    rx = ux - vx;
+    ry = uy - vy;
+    rz = uz - vz;
+
+    return sqrt((rx * rx) + (ry * ry) + (rz * rz));
+}
+
+double VMI::computeTriangleVolume(Vertex *vertices, Triangle *t) {
+    int i;
+    double m[3][3], vol;
+    
+    // Compute triangle Volume
+    i = t->indices[0];
+    m[0][0] = mesh->vertices[i].x;
+    m[0][1] = mesh->vertices[i].y;
+    m[0][2] = mesh->vertices[i].z;
+    
+    i = t->indices[1];
+    m[1][0] = mesh->vertices[i].x;
+    m[1][1] = mesh->vertices[i].y;
+    m[1][2] = mesh->vertices[i].z;
+
+    i = t->indices[2];
+    m[2][0] = mesh->vertices[i].x;
+    m[2][1] = mesh->vertices[i].y;
+    m[2][2] = mesh->vertices[i].z;
+    
+    vol = computeMatDet(m);
+    
+    //printf("Triangle Volume: %f\n", vol)
+    return vol;  
+}
+
 GLdouble VMI::computeTriangleArea(Vertex *vertices, Triangle *t) {
-    GLuint i;
+    int i;
     GLdouble v0[3], v1[3], v2[3], a;
     
@@ -129,5 +169,5 @@
 
 void VMI::computeTriangleNormal(Vertex *vertices, Triangle *t) {
-    GLuint i;
+    int i;
     GLfloat x0, y0, z0,
             x1, y1, z1,
@@ -175,5 +215,5 @@
 Mesh *VMI::initMesh(GLMmodel* pmodel) {
 
-    GLuint i, j, curGroup, v1, v2, v3, n, m, t;
+    int i, j, curGroup, v1, v2, v3, n, m, t;
     int e;
     Mesh *mesh;
@@ -202,5 +242,5 @@
     
     printf("Adding vertices...");
-    for (i=1; i<=pmodel->numvertices; i++) { // Vertices start at 1
+    for (i=1; i<=(int)pmodel->numvertices; i++) { // Vertices start at 1
         mesh->vertices[i - 1].x = pmodel->vertices[3 * i + 0];
         mesh->vertices[i - 1].y = pmodel->vertices[3 * i + 1];
@@ -208,4 +248,6 @@
         mesh->vertices[i - 1].numTriangles = 0;
         mesh->vertices[i - 1].triangles = NULL;
+				mesh->vertices[i - 1].numEdges = 0;
+        mesh->vertices[i - 1].edges = NULL;
         mesh->vertices[i - 1].enable = GL_TRUE;
     }
@@ -221,5 +263,5 @@
     while(group) {
         
-        for (i=0; i<group->numtriangles; i++) {
+        for (i=0; i<(int)group->numtriangles; i++) {
             
             t = group->triangles[i];
@@ -244,5 +286,5 @@
                 // Reallocate memory for the new adjacent triangle
                 mesh->vertices[v1].triangles = 
-					(GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint));
+					(int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int));
                 addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, t);
             }
@@ -254,7 +296,7 @@
     for (i=0; i<pmodel->numtriangles; i++) {
         mesh->triangles[i].id = i;
-        mesh->triangles[i].indices[0] = pmodel->triangles[i].vindices[0] - 1;
-        mesh->triangles[i].indices[1] = pmodel->triangles[i].vindices[1] - 1;
-        mesh->triangles[i].indices[2] = pmodel->triangles[i].vindices[2] - 1;
+        mesh->triangles[i].indices[0] = (int)pmodel->triangles[i].vindices[0] - 1;
+        mesh->triangles[i].indices[1] = (int)pmodel->triangles[i].vindices[1] - 1;
+        mesh->triangles[i].indices[2] = (int)pmodel->triangles[i].vindices[2] - 1;
         mesh->triangles[i].area = computeTriangleArea(mesh->vertices, &mesh->triangles[i]);
         //printf("\n%d a: %f",i , mesh->triangles[i].area);
@@ -271,5 +313,5 @@
             // Reallocate memory for the new adjacent triangle
             mesh->vertices[v1].triangles = 
-			    (GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint));
+			    (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int));
             addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, i);
         }
@@ -304,19 +346,8 @@
             mesh->edges[n].u = v1;
             mesh->edges[n].v = v2;
-						mesh->edges[n].triangles    = NULL;
-        		mesh->edges[n].numTriangles = 0;
             mesh->edges[n].enable = GL_TRUE;
             m = n;
             n++;
         } else m = e;
-		// Reallocate memory for the new adjacent triangle
-        mesh->edges[m].triangles = 
-			(GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));
-        // Adding triangle i adjacent to edge m
-        addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);
-        //printf("n:%d i:%d\n", m, i);
-        
-        // Adding edge m adjacent to triangle i
-        addItem((int *)mesh->triangles[i].edges, (int *)&t, m);
 
         /////////////////////////////////////////////////////////////////////////////////
@@ -325,19 +356,8 @@
             mesh->edges[n].u = v2;
             mesh->edges[n].v = v3;
-						mesh->edges[n].triangles    = NULL;
-        		mesh->edges[n].numTriangles = 0;
             mesh->edges[n].enable = GL_TRUE;
             m = n;
             n++;
         } else m = e;
-		// Reallocate memory for the new adjacent triangle
-        mesh->edges[m].triangles = 
-			(GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));
-        // Adding triangle i adjacent to edge m
-        addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);
-        //printf("n:%d i:%d\n", m, i);
-        
-        // Adding edge m adjacent to triangle i
-        addItem((int *)mesh->triangles[i].edges, (int *)&t, m);
 
         /////////////////////////////////////////////////////////////////////////////////
@@ -346,28 +366,32 @@
             mesh->edges[n].u = v3;
             mesh->edges[n].v = v1;
-						mesh->edges[n].triangles    = NULL;
-        		mesh->edges[n].numTriangles = 0;
             mesh->edges[n].enable = GL_TRUE;
             m = n;
             n++;
         } else m = e;
-		// Reallocate memory for the new adjacent triangle
-        mesh->edges[m].triangles = 
-			(GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint));
-        // Adding triangle i adjacent to edge m
-        addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i);
-        //printf("n:%d i:%d\n", m, i);
-        
-        // Adding edge m adjacent to triangle i
-        addItem((int *)mesh->triangles[i].edges, (int *)&t, m);
     }
     printf("Ok\n");
     mesh->numEdges = n;
 
+		for (i=0; i<mesh->numEdges; i++) {
+			v1 = mesh->edges[i].u;
+			v2 = mesh->edges[i].v;
+
+			mesh->vertices[v1].edges = 
+				(int *)realloc(mesh->vertices[v1].edges, (mesh->vertices[v1].numEdges + 1) * sizeof(int));
+			// Adding edge i adjacent to vertex v1
+			addItem(mesh->vertices[v1].edges, &mesh->vertices[v1].numEdges, i);
+
+			mesh->vertices[v2].edges = 
+				(int *)realloc(mesh->vertices[v2].edges, (mesh->vertices[v2].numEdges + 1) * sizeof(int));
+			// Adding edge i adjacent to vertex v2
+			addItem(mesh->vertices[v2].edges, &mesh->vertices[v2].numEdges, i);
+		}
+
     return mesh;
 }
 
 void VMI::printMesh(Mesh *mesh) {
-    GLuint i, j;
+    int i, j;
 
     printf("Vertices (%d)\n", mesh->numVertices);
@@ -385,4 +409,13 @@
         }
         printf("]\n");
+
+					printf("  e(%d)[", mesh->vertices[i].numEdges);
+        if (mesh->vertices[i].edges != NULL) {
+            printf("%d", mesh->vertices[i].edges[0]);
+            for (j=1; j<mesh->vertices[i].numEdges; j++) {
+                printf(",%d", mesh->vertices[i].edges[j]);
+            }
+        }
+        printf("]\n");
     }
 
@@ -391,12 +424,4 @@
     for (i=0; i<mesh->numEdges; i++) {
         printf("e%d (%d,%d) %d\n", i, mesh->edges[i].u, mesh->edges[i].v, mesh->edges[i].enable);
-        printf("  t(%d)[", mesh->edges[i].numTriangles);
-        if (mesh->edges[i].triangles != NULL) {
-            printf("%d", mesh->edges[i].triangles[0]);
-            for (j=1; j<mesh->edges[i].numTriangles; j++) {
-                printf(",%d", mesh->edges[i].triangles[j]);
-            }
-				}
-        printf("]\n");
     }
 
@@ -406,10 +431,4 @@
         printf("t%d (%d,%d,%d) %d\n", i, mesh->triangles[i].indices[0], mesh->triangles[i].indices[1],
                                      mesh->triangles[i].indices[2],  mesh->triangles[i].enable);
-        printf("  e(3)[");
-        printf("%d", mesh->triangles[i].edges[0]);
-        for (j=1; j<3; j++) {
-            printf(",%d", mesh->triangles[i].edges[j]);
-        }
-        printf("]\n");
 
         printf("  n(3)[");
@@ -425,5 +444,5 @@
 
 void VMI::deleteMesh(Mesh *mesh) {
-	GLuint i;
+	int i;
 
 	if (NULL != mesh) {
@@ -432,12 +451,11 @@
 				free(mesh->vertices[i].triangles);
 
+			if (mesh->vertices[i].edges != NULL)
+				free(mesh->vertices[i].edges);
+
 		}
 		if (mesh->vertices != NULL) free(mesh->vertices);
 		mesh->numVertices = 0;
 
-		for (i=0; i<mesh->numEdges; i++) {
-			if (mesh->edges[i].triangles != NULL)
-				free(mesh->edges[i].triangles);
-		}
 		if (mesh->edges != NULL) free(mesh->edges);
 		mesh->numEdges = 0;
@@ -525,50 +543,4 @@
 }
 
-int *VMI::edgesAdjToVertex(Mesh *mesh, int v, int *n) {
-    int *edges = NULL;
-    int i, t, e;
-#ifndef USE_EDGE_ADJACENCY
-    int n0, n1, n2;
-#else
-    int j;
-#endif
-    int num = 0;
-
-	if (mesh->vertices[v].numTriangles > 0) 
-		edges = (int*)malloc(sizeof(int) * mesh->vertices[v].numTriangles * 2);
-
-    for (i=0; i<(int)mesh->vertices[v].numTriangles; i++) {
-
-        t = mesh->vertices[v].triangles[i];
-
-#ifdef USE_EDGE_ADJACENCY
-        for (j=0; j<3; j++) {
-            e = mesh->triangles[t].edges[j];
-            
-            if ((int)mesh->edges[e].u == v || (int)mesh->edges[e].v == v)
-                
-                addItem(edges, &num, e);
-        }
-#else
-        n0 = mesh->triangles[t].indices[0];
-        n1 = mesh->triangles[t].indices[1];
-        n2 = mesh->triangles[t].indices[2];
-        
-        if (((n0 == v) || (n1 == v)) &&
-            ((e = findEdge(mesh->edges, mesh->numEdges, n0, n1)) != -1)) addItem(edges, &num, e);
- 
-        if (((n1 == v) || (n2 == v)) &&
-            ((e = findEdge(mesh->edges, mesh->numEdges, n1, n2)) != -1)) addItem(edges, &num, e);
-        
-        if (((n0 == v) || (n2 == v)) &&
-            ((e = findEdge(mesh->edges, mesh->numEdges, n0, n2)) != -1)) addItem(edges, &num, e);
-
-#endif
-    }
-    *n = num;
-
-    return edges;
-}
-
 int *VMI::edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n) {
     int *edges = NULL;
@@ -578,5 +550,6 @@
     if (numVertices > 0) {
         // Add the first
-        list = edgesAdjToVertex(mesh, vertices[0], &numEdges);
+		list = mesh->vertices[vertices[0]].edges;
+		numEdges = mesh->vertices[vertices[0]].numEdges;
 
         // Allocate memory
@@ -585,6 +558,4 @@
         memcpy(edges, list, sizeof(int) * numEdges);
 
-        free(list);
-
         num = numEdges;
 
@@ -592,8 +563,9 @@
         for (i=1; i<numVertices; i++) {
 
-            list = edgesAdjToVertex(mesh, vertices[i], &numEdges);
+			list = mesh->vertices[vertices[i]].edges;
+		    numEdges = mesh->vertices[vertices[i]].numEdges;
 
             // Reallocate memory
-			if (numEdges > 0) {
+            if (numEdges > 0) {
 
                 edges = (int *)realloc(edges, (num + numEdges + 1) * sizeof(int));
@@ -601,6 +573,5 @@
                 for (j=0; j<numEdges; j++)
                     addItem(edges, &num, list[j]);
-			}
-            free(list);
+            }
         }
     }
@@ -610,7 +581,7 @@
 }
 
-GLboolean VMI::findVertex(GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos) {
-    GLuint i;
-    GLfloat _x, _y, _z;
+GLboolean VMI::findVertex(float *vertices, int num, float x, float y, float z, int *pos) {
+    int i;
+    float _x, _y, _z;
     GLboolean found = GL_FALSE; 
     
@@ -648,4 +619,7 @@
 		newList[*n].numTriangles = 0;
 		newList[*n].triangles = NULL;
+
+		newList[*n].numEdges= 0;
+		newList[*n].edges = NULL;
 	
     // Enable the new vertex
@@ -663,8 +637,8 @@
 
 
-void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles) {
-    GLuint i , v1, v2 ,v3, numV = 1, numT = 0;
+void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles) {
+    int i , v1, v2 ,v3, numV = 1, numT = 0;
     int pos;
-    GLfloat x, y, z;
+    float x, y, z;
     
     if (pmodel->vertices != NULL) free(pmodel->vertices);
@@ -726,5 +700,5 @@
 
 void VMI::saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh) {
-    GLuint i, j, g, numT = 0;
+    int i, j, g, numT = 0;
     GLMgroup *group;
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp	(revision 2103)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp	(revision 2127)
@@ -10,4 +10,5 @@
 #include "../include/saliency.h"
 #include "../include/histogram.h"
+#include "../include/buffers.h"
 
 //#define RECOMPUTE_THE_WHOLE_HEAP
@@ -59,5 +60,5 @@
 
 bheap_t *VMI::initHeap(Mesh *mesh) {
-	GLuint i;
+	int i;
 	double cost;
 	bheap_t *h = NULL;
@@ -152,22 +153,4 @@
 
 	return h;
-}
-
-GLdouble VMI::computeEdgeLength(Vertex *vertices, int u, int v) {
-	GLfloat ux, uy, uz, vx, vy ,vz, rx, ry, rz;
-
-	ux = vertices[u].x;
-	uy = vertices[u].y;
-	uz = vertices[u].z;
-
-	vx = vertices[v].x;
-	vy = vertices[v].y;
-	vz = vertices[v].z;
-
-	rx = ux - vx;
-	ry = uy - vy;
-	rz = uz - vz;
-
-	return sqrt((rx * rx) + (ry * ry) + (rz * rz));
 }
 
@@ -243,8 +226,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
-void saveProjectedAreas(GLuint **histogram, GLuint numCameras, Change *c, GLuint *dest) {
-	GLuint i, j, t, n = 0;
-
-	for (j=0; j<(GLuint)c->numDel; j++) {
+void saveProjectedAreas(int **histogram, int numCameras, Change *c, int *dest) {
+	int i, j, t, n = 0;
+
+	for (j=0; j<c->numDel; j++) {
 
 		t = c->deleted[j].id;
@@ -257,5 +240,5 @@
 	}
 
-	for (j=0; j<(GLuint)c->numMod; j++) { 
+	for (j=0; j<c->numMod; j++) { 
 
 		t = c->modified[j].id;
@@ -276,8 +259,8 @@
 }
 
-void loadProjectedAreas(GLuint *src, GLuint numCameras, Change *c, GLuint **histogram) {
-	GLuint i, j, t, n = 0;
-
-	for (j=0; j<(GLuint)c->numDel; j++) { 
+void loadProjectedAreas(int *src, int numCameras, Change *c, int **histogram) {
+	int i, j, t, n = 0;
+
+	for (j=0; j<c->numDel; j++) { 
 
 		t = c->deleted[j].id;
@@ -290,5 +273,5 @@
 	}
 
-	for (j=0; j<(GLuint)c->numMod; j++) { 
+	for (j=0; j<c->numMod; j++) { 
 
 		t = c->modified[j].id;
@@ -308,6 +291,49 @@
 	}
 }
-
 ///////////////////////////////////////////////////////////////////////////////
+#ifdef CHECK_LOCAL_INVERSION
+int check_local_inversion(Mesh *mesh, Change *c) {
+    int i, t;
+    int v0, v1, v2;
+    double vol_before;
+    double vol_after;
+    Triangle tri;
+    
+    for(i=0; i<mesh->vertices[c->u].numTriangles; i++) {
+        
+        t = mesh->vertices[c->u].triangles[i];
+        
+        v0 = mesh->triangles[t].indices[0];
+        v1 = mesh->triangles[t].indices[1];
+        v2 = mesh->triangles[t].indices[2];
+        
+        if ((v0 != c->v) && (v1 != c->v) && (v2 != c->v)) {
+            
+            //printf("%d\n", t);
+            memcpy(&tri, &mesh->triangles[t], sizeof(Triangle));
+            
+            vol_before = computeTriangleVolume(mesh->vertices, &tri);
+
+            //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]);
+            //printf("v:%f\n", vol_before);
+          
+            if (tri.indices[0] == c->u) tri.indices[0] = c->v;
+            if (tri.indices[1] == c->u) tri.indices[1] = c->v;
+            if (tri.indices[2] == c->u) tri.indices[2] = c->v;
+            
+            vol_after = computeTriangleVolume(mesh->vertices, &tri);
+
+            //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]);
+            //printf("v:%f\n", vol_after);
+
+            if (((vol_before > 0) && (vol_after < 0)) || 
+                ((vol_before < 0) && (vol_after > 0)))
+
+                return TRUE;
+        }
+    }
+    return FALSE;
+}
+#endif
 
 GLdouble VMI::computeEdgeCost(Mesh *mesh, int e) {
@@ -318,6 +344,12 @@
 	GLdouble newI;
 #endif
-	GLuint i, *histoAux = NULL;
+	int i, *histoAux = NULL;
 	Change *c;
+#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY)
+    VertexIL *vb = NULL;
+#endif
+#ifdef CHECK_LOCAL_INVERSION
+    int penalized;
+#endif
 
 	chooseBestEndPoints(mesh, e);
@@ -327,8 +359,18 @@
 
 	// Compute cost only for boundary or manifold edges
-	if (c->numDel == 2
-			/*(c->numDel <3) && (c->numDel > 0)*/) {
+	if (/*c->numDel == 2*/
+			(c->numDel <3) && (c->numDel > 0)) {
+
+#ifdef CHECK_LOCAL_INVERSION
+        penalized = check_local_inversion(mesh, c);
+#endif
 		// Allocate memory
-		histoAux = (GLuint *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(GLuint));
+		histoAux = (int *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(int));
+
+#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY)
+        vb = (VertexIL *)malloc((c->numDel + c->numMod + 1) * 3 * sizeof(VertexIL));
+
+        saveVertexBuffer(c, vb);
+#endif
 
 #ifdef MI // Mutual Information
@@ -365,5 +407,5 @@
 			//printf("  I0:%f Is: %f\n", auxE[i], initialIs[i]);
 
-			cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight * sal);
+			cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight);
 
 			// Restore old informations
@@ -405,5 +447,5 @@
 			newI = computeCS(mesh, histogram[i]);
 #endif
-			cost += (ABS(initialIs[i] - newI) * cameras[i].weight * sal);
+			cost += (ABS(initialIs[i] - newI) * cameras[i].weight);
 		}
 		undoChange(mesh, c);
@@ -417,4 +459,11 @@
 		// Free memory
 		free(histoAux);
+#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY)
+        loadVertexBuffer(vb, c);
+        free(vb);
+#endif
+#ifdef CHECK_LOCAL_INVERSION
+        if (penalized) cost *= 5;
+#endif
 
 	} else cost = FLT_MAX;
@@ -422,6 +471,25 @@
 	deleteChange(c);
 
-	return cost;
-}
+	return (cost * sal);
+}
+
+int isValidEdge_(Mesh *mesh, int e) {
+    int u , v;
+
+    if (mesh->edges[e].enable == FALSE) return FALSE;
+    else {
+        u = mesh->edges[e].u;
+        v = mesh->edges[e].v;
+
+        if (u == v) {
+
+            mesh->edges[e].enable = FALSE;
+            return FALSE;
+        }
+    }
+
+    return TRUE;
+}
+
 /* Get a valid edge from the heap */
 int getMinValidEdge(Mesh *mesh, bheap_t *h) {
@@ -431,5 +499,5 @@
 	e = bh_min(h);
 
-	while (mesh->edges[e].enable == FALSE) {
+	while (!isValidEdge_(mesh, e)) {
 		/* delete invalid edge */
 		bh_delete(h, e);
@@ -473,5 +541,5 @@
 
 ///////////////////////////////////////////////////////////////////////////
-void VMI::simplifyModel(Mesh *mesh, GLuint numDemandedTri)
+void VMI::simplifyModel(Mesh *mesh, int numDemandedTri)
 {
 	int			e;
@@ -558,4 +626,6 @@
 		bh_delete(h, e);
 
+		updateHWAcceleration(c);
+
 		// Get projected areas after the edge collapse
 		getProjectedAreas(histogram, numCameras);
@@ -563,6 +633,7 @@
 		computeCameraIs(histogram, numCameras, initialIs);
 
-		deleteEdges(mesh, c);
-		modifyEdges(mesh, c);
+		updateEdgeAdj(mesh, c);
+
+    modifyEdges(mesh, c);
 
 		// Update the heap according to the edge collapse
@@ -751,5 +822,4 @@
 
 	Edge		*econ;
-	float		x,y,z;
 	int			*lv1;
 	int			v0;
@@ -797,5 +867,6 @@
 			v1	=	(*lb1).second;
 
-			lv1	=	edgesAdjToVertex(mesh,v1,&num_edges);
+			lv1	=	mesh->vertices[v1].edges;
+			num_edges = mesh->vertices[v1].numEdges;
 
 			//	Edje iterator.
@@ -857,6 +928,6 @@
 
 			deleteVertexOfMap(mesh, c->u);
-			deleteEdges(mesh, c);
-			modifyEdges(mesh, c);
+			updateEdgeAdj(mesh, c);
+      modifyEdges(mesh, c);
 			deleteChange(c);
 
@@ -910,5 +981,7 @@
 			lonely_vert	=	(*it).second;
 
-			le	=	edgesAdjToVertex(mesh,lonely_vert,&num_edges);
+			le	=	mesh->vertices[lonely_vert].edges;
+
+			num_edges = mesh->vertices[lonely_vert].numEdges;
 
 			//	Find an edge width v coordinates.
@@ -977,6 +1050,6 @@
 
 				deleteVertexOfMap(mesh, c->u);
-				deleteEdges(mesh, c);
-				modifyEdges(mesh, c);
+				updateEdgeAdj(mesh, c);
+        modifyEdges(mesh, c);
 				deleteChange(c);
 			}
@@ -1069,6 +1142,6 @@
 
 				deleteVertexOfMap(mesh, c->u);
-				deleteEdges(mesh, c);
-				modifyEdges(mesh, c);
+				updateEdgeAdj(mesh, c);
+        modifyEdges(mesh, c);
 				deleteChange(c);
 			}
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/histogram.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/histogram.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/histogram.cpp	(revision 2127)
@@ -14,5 +14,5 @@
 using namespace VMI;
 
-void VMI::printHistogram(GLuint histoGram[][4]) {
+void VMI::printHistogram(int histoGram[][4]) {
     int i;
    
@@ -23,7 +23,7 @@
 }
 
-void VMI::plotHistogram(GLuint histoGram[][4]) {
+void VMI::plotHistogram(int histoGram[][4]) {
     int i;
-    GLuint iLargest = 0;  // Largest histogram value
+    int iLargest = 0;  // Largest histogram value
     GLfloat maxHeight = height / 2.0f;
         
@@ -72,9 +72,9 @@
 }
 
-GLuint **VMI::initHistogram(GLuint numTriangles, GLuint numCameras) {
-    GLuint i;
-    GLuint **histogram;
-
-    histogram = (GLuint **)malloc(sizeof(GLuint *) * numCameras);
+int **VMI::initHistogram(int numTriangles, int numCameras) {
+    int i;
+    int **histogram;
+
+    histogram = (int **)malloc(sizeof(int *) * numCameras);
 
     if (histogram == NULL) {
@@ -84,15 +84,15 @@
 
     for (i=0; i<numCameras; i++)
-    histogram[i] = (GLuint *)malloc(sizeof(GLuint) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background
+    histogram[i] = (int *)malloc(sizeof(int) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background
 
     // Fill the histogram buffer with 0
     for (i=0; i<numCameras; i++)
-    memset(histogram[i], 0, sizeof(GLuint) * (numTriangles + 1));
+    memset(histogram[i], 0, sizeof(int) * (numTriangles + 1));
 
     return histogram;
 }
 
-void VMI::deleteHistogram(GLuint **histogram, GLuint numCameras) {
-    GLuint i;
+void VMI::deleteHistogram(int **histogram, int numCameras) {
+    int i;
     
     for (i=0;i<numCameras;i++)
@@ -102,6 +102,6 @@
 }
 
-void VMI::printFullHistogram(GLuint **histogram, GLuint numCameras, GLuint numTriangles) {
-    GLuint i, j;
+void VMI::printFullHistogram(int **histogram, int numCameras, int numTriangles) {
+    int i, j;
     
     printf("\n");
@@ -116,5 +116,5 @@
 }
 
-void VMI::getSubHistogram(GLuint subHistoGram[][4]) {
+void VMI::getSubHistogram(int subHistoGram[][4]) {
     //printf("Computing histogram...\n");
     // Define the histogram
@@ -137,8 +137,8 @@
 }
 
-void VMI::copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]) {
-    GLuint i;
+void VMI::copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]) {
+    int i;
     GLubyte r, g, b, a;
-    GLuint h = 0;
+    int h = 0;
 
     for (i=begin; i<end; i++) {
@@ -165,7 +165,7 @@
 }
 
-void VMI::getSWHistogram(GLuint *histogram, GLubyte *pixels) {
+void VMI::getSWHistogram(int *histogram, GLubyte *pixels) {
     GLubyte r, g, b, a;
-    GLuint i, t, p, numPixels = width * height;
+    int i, t, p, numPixels = width * height;
 
     glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
@@ -188,5 +188,5 @@
 
 void VMI::getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]) {
-    GLuint  i, j, t, v;
+    int  i, j, t, v;
     GLfloat maxx = 0.0f, minx = 0.0f, 
             maxy = 0.0f, miny = 0.0f,
@@ -194,5 +194,5 @@
     
     /* get the max/mins */
-    for (i=0; i<(GLuint)c->numMod; i++) {
+    for (i=0; i<c->numMod; i++) {
         t = c->modified[i].id;
         
@@ -217,5 +217,5 @@
     }
 
-    for (i=0; i<(GLuint)c->numDel; i++) {
+    for (i=0; i<c->numDel; i++) {
         t = c->deleted[i].id;
         
@@ -322,8 +322,8 @@
 }
 
-void VMI::getSWHistogramWin(GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) {
+void VMI::getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) {
     GLubyte r, g, b, a;
-    GLuint i, t, p, numPixels,
-          *histoAux = (GLuint *)calloc(mesh->numTriangles + 1, sizeof(GLuint));
+    int i, t, p, numPixels,
+          *histoAux = (int *)calloc(mesh->numTriangles + 1, sizeof(int));
     GLint minw[2], maxw[2], ox, oy, h, w;
 
@@ -369,6 +369,6 @@
     }
 
-    for (i=0; i<(GLuint)c->numMod; i++) {
-        t = (GLuint)c->modified[i].id;
+    for (i=0; i<c->numMod; i++) {
+        t = c->modified[i].id;
 
         histogram[t + 1] = histoAux[t + 1]; 
@@ -379,6 +379,6 @@
 }
 
-void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram) {
-    GLuint i, v1, v2, v3;
+void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram) {
+    int i, v1, v2, v3;
     GLint area, totalArea = 0;
 
@@ -432,7 +432,7 @@
 }
 
-void VMI::resetSWHistogram(GLuint *histogram, GLuint numTriangles) {
+void VMI::resetSWHistogram(int *histogram, int numTriangles) {
 
     // Fill the histogram buffer with 0
-    memset(histogram, 0, sizeof(GLuint) * (numTriangles + 1));
-}
+    memset(histogram, 0, sizeof(int) * (numTriangles + 1));
+}
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/interleave.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/interleave.cpp	(revision 2090)
+++ 	(revision )
@@ -1,354 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "../include/GL/glew.h"
-#ifdef _WIN32
-#include "../include/GL/wglew.h"
-#endif
-#include "../include/interleave.h"
-#include "../include/global.h"
-
-namespace	VMI
-{
-
-VertexIL *intertwined = NULL;
-
-static Vertex_ *buf_vertices = NULL;
-static Color   *buf_colors = NULL;
-
-GLuint vertex_buf = 0,
-       color_buf = 0;
-}
-
-using namespace	VMI;
-       
-void VMI::setupVertexArray(Mesh *mesh, Color *colors)
-{
-    GLuint i, v1, v2, v3, n = 0;
-    GLubyte r, g, b, a;
-
-    if (buf_vertices != NULL) free(buf_vertices);
-    if (buf_colors != NULL) free(buf_colors);
-
-    buf_vertices = (Vertex_ *)malloc(mesh->currentNumTriangles * 3 * sizeof(Vertex_));
-
-    buf_colors = (Color *)malloc(mesh->currentNumTriangles * 3 * sizeof(Color));
-
-    if (buf_vertices == NULL) {
-        fprintf(stderr, "Error allocating memory\n");
-        exit(1);
-    }
-
-    if (buf_colors == NULL) {
-        fprintf(stderr, "Error allocating memory\n");
-        exit(1);
-    }
-
-    for (i=0; i<mesh->numTriangles; i++) {
-        
-        if (mesh->triangles[i].enable == TRUE) {
-            
-            v1= mesh->triangles[i].indices[0];
-            v2= mesh->triangles[i].indices[1];
-            v3= mesh->triangles[i].indices[2];
-            
-            r = colors[i].r;
-            g = colors[i].g;
-            b = colors[i].b;
-            a = colors[i].a;
-            
-            buf_colors[n].r = r;
-            buf_colors[n].g = g;
-            buf_colors[n].b = b;
-            buf_colors[n].a = a;
-            buf_vertices[n].x = mesh->vertices[v1].x;
-            buf_vertices[n].y = mesh->vertices[v1].y;
-            buf_vertices[n].z = mesh->vertices[v1].z;
-            n++;
-            
-            buf_colors[n].r = r;
-            buf_colors[n].g = g;
-            buf_colors[n].b = b;
-            buf_colors[n].a = a;
-            buf_vertices[n].x = mesh->vertices[v2].x;
-            buf_vertices[n].y = mesh->vertices[v2].y;
-            buf_vertices[n].z = mesh->vertices[v2].z;
-            n++;
-            
-            buf_colors[n].r = r;
-            buf_colors[n].g = g;
-            buf_colors[n].b = b;
-            buf_colors[n].a = a;
-            buf_vertices[n].x = mesh->vertices[v3].x;
-            buf_vertices[n].y = mesh->vertices[v3].y;
-            buf_vertices[n].z = mesh->vertices[v3].z;
-            n++;
-        }
-    }
-#ifdef VERTEX_ARRAY
-    // Enable the buf_vertices vector
-    glEnableClientState(GL_COLOR_ARRAY);
-    glEnableClientState(GL_VERTEX_ARRAY);
-    
-    glColorPointer(4, GL_UNSIGNED_BYTE, 0, buf_colors);
-    glVertexPointer(3, GL_FLOAT, 0, buf_vertices);
-#endif
-}
-
-void VMI::setupVertexBufferObjects(Mesh *mesh, Color *colors) {
-    
-    setupVertexArray(mesh, colors);
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
-    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->currentNumTriangles * 3 * 3 * sizeof(float), buf_vertices, GL_STATIC_DRAW_ARB); //upload data
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, color_buf);
-    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->currentNumTriangles * 3 * sizeof(Color), buf_colors, GL_STATIC_DRAW_ARB); //upload data
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
-    glVertexPointer(3, GL_FLOAT, 0,0);
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, color_buf);
-    glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
-    
-    // Enable the vertex array functionality:
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glEnableClientState(GL_COLOR_ARRAY);
-    
-    free(buf_vertices);
-    buf_vertices = NULL;
-    
-    free(buf_colors);
-    buf_colors = NULL;
-}
-
-void VMI::updateVertexArray(Mesh *mesh)
-{
-    GLuint i, v1, v2, v3, n = 0;
-
-    if (buf_vertices != NULL) free(buf_vertices);
-
-    buf_vertices = (Vertex_ *)malloc(mesh->currentNumTriangles * 3 * sizeof(Vertex_));
-
-    if (buf_vertices == NULL) {
-        fprintf(stderr, "Error allocating memory\n");
-        exit(1);
-    }
-
-    for (i=0; i<mesh->numTriangles; i++) {
-        
-        if (mesh->triangles[i].enable == TRUE) {
-            
-            v1= mesh->triangles[i].indices[0];
-            v2= mesh->triangles[i].indices[1];
-            v3= mesh->triangles[i].indices[2];
-            
-            buf_vertices[n].x = mesh->vertices[v1].x;
-            buf_vertices[n].y = mesh->vertices[v1].y;
-            buf_vertices[n].z = mesh->vertices[v1].z;
-            n++;
-            
-            buf_vertices[n].x = mesh->vertices[v2].x;
-            buf_vertices[n].y = mesh->vertices[v2].y;
-            buf_vertices[n].z = mesh->vertices[v2].z;
-            n++;
-            
-            buf_vertices[n].x = mesh->vertices[v3].x;
-            buf_vertices[n].y = mesh->vertices[v3].y;
-            buf_vertices[n].z = mesh->vertices[v3].z;
-            n++;
-        }
-    }
-#ifdef VERTEX_ARRAY
-    // Enable the buf_vertices vector
-    glEnableClientState(GL_VERTEX_ARRAY);
-    
-    glVertexPointer(3, GL_FLOAT, 0, buf_vertices);
-#endif
-}
-
-void VMI::updateVertexBufferObjects(Mesh *mesh) {
-    
-    updateVertexArray(mesh);
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
-    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->currentNumTriangles * 3 * 3 * sizeof(float), buf_vertices, GL_STATIC_DRAW_ARB); //upload data
-    
-    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buf);
-    glVertexPointer(3, GL_FLOAT, 0,0);
-    
-    // Enable the vertex array functionality:
-    glEnableClientState(GL_VERTEX_ARRAY);
-    
-    free(buf_vertices);
-    buf_vertices = NULL;
-}
-
-void VMI::setupInterleave(Mesh *mesh, Color *colors)
-{
-    GLuint i, v1, v2, v3, n = 0;
-    GLubyte r, g, b, a;
-    
-    if (intertwined != NULL) free(intertwined);
-    
-    intertwined = (VertexIL *)malloc(mesh->currentNumTriangles * 3 * sizeof(VertexIL));
-    
-    if (intertwined == NULL) {
-        fprintf(stderr, "Error allocating memory\n");
-        exit(1);
-    }
-    
-    for (i=0; i<mesh->numTriangles; i++) {
-        
-        if (mesh->triangles[i].enable == TRUE) {
-            v1= mesh->triangles[i].indices[0];
-            v2= mesh->triangles[i].indices[1];
-            v3= mesh->triangles[i].indices[2];
-            
-            r = colors[i].r;
-            g = colors[i].g;
-            b = colors[i].b;
-            a = colors[i].a;
-            
-            intertwined[n].tx = 0.0f;
-            intertwined[n].ty = 0.0f;
-            intertwined[n].r = r;
-            intertwined[n].g = g;
-            intertwined[n].b = b;
-            intertwined[n].a = a;
-            intertwined[n].x = mesh->vertices[v1].x;
-            intertwined[n].y = mesh->vertices[v1].y;
-            intertwined[n].z = mesh->vertices[v1].z;
-            n++;
-            
-            intertwined[n].tx = 0.0f;
-            intertwined[n].ty = 0.0f;
-            intertwined[n].r = r;
-            intertwined[n].g = g;
-            intertwined[n].b = b;
-            intertwined[n].a = a;
-            intertwined[n].x = mesh->vertices[v2].x;
-            intertwined[n].y = mesh->vertices[v2].y;
-            intertwined[n].z = mesh->vertices[v2].z;
-            n++;
-            
-            intertwined[n].tx = 0.0f;
-            intertwined[n].ty = 0.0f;
-            intertwined[n].r = r;
-            intertwined[n].g = g;
-            intertwined[n].b = b;
-            intertwined[n].a = a;
-            intertwined[n].x = mesh->vertices[v3].x;
-            intertwined[n].y = mesh->vertices[v3].y;
-            intertwined[n].z = mesh->vertices[v3].z;
-            n++;
-        }
-    }
-}
-
-void VMI::printInterleave(int numTriangles)
-{
-    int i;
-
-    printf("\n");
-    for (i=0; i<numTriangles * 3; i++) {
-        printf("Interleave%d (%d, %d, %d ,%d, %f, %f ,%f)\n", i,
-            intertwined[i].r, intertwined[i].g, intertwined[i].b, intertwined[i].a,
-            intertwined[i].x , intertwined[i].y, intertwined[i].z);
-    }
-}
-
-void VMI::updateAllColorInterleave(Mesh *mesh, Color *colors)
-{
-    GLuint i, n = 0;
-    GLubyte r, g, b, a;
-
-    for (i=1; i<=mesh->numTriangles; i++) { // Triangles start at 1
-
-        r = colors[i].r;
-        g = colors[i].g;
-        b = colors[i].b;
-        a = colors[i].a;
-
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-        n++;
-
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-        n++;
-
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-        n++;
-    }
-}
-
-void VMI::updateColorInterleave(Mesh *mesh, Color *colors, GLuint begin, GLuint end)
-{
-    GLuint i, n;
-    GLubyte r, g, b, a;
-
-    if (end > mesh->numTriangles) return;
-
-    for (i=begin; i<end; i++) {
-        
-        n = i * 3;
-
-        r = colors[i].r;
-        g = colors[i].g;
-        b = colors[i].b;
-        a = colors[i].a;
-
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-
-        n++;
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-
-        n++;
-        intertwined[n].r = r;
-        intertwined[n].g = g;
-        intertwined[n].b = b;
-        intertwined[n].a = a;
-    }
-}
-
-void VMI::fillColorInterleave(Mesh *mesh, GLuint begin, GLuint end, GLubyte color)
-{
-    GLuint i, n;
-
-    if (end > mesh->numTriangles) return;
-
-    for (i=begin; i<end; i++) {
-        
-        n = i * 3;
-        intertwined[n].r = color;
-        intertwined[n].g = color;
-        intertwined[n].b = color;
-        intertwined[n].a = color;
-
-        n++;
-        intertwined[n].r = color;
-        intertwined[n].g = color;
-        intertwined[n].b = color;
-        intertwined[n].a = color;
-
-        n++;
-        intertwined[n].r = color;
-        intertwined[n].g = color;
-        intertwined[n].b = color;
-        intertwined[n].a = color;
-    }
-}
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 2103)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 2127)
@@ -158,18 +158,4 @@
 	mGeoMesh	=	m_qslim->GetMesh();
 
-	//	Debug.
-	cout	<<	"Number of bone assignaments: "
-				<<	mGeoMesh->mBones.size()
-				<<	endl;
-
-	// if the initial mesh had shared vertex,
-	// convert the mesh to shared vertex
-	//Mesh *sharedMesh = mGeoMesh->toSharedVertex();
-	//delete mGeoMesh;
-	//mGeoMesh = sharedMesh;
-
-	//	Sort bones.
-	//sortBones();
-
 	delete	m_qslim;
 }
@@ -191,13 +177,4 @@
 	mGeoMesh	=	m_qslim->GetMesh();
 
-	// if the initial mesh had shared vertex,
-	// convert the mesh to shared vertex
-	//Mesh *sharedMesh = mGeoMesh->toSharedVertex();
-	//delete mGeoMesh;
-	//mGeoMesh = sharedMesh;
-	
-	//	Sort bones.
-	//sortBones();
-	
 	delete m_qslim;
 }
@@ -453,7 +430,9 @@
 		vmi_mesh->vertices[i].y = vertex_buffer->mPosition[i].y;
 		vmi_mesh->vertices[i].z = vertex_buffer->mPosition[i].z;
-		
+
 		vmi_mesh->vertices[i].numTriangles = 0;
 		vmi_mesh->vertices[i].triangles = NULL;
+		vmi_mesh->vertices[i].numEdges = 0;
+		vmi_mesh->vertices[i].edges = NULL;
 		vmi_mesh->vertices[i].enable 	= GL_TRUE;
 		vmi_mesh->vertices[i].movable = GL_TRUE;
@@ -503,5 +482,5 @@
 
 				// Reallocate memory for the new adjacent triangle.
-				vmi_mesh->vertices[v1].triangles = (GLuint *)realloc(vmi_mesh->vertices[v1].triangles, (vmi_mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint));
+				vmi_mesh->vertices[v1].triangles = (int *)realloc(vmi_mesh->vertices[v1].triangles, (vmi_mesh->vertices[v1].numTriangles + 1) * sizeof(int));
 
 				VMI::addItem(	(int *)vmi_mesh->vertices[v1].triangles,
@@ -548,32 +527,7 @@
 			vmi_mesh->edges[n].u						=	v1;
 			vmi_mesh->edges[n].v						=	v2;
-			vmi_mesh->edges[n].triangles    = NULL;
-			vmi_mesh->edges[n].numTriangles = 0;
 			vmi_mesh->edges[n].enable 			=	GL_TRUE;
 
-			// Reallocate memory for the new adjacent triangle
-			vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge n
-			VMI::addItem(	(int *)vmi_mesh->edges[n].triangles,
-										(int *)&vmi_mesh->edges[n].numTriangles,
-										i);
-
-			// Adding edge n adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n);
 			n++;
-		}
-		else
-		{
-			// Reallocate memory for the new adjacent triangle.
-			vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge e
-			VMI::addItem(	(int *)vmi_mesh->edges[e].triangles,
-										(int *)&vmi_mesh->edges[e].numTriangles,
-										i);
-
-			// Adding edge e adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e);
 		}
 
@@ -582,32 +536,7 @@
 			vmi_mesh->edges[n].u 						= v2;
 			vmi_mesh->edges[n].v 						= v3;
-			vmi_mesh->edges[n].triangles    = NULL;
-			vmi_mesh->edges[n].numTriangles = 0;
 			vmi_mesh->edges[n].enable 			= GL_TRUE;
 
-			// Reallocate memory for the new adjacent triangle
-			vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge n
-			VMI::addItem((int *)vmi_mesh->edges[n].triangles, (int *)&vmi_mesh->edges[n].numTriangles, i);
-			vmi_mesh->edges[n].triangles    = NULL;
-			vmi_mesh->edges[n].numTriangles = 0;
-
-			// Adding edge n adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n);
 			n++;
-		}
-		else
-		{
-			// Reallocate memory for the new adjacent triangle
-			vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge e
-			VMI::addItem(	(int *)vmi_mesh->edges[e].triangles,
-										(int *)&vmi_mesh->edges[e].numTriangles,
-										i);
-
-			// Adding edge e adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e);
 		}
 		
@@ -616,30 +545,7 @@
 			vmi_mesh->edges[n].u 						= v3;
 			vmi_mesh->edges[n].v 						= v1;
-			vmi_mesh->edges[n].triangles    = NULL;
-			vmi_mesh->edges[n].numTriangles = 0;
 			vmi_mesh->edges[n].enable 			= GL_TRUE;
 
-			// Reallocate memory for the new adjacent triangle.
-			vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge n
-			VMI::addItem(	(int *)vmi_mesh->edges[n].triangles,
-										(int *)&vmi_mesh->edges[n].numTriangles,
-										i);
-
-			// Adding edge n adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n);
 			n++;
-		}
-		else
-		{
-			// Reallocate memory for the new adjacent triangle
-			vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint));
-
-			// Adding triangle i adjacent to edge e
-			VMI::addItem((int *)vmi_mesh->edges[e].triangles, (int *)&vmi_mesh->edges[e].numTriangles, i);
-
-			// Adding edge e adjacent to triangle i
-			VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e);
 		}
 	}
@@ -647,4 +553,19 @@
 	printf("Ok\n");
 	vmi_mesh->numEdges = n;
+
+	for (i=0; i<vmi_mesh->numEdges; i++) {
+		v1 = vmi_mesh->edges[i].u;
+		v2 = vmi_mesh->edges[i].v;
+
+		vmi_mesh->vertices[v1].edges = 
+			(int *)realloc(vmi_mesh->vertices[v1].edges, (vmi_mesh->vertices[v1].numEdges + 1) * sizeof(int));
+		// Adding edge i adjacent to vertex v1
+		VMI::addItem(vmi_mesh->vertices[v1].edges, &vmi_mesh->vertices[v1].numEdges, i);
+
+		vmi_mesh->vertices[v2].edges = 
+			(int *)realloc(vmi_mesh->vertices[v2].edges, (vmi_mesh->vertices[v2].numEdges + 1) * sizeof(int));
+		// Adding edge i adjacent to vertex v2
+		VMI::addItem(vmi_mesh->vertices[v2].edges, &vmi_mesh->vertices[v2].numEdges, i);
+	}
 
 	//	Creates vertex multimap.
@@ -1133,178 +1054,4 @@
 
 //-------------------------------------------------------------------------
-//	Modify the joined vertices sequento to an split.
-//-------------------------------------------------------------------------
-MeshSimplificationSequence *
-TextureConserver::WriteRealSimpSeq(MeshSimplificationSequence *simpseq)
-{
-	bool	edge_found;
-
-	size_t	v0;
-	size_t	v1;
-	size_t	vertex_count;
-	size_t	i,j;
-
-	VertexBuffer	*mVB;
-	GeoVertex			new_vertex;
-
-	multimap<int, int>::iterator	lb0;
-	multimap<int, int>::iterator	ub0;
-	multimap<int, int>::iterator	lb1;
-	multimap<int, int>::iterator	ub1;
-	multimap<int, int>::iterator	it0;
-
-	MeshSimplificationSequence				*real_seq;
-	MeshSimplificationSequence::Step	current_step;
-
-	//	Initialize vertex count.
-	vertex_count	=	mGeoMesh->mVertexBuffer->mVertexCount;
-
-	//	Creates new simplification sequence.
-	real_seq	=	new	MeshSimplificationSequence();
-
-	//	For each simplification step.
-	for (i = 0; i < simpseq->mSteps.size();	i++)
-	{
-		lb0	=	mVertices.lower_bound(simpseq->mSteps[i].mV0);
-		ub0	=	mVertices.upper_bound(simpseq->mSteps[i].mV0);
-		lb1	=	mVertices.lower_bound(simpseq->mSteps[i].mV1);
-		ub1	=	mVertices.upper_bound(simpseq->mSteps[i].mV1);
-
-		//	Removed vertex.
-		while (lb1 != ub1)
-		{
-			//	Real index.
-			v1	=	(*lb1).second;
-
-			//	Begin of iteration v0.
-			it0	=	lb0;
-
-			edge_found	=	false;
-
-			//	Remaining vertex.
-			while (it0 != ub0)
-			{
-				//	Real index.
-				v0	=	(*it0).second;
-
-				//	If edge exists.
-				if (mEdges->exists(v0,v1))
-				{
-					mEdges->contract(v1,v0);
-
-					//	Simplification sequence.
-					current_step.mV0	=	v0;
-					current_step.mV1	=	v1;
-
-					real_seq->mSteps.push_back(current_step);
-
-					edge_found	=	true;
-				}
-
-				it0++;
-			}
-
-			//	If not found a valid edge.
-			if (!edge_found)
-			{
-				//	Id new vertex.
-				new_vertex.id					=	vertex_count;
-				new_vertex.bonefrom		=	v0;
-
-				//	Simplification sequence.
-				current_step.mV0	=	new_vertex.id;
-				current_step.mV1	=	v1;
-
-				real_seq->mSteps.push_back(current_step);
-
-				//	Contracts lonely vertex.
-				mEdges->contract(v1,new_vertex.id);
-
-				//	New vertex adquires position of v0.
-				new_vertex.position.x	=	mGeoMesh->mVertexBuffer->mPosition[v0].x;
-				new_vertex.position.y	=	mGeoMesh->mVertexBuffer->mPosition[v0].y;
-				new_vertex.position.z	=	mGeoMesh->mVertexBuffer->mPosition[v0].z;
-
-				//	New vertex adquires normal of lonely one.
-				new_vertex.normal.x	=	mGeoMesh->mVertexBuffer->mNormal[v1].x;
-				new_vertex.normal.y	=	mGeoMesh->mVertexBuffer->mNormal[v1].y;
-				new_vertex.normal.z	=	mGeoMesh->mVertexBuffer->mNormal[v1].z;
-
-				//	New vertex adquires the texture cood of the lonely one.
-				new_vertex.texcoord.x	=	mGeoMesh->mVertexBuffer->mTexCoords[v1].x;
-				new_vertex.texcoord.y	=	mGeoMesh->mVertexBuffer->mTexCoords[v1].y;
-
-				//	New vertex stored.
-				real_seq->mNewVertices.push_back(new_vertex);
-
-				//	New vertex added.
-				vertex_count++;
-			}
-
-			lb1++;
-		}
-	}
-
-	//	Assigns new simplification sequence.
-	delete	simpseq;
-
-	return	real_seq;
-	/*
-	//	New vertex buffer to add new vertices.
-	mVB	=	new VertexBuffer();
-
-	mVB->mPosition	=	new Vector3[vertex_count];
-	mVB->mNormal		=	new Vector3[vertex_count];
-	mVB->mTexCoords	=	new Vector2[vertex_count];
-
-	mVB->mVertexInfo	=	mGeoMesh->mVertexBuffer->mVertexInfo;
-
-	//	Copy original vertices.
-	for (i = 0; i < mGeoMesh->mVertexBuffer->mVertexCount; i++)
-	{
-		mVB->mPosition[i].x	=	mGeoMesh->mVertexBuffer->mPosition[i].x;
-		mVB->mPosition[i].y	=	mGeoMesh->mVertexBuffer->mPosition[i].y;
-		mVB->mPosition[i].z	=	mGeoMesh->mVertexBuffer->mPosition[i].z;
-
-		mVB->mNormal[i].x	=	mGeoMesh->mVertexBuffer->mNormal[i].x;
-		mVB->mNormal[i].y	=	mGeoMesh->mVertexBuffer->mNormal[i].y;
-		mVB->mNormal[i].z	=	mGeoMesh->mVertexBuffer->mNormal[i].z;
-
-		mVB->mTexCoords[i].x	=	mGeoMesh->mVertexBuffer->mTexCoords[i].x;
-		mVB->mTexCoords[i].y	=	mGeoMesh->mVertexBuffer->mTexCoords[i].y;
-	}
-
-	//	Add new vertices.
-	j	=	mGeoMesh->mVertexBuffer->mVertexCount;
-
-	for (i = 0; i < new_vertices.size(); i++)
-	{
-		mVB->mPosition[j].x	=	new_vertices[i].position.x;
-		mVB->mPosition[j].y	=	new_vertices[i].position.y;
-		mVB->mPosition[j].z	=	new_vertices[i].position.z;
-
-		mVB->mNormal[j].x	=	new_vertices[i].normal.x;
-		mVB->mNormal[j].y	=	new_vertices[i].normal.y;
-		mVB->mNormal[j].z	=	new_vertices[i].normal.z;
-
-		mVB->mTexCoords[j].x	=	new_vertices[i].texcoord.x;
-		mVB->mTexCoords[j].y	=	new_vertices[i].texcoord.y;
-	}
-
-	//	Free memory.
-	delete	[]mGeoMesh->mVertexBuffer;
-
-	//	Reassigns main vertex buffer with new vertices.
-	mGeoMesh->mVertexBuffer	= mVB;
-
-	//	Reassign submesh vertex buffers.
-	for (i = 0; i < mGeoMesh->mSubMeshCount; i++)
-	{
-		mGeoMesh->mSubMesh[i].mVertexBuffer	=	mVB;
-	}
-	*/
-}
-
-//-------------------------------------------------------------------------
 //	Return	mesh that may have repeated vertices for texture aparence.
 //-------------------------------------------------------------------------
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp	(revision 1526)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp	(revision 2127)
@@ -1,12 +1,12 @@
-/*==========================================================================
+/*========================================================================
  *	(C) 2005 Universitat Jaume I
- *==========================================================================
+ *========================================================================
  *	PROYECT:	GAME TOOLS
- *==========================================================================*/
+ *========================================================================*/
 /*	CONTENT:	
  *
  *
  *	@file	GeoMeshLoader.cpp
- *==========================================================================*/
+ *========================================================================*/
 
 #include	"GeoMeshLoader.h"
@@ -18,7 +18,7 @@
 using	namespace	std;
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Jump a chunk.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::jumpChunk(FILE	*f)
 {
@@ -29,7 +29,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a chunk.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 unsigned short GeoMeshLoader::readChunk(FILE	*f)
 {
@@ -42,7 +42,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read geometry vertex element.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readGeometryVertexElement(FILE	*f, Mesh	*geoMesh)
 {
@@ -112,7 +112,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read geometry vertex declaration.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readGeometryVertexDeclaration(FILE	*f, Mesh	*geoMesh)
 {
@@ -154,8 +154,10 @@
 }//	End readGeometryVertexDeclaration.
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read geometry vertex buffer.
-//---------------------------------------------------------------------------
-void GeoMeshLoader::readGeometryVertexBuffer(FILE	*f, Mesh	*geoMesh, int option)
+//-------------------------------------------------------------------------
+void GeoMeshLoader::readGeometryVertexBuffer(	FILE	*f,
+																							Mesh	*geoMesh,
+																							int option)
 {
 	unsigned	short	bindIndex;
@@ -287,10 +289,9 @@
 		mError	=	true;
 	}
-
-}
-
-//---------------------------------------------------------------------------
+}
+
+//-------------------------------------------------------------------------
 //	Read Geometry.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readGeometry(FILE	*f, Mesh	*geoMesh, int option)
 {
@@ -379,7 +380,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a submesh operation.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readSubMeshOperation(	FILE	*f,
 																					Mesh	*geoMesh,
@@ -403,7 +404,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a submesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readSubMesh(FILE	*f, Mesh	*geoMesh, int option)
 {
@@ -563,7 +564,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a mesh lod information.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readMeshLodInfo(FILE	*f, Mesh	*geoMesh)
 {
@@ -600,7 +601,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a submesh name table.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readSubMeshNameTable(FILE	*f, Mesh	*geoMesh)
 {
@@ -639,7 +640,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read a mesh file.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 
 #include "GeoLodStripsLibrary.h"
@@ -869,7 +870,7 @@
 
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Allocate memory to the array of strips
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh)
 {
@@ -969,7 +970,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Remove degenerate triangles of a submesh given.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 SubMesh	*	GeoMeshLoader::removeDegenerateTriangles(SubMesh	*geoSubMesh)
 {
@@ -1074,7 +1075,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Loads a mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 Mesh* GeoMeshLoader::load(char	*nameFileMesh) 
 {
@@ -1083,5 +1084,5 @@
 	char		version[255];
 	FILE		*pFile;
-	SubMesh		*geosubmesh;
+	SubMesh	*geosubmesh;
 
 	//	Debug.
@@ -1106,11 +1107,18 @@
 	
 	geoMesh	=	NULL;
+
 	if (lodstripsdata)
+	{
 		delete lodstripsdata;
-	lodstripsdata=NULL;
+	}
+
+	lodstripsdata	=	NULL;
 
 	if (treesimpseq)
+	{
 		delete treesimpseq;
-	treesimpseq=NULL;
+	}
+
+	treesimpseq	=	NULL;
 
 	//	Open the mesh file.
@@ -1125,5 +1133,5 @@
 		geoMesh	=	new	Mesh();
 
-		if (fileExt==std::string("OBJ"))
+		if (fileExt == std::string("OBJ"))
 		{
 			mError	=	false;
@@ -1155,16 +1163,4 @@
 
 				cout	<<	version	<<	endl;
-
-				/*if (strcmp(version,"[MeshSerializer_v1.30]\n"))
-				{
-					//	Debug.
-					cout	<<	"Error: Wrong mesh version."
-						<<	endl
-						<<	"Only version 1.3 or older allowed."
-						<<	endl;
-
-					//	Error.
-					mError	=	true;
-				}*/
 
 				while(!feof(pFile))
@@ -1240,7 +1236,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Sets coords between -1 and 1.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshLoader::normalizeModel(Mesh	*geoMesh)
 {
@@ -1390,7 +1386,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Get the size in bytes of the file.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshLoader::getFileSize()
 {
@@ -1398,7 +1394,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Constructor
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 GeoMeshLoader::GeoMeshLoader()
 {
@@ -1409,7 +1405,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Destroyer.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 GeoMeshLoader::~GeoMeshLoader()
 {
@@ -1430,7 +1426,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read bones of the submesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readSubMeshBoneAssignment(FILE		*f,
 																							SubMesh	*geoSubMesh,
@@ -1452,7 +1448,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read bones of the main mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readMeshBoneAssignment(FILE	*f, Mesh	*geoMesh,	int option)
 {
@@ -1472,7 +1468,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read skeleton link.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshLoader::readSkeletonLink(FILE	*f, Mesh	*geoMesh,	int option)
 {
@@ -1490,7 +1486,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Read bounding box settings.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshLoader::readMeshBounds(FILE	*f, Mesh	*geoMesh,	int	option)
 {
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp	(revision 2079)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp	(revision 2127)
@@ -289,5 +289,4 @@
 {
 	unsigned long int i;
-	unsigned long int j;
 	unsigned long int t;
 	unsigned long int v;
@@ -301,5 +300,4 @@
 
 	tipoOrden			Orden;
-	tipoOrden			*Ord;
 	bool					bEncontrado;
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp	(revision 1526)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp	(revision 2127)
@@ -1,12 +1,12 @@
-/*==========================================================================
+/*========================================================================
  *	(C) 2005 Universitat Jaume I
- *==========================================================================
+ *========================================================================
  *	PROYECT:	GAME TOOLS
- *==========================================================================*/
+ *=======================================================================*/
 /*	CONTENT:	
  *
  *
  *	@file	GeoMeshSaver.cpp
- *==========================================================================*/
+ *=======================================================================*/
 #include	<GeoMeshSaver.h>
 
@@ -14,11 +14,11 @@
 using	namespace	std;
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //		Public:
-//---------------------------------------------------------------------------
-
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+
+//-------------------------------------------------------------------------
 //	Constructors.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 GeoMeshSaver::GeoMeshSaver()
 {
@@ -29,7 +29,7 @@
 }
 
-//---------------------------------------------------------------------------
-//	Destroyer.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+//	Destructor.
+//-------------------------------------------------------------------------
 GeoMeshSaver::~GeoMeshSaver()
 {
@@ -37,7 +37,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Saves a Mesh into a file.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshSaver::save(Mesh	*geoMesh,	const	char	*fileNameMesh)
 {
@@ -147,9 +147,11 @@
 }
 
-//------------------------------------------
+//-------------------------------------------------------------------------
 //		Private:
-//------------------------------------------
-
+//-------------------------------------------------------------------------
+
+//-------------------------------------------------------------------------
 //	Write the main mesh.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeMesh(Mesh	*geoMesh)
 {
@@ -226,5 +228,7 @@
 }//	End write mesh.
 
+//-------------------------------------------------------------------------
 //	Write a submesh.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeSubMesh(SubMesh	*geoSubMesh)
 {
@@ -345,5 +349,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write the submesh operation chunk and data.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeSubMeshOperation(const	SubMesh	*geoSubMesh)
 {
@@ -374,5 +380,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write geometry.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeGeometry(VertexBuffer	*vertexBuffer)
 {
@@ -581,5 +589,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write Mesh Bounds.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeMeshBounds(Mesh	*geoMesh)
 {
@@ -605,5 +615,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Calculate the mesh size in bytes.
+//-------------------------------------------------------------------------
 size_t GeoMeshSaver::calcMeshSize(const Mesh	*geoMesh)
 {
@@ -650,5 +662,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Calc the size in bytes for the submesh.
+//-------------------------------------------------------------------------
 size_t GeoMeshSaver::calcSubMeshSize(const SubMesh	*geoSubMesh)
 {
@@ -677,5 +691,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Calculate the geometry size in bytes.
+//-------------------------------------------------------------------------
 size_t GeoMeshSaver::calcGeometrySize(const VertexBuffer* vertexBuffer)
 {
@@ -709,5 +725,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Calculate the skeleton link size in bytes.
+//-------------------------------------------------------------------------
 size_t	GeoMeshSaver::calcSkeletonLinkSize(const Mesh	*geoMesh)
 {
@@ -723,5 +741,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write the file header.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeFileHeader(void)
 {
@@ -734,5 +754,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write a header chunk given.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeChunkHeader(unsigned short	id,
 																		unsigned long		size)
@@ -742,5 +764,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write integers into the file.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeInts(unsigned long	id,
 															unsigned long	count)
@@ -749,5 +773,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write shorts into the file
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeShorts(unsigned short	id,
 																unsigned long		count)
@@ -756,5 +782,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write float into the file.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeFloats(float						id,
 																unsigned long		count)
@@ -763,5 +791,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write a string into the file.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeString(const	String	&string)
 {
@@ -769,5 +799,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	Write booleans into the file.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::writeBools(	const bool id,
 																unsigned	long		count)
@@ -776,4 +808,7 @@
 }
 
+//-------------------------------------------------------------------------
+//	Write skeleton filename.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeSkeletonLink(const String& skelName)
 {	
@@ -788,4 +823,7 @@
 }
 
+//-------------------------------------------------------------------------
+//	Write bones assignmets.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeMeshBoneAssignment(const VertexBoneAssignment& assign)
 {
@@ -802,4 +840,7 @@
 }
 
+//-------------------------------------------------------------------------
+//	Write bones assignmets.
+//-------------------------------------------------------------------------
 void GeoMeshSaver::writeSubMeshBoneAssignment(const VertexBoneAssignment& assign)
 {
@@ -816,5 +857,7 @@
 }
 
+//-------------------------------------------------------------------------
 //	unnormalize geometry model.
+//-------------------------------------------------------------------------
 void	GeoMeshSaver::unnormalizeModel(Mesh	*geoMesh)
 {
@@ -859,5 +902,5 @@
 			continue;
 		}
-			
+
 		//	For each index of the strip.
 		for (size_t i = 0; i < vertex_buffer->mVertexCount; i++)
Index: GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h	(revision 2127)
@@ -215,4 +215,8 @@
 	inline void cb_menuRenderTextures_i(fltk::Item*, void*);
 	static void cb_menuRenderTextures(fltk::Item*, void*);
+	inline void cb_menuRenderBoundingBox_i(fltk::Item*, void*);
+	static void cb_menuRenderBoundingBox(fltk::Item*, void*);
+	inline void cb_menuRenderAxes_i(fltk::Item*, void*);
+	static void cb_menuRenderAxes(fltk::Item*, void*);
 	inline void cb_menuStripify_i(fltk::Item*, void*);
 	static void cb_menuStripify(fltk::Item*, void*);
Index: GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h	(revision 2127)
@@ -37,4 +37,6 @@
 	bool		mCW;
 	bool		mCCW;
+	bool		mBBox;
+	bool		mAxes;
 	bool		mPan;
 	bool		mRotate;
@@ -116,4 +118,12 @@
 	void	activeRotate(){mRotate	=	true;}
 	void	deactiveRotate(){mRotate	=	false;}
+
+	//	Counter Clockwise mode.
+	void	activeAxes(){mAxes	=	true;}
+	void	deactiveAxes(){mAxes	=	false;}
+
+	//	Counter Clockwise mode.
+	void	activeBoundingBox(){mBBox	=	true;}
+	void	deactiveBoundingBox(){mBBox	=	false;}
 
 	//	LodStrip mode.
@@ -170,7 +180,4 @@
 	void draw();
 
-	//	Gets the bounding box.
-	//Geometry::GeometryBounds	getBoundingBox();
-
 	//	Store one random color to each strip.
 	void	setStripColors();
@@ -211,4 +218,10 @@
 	int findLeavesSubMesh(void);
 
+	//	Draw coordinates axes.
+	void	drawAxes();
+
+	//	Draw bounding box.
+	void	drawBoundingBox();
+
 	private:
 	/* Draw the cube boundaries
@@ -242,4 +255,11 @@
 	float		zMed;
 
+	float		xMax;
+	float		yMax;
+	float		zMax;
+	float		xMin;
+	float		yMin;
+	float		zMin;
+
 	int			leavesSubMesh;
 	
@@ -257,4 +277,7 @@
 
 	virtual	int	handle(int event);
+
+	//	Gets the bounding box.
+	void	getBoundingBox();
 
 	//	Paint the mesh object.
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 2103)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 2127)
@@ -653,4 +653,58 @@
 										->
 										cb_menuRenderTextures_i(o,v);
+}
+
+//-------------------------------------------------------------------------
+//	Bounding Box callback
+//-------------------------------------------------------------------------
+inline void GeoMeshViewUI::cb_menuRenderBoundingBox_i(fltk::Item	*item,
+																											void	*v)
+{
+	//	If the item is activated.
+	if (item->value())
+	{
+		geoMeshView->activeBoundingBox();
+	}
+	else
+	{
+		geoMeshView->deactiveBoundingBox();
+	}
+
+	//	Repaint the main window.
+	mMainWindow->redraw();
+}
+
+void GeoMeshViewUI::cb_menuRenderBoundingBox(fltk::Item* o, void* v)
+{
+  ((GeoMeshViewUI*)	(o->parent()->parent()->parent()->user_data()))
+										->
+										cb_menuRenderBoundingBox_i(o,v);
+}
+
+//-------------------------------------------------------------------------
+//	Axes callback
+//-------------------------------------------------------------------------
+inline void GeoMeshViewUI::cb_menuRenderAxes_i(fltk::Item	*item,
+																											void	*v)
+{
+	//	If the item is activated.
+	if (item->value())
+	{
+		geoMeshView->activeAxes();
+	}
+	else
+	{
+		geoMeshView->deactiveAxes();
+	}
+
+	//	Repaint the main window.
+	mMainWindow->redraw();
+}
+
+void GeoMeshViewUI::cb_menuRenderAxes(fltk::Item* o, void* v)
+{
+  ((GeoMeshViewUI*)	(o->parent()->parent()->parent()->user_data()))
+										->
+										cb_menuRenderAxes_i(o,v);
 }
 
@@ -2468,5 +2522,8 @@
 	static	char			title[256];
 	
-	fcho	=	new fltk::FileChooser("", "*.{mesh,obj}", fltk::FileChooser::CREATE, "Open a mesh");
+	fcho	=	new fltk::FileChooser("",
+																"*.{mesh,obj}",
+																fltk::FileChooser::CREATE,
+																"Open a mesh");
 
 	fcho->exec();
@@ -2560,4 +2617,5 @@
 		}
 	}
+
 	//	Free memory.
 	delete	fcho;
@@ -2993,8 +3051,24 @@
 
 				{
-					fltk::Item* o = menuRenderTextures = new fltk::Item("Texture mapping");
+					fltk::Item* o = new fltk::Item("Texture mapping");
 					o->type(fltk::Item::RADIO);
 					o->set_value();
 					o->callback((fltk::Callback*)cb_menuRenderTextures);
+				}
+
+				new fltk::Divider();
+
+				{
+					fltk::Item* o =	new fltk::Item("Axis");
+					o->type(fltk::Item::RADIO);
+					o->set_value();
+					o->callback((fltk::Callback*)cb_menuRenderAxes);
+				}
+
+				{
+					fltk::Item* o =	new fltk::Item("Bounding Box");
+					o->type(fltk::Item::RADIO);
+					o->set_value();
+					o->callback((fltk::Callback*)cb_menuRenderBoundingBox);
 				}
 
@@ -3141,5 +3215,5 @@
 GeoMeshViewUI::~GeoMeshViewUI()
 {
-	delete	geoMeshLoader;
+	//delete	geoMeshLoader;
 	mMainWindow->destroy();
 }
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp	(revision 2127)
@@ -5,7 +5,7 @@
 using	namespace	std;
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Handle events.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 int	GeoMeshView::handle(int event)
 {
@@ -33,12 +33,13 @@
 		case	fltk::DRAG:
 			
-			button	=	fltk::event_state();
+			button	=	fltk::event_key();
 			x				=	fltk::event_x();
 			y				=	fltk::event_y();
 			
+
 			switch (button)
 			{
 				//	Button 1 Pushed.
-				case	0x01100000:
+				case	1:
 			
 					if (x > mMouseX)
@@ -104,5 +105,7 @@
 					return	1;
 				
-				case	0x04100000:
+				//	Button 3 pushed.
+				case	2:
+				case	3:
 
 					if (y	> mSizeY)
@@ -124,5 +127,5 @@
 					return 1;
 
-			}			
+			}
 			
 		case	fltk::MOUSEWHEEL:
@@ -172,7 +175,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Enable color strips.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::enableColorStrips()
 {
@@ -180,7 +183,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Disable color strips.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::disableColorStrips()
 {
@@ -188,7 +191,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Gets the color strips state.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 bool	GeoMeshView::getColorStrips()
 {
@@ -196,7 +199,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Set the color to the submesh sumbmeshIndex
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::setSubMeshSelected(int submeshIndex)
 {
@@ -204,7 +207,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Sets the leaves submesh index.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::setLeavesSubMesh(int submeshIndex)
 {
@@ -212,7 +215,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Gets the leaves submesh index.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 int	GeoMeshView::getLeavesSubMesh()
 {
@@ -220,7 +223,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Set the list of strip colors.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::setStripColors()
 {
@@ -253,9 +256,8 @@
 		}
 	}
-
 	
 	//	Sets random colors to each strip.
 	for (int submesh	= 0; submesh < geoMesh->mSubMeshCount; submesh++)
-	{
+	{	
 		//	Gets the actual submesh.
 		geosubmesh	=	&geoMesh->mSubMesh[submesh];
@@ -265,7 +267,7 @@
 			for	(int strip = 0; strip	<	geosubmesh->mStripCount; strip++)
 			{
-				mStripColors[submesh][strip].r	=	rand()/((float)RAND_MAX);
-				mStripColors[submesh][strip].g	=	rand()/((float)RAND_MAX);
-				mStripColors[submesh][strip].b	=	rand()/((float)RAND_MAX);
+				mStripColors[submesh][strip].r	=	(0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX);
+				mStripColors[submesh][strip].g	=	(0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX);
+				mStripColors[submesh][strip].b	=	(0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX);
 			}
 		}
@@ -276,119 +278,45 @@
 }
 
-/*
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Get the bounding box of the object.
-//---------------------------------------------------------------------------
-GeometryBounds	GeoMeshView::getBoundingBox()
-{
-	SubMesh					*geosubmesh;
-	Index						position;
-	Vector3					vector3;
-	GeometryBounds	bounds;
-	float						x,y,z;
-	float						xMin,yMin,zMin;
-	float						xMax,yMax,zMax;
-		
-	//	For each submesh.
-	for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
-	{
-		//	Gets the actual submesh.
-		geosubmesh	=	&geoMesh->mSubMesh[submesh];
-
-		//	For each index of the strip.
-		for (int index = 0; index < geosubmesh->mIndexCount; index++)
-		{
-			position	=	geosubmesh->mIndex[index];
-
-			//	Gets the vertex coordinates.
-			vector3	=	geosubmesh->mVertexBuffer->mPosition[position];
-				
-			x					=	vector3[0];
-			y					=	vector3[1];
-			z					=	vector3[2];
-				
-			//	If is the first iteation.
-			if ((submesh	== 0)	&&	(index	==	0))
-			{
-				xMin	=	xMax	=	x;
-				yMin	=	yMax	=	y;
-				zMin	=	zMax	=	z;
-			}
-			else
-			{
-				if (x < xMin)
-				{
-					xMin	=	x;
-				}
-				else if (x > xMax)
-				{
-					xMax	=	x;
-				}
-
-				if (y < yMin)
-				{
-					yMin	=	y;
-				}
-				else if (y > yMax)
-				{
-					yMax	=	y;
-				}
-
-				if (z < zMin)
-				{
-					zMin	=	z;
-				}
-				else if (z > zMax)
-				{
-					zMax	=	z;
-				}
-			}
-		}
-	}
-
-	xMed	=	(xMax + xMin)	/	2;
-	yMed	=	(yMax + yMin)	/	2;
-	zMed	=	(zMax + zMin)	/	2;
-
-
-	if ((xMax - xMin) > (yMax - yMin))
-	{
-		if ((xMax - xMin) > (zMax - zMin))
-		{
-			mScaleFactor	=	xMax - xMin;
-		}
-		else
-		{
-			mScaleFactor	=	zMax - zMin;
-		}
-	}
-	else
-	{
-		if ((yMax - yMin) > (zMax - zMin))
-		{
-			mScaleFactor	=	yMax - yMin;
-		}
-		else
-		{
-			mScaleFactor	=	zMax - zMin;
-		}
-	}
-
-	//	Set the bounds.
-	bounds.minx		=	xMin;
-	bounds.miny		=	yMin;
-	bounds.minz		=	zMin;
-	bounds.maxx		=	xMax;
-	bounds.maxy		=	yMax;
-	bounds.maxz		=	zMax;
-	bounds.radius	=	mScaleFactor;
-
-	return	bounds;
-}
-*/
-
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+void	GeoMeshView::getBoundingBox()
+{
+	float	cx;
+	float	cy;
+	float	cz;
+	float	scale;
+
+	xMax	=	geoMesh->mMeshBounds.maxX;
+	yMax	=	geoMesh->mMeshBounds.maxY;
+	zMax	=	geoMesh->mMeshBounds.maxZ;
+	xMin	=	geoMesh->mMeshBounds.minX;
+	yMin	=	geoMesh->mMeshBounds.minY;
+	zMin	=	geoMesh->mMeshBounds.minZ;
+	scale	=	geoMesh->mMeshBounds.scaleFactor;
+	
+	//	Calculate center of the model.
+	cx = (xMax + xMin) / 2.0f;
+	cy = (yMax + yMin) / 2.0f;
+	cz = (zMax + zMin) / 2.0f;
+
+	xMax	-=	cx;
+	yMax	-=	cy;
+	zMax	-=	cz;
+	xMin	-=	cx;
+	yMin	-=	cy;
+	zMin	-=	cz;
+
+	xMax	*=	scale;
+	yMax	*=	scale;
+	zMax	*=	scale;
+	xMin	*=	scale;
+	yMin	*=	scale;
+	zMin	*=	scale;
+}
+
+//-------------------------------------------------------------------------
 //	Constructor.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 GeoMeshView::GeoMeshView(	int						x,
 													int						y,
@@ -446,7 +374,7 @@
 #define ALPHA 0.5
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Sets the Mesh to display.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::setMesh(Mesh	*geomesh)
 {
@@ -458,4 +386,7 @@
 	mScaleFactor			=	geomesh->mMeshBounds.scaleFactor;
 	
+	//	Gets boundings of mesh.
+	getBoundingBox();
+
 	//	Refresh vertices to the vertex array.
 	refreshVertices(geomesh);
@@ -478,7 +409,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	 Refresh vertices to the vertex array.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::refreshVertices(Mesh	*geomesh)
 {
@@ -603,7 +534,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Gets the triangle count of the current lod.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshView::getLodStripsTriangleCount()
 {
@@ -618,7 +549,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Repaint the Mesh.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::drawGeoMesh(bool	paintWire)
 {
@@ -667,7 +598,7 @@
 }//	End drawGeoMesh.
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Paint eah strip separately.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::drawTriangleStrip(int submesh)
 {
@@ -745,5 +676,4 @@
 		}
 
-
 		//VERTEX ARRAYS
 		glEnableClientState(GL_VERTEX_ARRAY);
@@ -780,7 +710,7 @@
 }//End drawTriangleStrip.
 
-//---------------------------------------------------------------------------
-//	Paint the array of idices.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+//	Paint the array of indices.
+//-------------------------------------------------------------------------
 void GeoMeshView::drawTriangleList(	int			submesh,
 																		bool 		selectedSubMesh,
@@ -895,7 +825,7 @@
 }//End drawTriangleList
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Paint lodstrip object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::drawLodStrip()
 {
@@ -970,7 +900,7 @@
 }//End drawTriangleStrip.
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Paint lodtree object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::drawLodTree()
 {
@@ -1090,7 +1020,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Sets the lodstripslibrary object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::setLodStripsLibrary(LodStripsLibrary *lodstrips)
 {
@@ -1099,7 +1029,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Sets the lodtreeslibrary object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees)
 {
@@ -1108,7 +1038,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Change de Level of detail of the object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::GoToLod_LodStrip(float	lod)
 {
@@ -1126,7 +1056,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Change de Level of detail of the object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshView::GoToLod_LodTree(float	lod)
 {
@@ -1139,7 +1069,104 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+//	Draw axes.
+//-------------------------------------------------------------------------
+void	GeoMeshView::drawAxes()
+{
+	float	max;
+
+	max	=	xMax;
+
+	if (yMax > max)
+	{
+		max = yMax;
+	}
+
+	if (zMax > max)
+	{
+		max = zMax;
+	}
+
+	glDisable(GL_LIGHTING);
+	glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+	glDisable(GL_CULL_FACE);
+
+	//	Set white color to the object.
+	glColor3d(1.0, 0.0, 0.0);
+
+	//	X axis.
+	glBegin(GL_LINES);
+	glVertex3f(0.0f,0.0f,0.0f);
+	glVertex3f(max,0.0f,0.0f);
+	glEnd();
+
+	//	Set white color to the object.
+	glColor3d(0.0, 1.0, 0.0);
+
+	//	Y axis.
+	glBegin(GL_LINES);
+	glVertex3f(0.0f,0.0f,0.0f);
+	glVertex3f(0.0f,max,0.0f);
+	glEnd();
+
+	//	Set white color to the object.
+	glColor3d(0.0, 0.0, 1.0);
+
+	//	Z axis.
+	glBegin(GL_LINES);
+	glVertex3f(0.0f,0.0f,0.0f);
+	glVertex3f(0.0f,0.0f,max);
+	glEnd();
+}
+
+//-------------------------------------------------------------------------
+//	Draw bounding box.
+//-------------------------------------------------------------------------
+void	GeoMeshView::drawBoundingBox()
+{
+	glDisable(GL_LIGHTING);
+	glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+	glDisable(GL_CULL_FACE);
+
+	//	Set white color to the object.
+	glColor3d(0.0, 0.0, 0.0);
+
+	glBegin(GL_QUADS);
+	glVertex3f(xMin,yMin,zMin);
+	glVertex3f(xMin,yMax,zMin);
+	glVertex3f(xMax,yMax,zMin);
+	glVertex3f(xMax,yMin,zMin);
+
+	glVertex3f(xMin,yMin,zMin);
+	glVertex3f(xMin,yMax,zMin);
+	glVertex3f(xMin,yMax,zMax);
+	glVertex3f(xMin,yMin,zMax);
+
+	glVertex3f(xMax,yMin,zMin);
+	glVertex3f(xMax,yMax,zMin);
+	glVertex3f(xMax,yMax,zMax);
+	glVertex3f(xMax,yMin,zMax);
+
+	glVertex3f(xMax,yMin,zMax);
+	glVertex3f(xMax,yMax,zMax);
+	glVertex3f(xMin,yMax,zMax);
+	glVertex3f(xMin,yMin,zMax);
+
+	glVertex3f(xMin,yMin,zMax);
+	glVertex3f(xMax,yMin,zMax);
+	glVertex3f(xMax,yMin,zMin);
+	glVertex3f(xMin,yMin,zMin);
+
+	glVertex3f(xMin,yMax,zMax);
+	glVertex3f(xMax,yMax,zMax);
+	glVertex3f(xMax,yMax,zMin);
+	glVertex3f(xMin,yMax,zMin);
+
+	glEnd();
+}
+
+//-------------------------------------------------------------------------
 //	Draw the object in the window.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void GeoMeshView::draw()
 {
@@ -1182,13 +1209,34 @@
 	//glTranslatef(-xMed,-yMed,-zMed);
 
+	GLfloat color_blanco[]	=	{1.0f,1.0f,1.0f,1.0f};
+
+	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco);
+
+	glClearColor(0.3,0.3,0.3,0);
+	
+	if ((geoMesh != NULL) && mAxes)
+	{
+		//	Draw coordinates axes.
+		drawAxes();
+	}
+
+	if ((geoMesh != NULL) && mBBox)
+	{
+		//	Draw bounding box.
+		drawBoundingBox();
+	}
+
 	//	Set white color to the object.
 	glColor3d(1.0, 1.0, 1.0);
 
-	GLfloat color_blanco[]	=	{1.0f,1.0f,1.0f,1.0f};
-
-	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco);
-
-	glClearColor(0.3,0.3,0.3,0);
-	
+	if (mLighting)
+	{
+		glEnable(GL_LIGHTING);
+	}
+	else
+	{
+		glDisable(GL_LIGHTING);
+	}
+
 	if (mCW)
 	{
@@ -1214,13 +1262,4 @@
 		glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
 		drawGeoMesh(false);
-	}
-
-	if (mLighting)
-	{
-		glEnable(GL_LIGHTING);
-	}
-	else
-	{
-		glDisable(GL_LIGHTING);
 	}
 
@@ -1264,7 +1303,4 @@
 
 	swap_buffers();
-
-	//	Calculate the FPS.
-	//calcFPS();
 }
 
