Marching-cube like surface extracted using the combinatorial manifold structure of digital surfaces.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/SetOfSurfels.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
using namespace Z3i;
void usage( int, char** argv )
{
std::cerr << "Usage: " << argv[ 0 ] << " <fileName.vol> <minT> <maxT> <int=0|ext=1>" << std::endl;
std::cerr << "\t - displays the boundary of the shape stored in vol file <fileName.vol> as an OFF geomview surface file. It is a kind of marching-cube surface, defined by duality with respect to the digital surface." << std::endl;
std::cerr << "\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
std::cerr << "\t - 0: interior adjacency, 1: exterior adjacency." << std::endl;
}
int main(
int argc,
char** argv )
{
if ( argc < 5 )
{
usage( argc, argv );
return 1;
}
std::string inputFilename = argv[ 1 ];
unsigned int minThreshold = atoi( argv[ 2 ] );
unsigned int maxThreshold = atoi( argv[ 3 ] );
bool intAdjacency = atoi( argv[ 4 ] ) == 0;
typedef ImageSelector < Domain, int>::Type
Image;
minThreshold, maxThreshold);
bool space_ok =
K.init( image.domain().lowerBound(),
image.domain().upperBound(), true );
if (!space_ok)
{
trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
return 2;
}
MySurfelAdjacency surfAdj( intAdjacency );
MySetOfSurfels theSetOfSurfels(
K, surfAdj );
image.domain().lowerBound(),
image.domain().upperBound() );
trace.
info() <<
"Digital surface has " << digSurf.size() <<
" surfels."
<< std::endl;
ofstream out( "marching-cube.off" );
if ( out.good() )
digSurf.exportSurfaceAs3DOFF( out );
out.close();
return 0;
}
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Define utilities to convert a digital set into an image.
Aim: implements methods to read a "Vol" file format.
ImageContainerBySTLVector< Domain, Value > Image
Z2i::DigitalSet DigitalSet