DGtal  1.3.beta
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 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 
127  DigitalSetFromMap( Image& aImage,
128  const typename Image::Value& aDefaultValue = 0);
129 
134  DigitalSetFromMap ( const DigitalSetFromMap & other );
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 
256  ConstIterator begin() const;
257 
261  ConstIterator end() const;
262 
266  Iterator begin();
267 
271  Iterator end();
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 
332  void computeBoundingBox( Point & lower, Point & upper ) const;
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)
DGtal::functors::Pair1st< Point >
DGtal::DigitalSetFromMap::erase
Size erase(const Point &p)
DGtal::DigitalSetFromMap::className
std::string className() const
DGtal::ImageContainerBySTLVector< Domain, Value >::Domain
Domain Domain
Definition: ImageContainerBySTLVector.h:137
DGtal::ImageContainerBySTLVector::Value
TValue Value
Definition: ImageContainerBySTLVector.h:153
DGtal::DigitalSetFromMap::Iterator
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > Iterator
Definition: DigitalSetFromMap.h:91
lower
Vector lower(const Vector &z, unsigned int k)
Definition: viewDualSurface.cpp:190
DGtal::DigitalSetFromMap::myImgPtr
Image * myImgPtr
Definition: DigitalSetFromMap.h:99
DGtal::DigitalSetFromMap::empty
bool empty() const
DGtal::DigitalSetFromMap::insert
void insert(const Point &p)
DGtal::DigitalSetFromMap::Container
Image Container
Definition: DigitalSetFromMap.h:79
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::DigitalSetFromMap::Point
Domain::Point Point
Definition: DigitalSetFromMap.h:86
DGtal::HyperRectDomain< Space >::Size
Space::Size Size
Definition: HyperRectDomain.h:117
DGtal::DigitalSetFromMap::find
ConstIterator find(const Point &p) const
DGtal::DigitalSetFromMap::myFun
Functor myFun
Definition: DigitalSetFromMap.h:104
DGtal::DigitalSetFromMap::~DigitalSetFromMap
~DigitalSetFromMap()
DGtal::DigitalSetFromMap::isValid
bool isValid() const
DGtal::DigitalSetFromMap::Pair
std::pair< const typename Image::Point, typename Image::Value > Pair
Definition: DigitalSetFromMap.h:81
DGtal::DigitalSetFromMap::size
Size size() const
DGtal::DigitalSetFromMap::computeBoundingBox
void computeBoundingBox(Point &lower, Point &upper) const
DGtal::DigitalSetFromMap::Domain
Image::Domain Domain
Definition: DigitalSetFromMap.h:85
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::DigitalSetFromMap::operator()
bool operator()(const Point &p) const
DGtal::DigitalSetFromMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::DigitalSetFromMap::insertNew
void insertNew(const Point &p)
DGtal::DigitalSetFromMap
Aim: An adapter for viewing an associative image container like ImageContainerBySTLMap as a simple di...
Definition: DigitalSetFromMap.h:74
DGtal::DigitalSetFromMap::domain
const Domain & domain() const
DGtal::DigitalSetFromMap::clear
void clear()
DGtal::DigitalSetFromMap::operator=
DigitalSetFromMap & operator=(const DigitalSetFromMap &other)
DGtal::DigitalSetFromMap::Image
TMapImage Image
Definition: DigitalSetFromMap.h:78
DGtal::DigitalSetFromMap::ConstIterator
ConstIteratorAdapter< typename Image::ConstIterator, Functor, Point > ConstIterator
Definition: DigitalSetFromMap.h:90
DGtal::DigitalSetFromMap::Self
DigitalSetFromMap< Image > Self
Definition: DigitalSetFromMap.h:82
upper
Vector upper(const Vector &z, unsigned int k)
Definition: viewDualSurface.cpp:197
DGtal::DigitalSetFromMap::container
Container & container()
Definition: DigitalSetFromMap.h:282
DGtal::PointVector< dim, Integer >
DGtal::DigitalSetFromMap::container
const Container & container() const
Definition: DigitalSetFromMap.h:277
DGtal::DigitalSetFromMap::myDefault
Image::Value myDefault
Definition: DigitalSetFromMap.h:109
DGtal::DigitalSetFromMap::domainPointer
CowPtr< Domain > domainPointer() const
DGtal::DigitalSetFromMap::DigitalSetFromMap
DigitalSetFromMap()
DGtal::DigitalSetFromMap::Size
Domain::Size Size
Definition: DigitalSetFromMap.h:87
DGtal::DigitalSetFromMap::assignFromComplement
void assignFromComplement(const TDigitalSet &otherSet)
DGtal::DigitalSetFromMap::Functor
functors::Pair1st< Point > Functor
Definition: DigitalSetFromMap.h:89
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::Image::Point
TImageContainer::Point Point
Definition: Image.h:83
DGtal::DigitalSetFromMap::begin
ConstIterator begin() const
DGtal::DigitalSetFromMap::computeComplement
void computeComplement(TOutputIterator &ito) const
DGtal::ConstIteratorAdapter
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Definition: ConstIteratorAdapter.h:85
DGtal::DigitalSetFromMap::end
ConstIterator end() const
DGtal::CowPtr< Domain >