1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#ifndef COMPONENT_H
#define COMPONENT_H
#include <vector>
namespace Component
{
class TriStrip
{
public:
static TriStrip Create(const unsigned int& w_, const unsigned int& h_, const unsigned int& scale_);
int GetY(const unsigned int& x_, const unsigned int& z_) const;
void operator=(const TriStrip& another_);
~TriStrip();
private:
unsigned int Scale_;
unsigned int W_;
unsigned int H_;
int** Y_Array;
TriStrip(const unsigned int& w_, const unsigned int& h_, const unsigned int& scale_);
};
class TriStripData
{
public:
const TriStrip& GetAt(const unsigned int index_)const;
void Append(const TriStrip& append_);
void Erase(const unsigned int index_);
private:
std::vector<TriStrip> Data_;
};
inline TriStrip TriStrip::Create(const unsigned int& w_, const unsigned int& h_, const unsigned int& scale_){
return TriStrip(w_, h_, scale_); }
inline TriStrip::TriStrip(const unsigned int& w_, const unsigned int& h_, const unsigned int& scale_):W_(w_),H_(h_),Scale_(scale_){
Y_Array = new int*[w_];
for (unsigned int i = 0; i < w_; ++i){
Y_Array[i] = new int[h_];
}
for (unsigned int i = 0; i < w_; ++i){
for (unsigned int j = 0; j < h_; ++j){
Y_Array[i][j] = 0;
}
}
}
inline int TriStrip::GetY(const unsigned int& x_, const unsigned int& z_)const{
return Y_Array[x_][z_];
}
inline void TriStrip::operator=(const TriStrip& another_){
W_ = another_.W_;
H_ = another_.H_;
Scale_ = another_.Scale_;
delete []Y_Array;
Y_Array = another_.Y_Array;
}
inline TriStrip::~TriStrip()
{
delete []Y_Array;
}
inline const TriStrip& TriStripData::GetAt(const unsigned int index_)const{
return Data_[index_];
}
inline void TriStripData::Append(const TriStrip& append_){
Data_.push_back(append_);
}
inline void TriStripData::Erase(const unsigned int index_){
Data_.erase(Data_.begin()+index_);
}
}
#endif
|