DGtal  0.9.2
DigitalSetFromMap.h
1 
17 #pragma once
18 
31 #if defined(DigitalSetFromMap_RECURSES)
32 #error Recursive header files inclusion detected in DigitalSetFromMap.h
33 #else // defined(DigitalSetFromMap_RECURSES)
34 
35 #define DigitalSetFromMap_RECURSES
36 
37 #if !defined DigitalSetFromMap_h
38 
39 #define DigitalSetFromMap_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <map>
45 #include <string>
46 #include "DGtal/base/Common.h"
47 #include "DGtal/base/CowPtr.h"
48 
49 #include "DGtal/base/BasicFunctors.h"
50 #include "DGtal/base/IteratorAdapter.h"
51 #include "DGtal/base/ConstIteratorAdapter.h"
52 
54 
55 
56 namespace DGtal
57 {
58 
60  // template class DigitalSetFromMap
73  template <typename TMapImage>
75  {
76  public:
77 
78  typedef TMapImage Image;
79  typedef std::pair<const typename Image::Point,
80  typename Image::Value> Pair;
82 
83  // -------------------------- required types ------------------------------
84  typedef typename Image::Domain Domain;
85  typedef typename Domain::Point Point;
86  typedef typename Domain::Size Size;
87 
91 
92  // ------------------------- Protected Datas ------------------------------
93  protected:
94 
98  Image* myImgPtr;
99 
103  Functor myFun;
104 
109 
110  // ----------------------- Standard services ------------------------------
111  public:
112 
117 
126  DigitalSetFromMap( Image& aImage,
127  const typename Image::Value& aDefaultValue = 0);
128 
133  DigitalSetFromMap ( const DigitalSetFromMap & other );
134 
141 
142 
143  // ----------------------- Standard Set services --------------------------
144  public:
145 
149  const Domain & domain() const;
150 
155 
159  Size size() const;
160 
164  bool empty() const;
165 
172  void insert( const Point & p );
173 
182  template <typename PointInputIterator>
183  void insert( PointInputIterator first, PointInputIterator last );
184 
194  void insertNew( const Point & p );
195 
206  template <typename PointInputIterator>
207  void insertNew( PointInputIterator first, PointInputIterator last );
208 
215  Size erase( const Point & p );
216 
223  void erase( Iterator it );
224 
232  void erase( Iterator first, Iterator last );
233 
238  void clear();
239 
244  ConstIterator find( const Point & p ) const;
245 
250  Iterator find( const Point & p );
251 
255  ConstIterator begin() const;
256 
260  ConstIterator end() const;
261 
265  Iterator begin();
266 
270  Iterator end();
271 
277  template< typename TDigitalSet >
278  Self & operator+=
279  ( const TDigitalSet & aSet );
280 
281  // ----------------------- Model of concepts::CPointPredicate -----------------------------
282  public:
283 
288  bool operator()( const Point & p ) const;
289 
290  // ----------------------- Other Set services -----------------------------
291  public:
292 
299  template< typename TOutputIterator >
300  void computeComplement(TOutputIterator& ito) const;
301 
309  template< typename TDigitalSet >
310  void assignFromComplement( const TDigitalSet & otherSet );
311 
320  void computeBoundingBox( Point & lower, Point & upper ) const;
321 
322 
323  // ----------------------- Interface --------------------------------------
324  public:
325 
330  void selfDisplay ( std::ostream & out ) const;
331 
336  bool isValid() const;
337 
338 
339  public:
340 
341 
342 
343  // --------------- CDrawableWithBoard2D realization ---------------------
344  public:
345 
349  std::string className() const;
350 
351 
352  // ------------------------- Hidden services ------------------------------
353  protected:
354 
360 
361  private:
362 
363 
364  // ------------------------- Internals ------------------------------------
365  private:
366 
367 
368  }; // end of class DigitalSetFromMap
369 
370 
377  template <typename TMapImage>
378  std::ostream&
379  operator<< ( std::ostream & out, const DigitalSetFromMap<TMapImage> & object );
380 
381 } // namespace DGtal
382 
383 
385 // Includes inline functions.
386 #include "DGtal/kernel/sets/DigitalSetFromMap.ih"
387 
388 // //
390 
391 #endif // !defined DigitalSetFromMap_h
392 
393 #undef DigitalSetFromMap_RECURSES
394 #endif // else defined(DigitalSetFromMap_RECURSES)
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Aim: An adapter for viewing an associative image container like ImageContainerBySTLMap as a simple di...
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > Iterator
void computeBoundingBox(Point &lower, Point &upper) const
void insert(const Point &p)
ConstIterator begin() const
TImageContainer::Point Point
Definition: Image.h:83
CowPtr< Domain > domainPointer() const
void selfDisplay(std::ostream &out) const
std::pair< const typename Image::Point, typename Image::Value > Pair
Size erase(const Point &p)
ConstIterator end() const
DigitalSetFromMap & operator=(const DigitalSetFromMap &other)
void insertNew(const Point &p)
std::string className() const
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > ConstIterator
ConstIterator find(const Point &p) const
DigitalSetFromMap< Image > Self
DGtal is the top-level namespace which contains all DGtal functions and types.
void computeComplement(TOutputIterator &ito) const
void assignFromComplement(const TDigitalSet &otherSet)
functors::Pair1st< Point > Functor
const Domain & domain() const
bool operator()(const Point &p) const