DGtal  1.3.beta
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  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 
212  ConstRange constRange() const;
213 
218  Range range();
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)
DGtal::Clone
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
DGtal::ImageContainerBySTLMap::~ImageContainerBySTLMap
~ImageContainerBySTLMap()
DGtal::HyperRectDomain::Dimension
Space::Dimension Dimension
Definition: HyperRectDomain.h:116
DGtal::ImageContainerBySTLMap::ImageContainerBySTLMap
ImageContainerBySTLMap(Clone< const Domain > aDomain, const Value &aValue=0)
DGtal::ImageContainerBySTLMap::DomainPtr
CowPtr< const Domain > DomainPtr
Definition: ImageContainerBySTLMap.h:117
DGtal::ImageContainerBySTLMap::setValue
void setValue(const Point &aPoint, const Value &aValue)
DGtal::ImageContainerBySTLMap::ReverseIterator
std::map< Point, Value >::reverse_iterator ReverseIterator
Definition: ImageContainerBySTLMap.h:252
DGtal::ImageContainerBySTLMap::OutputIterator
SetValueIterator< Self > OutputIterator
output iterator
Definition: ImageContainerBySTLMap.h:129
DGtal::ImageContainerBySTLMap::Value
TValue Value
Definition: ImageContainerBySTLMap.h:124
DGtal::ImageContainerBySTLMap::Domain
TDomain Domain
Definition: ImageContainerBySTLMap.h:108
aPoint
const Point aPoint(3, 4)
DGtal::ImageContainerBySTLMap::range
Range range()
DGtal::ImageContainerBySTLMap::Vector
Domain::Vector Vector
Definition: ImageContainerBySTLMap.h:110
DGtal::ImageContainerBySTLMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::ImageContainerBySTLMap::Range
DefaultImageRange< Self > Range
Definition: ImageContainerBySTLMap.h:126
DGtal::ImageContainerBySTLMap::operator=
ImageContainerBySTLMap & operator=(const ImageContainerBySTLMap &other)
DGtal::ImageContainerBySTLMap::constRange
ConstRange constRange() const
DGtal::ImageContainerBySTLMap
Definition: ImageContainerBySTLMap.h:96
DGtal::ImageContainerBySTLMap::Size
Domain::Size Size
Definition: ImageContainerBySTLMap.h:112
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::HyperRectDomain< Space >::Size
Space::Size Size
Definition: HyperRectDomain.h:117
DGtal::ImageContainerBySTLMap::myDomainPtr
DomainPtr myDomainPtr
Definition: ImageContainerBySTLMap.h:137
DGtal::DefaultConstImageRange
Aim: model of CConstBidirectionalRangeFromPoint that adapts the domain of an image in order to iterat...
Definition: DefaultConstImageRange.h:76
DGtal::DefaultImageRange
Aim: model of CConstBidirectionalRangeFromPoint and CBidirectionalRangeWithWritableIteratorFromPoint ...
Definition: DefaultImageRange.h:76
DGtal::ImageContainerBySTLMap::container
const Container & container() const
Definition: ImageContainerBySTLMap.h:224
DGtal::concepts::CDomain
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::ImageContainerBySTLMap::Container
Parent Container
Definition: ImageContainerBySTLMap.h:104
DGtal::ImageContainerBySTLMap::ConstReverseIterator
std::map< Point, Value >::const_reverse_iterator ConstReverseIterator
Definition: ImageContainerBySTLMap.h:253
DGtal::SetValueIterator
Aim: implements an output iterator, which is able to write values in an underlying image,...
Definition: SetValueIterator.h:67
DGtal::ImageContainerBySTLMap::dimension
static const Domain::Dimension dimension
static constants
Definition: ImageContainerBySTLMap.h:120
DGtal::ImageContainerBySTLMap::myDefaultValue
Value myDefaultValue
Default value.
Definition: ImageContainerBySTLMap.h:140
DGtal::ImageContainerBySTLMap::outputIterator
OutputIterator outputIterator()
DGtal::ImageContainerBySTLMap::Vertex
Point Vertex
Definition: ImageContainerBySTLMap.h:114
DGtal::concepts::CLabel
Aim: Define the concept of DGtal labels. Models of CLabel can be default-constructible,...
Definition: CLabel.h:91
DGtal::ImageContainerBySTLMap::Point
Domain::Point Point
Definition: ImageContainerBySTLMap.h:109
DGtal::ImageContainerBySTLMap::operator()
Value operator()(const Point &aPoint) const
DGtal::ImageContainerBySTLMap::Dimension
Domain::Dimension Dimension
Definition: ImageContainerBySTLMap.h:113
DGtal::ImageContainerBySTLMap::Parent
std::map< typename TDomain::Point, TValue > Parent
Definition: ImageContainerBySTLMap.h:103
DGtal::ImageContainerBySTLMap::className
std::string className() const
DGtal::HyperRectDomain< Space >::Integer
Space::Integer Integer
Definition: HyperRectDomain.h:114
DGtal::PointVector< dim, Integer >
DGtal::ImageContainerBySTLMap::ConstIterator
std::map< Point, Value >::const_iterator ConstIterator
Definition: ImageContainerBySTLMap.h:251
DGtal::ImageContainerBySTLMap::container
Container & container()
Definition: ImageContainerBySTLMap.h:229
DGtal::ImageContainerBySTLMap::ConstRange
DefaultConstImageRange< Self > ConstRange
Definition: ImageContainerBySTLMap.h:125
DGtal::ImageContainerBySTLMap::isValid
bool isValid() const
DGtal::ImageContainerBySTLMap::Integer
Domain::Integer Integer
Definition: ImageContainerBySTLMap.h:111
DGtal::ImageContainerBySTLMap::Self
ImageContainerBySTLMap< TDomain, TValue > Self
Definition: ImageContainerBySTLMap.h:102
DGtal::ImageContainerBySTLMap::Iterator
std::map< Point, Value >::iterator Iterator
built-in iterators
Definition: ImageContainerBySTLMap.h:250
DGtal::ImageContainerBySTLMap::domain
const Domain & domain() const
DGtal::ImageContainerBySTLMap::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
domain
DGtal::CowPtr< const Domain >