Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Leaf.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Leaf.cpp	(revision 1026)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Leaf.cpp	(revision 1026)
@@ -0,0 +1,117 @@
+#include <math.h>
+#include "Leaf.h"
+
+//--------------------------------------------------------------------------------------------------------------------------------
+// Void constructor
+// Parameters --> None
+//--------------------------------------------------------------------------------------------------------------------------------
+Leaf::Leaf(void) 
+{	
+	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;
+	criteria = -1;
+	leafCop = -1;
+	leafCrit =-1;
+	exists = false;
+	parent=-1;
+	childLeft = childRight = -1;
+	root = visible= -1;
+}
+
+
+//--------------------------------------------------------------------------------------------------------------------------------
+// Copy constructor
+//--------------------------------------------------------------------------------------------------------------------------------
+Leaf::Leaf (const Leaf& aLeaf)
+{
+	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++){
+		center[i] = aLeaf.center[i];
+		normal[i] = aLeaf.normal[i];
+	}
+	for (i = 0L; i < 4; i++)
+		vertsLeaf[i] = aLeaf.vertsLeaf[i]; 
+	
+	parent = aLeaf.parent;
+	childLeft = aLeaf.childLeft;
+	childRight = aLeaf.childRight;
+	visible = aLeaf.visible;
+	root = aLeaf.root;
+}
+
+
+
+//--------------------------------------------------------------------------------------------------------------------------------
+// Destructor. We must deallocate the memory allocated for pointers to vertices and edges
+//--------------------------------------------------------------------------------------------------------------------------------
+Leaf::~Leaf (void)
+{
+}
+
+
+//--------------------------------------------------------------------------------------------------------------------------------
+//  CALCULA LA DISTANCIA ENTRE HOJAS
+//--------------------------------------------------------------------------------------------------------------------------------
+
+float Leaf::Distance (Leaf& leaf)
+{
+	float dist =0;
+	float x1,y1,z1;
+
+	x1 = leaf.center[0]; y1 = leaf.center[1] ; z1 = leaf.center[2];
+
+
+	//DISTANCIA BETWEEN CENTERS
+
+	dist = ((center[0]-x1)*(center[0]-x1)) + ((center[1]-y1)*(center[1]-y1)) + ((center[2]-z1)*(center[2]-z1));
+
+	return dist;
+}
+
+
+//--------------------------------------------------------------------------------------------------------------------------------
+//  CALCULA LA COPLANARIDAD ENTRE HOJAS
+//--------------------------------------------------------------------------------------------------------------------------------
+
+float Leaf::Coplanarity (Leaf& leaf)
+{
+	float cop =0;
+	float modulo1, modulo2;
+	float x1,y1,z1, nx1, ny1, nz1;
+	float nx, ny, nz;
+
+	//hoja pasada como parametro, normalizo las componentes
+	x1 = leaf.normal[0]; y1 = leaf.normal[1] ; z1 = leaf.normal[2];
+	modulo1 = sqrt ( (x1*x1) + (y1*y1) + (z1*z1));
+	nx1 = x1 / modulo1;
+	ny1 = y1 / modulo1;
+	nz1 = z1 / modulo1;
+
+	// 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;
+
+	// producto escalar : si es proximo a 0, perpendiculares, a 1, coplanares
+
+	cop = (nx1*nx) + (ny1*ny) + (nz1*nz);
+
+
+	return (fabs(cop));
+
+}
+
Index: P/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Hoja.cpp	(revision 1019)
+++ 	(revision )
@@ -1,117 +1,0 @@
-#include <math.h>
-#include "Leaf.h"
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Void constructor
-// Parameters --> None
-//--------------------------------------------------------------------------------------------------------------------------------
-Leaf::Leaf(void) 
-{	
-	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;
-	criteria = -1;
-	leafCop = -1;
-	leafCrit =-1;
-	exists = false;
-	parent=-1;
-	childLeft = childRight = -1;
-	root = visible= -1;
-}
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Copy constructor
-//--------------------------------------------------------------------------------------------------------------------------------
-Leaf::Leaf (const Leaf& aLeaf)
-{
-	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++){
-		center[i] = aLeaf.center[i];
-		normal[i] = aLeaf.normal[i];
-	}
-	for (i = 0L; i < 4; i++)
-		vertsLeaf[i] = aLeaf.vertsLeaf[i]; 
-	
-	parent = aLeaf.parent;
-	childLeft = aLeaf.childLeft;
-	childRight = aLeaf.childRight;
-	visible = aLeaf.visible;
-	root = aLeaf.root;
-}
-
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-// Destructor. We must deallocate the memory allocated for pointers to vertices and edges
-//--------------------------------------------------------------------------------------------------------------------------------
-Leaf::~Leaf (void)
-{
-}
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-//  CALCULA LA DISTANCIA ENTRE HOJAS
-//--------------------------------------------------------------------------------------------------------------------------------
-
-float Leaf::Distance (Leaf& leaf)
-{
-	float dist =0;
-	float x1,y1,z1;
-
-	x1 = leaf.center[0]; y1 = leaf.center[1] ; z1 = leaf.center[2];
-
-
-	//DISTANCIA BETWEEN CENTERS
-
-	dist = ((center[0]-x1)*(center[0]-x1)) + ((center[1]-y1)*(center[1]-y1)) + ((center[2]-z1)*(center[2]-z1));
-
-	return dist;
-}
-
-
-//--------------------------------------------------------------------------------------------------------------------------------
-//  CALCULA LA COPLANARIDAD ENTRE HOJAS
-//--------------------------------------------------------------------------------------------------------------------------------
-
-float Leaf::Coplanarity (Leaf& leaf)
-{
-	float cop =0;
-	float modulo1, modulo2;
-	float x1,y1,z1, nx1, ny1, nz1;
-	float nx, ny, nz;
-
-	//hoja pasada como parametro, normalizo las componentes
-	x1 = leaf.normal[0]; y1 = leaf.normal[1] ; z1 = leaf.normal[2];
-	modulo1 = sqrt ( (x1*x1) + (y1*y1) + (z1*z1));
-	nx1 = x1 / modulo1;
-	ny1 = y1 / modulo1;
-	nz1 = z1 / modulo1;
-
-	// 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;
-
-	// producto escalar : si es proximo a 0, perpendiculares, a 1, coplanares
-
-	cop = (nx1*nx) + (ny1*ny) + (nz1*nz);
-
-
-	return (fabs(cop));
-
-}
-
Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj	(revision 1019)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj	(revision 1026)
@@ -263,17 +263,5 @@
 				</File>
 				<File
