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/TriangulatedSurface.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>=255] [<Adj>=0]" << 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 - minT is the iso-surface level." << std::endl;
51 std::cerr <<
"\t - maxT should be equal to the maximum possible value in the image." << std::endl;
52 std::cerr <<
"\t - 0: interior adjacency, 1: exterior adjacency (rules used to connect surface elements unambiguously)." << std::endl;
55int main(
int argc,
char** argv )
62 std::string inputFilename = argv[ 1 ];
63 unsigned int minThreshold = atoi( argv[ 2 ] );
64 unsigned int maxThreshold = argc > 3 ? atoi( argv[ 3 ] ) : 255;
65 bool intAdjacency = argc > 4 ? (atoi( argv[ 4 ] ) == 0) :
true;
74 minThreshold, maxThreshold);
80 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
82 bool space_ok = ks.
init( image.domain().lowerBound(),
83 image.domain().upperBound(),
true );
86 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
94 MySurfelAdjacency surfAdj( intAdjacency );
102 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
105 image.
domain().lowerBound(),
106 image.domain().upperBound() );
108 trace.
info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
120 typedef std::map< MyDigitalSurface::Vertex, TriMesh::Index > VertexMap;
123 TrivialEmbedder trivialEmbedder;
124 CellEmbedder cellEmbedder;
127 cellEmbedder.init( ks, image, trivialEmbedder,
128 ( (
double) minThreshold ) + 0.5 );
131 ( digSurf, cellEmbedder, trimesh, vmap );
132 trace.
info() <<
"Triangulated surface is " << trimesh << std::endl;
134 trace.
info() <<
"Mesh has " << viewmesh.nbVertex()
135 <<
" vertices and " << viewmesh.nbFaces() <<
" faces." << std::endl;
139 QApplication application(argc,argv);
144 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,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
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="")
Aim: Represents a triangulated surface. The topology is stored with a half-edge data structure....
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
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
PointVector< 3, double > RealPoint
TriangulatedSurface< RealPoint > TriMesh