Index: /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h
===================================================================
--- /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h	(revision 1526)
+++ /GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h	(revision 2087)
@@ -10,5 +10,45 @@
 
 using	namespace	Geometry;
-
+using	namespace	std;
+
+//-------------------------------------------------------------------------
+// Class to create a map without repeated vertices
+//-------------------------------------------------------------------------
+class _float3_
+{
+	public:
+
+		float x,y,z;
+
+		_float3_(float x=0.0f, float y=0.0f, float z=0.0f)
+		{
+			this->x = x; this->y = y; this->z = z;
+		}
+
+		_float3_(const _float3_ &f)
+		{
+			x=f.x; y=f.y; z=f.z;
+		}
+
+		_float3_ & operator=(const _float3_ &f)
+		{
+			x=f.x; y=f.y; z=f.z; return *this;
+		}
+
+		bool operator<(const _float3_ &f) const
+		{
+			if (x<f.x) return true;
+			if (x>f.x) return false;
+			if (y<f.y) return true;
+			if (y>f.y) return false;
+			if (z<f.z) return true;
+			if (z>f.z) return false;
+			return false;
+		}
+};
+
+//-------------------------------------------------------------------------
+// Class to perform mesh simplification.
+//-------------------------------------------------------------------------
 class SimplificationMethod
 {
@@ -21,5 +61,5 @@
 		simplif::Model M0;
 
-		simplif::array<simplif::vert_info> vinfo;
+		simplif::buffer<simplif::vert_info> vinfo;
 
 		simplif::Heap *heap;
@@ -90,4 +130,17 @@
 		std::map< int,	std::vector<int> > vertexbuffermap;
 
+		//	Multimap to store current vertex in a simplification state.
+		typedef	multimap<_float3_,	int>	vertex_map;
+		typedef	vertex_map::iterator			vertex_map_str;
+		typedef	vertex_map::value_type		vertex_pair;
+
+		//	Store unique vertices by submesh (without repetitions).
+		typedef std::map<int,int> MAPAINDIND;
+
+		//	Store all the indices by submesh (with repetitions).
+		typedef std::vector<int> REPINDLIST;
+
+		vertex_map	vertexMultimap;
+
 		//	Simplification sequence of the simplification method.
 		std::vector<Geometry::MeshSimplificationSequence::Step> decim_data;
@@ -101,5 +154,6 @@
 		int indexMeshLeaves;
 
-		//	Contract lonely vertices that have same coords than the contracted one.
+		//	Contract lonely vertices that have same coords 
+		//	than the contracted one.
 		void	contractLonelyVertices(	simplif::Model	&m,
 																	simplif::Vertex	*v0,
@@ -107,32 +161,44 @@
 																	simplif::Vec3		candidate);
 
-		//	Remove twin edges.
-		void	removeTwinEdges(simplif::Model	&m,
-													simplif::Vertex	*v0,
-													simplif::Vertex	*v1,
-													simplif::Vec3		candidate);
+		//	Find twin vertices to the contracted one and contract them.
+		void	removeTwinVertices(	simplif::Model	&m,
+															simplif::Vertex	*v0,
+															simplif::Vertex	*v1,
+															simplif::Vec3		candidate);
+
+		void	fillUpSharedVertices(	MAPAINDIND	&shared_vertex_map,
+																REPINDLIST *ver_inds_rep_by_geo);
+
+		void	fillUpVertices(	MAPAINDIND	*unique_verts_inds_by_geo,
+													REPINDLIST *ver_inds_rep_by_geo);
+
+		void	addNewBoneAssignments();
+
+		void	eraseVoidSubMeshes(Mesh	*geoMesh);
 
 	public:
 
-		const Geometry::Mesh *objmesh;
+		Mesh *mInitialMesh;
 
 		//	Total number of triangles of all the submeshes.
 		int number_of_triangles;
 
-		SimplificationMethod(const Geometry::Mesh *m);
-
-		void	generateSimplifModel(void);
-
-		Geometry::MeshSimplificationSequence *Decimate(	float lod,
-				int simpliftype,
-				Geometry::TIPOFUNC	upb=0);
-
-		void setMeshLeaves(int meshLeaves);
-
-		///	Gets mesh simplified.
-		Geometry::Mesh	*	GetMesh();
+		///	Constructor.
+		SimplificationMethod(const Mesh *m);
 
 		///	Destructor.
 		~SimplificationMethod();
+
+		void	generateSimplifModel(void);
+
+		MeshSimplificationSequence *Decimate(	float			lod,
+																					int				simpliftype,
+																					TIPOFUNC	upb=0);
+
+		void setMeshLeaves(int meshLeaves);
+
+		///	Gets mesh simplified.
+		Mesh	*	GetMesh();
+
 };
 
