DGtal  0.9.2
3dBorderExtraction.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 
34 #include "DGtal/io/readers/VolReader.h"
35 #include "DGtal/io/DrawWithDisplay3DModifier.h"
36 #include "DGtal/io/viewers/Viewer3D.h"
37 #include "DGtal/io/Color.h"
38 #include "DGtal/images/ImageSelector.h"
39 #include "DGtal/helpers/StdDefs.h"
40 #include "ConfigExamples.h"
41 
42 
44 
45 using namespace std;
46 using namespace DGtal;
47 
49 
50 int main( int argc, char** argv )
51 {
52  typedef SpaceND< 3,int > Z3;
56 
57  Adj6 adj6;
58  Adj18 adj18;
59  DT6_18 dt6_18( adj6, adj18, JORDAN_DT );
60 
61  typedef Z3::Point Point;
63  typedef Domain::ConstIterator DomainConstIterator;
65  typedef Object<DT6_18, DigitalSet> ObjectType;
66 
67  Point p1( -50, -50, -50 );
68  Point p2( 50, 50, 50 );
69  Domain domain( p1, p2 );
70  Point c( 0, 0 );
71  // diamond of radius 30
72  DigitalSet diamond_set( domain );
73  for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
74  {
75  if ( (*it - c ).norm1() <= 30 ) diamond_set.insertNew( *it );
76  }
77  ObjectType diamond( dt6_18, diamond_set );
78  // The following line takes almost no time.
79  ObjectType diamond_clone( diamond );
80  // Since one of the objects is modified, the set is duplicated at the following line
81  diamond_clone.pointSet().erase( c );
82  ObjectType bdiamond = diamond.border(); // one component
83  ObjectType bdiamond_clone = diamond_clone.border(); // two components
84 
85  QApplication application(argc,argv);
86  typedef Viewer3D<> MyViewer;
87  MyViewer viewer;
88  viewer.show();
89  viewer<< CustomColors3D(Color(250, 250,250),Color(250, 250,250));
90  viewer << bdiamond_clone;
91  viewer << bdiamond ;
92  viewer << ClippingPlane(1,1,0,5, false) << MyViewer::updateDisplay;
93  return application.exec();
94 
95 }
96 // //
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition: Object.h:119
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
const ConstIterator & begin() const
const ConstIterator & end() const
DigitalTopology< Adj6, Adj18 > DT6_18
Definition: StdDefs.h:164
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
STL namespace.
Space Z3
Definition: StdDefs.h:145
Aim: Describes digital adjacencies in digital spaces that are defined with the 1-norm and the infinit...
Aim: Represents a digital topology as a couple of adjacency relations.
MetricAdjacency< Space, 1 > Adj6
Definition: StdDefs.h:159
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Class for adding a Clipping plane through the Viewer3D stream. Realizes the concept CDrawableWithView...
MetricAdjacency< Space, 2 > Adj18
Definition: StdDefs.h:161