DGtal  0.9.2
SaturatedSegmentation.h
1 
17 #pragma once
18 
31 #if defined(SaturatedSegmentation_RECURSES)
32 #error Recursive header files inclusion detected in SaturatedSegmentation.h
33 #else // defined(SaturatedSegmentation_RECURSES)
34 
35 #define SaturatedSegmentation_RECURSES
36 
37 #if !defined SaturatedSegmentation_h
38 
39 #define SaturatedSegmentation_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 
46 #include "DGtal/geometry/curves/SegmentComputerUtils.h"
47 #include "DGtal/geometry/curves/CForwardSegmentComputer.h"
48 
50 
51 namespace DGtal
52 {
53 
55  // template class SaturatedSegmentation
152  template <typename TSegmentComputer>
154  {
155 
156  public:
157 
159  typedef TSegmentComputer SegmentComputer;
160  typedef typename SegmentComputer::ConstIterator ConstIterator;
161 
162  private:
163 
164  typedef typename TSegmentComputer::Reverse ReverseSegmentComputer;
165  typedef typename ReverseSegmentComputer::ConstIterator ConstReverseIterator;
166 
167  // ----------------------- Standard services ------------------------------
168  public:
169 
170 
171 
173  // template class SegmentComputerIterator
180  {
181 
182  // ------------------------- inner Types -----------------------
183 
184  public:
186  typedef typename SegmentComputer::ConstIterator ConstIterator;
187 
188  // ------------------------- data -----------------------
189  private:
190 
195 
199  SegmentComputer mySegmentComputer;
200 
205 
213  ConstIterator myLastMaximalSegmentEnd;
214 
221 
228 
234 
235 
236 
237  // ------------------------- Standard services -----------------------
238  public:
239  friend class SaturatedSegmentation<TSegmentComputer>;
240 
241 
242 
252  const TSegmentComputer& aSegmentComputer,
253  const bool& aFlag );
254 
255 
261 
268 
273 
278  bool isValid() const { return myFlagIsValid; }
279 
280  // ------------------------- iteration services -------------------------
281  public:
282 
286  const SegmentComputer& operator*() const;
287 
291  SegmentComputer get() const;
292 
296  const SegmentComputer* operator->() const;
297 
305 
312  bool operator==( const SegmentComputerIterator & aOther ) const;
313 
320  bool operator!=( const SegmentComputerIterator & aOther ) const;
321 
322  // ----------------------- accessors --------------------------------------
323 
328  bool intersectNext() const;
329 
334  bool intersectPrevious() const;
335 
339  const ConstIterator begin() const;
340 
344  const ConstIterator end() const;
345 
346  // ----------------------- hidden services --------------------------------------
347 
348  private:
349 
350 
351 
360  bool doesIntersectNext(const ConstIterator& it,
361  const ConstIterator& itb, const ConstIterator& ite);
362  bool doesIntersectNext(const ConstIterator& it,
363  const ConstIterator& itb, const ConstIterator& ite, IteratorType);
364  bool doesIntersectNext(const ConstIterator& it,
365  const ConstIterator& itb, const ConstIterator& ite, CirculatorType);
366 
374  bool doesIntersectNext(const ConstIterator& it);
375 
379  void nextMaximalSegment();
380 
385 
389  void initLastMaximalSegment();
390 
391  };
392 
393  //-------------------------------------------------------------------------
394  // end class SegmentComputerIterator
395  //-------------------------------------------------------------------------
396 
397 
398  // ----------------------- Interface --------------------------------------
399  public:
400 
407 
414  SaturatedSegmentation(const ConstIterator& itb,
415  const ConstIterator& ite,
416  const SegmentComputer& aSegmentComputer);
417 
425  void setSubRange(const ConstIterator& itb,
426  const ConstIterator& ite);
427 
428 
434  void setMode(const std::string& aMode);
435 
436 
441 
447 
453 
454 
459  void selfDisplay ( std::ostream & out ) const;
460 
465  bool isValid() const;
466 
467  // ------------------------- Protected Datas ------------------------------
468  private:
469  // ------------------------- Private Datas --------------------------------
470  private:
471 
475  ConstIterator myBegin;
476 
480  ConstIterator myEnd;
481 
485  ConstIterator myStart;
486 
490  ConstIterator myStop;
491 
495  std::string myMode;
496 
500  SegmentComputer mySegmentComputer;
501 
502  // ------------------------- Hidden services ------------------------------
503 
504 
505  private:
506 
512 
519 
520  // ------------------------- Internals ------------------------------------
521  private:
522 
523  }; // end of class SaturatedSegmentation
524 
525 
532  template <typename SegmentComputer>
533  std::ostream&
534  operator<< ( std::ostream & out, const SaturatedSegmentation<SegmentComputer> & object );
535 
536 } // namespace DGtal
537 
538 
540 // Includes inline functions.
541 #include "DGtal/geometry/curves/SaturatedSegmentation.ih"
542 
543 // //
545 
546 #endif // !defined SaturatedSegmentation_h
547 
548 #undef SaturatedSegmentation_RECURSES
549 #endif // else defined(SaturatedSegmentation_RECURSES)
void selfDisplay(std::ostream &out) const
SaturatedSegmentation::SegmentComputer SegmentComputer
bool doesIntersectNext(const ConstIterator &it, const ConstIterator &itb, const ConstIterator &ite)
BOOST_CONCEPT_ASSERT((concepts::CForwardSegmentComputer< TSegmentComputer >))
const SaturatedSegmentation< TSegmentComputer > * myS
SegmentComputerIterator & operator=(const SegmentComputerIterator &aOther)
SaturatedSegmentation::SegmentComputerIterator begin() const
SegmentComputer::ConstIterator ConstIterator
SaturatedSegmentation & operator=(const SaturatedSegmentation &other)
ReverseSegmentComputer::ConstIterator ConstReverseIterator
void setMode(const std::string &aMode)
void setSubRange(const ConstIterator &itb, const ConstIterator &ite)
Aim: Specific iterator to visit all the maximal segments of a saturated segmentation.
TSegmentComputer::Reverse ReverseSegmentComputer
Aim: Defines the concept describing a forward segment computer. Like any model of CIncrementalSegment...
bool operator==(const SegmentComputerIterator &aOther) const
bool operator!=(const SegmentComputerIterator &aOther) const
DGtal is the top-level namespace which contains all DGtal functions and types.
SegmentComputerIterator(const SaturatedSegmentation< TSegmentComputer > *aSegmentation, const TSegmentComputer &aSegmentComputer, const bool &aFlag)
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
SaturatedSegmentation::SegmentComputerIterator end() const