Loading...
Searching...
No Matches
contour.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: contour.h,v 1.17 2004/04/22 10:08:19 oliver Exp $
//
#ifndef BALL_DATATYPE_CONTOUR_H
#define BALL_DATATYPE_CONTOUR_H
#ifndef BALL_DATATYPE_REGULARDATA2D_H
# include <BALL/DATATYPE/regularData2D.h>
#endif
#ifndef BALL_DATATYPE_CONTOURLINE_H
# include <BALL/DATATYPE/contourLine.h>
#endif
#include <vector>
namespace BALL
{
template <typename T>
class TContour
{
public:
// macro for create method
BALL_CREATE(TContour<T>)
TContour(Size num_lines=0, double start=0, double end=0);
TContour(const TContour& contour);
virtual ~TContour();
bool getNextContourLine(TContourLine<T>& contour);
TContour& operator = (const TContour& rhs);
void apply(TRegularData2D<T>& data);
virtual void clear();
void resetCounter();
bool operator == (const TContour& contour) const;
protected:
std::vector< TContourLine<T> > lines_;
Size num_lines_;
double start_;
double end_;
typename std::vector<TContourLine<T> >::const_iterator it_;
Position index_;
};
typedef TContour<float> Contour;
template <typename T>
TContour<T>::TContour(Size num_lines, double start, double end) : lines_(num_lines), num_lines_(num_lines), start_(start), end_(end), index_(0)
{
}
template <typename T>
TContour<T>::TContour(const TContour& copyTContour) : lines_(copyTContour.lines_), num_lines_(copyTContour.num_lines_), start_(copyTContour.start_), end_(copyTContour.end_), index_(copyTContour.index_)
{
}
template <typename T>
TContour<T>::~TContour()
{
}
template <typename T>
TContour<T>& TContour<T>::operator = (const TContour& rhs)
{
start_ = rhs.start_;
end_ = rhs.end_;
num_lines_ = rhs.num_lines_;
it_ = rhs.it_;
}
template <typename T>
void TContour<T>::clear()
{
start_ = 0;
end_ = 0;
num_lines_ = 0;
lines_ = std::vector< TContourLine<T> >(0);
index_ = 0;
}
template <typename T>
bool TContour<T>::operator == (const TContour& compTContour) const
{
return ((start_ == compTContour.start_) && (end_ == compTContour.end_) && (lines_ == compTContour.lines_)
&& (num_lines_ == compTContour.num_lines_) && (it_ == compTContour.it_) && (index_ == compTContour.index_));
}
template <typename T>
void TContour<T>::apply(TRegularData2D<T>& data)
{
Position i;
double step = (end_ - start_) / num_lines_;
for (i=0; i<num_lines_; i++)
{
TContourLine<T> con(start_ + i*step);
con.createContourLine(data);
lines_[i]=con;
};
if (num_lines_ > 0)
{
it_ = lines_.begin();
index_ = 0;
};
}
template <typename T>
bool TContour<T>::getNextContourLine(TContourLine<T>& cont)
{
if (index_<num_lines_)
{
cont = *it_;
it_++;
index_++;
return (true);
} else {
return false;
};
}
template <typename T>
void TContour<T>::resetCounter()
{
it_ = lines_.begin();
index_ = 0;
}
} // namespace BALL
#endif
BALL::TContourLine
Definition contourLine.h:69
BALL::TContourLine::createContourLine
void createContourLine(TRegularData2D< T > &from)
Creates a contour line from a given data set.
Definition contourLine.h:205
BALL::TContour
Definition contour.h:28
BALL::TContour::operator==
bool operator==(const TContour &contour) const
Equality operator.
Definition contour.h:132
BALL::TContour< float >::num_lines_
Size num_lines_
Definition contour.h:85
BALL::TContour< float >::start_
double start_
Definition contour.h:86
BALL::TContour< float >::getNextContourLine
bool getNextContourLine(TContourLine< float > &contour)
BALL::TContour::operator=
TContour & operator=(const TContour &rhs)
Assignment operator.
Definition contour.h:113
BALL::TContour< float >::apply
void apply(TRegularData2D< float > &data)
BALL::TContour< float >::end_
double end_
Definition contour.h:87
BALL::TContour::TContour
TContour(Size num_lines=0, double start=0, double end=0)
Default constructor.
Definition contour.h:98
BALL::TContour< float >::clear
virtual void clear()
BALL::TContour< float >::index_
Position index_
Definition contour.h:89
BALL::TContour< float >::it_
std::vector< TContourLine< float > >::const_iterator it_
Definition contour.h:88
BALL::TContour< float >::lines_
std::vector< TContourLine< float > > lines_
Definition contour.h:84
BALL::TContour< float >::resetCounter
void resetCounter()
BALL::TContour::~TContour
virtual ~TContour()
Destructor.
Definition contour.h:108
BALL::TRegularData2D
Definition regularData2D.h:38
contourLine.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL::Contour
TContour< float > Contour
Definition contour.h:95
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
std
STL namespace.
regularData2D.h