18#include "DGtal/base/Common.h"
19#include "DGtal/kernel/CanonicEmbedder.h"
20#include "DGtal/io/readers/VolReader.h"
21#include "DGtal/images/ImageSelector.h"
22#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
23#include "DGtal/images/ImageLinearCellEmbedder.h"
24#include "DGtal/shapes/Shapes.h"
25#include "DGtal/helpers/StdDefs.h"
26#include "DGtal/topology/helpers/Surfaces.h"
27#include "DGtal/topology/DigitalSurface.h"
28#include "DGtal/topology/SetOfSurfels.h"
29#include "DGtal/shapes/Mesh.h"
30#include "DGtal/shapes/PolygonalSurface.h"
31#include "DGtal/shapes/MeshHelpers.h"
32#include "DGtal/io/viewers/Viewer3D.h"
43void usage(
int,
char** argv )
45 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <fileName.vol> <minT> <maxT> <Adj>" << std::endl;
46 std::cerr <<
"\t - displays the boundary of the shape stored in vol file <fileName.vol>" << std::endl;
47 std::cerr <<
"\t as a Marching-Cube triangulated surface (more precisely a dual" << std::endl;
48 std::cerr <<
"\t surface to the digital boundary)." << std::endl;
49 std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
50 std::cerr <<
"\t - 0: interior adjacency, 1: exterior adjacency (rules used to connect surface elements unambiguously)." << std::endl;
53int main(
int argc,
char** argv )
60 std::string inputFilename = argv[ 1 ];
61 unsigned int minThreshold = atoi( argv[ 2 ] );
62 unsigned int maxThreshold = atoi( argv[ 3 ] );
63 bool intAdjacency = atoi( argv[ 4 ] ) == 0;
72 minThreshold, maxThreshold);
78 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
80 bool space_ok = ks.
init( image.domain().lowerBound(),
81 image.domain().upperBound(),
true );
84 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
92 MySurfelAdjacency surfAdj( intAdjacency );
100 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
103 image.
domain().lowerBound(),
104 image.domain().upperBound() );
106 trace.
info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
118 typedef std::map< MyDigitalSurface::Vertex, PolygonMesh::Index > VertexMap;
119 PolygonMesh polymesh;
121 TrivialEmbedder trivialEmbedder;
122 CellEmbedder cellEmbedder;
125 cellEmbedder.init( ks, image, trivialEmbedder,
126 ( (
double) minThreshold ) + 0.5 );
129 ( digSurf, cellEmbedder, polymesh, vmap );
130 trace.
info() <<
"Polygonal surface is " << polymesh << std::endl;
132 trace.
info() <<
"Mesh has " << viewmesh.nbVertex()
133 <<
" vertices and " << viewmesh.nbFaces() <<
" faces." << std::endl;
137 QApplication application(argc,argv);
142 viewer << Viewer3D<>::updateDisplay;
Structure representing an RGB triple with alpha component.
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...
virtual void setLineColor(DGtal::Color aColor)
Aim: a cellular embedder for images. (default constructible, copy constructible, assignable)....
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.
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
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="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
Space::RealPoint RealPoint
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