DGtal  0.9.4beta
ImageContainerBySTLMap.h
1 
17 #pragma once
18 
37 #if defined(ImageContainerBySTLMap_RECURSES)
38 #error Recursive header files inclusion detected in ImageContainerBySTLMap.h
39 #else // defined(ImageContainerBySTLMap_RECURSES)
40 
41 #define ImageContainerBySTLMap_RECURSES
42 
43 #if !defined ImageContainerBySTLMap_h
44 
45 #define ImageContainerBySTLMap_h
46 
48 // Inclusions
49 #include <iostream>
50 #include <map>
51 
52 #include "DGtal/base/Common.h"
53 #include "DGtal/base/BasicFunctors.h"
54 #include "DGtal/base/CowPtr.h"
55 #include "DGtal/base/Clone.h"
56 #include "DGtal/images/DefaultConstImageRange.h"
57 #include "DGtal/images/DefaultImageRange.h"
58 #include "DGtal/images/SetValueIterator.h"
59 #include "DGtal/base/CLabel.h"
60 #include "DGtal/kernel/domains/CDomain.h"
61 
63 
64 #ifdef _MSC_VER
65 #pragma warning(disable : 4290)
66 #endif
67 
68 namespace DGtal
69 {
70 
72  // class ImageContainerBySTLMap
95  template <typename TDomain, typename TValue>
97  public std::map<typename TDomain::Point, TValue >
98  {
99 
100  public:
101 
103  typedef std::map<typename TDomain::Point, TValue > Parent;
104 
107  typedef TDomain Domain;
108  typedef typename Domain::Point Point;
109  typedef typename Domain::Vector Vector;
110  typedef typename Domain::Integer Integer;
111  typedef typename Domain::Size Size;
112  typedef typename Domain::Dimension Dimension;
113  typedef Point Vertex;
114 
115  // Pointer to the (const) Domain given at construction.
117 
119  static const typename Domain::Dimension dimension;
120 
123  typedef TValue Value;
126 
129 
131  private:
132 
136  DomainPtr myDomainPtr;
137 
140 
142 
143  public:
144 
154  ImageContainerBySTLMap( Clone<const Domain> aDomain, const Value& aValue = 0);
155 
162 
170 
176 
177 
179 
189  Value operator()(const Point & aPoint) const;
190 
199  void setValue(const Point &aPoint, const Value &aValue);
200 
201 
205  const Domain &domain() const;
206 
211  ConstRange constRange() const;
212 
217  Range range();
218 
223  void selfDisplay ( std::ostream & out ) const;
224 
225 
229  bool isValid() const;
230 
234  std::string className() const;
235 
236 
238  typedef typename std::map<Point,Value>::iterator Iterator;
239  typedef typename std::map<Point,Value>::const_iterator ConstIterator;
240  typedef typename std::map<Point,Value>::reverse_iterator ReverseIterator;
241  typedef typename std::map<Point,Value>::const_reverse_iterator ConstReverseIterator;
242 
248  OutputIterator outputIterator();
249 
250 
251  };
252 
259  template <typename TDomain, typename TValue>
260  inline
261  std::ostream&
262  operator<< ( std::ostream & out,
264  {
265  object.selfDisplay ( out );
266  return out;
267  }
268 
269 
270 } // namespace DGtal
271 
272 
274 // Includes inline functions
275 #include "DGtal/images/ImageContainerBySTLMap.ih"
276 // //
278 
279 #endif // !defined ImageContainerBySTLMap_h
280 
281 #undef ImageContainerBySTLMap_RECURSES
282 #endif // else defined(ImageContainerBySTLMap_RECURSES)
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Aim: Define the concept of DGtal labels. Models of CLabel can be default-constructible, assignable and equality comparable.
Definition: CLabel.h:91
std::map< Point, Value >::reverse_iterator ReverseIterator
SetValueIterator< Self > OutputIterator
output iterator
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
Aim: implements an output iterator, which is able to write values in an underlying image...
Value operator()(const Point &aPoint) const
std::map< Point, Value >::const_reverse_iterator ConstReverseIterator
ImageContainerBySTLMap & operator=(const ImageContainerBySTLMap &other)
void selfDisplay(std::ostream &out) const
const Domain & domain() const
Space::Dimension Dimension
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
ConstRange constRange() const
void setValue(const Point &aPoint, const Value &aValue)
std::map< typename TDomain::Point, TValue > Parent
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
ImageContainerBySTLMap(Clone< const Domain > aDomain, const Value &aValue=0)
DefaultImageRange< Self > Range
DGtal is the top-level namespace which contains all DGtal functions and types.
DefaultConstImageRange< Self > ConstRange
std::string className() const
static const Domain::Dimension dimension
static constants
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
domain
OutputIterator outputIterator()
ImageContainerBySTLMap< TDomain, TValue > Self
std::map< Point, Value >::const_iterator ConstIterator
std::map< Point, Value >::iterator Iterator
built-in iterators