DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
exampleGridCurve3d.cpp
1 
30 
31 #include <iostream>
32 
33 #include "DGtal/base/Common.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "ConfigExamples.h"
36 
37 #include "DGtal/geometry/curves/GridCurve.h"
38 
39  #ifdef WITH_VISU3D_QGLVIEWER
40 #include <QtGui/qapplication.h>
41 #include "DGtal/io/viewers/Viewer3D.h"
42 #include "DGtal/io/DrawWithDisplay3DModifier.h"
43  #endif
44 
46 
47 using namespace std;
48 using namespace DGtal;
49 using namespace Z3i;
50 
52 #include <boost/program_options/options_description.hpp>
53 #include <boost/program_options/parsers.hpp>
54 #include <boost/program_options/variables_map.hpp>
55 
56 namespace po = boost::program_options;
57 
59 int main( int argc, char** argv )
60 {
62  // parse command line
63  po::options_description general_opt("Allowed options are");
64  general_opt.add_options()
65  ("help,h", "display this message")
66  ("range,r", po::value<string>()->default_value("gridcurve"),
67  " Either <gridcurve> (default), <scells>, <points>, <midpoints>, <arrows> " );
68 
69  po::variables_map vm;
70  po::store(po::parse_command_line(argc, argv, general_opt), vm);
71  po::notify(vm);
72  if(vm.count("help"))
73  {
74  trace.info()<< "exampleGridCurve3d" << std::endl
75  << "Basic usage: "<<std::endl
76  << argv[0] << " " << std::endl
77  << general_opt << "\n";
78  return 0;
79  }
80 
81  //Parse options
82  string type = vm["range"].as<string>();
83 
84  //curve
85  string sinus = examplesPath + "samples/sinus.dat";
86 
87  // domain
88  Point lowerBound = Point::diagonal( -100 );
89  Point upperBound = Point::diagonal( 100 );
90 
92  K3 ks; ks.init( lowerBound, upperBound, true );
93  GridCurve<K3> gc( ks );
95 
97  fstream inputStream;
98  inputStream.open (sinus.c_str(), ios::in);
99 
100  gc.initFromVectorStream(inputStream);
101 
102  inputStream.close();
104 
105  bool flag = false;
106  #ifdef WITH_VISU3D_QGLVIEWER
107  QApplication application(argc,argv);
108  Viewer3D viewer;
109  viewer.show();
110 
111  if (type == "gridcurve")
112  {
113  viewer << gc;
114  }
115  else if (type == "scells")
116  {
117  viewer << gc.getSCellsRange();
118  }
119  else if (type == "points")
120  {
121  viewer << gc.getPointsRange();
122  }
123  else if (type == "midpoints")
124  {
125  viewer << gc.getMidPointsRange();
126  }
127  else if (type == "arrows")
128  {
129  viewer << gc.getArrowsRange();
130  }
131  else
132  {
133  trace.info() << "Display type not known. Use option -h" << std::endl;
134  }
135  viewer << Viewer3D::updateDisplay;
136  flag = application.exec();
137  #endif
138 
139  return flag;
140 }
141 // //