DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
3dKSSurfaceExtraction.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/Color.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/helpers/Surfaces.h"

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
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/06/27

An example file named 3dKSSurfaceExtraction.

This file is part of the DGtal library.

Definition in file 3dKSSurfaceExtraction.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file 3dKSSurfaceExtraction.cpp.

69{
70
71 Point p1( 0, 0, 0 );
72 Point p2( 20, 20, 20 );
73 Point c( 10, 10, 10 );
74 Domain domain( p1, p2);
75
76 // Generate the digital set from randam seeds and distance threshold.
77 DigitalSet diamond_set( domain );
78 //srand ( time(NULL) );
79 unsigned int nbSeeds = 35;
80 vector<Point> vCenters;
81 vector<uint> vRad;
82 for(unsigned int i=0;i<nbSeeds; i++){
83 vCenters.push_back(Point(rand()%p2[0], rand()%p2[1],
84 rand()%p2[2]));
85 vRad.push_back(rand()%7);
86 }
87 for ( Domain::ConstIterator it = domain.begin(); it != domain.end(); ++it ){
88 for(unsigned int i=0;i<nbSeeds; i++){
89 if ( (*it - vCenters.at(i) ).norm1() <= vRad.at(i) && domain.isInside(*it) &&
90 domain.isInside(*it+Point(1,1,1)) && domain.isInside(*it-Point(1,1,1)) ){
91 diamond_set.insertNew( *it );
92 break;
93 }
94 }
95 }
96
97
98 //A KhalimskySpace is constructed from the domain boundary points.
99 KSpace K;
100 K.init(p1, p2, true);
101
102 SurfelAdjacency<3> SAdj( true );
103 vector<vector<SCell> > vectConnectedSCell;
104
105
106 //Here since the last argument is set to true, the resulting
107 //SignedKhalimskySpaceND are signed in order to indicate the direction
108 //of exterior. You can also get the SignefKhalimskySpaceND with default
109 //sign:
110
111 Surfaces<KSpace>::extractAllConnectedSCell(vectConnectedSCell,K, SAdj, diamond_set, false);
112
113
114 QApplication application(argc,argv);
115 Viewer3D<> viewer (K);
116 viewer.show();
117
118
119 // Each connected compoments are simply displayed with a specific color.
120 GradientColorMap<long> gradient(0, (const long)vectConnectedSCell.size());
121 gradient.addColor(Color::Red);
122 gradient.addColor(Color::Yellow);
123 gradient.addColor(Color::Green);
124 gradient.addColor(Color::Cyan);
125 gradient.addColor(Color::Blue);
126 gradient.addColor(Color::Magenta);
127 gradient.addColor(Color::Red);
128
129
130 for(unsigned int i=0; i< vectConnectedSCell.size();i++){
131 DGtal::Color col= gradient(i);
132 viewer << CustomColors3D(Color(250, 0,0), Color(col.red(),
133 col.green(),
134 col.blue()));
135
136 for(unsigned int j=0; j< vectConnectedSCell.at(i).size();j++){
137 viewer << vectConnectedSCell.at(i).at(j);
138 }
139 }
140
141
142 viewer << CustomColors3D(Color(250, 0,0),Color(250, 200,200, 200));
143 viewer << diamond_set;
144 //viewer << ClippingPlane(0,1,0.0,-2);
145 viewer << Viewer3D<>::updateDisplay;
146 return application.exec();
147}
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color Yellow
Definition: Color.h:422
static const Color Cyan
Definition: Color.h:420
void green(const unsigned char aGreenValue)
static const Color Green
Definition: Color.h:417
void red(const unsigned char aRedValue)
static const Color Red
Definition: Color.h:416
static const Color Blue
Definition: Color.h:419
void blue(const unsigned char aBlueValue)
static const Color Magenta
Definition: Color.h:421
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Iterator for HyperRectDomain.
bool isInside(const Point &p) const
const ConstIterator & begin() const
const ConstIterator & end() const
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.
static void extractAllConnectedSCell(std::vector< std::vector< SCell > > &aVectConnectedSCell, const KSpace &aKSpace, const SurfelAdjacency< KSpace::dimension > &aSurfelAdj, const PointPredicate &pp, bool forceOrientCellExterior=false)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Space::Point Point
Definition: StdDefs.h:168
KSpace K
Domain domain

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::HyperRectDomain< TSpace >::begin(), DGtal::Color::blue(), DGtal::Color::Blue, DGtal::Color::Cyan, domain, DGtal::HyperRectDomain< TSpace >::end(), DGtal::Surfaces< TKSpace >::extractAllConnectedSCell(), DGtal::Color::green(), DGtal::Color::Green, DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), DGtal::HyperRectDomain< TSpace >::isInside(), K, DGtal::Color::Magenta, DGtal::Color::red(), DGtal::Color::Red, DGtal::Viewer3D< TSpace, TKSpace >::show(), and DGtal::Color::Yellow.