-					RelativePath=".\src\libs\leaves\Hoja.cpp">
-					<FileConfiguration
-						Name="Debug|Win32">
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)/$(InputName)1.obj"/>
-					</FileConfiguration>
-					<FileConfiguration
-						Name="Release|Win32">
-						<Tool
-							Name="VCCLCompilerTool"
-							ObjectFile="$(IntDir)/$(InputName)1.obj"/>
-					</FileConfiguration>
+					RelativePath=".\src\libs\leaves\Leaf.cpp">
 				</File>
 				<File
Index: /GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 1024)
+++ /GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 1026)
@@ -1002,4 +1002,8 @@
 }
 
+VertexBuffer *origSubMeshVB=NULL;
+int orig_numindices=0;
+Index *orig_indices=NULL;
+
 //---------------------------------------------------------------------------
 //	Button Process Callback
@@ -1014,4 +1018,6 @@
 	mProcessBar->position(0);
 
+	origSubMeshVB=NULL;
+    
 	//	Initialize error flag.
 	error	=	false;
@@ -1079,4 +1085,10 @@
 				else
 				{
+					origSubMeshVB=mGeoMesh->mSubMesh[idMeshLeaves].mVertexBuffer->Clone();
+					orig_numindices=mGeoMesh->mSubMesh[idMeshLeaves].mIndexCount;
+					orig_indices=new Index[orig_numindices];
+					for (int i=0; i<orig_numindices; i++)
+						orig_indices[i]=mGeoMesh->mSubMesh[idMeshLeaves].mIndex[i];
+
 					std::cout << "Simplificando hojas...";
 					simplifyLeavesCollapse();
@@ -1323,6 +1335,9 @@
 						file_name[strlen(file_name) - 4]	=	'\0';
 						
-						mesh_saver->save(	mGeoMesh,
-															strcat(file_name,".mesh"));
+						mesh_saver->leavesSubMesh=idMeshLeaves;
+						mesh_saver->leavesVB=origSubMeshVB;
+						mesh_saver->numindices=orig_numindices;
+						mesh_saver->indices=orig_indices;
+						mesh_saver->save(mGeoMesh,strcat(file_name,".mesh"));
 						
 						delete	mesh_saver;
