DGtal  0.9.2
exampleGridCurve3d.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "ConfigExamples.h"
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include "DGtal/geometry/curves/GridCurve.h"
37 
38 #ifdef WITH_VISU3D_QGLVIEWER
39 #include "DGtal/io/DrawWithDisplay3DModifier.h"
40 #endif
41 
43 
44 using namespace std;
45 using namespace DGtal;
46 using namespace Z3i;
47 
48 
49 
51 int main( int argc, char** argv )
52 {
53 
54 
55  trace.info() << "exampleGridCurve3d: the type of data to be displayed "
56  << "may be given as argument as follows: "
57  << argv[0] << " scells" << endl;
58  trace.info() << "Available types are: gridcurve (default), scells, points, midpoints, arrows" << endl;
59 
60  string type = (argc > 1) ? string(argv[1]) : "gridcurve";
61  trace.info() << "Chosen type: " << type << endl;
62 
63  //curve
64  string sinus = examplesPath + "samples/sinus.dat";
65 
66  // domain
67  Point lowerBound = Point::diagonal( -100 );
68  Point upperBound = Point::diagonal( 100 );
69 
71  K3 ks; ks.init( lowerBound, upperBound, true );
72  GridCurve<K3> gc( ks );
74 
76  fstream inputStream;
77  inputStream.open (sinus.c_str(), ios::in);
78 
79  gc.initFromVectorStream(inputStream);
80 
81  inputStream.close();
83 
84  bool flag = false;
85 #ifdef WITH_VISU3D_QGLVIEWER
86  QApplication application(argc,argv);
87  Viewer3D<Space,K3> viewer(ks);
88  viewer.show();
89 
90  if (type == "gridcurve")
91  {
92  viewer << gc;
93  }
94  else if (type == "scells")
95  {
96  viewer << gc.getSCellsRange();
97  }
98  else if (type == "points")
99  {
100  viewer << gc.getPointsRange();
101  }
102  else if (type == "midpoints")
103  {
104  viewer << gc.getMidPointsRange();
105  }
106  else if (type == "arrows")
107  {
108  viewer << gc.getArrowsRange();
109  }
110  else
111  {
112  trace.info() << "Display type not known." << std::endl;
113  }
114  viewer << Viewer3D<Space,K3>::updateDisplay;
115  flag = application.exec();
116 #endif
117 
118  return flag;
119 }
120 // //
Trace trace
Definition: Common.h:130
STL namespace.
bool init(const Point &lower, const Point &upper, bool isClosed)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:172
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...