Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/include/leaf.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/include/leaf.h	(revision 1019)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/include/leaf.h	(revision 1019)
@@ -0,0 +1,38 @@
+#ifndef LEAF_H
+#define LEAF_H
+
+class Leaf
+{
+	public :
+    	int  vertsLeaf[4];// Array of pointers to vertices
+		float  normal[3];
+		float  parentLeafCount;
+		float center[3];
+		int parent;
+		int childLeft;
+		int childRight;
+		int visible;
+		int root;
+
+		bool exists;
+		int leafNear;
+		float dist;
+		long int leafCop;
+		float coplanar;
+		float criteria;
+		long int leafCrit;
+		
+		// Identifiers of the triangles forming this leaf
+		long int idTriangle[2];
+		
+	public :
+		// Constructors
+		Leaf (void); // default constructor
+		Leaf (const Leaf&); // Copy constructor
+		virtual ~Leaf (void); // Destructor
+
+		float Distance (Leaf&);
+		float Coplanarity (Leaf&);
+};
+
+#endif
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/include/VertexData.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/include/VertexData.h	(revision 831)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/include/VertexData.h	(revision 1019)
@@ -36,4 +36,6 @@
 		virtual void SetIndex(unsigned int i, unsigned int index)=0;
 		virtual void End(void)=0;
+
+//		virtual void UpdateData(int*,int)=0;
 
 		virtual unsigned int GetIndex(unsigned int) const =0;
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h	(revision 1018)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h	(revision 1019)
@@ -44,5 +44,5 @@
 		uint32 MaxFoliageLod(void) const;
 
-		// funciones nuevas propuestas
+		// new proposed functions
 //		uint32 Get_Trunk_VertexCount(void) const;
 //		uint32 Get_Trunk_MaxIndexCount(uint32 istrip) const;
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoTreeSimplifier.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoTreeSimplifier.h	(revision 1007)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoTreeSimplifier.h	(revision 1019)
@@ -4,5 +4,4 @@
 #include "GeoMesh.h"
 #include "GeoTreeSimpSequence.h"
-#include "Hoja.h"
 
 #define K1		0.8f //distance factor
@@ -10,4 +9,5 @@
 
 class LeafOctree;
+class Leaf;
 
 namespace Geometry
@@ -51,7 +51,7 @@
 
 	private:
-		void CalculateLeafCenter(Hoja &);
-		void CalculateLeafNormal(Hoja &);
-		float CalculateLeafArea(Hoja &) const;
+		void CalculateLeafCenter(Leaf &);
+		void CalculateLeafNormal(Leaf &);
+		float CalculateLeafArea(Leaf &) const;
 		void CoplanarBetweenLeaves(void);
 		float BoundingSphereDiameter() const;
@@ -64,7 +64,7 @@
 		long int Collapse(float);
 		void TwoGreater(float*, int* );
-		void ChooseVertices(Hoja& , Hoja& , long int);
-		float HausdorffOptimized(const Hoja &, const Hoja&) const;
-		float DistanceFromCenters(const Hoja &, const Hoja &) const;
+		void ChooseVertices(Leaf& , Leaf& , long int);
+		float HausdorffOptimized(const Leaf &, const Leaf&) const;
+		float DistanceFromCenters(const Leaf &, const Leaf &) const;
 		float distan(float, float, float, float, float, float) const;
 		long int MinDistance(void);
@@ -82,5 +82,5 @@
 		const			Mesh *objmesh;
 		float			(*Vertex)[3];
-		Hoja			*Leaves;
+		Leaf			*Leaves;
 		long int	activeLeaves, countLeaves;
 		TreeSimplificationSequence	*mtreesimpsequence;
@@ -96,5 +96,5 @@
 		int vertex_count;
 		LeafOctree ** octree_owning_leaf;
-		LeafOctree *GetMinOctreeNodeForLeaf(LeafOctree *start, const Hoja &leaf);
+		LeafOctree *GetMinOctreeNodeForLeaf(LeafOctree *start, const Leaf &leaf);
 		bool PruneOctree(LeafOctree *); // erases one octree level and translates its leaves to the parent. Returns true if the node itself was pruned
 	};
Index: P/trunk/Lib/Geom/shared/GTGeometry/include/hoja.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/include/hoja.h	(revision 834)
+++ 	(revision )
@@ -1,41 +1,0 @@
-#ifndef HOJA_H
-#define HOJA_H
-
-
-class Hoja
-{
-	public :
-		// Variable members
-    	int  Vert_Hoja[4];// Array of pointers to vertices
-		float  Normal[3];
-		float  Cuantas_hojas;
-		float Centro[3];
-		int padre;
-		int hijoi;
-		int hijod;
-		int visible;
-		int raiz;
-
-		bool existe;
-		int hoja_cerca;
-		float dist;
-		long int hoja_cop;
-		float coplanar;
-		float criterio;
-		long int hoja_crit;
-
-		
-		// Identificadores de los triángulos que forman la hoja
-		long int id_triangulo[2];
-		
-	public :
-		// Constructors
-		Hoja (void); // Void constructor
-		Hoja (const Hoja& aHoja); // Copy constructor
-		virtual ~Hoja (void); // Destructor
-
-		float Distancia (Hoja&);
-		float Coplanaridad (Hoja&);
-};
-
-#endif
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp	(revision 985)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp	(revision 1019)
@@ -1,4 +1,4 @@
 #include <math.h>
-#include "Hoja.h"
+#include "Leaf.h"
 
 //--------------------------------------------------------------------------------------------------------------------------------
@@ -6,20 +6,20 @@
 // Parameters --> None
 //--------------------------------------------------------------------------------------------------------------------------------
-Hoja::Hoja(void) 
+Leaf::Leaf(void) 
 {	
-	Vert_Hoja[0] = Vert_Hoja[1] = Vert_Hoja[2] = Vert_Hoja[3] =0; 
-	Centro[0] = Centro[1] = Centro[2] = 0;
-	Normal[0] = Normal[1] = Normal[2] = 0;
-	hoja_cerca=-1;
-	Cuantas_hojas = 1;
+	vertsLeaf[0] = vertsLeaf[1] = vertsLeaf[2] = vertsLeaf[3] =0; 
+	center[0] = center[1] = center[2] = 0;
+	normal[0] = normal[1] = normal[2] = 0;
+	leafNear=-1;
+	parentLeafCount = 1;
 	dist = -1;
 	coplanar = -1;
-	criterio = -1;
-	hoja_cop = -1;
-	hoja_crit =-1;
-	existe = false;
-	padre=-1;
-	hijoi = hijod = -1;
-	raiz= visible= -1;
+	criteria = -1;
+	leafCop = -1;
+	leafCrit =-1;
+	exists = false;
+	parent=-1;
+	childLeft = childRight = -1;
+	root = visible= -1;
 }
 
@@ -27,28 +27,27 @@
 //--------------------------------------------------------------------------------------------------------------------------------
 // Copy constructor
-// Parameters --> const Hoja& aHoja : The Hoja to copy
 //--------------------------------------------------------------------------------------------------------------------------------
-Hoja::Hoja (const Hoja& aHoja)
+Leaf::Leaf (const Leaf& aLeaf)
 {
-	Cuantas_hojas = aHoja.Cuantas_hojas;;
-	hoja_cerca = aHoja.hoja_cerca;
-	hoja_crit = aHoja.hoja_crit;
-	dist = aHoja.dist;
-	existe = aHoja.existe;
-	coplanar = aHoja.coplanar;
-	hoja_cop = aHoja.hoja_cop;
-	criterio = aHoja.criterio;
+	parentLeafCount = aLeaf.parentLeafCount;;
+	leafNear = aLeaf.leafNear;
+	leafCrit = aLeaf.leafCrit;
+	dist = aLeaf.dist;
+	exists = aLeaf.exists;
+	coplanar = aLeaf.coplanar;
+	leafCop = aLeaf.leafCop;
+	criteria = aLeaf.criteria;
 	for ( int i=0;i<3;i++){
-		Centro[i] = aHoja.Centro[i];
-		Normal[i] = aHoja.Normal[i];
+		center[i] = aLeaf.center[i];
+		normal[i] = aLeaf.normal[i];
 	}
 	for (i = 0L; i < 4; i++)
-		Vert_Hoja[i] = aHoja.Vert_Hoja[i]; 
+		vertsLeaf[i] = aLeaf.vertsLeaf[i]; 
 	
-	padre = aHoja.padre;
-	hijoi = aHoja.hijoi;
-	hijod = aHoja.hijod;
-	visible = aHoja.visible;
-	raiz = aHoja.raiz;
+	parent = aLeaf.parent;
+	childLeft = aLeaf.childLeft;
+	childRight = aLeaf.childRight;
+	visible = aLeaf.visible;
+	root = aLeaf.root;
 }
 
@@ -58,5 +57,5 @@
 // Destructor. We must deallocate the memory allocated for pointers to vertices and edges
 //--------------------------------------------------------------------------------------------------------------------------------
-Hoja::~Hoja (void)
+Leaf::~Leaf (void)
 {
 }
@@ -67,17 +66,17 @@
 //--------------------------------------------------------------------------------------------------------------------------------
 
-float Hoja::Distancia (Hoja& Hoja1)
+float Leaf::Distance (Leaf& leaf)
 {
 	float dist =0;
 	float x1,y1,z1;
 
-	x1 = Hoja1.Centro[0]; y1 = Hoja1.Centro[1] ; z1 = Hoja1.Centro[2];
+	x1 = leaf.center[0]; y1 = leaf.center[1] ; z1 = leaf.center[2];
 
 
-	//DISTANCIA ENTRE CENTROS
+	//DISTANCIA BETWEEN CENTERS
 
-	dist = ((Centro[0]-x1)*(Centro[0]-x1)) + ((Centro[1]-y1)*(Centro[1]-y1)) + ((Centro[2]-z1)*(Centro[2]-z1));
+	dist = ((center[0]-x1)*(center[0]-x1)) + ((center[1]-y1)*(center[1]-y1)) + ((center[2]-z1)*(center[2]-z1));
 
-	return (dist);
+	return dist;
 }
 
@@ -87,5 +86,5 @@
 //--------------------------------------------------------------------------------------------------------------------------------
 
