11#ifndef BIOPROCESSING_WATERSHED_COUSTYFLOWMAP
12#define BIOPROCESSING_WATERSHED_COUSTYFLOWMAP
17#include <aims/vector/vector.h>
19#include <cartodata/volume/volume.h>
21#include <cartobase/smart/rcptr.h>
22#include <cartobase/smart/refwrapper.h>
47 template <
typename V,
typename L>
74 const_iterator begin()
const {
return const_iterator(_volume,
false); }
75 const_iterator end()
const {
return const_iterator(_volume,
true); }
76 iterator begin() {
return iterator(_volume,
false); }
77 iterator end() {
return iterator(_volume,
true); }
84 template <
typename Iterator>
85 void init( Iterator b, Iterator e )
89 for( i = b; i != e; ++i )
91 const typename Iterator::Point & p = i->point();
92 _volume( p[0], p[1], p[2], p[3] ) = labelNone();
98 return std::numeric_limits<L>::max();
103 if( std::numeric_limits<L>::min() < 0 )
106 return std::numeric_limits<L>::max() - 1;
109 L label( Vertex v )
const
111 const typename Vertex::Point & p = v.point();
112 return _volume( p[0], p[1], p[2], p[3] );
115 void setLabel( Vertex v, L lab )
117 const typename Vertex::Point & p = v.point();
118 _volume( p[0], p[1], p[2], p[3] ) = lab;
120 void setMinimum( Vertex v )
122 const typename Vertex::Point & p = v.point();
123 _minima( p[0], p[1], p[2], p[3] ) = 1;
126 carto::VolumeRef<L> volume()
131 size_t size()
const {
return (
size_t) _volume.getSizeX() *
132 (size_t) _volume.getSizeY() *
133 (size_t) _volume.getSizeZ() *
134 (size_t) _volume.getSizeT(); }
135 carto::VolumeRef<L> getMinima()
143 void setVolume( carto::VolumeRef<L> in )
146 _minima->reallocate( in.getSizeX(), in.getSizeY(), in.getSizeZ(), in.getSizeT() );
149 void setDimensions(
int sx = 1,
int sy = 1,
int sz = 1,
int st = 1 )
151 _volume->reallocate( sx, sy, sz, st );
152 _minima->reallocate( sx, sy, sz, st );
155 void setHeader(
const carto::PropertySet & h )
157 _volume->copyHeaderFrom( h );
158 _minima->copyHeaderFrom( h );
163 carto::VolumeRef<L> _volume;
164 carto::VolumeRef<L> _minima;
172 template <
typename L>
176 typedef CoustyFlowMap<PointVertexRef<Point4dl>,L>
Owner;
178 typedef std::pair<Vertex,carto::reference_wrapper<L> >
IterType;
185 _dimensions(in.getSizeX(),in.getSizeY(),in.getSizeZ(),in.getSizeT())
249 return other._current.first ==
_current.first;
251 bool operator==(
const iterator & other )
const {
return other == *
this; }
253 bool operator!=(
const iterator & other )
const {
return !( other == *this ); }
271 friend class CoustyFlowMap<
Vertex, L>;
274 template <
typename L>
276 public CoustyFlowMap<PointVertexRef<Point4dl>,L>::const_iterator
279 iterator( carto::VolumeRef<L> in,
bool end =
false ): const_iterator(in,end) {}
284 typedef CoustyFlowMap<PointVertexRef<Point4dl>, L>
Owner;
286 typedef std::pair<Vertex,carto::reference_wrapper<L> >
IterType;
299 friend class CoustyFlowMap<Vertex,L>;
309 template <
typename V,
typename L>
321 template <
typename L>
323 public carto::rc_ptr<CoustyFlowMap<PointVertexRef<Point4dl>,L> >
327 typedef carto::rc_ptr<CoustyFlowMap<PointVertexRef<Point4dl>,L> >
Base;
348 template <
typename Iterator>
349 void init( Iterator b, Iterator e ) {
return (*this)->init(b,e); }
355 carto::VolumeRef<L>
volume() {
return (*this)->volume(); }
356 size_t size()
const {
return (*this)->size(); }
357 carto::VolumeRef<L>
getMinima() {
return (*this)->getMinima(); }
364 {
return (*this)->setVolume(in); }
366 {
return (*this)->setDimensions(sx,sy,sz,st); }
368 {
return (*this)->setHeader(h); }
carto::rc_ptr< CoustyFlowMap< PointVertexRef< Point4dl >, L > > Base
void setVolume(carto::VolumeRef< L > in)
Pointed::iterator iterator
void setDimensions(int sx=1, int sy=1, int sz=1, int st=1)
Pointed::const_iterator const_iterator
void init(Iterator b, Iterator e)
void setLabel(Vertex v, L lab)
CoustyFlowMap< PointVertexRef< Point4dl >, L > Pointed
void setHeader(const carto::PropertySet &h)
const_iterator end() const
carto::VolumeRef< L > volume()
carto::VolumeRef< L > getMinima()
void setMinimum(Vertex v)
const_iterator begin() const
Reference counting pointer to a CoustyFlowMap.
bool operator==(const const_iterator &other) const
const_iterator & operator=(const const_iterator &other)
const_iterator(const iterator &other)
std::pair< Vertex, carto::reference_wrapper< L > > IterType
bool operator!=(const iterator &other) const
const_iterator & operator++()
const_iterator & operator=(const iterator &other)
const_iterator(const const_iterator &other)
const IterType * operator->() const
const_iterator operator++(int)
carto::VolumeRef< L > _volume
bool operator!=(const const_iterator &other) const
const IterType & operator*() const
CoustyFlowMap< PointVertexRef< Point4dl >, L > Owner
bool operator==(const iterator &other) const
const_iterator(carto::VolumeRef< L > in, bool end=false)
iterator & operator=(const iterator &other)
iterator(carto::VolumeRef< L > in, bool end=false)
iterator(const iterator &other)
std::pair< Vertex, carto::reference_wrapper< L > > IterType
CoustyFlowMap< PointVertexRef< Point4dl >, L > Owner
A flow map is a mapping of the vertices of a graph to a value.
Reference counting pointer to a PointVertex.