DGtal  1.5.beta
exampleGridCurve3d.cpp
Go to the documentation of this file.
1 
53 #include <iostream>
54 #include "DGtal/base/Common.h"
55 #include "DGtal/helpers/StdDefs.h"
56 #include "ConfigExamples.h"
57 #include "DGtal/io/viewers/Viewer3D.h"
58 #include "DGtal/geometry/curves/GridCurve.h"
59 
60 #ifdef WITH_VISU3D_QGLVIEWER
61 #include "DGtal/io/DrawWithDisplay3DModifier.h"
62 #endif
63 
65 
66 using namespace std;
67 using namespace DGtal;
68 using namespace Z3i;
69 
70 
71 
73 int main( int argc, char** argv )
74 {
75 
76 
77  trace.info() << "exampleGridCurve3d: the type of data to be displayed "
78  << "may be given as argument as follows: "
79  << argv[0] << " scells" << endl;
80  trace.info() << "Available types are: gridcurve (default), scells, points, midpoints, arrows" << endl;
81 
82  string type = (argc > 1) ? string(argv[1]) : "gridcurve";
83  trace.info() << "Chosen type: " << type << endl;
84 
85  //curve
86  string sinus = examplesPath + "samples/sinus.dat";
87 
88  // domain
89  Point lowerBound = Point::diagonal( -100 );
90  Point upperBound = Point::diagonal( 100 );
91 
93  K3 ks; ks.init( lowerBound, upperBound, true );
94  GridCurve<K3> gc( ks );
96 
98  fstream inputStream;
99  inputStream.open (sinus.c_str(), ios::in);
100 
101  gc.initFromVectorStream(inputStream);
102 
103  inputStream.close();
105 
106  bool flag = false;
107 #ifdef WITH_VISU3D_QGLVIEWER
108  QApplication application(argc,argv);
109  Viewer3D<Space,K3> viewer(ks);
110  viewer.show();
111 
112  if (type == "gridcurve")
113  {
114  viewer << gc;
115  }
116  else if (type == "scells")
117  {
118  viewer << gc.getSCellsRange();
119  }
120  else if (type == "points")
121  {
122  viewer << gc.getPointsRange();
123  }
124  else if (type == "midpoints")
125  {
126  viewer << gc.getMidPointsRange();
127  }
128  else if (type == "arrows")
129  {
130  viewer << gc.getArrowsRange();
131  }
132  else
133  {
134  trace.info() << "Display type not known." << std::endl;
135  }
136  viewer << Viewer3D<Space,K3>::updateDisplay;
137  flag = application.exec();
138 #endif
139 
140  return flag;
141 }
142 // //
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:173
SCellsRange getSCellsRange() const
Definition: GridCurve.h:415
MidPointsRange getMidPointsRange() const
Definition: GridCurve.h:438
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
Definition: GridCurve.h:426
ArrowsRange getArrowsRange() const
Definition: GridCurve.h:450
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
std::ostream & info()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153