-float Hoja::Coplanaridad (Hoja& Hoja1)
+float Leaf::Coplanarity (Leaf& leaf)
 {
 	float cop =0;
@@ -95,5 +94,5 @@
 
 	//hoja pasada como parametro, normalizo las componentes
-	x1 = Hoja1.Normal[0]; y1 = Hoja1.Normal[1] ; z1 = Hoja1.Normal[2];
+	x1 = leaf.normal[0]; y1 = leaf.normal[1] ; z1 = leaf.normal[2];
 	modulo1 = sqrt ( (x1*x1) + (y1*y1) + (z1*z1));
 	nx1 = x1 / modulo1;
@@ -103,8 +102,8 @@
 	// hoja desde la que llamo
 
-	modulo2 = sqrt ( (Normal[0]*Normal[0]) + (Normal[1]*Normal[1]) + (Normal[2]*Normal[2]));
-	nx = Normal[0] / modulo2;
-	ny = Normal[1] / modulo2;
-	nz = Normal[2] / modulo2;
+	modulo2 = sqrt ( (normal[0]*normal[0]) + (normal[1]*normal[1]) + (normal[2]*normal[2]));
+	nx = normal[0] / modulo2;
+	ny = normal[1] / modulo2;
+	nz = normal[2] / modulo2;
 
 	// producto escalar : si es proximo a 0, perpendiculares, a 1, coplanares
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp	(revision 985)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp	(revision 1019)
@@ -1,7 +1,5 @@
-//#include <GL\glut.h>
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
-//#include <vl\VLf.h>
 
 #include "Foliage.h"
@@ -13,23 +11,29 @@
 // Parameters --> None
 //--------------------------------------------------------------------------------------------------------------------------------
-Foliage::Foliage(void):  MiArbol(NULL), Acth(NULL)
-{
-	 ppio= final = -1;
-}
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Constructor with the name of a file cotaining the data
-//--------------------------------------------------------------------------------------------------------------------------------
-Foliage::Foliage ( Arbol *Arbol1)
-{
+Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 
+Acth(NULL),
+create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),
+create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),
+vertexdata(NULL), Leaves(NULL), MinDet(NULL)
+{
+	cx = cy= cz= 0;
+	ppio= final = -1;
+
+	ReadVertices(leavesSubMesh);
+	ReadLeafs(leavesSubMesh);
+	if (!ReadSimpSeq(simpSeq)) exit(1);
+	RellenoRaiz();
+	CalculaTexCoordsYNorms();
+
+
+	// esto no sé si devería haber akí
+	indexdata->SetNumValidIndices(0);
+
 	int h=0;
 
 
-	MiArbol = Arbol1;
-
-	Acth  = new Activas[(MiArbol->nHojas)*8];
-
-	for ( h=0; h < MiArbol->nHojas; h++) {
+	Acth  = new Activas[nHojas*8];
+
+	for ( h=0; h < nHojas; h++) {
 
 		Acth[h].indice = h;
@@ -43,4 +47,34 @@
 				
 	ppio = 0;
+	final = nHojas-1;
+	nhactivas = nHojas;
+
+}
+
+/*
+//--------------------------------------------------------------------------------------------------------------------------------
+// Constructor with the name of a file cotaining the data
+//--------------------------------------------------------------------------------------------------------------------------------
+Foliage::Foliage ( Arbol *Arbol1)
+{
+	int h=0;
+
+
+	MiArbol = Arbol1;
+
+	Acth  = new Activas[(MiArbol->nHojas)*8];
+
+	for ( h=0; h < MiArbol->nHojas; h++) {
+
+		Acth[h].indice = h;
+		if ( h != 0)
+		{
+			Acth[h].prev = (h-1);
+			Acth[h-1].next = h;
+		}
+
+	}
+				
+	ppio = 0;
 	final = (MiArbol->nHojas)-1;
 	nhactivas = MiArbol->nHojas;
@@ -48,5 +82,5 @@
 
 
-}
+}*/
 
 //--------------------------------------------------------------------------------------------------------------------------------
@@ -55,5 +89,8 @@
 Foliage::~Foliage (void)
 {
-	delete MiArbol;
+	if (vertexdata) delete vertexdata;
+	if (indexdata) delete indexdata;
+	delete[] Leaves;
+	delete MinDet;
 	delete Acth;
 }
@@ -71,18 +108,18 @@
 	glBegin (GL_TRIANGLE_STRIP);
 		glNormal3fv (aHoja.Normal);
-		MiArbol->Vertices[aHoja.Vert_Hoja[0]].GetCoordinates (a,b,c);
+		MiArbol->Vertices[aHoja.vertsLeaf[0]].GetCoordinates (a,b,c);
 		glTexCoord2f ( 0.0, 0.0);
 
 		glVertex3f (a,b,c);
 
-		MiArbol->Vertices[aHoja.Vert_Hoja[1]].GetCoordinates (a,b,c);
+		MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (a,b,c);
 		glTexCoord2f ( 0.0, 1.0);
 		glVertex3f (a,b,c);
 	
-		MiArbol->Vertices[aHoja.Vert_Hoja[2]].GetCoordinates (a,b,c);
+		MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (a,b,c);
 		glTexCoord2f ( 1.0, 0.0);
 		glVertex3f (a,b,c);
 
-		MiArbol->Vertices[aHoja.Vert_Hoja[3]].GetCoordinates (a,b,c);
+		MiArbol->Vertices[aHoja.vertsLeaf[3]].GetCoordinates (a,b,c);
 		glTexCoord2f ( 1.0, 1.0);
 		glVertex3f (a,b,c);
@@ -236,15 +273,15 @@
 
 	i = 0;
-	while ( MiArbol->MinDet[i].indice != -1)
-	{
-		j = MiArbol->MinDet[i].indice;
+	while ( MinDet[i].indice != -1)
+	{
+		j = MinDet[i].indice;
 		if (LeafinFrustum ( j, frustum) == true) {
-		//	printf("dentro %i y el padre es %i\n", j, MiArbol->Hojas[MiArbol->MinDet[i].indice].padre);
-			MiArbol->Hojas[j].visible = 1;
+		//	printf("dentro %i y el padre es %i\n", j, MiArbol->Hojas[MiArbol->MinDet[i].indice].parent);
+			Leaves[j].visible = 1;
 		}
 		else  
 		{
 		//	printf("fuera %i\n", j);
-			MiArbol->Hojas[j].visible = 0;
+			Leaves[j].visible = 0;
 		}
 
@@ -269,6 +306,6 @@
 	for (j =0; j<4; j++)
 	{
-//		MiArbol->Vertices[MiArbol->Hojas[i].Vert_Hoja[j]].GetCoordinates (a,b,c);
-		MiArbol->vertexdata->GetVertexCoord(MiArbol->Hojas[i].Vert_Hoja[j],a,b,c);
+//		MiArbol->Vertices[MiArbol->Hojas[i].vertsLeaf[j]].GetCoordinates (a,b,c);
+		vertexdata->GetVertexCoord(Leaves[i].vertsLeaf[j],a,b,c);
 		v[0]=a; v[1]=b;	v[2]=c; v[3]=1;
 
@@ -336,5 +373,5 @@
 
 
-bool Foliage::Criterio ( Hoja &aHoja,  char ch, float rva, float rvb,float rvc, float rvd, float radio)
+bool Foliage::Criterio ( Leaf &aLeaf,  char ch, float rva, float rvb,float rvc, float rvd, float radio)
 {
 	float a,b,c; // coordenadas del primero de los vertices en la hoja
@@ -346,13 +383,9 @@
 	float ccx, ccy, ccz;
 
-	
-
-//	MiArbol->Vertices[aHoja.Vert_Hoja[0]].GetCoordinates (a,b,c);
-	MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[0],a,b,c);
-
-	ccx = MiArbol->cx;
-	ccy = MiArbol->cy;
-	ccz = MiArbol->cz;
-
+	vertexdata->GetVertexCoord(aLeaf.vertsLeaf[0],a,b,c);
+
+	ccx = cx;
+	ccy = cy;
+	ccz = cz;
 
 	if ( (ch == 'p') || (ch == 'd'))
@@ -361,14 +394,14 @@
 	if (DondeEsta (a,b,c, rva,rvb,rvc,rvd) == 1)
 	{
-//		MiArbol->Vertices[aHoja.Vert_Hoja[1]].GetCoordinates (d,e,f);
-		MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[1],d,e,f);
+//		MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (d,e,f);
+		vertexdata->GetVertexCoord(aLeaf.vertsLeaf[1],d,e,f);
 		if (DondeEsta (d,e,f, rva,rvb,rvc,rvd) == 1)
 		{
-//			MiArbol->Vertices[aHoja.Vert_Hoja[2]].GetCoordinates (g,h,i);
-			MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[2],g,h,i);
+//			MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (g,h,i);
+			vertexdata->GetVertexCoord(aLeaf.vertsLeaf[2],g,h,i);
 			if (DondeEsta (g,h,i, rva,rvb,rvc,rvd) == 1)
 			{
-//				MiArbol->Vertices[aHoja.Vert_Hoja[3]].GetCoordinates (j,k,l);
-				MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[3],j,k,l);
+//				Vertices[aHoja.vertsLeaf[3]].GetCoordinates (j,k,l);
+				vertexdata->GetVertexCoord(aLeaf.vertsLeaf[3],j,k,l);
 				if (DondeEsta (j,k,l, rva,rvb,rvc,rvd) == 1) inter = true;
 			}
@@ -388,18 +421,18 @@
 
 	{
-//		MiArbol->Vertices[aHoja.Vert_Hoja[1]].GetCoordinates (a,b,c);
-		MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[1],a,b,c);
+//		MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (a,b,c);
+		vertexdata->GetVertexCoord(aLeaf.vertsLeaf[1],a,b,c);
 		dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz));
 
 		if (dist >  radio)
 		{
-//			MiArbol->Vertices[aHoja.Vert_Hoja[2]].GetCoordinates (a,b,c);
-			MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[2],a,b,c);
+//			MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (a,b,c);
+			vertexdata->GetVertexCoord(aLeaf.vertsLeaf[2],a,b,c);
 			dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz));
 
 			if (dist >  radio)
 			{
-//				MiArbol->Vertices[aHoja.Vert_Hoja[3]].GetCoordinates (a,b,c);
-				MiArbol->vertexdata->GetVertexCoord(aHoja.Vert_Hoja[3],a,b,c);
+//				MiArbol->Vertices[aHoja.vertsLeaf[3]].GetCoordinates (a,b,c);
+				vertexdata->GetVertexCoord(aLeaf.vertsLeaf[3],a,b,c);
 				dist =(float)sqrt ((a-ccx)*(a-ccx)+ (b-ccy)*(b-ccy)+ (c-ccz)*(c-ccz));
 
@@ -442,6 +475,6 @@
 	spli = -1;
 
-	renvol = MiArbol->rad;
-	centroz = MiArbol->cz;
+	renvol = rad;
+	centroz = cz;
 //	printf (" el centro en %f y el radio es de %f\n", centroz, renvol);
 
@@ -473,12 +506,12 @@
 		//COLAPSAR
 
-		if (( Criterio ( MiArbol->Hojas[i], ch, rva,rvb,rvc,rvd, radio )== false) && (MiArbol->Hojas[i].padre != -1)) 
+		if (( Criterio ( Leaves[i], ch, rva,rvb,rvc,rvd, radio )== false) && (Leaves[i].parent != -1)) 
 		{
 			// SI ESTA FUESE LA HOJA IZQUIERDA Y LA DERECHA NO CUMPLE TAMPOCO EL CRITERIO
-			if ((MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi == i) &&
-				( Criterio (MiArbol->Hojas[MiArbol->Hojas[MiArbol->Hojas[i].padre].hijod] , ch, rva,rvb,rvc,rvd, radio )== false))
+			if ((Leaves[Leaves[i].parent].childLeft == i) &&
+				( Criterio (Leaves[Leaves[Leaves[i].parent].childRight] , ch, rva,rvb,rvc,rvd, radio )== false))
 			{	//hay que colapsar
-				if (EsActivo(MiArbol->Hojas[MiArbol->Hojas[i].padre].hijod) == false)
-					lista = Forzar_Colapse (MiArbol->Hojas[MiArbol->Hojas[i].padre].hijod, hpost, ch, rva,rvb,rvc,rvd, radio); // para activarla
+				if (EsActivo(Leaves[Leaves[i].parent].childRight) == false)
+					lista = Forzar_Colapse (Leaves[Leaves[i].parent].childRight, hpost, ch, rva,rvb,rvc,rvd, radio); // para activarla
 				else lista = true;
 									
@@ -486,9 +519,9 @@
 			else
 			// SI ESTA FUESE LA HOJA DERECHA Y LA IZQUIERDA NO CUMPLE TAMPOCO EL CRITERIO
-			if ((MiArbol->Hojas[MiArbol->Hojas[i].padre].hijod == i) &&
-				( Criterio (MiArbol->Hojas[MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi] , ch, rva,rvb,rvc,rvd, radio )== false))
+			if ((Leaves[Leaves[i].parent].childRight == i) &&
+				( Criterio (Leaves[Leaves[Leaves[i].parent].childLeft] , ch, rva,rvb,rvc,rvd, radio )== false))
 			{//hay que colapsar
-				if (EsActivo(MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi) == false)
-					 lista = Forzar_Colapse (MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi, hpost,  ch, rva,rvb,rvc,rvd, radio); // para activarla
+				if (EsActivo(Leaves[Leaves[i].parent].childLeft) == false)
+					 lista = Forzar_Colapse (Leaves[Leaves[i].parent].childLeft, hpost,  ch, rva,rvb,rvc,rvd, radio); // para activarla
 				else  lista = true;
 					
@@ -501,5 +534,5 @@
 				lista = false;
 				
-					ColapsaHoja ( MiArbol->Hojas[i].padre, hpost);
+					ColapsaHoja ( Leaves[i].parent, hpost);
 			}
 					
@@ -535,10 +568,10 @@
 
 	//actualizo los punteros del ppio y del final, y post
-	while (( ppio == MiArbol->Hojas[h].hijoi) || ( ppio == MiArbol->Hojas[h].hijod))
+	while (( ppio == Leaves[h].childLeft) || ( ppio == Leaves[h].childRight))
 		ppio = Acth[ppio].next;
-	while (( final == MiArbol->Hojas[h].hijoi) || ( final == MiArbol->Hojas[h].hijod))
+	while (( final == Leaves[h].childLeft) || ( final == Leaves[h].childRight))
 		 final = Acth[final].prev; 
 
-	while (( post == MiArbol->Hojas[h].hijoi) || ( post == MiArbol->Hojas[h].hijod))
+	while (( post == Leaves[h].childLeft) || ( post == Leaves[h].childRight))
 		 post = Acth[post].next; 
 
@@ -547,20 +580,20 @@
 	//COLAPSAR = QUITO DOS DE ACTIVOS PONGO UNO A ACTIVO
 
-	if (Acth[MiArbol->Hojas[h].hijoi].next != -1)
-		Acth[Acth[MiArbol->Hojas[h].hijoi].next].prev = Acth[MiArbol->Hojas[h].hijoi].prev;
-	if (Acth[MiArbol->Hojas[h].hijoi].prev != -1)
-		Acth[Acth[MiArbol->Hojas[h].hijoi].prev].next = Acth[MiArbol->Hojas[h].hijoi].next;
-
-	if (Acth[MiArbol->Hojas[h].hijod].next != -1)
-		Acth[Acth[MiArbol->Hojas[h].hijod].next].prev = Acth[MiArbol->Hojas[h].hijod].prev;
-	if (Acth[MiArbol->Hojas[h].hijod].prev != -1)
-		Acth[Acth[MiArbol->Hojas[h].hijod].prev].next = Acth[MiArbol->Hojas[h].hijod].next;
+	if (Acth[Leaves[h].childLeft].next != -1)
+		Acth[Acth[Leaves[h].childLeft].next].prev = Acth[Leaves[h].childLeft].prev;
+	if (Acth[Leaves[h].childLeft].prev != -1)
+		Acth[Acth[Leaves[h].childLeft].prev].next = Acth[Leaves[h].childLeft].next;
+
+	if (Acth[Leaves[h].childRight].next != -1)
+		Acth[Acth[Leaves[h].childRight].next].prev = Acth[Leaves[h].childRight].prev;
+	if (Acth[Leaves[h].childRight].prev != -1)
+		Acth[Acth[Leaves[h].childRight].prev].next = Acth[Leaves[h].childRight].next;
 
 	
 	//  desconecto a los hijos
-	Acth[MiArbol->Hojas[h].hijoi].prev = -1;
-	Acth[MiArbol->Hojas[h].hijoi].next = -1;
-	Acth[MiArbol->Hojas[h].hijod].prev = -1;
-	Acth[MiArbol->Hojas[h].hijod].next = -1;
+	Acth[Leaves[h].childLeft].prev = -1;
+	Acth[Leaves[h].childLeft].next = -1;
+	Acth[Leaves[h].childRight].prev = -1;
+	Acth[Leaves[h].childRight].next = -1;
 
 	//añado al final
@@ -596,15 +629,15 @@
 		
 		h = listah.GetCola ();//coger la cola
-		if (MiArbol->Hojas[h].hijoi != -1) 
-
-		{ if (!EsActivo (MiArbol->Hojas[h].hijoi ))
-			listah.Inserta (MiArbol->Hojas[h].hijoi);
+		if (Leaves[h].childLeft != -1) 
+
+		{ if (!EsActivo (Leaves[h].childLeft ))
+			listah.Inserta (Leaves[h].childLeft);
 			
-		  if ( (!EsActivo (MiArbol->Hojas[h].hijod)) )	
-			listah.Inserta (MiArbol->Hojas[h].hijod);
-		
-		  if (EsActivo (MiArbol->Hojas[h].hijoi) && EsActivo (MiArbol->Hojas[h].hijod )) 
-			  if((Criterio ( MiArbol->Hojas[MiArbol->Hojas[h].hijoi] ,ch, rva,rvb,rvc,rvd, radio )== false) &&
-				  (Criterio ( MiArbol->Hojas[MiArbol->Hojas[h].hijod], ch, rva,rvb,rvc,rvd, radio ) == false))
+		  if ( (!EsActivo (Leaves[h].childRight)) )	
+			listah.Inserta (Leaves[h].childRight);
+		
+		  if (EsActivo (Leaves[h].childLeft) && EsActivo (Leaves[h].childRight )) 
+			  if((Criterio ( Leaves[Leaves[h].childLeft] ,ch, rva,rvb,rvc,rvd, radio )== false) &&
+				  (Criterio ( Leaves[Leaves[h].childRight], ch, rva,rvb,rvc,rvd, radio ) == false))
 			{
 		    	ColapsaHoja ( h, hpost);
@@ -642,7 +675,7 @@
 
 	// 1 enlazo los hijos 
-	Acth[MiArbol->Hojas[h].hijoi].next = MiArbol->Hojas[h].hijod;
-	Acth[MiArbol->Hojas[h].hijod].prev = MiArbol->Hojas[h].hijoi;
-	Acth[MiArbol->Hojas[h].hijod].next = -1;
+	Acth[Leaves[h].childLeft].next = Leaves[h].childRight;
+	Acth[Leaves[h].childRight].prev = Leaves[h].childLeft;
+	Acth[Leaves[h].childRight].next = -1;
 
 	//y desconecto al padre
@@ -655,7 +688,7 @@
 	
 	//añado al final los hijos 
-	Acth[MiArbol->Hojas[h].hijoi].prev = final;
-	Acth[final].next = MiArbol->Hojas[h].hijoi;
-	final = MiArbol->Hojas[h].hijod;
+	Acth[Leaves[h].childLeft].prev = final;
+	Acth[final].next = Leaves[h].childLeft;
+	final = Leaves[h].childRight;
 
 }
@@ -676,16 +709,16 @@
 	nodo = -1;
 
-	if (MiArbol->Hojas[h].hijoi != -1) 
+	if (Leaves[h].childLeft != -1) 
 
 	{  // si el hijo derecho o el izquierdo están en la zona de máximo detalle, haré que estos se activen 	
-		  if ( (Criterio (MiArbol->Hojas[MiArbol->Hojas[h].hijoi],  ch, rva,rvb,rvc,rvd, radio ) == true) ||
-			  (Criterio (MiArbol->Hojas[MiArbol->Hojas[h].hijod], ch, rva,rvb,rvc,rvd, radio ) == true))
+		  if ( (Criterio (Leaves[Leaves[h].childLeft],  ch, rva,rvb,rvc,rvd, radio ) == true) ||
+			  (Criterio (Leaves[Leaves[h].childRight], ch, rva,rvb,rvc,rvd, radio ) == true))
 			
-				nodo = MiArbol->Hojas[h].hijoi; 
+				nodo = Leaves[h].childLeft; 
 			
 			else // si no, bajo un nivel más hasta encontrar algún descendiente que se encuentre en la zona de + detalle
 			{
-				nodo = Chequea_Split (MiArbol->Hojas[h].hijoi,  ch, rva,rvb,rvc,rvd, radio);
-				if ( nodo == -1 ) nodo = Chequea_Split (MiArbol->Hojas[h].hijod, ch, rva,rvb,rvc,rvd, radio);
+				nodo = Chequea_Split (Leaves[h].childLeft,  ch, rva,rvb,rvc,rvd, radio);
+				if ( nodo == -1 ) nodo = Chequea_Split (Leaves[h].childRight, ch, rva,rvb,rvc,rvd, radio);
 			}
 				  
@@ -711,10 +744,10 @@
 
 	bien = false;
-	h = MiArbol->Hojas[hoja].padre;
+	h = Leaves[hoja].parent;
 	listah.Inserta (h); // Inserta un dato en la lista
 
 	while ( h != padre)
 	{
-		h = MiArbol->Hojas[h].padre;
+		h = Leaves[h].parent;
 		listah.Inserta (h); // Inserta un dato en la lista
 	}
@@ -750,5 +783,5 @@
 	{
 		difdist = dmax - dmin;
-		difhojas = MiArbol->nHojas - MiArbol->minHojas;
+		difhojas = nHojas - minHojas;
 
 		d = dist - dmin;
@@ -758,12 +791,12 @@
 		nhojas = int(abs(d*difhojas /difdist));
 
-		AjusteHojas ((MiArbol->nHojas)-nhojas);
+		AjusteHojas ((nHojas)-nhojas);
 
 	}
 	else if (dist > dmax) {
-		AjusteHojas (MiArbol->minHojas);
+		AjusteHojas (minHojas);
 	}
 	else if (dist < dmin) {
-		AjusteHojas (MiArbol->nHojas);
+		AjusteHojas (nHojas);
 	}
 		
@@ -775,5 +808,5 @@
 void Foliage::AjusteHojas( int nhojas)
 {
-	if ((nhojas <= MiArbol->nHojas) && (nhojas >= MiArbol->minHojas))
+	if ((nhojas <= nHojas) && (nhojas >= minHojas))
 	{
 		if ( nhojas < nhactivas) {
@@ -810,15 +843,15 @@
  		hpost = Acth[i].next;
 
-			if ( MiArbol->Hojas[i].padre != -1) 
-				if ( MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi == i)
-				{if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].padre].hijod ) )
+			if ( MiArbol->Hojas[i].parent != -1) 
+				if ( MiArbol->Hojas[MiArbol->Hojas[i].parent].childLeft == i)
+				{if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].parent].childRight ) )
 				{ 
-					ColapsaHoja ( MiArbol->Hojas[i].padre, hpost);
+					ColapsaHoja ( MiArbol->Hojas[i].parent, hpost);
 					nhojas --; }
 				}
 				else 
-				{if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].padre].hijoi ) )
+				{if ( EsActivo (MiArbol->Hojas[MiArbol->Hojas[i].parent].childLeft ) )
 				{
-					ColapsaHoja ( MiArbol->Hojas[i].padre, hpost); 
+					ColapsaHoja ( MiArbol->Hojas[i].parent, hpost); 
 					nhojas --; }
 				}
@@ -838,10 +871,10 @@
 	j = num;
 	h = final+1;
