00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkWatershedSegmentTree_h
00018
#define __itkWatershedSegmentTree_h
00019
00020
#include "itkObjectFactory.h"
00021
#include "itkDataObject.h"
00022
#include "itkProcessObject.h"
00023
#include <deque>
00024
#include <functional>
00025
00026
namespace itk
00027 {
00028
namespace watershed
00029 {
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
template <
class TScalarType>
00044 class ITK_EXPORT SegmentTree :
public DataObject
00045 {
00046
public:
00048 typedef SegmentTree
Self;
00049 typedef DataObject Superclass;
00050 typedef SmartPointer<Self> Pointer;
00051 typedef SmartPointer<const Self> ConstPointer;
00052
itkNewMacro(
Self);
00053
itkTypeMacro(SegmentTree,
DataObject);
00054 typedef TScalarType
ScalarType;
00055
00059
struct merge_t
00060 {
00061
unsigned long from;
00062 unsigned long to;
00063 ScalarType saliency;
00064 };
00065
00067
typedef std::deque<merge_t>
DequeType;
00068
typedef typename DequeType::iterator
Iterator;
00069 typedef typename DequeType::const_iterator
ConstIterator;
00070 typedef typename DequeType::value_type
ValueType;
00071
00073
struct merge_comp :
public std::binary_function<bool, const merge_t&,
00074 const merge_t& >
00075 {
00076
bool operator()(
const merge_t &a,
const merge_t &b)
00077 {
00078 return b.
saliency < a.
saliency;
00079 }
00080 };
00081
00083
struct sort_comp :
public std::binary_function<bool, const merge_t&,
00084 const merge_t& >
00085 {
00086
bool operator()(
const merge_t &a,
const merge_t &b)
00087 {
00088 return a.
saliency < s.Saliency;
00089 }
00090 };
00091
00093
typename DequeType::size_type
Size()
const
00094
{
return m_Deque.size(); }
00095
00098
bool Empty()
const
00099
{
return m_Deque.empty(); }
00100
00103
const merge_t &Front()
const
00104
{
return m_Deque.front(); }
00105
00108
const merge_t &Back()
const
00109
{
return m_Deque.back(); }
00110
00112
merge_t &Front()
00113 {
return m_Deque.front(); }
00114
00116
merge_t &Back()
00117 {
return m_Deque.back(); }
00118
00120
void PushFront(
const ValueType &t)
00121 { m_Deque.push_front(t); }
00122
00124
void PushBack(
const ValueType &t)
00125 { m_Deque.push_back(t); }
00126
00128
void PopFront()
00129 { m_Deque.pop_front(); }
00130
00132
void PopBack()
00133 { m_Deque.pop_back(); }
00134
00136
Iterator Begin()
00137 {
return m_Deque.begin(); }
00138
00140
ConstIterator Begin()
const
00141
{
return m_Deque.begin(); }
00142
00145
Iterator End()
00146 {
return m_Deque.end(); }
00147
00150
ConstIterator End()
const
00151
{
return m_Deque.end(); }
00152
00154
void Clear()
00155 { m_Deque.clear(); }
00156
00158
00159
protected:
00160 SegmentTree() {}
00161
virtual ~SegmentTree() {}
00162 SegmentTree(
const Self&) {}
00163 void operator=(
const Self&) {}
00164 void PrintSelf(std::ostream& os,
Indent indent)
const;
00165
00166
DequeType m_Deque;
00167
void UpdateOutputInformation();
00168
bool VerifyRequestedRegion() {
return true; }
00169 void SetRequestedRegionToLargestPossibleRegion () {}
00170
bool RequestedRegionIsOutsideOfTheBufferedRegion () {
return false; }
00171 void SetRequestedRegion (
itk::DataObject *) {}
00172 };
00173 }
00174 }
00175
00176
#ifndef ITK_MANUAL_INSTANTIATION
00177
#include "itkWatershedSegmentTree.txx"
00178
#endif
00179
00180
#endif
00181