18 #include "DGtal/base/Common.h"
19 #include "DGtal/kernel/sets/SetPredicate.h"
20 #include "DGtal/kernel/CanonicEmbedder.h"
21 #include "DGtal/io/readers/VolReader.h"
22 #include "DGtal/images/ImageSelector.h"
23 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
24 #include "DGtal/images/ImageLinearCellEmbedder.h"
25 #include "DGtal/shapes/Shapes.h"
26 #include "DGtal/helpers/StdDefs.h"
27 #include "DGtal/topology/helpers/Surfaces.h"
28 #include "DGtal/topology/DigitalSurface.h"
29 #include "DGtal/topology/SetOfSurfels.h"
35 using namespace DGtal;
40 void usage(
int,
char** argv )
42 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <Adj>" << std::endl;
43 std::cerr <<
"\t - displays the boundary of the shape stored in vol file <fileName.vol>." << std::endl;
44 std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
45 std::cerr <<
"\t - 0: interior adjacency, 1: exterior adjacency." << std::endl;
49 int main(
int argc,
char** argv )
56 std::string inputFilename = argv[ 1 ];
57 unsigned int minThreshold = atoi( argv[ 2 ] );
58 unsigned int maxThreshold = atoi( argv[ 3 ] );
59 bool intAdjacency = atoi( argv[ 4 ] ) == 0;
68 minThreshold, maxThreshold);
74 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
76 bool space_ok = ks.
init( image.domain().lowerBound(),
77 image.domain().upperBound(), true );
80 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
88 MySurfelAdjacency surfAdj( intAdjacency );
96 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
99 image.domain().lowerBound(),
100 image.domain().upperBound() );
101 MyDigitalSurface digSurf( theSetOfSurfels );
102 trace.
info() <<
"Digital surface has " << digSurf.size() <<
" surfels."
112 CellEmbedder cellEmbedder;
113 MyEmbedder trivialEmbedder;
114 cellEmbedder.
init( ks, image, trivialEmbedder, minThreshold );
115 ofstream out(
"marching-cube.off" );
117 digSurf.exportEmbeddedSurfaceAs3DOFF( out, cellEmbedder );