34 #if defined(SegmentComputerUtils_RECURSES)
35 #error Recursive header files inclusion detected in SegmentComputerUtils.h
36 #else // defined(SegmentComputerUtils_RECURSES)
38 #define SegmentComputerUtils_RECURSES
40 #if !defined SegmentComputerUtils_h
42 #define SegmentComputerUtils_h
45 #include "DGtal/base/Circulator.h"
70 template <
typename SC>
121 template<
typename IC>
131 unsigned int k = c/2;
150 template<
typename IC>
163 template <
typename SC>
166 while ( (s.end() != end)
167 && (s.extendFront()) ) {}
173 template <
typename SC>
177 const typename SC::ConstIterator newEnd( s.begin() );
178 while ( (s.extendFront())
179 && (s.end() != newEnd) ) {}
187 template <
typename SC>
197 template <
typename SC>
200 while ( (s.begin() != begin)
201 && (s.extendBack()) ) {}
202 if (s.begin() == begin) s.extendBack();
208 template <
typename SC>
211 boost::ignore_unused_variable_warning( begin );
213 const typename SC::ConstIterator newBegin( s.end() );
214 while ( (s.extendBack())
215 && (s.begin() != newBegin) ) {}
224 template <
typename SC>
235 template <
typename SC>
237 const typename SC::ConstIterator& begin,
238 const typename SC::ConstIterator& end,
242 bool flagForward =
true;
248 if ( s.end() != end ) flagOk = s.extendFront();
252 if ( s.begin() != begin ) flagOk = s.extendBack();
257 if (s.begin() != begin ) {
258 if (s.extendBack())
return !s.extendFront();
269 template <
typename SC>
271 const typename SC::ConstIterator& begin,
272 const typename SC::ConstIterator& end,
275 boost::ignore_unused_variable_warning( begin );
276 boost::ignore_unused_variable_warning( end );
279 bool flagForward =
true;
282 while ( (flagOk) && ( s.end() != s.begin() ) ) {
285 flagOk = s.extendFront();
288 flagOk = s.extendBack();
304 template <
typename SC>
306 const typename SC::ConstIterator& begin,
307 const typename SC::ConstIterator& end) {
322 template <
typename SC>
325 if ( isNotEmpty<typename SC::ConstIterator>(s.end(),end) ) {
326 while ( (! s.isExtendableFront() )
327 &&(s.retractBack() ) ) {}
329 while ( s.retractBack() ) {}
340 template <
typename SC>
343 if ( isNotEmpty<typename SC::ConstIterator>(s.begin(),begin) ) {
344 while ( (! s.isExtendableBack() )
345 &&(s.retractFront() ) ) {}
347 while ( s.retractFront() ) {}
358 template <
typename SC>
360 const typename SC::ConstIterator& i,
361 const typename SC::ConstIterator& end,
373 template <
typename SC>
375 const typename SC::ConstIterator& i,
376 const typename SC::ConstIterator& end,
390 template <
typename SC>
392 const typename SC::ConstIterator& i,
393 const typename SC::ConstIterator& end)
411 template <
typename SC>
413 const typename SC::ConstIterator& i,
414 const typename SC::ConstIterator& begin,
415 const typename SC::ConstIterator& end,
419 typedef typename SC::ConstIterator ConstIterator;
420 typedef typename SC::Reverse ReverseSegmentComputer;
421 typedef typename ReverseSegmentComputer::ConstIterator ConstReverseIterator;
423 if ( isNotEmpty<ConstIterator>(i,end) ) {
426 ConstIterator it( i ); ++it;
427 ConstReverseIterator rit( it );
428 ConstReverseIterator rend( begin );
429 ReverseSegmentComputer r( s.getReverse() );
433 ConstIterator it2( r.end().base() );
448 template <
typename SC>
450 const typename SC::ConstIterator& i,
451 const typename SC::ConstIterator& begin,
452 const typename SC::ConstIterator& end,
470 template <
typename SC>
472 const typename SC::ConstIterator& i,
473 const typename SC::ConstIterator& begin,
474 const typename SC::ConstIterator& end,
489 template <
typename SC>
491 const typename SC::ConstIterator& i,
492 const typename SC::ConstIterator& begin,
493 const typename SC::ConstIterator& end,
507 template <
typename SC>
509 const typename SC::ConstIterator& i,
510 const typename SC::ConstIterator& begin,
511 const typename SC::ConstIterator& end )
513 firstMaximalSegment<SC>(s, i, begin, end,
528 template <
typename SC>
530 const typename SC::ConstIterator& i,
531 const typename SC::ConstIterator& begin,
532 const typename SC::ConstIterator& end,
536 typedef typename SC::ConstIterator ConstIterator;
537 typedef typename SC::Reverse ReverseSegmentComputer;
538 typedef typename ReverseSegmentComputer::ConstIterator ConstReverseIterator;
547 ConstIterator k( s.begin() );
550 if ( isNotEmpty<ConstIterator>(s.end(),end) ) {
553 ConstIterator it( s.end() ); ++it;
554 ConstReverseIterator rit( it );
555 ConstReverseIterator rend( s.begin() );
556 ReverseSegmentComputer r( s.getReverse() );
558 ConstIterator newBegin = r.end().base();
559 ASSERT( newBegin != s.begin() );
586 template <
typename SC>
588 const typename SC::ConstIterator& i,
589 const typename SC::ConstIterator& begin,
590 const typename SC::ConstIterator& end,
622 template <
typename SC>
624 const typename SC::ConstIterator& i,
625 const typename SC::ConstIterator& begin,
626 const typename SC::ConstIterator& end,
641 template <
typename SC>
643 const typename SC::ConstIterator& i,
644 const typename SC::ConstIterator& begin,
645 const typename SC::ConstIterator& end,
659 template <
typename SC>
661 const typename SC::ConstIterator& i,
662 const typename SC::ConstIterator& begin,
663 const typename SC::ConstIterator& end )
665 mostCenteredMaximalSegment<SC>(s, i, begin, end,
680 template <
typename SC>
682 const typename SC::ConstIterator& i,
683 const typename SC::ConstIterator& begin,
684 const typename SC::ConstIterator& end,
688 typedef typename SC::ConstIterator ConstIterator;
689 typedef typename SC::Reverse ReverseSegmentComputer;
690 typedef typename ReverseSegmentComputer::ConstIterator ConstReverseIterator;
693 ConstIterator j( i );
697 ConstIterator it( s.end() );
698 ConstReverseIterator rit( it );
699 ConstReverseIterator rend( begin );
700 ReverseSegmentComputer r( s.getReverse() );
704 ConstIterator it2( r.end().base() );
716 template <
typename SC>
718 const typename SC::ConstIterator& i,
719 const typename SC::ConstIterator& begin,
720 const typename SC::ConstIterator& end,
738 template <
typename SC>
740 const typename SC::ConstIterator& i,
741 const typename SC::ConstIterator& begin,
742 const typename SC::ConstIterator& end,
757 template <
typename SC>
759 const typename SC::ConstIterator& i,
760 const typename SC::ConstIterator& begin,
761 const typename SC::ConstIterator& end,
775 template <
typename SC>
777 const typename SC::ConstIterator& i,
778 const typename SC::ConstIterator& begin,
779 const typename SC::ConstIterator& end )
781 lastMaximalSegment<SC>(s, i, begin, end,
796 template <
typename SC>
798 const typename SC::ConstIterator& end,
812 template <
typename SC>
814 const typename SC::ConstIterator& end,
827 template <
typename SC>
829 const typename SC::ConstIterator& end,
832 typedef typename SC::ConstIterator ConstIterator;
838 ConstIterator i( s.begin() ); ++i;
841 if ( i == s.end() ) {
842 if ( isNotEmpty<ConstIterator>(i, end) ) {
860 template <
typename SC>
862 const typename SC::ConstIterator& end,
875 template <
typename SC>
877 const typename SC::ConstIterator& end )
879 nextMaximalSegment<SC>(s, end,
894 template <
typename SC>
896 const typename SC::ConstIterator& begin,
899 if ( isNotEmpty<typename SC::ConstIterator>(s.begin(),begin) )
911 template <
typename SC>
913 const typename SC::ConstIterator& begin,
916 if ( isNotEmpty<typename SC::ConstIterator>(s.begin(),begin) )
927 template <
typename SC>
929 const typename SC::ConstIterator& begin,
933 typedef typename SC::ConstIterator ConstIterator;
939 ConstIterator i( s.end() ); --i;
942 if ( i == s.begin() ) {
943 if ( isNotEmpty<ConstIterator>(i, begin) ) {
962 template <
typename SC>
964 const typename SC::ConstIterator& end,
977 template <
typename SC>
979 const typename SC::ConstIterator& begin )
992 #endif // !defined SegmentComputerUtils_h
994 #undef SegmentComputerUtils_RECURSES
995 #endif // else defined(SegmentComputerUtils_RECURSES)
void nextMaximalSegment(SC &s, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Aim: Provides the category of the segment computer {ForwardSegmentComputer,BidirectionalSegmentComput...
void longestSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &end, IteratorType)
void maximalRetraction(SC &s, const typename SC::ConstIterator &end)
ToDGtalCategory< typename boost::iterator_category< IC >::type >::Category Category
void maximalExtension(SC &s, const typename SC::ConstIterator &end, IteratorType)
void oppositeEndMaximalExtension(SC &s, const typename SC::ConstIterator &begin, IteratorType)
void oppositeEndMaximalRetraction(SC &s, const typename SC::ConstIterator &begin)
bool maximalSymmetricExtension(SC &s, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, IteratorType)
DGtal is the top-level namespace which contains all DGtal functions and types.
void mostCenteredMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
void lastMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
void previousMaximalSegment(SC &s, const typename SC::ConstIterator &begin, DGtal::ForwardSegmentComputer)
ForwardSegmentComputer Category
bool isNotEmpty(const IC &itb, const IC &ite)
IC getMiddleIterator(const IC &itb, const IC &ite, RandomAccessCategory)
void firstMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)