DGtal  1.0.0
NaiveParametricCurveDigitizer3D.h
1 
17 #pragma once
18 
31 #if defined(CurveDigitizer_RECURSES)
32 #error Recursive header files inclusion detected in CurveDigitizer.h
33 #else // defined(CurveDigitizer_RECURSES)
34 
35 #define CurveDigitizer_RECURSES
36 
37 #if !defined CurveDigitizer_h
38 
39 #define CurveDigitizer_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/helpers/StdDefs.h"
45 #include "DGtal/base/Common.h"
46 #include <vector>
47 #include <map>
48 #include <iterator>
49 #include "DGtal/geometry/curves/parametric/C3DParametricCurve.h"
51 
52 namespace DGtal
53 {
54 
56 // class NaiveParametricCurveDigitizer3D
71 template <typename TParametricCurve>
73 {
75  // ----------------------- Standard services ------------------------------
76 public:
82  typedef std::vector<Point> DigitalCurve;
89  typedef std::vector< std::pair < long double, unsigned int > > MetaData;
90 
95 
100 
101 
108 
109 
117 
118  // ----------------------- Interface --------------------------------------
119 public:
120 
124  void attach ( ConstAlias<TParametricCurve> p_curve );
125 
131  void init ( long double tmin, long double tmax, long double timeStep );
132 
137  unsigned int setKNext ( unsigned int knext );
138 
139 
143  void digitize ( std::back_insert_iterator < DigitalCurve > inserter );
144 
150  void digitize ( std::back_insert_iterator < DigitalCurve > inserter, std::back_insert_iterator < MetaData > meta_inserter );
151 
156  void selfDisplay ( std::ostream & out ) const;
157 
162  bool isValid() const;
163 
164  // ------------------------- Private Data --------------------------------
165 private:
166 
172 
176  typedef typename Buffer::const_iterator ConstIterator;
177 
182  typedef std::map < Point, std::pair < long double, unsigned int > > DataInfo;
183 
188  unsigned int K_NEXT;
189 
193  unsigned int BUFFER_SIZE;
194 
196  struct KConstIter { typename DigitalCurve::const_iterator jt; unsigned int k; };
198  struct KIter { typename DigitalCurve::iterator jt; unsigned int k; };
199 
200  // ------------------------- Protected Data ------------------------------
201 protected:
207  bool metaData;
209  const TParametricCurve * curve;
211  long double step;
213  long double timeMin;
215  long double timeMax;
217  bool initOK;
218 
219  // ------------------------- Hidden services ------------------------------
220 private:
221 
228  bool is26Connected ( const Point &x, const Point &y );
235  void syncData ( ConstIterator bbegin, ConstIterator bend, DataInfo & weights );
236 
243  void flashBuffers ( Buffer & buffer, DataInfo & weights );
244 
253  void updateMetaData ( const Point & p, const RealPoint & pc, DataInfo & weights, long double t );
254 
258  void cleanCurve ( );
259 
263  void cleanClosedPart ( );
264 
265 
266 
267  // ------------------------- Internals ------------------------------------
268 
269 }; // end of class CurveDigitizer
270 
271 
278 template <typename T>
279 std::ostream&
280 operator<< ( std::ostream & out, const NaiveParametricCurveDigitizer3D<T> & object );
281 
282 
283 } // namespace DGtal
284 
285 
287 // Includes inline functions.
288 #if !defined(BUILD_INLINE)
289 #include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.ih"
290 #endif
291 
292 
293 // //
295 
296 #endif // !defined CurveDigitizer_h
297 
298 #undef CurveDigitizer_RECURSES
299 #endif // else defined(CurveDigitizer_RECURSES)
A structure used for making iterations over digital curve with respect to K_NEXT.
NaiveParametricCurveDigitizer3D & operator=(const NaiveParametricCurveDigitizer3D &other)=delete
std::vector< std::pair< long double, unsigned int > > MetaData
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
void attach(ConstAlias< TParametricCurve > p_curve)
void updateMetaData(const Point &p, const RealPoint &pc, DataInfo &weights, long double t)
Aim: Digitization of 3D parametric curves. This method produces, for good parameters step and k_next,...
void syncData(ConstIterator bbegin, ConstIterator bend, DataInfo &weights)
void digitize(std::back_insert_iterator< DigitalCurve > inserter)
PointVector< 3, double > RealPoint
TParametricCurve::Space::RealPoint RealPoint
Real point type.
bool initOK
A flag which is set to true if the initial paramters are correct.
void selfDisplay(std::ostream &out) const
std::map< Point, std::pair< long double, unsigned int > > DataInfo
long double timeMin
starting time (has to be lower than timeMax)
BOOST_CONCEPT_ASSERT((concepts::C3DParametricCurve< TParametricCurve >))
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
MetaData metaDataContainter
A storage of final meta data (if requested)
bool metaData
A flag used to decided if meta data should be stored and returned to the user.
unsigned int setKNext(unsigned int knext)
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
std::vector< Point > DigitalCurve
Digital curve type.
A structure used for making iterations over digital curve with respect to K_NEXT.
void flashBuffers(Buffer &buffer, DataInfo &weights)
bool is26Connected(const Point &x, const Point &y)
long double timeMax
the time when the digitization should stop (has to be bigger than timeMin)
TParametricCurve::Space::Point Point
Integer point type.
const TParametricCurve * curve
A pointer to the parameteric curve which is going to be digitized.
void init(long double tmin, long double tmax, long double timeStep)
DigitalCurve digitalCurve
A storage of final integer points.