DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
48 #include "DGtal/base/BasicFunctors.h"
49 #include "DGtal/base/IteratorAdapter.h"
50 #include "DGtal/base/ConstIteratorAdapter.h"
51 
53 
54 
55 namespace DGtal
56 {
57 
59  // template class DigitalSetFromMap
72  template <typename TMapImage>
74  {
75  public:
76 
77  typedef TMapImage Image;
78  typedef std::pair<const typename Image::Point,
79  typename Image::Value> Pair;
81 
82  // -------------------------- required types ------------------------------
83  typedef typename Image::Domain Domain;
84  typedef typename Domain::Point Point;
85  typedef typename Domain::Size Size;
86 
90 
91  // ------------------------- Protected Datas ------------------------------
92  protected:
93 
98 
103 
108 
109  // ----------------------- Standard services ------------------------------
110  public:
111 
116 
125  DigitalSetFromMap( Image& aImage,
126  const typename Image::Value& aDefaultValue = 0);
127 
132  DigitalSetFromMap ( const DigitalSetFromMap & other );
133 
140 
141 
142  // ----------------------- Standard Set services --------------------------
143  public:
144 
148  const Domain & domain() const;
149 
153  Size size() const;
154 
158  bool empty() const;
159 
166  void insert( const Point & p );
167 
176  template <typename PointInputIterator>
177  void insert( PointInputIterator first, PointInputIterator last );
178 
188  void insertNew( const Point & p );
189 
200  template <typename PointInputIterator>
201  void insertNew( PointInputIterator first, PointInputIterator last );
202 
209  Size erase( const Point & p );
210 
217  void erase( Iterator it );
218 
226  void erase( Iterator first, Iterator last );
227 
232  void clear();
233 
238  ConstIterator find( const Point & p ) const;
239 
244  Iterator find( const Point & p );
245 
249  ConstIterator begin() const;
250 
254  ConstIterator end() const;
255 
259  Iterator begin();
260 
264  Iterator end();
265 
271  template< typename TDigitalSet >
272  Self & operator+=
273  ( const TDigitalSet & aSet );
274 
275  // ----------------------- Other Set services -----------------------------
276  public:
277 
284  template< typename TOutputIterator >
285  void computeComplement(TOutputIterator& ito) const;
286 
294  template< typename TDigitalSet >
295  void assignFromComplement( const TDigitalSet & otherSet );
296 
305  void computeBoundingBox( Point & lower, Point & upper ) const;
306 
307 
308  // ----------------------- Interface --------------------------------------
309  public:
310 
315  void selfDisplay ( std::ostream & out ) const;
316 
321  bool isValid() const;
322 
323 
324  public:
325 
326 
327 
328  // --------------- CDrawableWithBoard2D realization ---------------------
329  public:
330 
334  std::string className() const;
335 
336 
337  // ------------------------- Hidden services ------------------------------
338  protected:
339 
345 
346  private:
347 
348 
349  // ------------------------- Internals ------------------------------------
350  private:
351 
352 
353  }; // end of class DigitalSetFromMap
354 
355 
362  template <typename TMapImage>
363  std::ostream&
364  operator<< ( std::ostream & out, const DigitalSetFromMap<TMapImage> & object );
365 
366 } // namespace DGtal
367 
368 
370 // Includes inline functions.
371 #include "DGtal/kernel/sets/DigitalSetFromMap.ih"
372 
373 // //
375 
376 #endif // !defined DigitalSetFromMap_h
377 
378 #undef DigitalSetFromMap_RECURSES
379 #endif // else defined(DigitalSetFromMap_RECURSES)