-		while ((h<=MiArbol->TotHojas) && (j>0))
+		while ((h<=TotHojas) && (j>0))
 		{
-			while (( ppio == MiArbol->Hojas[h].hijoi) || ( ppio == MiArbol->Hojas[h].hijod))
+			while (( ppio == Leaves[h].childLeft) || ( ppio == Leaves[h].childRight))
 				ppio = Acth[ppio].next;
 
-			while (( final == MiArbol->Hojas[h].hijoi) || ( final == MiArbol->Hojas[h].hijod))
+			while (( final == Leaves[h].childLeft) || ( final == Leaves[h].childRight))
 				final = Acth[final].prev; 
 
@@ -849,20 +882,20 @@
 			//COLAPSAR = QUITO DOS DE ACTIVOS PONGO UNO A ACTIVO
 
-			if (Acth[MiArbol->Hojas[h].hijoi].next != -1)
-				Acth[Acth[MiArbol->Hojas[h].hijoi].next].prev = Acth[MiArbol->Hojas[h].hijoi].prev;
-			if (Acth[MiArbol->Hojas[h].hijoi].prev != -1)
-				Acth[Acth[MiArbol->Hojas[h].hijoi].prev].next = Acth[MiArbol->Hojas[h].hijoi].next;
-
-			if (Acth[MiArbol->Hojas[h].hijod].next != -1)
-				Acth[Acth[MiArbol->Hojas[h].hijod].next].prev = Acth[MiArbol->Hojas[h].hijod].prev;
-			if (Acth[MiArbol->Hojas[h].hijod].prev != -1)
-				Acth[Acth[MiArbol->Hojas[h].hijod].prev].next = Acth[MiArbol->Hojas[h].hijod].next;
+			if (Acth[Leaves[h].childLeft].next != -1)
+				Acth[Acth[Leaves[h].childLeft].next].prev = Acth[Leaves[h].childLeft].prev;
+			if (Acth[Leaves[h].childLeft].prev != -1)
+				Acth[Acth[Leaves[h].childLeft].prev].next = Acth[Leaves[h].childLeft].next;
+
+			if (Acth[Leaves[h].childRight].next != -1)
+				Acth[Acth[Leaves[h].childRight].next].prev = Acth[Leaves[h].childRight].prev;
+			if (Acth[Leaves[h].childRight].prev != -1)
+				Acth[Acth[Leaves[h].childRight].prev].next = Acth[Leaves[h].childRight].next;
 
 	
 			//  desconecto a los hijos
-			Acth[MiArbol->Hojas[h].hijoi].prev = -1;
-			Acth[MiArbol->Hojas[h].hijoi].next = -1;
-			Acth[MiArbol->Hojas[h].hijod].prev = -1;
-			Acth[MiArbol->Hojas[h].hijod].next = -1;
+			Acth[Leaves[h].childLeft].prev = -1;
+			Acth[Leaves[h].childLeft].next = -1;
+			Acth[Leaves[h].childRight].prev = -1;
+			Acth[Leaves[h].childRight].next = -1;
 
 			//añado al final
@@ -893,5 +926,5 @@
 		hpost = Acth[i].next;
 
-		if (MiArbol->Hojas[i].hijoi != -1){
+		if (MiArbol->Leaves[i].childLeft != -1){
 					SplitHoja(i, hpost);
 					nhojas --;
@@ -927,8 +960,8 @@
 	i = h++;
 	
-	while ((EsActivo (i) == false) || (i> MiArbol->TotHojas))
+	while ((EsActivo (i) == false) || (i> TotHojas))
 		i++;
 
-	if (i > MiArbol->TotHojas) i=-1;
+	if (i > TotHojas) i=-1;
 
 
@@ -943,30 +976,30 @@
 	j = num;
 	h = final;
-	while ((h > MiArbol->nHojas) &&  (j>0))
+	while ((h > nHojas) &&  (j>0))
 	{
 
 		///////////// insertar a los hijos en orden segun su indice
 		//hijo izquierdo
-		ant = AnteriorActivo (MiArbol->Hojas[h].hijoi);
-		post = PosteriorActivo (MiArbol->Hojas[h].hijoi);
-
-
-		Acth[MiArbol->Hojas[h].hijoi].next = post;
-		Acth[MiArbol->Hojas[h].hijoi].prev = ant;
-		if (ant != -1) Acth[ant].next = MiArbol->Hojas[h].hijoi;
-			else ppio = MiArbol->Hojas[h].hijoi;
-		if (post != -1) Acth[post].prev = MiArbol->Hojas[h].hijoi;
+		ant = AnteriorActivo (Leaves[h].childLeft);
+		post = PosteriorActivo (Leaves[h].childLeft);
+
+
+		Acth[Leaves[h].childLeft].next = post;
+		Acth[Leaves[h].childLeft].prev = ant;
+		if (ant != -1) Acth[ant].next = Leaves[h].childLeft;
+			else ppio = Leaves[h].childLeft;
+		if (post != -1) Acth[post].prev = Leaves[h].childLeft;
 
 		
 		//hijo derecho
-		ant = AnteriorActivo (MiArbol->Hojas[h].hijod);
-		post = PosteriorActivo (MiArbol->Hojas[h].hijod);
-
-
-		Acth[MiArbol->Hojas[h].hijod].next = post;
-		Acth[MiArbol->Hojas[h].hijod].prev = ant;
-		if (ant != -1)  Acth[ant].next = MiArbol->Hojas[h].hijod;
-				else ppio = MiArbol->Hojas[h].hijod;
-		if (post != -1) Acth[post].prev = MiArbol->Hojas[h].hijod;
+		ant = AnteriorActivo (Leaves[h].childRight);
+		post = PosteriorActivo (Leaves[h].childRight);
+
+
+		Acth[Leaves[h].childRight].next = post;
+		Acth[Leaves[h].childRight].prev = ant;
+		if (ant != -1)  Acth[ant].next = Leaves[h].childRight;
+				else ppio = Leaves[h].childRight;
+		if (post != -1) Acth[post].prev = Leaves[h].childRight;
 
 
@@ -992,2 +1025,287 @@
 
  }
+
+void Foliage::ReadVertices(const Geometry::SubMesh *submesh)
+{
+	int countv= int(submesh->mVertexBuffer->mVertexCount);
+	vertexdata = create_vertex_data_func(2*countv);
+	Leaves = new Leaf[countv*2];
+	indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja
+	
+	vertexdata->Begin();
+	for (int i=0; i<countv; i++)
+	{
+		vertexdata->SetVertexCoord( i,	submesh->mVertexBuffer->mPosition[i].x, 
+										submesh->mVertexBuffer->mPosition[i].y, 
+										submesh->mVertexBuffer->mPosition[i].z );
+	}
+	vertexdata->End();
+
+	TotVerts = countv;
+}
+
+
+void Foliage::GetNormalH (Leaf &aleaf)
+{
+
+	float onex, oney, onez;
+	float twox, twoy, twoz;
+	float threex, threey, threez;
+
+/*	Vertices[aHoja.vertsLeaf[0]].GetCoordinates (onex, oney, onez);
+	Vertices[aHoja.vertsLeaf[1]].GetCoordinates(twox, twoy, twoz);
+	Vertices[aHoja.vertsLeaf[2]].GetCoordinates (threex, threey, threez);*/
+
+	vertexdata->GetVertexCoord(aleaf.vertsLeaf[0],onex,oney,onez);
+	vertexdata->GetVertexCoord(aleaf.vertsLeaf[1],twox,twoy,twoz);
+	vertexdata->GetVertexCoord(aleaf.vertsLeaf[2],threex,threey,threez);
+
+	float v1[3]={twox-onex,twoy-oney,twoz-onez};
+	float v2[3]={threex-onex,threey-oney,threez-onez};
+
+	Normalize(v1,v1);
+	Normalize(v2,v2);
+	
+//	aleaf.Normal[0] = (twoz-onez)*(threey-oney) - (twoy-oney)*(threez-onez);
+//	aleaf.Normal[1] = (twox-onex)*(threez-onez) - (threex-onex)*(twoz-onez);
+//	aleaf.Normal[2] = (threex-onex)*(twoy-oney) - (twox-onex)*(threey-oney);
+
+	CrossProduct(v1,v2,aleaf.normal);
+	
+}
+
+void Foliage::CrossProduct(const float *v1, const float *v2, float *res)
+{
+	res[0] = v1[1]*v2[2] - v1[2]*v2[1];
+	res[1] = v1[2]*v2[0] - v1[0]*v2[2];
+	res[2] = v1[0]*v2[1] - v1[1]*v2[0];
+}
+
+void Foliage::Normalize(const float *v, float *res)
+{
+	float module=sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+	res[0]=v[0]/module;
+	res[1]=v[1]/module;
+	res[2]=v[2]/module;
+}
+
+void Foliage::ReadLeafs(const Geometry::SubMesh *submesh)
+{
+	int numtris = int(submesh->mIndexCount / 3);
+	nHojas =  numtris / 2;
+	for (int h=0; h<nHojas; h++)
+	{
+		Leaves[h].vertsLeaf[0] = submesh->mIndex[h*6+0];
+		Leaves[h].vertsLeaf[1] = submesh->mIndex[h*6+1];
+		Leaves[h].vertsLeaf[2] = submesh->mIndex[h*6+2];
+		Leaves[h].vertsLeaf[3] = submesh->mIndex[h*6+5];
+		Leaves[h].visible = 0;
+
+		GetNormalH ( Leaves[h]);
+	}
+}
+
+/// returns the number of total leafs
+bool Foliage::ReadSimpSeq(const char *simpSeqFile)
+{
+	FILE* fp_simpli;
+	char linea[256];
+	int v0, v1, v2, v3, tn, tv1,tv2, e=0;
+
+	if ((fp_simpli = fopen (simpSeqFile, "r")) == NULL)
+	{
+		printf ("No he podido abrir el fichero %s\n", simpSeqFile);
+		return false;
+	}
+	else
+	{
+		tn = nHojas;
+		while (fgets (linea, 255, fp_simpli) != NULL)
+		{
+			if (linea[0]<'0' || linea[0]>'9')
+				continue;
+		
+			//N 446 Ver 10176 10178 10169 10171  Tv 156 154 E 2
+
+//			sscanf(linea, "%s %lu %s %lu %lu  %lu %lu %s %lu %lu %s %i", 
+//				&str, &tn, &str, &v0, &v1, &v2, &v3, &str, &tv1, &tv2, &str, &e );
+			long int triviej00=-1, triviej01=-1;
+			long int triviej10=-1, triviej11=-1;
+			sscanf(linea, "%lu %lu %lu %lu & %lu %lu %lu %lu", &triviej00,&triviej01,&triviej10,&triviej11, &v0,&v1,&v2,&v3);
+
+			Leaves[tn].vertsLeaf[0] = v0;
+			Leaves[tn].vertsLeaf[1] = v1;
+			Leaves[tn].vertsLeaf[2] = v2;
+			Leaves[tn].vertsLeaf[3] = v3;
+
+			Leaves[tn].visible = 0;
+
+			GetNormalH  (Leaves[tn]);
+
+			tv1 = triviej00/2;
+			tv2 = triviej10/2;
+
+			Leaves[tn].childLeft= tv1;
+			Leaves[tn].childRight= tv2;
+
+			Leaves[tv1].parent = tn;
+			Leaves[tv2].parent = tn;		
+
+			tn++;
+		}
+
+	}
+
+	fclose(fp_simpli);
+
+	TotHojas=tn;
+		
+	return true;
+}
+
+void Foliage::RellenoRaiz (void)
+{
+	int i,j, k, t, cont;
+	bool esta, fin;
+
+	i=0;
+	k=-1;
+	cont =-1;
+
+	MinDet  = new Activas[nHojas*2];
+	
+	while (i<TotHojas)
+	{
+		j=i;
+		while (Leaves[j].parent > -1) j= Leaves[j].parent;
+		Leaves[i].root = j;
+
+
+		// para la estructura MinDet
+		if ( k == -1){
+			k++;
+			MinDet[k].indice = j;
+			cont =k;
+		}
+		else
+		{
+			t = 0;
+			esta = false;
+			fin = false;
+
+			while (( fin == false) && (esta == false))
+			{	if ( MinDet[t].indice == j) esta = true;
+					else t++;
+				if (MinDet[t].indice == -1) fin = true;
+			}
+
+			if ( esta == false) //añado al final
+			{
+				cont++;
+				MinDet[cont].indice = j;
+			}
+		}
+
+	i++;
+	}	
+
+	minHojas = cont;
+
+}
+
+void Foliage::CalculaTexCoordsYNorms(void)
+{	
+	vertexdata->Begin();
+	for (int i=0; i<nHojas; i++)
+	{	
+		const float* lanormal = Leaves[i].normal;
+		vertexdata->SetVertexNormal(Leaves[i].vertsLeaf[0], lanormal[0], lanormal[1], lanormal[2]);
+		vertexdata->SetVertexTexCoord(Leaves[i].vertsLeaf[0], 0.0f, 1.0f);
+
+		vertexdata->SetVertexNormal(Leaves[i].vertsLeaf[1], lanormal[0], lanormal[1], lanormal[2]);
+		vertexdata->SetVertexTexCoord(Leaves[i].vertsLeaf[1], 0.0f, 0.0f);
+
+		vertexdata->SetVertexNormal(Leaves[i].vertsLeaf[2], lanormal[0], lanormal[1], lanormal[2]);
+		vertexdata->SetVertexTexCoord(Leaves[i].vertsLeaf[2], 1.0f, 1.0f);
+
+		vertexdata->SetVertexNormal(Leaves[i].vertsLeaf[3], lanormal[0], lanormal[1], lanormal[2]);
+		vertexdata->SetVertexTexCoord(Leaves[i].vertsLeaf[3], 1.0f, 0.0f);
+
+
+/*		MiArbol->Vertices[aHoja.vertsLeaf[1]].GetCoordinates (a,b,c);
+		glTexCoord2f ( 0.0, 1.0);
+		glVertex3f (a,b,c);
+	
+		MiArbol->Vertices[aHoja.vertsLeaf[2]].GetCoordinates (a,b,c);
+		glTexCoord2f ( 1.0, 0.0);
+		glVertex3f (a,b,c);
+
+		MiArbol->Vertices[aHoja.vertsLeaf[3]].GetCoordinates (a,b,c);
+		glTexCoord2f ( 1.0, 1.0);
+		glVertex3f (a,b,c);*/
+	}
+	vertexdata->End();
+}
+
+Foliage::Foliage(const Foliage *ar)
+{
+	nHojas=ar->nHojas;
+	MinDet  = new Activas[nHojas*2];
+//	for (unsigned int i=0; i<nHojas*2; i++)
+//		MinDet[i]=ar->MinDet[i];
+	memcpy(MinDet,ar->MinDet,sizeof(Activas)*nHojas*2);
+	TotHojas=ar->TotHojas;
+	cx=ar->cx;
+	cy=ar->cy;
+	cz=ar->cz;
+	rad=ar->rad;
+	minHojas=ar->minHojas;
+	TotVerts=ar->TotVerts;
+
+	create_vertex_data_func=ar->create_vertex_data_func;
+	create_index_data_func=ar->create_index_data_func;
+	vertexdata=create_vertex_data_func(ar->vertexdata->GetNumVertices());
+	vertexdata->Begin(); 
+	for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++) 
+	{
+		float va,vb,vc;
+		ar->vertexdata->GetVertexCoord(i,va,vb,vc);
+		vertexdata->SetVertexCoord(i,va,vb,vc);
+		ar->vertexdata->GetVertexNormal(i,va,vb,vc);
+		vertexdata->SetVertexNormal(i,va,vb,vc);
+	}
+	vertexdata->End();
+	indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices());
+	indexdata->Begin(); 
+	for (unsigned int i=0; i<indexdata->GetNumMaxIndices(); i++) 
+		indexdata->SetIndex(i,ar->indexdata->GetIndex(i));
+	indexdata->End();
+
+	Leaves=new Leaf[vertexdata->GetNumVertices()];
+//	for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++) 
+//		Leaves[i]=ar->Leaves[i];
+	memcpy(Leaves,ar->Leaves,sizeof(Leaf)*vertexdata->GetNumVertices());
+
+	// esto no sé si devería haber akí
+	indexdata->SetNumValidIndices(0);
+
+	int h=0;
+
+	Acth  = new Activas[nHojas*8];
+
+	for ( h=0; h < nHojas; h++) {
+
+		Acth[h].indice = h;
+		if ( h != 0)
+		{
+			Acth[h].prev = (h-1);
+			Acth[h-1].next = h;
+		}
+
+	}
+				
+	ppio = 0;
+	final = nHojas-1;
+	nhactivas = nHojas;
+
+}
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h	(revision 830)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h	(revision 1019)
@@ -3,12 +3,10 @@
 
 
-#include "arbol.h"
 #include "Activas.h"
-//#include "material.h"
+#include "GeoSubMesh.h"
 #include "tlista.h"
-//#include <vl\VLf.h>
 #include "TMatrix.h"
-
-
+#include "VertexData.h"
+#include "Leaf.h"
 
 class Foliage
@@ -16,20 +14,13 @@
 	public :
 
-	Arbol	 *MiArbol;
-	Activas  *Acth; // primera hoja activa
-	int ppio, final;
-	int nhactivas;
-	TMatrix mat_aux;
+		Activas  *Acth; // primera hoja activa
+		int ppio, final;
+		int nhactivas;
+		TMatrix mat_aux;
 
-	public :
-		Foliage (void); // Void constructor
-		Foliage ( Arbol* Arbol1 ); // Constructor with the name of a file cotaining the data
+		Foliage (const Geometry::SubMesh *, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL);
+		Foliage (const Foliage *);
 		virtual ~Foliage (void); // Destructor
 		
-		// sacar por pantalla
-/*		void Dibuja_Hoja ( Hoja&);
-		int  DibujarHojas (float frustum[6][4], float zoom);
-		void DibujaEsfera (float);*/
-
 		//culling
 		void Culling (float frustum[6][4]);
@@ -39,5 +30,5 @@
 		bool EsActivo (  int num);
 		int  DondeEsta (  float x, float y, float z, float rva, float rvb,float rvc, float rvd);
-		bool Criterio ( Hoja &aHoja, char ch, float rva, float rvb,float rvc, float rvd, float radio);
+		bool Criterio ( Leaf &, char ch, float rva, float rvb,float rvc, float rvd, float radio);
 		int  ResolucionV ( char c, float rva, float rvb,float rvc, float rvd, float radio);
 		void ColapsaHoja (int, int&);
@@ -56,8 +47,34 @@
 		void RCsplit (  int nhojas);
 
-		//impostores
-//		void DibujaCaja (float alfa, float d);
-//		int  DibujaMediaCopa ( char c, float rva, float rvb,float rvc, float rvd, float radio);
+		Geometry::VertexData *vertexdata;
+		Geometry::IndexData *indexdata;
+
+		Leaf   *Leaves;
+		Activas  *MinDet; // primera hoja activa
+		int nHojas;
+		int TotHojas;
 		
+		float cx,cy,cz; //centro de la copa// para los impostores y resolucion variable
+		float rad; //radio de la esfera envolvente
+		int minHojas;
+		int TotVerts;
+
+	private:
+		Geometry::CREATEVERTEXDATAFUNC create_vertex_data_func;		
+		Geometry::CREATEINDEXDATAFUNC create_index_data_func;
+
+		void ReadLeafs(const Geometry::SubMesh *);
+		void ReadVertices(const Geometry::SubMesh *);
+		bool ReadSimpSeq(const char*); /// returns true when successful
+		void RellenoRaiz (void);
+
+		void GetNormalH (Leaf&);
+//		void GetNormalT(Tronco&);
+
+		void CrossProduct(const float *v1, const float *v2, float *res);
+		void Normalize(const float *v, float *res);
+//		void CalculaNormalesVertice(void);
+		void CalculaTexCoordsYNorms(void);
+
 };
 
