DGtal 0.3.0

3dBorderExtraction.cpp


#include <iostream>
#include "DGtal/base/Common.h"
#include <QtGui/qapplication.h>
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/kernel/images/ImageSelector.h"
#include "DGtal/3dViewer/DGtalQGLViewer.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"



using namespace std;
using namespace DGtal;


int main( int argc, char** argv )
{
 typedef SpaceND< 3,int > Z3;
 typedef MetricAdjacency< Z3, 1 > Adj6;
 typedef MetricAdjacency< Z3, 2 > Adj18;
 typedef DigitalTopology< Adj6, Adj18 > DT6_18;

 Adj6 adj6;
 Adj18 adj18;
 DT6_18 dt6_18( adj6, adj18, JORDAN_DT );
 
 typedef Z3::Point Point;
 typedef HyperRectDomain< Z3 > Domain; 
 typedef Domain::ConstIterator DomainConstIterator; 
 typedef DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet;
 typedef Object<DT6_18, DigitalSet> ObjectType;

 Point p1( -50, -50, -50 );
 Point p2( 50, 50, 50 );
 Domain domain( p1, p2 );
 Point c( 0, 0 );
 // diamond of radius 30
 DigitalSet diamond_set( domain );
 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
   {
     if ( (*it - c ).norm1() <= 30 ) diamond_set.insertNew( *it );
   }
 ObjectType diamond( dt6_18, diamond_set );
 // The following line takes almost no time.
 ObjectType diamond_clone( diamond );
 // Since one of the objects is modified, the set is duplicated at the following line
 diamond_clone.pointSet().erase( c );
 ObjectType bdiamond = diamond.border(); // one component
 ObjectType bdiamond_clone = diamond_clone.border(); // two components
 
 QApplication application(argc,argv);
 DGtalQGLViewer viewer;
 viewer.show(); 
 viewer<<  CustomColors3D(QColor(250, 250,250),QColor(250, 250,250));
 viewer << bdiamond_clone;
 viewer << bdiamond ;
 viewer << ClippingPlane(1,1,0,5, false)<< DGtalQGLViewer::updateDisplay;
 
 return application.exec();
 
}
//                                                                           //
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines