File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
geometry/curves/exampleGridCurve3d-2.cpp

This example shows how to use GridCurve as a sequence of 2-scells in a 3d Khalimsky space.

$ ./examples/geometry/curves/exampleGridCurve3d-2

Note that the data type you want to display may be passed as argument as follows:

$ ./examples/geometry/curves/exampleGridCurve3d-2 gridcurve

This command line produces the following output:

Slice of a digital surface
See also
Analysis of one-dimensional discrete structures
#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/PolyscopeViewer.h"
#include "DGtal/io/readers/VolReader.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 std;
using namespace DGtal;
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;
//vol reading and digital set construction
trace.beginBlock( "Reading vol file into an image." );
typedef ImageSelector < Domain, int>::Type Image;
std::string inputFilename = examplesPath + "samples/cat10.vol";
DigitalSet set3d (image.domain());
trace.info() << set3d.size() << " voxels." << std::endl;
trace.endBlock();
//Khalimsky space construction
trace.beginBlock( "Construct the Khalimsky space from the image domain." );
KSpace ks;
trace.endBlock();
//digital surface construction
typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
MySurfelAdjacency surfAdj( true ); // interior in all directions.
trace.beginBlock( "Extracting boundary by scanning the space. " );
typedef KSpace::Surfel Surfel;
typedef KSpace::SurfelSet SurfelSet;
typedef SetOfSurfels< KSpace, SurfelSet > MySetOfSurfels;
MySetOfSurfels theSetOfSurfels( ks, surfAdj );
Surfaces<KSpace>::sMakeBoundary( theSetOfSurfels.surfelSet(),
ks, set3d,
image.domain().lowerBound(),
image.domain().upperBound() );
MyDigitalSurface digSurf( theSetOfSurfels );
trace.info() << digSurf.size() << " surfels." << std::endl;
trace.endBlock();
//slice retrieving
trace.beginBlock( "Extracting slice and constructing a grid curve. " );
typedef MyDigitalSurface::DigitalSurfaceTracker MyTracker;
//Extract an initial boundary cell
Surfel surf = *digSurf.begin();
MyTracker* tracker = digSurf.container().newTracker( surf );
// Extract the bondary contour associated to the initial surfel in
// its first direction
My2DSlice slice( tracker, *(ks.sDirs( surf )) );
delete tracker;
gc.initFromSCellsRange( slice.begin(), slice.end() );
trace.endBlock();
// for 3D display with PolyscopeViewer
trace.beginBlock( "Display all with Viewer." );
PolyscopeViewer<Space, KSpace> viewer(ks);
// Displaying all the surfels in transparent mode
viewer.allowReuseList = true;
for( MyDigitalSurface::ConstIterator it = theSetOfSurfels.begin(),
it_end = theSetOfSurfels.end(); it != it_end; ++it )
viewer<< *it;
// Displaying slice
viewer << Color( 50, 50, 255 );
if (type == "gridcurve")
{
viewer << gc;
}
else if (type == "inner")
{
viewer << gc.getInnerPointsRange();
}
else if (type == "outer")
{
viewer << gc.getOuterPointsRange();
}
else if (type == "incident")
{
viewer << gc.getIncidentPointsRange();
}
else
{
trace.info() << "Display type not known." << std::endl;
}
trace.endBlock();
viewer.show();
return 0;
}
// //
Structure representing an RGB triple with alpha component.
Definition Color.h:77
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,...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition GridCurve.h:173
IncidentPointsRange getIncidentPointsRange() const
Definition GridCurve.h:478
OuterPointsRange getOuterPointsRange() const
Definition GridCurve.h:466
InnerPointsRange getInnerPointsRange() const
Definition GridCurve.h:454
bool initFromSCellsRange(const TIterator &itb, const TIterator &ite)
void show() override
Starts the event loop and display of elements.
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...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
Trace trace
STL namespace.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
int main()
Definition testBits.cpp:56
Image image(domain)
ImageContainerBySTLVector< Domain, Value > Image
Z2i::DigitalSet DigitalSet