DGtal  1.2.0
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)
41 #define ImageContainerBySTLMap_RECURSES
42 
43 #if !defined ImageContainerBySTLMap_h
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  typedef Parent Container;
105 
108  typedef TDomain Domain;
109  typedef typename Domain::Point Point;
110  typedef typename Domain::Vector Vector;
111  typedef typename Domain::Integer Integer;
112  typedef typename Domain::Size Size;
113  typedef typename Domain::Dimension Dimension;
114  typedef Point Vertex;
115 
116  // Pointer to the (const) Domain given at construction.
118 
120  static const typename Domain::Dimension dimension;
121 
124  typedef TValue Value;
127 
130 
132  private:
133 
138 
141 
143 
144  public:
145 
155  ImageContainerBySTLMap( Clone<const Domain> aDomain, const Value& aValue = 0);
156 
163 
171 
177 
178 
180 
190  Value operator()(const Point & aPoint) const;
191 
200  void setValue(const Point &aPoint, const Value &aValue);
201 
202 
206  const Domain &domain() const;
207 
213 
219 
224  const Container & container() const { return static_cast<Parent>(*this); };
229  Container & container() { return static_cast<Parent>(*this); };
230 
235  void selfDisplay ( std::ostream & out ) const;
236 
237 
241  bool isValid() const;
242 
246  std::string className() const;
247 
248 
250  typedef typename std::map<Point,Value>::iterator Iterator;
251  typedef typename std::map<Point,Value>::const_iterator ConstIterator;
252  typedef typename std::map<Point,Value>::reverse_iterator ReverseIterator;
253  typedef typename std::map<Point,Value>::const_reverse_iterator ConstReverseIterator;
254 
261 
262 
263  };
264 
271  template <typename TDomain, typename TValue>
272  inline
273  std::ostream&
274  operator<< ( std::ostream & out,
276  {
277  object.selfDisplay ( out );
278  return out;
279  }
280 
281 
282 } // namespace DGtal
283 
284 
286 // Includes inline functions
287 #include "DGtal/images/ImageContainerBySTLMap.ih"
288 // //
290 
291 #endif // !defined ImageContainerBySTLMap_h
292 
293 #undef ImageContainerBySTLMap_RECURSES
294 #endif // else defined(ImageContainerBySTLMap_RECURSES)
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:267
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
Space::Dimension Dimension
ImageContainerBySTLMap(Clone< const Domain > aDomain, const Value &aValue=0)
ConstRange constRange() const
SetValueIterator< Self > OutputIterator
output iterator
std::map< Point, Value >::iterator Iterator
built-in iterators
DefaultImageRange< Self > Range
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
domain
ImageContainerBySTLMap & operator=(const ImageContainerBySTLMap &other)
std::map< Point, Value >::const_reverse_iterator ConstReverseIterator
void selfDisplay(std::ostream &out) const
Value operator()(const Point &aPoint) const
std::map< typename TDomain::Point, TValue > Parent
std::map< Point, Value >::reverse_iterator ReverseIterator
std::string className() const
const Container & container() const
void setValue(const Point &aPoint, const Value &aValue)
DefaultConstImageRange< Self > ConstRange
BOOST_CONCEPT_ASSERT((concepts::CLabel< TValue >))
range of values
const Domain & domain() const
static const Domain::Dimension dimension
static constants
ImageContainerBySTLMap< TDomain, TValue > Self
std::map< Point, Value >::const_iterator ConstIterator
ImageContainerBySTLMap(const ImageContainerBySTLMap &other)
OutputIterator outputIterator()
Aim: implements an output iterator, which is able to write values in an underlying image,...
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:130
Aim: Define the concept of DGtal labels. Models of CLabel can be default-constructible,...
Definition: CLabel.h:93
const Point aPoint(3, 4)