DGtal  0.9.2
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/SegmentComputerUtils.h"
46 #include "DGtal/geometry/curves/CForwardSegmentComputer.h"
47 
49 
50 namespace DGtal
51 {
52 
54  // template class GreedySegmentation
148  template <typename TSegmentComputer>
150  {
151 
152  public:
153 
155  typedef TSegmentComputer SegmentComputer;
156  typedef typename SegmentComputer::ConstIterator ConstIterator;
157 
158  // ----------------------- Standard services ------------------------------
159  public:
160 
161 
162 
164  // template class SegmentComputerIterator
170  {
171 
172  // ------------------------- inner Types -----------------------
173 
174  public:
176  typedef typename SegmentComputer::ConstIterator ConstIterator;
177 
178  // ------------------------- data -----------------------
179  private:
180 
185 
189  SegmentComputer mySegmentComputer;
190 
195 
202 
209 
214 
215 
216 
217  // ------------------------- Standard services -----------------------
218  public:
219  friend class GreedySegmentation<TSegmentComputer>;
220 
221 
222 
233  const TSegmentComputer& aSegmentComputer,
234  const bool& aFlag );
235 
236 
242 
249 
254 
259  bool isValid() const { return myFlagIsValid; }
260 
261  // ------------------------- iteration services -------------------------
262  public:
263 
267  const SegmentComputer& operator*() const;
268 
269 
273  SegmentComputer get() const;
274 
275 
279  const SegmentComputer* operator->() const;
280 
288 
294  void next();
295 
296 
303  bool operator==( const SegmentComputerIterator & aOther ) const;
304 
311  bool operator!=( const SegmentComputerIterator & aOther ) const;
312 
313  // ----------------------- accessors --------------------------------------
314 
319  bool intersectNext() const;
320 
325  bool intersectPrevious() const;
326 
330  const ConstIterator begin() const;
331 
335  const ConstIterator end() const;
336 
337  // ----------------------- hidden services --------------------------------------
338 
339  private:
340 
347  void longestSegment(const ConstIterator& it);
348 
357  bool doesIntersectNext(const ConstIterator& it,
358  const ConstIterator& itb, const ConstIterator& ite);
359  bool doesIntersectNext(const ConstIterator& it,
360  const ConstIterator& itb, const ConstIterator& ite, IteratorType);
361  bool doesIntersectNext(const ConstIterator& it,
362  const ConstIterator& itb, const ConstIterator& ite, CirculatorType);
363 
371  bool doesIntersectNext(const ConstIterator& it);
372 
373 
374  };
375 
376 
377  // ----------------------- Interface --------------------------------------
378  public:
379 
386 
393  GreedySegmentation(const ConstIterator& itb,
394  const ConstIterator& ite,
395  const SegmentComputer& aSegmentComputer);
396 
404  void setSubRange(const ConstIterator& itb,
405  const ConstIterator& ite);
406 
407 
413  void setMode(const std::string& aMode);
414 
415 
420 
426 
432 
433 
438  void selfDisplay ( std::ostream & out ) const;
439 
444  bool isValid() const;
445 
446  // ------------------------- Protected Datas ------------------------------
447  private:
448  // ------------------------- Private Datas --------------------------------
449  private:
450 
454  ConstIterator myBegin;
455 
459  ConstIterator myEnd;
460 
464  ConstIterator myStart;
465 
469  ConstIterator myStop;
470 
474  std::string myMode;
475 
479  SegmentComputer mySegmentComputer;
480 
481  // ------------------------- Hidden services ------------------------------
482 
483 
484  private:
485 
490  GreedySegmentation ( const GreedySegmentation & other );
491 
498 
499  // ------------------------- Internals ------------------------------------
500  private:
501 
502  }; // end of class GreedySegmentation
503 
504 
511  template <typename SegmentComputer>
512  std::ostream&
513  operator<< ( std::ostream & out, const GreedySegmentation<SegmentComputer> & object );
514 
515 } // namespace DGtal
516 
517 
519 // Includes inline functions.
520 #include "DGtal/geometry/curves/GreedySegmentation.ih"
521 
522 // //
524 
525 #endif // !defined GreedySegmentation_h
526 
527 #undef GreedySegmentation_RECURSES
528 #endif // else defined(GreedySegmentation_RECURSES)
void selfDisplay(std::ostream &out) const
void setMode(const std::string &aMode)
bool doesIntersectNext(const ConstIterator &it, const ConstIterator &itb, const ConstIterator &ite)
void setSubRange(const ConstIterator &itb, const ConstIterator &ite)
SegmentComputer::ConstIterator ConstIterator
SegmentComputerIterator(const GreedySegmentation< TSegmentComputer > *aSegmentation, const TSegmentComputer &aSegmentComputer, const bool &aFlag)
Aim: Specific iterator to visit all the segments of a greedy segmentation.
TSegmentComputer SegmentComputer
bool operator!=(const SegmentComputerIterator &aOther) const
const SegmentComputer * operator->() const
const GreedySegmentation< TSegmentComputer > * myS
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators. The last element of a given segment is the first one one of the next segment.
SegmentComputerIterator & operator=(const SegmentComputerIterator &aOther)
GreedySegmentation::SegmentComputerIterator begin() const
GreedySegmentation::SegmentComputerIterator end() const
void longestSegment(const ConstIterator &it)
const SegmentComputer & operator*() const
Aim: Defines the concept describing a forward segment computer. Like any model of CIncrementalSegment...
DGtal is the top-level namespace which contains all DGtal functions and types.
GreedySegmentation & operator=(const GreedySegmentation &other)
BOOST_CONCEPT_ASSERT((concepts::CForwardSegmentComputer< TSegmentComputer >))
GreedySegmentation::SegmentComputer SegmentComputer
bool operator==(const SegmentComputerIterator &aOther) const