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 983)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp	(revision 2090)
@@ -23,30 +23,41 @@
 
 void VMI::computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras) {
-    GLuint i = 0;
-    double sal;
-    
-    maxSal = minSal = computeTriangleSaliency(mesh, histogram, numCameras, 0);
-
-    mesh->triangles[0].saliency = maxSal;
-
-    for (i=1; i<mesh->numTriangles; i++) {
-
-        sal = computeTriangleSaliency(mesh, histogram, numCameras, i);
-
-        if (sal > maxSal) maxSal = sal;
-        if (sal < minSal) minSal = sal;
-        
-        mesh->triangles[i].saliency = sal;
-    }
-
-    printf("\nMax Sal: %f  Min Sal: %f\n", maxSal, minSal);
-
-    percentile = computePercentile(alpha, mesh->triangles, mesh->numTriangles);
-    printf("\n%dth percentile: %f\n", alpha, percentile);
+	GLuint i = 0;
+	double sal;
+
+	maxSal = minSal = computeTriangleSaliency(mesh, histogram, numCameras, 0);
+
+	mesh->triangles[0].saliency = maxSal;
+
+	for (i=1; i<mesh->numTriangles; i++) {
+
+		sal = computeTriangleSaliency(mesh, histogram, numCameras, i);
+
+		if (sal > maxSal) maxSal = sal;
+		if (sal < minSal) minSal = sal;
+
+		mesh->triangles[i].saliency = sal;
+	}
+
+	printf("\nMax Sal: %f  Min Sal: %f\n", maxSal, minSal);
+
+	percentile = computePercentile(alpha, mesh->triangles, mesh->numTriangles);
+	printf("\n%dth percentile: %f\n", alpha, percentile);
+}
+
+void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v) {
+	int i, t;
+
+	for(i=0; i<(int)mesh->vertices[v].numTriangles; i++) {
+
+		t = mesh->vertices[v].triangles[i];
+
+		mesh->triangles[t].saliency = computeTriangleSaliency(mesh, histogram, numCameras, t);
+	}
 }
 
 double VMI::computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k) {
-    GLuint i, l, v0, v1, v2;
-    int triangles[MAX_NUM_TRI], n = 0;
+     GLuint i, l, v0, v1, v2;
+    int *triangles = NULL, n = 0;
     double sal = 0.0;
     
@@ -55,4 +66,9 @@
     v2 = mesh->triangles[k].indices[2];
     
+    /* Allocating memory */
+    triangles = (int *)malloc((mesh->vertices[v0].numTriangles +
+                               mesh->vertices[v1].numTriangles +
+                               mesh->vertices[v2].numTriangles) * sizeof(int));
+
     for(i=0; i<mesh->vertices[v0].numTriangles; i++) {
         l = mesh->vertices[v0].triangles[i];
@@ -86,4 +102,6 @@
     //getchar();
     
+    free(triangles);
+
     return (sal /*/ n*/);
 }
@@ -150,5 +168,6 @@
     if((fp= fopen(filename, "rt"))== NULL) {
         printf("Can't open file %s\n", filename);
-        exit(1);
+				getchar();
+				exit(1);
     }
 
@@ -219,35 +238,37 @@
 void VMI::computeRGB(double min, double max,double value,float *r,float *g,float *b)
 {
-    //Dados el valor máximo, el mínimo y el valor que le quieres calcular el color te devuelve el respectivo RGB.
-    if(value>max) value=max;
-    if(value<min) value=min;
-    
-    if(max==min) value=1;
-    else value=(float)(value-min)/(float)(max-min);
-    
-    if (value<=0.25)
-    {
-        (*r)=0;
-        (*g)=4*value;
-        (*b)=1;
-    }
-    else if (value<=0.50)
-    {
-        (*r)=0;
-        (*g)=1;
-        (*b)=2-4*value;
-    }
-    else if (value<=0.75)
-    {
-        (*r)=4*value-2;
-        (*g)=1;
-        (*b)=0;
-    }
-    else
-    {
-        (*r)=1;
-        (*g)=4-4*value;
-        (*b)=0;
-    }
+	/* Given the maximum, the minimum value and the demanded color value returns
+	 * the respective RGB color
+	 */
+	if(value>max) value=max;
+	if(value<min) value=min;
+
+	if(max==min) value=1;
+	else value=(float)(value-min)/(float)(max-min);
+
+	if (value<=0.25)
+	{
+		(*r)=0;
+		(*g)=4*value;
+		(*b)=1;
+	}
+	else if (value<=0.50)
+	{
+		(*r)=0;
+		(*g)=1;
+		(*b)=2-4*value;
+	}
+	else if (value<=0.75)
+	{
+		(*r)=4*value-2;
+		(*g)=1;
+		(*b)=0;
+	}
+	else
+	{
+		(*r)=1;
+		(*g)=4-4*value;
+		(*b)=0;
+	}
 }
 