Index: P/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Arbol.cpp	(revision 985)
+++ 	(revision )
@@ -1,753 +1,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "Arbol.h"
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Constructor with the name of a file cotaining the data
-//--------------------------------------------------------------------------------------------------------------------------------
-/*Arbol::Arbol (const char * arbol, const char* hojas, const char* simplifi, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 
-create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),
-create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),
-vertexdata(NULL), Hojas(NULL), MinDet(NULL)*/
-Arbol::Arbol (const Geometry::SubMesh *leafsSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):
-create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),
-create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),
-vertexdata(NULL), Hojas(NULL), MinDet(NULL)
-{	
-	cx = cy= cz= 0;
-
-	//VERTICES
-/*	if ((TotVerts=LeeVertices(arbol))==0){ printf("File not found '%s'\n",arbol); exit(1); }//ThrowFileNotFoundError((const char*)arbol);
-	if ((nHojas = LeoHojas (hojas))==0) { printf("File not found '%s'\n",hojas); exit(1); }//ThrowFileNotFoundError((const char*)hojas);
-//	TotTronco = LeoTronco (tronco);
-//	CalculaNormalesVertice();	
-	if ((TotHojas = LeoHojasSimpl(simpli))==0){ printf("File not found '%s'\n",simpli); exit(1); }// ThrowFileNotFoundError((const char*)simpli);	
-	RellenoRaiz();
-
-	CalculaTexCoordsYNorms();*/
-
-
-	ReadVertices(leafsSubMesh);
-	ReadLeafs(leafsSubMesh);
-	if (!ReadSimpSeq(simpSeq)) exit(1);
-	RellenoRaiz();
-	CalculaTexCoordsYNorms();
-
-
-	// esto no sé si devería haber akí
-	indexdata->SetNumValidIndices(0);
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Destructor. We must deallocate the memory allocated for pointers to vertices and edges
-//--------------------------------------------------------------------------------------------------------------------------------
-Arbol::~Arbol (void)
-{
-	if (vertexdata) delete vertexdata;
-	if (indexdata) delete indexdata;
-	delete Hojas;
-	delete MinDet;
-//	delete [] normales_vert;
-}
-
-
-//
-//
-//--------------------------------------------------------------------------------------------------------------------------------
-// leer informacion desde el fichero
-//--------------------------------------------------------------------------------------------------------------------------------
-/*void Arbol::ReadFromFile ( const char * arbol, const char* hojas, const char* simpli) // Reads a obj-model from a file
-{
-	    
-	//VERTICES
-	if ((TotVerts=LeeVertices(arbol))==0){ printf("File not found '%s'\n",arbol); exit(1); }//ThrowFileNotFoundError((const char*)arbol);
-	if ((nHojas = LeoHojas (hojas))==0) { printf("File not found '%s'\n",hojas); exit(1); }//ThrowFileNotFoundError((const char*)hojas);
-//	TotTronco = LeoTronco (tronco);
-//	CalculaNormalesVertice();	
-	if ((TotHojas = LeoHojasSimpl(simpli))==0){ printf("File not found '%s'\n",simpli); exit(1); }// ThrowFileNotFoundError((const char*)simpli);	
-	RellenoRaiz();
-
-	CalculaTexCoordsYNorms();
-}*/
-
-
-//#include "TMatrix.h"
-
-
-void Arbol::ReadVertices(const Geometry::SubMesh *submesh)
-{
-	int countv= int(submesh->mVertexBuffer->mVertexCount);
-	vertexdata = create_vertex_data_func(2*countv);
-	Hojas = new Hoja[countv*2];
-	indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja
-	
-	vertexdata->Begin();
-	for (int i=0; i<countv; i++)
-	{
-		vertexdata->SetVertexCoord( i,	submesh->mVertexBuffer->mPosition[i].x, 
-										submesh->mVertexBuffer->mPosition[i].y, 
-										submesh->mVertexBuffer->mPosition[i].z );
-	}
-	vertexdata->End();
-
-	TotVerts = countv;
-}
-
-/*
-//--------------------------------------------------------------------------------------------------------------------------------
-// Procesar línea para extraer los VERTICES DE VERTICES.OBJ
-//--------------------------------------------------------------------------------------------------------------------------------
-int Arbol::LeeVertices ( const char *  arbol)
-
-{
-		FILE* fp_origen;
-		char linea[256], str[20];
-		float x,y,z;
-		int countv=0;
-		bool fin_vertices = false;
-
-		//cuento todos los vertices, y relleno la estructura
-		if ((fp_origen = fopen (arbol, "r")) == NULL)
-		{
-			printf ("No he podido abrir el fichero %s\n", arbol);
-			return 0;
-		}
-		else
-		{
-			while ((fgets (linea, 255, fp_origen) != NULL) && (fin_vertices == false))
-		
-				
-				switch (linea[0])
-				{
-					case '#':
-						switch ( linea[2])
-						{
-						case 'v':
-							sscanf(linea,"# %s %lu",  str, &countv);
-							if ( countv > 0){
-									//Vertices  = new Point3D[2*countv];
-									//tex_coords=new float[countv*2];
-									vertexdata = create_vertex_data_func(2*countv);
-									Hojas = new Hoja[countv*2];
-									indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja
-									vertexdata->Begin();
-									//para impostores
-
-							}
-							countv=0;
-							break;
-						
-						default:
-							break;
-
-						}
-						break;
-					case 'v':
-						switch (linea[1])
-						{
-							case ' ':
-								{
-							sscanf (linea, "v %f %f %f ", &x, &y, &z);
-							//Vertices[countv].Update( x, y, z); para girarlo
-							//Vertices[countv].Update( x, z, y);
-
-//							Vector rotv(x,y,z);
-//							rotv = rot90mat * rotv;
-							
-							vertexdata->SetVertexCoord(countv,x,z,-y);
-							
-							countv++;
-								break;
-								}
-							case 't':
-							// PASAMOS DE ESTO: LAS COORDENADAS DE TEXTURA DE LAS HOJAS SE CALCULAN A MANO Y LAS DEL TRONCO NO SE NECESITAN AKI
-							sscanf (linea, "vt %f %f", &x, &y);
-							//printf ("%f %f:%s", x, y,linea);
-//							tex_coords[countv*2]=x;
-//							tex_coords[countv*2+1]=y;
-							//vertexdata->Begin();
-//							vertexdata->SetVertexTexCoord(countv-1,x,y); // -1 porque al cargar el vertice antes se incrementa countv
-							//vertexdata->End();
-
-								break;
-
-							default :
-								break;
-						}
-						break;
-
-
-					default:
-						break;
-	
-				}
-
-		fclose (fp_origen);
-		}
-
-		vertexdata->End();
-		return ( countv);
-
-		
-}*/
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Calcular las normales de las hojas
-//--------------------------------------------------------------------------------------------------------------------------------
-
-void Arbol::GetNormalH (Hoja &aHoja)
-{
-
-	float onex, oney, onez;
-	float twox, twoy, twoz;
-	float threex, threey, threez;
-
-/*	Vertices[aHoja.Vert_Hoja[0]].GetCoordinates (onex, oney, onez);
-	Vertices[aHoja.Vert_Hoja[1]].GetCoordinates(twox, twoy, twoz);
-	Vertices[aHoja.Vert_Hoja[2]].GetCoordinates (threex, threey, threez);*/
-
-	vertexdata->GetVertexCoord(aHoja.Vert_Hoja[0],onex,oney,onez);
-	vertexdata->GetVertexCoord(aHoja.Vert_Hoja[1],twox,twoy,twoz);
-	vertexdata->GetVertexCoord(aHoja.Vert_Hoja[2],threex,threey,threez);
-
-	float v1[3]={twox-onex,twoy-oney,twoz-onez};
-	float v2[3]={threex-onex,threey-oney,threez-onez};
-
-	Normalize(v1,v1);
-	Normalize(v2,v2);
-	
-//	aHoja.Normal[0] = (twoz-onez)*(threey-oney) - (twoy-oney)*(threez-onez);
-//	aHoja.Normal[1] = (twox-onex)*(threez-onez) - (threex-onex)*(twoz-onez);
-//	aHoja.Normal[2] = (threex-onex)*(twoy-oney) - (twox-onex)*(threey-oney);
-
-	CrossProduct(v1,v2,aHoja.Normal);
-
-	
-}
-
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Calcular las normales del tronco
-//--------------------------------------------------------------------------------------------------------------------------------
-
-/*void Arbol::GetNormalT (Tronco &aTronco)
-{
-
-	float onex, oney, onez;
-	float twox, twoy, twoz;
-	float threex, threey, threez;
-
-	Vertices[aTronco.Vert_Tronco[0]].GetCoordinates (onex, oney, onez);
-	Vertices[aTronco.Vert_Tronco[1]].GetCoordinates(twox, twoy, twoz);
-	Vertices[aTronco.Vert_Tronco[2]].GetCoordinates (threex, threey, threez);
-	
-//	aTronco.Normal[0] = (twoz-onez)*(threey-oney) - (twoy-oney)*(threez-onez);
-//	aTronco.Normal[1] = (twox-onex)*(threez-onez) - (threex-onex)*(twoz-onez);
-//	aTronco.Normal[2] = (threex-onex)*(twoy-oney) - (twox-onex)*(threey-oney);
-
-	
-}
-*/
-
-void Arbol::CrossProduct(const float *v1, const float *v2, float *res)
-{
-	res[0] = v1[1]*v2[2] - v1[2]*v2[1];
-	res[1] = v1[2]*v2[0] - v1[0]*v2[2];
-	res[2] = v1[0]*v2[1] - v1[1]*v2[0];
-}
-
-void Arbol::Normalize(const float *v, float *res)
-{
-	float module=sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
-	res[0]=v[0]/module;
-	res[1]=v[1]/module;
-	res[2]=v[2]/module;
-}
-
-/*void Arbol::CalculaNormalesVertice(void)
-{
-	int l;
-	normales_vert = new float[TotVerts*3];
-	unsigned int i,j;
-	float onex, oney, onez;
-	float twox, twoy, twoz;
-	float threex, threey, threez;
-	unsigned int iv[3];
-
-
-	for (i=0; i<TotVerts; i++)
-	{
-		normales_vert[i*3+0] = 0.0f;
-		normales_vert[i*3+1] = 0.0f;
-		normales_vert[i*3+2] = 0.0f;
-	}
-
-	
-	for (i=0; i<TotTronco; i++)
-	{
-		//unsigned int iv[3] = { Troncos[i].Vert_Tronco[0], Troncos[i].Vert_Tronco[1], Troncos[i].Vert_Tronco[3] };
-		iv[0]=Troncos[i].Vert_Tronco[0];
-		iv[1]=Troncos[i].Vert_Tronco[1];
-		iv[2]=Troncos[i].Vert_Tronco[2];
-
-		float auxnormal[3]={0.0f, 0.0f, 0.0f};
-
-//		if (iv[0] != iv[1] && iv[0] != iv[2] && iv[1] != iv[2])
-//		{
-
-			Vertices[iv[0]].GetCoordinates (onex, oney, onez);
-			Vertices[iv[1]].GetCoordinates(twox, twoy, twoz);
-			Vertices[iv[2]].GetCoordinates (threex, threey, threez);
-
-			float vd1[3] = {	twox - onex, 
-								twoy - oney, 
-								twoz - onez };
-
-			float vd2[3] = {	threex - onex, 
-								threey - oney, 						
-								threez - onez };
-
-			Normalize(vd1,vd1);
-			Normalize(vd2,vd2);
-//			if (i%2)
-				CrossProduct(vd2,vd1,auxnormal);
-//			else
-//				CrossProduct(vd1,vd2,auxnormal);
-
-//		}
-
-		for (j=0; j<3; j++)
-		{
-			normales_vert[iv[j]*3+0] += auxnormal[0];
-			normales_vert[iv[j]*3+1] += auxnormal[1];
-			normales_vert[iv[j]*3+2] += auxnormal[2];
-		}
-	}
-
-		
-	for (i=0; i<TotVerts; i++)
-	{
-		if ((normales_vert[i*3]!=0.0)||(normales_vert[i*3+1]!=0.0)||(normales_vert[i*3+2]!=0.0))
-			Normalize(normales_vert+i*3, normales_vert+i*3);
-		
-	}
-
-	
-	for (i=0; i<TotTronco; i++)
-	{
-		iv[0]=Troncos[i].Vert_Tronco[0];
-		iv[1]=Troncos[i].Vert_Tronco[1];
-		iv[2]=Troncos[i].Vert_Tronco[2];
-
-
-		Troncos[i].Normal[0][0]=normales_vert[iv[0]*3];
-		Troncos[i].Normal[0][1]=normales_vert[iv[0]*3+1];
-		Troncos[i].Normal[0][2]=normales_vert[iv[0]*3+2];
-		Troncos[i].Normal[1][0]=normales_vert[iv[1]*3];
-		Troncos[i].Normal[1][1]=normales_vert[iv[1]*3+1];
-		Troncos[i].Normal[1][2]=normales_vert[iv[1]*3+2];
-		Troncos[i].Normal[2][0]=normales_vert[iv[2]*3];
-		Troncos[i].Normal[2][1]=normales_vert[iv[2]*3+1];
-		Troncos[i].Normal[2][2]=normales_vert[iv[2]*3+2];
-	}
-
-	delete [] normales_vert;
-
-}*/
-
-void Arbol::ReadLeafs(const Geometry::SubMesh *submesh)
-{
-	int numtris = int(submesh->mIndexCount / 3);
-	nHojas =  numtris / 2;
-	for (int h=0; h<nHojas; h++)
-	{
-		Hojas[h].Vert_Hoja[0] = submesh->mIndex[h*6+0];
-		Hojas[h].Vert_Hoja[1] = submesh->mIndex[h*6+1];
-		Hojas[h].Vert_Hoja[2] = submesh->mIndex[h*6+2];
-		Hojas[h].Vert_Hoja[3] = submesh->mIndex[h*6+5];
-		Hojas[h].visible = 0;
-
-		GetNormalH ( Hojas[h]);
-	}
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Procesar línea para extraer las HOJAS DE HOJAS.OBJ
-//--------------------------------------------------------------------------------------------------------------------------------
-/*
-  int Arbol::LeoHojas (const char* hojas)
-{
-	FILE* fp_hojas;
-	char linea[256];
-
-	int v1, v2, v3, h=0;
-	
-
-
-	if ((fp_hojas = fopen (hojas, "r")) == NULL)
-	{
-			printf ("No he podido abrir el fichero %s\n", hojas);
-			return 0;
-	}		
-	else
-	{
-
-
-		while (fgets (linea, 255, fp_hojas) != NULL)
-		
-			switch (linea[0])
-			{
-				case 'H':
-				
-					fgets (linea, 255, fp_hojas);
-					sscanf(linea, "f %lu %lu %lu", &v1, &v2, &v3);
-
-
-					Hojas[h].Vert_Hoja[0]=(v1-1);
-					Hojas[h].Vert_Hoja[1]=(v2-1);
-					Hojas[h].Vert_Hoja[2]=(v3-1);
-					Hojas[h].visible = 0;
-
-					
-					fgets (linea, 255, fp_hojas);
-					sscanf(linea, "f %lu %lu %lu", &v1, &v2, &v3);
-					Hojas[h].Vert_Hoja[3]=(v3-1);
-
-					GetNormalH ( Hojas[h]);
-
-					h++;
-					break;
-					
-				default :
-					printf( "Hay un error al leer las hojas\n");
-					break;
-	
-			}
-		
-	}
-
-	return (h);	
-}
-*/
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Procesar línea para extraer los triangulos del tronco de TRONCO.OBJ
-//--------------------------------------------------------------------------------------------------------------------------------
-/*
-  int Arbol::LeoTronco (char* tronco)
-{
-	FILE* fp_tronco;
-	char linea[256];
-    int v1, v2, v3, t=0;
-	
-
-
-	if ((fp_tronco = fopen (tronco, "r")) == NULL)
-			printf ("No he podido abrir el fichero %s\n", tronco);
-		
-	else
-	{
-
-		while (fgets (linea, 255, fp_tronco) != NULL)
-		
-		{
-			sscanf(linea, "f %lu %lu %lu", &v1, &v2, &v3);
-
-			Troncos[t].Vert_Tronco[0]=(v1-1);
-			Troncos[t].Vert_Tronco[1]=(v2-1);
-			Troncos[t].Vert_Tronco[2]=(v3-1);
-
-			GetNormalT (Troncos[t]);
-			t++;
-		
-		}
-		
-			fclose(fp_tronco);
-	}
-	return (t);
-}
-*/
-
-
- /// returns the number of total leafs
-bool Arbol::ReadSimpSeq(const char *simpSeqFile)
-{
-	FILE* fp_simpli;
-	char linea[256];
-	int v0, v1, v2, v3, tn, tv1,tv2, e=0;
-
-	if ((fp_simpli = fopen (simpSeqFile, "r")) == NULL)
-	{
-		printf ("No he podido abrir el fichero %s\n", simpSeqFile);
-		return false;
-	}
-	else
-	{
-		tn = nHojas;
-		while (fgets (linea, 255, fp_simpli) != NULL)
-		{
-			if (linea[0]<'0' || linea[0]>'9')
-				continue;
-		
-			//N 446 Ver 10176 10178 10169 10171  Tv 156 154 E 2
-
-//			sscanf(linea, "%s %lu %s %lu %lu  %lu %lu %s %lu %lu %s %i", 
-//				&str, &tn, &str, &v0, &v1, &v2, &v3, &str, &tv1, &tv2, &str, &e );
-			long int triviej00=-1, triviej01=-1;
-			long int triviej10=-1, triviej11=-1;
-			sscanf(linea, "%lu %lu %lu %lu & %lu %lu %lu %lu", &triviej00,&triviej01,&triviej10,&triviej11, &v0,&v1,&v2,&v3);
-
-			Hojas[tn].Vert_Hoja[0] = v0;
-			Hojas[tn].Vert_Hoja[1] = v1;
-			Hojas[tn].Vert_Hoja[2] = v2;
-			Hojas[tn].Vert_Hoja[3] = v3;
-
-			Hojas[tn].visible = 0;
-
-			GetNormalH  (Hojas[tn]);
-
-			tv1 = triviej00/2;
-			tv2 = triviej10/2;
-
-			Hojas[tn].hijoi= tv1;
-			Hojas[tn].hijod= tv2;
-
-			Hojas[tv1].padre = tn;
-			Hojas[tv2].padre = tn;		
-
-			tn++;
-		}
-
-	}
-
-	fclose(fp_simpli);
-
-	TotHojas=tn;
-		
-	return true;
-}
-
-
-
-//---------------------------------------------------------------------------------------------------------------------
-// Procesar línea para extraer las HOJAS DE SIMPLIFICA.OBJ
-//---------------------------------------------------------------------------------------------------------------------
-/*
-  int Arbol::LeoHojasSimpl (const char* simplifica)
-{
-	FILE* fp_simpli;
-	char linea[256], str[10];;
-	int v0, v1, v2, v3, tn, tv1,tv2, e=0;
-	float xc,yc, zc;
-	float xmax, xmin, ymax, ymin, zmax, zmin;
-
-
-	if ((fp_simpli = fopen (simplifica, "r")) == NULL)
-	{
-			printf ("No he podido abrir el fichero %s\n", simplifica);
-			return 0;
-	}
-		
-	else
-	{
-
-		while (fgets (linea, 255, fp_simpli) != NULL)
-		{
-			switch (linea[0])
-			{
-
-			case 'C' :
-				sscanf(linea, "%s %f %f %f ", &str, &xc, &yc, &zc );
-				cx = xc;
-				cy = zc;
-				cz = yc;
-			
-				break;
-
-			//para almacenar la caja envolvente también cambio las componentes y y z
-			case 'x' :
-				sscanf(linea, "%s %f %f", &str, &xmax, &xmin );
-				break;
-
-			case 'y' :
-				sscanf(linea, "%s %f %f", &str, &zmax, &zmin );
-				break;
-
-			case 'z' :
-				sscanf(linea, "%s %f %f", &str, &ymax, &ymin );
-				rad = (float)(sqrt ((xmax-cx)*(xmax-cx)+ (ymax-cy)*(ymax-cy)+ (zmax-cz)*(zmax-cz)))-3;
-
-				break;
-
-
-
-			case 'N':
-			
-				//N 446 Ver 10176 10178 10169 10171  Tv 156 154 E 2
-	
-				sscanf(linea, "%s %lu %s %lu %lu  %lu %lu %s %lu %lu %s %i", 
-					&str, &tn, &str, &v0, &v1, &v2, &v3, &str, &tv1, &tv2, &str, &e );
-				Hojas[tn].Vert_Hoja[0] = v0;
-				Hojas[tn].Vert_Hoja[1] = v1;
-				Hojas[tn].Vert_Hoja[2] = v2;
-				Hojas[tn].Vert_Hoja[3] = v3;
-
-				Hojas[tn].visible = 0;
-
-				GetNormalH  (Hojas[tn]);
-	
-				Hojas[tn].hijoi= tv1;
-				Hojas[tn].hijod= tv2;
-
-				Hojas[tv1].padre = tn;
-				Hojas[tv2].padre = tn;
-
-				break;
-
-			default:
-				break;
-
-			}
-		}
-
-	}
-
-		
-	return (tn);
-}
-*/
- 
-//--------------------------------------------------------------------------------------------------------------------------------
-// relleno la lista de las hojas con el menor detalle para hacer el culling
-// cada hoja ahora tiene un índice a la hoja raíz de su árbol
-//--------------------------------------------------------------------------------------------------------------------------------
-
-void Arbol::RellenoRaiz (void)
-{
-	int i,j, k, t, cont;
-	bool esta, fin;
-
-	i=0;
-	k=-1;
-	cont =-1;
-
-	MinDet  = new Activas[nHojas*2];
-	
-	while (i<TotHojas)
-	{
-		j=i;
-		while (Hojas[j].padre > -1) j= Hojas[j].padre;
-		Hojas[i].raiz = j;
-
-
-		// para la estructura MinDet
-		if ( k == -1){
-			k++;
-			MinDet[k].indice = j;
-			cont =k;
-		}
-		else
-		{
-			t = 0;
-			esta = false;
-			fin = false;
-
-			while (( fin == false) && (esta == false))
-			{	if ( MinDet[t].indice == j) esta = true;
-					else t++;
-				if (MinDet[t].indice == -1) fin = true;
-			}
-
-			if ( esta == false) //añado al final
-			{
-				cont++;
-				MinDet[cont].indice = j;
-			}
-		}
-
-	i++;
-	}	
-
-	minHojas = cont;
-
-}
-
-void Arbol::CalculaTexCoordsYNorms(void)
-{	
-	vertexdata->Begin();
-	for (int i=0; i<nHojas; i++)
-	{	
-		const float* lanormal = Hojas[i].Normal;
-		vertexdata->SetVertexNormal(Hojas[i].Vert_Hoja[0], lanormal[0], lanormal[1], lanormal[2]);
-		vertexdata->SetVertexTexCoord(Hojas[i].Vert_Hoja[0], 0.0f, 1.0f);
-
-		vertexdata->SetVertexNormal(Hojas[i].Vert_Hoja[1], lanormal[0], lanormal[1], lanormal[2]);
-		vertexdata->SetVertexTexCoord(Hojas[i].Vert_Hoja[1], 0.0f, 0.0f);
-
-		vertexdata->SetVertexNormal(Hojas[i].Vert_Hoja[2], lanormal[0], lanormal[1], lanormal[2]);
-		vertexdata->SetVertexTexCoord(Hojas[i].Vert_Hoja[2], 1.0f, 1.0f);
-
-		vertexdata->SetVertexNormal(Hojas[i].Vert_Hoja[3], lanormal[0], lanormal[1], lanormal[2]);
-		vertexdata->SetVertexTexCoord(Hojas[i].Vert_Hoja[3], 1.0f, 0.0f);
-
-
-/*		MiArbol->Vertices[aHoja.Vert_Hoja[1]].GetCoordinates (a,b,c);
-		glTexCoord2f ( 0.0, 1.0);
-		glVertex3f (a,b,c);
-	
-		MiArbol->Vertices[aHoja.Vert_Hoja[2]].GetCoordinates (a,b,c);
-		glTexCoord2f ( 1.0, 0.0);
-		glVertex3f (a,b,c);
-
-		MiArbol->Vertices[aHoja.Vert_Hoja[3]].GetCoordinates (a,b,c);
-		glTexCoord2f ( 1.0, 1.0);
-		glVertex3f (a,b,c);*/
-	}
-	vertexdata->End();
-}
-
-Arbol::Arbol(Arbol *ar)
-{
-	nHojas=ar->nHojas;
-	MinDet  = new Activas[nHojas*2];
-//	for (unsigned int i=0; i<nHojas*2; i++)
-//		MinDet[i]=ar->MinDet[i];
-	memcpy(MinDet,ar->MinDet,sizeof(Activas)*nHojas*2);
-	TotHojas=ar->TotHojas;
-	cx=ar->cx;
-	cy=ar->cy;
-	cz=ar->cz;
-	rad=ar->rad;
-	minHojas=ar->minHojas;
-	TotVerts=ar->TotVerts;
-
-	create_vertex_data_func=ar->create_vertex_data_func;
-	create_index_data_func=ar->create_index_data_func;
-	vertexdata=create_vertex_data_func(ar->vertexdata->GetNumVertices());
-	vertexdata->Begin(); 
-	for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++) 
-	{
-		float va,vb,vc;
-		ar->vertexdata->GetVertexCoord(i,va,vb,vc);
-		vertexdata->SetVertexCoord(i,va,vb,vc);
-		ar->vertexdata->GetVertexNormal(i,va,vb,vc);
-		vertexdata->SetVertexNormal(i,va,vb,vc);
-	}
-	vertexdata->End();
-	indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices());
-	indexdata->Begin(); 
-	for (unsigned int i=0; i<indexdata->GetNumMaxIndices(); i++) 
-		indexdata->SetIndex(i,ar->indexdata->GetIndex(i));
-	indexdata->End();
-
-	Hojas=new Hoja[vertexdata->GetNumVertices()];
-//	for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++) 
-//		Hojas[i]=ar->Hojas[i];
-	memcpy(Hojas,ar->Hojas,sizeof(Hoja)*vertexdata->GetNumVertices());
-
-	// esto no sé si devería haber akí
-	indexdata->SetNumValidIndices(0);
-}
Index: P/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/arbol.h	(revision 895)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#ifndef ARBOL_H
-#define ARBOL_H 
-
-
-#include "Hoja.h"
-#include "vertexdata.h"
-#include "Point3D.h"
-#include "Activas.h"
-#include "GeoSubMesh.h"
-
-class Arbol
-{
-	private:
-		Geometry::CREATEVERTEXDATAFUNC create_vertex_data_func;		
-		Geometry::CREATEINDEXDATAFUNC create_index_data_func;
-
-	public :
-	// Variable members
-		
-		Geometry::VertexData *vertexdata;
-		Geometry::IndexData *indexdata;
-
-		Hoja   *Hojas;
-		Activas  *MinDet; // primera hoja activa
-		int nHojas;
-		int TotHojas;
-		
-		float cx,cy,cz; //centro de la copa// para los impostores y resolucion variable
-		float rad; //radio de la esfera envolvente
-		int minHojas;
-
-//		float *normales_vert;
-//		float *normales_vert2;
-//		float *tex_coords;
-		int TotVerts;
-
-	public :
-//		Arbol (const char *, const char *, const char*, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); // Constructor with the name of a file cotaining the data
-		Arbol (const Geometry::SubMesh *, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); // Constructor with the name of a file cotaining the data
-		Arbol (Arbol *a);
-		virtual ~Arbol (void); // Destructor
-		
-		// Montan la estructura
-//		void ReadFromFile (const char *, const char*, const char*/*, char**/); // Reads a obj-model from a file
-/*		int LeeVertices ( const char * );
-		int LeoHojas( const char *);
-//		int LeoTronco( char *);
-		int LeoHojasSimpl( const char*);*/
-		void ReadLeafs(const Geometry::SubMesh *);
-		void ReadVertices(const Geometry::SubMesh *);
-		bool ReadSimpSeq(const char*); /// returns true when successful
-		void RellenoRaiz (void);
-
-		void GetNormalH (Hoja&);
-//		void GetNormalT(Tronco&);
-
-		void CrossProduct(const float *v1, const float *v2, float *res);
-		void Normalize(const float *v, float *res);
-//		void CalculaNormalesVertice(void);
-		void CalculaTexCoordsYNorms(void);
-        
-		
-};
-
-#endif
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp	(revision 1018)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp	(revision 1019)
@@ -2,5 +2,4 @@
 #include <assert.h>
 #include "GeoLodTreeLibrary.h"
