DGtal  0.9.2
DECExamplesCommon.h
1 #if !defined(__DEC_EXAMPLE_COMMON_H__)
2 #define __DEC_EXAMPLE_COMMON_H__
3 
4 #include "DGtal/base/Common.h"
5 #include "DGtal/helpers/StdDefs.h"
6 
7 inline DGtal::Z2i::DigitalSet generateDiskSet(const DGtal::Z2i::Domain& domain)
8 {
9  DGtal::Z2i::DigitalSet set(domain);
10  DGtal::Z2i::RealPoint center = domain.lowerBound() + domain.upperBound();
11  center /= 2.;
12  DGtal::Z2i::RealPoint delta = domain.upperBound() - domain.lowerBound();
13  double radius = delta[0]>delta[1] ? delta[1] : delta[0];
14  radius += 1.;
15  radius /= 2.;
16 
17  for (DGtal::Z2i::Domain::ConstIterator di=domain.begin(), die=domain.end(); di!=die; di++)
18  {
19  const DGtal::Z2i::Point point = *di;
20  const DGtal::Z2i::RealPoint point_real = DGtal::Z2i::RealPoint(point) - center;
21  if (point_real.norm() > 5.*radius/6.) continue;
22  set.insert(point);
23  }
24 
25  return set;
26 }
27 
28 inline DGtal::Z2i::DigitalSet generateRingSet(const DGtal::Z2i::Domain& domain)
29 {
30  DGtal::Z2i::DigitalSet set(domain);
31  DGtal::Z2i::RealPoint center = domain.lowerBound() + domain.upperBound();
32  center /= 2.;
33  DGtal::Z2i::RealPoint delta = domain.upperBound() - domain.lowerBound();
34  double radius = delta[0]>delta[1] ? delta[1] : delta[0];
35  radius += 1.;
36  radius /= 2.;
37 
38  for (DGtal::Z2i::Domain::ConstIterator di=domain.begin(), die=domain.end(); di!=die; di++)
39  {
40  const DGtal::Z2i::Point point = *di;
41  const DGtal::Z2i::RealPoint point_real = DGtal::Z2i::RealPoint(point) - center;
42  if (point_real.norm() < 1.*radius/6.) continue;
43  if (point_real.norm() > 5.*radius/6.) continue;
44  set.insert(point);
45  }
46 
47  return set;
48 }
49 
50 inline DGtal::Z2i::DigitalSet generateDoubleRingSet(const DGtal::Z2i::Domain& domain)
51 {
52  DGtal::Z2i::DigitalSet set(domain);
53  DGtal::Z2i::RealPoint center = domain.lowerBound() + domain.upperBound();
54  center /= 2.;
55  DGtal::Z2i::RealPoint delta = domain.upperBound() - domain.lowerBound();
56  double radius = delta[0]>delta[1] ? delta[1] : delta[0];
57  radius += 1.;
58  radius /= 2.;
59 
60  center -= DGtal::Z2i::RealPoint(radius/2.+radius/5.,0);
61  for (DGtal::Z2i::Domain::ConstIterator di=domain.begin(), die=domain.end(); di!=die; di++)
62  {
63  const DGtal::Z2i::Point point = *di;
64  const DGtal::Z2i::RealPoint point_real = DGtal::Z2i::RealPoint(point) - center;
65  if (point_real.norm() < 1.*radius/6.) continue;
66  if (point_real.norm() > 4.5*radius/6.) continue;
67  set.insert(point);
68  }
69 
70  center += DGtal::Z2i::RealPoint(2*(radius/2.+radius/5.),0);
71  for (DGtal::Z2i::Domain::ConstIterator di=domain.begin(), die=domain.end(); di!=die; di++)
72  {
73  const DGtal::Z2i::Point point = *di;
74  const DGtal::Z2i::RealPoint point_real = DGtal::Z2i::RealPoint(point) - center;
75  if (point_real.norm() < 1.*radius/6.) continue;
76  if (point_real.norm() > 4.5*radius/6.) continue;
77  set.insert(point);
78  }
79 
80  return set;
81 }
82 
83 #endif
84 
const ConstIterator & begin() const
const ConstIterator & end() const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
const Point & upperBound() const
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
double norm(const NormType type=L_2) const
Space::RealPoint RealPoint
Definition: StdDefs.h:97
const Point & lowerBound() const