mirror of https://github.com/CGAL/cgal
- 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)!
This commit is contained in:
parent
88ebeaa284
commit
e31d045128
|
|
@ -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} )
|
||||
|
||||
|
|
|
|||
|
|
@ -313,19 +313,21 @@ void Volume::display_marchin_cube()
|
|||
mc.init_all();
|
||||
|
||||
// set data
|
||||
for(unsigned int i=0;i<nx;i++)
|
||||
for(unsigned int j=0;j<ny;j++)
|
||||
for(unsigned int k=0;k<nz;k++)
|
||||
{
|
||||
const float& value = m_image.value(i,j,k);
|
||||
mc.set_data(value,i,j,k);
|
||||
}
|
||||
// for(unsigned int i=0;i<nx;i++)
|
||||
// for(unsigned int j=0;j<ny;j++)
|
||||
// for(unsigned int k=0;k<nz;k++)
|
||||
// {
|
||||
// const float& value = m_image.value(i,j,k);
|
||||
// mc.set_data(value,i,j,k);
|
||||
// }
|
||||
mc.set_ext_data(static_cast<unsigned char*>(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<double> 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);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ private:
|
|||
|
||||
std::vector<Facet> m_surface;
|
||||
std::vector<Facet> m_surface_mc;
|
||||
MarchingCubes mc ;
|
||||
MarchingCubes<unsigned char> mc ;
|
||||
Tr del; // 3D-Delaunay triangulation
|
||||
|
||||
MainWindow* mw;
|
||||
|
|
|
|||
Loading…
Reference in New Issue