Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp	(revision 2103)
@@ -764,4 +764,11 @@
 	mSequence->mSteps.clear();
 
+	//	Debug.
+	cout	<<	"Simplification steps: "
+				<<	steps.size()
+				<<	" new vertices: "
+				<<	mSequence->mNewVertices.size()
+				<<	endl;
+
 	for	(size_t	i	=	0;	i < steps.size(); i++)
 	{
@@ -843,8 +850,8 @@
 						<<	endl;
 	
-			// Collapse new edge.
+			//	Collapse new edge.
 			doChange(mesh, c); // the mesh has been updated.
 
-			// Write Simplification sequence.
+			//	Write Simplification sequence.
 			saveSimplificationSequence(c,0);
 
Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 2086)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp	(revision 2103)
@@ -137,5 +137,5 @@
 
 //-------------------------------------------------------------------------
-//	Destroyer.
+//	Destructor.
 //-------------------------------------------------------------------------
 GeometryBasedSimplifier::~GeometryBasedSimplifier()
@@ -247,4 +247,6 @@
 	VMI::vTexCoords	=	vTexCoords;
 
+	
+
 	mGeoMesh	=	new Mesh();
 
@@ -288,4 +290,7 @@
 	// Free memory
 	VMI::freeMemory();
+
+	delete	VMI::mSequence;
+	VMI::mSequence	=	NULL;
 }
 
@@ -375,4 +380,10 @@
 	msimpsequence->mSteps				=	VMI::mSequence->mSteps;
 	msimpsequence->mNewVertices	=	VMI::mSequence->mNewVertices;
+
+	cout	<<	"Steps of simplification: "
+				<<	msimpsequence->mSteps.size()
+				<<	" Number of new vertices: "
+				<<	msimpsequence->mNewVertices.size()
+				<<	endl;
 }
 
@@ -871,4 +882,11 @@
 EdgesMultimap::EdgesMultimap()
 {
+}
+
+//-------------------------------------------------------------------------
+//	Destructor.
+//-------------------------------------------------------------------------
+EdgesMultimap::~EdgesMultimap()
+{
 	edges.clear();
 }
@@ -1005,4 +1023,5 @@
 {
 	delete	mGeoMesh;
+	delete	mEdges;
 }
 
Index: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 2090)
+++ GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp	(revision 2103)
@@ -282,5 +282,6 @@
 //	Transform to Shared Vertex callback
 //-------------------------------------------------------------------------
