DGtal  1.3.beta
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/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 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." );
std::string inputFilename = examplesPath + "samples/cat10.vol";
Image image = VolReader<Image>::importVol(inputFilename);
DigitalSet set3d (image.domain());
trace.info() << set3d.size() << " voxels." << std::endl;
//Khalimsky space construction
trace.beginBlock( "Construct the Khalimsky space from the image domain." );
KSpace ks;
//digital surface construction
typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
MySurfelAdjacency surfAdj( true ); // interior in all directions.
trace.beginBlock( "Extracting boundary by scanning the space. " );
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;
//slice retrieving
trace.beginBlock( "Extracting slice and constructing a grid curve. " );
//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() );
// for 3D display with Viewer3D
QApplication application(argc,argv);
trace.beginBlock( "Display all with QGLViewer." );
viewer.show();
// Displaying all the surfels in transparent mode
viewer << SetMode3D( surf.className(), "Transparent");
for( MyDigitalSurface::ConstIterator it = theSetOfSurfels.begin(),
it_end = theSetOfSurfels.end(); it != it_end; ++it )
viewer<< *it;
// Displaying slice
viewer << Viewer3D<Space, KSpace>::shiftSurfelVisu;
viewer << SetMode3D( surf.className(), "");
viewer.setFillColor( 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;
}
viewer << Viewer3D<Space, KSpace>::updateDisplay;
return application.exec();
}
// //
DGtal::Surfaces
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:78
DGtal::DigitalSurface::ConstIterator
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Definition: DigitalSurface.h:163
DGtal::Trace::endBlock
double endBlock()
DGtal::KhalimskySpaceND::SurfelSet
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
Definition: KhalimskySpaceND.h:450
DGtal::DigitalSurface::DigitalSurfaceTracker
DigitalSurfaceContainer::DigitalSurfaceTracker DigitalSurfaceTracker
Definition: DigitalSurface.h:164
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition: DigitalSurface.h:139
DGtal::SurfelAdjacency< KSpace::dimension >
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::GridCurve::initFromSCellsRange
bool initFromSCellsRange(const TIterator &itb, const TIterator &ite)
DGtal::DigitalSurface::size
Size size() const
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::GridCurve
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:172
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::KhalimskySpaceND::sDirs
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
DGtal::KhalimskySpaceND::lowerBound
const Point & lowerBound() const
Return the lower bound for digital points in this space.
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
DGtal::Trace::info
std::ostream & info()
Surfel
KSpace::SCell Surfel
Definition: testArithmeticalDSSComputerOnSurfels.cpp:50
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
DGtal::SignedKhalimskyCell::className
std::string className() const
Return the style name used for drawing this object.
DGtal::Viewer3D< Space, KSpace >
DGtal::DigitalSurface::begin
ConstIterator begin() const
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition: testSimpleRandomAccessRangeFromPoint.cpp:45
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::GridCurve::getInnerPointsRange
InnerPointsRange getInnerPointsRange() const
Definition: GridCurve.h:462
DGtal::GridCurve::getOuterPointsRange
OuterPointsRange getOuterPointsRange() const
Definition: GridCurve.h:474
DGtal::setFromImage
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
DGtal::SetMode3D
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Definition: DrawWithDisplay3DModifier.h:73
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::DigitalSetInserter
Aim: this output iterator class is designed to allow algorithms to insert points in the digital set....
Definition: DigitalSetInserter.h:65
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
DGtal::Display3D::setFillColor
virtual void setFillColor(DGtal::Color aColor)
DGtal::VolReader
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
DGtal::DigitalSurface2DSlice
Aim: Represents a 2-dimensional slice in a DigitalSurface. In a sense, it is a 4-connected contour,...
Definition: DigitalSurface2DSlice.h:93
DGtal::SetOfSurfels
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Definition: SetOfSurfels.h:73
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal::DigitalSurface::container
const DigitalSurfaceContainer & container() const
MyDigitalSurface
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
Definition: greedy-plane-segmentation-ex2.cpp:92
DGtal::GridCurve::getIncidentPointsRange
IncidentPointsRange getIncidentPointsRange() const
Definition: GridCurve.h:486
SurfelSet
MyDigitalSurface::SurfelSet SurfelSet
Definition: greedy-plane-segmentation-ex2.cpp:95
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64