DGtal  1.1.0
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 {
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];
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 {
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];
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 {
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];
59
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
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
DGtal::HyperRectDomain< Space >
DGtal::Z2i::RealPoint
Space::RealPoint RealPoint
Definition: StdDefs.h:97
DGtal::PointVector::norm
double norm(const NormType type=L_2) const
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:154
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal::DigitalSetByAssociativeContainer
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Definition: DigitalSetByAssociativeContainer.h:90