-inline void GeoMeshViewUI::cb_menuTransformSharedVertex_i(fltk::Item*, void*)
+inline void GeoMeshViewUI::cb_menuTransformSharedVertex_i(fltk::Item	*,
+																													void				*)
 {
 	Mesh	*mesh_aux;
@@ -1171,5 +1172,4 @@
 					if (simplifyEdgeCollapse())
 					{
-						//delete	mMeshSimplifier;
 						geoMeshView->restoreContext();
 
@@ -1213,7 +1213,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Button Sort Callback
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mButtonSort_i(fltk::Button*, void*)
 {
@@ -1227,7 +1227,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Button Build Callback
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*)
 {
@@ -1304,7 +1304,4 @@
 
 					oLodStrip->Save(file_name);
-
-					//	Delete simplified mesh.
-					delete	mMeshSimplifier;
 				}
 				else
@@ -1333,7 +1330,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Lod Slider Callback
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider	*o, void	*)
 {
@@ -1354,7 +1351,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Lod Slider Callback for the foliage
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider	*o, void	*)
 {
@@ -1375,7 +1372,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Mesh Info Callback
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mMeshInfo_i(fltk::Browser	*, void	*)
 {	
@@ -1390,7 +1387,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Logo Callback.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 inline void GeoMeshViewUI::cb_mLogo_i(fltk::InvisibleBox*, void*)
 {
@@ -1404,7 +1401,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Active Build process.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::activeBuildProcess()
 {
@@ -1416,7 +1413,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the stripify panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showStripify()
 {
@@ -1439,7 +1436,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the stripify panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideStripify()
 {
@@ -1462,7 +1459,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the Simplify Edge Collapse panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showEdgeCollapse()
 {
@@ -1512,7 +1509,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the Simplify Edge Collapse
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideEdgeCollapse()
 {
@@ -1597,7 +1594,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the Simplify Leaves Collapse.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideLeavesCollapse()
 {
@@ -1638,7 +1635,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the LodStrips Panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showOpenMeshSimplification()
 {
@@ -1656,7 +1653,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the LodStrips Panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideOpenMeshSimplification()
 {
@@ -1674,7 +1671,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Shows the auto generate LodStrips panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showAutoGenerateLodStrips()
 {
@@ -1692,7 +1689,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Shows the auto generate LodStrips panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showAutoGenerateLodTrees()
 {
@@ -1710,7 +1707,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the LodStrips visulization panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showLodStripSlider()
 {
@@ -1719,7 +1716,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the LodStrips visualization panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideLodStripSlider()
 {
@@ -1728,7 +1725,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the LodTree visulization panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showLodTreeSlider()
 {
@@ -1737,7 +1734,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the LodTree visualization panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideLodTreeSlider()
 {
@@ -1746,7 +1743,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the LodTrees Panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showOpenLeavesSimplification()
 {
@@ -1758,7 +1755,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the LodTrees Panel.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideOpenLeavesSimplification()
 {
@@ -1770,7 +1767,7 @@
 }
 
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Show the mesh info browser.
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::showMeshInfo()
 {
@@ -1915,7 +1912,7 @@
 }
 
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the mesh info browser.
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideMeshInfo()
 {
@@ -1924,7 +1921,7 @@
 }
 
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Hide the right panel.
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::hideRightPanel()
 {
@@ -1939,7 +1936,7 @@
 }
 
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Get the number of vertices.
-//--------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshViewUI::getVertexCount(Mesh	*geoMesh)
 {
@@ -1966,7 +1963,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Get the number of triangles.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshViewUI::getTriangleCount(Geometry::Mesh	*geoMesh)
 {
@@ -2005,7 +2002,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Get the number of strips.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 size_t	GeoMeshViewUI::getStripCount(Geometry::Mesh	*geoMesh)
 {
@@ -2031,8 +2028,8 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	It paints the submesh selected by the mMeshInfo tree.
 //	Trate the mMeshInfo event.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 int GeoMeshViewUI::paintMesh(void)
 {
@@ -2064,10 +2061,16 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Simplify the mesh object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 bool GeoMeshViewUI::simplifyEdgeCollapse()
 {
 	Real    percent;
+
+	//	Free memory.
+	if (mMeshSimplifier != NULL)
+	{
+		delete	mMeshSimplifier;
+	}
 
 	//    If input field empty.
@@ -2158,7 +2161,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Simplify the mesh object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::simplifyLeavesCollapse()
 {
@@ -2219,7 +2222,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Create a simplification sequence of the simplification method.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::createSimplificationSequence()
 {
@@ -2233,7 +2236,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Create a simplification sequence of the leaves.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::createLeavesSequence(const std::string &filename)
 {
@@ -2248,7 +2251,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Stripify the mesh object.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::stripify()
 {	
@@ -2318,7 +2321,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Method that undo then mesh changes.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::undo()
 {
@@ -2347,7 +2350,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Refresh number of vertices, triangles, strips, ...
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::refreshApplicationBar()
 {
@@ -2399,7 +2402,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Initialize the lodstripslibrary for visualization.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData *loddata, Mesh	*geomesh)
 {
@@ -2426,7 +2429,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Initialize the lodTreelibrary for visualization.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData *lodstripsdata, const TreeSimplificationSequence *treesimpseq, Mesh *geomesh/*, uint32 ileafSubMesh*/)
 {
@@ -2455,7 +2458,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	Open a mesh file.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 void	GeoMeshViewUI::openMeshFile(void)
 {
@@ -2594,7 +2597,7 @@
 }
 
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 //	If file exists.
-//---------------------------------------------------------------------------
+//-------------------------------------------------------------------------
 bool	GeoMeshViewUI::fileExists(const char	*fileNameMesh)
 {
@@ -2614,7 +2617,7 @@
 }
 
-/******************/
-/*	Constructor		*/
-/******************/
+//-------------------------------------------------------------------------
+//	Constructor
+//-------------------------------------------------------------------------
 GeoMeshViewUI::GeoMeshViewUI(TIPOFUNC fun)
 {
@@ -2628,4 +2631,7 @@
 	mGeoMesh	=	NULL;
 	mUndoMesh	=	NULL;
+
+	//	Initialize mesh simplifier.
+	mMeshSimplifier	=	NULL;
 
 	//	Initialize the lod strip object.
@@ -3130,7 +3136,7 @@
 }
 
-/****************/
-/*	Destroyer		*/
-/****************/
+//-------------------------------------------------------------------------
+//	Destructor.
+//-------------------------------------------------------------------------
 GeoMeshViewUI::~GeoMeshViewUI()
 {
@@ -3139,10 +3145,14 @@
 }
 
+//-------------------------------------------------------------------------
 //	Shows the main window.
+//-------------------------------------------------------------------------
 void GeoMeshViewUI::show()
 {
 }
 
+//-------------------------------------------------------------------------
 //	Build Textures menu.
+//-------------------------------------------------------------------------
 void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void)
 {
