This example shows how to use GridCurve as a sequence of 2-scells in a 3d Khalimsky space.
Note that the data type you want to display may be passed as argument as follows:
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/SetOfSurfels.h"
#include "DGtal/topology/DigitalSurface2DSlice.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/kernel/sets/DigitalSetInserter.h"
#include "DGtal/io/Color.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "ConfigExamples.h"
using namespace Z3i;
int main(
int argc,
char** argv )
{
trace.
info() <<
"exampleGridCurve3d-2: the type of data to be displayed "
<< "may be given as argument as follows: "
<< argv[0] << " inner" << endl;
trace.
info() <<
"Available types are: gridcurve (default), inner, outer, incident" << endl;
string type = (argc > 1) ? string(argv[1]) : "gridcurve";
trace.
info() <<
"Chosen type: " << type << endl;
trace.
beginBlock(
"Reading vol file into an image." );
typedef ImageSelector < Domain, int>::Type
Image;
std::string inputFilename = examplesPath + "samples/cat10.vol";
trace.
info() << set3d.size() <<
" voxels." << std::endl;
trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
MySurfelAdjacency surfAdj( true );
trace.
beginBlock(
"Extracting boundary by scanning the space. " );
typedef KSpace::Surfel
Surfel;
MySetOfSurfels theSetOfSurfels( ks, surfAdj );
ks, set3d,
image.domain().lowerBound(),
image.domain().upperBound() );
trace.
info() << digSurf.size() <<
" surfels." << std::endl;
trace.
beginBlock(
"Extracting slice and constructing a grid curve. " );
typedef MyDigitalSurface::DigitalSurfaceTracker MyTracker;
MyTracker* tracker = digSurf.container().newTracker( surf );
My2DSlice slice( tracker, *(ks.sDirs( surf )) );
delete tracker;
QApplication application(argc,argv);
trace.
beginBlock(
"Display all with QGLViewer." );
viewer <<
SetMode3D( surf.className(),
"Transparent");
for( MyDigitalSurface::ConstIterator it = theSetOfSurfels.begin(),
it_end = theSetOfSurfels.end(); it != it_end; ++it )
viewer<< *it;
viewer << Viewer3D<Space, KSpace>::shiftSurfelVisu;
if (type == "gridcurve")
{
viewer << gc;
}
else if (type == "inner")
{
}
else if (type == "outer")
{
}
else if (type == "incident")
{
}
else
{
trace.
info() <<
"Display type not known." << std::endl;
}
viewer << Viewer3D<Space, KSpace>::updateDisplay;
return application.exec();
}
Structure representing an RGB triple with alpha component.
Aim: this output iterator class is designed to allow algorithms to insert points in the digital set....
Aim: Represents a 2-dimensional slice in a DigitalSurface. In a sense, it is a 4-connected contour,...
ConstIterator begin() const
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
virtual void setFillColor(DGtal::Color aColor)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
IncidentPointsRange getIncidentPointsRange() const
OuterPointsRange getOuterPointsRange() const
InnerPointsRange getInnerPointsRange() const
bool initFromSCellsRange(const TIterator &itb, const TIterator &ite)
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
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
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Aim: implements methods to read a "Vol" file format.
ImageContainerBySTLVector< Domain, Value > Image
Z2i::DigitalSet DigitalSet