DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GreedySegmentation.h
1 
17 #pragma once
18 
31 #if defined(GreedySegmentation_RECURSES)
32 #error Recursive header files inclusion detected in GreedySegmentation.h
33 #else // defined(GreedySegmentation_RECURSES)
34 
35 #define GreedySegmentation_RECURSES
36 
37 #if !defined GreedySegmentation_h
38 
39 #define GreedySegmentation_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/geometry/curves/CForwardSegmentComputer.h"
46 
48 
49 namespace DGtal
50 {
51 
53  // template class GreedySegmentation
147  template <typename TSegmentComputer>
149  {
150 
151  public:
152 
154  typedef TSegmentComputer SegmentComputer;
155  typedef typename SegmentComputer::ConstIterator ConstIterator;
156 
157  // ----------------------- Standard services ------------------------------
158  public:
159 
160 
161 
163  // template class SegmentComputerIterator
169  {
170 
171  // ------------------------- inner Types -----------------------
172 
173  public:
175  typedef typename SegmentComputer::ConstIterator ConstIterator;
176 
177  // ------------------------- data -----------------------
178  private:
179 
184 
189 
194 
201 
208 
213 
214 
215 
216  // ------------------------- Standard services -----------------------
217  public:
218  friend class GreedySegmentation<TSegmentComputer>;
219 
220 
221 
232  const TSegmentComputer& aSegmentComputer,
233  const bool& aFlag );
234 
235 
241 
248 
253 
258  bool isValid() const { return myFlagIsValid; }
259 
260  // ------------------------- iteration services -------------------------
261  public:
262 
266  const SegmentComputer& operator*() const;
267 
268 
272  SegmentComputer get() const;
273 
274 
278  const SegmentComputer* operator->() const;
279 
287 
293  void next();
294 
295 
302  bool operator==( const SegmentComputerIterator & aOther ) const;
303 
310  bool operator!=( const SegmentComputerIterator & aOther ) const;
311 
312  // ----------------------- accessors --------------------------------------
313 
318  bool intersectNext() const;
319 
324  bool intersectPrevious() const;
325 
329  const ConstIterator begin() const;
330 
334  const ConstIterator end() const;
335 
336  // ----------------------- hidden services --------------------------------------
337 
338  private:
339 
346  void longestSegment(const ConstIterator& it);
347 
356  bool doesIntersectNext(const ConstIterator& it,
357  const ConstIterator& itb, const ConstIterator& ite);
358  bool doesIntersectNext(const ConstIterator& it,
359  const ConstIterator& itb, const ConstIterator& ite, IteratorType);
360  bool doesIntersectNext(const ConstIterator& it,
361  const ConstIterator& itb, const ConstIterator& ite, CirculatorType);
362 
370  bool doesIntersectNext(const ConstIterator& it);
371 
372 
373  };
374 
375 
376  // ----------------------- Interface --------------------------------------
377  public:
378 
385 
392  GreedySegmentation(const ConstIterator& itb,
393  const ConstIterator& ite,
394  const SegmentComputer& aSegmentComputer);
395 
403  void setSubRange(const ConstIterator& itb,
404  const ConstIterator& ite);
405 
406 
412  void setMode(const std::string& aMode);
413 
414 
419 
425 
431 
432 
437  void selfDisplay ( std::ostream & out ) const;
438 
443  bool isValid() const;
444 
445  // ------------------------- Protected Datas ------------------------------
446  private:
447  // ------------------------- Private Datas --------------------------------
448  private:
449 
454 
459 
464 
469 
473  std::string myMode;
474 
479 
480  // ------------------------- Hidden services ------------------------------
481 
482 
483  private:
484 
489  GreedySegmentation ( const GreedySegmentation & other );
490 
497 
498  // ------------------------- Internals ------------------------------------
499  private:
500 
501  }; // end of class GreedySegmentation
502 
503 
510  template <typename SegmentComputer>
511  std::ostream&
512  operator<< ( std::ostream & out, const GreedySegmentation<SegmentComputer> & object );
513 
514 } // namespace DGtal
515 
516 
518 // Includes inline functions.
519 #include "DGtal/geometry/curves/GreedySegmentation.ih"
520 
521 // //
523 
524 #endif // !defined GreedySegmentation_h
525 
526 #undef GreedySegmentation_RECURSES
527 #endif // else defined(GreedySegmentation_RECURSES)