DGtal  0.9.2
DigitalSetBySTLSet.h
1 
17 #pragma once
18 
35 #if defined(DigitalSetBySTLSet_RECURSES)
36 #error Recursive header files inclusion detected in DigitalSetBySTLSet.h
37 #else // defined(DigitalSetBySTLSet_RECURSES)
38 
39 #define DigitalSetBySTLSet_RECURSES
40 
41 #if !defined DigitalSetBySTLSet_h
42 
43 #define DigitalSetBySTLSet_h
44 
46 // Inclusions
47 #include <iostream>
48 #include <set>
49 #include <string>
50 #include "DGtal/base/Common.h"
51 #include "DGtal/base/CowPtr.h"
52 #include "DGtal/base/Clone.h"
53 #include "DGtal/base/Alias.h"
54 #include "DGtal/base/ConstAlias.h"
55 #include "DGtal/kernel/domains/CDomain.h"
57 
58 //#include "DGtal/io/Display3D.h"
59 
60 
61 namespace DGtal
62 {
63 
65  // template class DigitalSetBySTLSet
83  template <typename TDomain, typename TCompare = std::less<typename TDomain::Point> >
85  {
86  public:
87  typedef TDomain Domain;
88  typedef TCompare Compare;
90  typedef typename Domain::Space Space;
91  typedef typename Domain::Point Point;
92  typedef typename Domain::Size Size;
93  typedef typename std::set<Point>::iterator Iterator;
94  typedef typename std::set<Point>::const_iterator ConstIterator;
95 
98 
99  // ----------------------- Standard services ------------------------------
100  public:
101 
106 
114  DigitalSetBySTLSet( Clone<Domain> d, const Compare & c = Compare() );
115 
120  DigitalSetBySTLSet ( const DigitalSetBySTLSet & other );
121 
128 
132  const Domain & domain() const;
133 
138 
139  // ----------------------- Standard Set services --------------------------
140  public:
141 
145  Size size() const;
146 
150  bool empty() const;
151 
158  void insert( const Point & p );
159 
168  template <typename PointInputIterator>
169  void insert( PointInputIterator first, PointInputIterator last );
170 
180  void insertNew( const Point & p );
181 
192  template <typename PointInputIterator>
193  void insertNew( PointInputIterator first, PointInputIterator last );
194 
201  Size erase( const Point & p );
202 
209  void erase( Iterator it );
210 
218  void erase( Iterator first, Iterator last );
219 
224  void clear();
225 
229  ConstIterator find( const Point & p ) const;
230 
235  Iterator find( const Point & p );
236 
240  ConstIterator begin() const;
241 
245  ConstIterator end() const;
246 
250  Iterator begin();
251 
255  Iterator end();
256 
262  ( const DigitalSetBySTLSet<Domain, Compare> & aSet );
263 
264  // ----------------------- Model of concepts::CPointPredicate -----------------------------
265  public:
266 
271  bool operator()( const Point & p ) const;
272 
273  // ----------------------- Other Set services -----------------------------
274  public:
275 
281  template< typename TOutputIterator >
282  void computeComplement(TOutputIterator& ito) const;
283 
291 
300  void computeBoundingBox( Point & lower, Point & upper ) const;
301 
302 
303  // ----------------------- Interface --------------------------------------
304  public:
305 
310  void selfDisplay ( std::ostream & out ) const;
311 
316  bool isValid() const;
317 
318  // ------------------------- Protected Datas ------------------------------
319  protected:
320 
326 
330  std::set<Point, Compare> mySet;
331 
332 
333  public:
334 
335 
336 
337  // --------------- CDrawableWithBoard2D realization ---------------------
338  public:
339 
343  std::string className() const;
344 
345 
346  // ------------------------- Hidden services ------------------------------
347  protected:
348 
354 
355  private:
356 
357 
358  // ------------------------- Internals ------------------------------------
359  private:
360 
361 
362  }; // end of class DigitalSetBySTLSet
363 
364 
371  template <typename Domain, typename Compare>
372  std::ostream&
373  operator<< ( std::ostream & out, const DigitalSetBySTLSet<Domain, Compare> & object );
374 
375 } // namespace DGtal
376 
377 
379 // Includes inline functions.
380 #include "DGtal/kernel/sets/DigitalSetBySTLSet.ih"
381 
382 // //
384 
385 #endif // !defined DigitalSetBySTLSet_h
386 
387 #undef DigitalSetBySTLSet_RECURSES
388 #endif // else defined(DigitalSetBySTLSet_RECURSES)
std::set< Point >::const_iterator ConstIterator
void insertNew(const Point &p)
const Domain & domain() const
Size erase(const Point &p)
DigitalSetBySTLSet & operator=(const DigitalSetBySTLSet &other)
void selfDisplay(std::ostream &out) const
DigitalSetBySTLSet< Domain, Compare > Self
void computeBoundingBox(Point &lower, Point &upper) const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
bool operator()(const Point &p) const
std::string className() const
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
Definition: CDomain.h:129
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Definition: Clone.h:266
std::set< Point, Compare > mySet
BOOST_CONCEPT_ASSERT((concepts::CDomain< TDomain >))
Concept checks.
CowPtr< Domain > domainPointer() const
void computeComplement(TOutputIterator &ito) const
ConstIterator end() const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::set< Point >::iterator Iterator
void assignFromComplement(const DigitalSetBySTLSet< Domain, Compare > &other_set)
ConstIterator begin() const
ConstIterator find(const Point &p) const
void insert(const Point &p)
Aim: A container class for storing sets of digital points within some given domain.