DGtal  1.2.0
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)
35 #define DigitalSetFromMap_RECURSES
36 
37 #if !defined DigitalSetFromMap_h
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 Image Container;
80  typedef std::pair<const typename Image::Point,
81  typename Image::Value> Pair;
83 
84  // -------------------------- required types ------------------------------
85  typedef typename Image::Domain Domain;
86  typedef typename Domain::Point Point;
87  typedef typename Domain::Size Size;
88 
92 
93  // ------------------------- Protected Datas ------------------------------
94  protected:
95 
100 
105 
110 
111  // ----------------------- Standard services ------------------------------
112  public:
113 
118 
128  const typename Image::Value& aDefaultValue = 0);
129 
135 
142 
143 
144  // ----------------------- Standard Set services --------------------------
145  public:
146 
150  const Domain & domain() const;
151 
156 
160  Size size() const;
161 
165  bool empty() const;
166 
173  void insert( const Point & p );
174 
183  template <typename PointInputIterator>
184  void insert( PointInputIterator first, PointInputIterator last );
185 
195  void insertNew( const Point & p );
196 
207  template <typename PointInputIterator>
208  void insertNew( PointInputIterator first, PointInputIterator last );
209 
216  Size erase( const Point & p );
217 
224  void erase( Iterator it );
225 
233  void erase( Iterator first, Iterator last );
234 
239  void clear();
240 
245  ConstIterator find( const Point & p ) const;
246 
251  Iterator find( const Point & p );
252 
257 
262 
267 
272 
277  const Container & container() const { return *myImgPtr;};
282  Container & container(){ return *myImgPtr;};
283 
289  template< typename TDigitalSet >
290  Self & operator+=
291  ( const TDigitalSet & aSet );
292 
293  // ----------------------- Model of concepts::CPointPredicate -----------------------------
294  public:
295 
300  bool operator()( const Point & p ) const;
301 
302  // ----------------------- Other Set services -----------------------------
303  public:
304 
311  template< typename TOutputIterator >
312  void computeComplement(TOutputIterator& ito) const;
313 
321  template< typename TDigitalSet >
322  void assignFromComplement( const TDigitalSet & otherSet );
323 
333 
334 
335  // ----------------------- Interface --------------------------------------
336  public:
337 
342  void selfDisplay ( std::ostream & out ) const;
343 
348  bool isValid() const;
349 
350 
351  public:
352 
353 
354 
355  // --------------- CDrawableWithBoard2D realization ---------------------
356  public:
357 
361  std::string className() const;
362 
363 
364  // ------------------------- Hidden services ------------------------------
365  protected:
366 
372 
373  private:
374 
375 
376  // ------------------------- Internals ------------------------------------
377  private:
378 
379 
380  }; // end of class DigitalSetFromMap
381 
382 
389  template <typename TMapImage>
390  std::ostream&
391  operator<< ( std::ostream & out, const DigitalSetFromMap<TMapImage> & object );
392 
393 } // namespace DGtal
394 
395 
397 // Includes inline functions.
398 #include "DGtal/kernel/sets/DigitalSetFromMap.ih"
399 
400 // //
402 
403 #endif // !defined DigitalSetFromMap_h
404 
405 #undef DigitalSetFromMap_RECURSES
406 #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...
ConstIterator end() const
std::pair< const typename Image::Point, typename Image::Value > Pair
void insertNew(const Point &p)
DigitalSetFromMap & operator=(const DigitalSetFromMap &other)
DigitalSetFromMap(const DigitalSetFromMap &other)
void insert(PointInputIterator first, PointInputIterator last)
void computeComplement(TOutputIterator &ito) const
Size erase(const Point &p)
functors::Pair1st< Point > Functor
std::string className() const
ConstIterator find(const Point &p) const
const Container & container() const
const Domain & domain() const
DigitalSetFromMap< Image > Self
void selfDisplay(std::ostream &out) const
ConstIterator begin() const
void erase(Iterator it)
void assignFromComplement(const TDigitalSet &otherSet)
Iterator find(const Point &p)
void erase(Iterator first, Iterator last)
void computeBoundingBox(Point &lower, Point &upper) const
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > ConstIterator
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > Iterator
void insertNew(PointInputIterator first, PointInputIterator last)
void insert(const Point &p)
bool operator()(const Point &p) const
DigitalSetFromMap(Image &aImage, const typename Image::Value &aDefaultValue=0)
CowPtr< Domain > domainPointer() const
TImageContainer::Point Point
Definition: Image.h:83
TImageContainer::Domain Domain
Definition: Image.h:82
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Vector lower(const Vector &z, unsigned int k)
Vector upper(const Vector &z, unsigned int k)