36#include "DGtal/base/Common.h"
37#include "DGtal/kernel/CanonicEmbedder.h"
38#include "DGtal/io/readers/VolReader.h"
39#include "DGtal/images/ImageSelector.h"
40#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
41#include "DGtal/images/ImageLinearCellEmbedder.h"
42#include "DGtal/shapes/Shapes.h"
43#include "DGtal/helpers/StdDefs.h"
44#include "DGtal/topology/helpers/Surfaces.h"
45#include "DGtal/topology/DigitalSurface.h"
46#include "DGtal/topology/SetOfSurfels.h"
57void usage(
int,
char** argv )
59 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <Adj>" << std::endl;
60 std::cerr <<
"\t - displays the boundary of the shape stored in vol file <fileName.vol>." << std::endl;
61 std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
62 std::cerr <<
"\t - 0: interior adjacency, 1: exterior adjacency." << std::endl;
66int main(
int argc,
char** argv )
73 std::string inputFilename = argv[ 1 ];
74 unsigned int minThreshold = atoi( argv[ 2 ] );
75 unsigned int maxThreshold = atoi( argv[ 3 ] );
76 bool intAdjacency = atoi( argv[ 4 ] ) == 0;
84 minThreshold, maxThreshold);
90 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
92 bool space_ok = ks.
init( image.domain().lowerBound(),
93 image.domain().upperBound(),
true );
96 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
104 MySurfelAdjacency surfAdj( intAdjacency );
112 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
115 image.
domain().lowerBound(),
116 image.domain().upperBound() );
118 trace.
info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
128 CellEmbedder cellEmbedder;
129 MyEmbedder trivialEmbedder;
132 cellEmbedder.
init( ks, image, trivialEmbedder,
133 ( (
double) minThreshold ) + 0.5 );
134 ofstream out(
"marching-cube.off" );
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
const Domain & domain() const
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
void exportEmbeddedSurfaceAs3DOFF(std::ostream &out, const CellEmbedder &cembedder) const
Aim: a cellular embedder for images. (default constructible, copy constructible, assignable)....
void init(ConstAlias< KSpace > K, ConstAlias< Image > f, ConstAlias< Embedder > e, double iso_value)
Aim: implements association bewteen points lying in a digital domain and values.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
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: A trivial embedder for digital points, which corresponds to the canonic injection of Zn into Rn.
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
ImageContainerBySTLVector< Domain, Value > Image