BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
contour.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: contour.h,v 1.17 2004/04/22 10:08:19 oliver Exp $
5 //
6 
7 #ifndef BALL_DATATYPE_CONTOUR_H
8 #define BALL_DATATYPE_CONTOUR_H
9 
10 #ifndef BALL_DATATYPE_REGULARDATA2D_H
12 #endif
13 
14 #ifndef BALL_DATATYPE_CONTOURLINE_H
16 #endif
17 
18 #include <vector>
19 
20 
21 namespace BALL
22 {
26  template <typename T>
27  class TContour
28  {
29  public:
30 
31  // macro for create method
33 
34 
37  TContour(Size num_lines=0, double start=0, double end=0);
39 
41  TContour(const TContour& contour);
42 
44  virtual ~TContour();
45 
47 
50 
52  bool getNextContourLine(TContourLine<T>& contour);
53 
55 
58 
60  TContour& operator = (const TContour& rhs);
61 
64  void apply(TRegularData2D<T>& data);
65 
67  virtual void clear();
68 
70  void resetCounter();
71 
73 
76 
78  bool operator == (const TContour& contour) const;
79 
81 
82  protected:
83 
84  std::vector< TContourLine<T> > lines_;
86  double start_;
87  double end_;
88  typename std::vector<TContourLine<T> >::const_iterator it_;
90  };
91 
96 
97  template <typename T>
98  TContour<T>::TContour(Size num_lines, double start, double end) : lines_(num_lines), num_lines_(num_lines), start_(start), end_(end), index_(0)
99  {
100  }
101 
102  template <typename T>
103  TContour<T>::TContour(const TContour& copyTContour) : lines_(copyTContour.lines_), num_lines_(copyTContour.num_lines_), start_(copyTContour.start_), end_(copyTContour.end_), index_(copyTContour.index_)
104  {
105  }
106 
107  template <typename T>
109  {
110  }
111 
112  template <typename T>
114  {
115  start_ = rhs.start_;
116  end_ = rhs.end_;
117  num_lines_ = rhs.num_lines_;
118  it_ = rhs.it_;
119  }
120 
121  template <typename T>
123  {
124  start_ = 0;
125  end_ = 0;
126  num_lines_ = 0;
127  lines_ = std::vector< TContourLine<T> >(0);
128  index_ = 0;
129  }
130 
131  template <typename T>
132  bool TContour<T>::operator == (const TContour& compTContour) const
133  {
134  return ((start_ == compTContour.start_) && (end_ == compTContour.end_) && (lines_ == compTContour.lines_)
135  && (num_lines_ == compTContour.num_lines_) && (it_ == compTContour.it_) && (index_ == compTContour.index_));
136  }
137 
138  template <typename T>
140  {
141  Position i;
142  double step = (end_ - start_) / num_lines_;
143 
144  for (i=0; i<num_lines_; i++)
145  {
146  TContourLine<T> con(start_ + i*step);
147  con.createContourLine(data);
148  lines_[i]=con;
149  };
150 
151  if (num_lines_ > 0)
152  {
153  it_ = lines_.begin();
154  index_ = 0;
155  };
156  }
157 
158  template <typename T>
160  {
161  if (index_<num_lines_)
162  {
163  cont = *it_;
164  it_++;
165  index_++;
166  return (true);
167  } else {
168  return false;
169  };
170  }
171 
172  template <typename T>
174  {
175  it_ = lines_.begin();
176  index_ = 0;
177  }
178 
179 } // namespace BALL
180 
181 #endif
Position index_
Definition: contour.h:89
#define BALL_CREATE(name)
Definition: create.h:62
TContour & operator=(const TContour &rhs)
Assignment operator.
Definition: contour.h:113
void apply(TRegularData2D< T > &data)
Definition: contour.h:139
TContour< float > Contour
Definition: contour.h:95
double start_
Definition: contour.h:86
Size num_lines_
Definition: contour.h:85
bool operator==(const TContour &contour) const
Equality operator.
Definition: contour.h:132
std::vector< TContourLine< T > >::const_iterator it_
Definition: contour.h:88
TContour(Size num_lines=0, double start=0, double end=0)
Default constructor.
Definition: contour.h:98
virtual void clear()
Clear method.
Definition: contour.h:122
virtual ~TContour()
Destructor.
Definition: contour.h:108
std::vector< TContourLine< T > > lines_
Definition: contour.h:84
void resetCounter()
Reset the ContourLine-counter.
Definition: contour.h:173
double end_
Definition: contour.h:87
void createContourLine(TRegularData2D< T > &from)
Creates a contour line from a given data set.
Definition: contourLine.h:205
bool getNextContourLine(TContourLine< T > &contour)
Gives access to the next ContourLine. Returns false if we had already returned the last line...
Definition: contour.h:159