From e31d0451289108701a037921963107ee74a7466d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 7 Feb 2008 16:32:31 +0000 Subject: [PATCH] - MarchingCube is now templated with the data type. It means that it now internaly stores a Data_type[] array, instead of a double[] array. When Data_type==char, it uses the 8th of the memory! For a 3D images of 182MB (the "colon" image), that saves 1.2GB. As a side effect, MarchingCubes.cpp is renamed to MarchingCubes_impl.h (because it is now a template class). - Use MarchingCube.set_ext_data, so that the 3D image and the MarchingCube object share the same (unsigned char*) array. That saves again a lot of memory. - call MarchingCube::clean_temps *before* copying its result in the demo's internal structures. My laptop with 2GB RAM can now call the marching cubes algorithm on the colon 3D image. It uses 2.8GB of virtual memory, which is just below the limit of 3GB (Linux's limit on x86 machines)! --- .../demo/Surface_mesher/qt4-demo/CMakeLists.txt | 2 +- .../demo/Surface_mesher/qt4-demo/volume.cpp | 17 +++++++++-------- .../demo/Surface_mesher/qt4-demo/volume.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Surface_mesher/demo/Surface_mesher/qt4-demo/CMakeLists.txt b/Surface_mesher/demo/Surface_mesher/qt4-demo/CMakeLists.txt index 0d005da2943..c7477805ee4 100644 --- a/Surface_mesher/demo/Surface_mesher/qt4-demo/CMakeLists.txt +++ b/Surface_mesher/demo/Surface_mesher/qt4-demo/CMakeLists.txt @@ -40,7 +40,7 @@ if ( CGAL_FOUND AND QT_FOUND AND QGLVIEWER_FOUND ) include_directories( ${QGLVIEWER_INCLUDE_DIR} ) - set( sources colorlisteditor.cpp isovalues_list.cpp mainwindow.cpp polyhedral_surface.cpp surface_mesher.cpp viewer.cpp volume.cpp ../../../../Marching_cube/src/mc/MarchingCubes.cpp ../../../../Marching_cube/src/mc/ply.c) + set( sources colorlisteditor.cpp isovalues_list.cpp mainwindow.cpp polyhedral_surface.cpp surface_mesher.cpp viewer.cpp volume.cpp ../../../../Marching_cube/src/mc/ply.c) qt4_automoc( ${sources} ) diff --git a/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.cpp b/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.cpp index 9b417719e00..da1c8c56fb3 100644 --- a/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.cpp +++ b/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.cpp @@ -313,19 +313,21 @@ void Volume::display_marchin_cube() mc.init_all(); // set data - for(unsigned int i=0;i(m_image.image()->data)); // compute scaling ratio const double xr = m_image.xmax() / nx; const double yr = m_image.ymax() / ny; const double zr = m_image.zmax() / nz; mc.run(isovalues_list->isovalue(isovalue_id), xr, yr, zr); + mc.clean_temps(); std::vector facets; mc.get_facets(facets); @@ -349,7 +351,6 @@ void Volume::display_marchin_cube() timer.stop(); not_busy(); - mc.clean_temps(); status_message(QString("Marching cubes...done (%2 facets in %1 s)").arg(timer.time()).arg(m_surface_mc.size())); } CGAL::Bbox_3 bbox(0,0,0,0,0,0); diff --git a/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.h b/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.h index 497f666ee09..28e79a9ed2b 100644 --- a/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.h +++ b/Surface_mesher/demo/Surface_mesher/qt4-demo/volume.h @@ -95,7 +95,7 @@ private: std::vector m_surface; std::vector m_surface_mc; - MarchingCubes mc ; + MarchingCubes mc ; Tr del; // 3D-Delaunay triangulation MainWindow* mw;