DGtal 1.4.2
Loading...
Searching...
No Matches
exampleGridCurve3d-2.cpp File Reference
#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"
Include dependency graph for exampleGridCurve3d-2.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/06/03

An example file for GridCurve, defined as a sequence of 2-scells, in a 3d Khalimsky space.

This file is part of the DGtal library.

Definition in file exampleGridCurve3d-2.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

[exampleGridCurve3d-Construction]

[exampleGridCurve3d-Construction]

Definition at line 85 of file exampleGridCurve3d-2.cpp.

86{
87 trace.info() << "exampleGridCurve3d-2: the type of data to be displayed "
88 << "may be given as argument as follows: "
89 << argv[0] << " inner" << endl;
90 trace.info() << "Available types are: gridcurve (default), inner, outer, incident" << endl;
91
92 string type = (argc > 1) ? string(argv[1]) : "gridcurve";
93 trace.info() << "Chosen type: " << type << endl;
94
95 //vol reading and digital set construction
96 trace.beginBlock( "Reading vol file into an image." );
98 std::string inputFilename = examplesPath + "samples/cat10.vol";
99 Image image = VolReader<Image>::importVol(inputFilename);
100 DigitalSet set3d (image.domain());
102 trace.info() << set3d.size() << " voxels." << std::endl;
103 trace.endBlock();
104
105 //Khalimsky space construction
106 trace.beginBlock( "Construct the Khalimsky space from the image domain." );
107 KSpace ks;
108 trace.endBlock();
109
110 //digital surface construction
111 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
112 MySurfelAdjacency surfAdj( true ); // interior in all directions.
113
114 trace.beginBlock( "Extracting boundary by scanning the space. " );
115 typedef KSpace::Surfel Surfel;
117 typedef SetOfSurfels< KSpace, SurfelSet > MySetOfSurfels;
119 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
120 Surfaces<KSpace>::sMakeBoundary( theSetOfSurfels.surfelSet(),
121 ks, set3d,
122 image.domain().lowerBound(),
123 image.domain().upperBound() );
124 MyDigitalSurface digSurf( theSetOfSurfels );
125 trace.info() << digSurf.size() << " surfels." << std::endl;
126 trace.endBlock();
127
128 //slice retrieving
129 trace.beginBlock( "Extracting slice and constructing a grid curve. " );
131 typedef DigitalSurface2DSlice< MyTracker > My2DSlice;
132
133 //Extract an initial boundary cell
134 Surfel surf = *digSurf.begin();
135 MyTracker* tracker = digSurf.container().newTracker( surf );
136
137 // Extract the bondary contour associated to the initial surfel in
138 // its first direction
139 My2DSlice slice( tracker, *(ks.sDirs( surf )) );
140 delete tracker;
141
143 GridCurve<KSpace> gc(ks);
144 gc.initFromSCellsRange( slice.begin(), slice.end() );
146
147 trace.endBlock();
148
149
150 // for 3D display with Viewer3D
151 QApplication application(argc,argv);
152 trace.beginBlock( "Display all with QGLViewer." );
153 Viewer3D<Space, KSpace> viewer(ks);
154 viewer.show();
155 // Displaying all the surfels in transparent mode
156 viewer << SetMode3D( surf.className(), "Transparent");
157 for( MyDigitalSurface::ConstIterator it = theSetOfSurfels.begin(),
158 it_end = theSetOfSurfels.end(); it != it_end; ++it )
159 viewer<< *it;
160
161
162 // Displaying slice
163 viewer << Viewer3D<Space, KSpace>::shiftSurfelVisu;
164 viewer << SetMode3D( surf.className(), "");
165 viewer.setFillColor( Color( 50, 50, 255 ) );
166
167 if (type == "gridcurve")
168 {
169 viewer << gc;
170 }
171 else if (type == "inner")
172 {
173 viewer << gc.getInnerPointsRange();
174 }
175 else if (type == "outer")
176 {
177 viewer << gc.getOuterPointsRange();
178 }
179 else if (type == "incident")
180 {
181 viewer << gc.getIncidentPointsRange();
182 }
183 else
184 {
185 trace.info() << "Display type not known." << std::endl;
186 }
187
188 viewer << Viewer3D<Space, KSpace>::updateDisplay;
189 trace.endBlock();
190
191 return application.exec();
192}
Structure representing an RGB triple with alpha component.
Definition Color.h:68
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
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...
DigitalSurfaceContainer::DigitalSurfaceTracker DigitalSurfaceTracker
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition GridCurve.h:173
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
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="")
std::ostream & info()
double endBlock()
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
Trace trace
Definition Common.h:153
ImageContainerBySTLVector< Domain, Value > Type
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
ImageContainerBySTLVector< Domain, Value > Image

References DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::SignedKhalimskyCell< dim, TInteger >::className(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::domain(), DGtal::Trace::endBlock(), DGtal::GridCurve< TKSpace >::getIncidentPointsRange(), DGtal::GridCurve< TKSpace >::getInnerPointsRange(), DGtal::GridCurve< TKSpace >::getOuterPointsRange(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), DGtal::GridCurve< TKSpace >::initFromSCellsRange(), DGtal::KhalimskySpaceND< dim, TInteger >::sDirs(), DGtal::Display3D< Space, KSpace >::setFillColor(), DGtal::setFromImage(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::size(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::size(), DGtal::Surfaces< TKSpace >::sMakeBoundary(), and DGtal::trace.