-#include "libs/leaves/arbol.h"
 #include "libs/leaves/Foliage.h"
 
@@ -29,6 +28,5 @@
 //	arbol = new Arbol(foliage_verts.c_str(),foliage_leafs.c_str(),foliage_simpl.c_str(),NULL/*vdfun*/,NULL/*idfun*/);
 	Geometry::SubMesh * leafsSubMesh = &(treeGeoMesh->mSubMesh[leafSubMeshID]);
-	arbol = new Arbol(leafsSubMesh,leafSimpSeqFile.c_str());
-	foliage = new Foliage(arbol);
+	foliage = new Foliage(leafsSubMesh,leafSimpSeqFile.c_str());
 }
 /*
@@ -54,5 +52,4 @@
 {
 	if (trunk) delete trunk;
-	if (arbol) delete arbol;
 	if (foliage) delete foliage;
 /*	if (trunk_all_indices) delete trunk_all_indices;
@@ -111,6 +108,6 @@
 	foliage->AjusteHojas(newlod);
 
-	arbol->indexdata->Begin();
-	arbol->vertexdata->Begin();
+	foliage->indexdata->Begin();
+	foliage->vertexdata->Begin();
 	int i = foliage->ppio;
 	int auxnumhojas = 0;
@@ -121,6 +118,6 @@
 	}
 
-	assert(auxnumhojas*6<=int(arbol->indexdata->GetNumMaxIndices()));
-	arbol->indexdata->SetNumValidIndices(auxnumhojas*6);
+	assert(auxnumhojas*6<=int(foliage->indexdata->GetNumMaxIndices()));
+	foliage->indexdata->SetNumValidIndices(auxnumhojas*6);
 	i = foliage->ppio;
 	int kkkk=0;
@@ -128,26 +125,26 @@
 	{
 		unsigned int v0,v1,v2,v3;
-		v0 = arbol->Hojas[i].Vert_Hoja[0];
-		v1 = arbol->Hojas[i].Vert_Hoja[1];
-		v2 = arbol->Hojas[i].Vert_Hoja[2];
-		v3 = arbol->Hojas[i].Vert_Hoja[3];
-
-		arbol->indexdata->SetIndex(kkkk+0,v0);
-		arbol->indexdata->SetIndex(kkkk+1,v1);
-		arbol->indexdata->SetIndex(kkkk+2,v2);
-		arbol->indexdata->SetIndex(kkkk+3,v2);
-		arbol->indexdata->SetIndex(kkkk+4,v1);
-		arbol->indexdata->SetIndex(kkkk+5,v3);
-
-		arbol->vertexdata->SetVertexTexCoord(v0,0,0);
-		arbol->vertexdata->SetVertexTexCoord(v1,0,1);
-		arbol->vertexdata->SetVertexTexCoord(v2,1,0);
-		arbol->vertexdata->SetVertexTexCoord(v3,1,1); 
+		v0 = foliage->Leaves[i].vertsLeaf[0];
+		v1 = foliage->Leaves[i].vertsLeaf[1];
+		v2 = foliage->Leaves[i].vertsLeaf[2];
+		v3 = foliage->Leaves[i].vertsLeaf[3];
+
+		foliage->indexdata->SetIndex(kkkk+0,v0);
+		foliage->indexdata->SetIndex(kkkk+1,v1);
+		foliage->indexdata->SetIndex(kkkk+2,v2);
+		foliage->indexdata->SetIndex(kkkk+3,v2);
+		foliage->indexdata->SetIndex(kkkk+4,v1);
+		foliage->indexdata->SetIndex(kkkk+5,v3);
+
+		foliage->vertexdata->SetVertexTexCoord(v0,0,0);
+		foliage->vertexdata->SetVertexTexCoord(v1,0,1);
+		foliage->vertexdata->SetVertexTexCoord(v2,1,0);
+		foliage->vertexdata->SetVertexTexCoord(v3,1,1); 
 
 		kkkk+=6;
 		i=foliage->Acth[i].next;
 	}
-	arbol->indexdata->End();
-	arbol->vertexdata->End();
+	foliage->indexdata->End();
+	foliage->vertexdata->End();
 
 	return 0;
@@ -157,5 +154,5 @@
 {
 //	return arbol->minHojas;
-	return arbol->nHojas;
+	return foliage->nHojas;
 }
 uint32 LodTreeLibrary::MaxFoliageLod(void) const
@@ -163,5 +160,5 @@
 	//	return arbol->TotHojas;
 	//return arbol->nHojas;
-	return arbol->minHojas;
+	return foliage->minHojas;
 }
 
@@ -180,5 +177,5 @@
 const VertexData* LodTreeLibrary::Get_Foliage_VertexData(void) const
 {
-	return arbol->vertexdata;
+	return foliage->vertexdata;
 }
 
@@ -186,5 +183,5 @@
 {
 //	return current_foliage_indices;
-	return arbol->indexdata;
+	return foliage->indexdata;
 }
 
@@ -198,5 +195,5 @@
 {
 //	return current_foliage_indexcount;
-	return arbol->indexdata->GetNumValidIndices();
+	return foliage->indexdata->GetNumValidIndices();
 }
 /*
@@ -218,4 +215,4 @@
 uint32 LodTreeLibrary::Get_Foliage_MaxIndexCount(void) const
 {
-	return arbol->indexdata->GetNumMaxIndices();
-}
+	return foliage->indexdata->GetNumMaxIndices();
+}
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimplifier.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimplifier.cpp	(revision 1014)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimplifier.cpp	(revision 1019)
@@ -1,4 +1,4 @@
 #include "GeoTreeSimplifier.h"
-#include "Hoja.h"
+#include "Leaf.h"
 
 #include <iostream>
@@ -87,5 +87,5 @@
 /*	std::map<float,int> hojas_x_crit;
 	for (int i=0; i<countLeaves; i++)
-		hojas_x_crit[Leaves[i].criterio] = i;
+		hojas_x_crit[Leaves[i].criteria] = i;
 
 	int *leaf_order = new int[countLeaves];
@@ -167,5 +167,5 @@
 
 	if (countLeaves > 0)
-		Leaves = new Hoja[2*countLeaves];
+		Leaves = new Leaf[2*countLeaves];
 
 	activeLeaves = countLeaves;
@@ -191,15 +191,15 @@
 		v2=mesh->mSubMesh[meshLeaves].mIndex[j+1];
 		v3=mesh->mSubMesh[meshLeaves].mIndex[j+2];
-		Leaves[pos].Vert_Hoja[0]=v1;
-		Leaves[pos].Vert_Hoja[1]=v2;
-		Leaves[pos].Vert_Hoja[2]=v3;
-		Leaves[pos].id_triangulo[0]=triangleID;
-		Leaves[pos].existe=true;
+		Leaves[pos].vertsLeaf[0]=v1;
+		Leaves[pos].vertsLeaf[1]=v2;
+		Leaves[pos].vertsLeaf[2]=v3;
+		Leaves[pos].idTriangle[0]=triangleID;
+		Leaves[pos].exists=true;
 		triangleID++;
 
 		// second triangle
 		v3=mesh->mSubMesh[meshLeaves].mIndex[j+5];
-		Leaves[pos].Vert_Hoja[3]=v3;
-		Leaves[pos].id_triangulo[1]=triangleID;
+		Leaves[pos].vertsLeaf[3]=v3;
+		Leaves[pos].idTriangle[1]=triangleID;
 		triangleID++;
 
@@ -228,5 +228,5 @@
 
 // Calculates the center of a leaf
-void TreeSimplifier::CalculateLeafCenter(Hoja &auxleaf)
+void TreeSimplifier::CalculateLeafCenter(Leaf &auxleaf)
 {
 	float	max_x;
@@ -238,34 +238,34 @@
 	
 	//x1
-	max_x	=	max(max(Vertex[auxleaf.Vert_Hoja[0]][0],Vertex[auxleaf.Vert_Hoja[1]][0]),
-				    max(Vertex[auxleaf.Vert_Hoja[2]][0],Vertex[auxleaf.Vert_Hoja[3]][0]));
-	
-	min_x	=	min(min(Vertex[auxleaf.Vert_Hoja[0]][0],Vertex[auxleaf.Vert_Hoja[1]][0]),
-				  	min(Vertex[auxleaf.Vert_Hoja[2]][0],Vertex[auxleaf.Vert_Hoja[3]][0]));
-
-	auxleaf.Centro[0] = (max_x + min_x)/2;
+	max_x	=	max(max(Vertex[auxleaf.vertsLeaf[0]][0],Vertex[auxleaf.vertsLeaf[1]][0]),
+				    max(Vertex[auxleaf.vertsLeaf[2]][0],Vertex[auxleaf.vertsLeaf[3]][0]));
+	
+	min_x	=	min(min(Vertex[auxleaf.vertsLeaf[0]][0],Vertex[auxleaf.vertsLeaf[1]][0]),
+				  	min(Vertex[auxleaf.vertsLeaf[2]][0],Vertex[auxleaf.vertsLeaf[3]][0]));
+
+	auxleaf.center[0] = (max_x + min_x)/2;
 
 	//y1
-	max_y	=	max(max(Vertex[auxleaf.Vert_Hoja[0]][1],Vertex[auxleaf.Vert_Hoja[1]][1]),
-				  	max(Vertex[auxleaf.Vert_Hoja[2]][1],Vertex[auxleaf.Vert_Hoja[3]][1]));
-	
-	min_y	=	min(min(Vertex[auxleaf.Vert_Hoja[0]][1],Vertex[auxleaf.Vert_Hoja[1]][1]),
-				  	min(Vertex[auxleaf.Vert_Hoja[2]][1],Vertex[auxleaf.Vert_Hoja[3]][1]));
-
-	auxleaf.Centro[1]	=	(max_y + min_y) / 2;
+	max_y	=	max(max(Vertex[auxleaf.vertsLeaf[0]][1],Vertex[auxleaf.vertsLeaf[1]][1]),
+				  	max(Vertex[auxleaf.vertsLeaf[2]][1],Vertex[auxleaf.vertsLeaf[3]][1]));
+	
+	min_y	=	min(min(Vertex[auxleaf.vertsLeaf[0]][1],Vertex[auxleaf.vertsLeaf[1]][1]),
+				  	min(Vertex[auxleaf.vertsLeaf[2]][1],Vertex[auxleaf.vertsLeaf[3]][1]));
+
+	auxleaf.center[1]	=	(max_y + min_y) / 2;
 	
 	//z1
-	max_z	=	max(max(Vertex[auxleaf.Vert_Hoja[0]][2],Vertex[auxleaf.Vert_Hoja[1]][2]),
-				  	max(Vertex[auxleaf.Vert_Hoja[2]][2],Vertex[auxleaf.Vert_Hoja[3]][2]));
-	
-	min_z	=	min(min(Vertex[auxleaf.Vert_Hoja[0]][2],Vertex[auxleaf.Vert_Hoja[1]][2]),
-				  	min(Vertex[auxleaf.Vert_Hoja[2]][2],Vertex[auxleaf.Vert_Hoja[3]][2]));
-
-	auxleaf.Centro[2]	=	(max_z + min_z) / 2;
+	max_z	=	max(max(Vertex[auxleaf.vertsLeaf[0]][2],Vertex[auxleaf.vertsLeaf[1]][2]),
+				  	max(Vertex[auxleaf.vertsLeaf[2]][2],Vertex[auxleaf.vertsLeaf[3]][2]));
+	
+	min_z	=	min(min(Vertex[auxleaf.vertsLeaf[0]][2],Vertex[auxleaf.vertsLeaf[1]][2]),
+				  	min(Vertex[auxleaf.vertsLeaf[2]][2],Vertex[auxleaf.vertsLeaf[3]][2]));
+
+	auxleaf.center[2]	=	(max_z + min_z) / 2;
 }
 
 
 //  calculate the normal vector of a leaf
-void TreeSimplifier::CalculateLeafNormal(Hoja &auxleaf)
+void TreeSimplifier::CalculateLeafNormal(Leaf &auxleaf)
 {
 	float onex, oney, onez;
@@ -273,11 +273,11 @@
 	float threex, threey, threez;
 
-	onex   = Vertex[auxleaf.Vert_Hoja[0]][0]; oney   = Vertex[auxleaf.Vert_Hoja[0]][1]; onez   = Vertex[auxleaf.Vert_Hoja[0]][2];
-	twox   = Vertex[auxleaf.Vert_Hoja[1]][0]; twoy   = Vertex[auxleaf.Vert_Hoja[1]][1]; twoz   = Vertex[auxleaf.Vert_Hoja[1]][2];
-	threex = Vertex[auxleaf.Vert_Hoja[2]][0]; threey = Vertex[auxleaf.Vert_Hoja[2]][1]; threez = Vertex[auxleaf.Vert_Hoja[2]][2];
-	
-	auxleaf.Normal[0] = ((twoz-onez)*(threey-oney)) - ((twoy-oney)*(threez-onez));
-	auxleaf.Normal[1] = ((twox-onex)*(threez-onez)) - ((threex-onex)*(twoz-onez));
-	auxleaf.Normal[2] = ((threex-onex)*(twoy-oney)) - ((twox-onex)*(threey-oney));	
+	onex   = Vertex[auxleaf.vertsLeaf[0]][0]; oney   = Vertex[auxleaf.vertsLeaf[0]][1]; onez   = Vertex[auxleaf.vertsLeaf[0]][2];
+	twox   = Vertex[auxleaf.vertsLeaf[1]][0]; twoy   = Vertex[auxleaf.vertsLeaf[1]][1]; twoz   = Vertex[auxleaf.vertsLeaf[1]][2];
+	threex = Vertex[auxleaf.vertsLeaf[2]][0]; threey = Vertex[auxleaf.vertsLeaf[2]][1]; threez = Vertex[auxleaf.vertsLeaf[2]][2];
+	
+	auxleaf.normal[0] = ((twoz-onez)*(threey-oney)) - ((twoy-oney)*(threez-onez));
+	auxleaf.normal[1] = ((twox-onex)*(threez-onez)) - ((threex-onex)*(twoz-onez));
+	auxleaf.normal[2] = ((threex-onex)*(twoy-oney)) - ((twox-onex)*(threey-oney));	
 }
 
@@ -296,14 +296,14 @@
 	float dist1, dist2, dist3, dist4, distmp, dista, distb, dist;
 
-	onex=Vertex[leaf1.Vert_Hoja[0]][0]; oney= Vertex[leaf1.Vert_Hoja[0]][1]; onez = Vertex[leaf1.Vert_Hoja[0]][2];
-	twox = Vertex[leaf1.Vert_Hoja[1]][0]; twoy = Vertex[leaf1.Vert_Hoja[1]][1]; twoz = Vertex[leaf1.Vert_Hoja[1]][2];
-	threex = Vertex[leaf1.Vert_Hoja[2]][0]; threey = Vertex[leaf1.Vert_Hoja[2]][1]; threez = Vertex[leaf1.Vert_Hoja[2]][2];
-	fourx = Vertex[leaf1.Vert_Hoja[3]][0]; foury = Vertex[leaf1.Vert_Hoja[3]][1]; fourz = Vertex[leaf1.Vert_Hoja[3]][2];
-	
-
-	x1 = Vertex[leaf2.Vert_Hoja[0]][0]; y1 = Vertex[leaf2.Vert_Hoja[0]][1]; z1 = Vertex[leaf2.Vert_Hoja[0]][2];
-	x2 = Vertex[leaf2.Vert_Hoja[1]][0]; y2 = Vertex[leaf2.Vert_Hoja[1]][1]; z2 = Vertex[leaf2.Vert_Hoja[1]][2];
-	x3 = Vertex[leaf2.Vert_Hoja[2]][0]; y3 = Vertex[leaf2.Vert_Hoja[2]][1]; z3 = Vertex[leaf2.Vert_Hoja[2]][2];
-	x4 = Vertex[leaf2.Vert_Hoja[3]][0]; y4 = Vertex[leaf2.Vert_Hoja[3]][1]; z4 = Vertex[leaf2.Vert_Hoja[3]][2];
+	onex=Vertex[leaf1.vertsLeaf[0]][0]; oney= Vertex[leaf1.vertsLeaf[0]][1]; onez = Vertex[leaf1.vertsLeaf[0]][2];
+	twox = Vertex[leaf1.vertsLeaf[1]][0]; twoy = Vertex[leaf1.vertsLeaf[1]][1]; twoz = Vertex[leaf1.vertsLeaf[1]][2];
+	threex = Vertex[leaf1.vertsLeaf[2]][0]; threey = Vertex[leaf1.vertsLeaf[2]][1]; threez = Vertex[leaf1.vertsLeaf[2]][2];
+	fourx = Vertex[leaf1.vertsLeaf[3]][0]; foury = Vertex[leaf1.vertsLeaf[3]][1]; fourz = Vertex[leaf1.vertsLeaf[3]][2];
+	
+
+	x1 = Vertex[leaf2.vertsLeaf[0]][0]; y1 = Vertex[leaf2.vertsLeaf[0]][1]; z1 = Vertex[leaf2.vertsLeaf[0]][2];
+	x2 = Vertex[leaf2.vertsLeaf[1]][0]; y2 = Vertex[leaf2.vertsLeaf[1]][1]; z2 = Vertex[leaf2.vertsLeaf[1]][2];
+	x3 = Vertex[leaf2.vertsLeaf[2]][0]; y3 = Vertex[leaf2.vertsLeaf[2]][1]; z3 = Vertex[leaf2.vertsLeaf[2]][2];
+	x4 = Vertex[leaf2.vertsLeaf[3]][0]; y4 = Vertex[leaf2.vertsLeaf[3]][1]; z4 = Vertex[leaf2.vertsLeaf[3]][2];
 
 	dist1 = distan ( onex, oney,onez,x1,y1,z1);
@@ -414,5 +414,5 @@
 
 //  Calculate the Hausdorff distance (distance between point clouds) (Optimized)
-float TreeSimplifier::HausdorffOptimized(const Hoja &leaf1, const Hoja& leaf2) const
+float TreeSimplifier::HausdorffOptimized(const Leaf &leaf1, const Leaf& leaf2) const
 {
 	float onex, oney, onez;
@@ -426,13 +426,13 @@
 	float dist1, dist2, dist3, dist4, distmp, dista, distb, dist;
 
-	onex   = Vertex[leaf1.Vert_Hoja[0]][0]; oney   = Vertex[leaf1.Vert_Hoja[0]][1]; onez   = Vertex[leaf1.Vert_Hoja[0]][2];
-	twox   = Vertex[leaf1.Vert_Hoja[1]][0]; twoy   = Vertex[leaf1.Vert_Hoja[1]][1]; twoz   = Vertex[leaf1.Vert_Hoja[1]][2];
-	threex = Vertex[leaf1.Vert_Hoja[2]][0]; threey = Vertex[leaf1.Vert_Hoja[2]][1]; threez = Vertex[leaf1.Vert_Hoja[2]][2];
-	fourx  = Vertex[leaf1.Vert_Hoja[3]][0]; foury  = Vertex[leaf1.Vert_Hoja[3]][1]; fourz  = Vertex[leaf1.Vert_Hoja[3]][2];
-
-	x1 = Vertex[leaf2.Vert_Hoja[0]][0]; y1 = Vertex[leaf2.Vert_Hoja[0]][1]; z1 = Vertex[leaf2.Vert_Hoja[0]][2];
-	x2 = Vertex[leaf2.Vert_Hoja[1]][0]; y2 = Vertex[leaf2.Vert_Hoja[1]][1]; z2 = Vertex[leaf2.Vert_Hoja[1]][2];
-	x3 = Vertex[leaf2.Vert_Hoja[2]][0]; y3 = Vertex[leaf2.Vert_Hoja[2]][1]; z3 = Vertex[leaf2.Vert_Hoja[2]][2];
-	x4 = Vertex[leaf2.Vert_Hoja[3]][0]; y4 = Vertex[leaf2.Vert_Hoja[3]][1]; z4 = Vertex[leaf2.Vert_Hoja[3]][2];
+	onex   = Vertex[leaf1.vertsLeaf[0]][0]; oney   = Vertex[leaf1.vertsLeaf[0]][1]; onez   = Vertex[leaf1.vertsLeaf[0]][2];
+	twox   = Vertex[leaf1.vertsLeaf[1]][0]; twoy   = Vertex[leaf1.vertsLeaf[1]][1]; twoz   = Vertex[leaf1.vertsLeaf[1]][2];
+	threex = Vertex[leaf1.vertsLeaf[2]][0]; threey = Vertex[leaf1.vertsLeaf[2]][1]; threez = Vertex[leaf1.vertsLeaf[2]][2];
+	fourx  = Vertex[leaf1.vertsLeaf[3]][0]; foury  = Vertex[leaf1.vertsLeaf[3]][1]; fourz  = Vertex[leaf1.vertsLeaf[3]][2];
+
+	x1 = Vertex[leaf2.vertsLeaf[0]][0]; y1 = Vertex[leaf2.vertsLeaf[0]][1]; z1 = Vertex[leaf2.vertsLeaf[0]][2];
+	x2 = Vertex[leaf2.vertsLeaf[1]][0]; y2 = Vertex[leaf2.vertsLeaf[1]][1]; z2 = Vertex[leaf2.vertsLeaf[1]][2];
+	x3 = Vertex[leaf2.vertsLeaf[2]][0]; y3 = Vertex[leaf2.vertsLeaf[2]][1]; z3 = Vertex[leaf2.vertsLeaf[2]][2];
+	x4 = Vertex[leaf2.vertsLeaf[3]][0]; y4 = Vertex[leaf2.vertsLeaf[3]][1]; z4 = Vertex[leaf2.vertsLeaf[3]][2];
 
 	// variables used to cache distances
@@ -608,5 +608,5 @@
 	for (i = 0; i < countLeaves; i++)
 	{
-		if (Leaves[i].existe)
+		if (Leaves[i].exists)
 		{
 			if (mindist > Leaves[i].dist || which==-1)
@@ -631,5 +631,5 @@
 	for (i=0;i<countLeaves;i++)
 	{
-		if (Leaves[i].existe)
+		if (Leaves[i].exists)
 		{
 			if (i == countLeaves-1)
@@ -638,15 +638,15 @@
 				j =	i + 1;
 			
-			while (Leaves[j].existe == false)
+			while (Leaves[j].exists == false)
 				j++;
 			
-			cop	= Leaves[i].Coplanaridad(Leaves[j]);
-			Leaves[i].hoja_cop	=	j;
+			cop	= Leaves[i].Coplanarity(Leaves[j]);
+			Leaves[i].leafCop	=	j;
 			
 			for (j=0; j<countLeaves-1; j++)
 			{
-				if (( j != i) && (Leaves[j].existe))
+				if (( j != i) && (Leaves[j].exists))
 				{
-					coptmp	=	Leaves[i].Coplanaridad(Leaves[j]);
+					coptmp	=	Leaves[i].Coplanarity(Leaves[j]);
 
 					// Take the most coplanar: close to 1
@@ -654,5 +654,5 @@
 					{
 						cop	= coptmp;
-						Leaves[i].hoja_cop = j;
+						Leaves[i].leafCop = j;
 					}
 				}
@@ -729,11 +729,11 @@
 
 	// initialize all vertices to the first
-	xmax = Vertex[Leaves[0].Vert_Hoja[0]][0];
+	xmax = Vertex[Leaves[0].vertsLeaf[0]][0];
 	xmin = xmax;
 
-	ymax = Vertex[Leaves[0].Vert_Hoja[0]][1];
+	ymax = Vertex[Leaves[0].vertsLeaf[0]][1];
 	ymin = ymax;
 
-	zmax = Vertex[Leaves[0].Vert_Hoja[0]][2];
+	zmax = Vertex[Leaves[0].vertsLeaf[0]][2];
 	zmin = zmax;
 
@@ -753,12 +753,12 @@
 		for (j=0;j<4;j++)
 		{			
-			if ( xmax < Vertex[Leaves[i].Vert_Hoja[j]][0]) xmax = Vertex[Leaves[i].Vert_Hoja[j]][0];
-			if ( xmin > Vertex[Leaves[i].Vert_Hoja[j]][0]) xmin = Vertex[Leaves[i].Vert_Hoja[j]][0];
-
-			if ( ymax < Vertex[Leaves[i].Vert_Hoja[j]][1]) ymax = Vertex[Leaves[i].Vert_Hoja[j]][1];
-			if ( ymin > Vertex[Leaves[i].Vert_Hoja[j]][1]) ymin = Vertex[Leaves[i].Vert_Hoja[j]][1];
+			if ( xmax < Vertex[Leaves[i].vertsLeaf[j]][0]) xmax = Vertex[Leaves[i].vertsLeaf[j]][0];
+			if ( xmin > Vertex[Leaves[i].vertsLeaf[j]][0]) xmin = Vertex[Leaves[i].vertsLeaf[j]][0];
+
+			if ( ymax < Vertex[Leaves[i].vertsLeaf[j]][1]) ymax = Vertex[Leaves[i].vertsLeaf[j]][1];
+			if ( ymin > Vertex[Leaves[i].vertsLeaf[j]][1]) ymin = Vertex[Leaves[i].vertsLeaf[j]][1];
 			
-			if ( zmax < Vertex[Leaves[i].Vert_Hoja[j]][2]) zmax = Vertex[Leaves[i].Vert_Hoja[j]][2];
-			if ( zmin > Vertex[Leaves[i].Vert_Hoja[j]][2]) zmin = Vertex[Leaves[i].Vert_Hoja[j]][2];
+			if ( zmax < Vertex[Leaves[i].vertsLeaf[j]][2]) zmax = Vertex[Leaves[i].vertsLeaf[j]][2];
+			if ( zmin > Vertex[Leaves[i].vertsLeaf[j]][2]) zmin = Vertex[Leaves[i].vertsLeaf[j]][2];
 		}
 	}
@@ -802,6 +802,6 @@
 		{
 			//incializo criterio a un numero elevado
-			Leaves[i].criterio = 1000;
-			nhojasi = int(Leaves[i].Cuantas_hojas);
+			Leaves[i].criteria = 1000;
+			nhojasi = int(Leaves[i].parentLeafCount);
 			//coplanaridad
 			for ( j =0; j<countLeaves;j++)
@@ -813,5 +813,5 @@
 					// ES COMO MÁXIMO 1
 
-					nhojasj = int(Leaves[j].Cuantas_hojas);
+					nhojasj = int(Leaves[j].parentLeafCount);
 
 					if ( abs((nhojasi - nhojasj)) < 2)
@@ -826,7 +826,7 @@
 						criteriotmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 						//selecciono el criterio menor
-						if (Leaves[i].criterio > criteriotmp) 
+						if (Leaves[i].criteria > criteriotmp) 
 						{
-							Leaves[i].criterio = criteriotmp;
+							Leaves[i].criteria = criteriotmp;
 							Leaves[i].hoja_crit = j;
 						}
@@ -854,9 +854,9 @@
 		if ((Leaves[i].existe == true) && (i != hojanueva))
 		{	
-			nhojasi = int(Leaves[i].Cuantas_hojas);
+			nhojasi = int(Leaves[i].parentLeafCount);
 			//¿ SE HA DESACTIVADO LA HOJA_CRIT QUE GUARDABA LA HOJA?
 			if ( Leaves[Leaves[i].hoja_crit].existe == false)
 			{
-				Leaves[i].criterio = 1000;
+				Leaves[i].criteria = 1000;
 
 				//coplanaridad
@@ -869,5 +869,5 @@
 						// ES COMO MÁXIMO 1
 
-						nhojasj = int(Leaves[j].Cuantas_hojas);
+						nhojasj = int(Leaves[j].parentLeafCount);
 
 						if ( abs((nhojasi - nhojasj)) < 2)
@@ -884,7 +884,7 @@
 							criteriotmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 							//selecciono el criterio menor
-							if (Leaves[i].criterio > criteriotmp) 
+							if (Leaves[i].criteria > criteriotmp) 
 							{
-								Leaves[i].criterio = criteriotmp;
+								Leaves[i].criteria = criteriotmp;
 								Leaves[i].hoja_crit = j;
 							}
@@ -895,5 +895,5 @@
 			else
 			{ // CALCULARE SI EL CRITERIO CON ESTA HOJA ES MENOR QUE EL ANTERIOR
-				nhojasj = int(Leaves[hojanueva].Cuantas_hojas);
+				nhojasj = int(Leaves[hojanueva].parentLeafCount);
 
 				if ( abs((nhojasi - nhojasj)) < 2)
@@ -909,7 +909,7 @@
 					criteriotmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 					//selecciono el criterio menor
-					if (Leaves[i].criterio > criteriotmp) 
+					if (Leaves[i].criteria > criteriotmp) 
 					{	
-						Leaves[i].criterio = criteriotmp;
+						Leaves[i].criteria = criteriotmp;
 						Leaves[i].hoja_crit = hojanueva;
 					}
@@ -929,14 +929,14 @@
 		
 /*	while (Leaves[i].existe != true) i++;
-	mincrit = Leaves[i].criterio;
+	mincrit = Leaves[i].criteria;
 	which =i;
 	*/
 	for (int i=0;i<countLeaves;i++)
 	{
-		if (Leaves[i].existe)
-		{
-			if (mincrit>Leaves[i].criterio || which==-1)
+		if (Leaves[i].exists)
+		{
+			if (mincrit>Leaves[i].criteria || which==-1)
 			{
-				mincrit = Leaves[i].criterio;
+				mincrit = Leaves[i].criteria;
 				which = i;
 			}
@@ -948,5 +948,5 @@
 
 
-void TreeSimplifier::ChooseVertices(Hoja& leaf1, Hoja& leaf2, long int count)
+void TreeSimplifier::ChooseVertices(Leaf& leaf1, Leaf& leaf2, long int count)
 {
 	float a,b,c;
@@ -954,33 +954,33 @@
 	int indices[4];
 	
-	a = Vertex[leaf1.Vert_Hoja[0]][0];
-	b = Vertex[leaf1.Vert_Hoja[0]][1];
-	c = Vertex[leaf1.Vert_Hoja[0]][2];
-
-	dist[0] = ((leaf2.Centro[0]-a)*(leaf2.Centro[0]-a)) + ((leaf2.Centro[1]-b)*(leaf2.Centro[1]-b)) +
-		   ((leaf2.Centro[2]-c)*(leaf2.Centro[2]-c));
-
-	
-	a = Vertex[leaf1.Vert_Hoja[1]][0];
-	b = Vertex[leaf1.Vert_Hoja[1]][1];
-	c = Vertex[leaf1.Vert_Hoja[1]][2];
-
-	dist[1] = ((leaf2.Centro[0]-a)*(leaf2.Centro[0]-a)) + ((leaf2.Centro[1]-b)*(leaf2.Centro[1]-b)) +
-		   ((leaf2.Centro[2]-c)*(leaf2.Centro[2]-c));
-
-	a = Vertex[leaf1.Vert_Hoja[2]][0];
-	b = Vertex[leaf1.Vert_Hoja[2]][1];
-	c = Vertex[leaf1.Vert_Hoja[2]][2];
-
-	dist[2] = ((leaf2.Centro[0]-a)*(leaf2.Centro[0]-a)) + ((leaf2.Centro[1]-b)*(leaf2.Centro[1]-b)) +
-		   ((leaf2.Centro[2]-c)*(leaf2.Centro[2]-c));
-
-
-	a = Vertex[leaf1.Vert_Hoja[3]][0];
-	b = Vertex[leaf1.Vert_Hoja[3]][1];
-	c = Vertex[leaf1.Vert_Hoja[3]][2];
-
-	dist[3] = ((leaf2.Centro[0]-a)*(leaf2.Centro[0]-a)) + ((leaf2.Centro[1]-b)*(leaf2.Centro[1]-b)) +
-		   ((leaf2.Centro[2]-c)*(leaf2.Centro[2]-c));
+	a = Vertex[leaf1.vertsLeaf[0]][0];
+	b = Vertex[leaf1.vertsLeaf[0]][1];
+	c = Vertex[leaf1.vertsLeaf[0]][2];
+
+	dist[0] = ((leaf2.center[0]-a)*(leaf2.center[0]-a)) + ((leaf2.center[1]-b)*(leaf2.center[1]-b)) +
+		   ((leaf2.center[2]-c)*(leaf2.center[2]-c));
+
+	
+	a = Vertex[leaf1.vertsLeaf[1]][0];
+	b = Vertex[leaf1.vertsLeaf[1]][1];
+	c = Vertex[leaf1.vertsLeaf[1]][2];
+
+	dist[1] = ((leaf2.center[0]-a)*(leaf2.center[0]-a)) + ((leaf2.center[1]-b)*(leaf2.center[1]-b)) +
+		   ((leaf2.center[2]-c)*(leaf2.center[2]-c));
+
+	a = Vertex[leaf1.vertsLeaf[2]][0];
+	b = Vertex[leaf1.vertsLeaf[2]][1];
+	c = Vertex[leaf1.vertsLeaf[2]][2];
+
+	dist[2] = ((leaf2.center[0]-a)*(leaf2.center[0]-a)) + ((leaf2.center[1]-b)*(leaf2.center[1]-b)) +
+		   ((leaf2.center[2]-c)*(leaf2.center[2]-c));
+
+
+	a = Vertex[leaf1.vertsLeaf[3]][0];
+	b = Vertex[leaf1.vertsLeaf[3]][1];
+	c = Vertex[leaf1.vertsLeaf[3]][2];
+
+	dist[3] = ((leaf2.center[0]-a)*(leaf2.center[0]-a)) + ((leaf2.center[1]-b)*(leaf2.center[1]-b)) +
+		   ((leaf2.center[2]-c)*(leaf2.center[2]-c));
 
 	for ( int i=0;i<4;i++) indices[i]=i;
@@ -988,38 +988,38 @@
 	TwoGreater(dist, indices);
 	
-	Leaves[countLeaves].Vert_Hoja[0] = leaf1.Vert_Hoja[indices[0]]; 
-	Leaves[countLeaves].Vert_Hoja[1] = leaf1.Vert_Hoja[indices[1]]; 
-	
-
-	
-	a = Vertex[leaf2.Vert_Hoja[0]][0];
-	b = Vertex[leaf2.Vert_Hoja[0]][1];
-	c = Vertex[leaf2.Vert_Hoja[0]][2];
-
-	dist[0] = ((leaf1.Centro[0]-a)*(leaf1.Centro[0]-a)) + ((leaf1.Centro[1]-b)*(leaf1.Centro[1]-b)) +
-		   ((leaf1.Centro[2]-c)*(leaf1.Centro[2]-c));
-
-	
-	a = Vertex[leaf2.Vert_Hoja[1]][0];
-	b = Vertex[leaf2.Vert_Hoja[1]][1];
-	c = Vertex[leaf2.Vert_Hoja[1]][2];
-
-	dist[1] = ((leaf2.Centro[0]-a)*(leaf2.Centro[0]-a)) + ((leaf1.Centro[1]-b)*(leaf1.Centro[1]-b)) +
-		   ((leaf2.Centro[2]-c)*(leaf2.Centro[2]-c));
-
-	a = Vertex[leaf2.Vert_Hoja[2]][0];
-	b = Vertex[leaf2.Vert_Hoja[2]][1];
-	c = Vertex[leaf2.Vert_Hoja[2]][2];
-
-	dist[2] = ((leaf1.Centro[0]-a)*(leaf1.Centro[0]-a)) + ((leaf1.Centro[1]-b)*(leaf1.Centro[1]-b)) +
-		   ((leaf1.Centro[2]-c)*(leaf1.Centro[2]-c));
-
-
-	a = Vertex[leaf2.Vert_Hoja[3]][0];
-	b = Vertex[leaf2.Vert_Hoja[3]][1];
-	c = Vertex[leaf2.Vert_Hoja[3]][2];
-
-	dist[3] = ((leaf1.Centro[0]-a)*(leaf1.Centro[0]-a)) + ((leaf1.Centro[1]-b)*(leaf1.Centro[1]-b)) +
-		   ((leaf1.Centro[2]-c)*(leaf1.Centro[2]-c));
+	Leaves[countLeaves].vertsLeaf[0] = leaf1.vertsLeaf[indices[0]]; 
+	Leaves[countLeaves].vertsLeaf[1] = leaf1.vertsLeaf[indices[1]]; 
+	
+
+	
+	a = Vertex[leaf2.vertsLeaf[0]][0];
+	b = Vertex[leaf2.vertsLeaf[0]][1];
+	c = Vertex[leaf2.vertsLeaf[0]][2];
+
+	dist[0] = ((leaf1.center[0]-a)*(leaf1.center[0]-a)) + ((leaf1.center[1]-b)*(leaf1.center[1]-b)) +
+		   ((leaf1.center[2]-c)*(leaf1.center[2]-c));
+
+	
+	a = Vertex[leaf2.vertsLeaf[1]][0];
+	b = Vertex[leaf2.vertsLeaf[1]][1];
+	c = Vertex[leaf2.vertsLeaf[1]][2];
+
+	dist[1] = ((leaf2.center[0]-a)*(leaf2.center[0]-a)) + ((leaf1.center[1]-b)*(leaf1.center[1]-b)) +
+		   ((leaf2.center[2]-c)*(leaf2.center[2]-c));
+
+	a = Vertex[leaf2.vertsLeaf[2]][0];
+	b = Vertex[leaf2.vertsLeaf[2]][1];
+	c = Vertex[leaf2.vertsLeaf[2]][2];
+
+	dist[2] = ((leaf1.center[0]-a)*(leaf1.center[0]-a)) + ((leaf1.center[1]-b)*(leaf1.center[1]-b)) +
+		   ((leaf1.center[2]-c)*(leaf1.center[2]-c));
+
+
+	a = Vertex[leaf2.vertsLeaf[3]][0];
+	b = Vertex[leaf2.vertsLeaf[3]][1];
+	c = Vertex[leaf2.vertsLeaf[3]][2];
+
+	dist[3] = ((leaf1.center[0]-a)*(leaf1.center[0]-a)) + ((leaf1.center[1]-b)*(leaf1.center[1]-b)) +
+		   ((leaf1.center[2]-c)*(leaf1.center[2]-c));
 
 	for ( int i=0;i<4;i++) indices[i]=i;
@@ -1027,6 +1027,6 @@
 	TwoGreater(dist, indices);
 	
-	Leaves[countLeaves].Vert_Hoja[2] = leaf2.Vert_Hoja[indices[0]]; 
-	Leaves[countLeaves].Vert_Hoja[3] = leaf2.Vert_Hoja[indices[1]]; 
+	Leaves[countLeaves].vertsLeaf[2] = leaf2.vertsLeaf[indices[0]]; 
+	Leaves[countLeaves].vertsLeaf[3] = leaf2.vertsLeaf[indices[1]]; 
 
 
@@ -1043,18 +1043,18 @@
 
 	which=MinCriteria();
-	other = Leaves[which].hoja_crit;
+	other = Leaves[which].leafCrit;
 
 	//desactivo las hojas cercanas
-	Leaves[which].existe = false;
-	Leaves[other].existe = false;
+	Leaves[which].exists = false;
+	Leaves[other].exists = false;
 	//creo la hoja nueva
 
-	Leaves[countLeaves].hoja_cerca = -1;
+	Leaves[countLeaves].leafNear = -1;
 	Leaves[countLeaves].dist = 0;
-	Leaves[countLeaves].hoja_cop = -1;
+	Leaves[countLeaves].leafCop = -1;
 	Leaves[countLeaves].coplanar = 0;
 
-	Leaves[countLeaves].Cuantas_hojas = Leaves[which].Cuantas_hojas + Leaves[other].Cuantas_hojas;
-//	Leaves[countLeaves].Cuantas_hojas = 10;
+	Leaves[countLeaves].parentLeafCount = Leaves[which].parentLeafCount + Leaves[other].parentLeafCount;
+//	Leaves[countLeaves].parentLeafCount = 10;
 	ChooseVertices(Leaves[which], Leaves[other], countLeaves);
 	CalculateLeafCenter (Leaves[countLeaves]);
@@ -1066,5 +1066,5 @@
 	onode->leaves.push_back(countLeaves);
 
-/*	if (Leaves[countLeaves].Cuantas_hojas > 60 )
+/*	if (Leaves[countLeaves].parentLeafCount > 60 )
 	{
 			Leaves[countLeaves].existe = false;
@@ -1073,8 +1073,8 @@
 	else
 	{		*/
-     	Leaves[countLeaves].existe = true;
-		Leaves[countLeaves].criterio = 1000000.0f;
-		Leaves[countLeaves].id_triangulo[0] = countLeaves*2;
-		Leaves[countLeaves].id_triangulo[1] = countLeaves*2+1;
+     	Leaves[countLeaves].exists = true;
+		Leaves[countLeaves].criteria = 1000000.0f;
+		Leaves[countLeaves].idTriangle[0] = countLeaves*2;
+		Leaves[countLeaves].idTriangle[1] = countLeaves*2+1;
 
  		float area_leaf_i = CalculateLeafArea(Leaves[i])/diam;
@@ -1088,7 +1088,7 @@
 				int j = *it;*/
 
-				if (j != countLeaves && Leaves[j].existe)
+				if (j != countLeaves && Leaves[j].exists)
 				{
-					coptmp2 = Leaves[countLeaves].Coplanaridad(Leaves[j]); 
+					coptmp2 = Leaves[countLeaves].Coplanarity(Leaves[j]); 
 					coptmp = 1 - coptmp2;
 					//distmp2 = HausdorffOptimized(Leaves[countLeaves], Leaves[j]);
@@ -1098,10 +1098,10 @@
 					criteriatmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 					criteriatmp *= CalculateLeafArea(Leaves[j])/diam + area_leaf_i;
-					criteriatmp *= Leaves[j].Cuantas_hojas + Leaves[i].Cuantas_hojas;
+					criteriatmp *= Leaves[j].parentLeafCount + Leaves[i].parentLeafCount;
 					
-					if (Leaves[countLeaves].criterio > criteriatmp) 
+					if (Leaves[countLeaves].criteria > criteriatmp) 
 					{
-						Leaves[countLeaves].criterio = criteriatmp;
-						Leaves[countLeaves].hoja_crit = j;
+						Leaves[countLeaves].criteria = criteriatmp;
+						Leaves[countLeaves].leafCrit = j;
 					}
 				}
@@ -1112,14 +1112,14 @@
 	// Crear el paso de simplificación
 	Geometry::TreeSimplificationSequence::Step pasosimp;
-	pasosimp.mV0=Leaves[which].id_triangulo[0];
-	pasosimp.mV1=Leaves[which].id_triangulo[1];
-	pasosimp.mT0=Leaves[other].id_triangulo[0];
-	pasosimp.mT1=Leaves[other].id_triangulo[1];
+	pasosimp.mV0=Leaves[which].idTriangle[0];
+	pasosimp.mV1=Leaves[which].idTriangle[1];
+	pasosimp.mT0=Leaves[other].idTriangle[0];
+	pasosimp.mT1=Leaves[other].idTriangle[1];
 
 	// Nuevos vértices
-	pasosimp.mNewQuad[0]=Leaves[countLeaves].Vert_Hoja[0];
-	pasosimp.mNewQuad[1]=Leaves[countLeaves].Vert_Hoja[1];
-	pasosimp.mNewQuad[2]=Leaves[countLeaves].Vert_Hoja[2];
-	pasosimp.mNewQuad[3]=Leaves[countLeaves].Vert_Hoja[3];
+	pasosimp.mNewQuad[0]=Leaves[countLeaves].vertsLeaf[0];
+	pasosimp.mNewQuad[1]=Leaves[countLeaves].vertsLeaf[1];
+	pasosimp.mNewQuad[2]=Leaves[countLeaves].vertsLeaf[2];
+	pasosimp.mNewQuad[3]=Leaves[countLeaves].vertsLeaf[3];
 
 	// Insertar el paso de simplificación
@@ -1156,14 +1156,14 @@
 		ticks_since_last_update++;
 		
-		if (Leaves[j].existe)
+		if (Leaves[j].exists)
 		{
 //			if (index<6)
 //			{
-				mesh->mSubMesh[idMeshLeaves].mIndex[index]=Leaves[j].Vert_Hoja[0];
-				mesh->mSubMesh[idMeshLeaves].mIndex[index+1]=Leaves[j].Vert_Hoja[1];
-				mesh->mSubMesh[idMeshLeaves].mIndex[index+2]=Leaves[j].Vert_Hoja[2];
-				mesh->mSubMesh[idMeshLeaves].mIndex[index+3]=Leaves[j].Vert_Hoja[2];
-				mesh->mSubMesh[idMeshLeaves].mIndex[index+4]=Leaves[j].Vert_Hoja[1];
-				mesh->mSubMesh[idMeshLeaves].mIndex[index+5]=Leaves[j].Vert_Hoja[3];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index]=Leaves[j].vertsLeaf[0];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index+1]=Leaves[j].vertsLeaf[1];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index+2]=Leaves[j].vertsLeaf[2];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index+3]=Leaves[j].vertsLeaf[2];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index+4]=Leaves[j].vertsLeaf[1];
+				mesh->mSubMesh[idMeshLeaves].mIndex[index+5]=Leaves[j].vertsLeaf[3];
 /*			}
 			else
@@ -1312,8 +1312,8 @@
 			{
 				int idleaf = *it;
-				int idv0 = Leaves[idleaf].Vert_Hoja[0];
-				int idv1 = Leaves[idleaf].Vert_Hoja[1];
-				int idv2 = Leaves[idleaf].Vert_Hoja[2];
-				int idv3 = Leaves[idleaf].Vert_Hoja[3];
+				int idv0 = Leaves[idleaf].vertsLeaf[0];
+				int idv1 = Leaves[idleaf].vertsLeaf[1];
+				int idv2 = Leaves[idleaf].vertsLeaf[2];
+				int idv3 = Leaves[idleaf].vertsLeaf[3];
 
 				float * v0 = Vertex[idv0];
@@ -1358,8 +1358,8 @@
 		ticks_since_last_update++;
 		
-		if (Leaves[i].existe == true)
-		{
-			Leaves[i].criterio = 1000000.0f;
-			nleavesi = int(Leaves[i].Cuantas_hojas);
+		if (Leaves[i].exists == true)
+		{
+			Leaves[i].criteria = 1000000.0f;
+			nleavesi = int(Leaves[i].parentLeafCount);
  			float area_leaf_i = CalculateLeafArea(Leaves[i])/diam;
 
@@ -1373,11 +1373,11 @@
 //				for (j=0; j<countLeaves; j++)
 //				{
-					if (j!=i && Leaves[j].existe)
+					if (j!=i && Leaves[j].exists)
 					{
-						nleavesj = int(Leaves[j].Cuantas_hojas);
+						nleavesj = int(Leaves[j].parentLeafCount);
 
 	//					if ( abs((nleavesi - nleavesj)) < 2)
 	//					{							
-							coptmp2 = Leaves[i].Coplanaridad(Leaves[j]);
+							coptmp2 = Leaves[i].Coplanarity(Leaves[j]);
 							coptmp = 1 - coptmp2;
 
@@ -1390,9 +1390,9 @@
 							// select the lowest
 							criteriatmp *= CalculateLeafArea(Leaves[j])/diam + area_leaf_i;
-							criteriatmp *= Leaves[j].Cuantas_hojas + Leaves[i].Cuantas_hojas;
-							if (Leaves[i].criterio > criteriatmp)
+							criteriatmp *= Leaves[j].parentLeafCount + Leaves[i].parentLeafCount;
+							if (Leaves[i].criteria > criteriatmp)
 							{
-								Leaves[i].criterio = criteriatmp;
-								Leaves[i].hoja_crit = j;
+								Leaves[i].criteria = criteriatmp;
+								Leaves[i].leafCrit = j;
 							}
 		//				}
@@ -1412,11 +1412,11 @@
 	for (i = 0; i < countLeaves; i++)
 	{
-		if (Leaves[i].existe && i!=newleaf)
+		if (Leaves[i].exists && i!=newleaf)
 		{	
  			float area_leaf_i = CalculateLeafArea(Leaves[i])/diam;
-			nleavesi = int(Leaves[i].Cuantas_hojas);
-			if ( Leaves[Leaves[i].hoja_crit].existe == false)
+			nleavesi = int(Leaves[i].parentLeafCount);
+			if ( Leaves[Leaves[i].leafCrit].exists == false)
 			{
-				Leaves[i].criterio = 1000000.0f;
+				Leaves[i].criteria = 1000000.0f;
 
 				int visit_parents = VISIT_PARENTS_DEEP;
@@ -1428,11 +1428,11 @@
 	//			for (j=0; j<countLeaves; j++)
 	//			{
-						if (j!=i && Leaves[j].existe)
+						if (j!=i && Leaves[j].exists)
 						{
-							nleavesj = int(Leaves[j].Cuantas_hojas);
+							nleavesj = int(Leaves[j].parentLeafCount);
 
 //							if ( abs((nleavesi - nleavesj)) < 2)
 //							{
-								coptmp2 = Leaves[i].Coplanaridad(Leaves[j]); 
+								coptmp2 = Leaves[i].Coplanarity(Leaves[j]); 
 								coptmp = 1 - coptmp2;	
 							
@@ -1444,11 +1444,11 @@
 								criteriatmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 								criteriatmp *= CalculateLeafArea(Leaves[j])/diam + area_leaf_i;
-								criteriatmp *= Leaves[j].Cuantas_hojas + Leaves[i].Cuantas_hojas;
+								criteriatmp *= Leaves[j].parentLeafCount + Leaves[i].parentLeafCount;
 								
 								// select the leaf with the lowest criteria
-								if (Leaves[i].criterio > criteriatmp) 
+								if (Leaves[i].criteria > criteriatmp) 
 								{
-									Leaves[i].criterio = criteriatmp;
-									Leaves[i].hoja_crit = j;
+									Leaves[i].criteria = criteriatmp;
+									Leaves[i].leafCrit = j;
 								}
 						//	}
@@ -1459,9 +1459,9 @@
 			else
 			{ 
-				nleavesj = int(Leaves[newleaf].Cuantas_hojas);
+				nleavesj = int(Leaves[newleaf].parentLeafCount);
 
 //				if ( abs((nleavesi - nleavesj)) < 2)
 //				{
-					coptmp2 = Leaves[i].Coplanaridad(Leaves[newleaf]); 
+					coptmp2 = Leaves[i].Coplanarity(Leaves[newleaf]); 
 					coptmp = 1 - coptmp2;
 
@@ -1472,10 +1472,10 @@
 					criteriatmp = (( K1 * distmp * distmp ) + (K2 * coptmp * distmp))/ (K1 + K2);
 					criteriatmp *= CalculateLeafArea(Leaves[newleaf])/diam + area_leaf_i;
-					criteriatmp *= Leaves[newleaf].Cuantas_hojas + Leaves[i].Cuantas_hojas;
+					criteriatmp *= Leaves[newleaf].parentLeafCount + Leaves[i].parentLeafCount;
 					
-					if (Leaves[i].criterio > criteriatmp) 
+					if (Leaves[i].criteria > criteriatmp) 
 					{	
-						Leaves[i].criterio = criteriatmp;
-						Leaves[i].hoja_crit = newleaf;
+						Leaves[i].criteria = criteriatmp;
+						Leaves[i].leafCrit = newleaf;
 					}
 //				}
@@ -1486,10 +1486,10 @@
 
 
-LeafOctree *TreeSimplifier::GetMinOctreeNodeForLeaf(LeafOctree *start, const Hoja &leaf)
-{
-	int idv0 = leaf.Vert_Hoja[0];
-	int idv1 = leaf.Vert_Hoja[1];
-	int idv2 = leaf.Vert_Hoja[2];
-	int idv3 = leaf.Vert_Hoja[3];
+LeafOctree *TreeSimplifier::GetMinOctreeNodeForLeaf(LeafOctree *start, const Leaf &leaf)
+{
+	int idv0 = leaf.vertsLeaf[0];
+	int idv1 = leaf.vertsLeaf[1];
+	int idv2 = leaf.vertsLeaf[2];
+	int idv3 = leaf.vertsLeaf[3];
 
 	float * v0 = Vertex[idv0];
@@ -1517,5 +1517,5 @@
 }
 
-float TreeSimplifier::DistanceFromCenters(const Hoja &leaf1, const Hoja &leaf2) const
+float TreeSimplifier::DistanceFromCenters(const Leaf &leaf1, const Leaf &leaf2) const
 {
 	float onex, oney, onez;
@@ -1528,8 +1528,8 @@
 	float x4, y4, z4;
 
-	onex   = Vertex[leaf1.Vert_Hoja[0]][0]; oney   = Vertex[leaf1.Vert_Hoja[0]][1]; onez   = Vertex[leaf1.Vert_Hoja[0]][2];
-	twox   = Vertex[leaf1.Vert_Hoja[1]][0]; twoy   = Vertex[leaf1.Vert_Hoja[1]][1]; twoz   = Vertex[leaf1.Vert_Hoja[1]][2];
-	threex = Vertex[leaf1.Vert_Hoja[2]][0]; threey = Vertex[leaf1.Vert_Hoja[2]][1]; threez = Vertex[leaf1.Vert_Hoja[2]][2];
-	fourx  = Vertex[leaf1.Vert_Hoja[3]][0]; foury  = Vertex[leaf1.Vert_Hoja[3]][1]; fourz  = Vertex[leaf1.Vert_Hoja[3]][2];
+	onex   = Vertex[leaf1.vertsLeaf[0]][0]; oney   = Vertex[leaf1.vertsLeaf[0]][1]; onez   = Vertex[leaf1.vertsLeaf[0]][2];
+	twox   = Vertex[leaf1.vertsLeaf[1]][0]; twoy   = Vertex[leaf1.vertsLeaf[1]][1]; twoz   = Vertex[leaf1.vertsLeaf[1]][2];
+	threex = Vertex[leaf1.vertsLeaf[2]][0]; threey = Vertex[leaf1.vertsLeaf[2]][1]; threez = Vertex[leaf1.vertsLeaf[2]][2];
+	fourx  = Vertex[leaf1.vertsLeaf[3]][0]; foury  = Vertex[leaf1.vertsLeaf[3]][1]; fourz  = Vertex[leaf1.vertsLeaf[3]][2];
 
 	float center1x = (onex + twox + threex + fourx)*0.25f;
@@ -1537,8 +1537,8 @@
 	float center1z = (onez + twoz + threez + fourz)*0.25f;
 
-	x1 = Vertex[leaf2.Vert_Hoja[0]][0]; y1 = Vertex[leaf2.Vert_Hoja[0]][1]; z1 = Vertex[leaf2.Vert_Hoja[0]][2];
-	x2 = Vertex[leaf2.Vert_Hoja[1]][0]; y2 = Vertex[leaf2.Vert_Hoja[1]][1]; z2 = Vertex[leaf2.Vert_Hoja[1]][2];
-	x3 = Vertex[leaf2.Vert_Hoja[2]][0]; y3 = Vertex[leaf2.Vert_Hoja[2]][1]; z3 = Vertex[leaf2.Vert_Hoja[2]][2];
-	x4 = Vertex[leaf2.Vert_Hoja[3]][0]; y4 = Vertex[leaf2.Vert_Hoja[3]][1]; z4 = Vertex[leaf2.Vert_Hoja[3]][2];
+	x1 = Vertex[leaf2.vertsLeaf[0]][0]; y1 = Vertex[leaf2.vertsLeaf[0]][1]; z1 = Vertex[leaf2.vertsLeaf[0]][2];
+	x2 = Vertex[leaf2.vertsLeaf[1]][0]; y2 = Vertex[leaf2.vertsLeaf[1]][1]; z2 = Vertex[leaf2.vertsLeaf[1]][2];
+	x3 = Vertex[leaf2.vertsLeaf[2]][0]; y3 = Vertex[leaf2.vertsLeaf[2]][1]; z3 = Vertex[leaf2.vertsLeaf[2]][2];
+	x4 = Vertex[leaf2.vertsLeaf[3]][0]; y4 = Vertex[leaf2.vertsLeaf[3]][1]; z4 = Vertex[leaf2.vertsLeaf[3]][2];
 
 	float center2x = (x1 + x2 + x3 + x4)*0.25f;
@@ -1588,10 +1588,10 @@
 
 
-float TreeSimplifier::CalculateLeafArea(Hoja &leaf) const
-{
-	int idv0 = leaf.Vert_Hoja[0];
-	int idv1 = leaf.Vert_Hoja[1];
-	int idv2 = leaf.Vert_Hoja[2];
-	int idv3 = leaf.Vert_Hoja[3];
+float TreeSimplifier::CalculateLeafArea(Leaf &leaf) const
+{
+	int idv0 = leaf.vertsLeaf[0];
+	int idv1 = leaf.vertsLeaf[1];
+	int idv2 = leaf.vertsLeaf[2];
+	int idv3 = leaf.vertsLeaf[3];
 
 	float * v0 = Vertex[idv0];
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj	(revision 1014)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj	(revision 1019)
@@ -260,7 +260,4 @@
 				</File>
 				<File
-					RelativePath=".\src\libs\leaves\Arbol.cpp">
-				</File>
-				<File
 					RelativePath=".\src\libs\leaves\foliage.cpp">
 				</File>
@@ -360,7 +357,4 @@
 			</File>
 			<File
-				RelativePath=".\src\libs\leaves\arbol.h">
-			</File>
-			<File
 				RelativePath=".\include\auxiliar.h">
 			</File>
