DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
3dBorderExtraction.cpp
1 
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include <QtGui/qapplication.h>
34 #include "DGtal/base/Common.h"
35 #include "DGtal/io/readers/VolReader.h"
36 #include "DGtal/io/viewers/Viewer3D.h"
37 #include "DGtal/io/DrawWithDisplay3DModifier.h"
38 #include "DGtal/io/Color.h"
39 #include "DGtal/images/ImageSelector.h"
40 #include "DGtal/helpers/StdDefs.h"
41 #include "ConfigExamples.h"
42 
43 
45 
46 using namespace std;
47 using namespace DGtal;
48 
50 
51 int main( int argc, char** argv )
52 {
53  typedef SpaceND< 3,int > Z3;
57 
58  Adj6 adj6;
59  Adj18 adj18;
60  DT6_18 dt6_18( adj6, adj18, JORDAN_DT );
61 
62  typedef Z3::Point Point;
64  typedef Domain::ConstIterator DomainConstIterator;
66  typedef Object<DT6_18, DigitalSet> ObjectType;
67 
68  Point p1( -50, -50, -50 );
69  Point p2( 50, 50, 50 );
70  Domain domain( p1, p2 );
71  Point c( 0, 0 );
72  // diamond of radius 30
73  DigitalSet diamond_set( domain );
74  for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
75  {
76  if ( (*it - c ).norm1() <= 30 ) diamond_set.insertNew( *it );
77  }
78  ObjectType diamond( dt6_18, diamond_set );
79  // The following line takes almost no time.
80  ObjectType diamond_clone( diamond );
81  // Since one of the objects is modified, the set is duplicated at the following line
82  diamond_clone.pointSet().erase( c );
83  ObjectType bdiamond = diamond.border(); // one component
84  ObjectType bdiamond_clone = diamond_clone.border(); // two components
85 
86  QApplication application(argc,argv);
87  Viewer3D 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) << Display3D::updateDisplay;
93  return application.exec();
94 
95 }
96 // //