33 #include "DGtal/base/Common.h"
34 #include "DGtal/io/readers/VolReader.h"
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/topology/helpers/Surfaces.h"
37 #include "DGtal/topology/DigitalSurface.h"
38 #include "DGtal/topology/SetOfSurfels.h"
39 #include "DGtal/images/ImageSelector.h"
40 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
46 using namespace DGtal;
52 void usage(
int,
char** argv )
54 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <int=0|ext=1>" << std::endl;
55 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;
56 std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
57 std::cerr <<
"\t - 0: interior adjacency, 1: exterior adjacency." << std::endl;
60 int main(
int argc,
char** argv )
67 std::string inputFilename = argv[ 1 ];
68 unsigned int minThreshold = atoi( argv[ 2 ] );
69 unsigned int maxThreshold = atoi( argv[ 3 ] );
70 bool intAdjacency = atoi( argv[ 4 ] ) == 0;
79 minThreshold, maxThreshold);
86 bool space_ok = K.
init( image.domain().lowerBound(),
87 image.domain().upperBound(), true );
90 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
97 MySurfelAdjacency surfAdj( intAdjacency );
107 MySetOfSurfels theSetOfSurfels( K, surfAdj );
110 image.domain().lowerBound(),
111 image.domain().upperBound() );
112 MyDigitalSurface digSurf( theSetOfSurfels );
113 trace.
info() <<
"Digital surface has " << digSurf.size() <<
" surfels."
120 ofstream out(
"marching-cube.off" );
122 digSurf.exportSurfaceAs3DOFF( out );