~sophie-middleton08/maus/devel

« back to all changes in this revision

Viewing changes to src/legacy/Interface/Meshing/Mesh-inl.hh

  • Committer: Chris Rogers
  • Date: 2012-10-03 07:19:33 UTC
  • mfrom: (659.1.40 release-candidate)
  • Revision ID: chris.rogers@stfc.ac.uk-20121003071933-kgrhvl1ec6w2jmug
Tags: MAUS-v0.3, MAUS-v0.3.3
MAUS-v0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://  www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include <vector>
 
18
 
 
19
Mesh::Mesh() {
 
20
}
 
21
 
 
22
Mesh::~Mesh() {
 
23
}
 
24
 
 
25
Mesh::Iterator::Iterator() {
 
26
}
 
27
 
 
28
Mesh::Iterator::Iterator(const Mesh::Iterator& in)
 
29
    : _mesh(in._mesh), _state(in._state)   {
 
30
}
 
31
 
 
32
Mesh::Iterator::Iterator(std::vector<int> state, const Mesh* mesh)
 
33
    : _mesh(mesh), _state(state) {
 
34
}
 
35
 
 
36
Mesh::Iterator::~Iterator() {
 
37
}
 
38
 
 
39
int Mesh::Iterator::ToInteger() const {
 
40
    return _mesh->ToInteger(*this);
 
41
}
 
42
 
 
43
std::vector<int> Mesh::Iterator::State() const {
 
44
    return _state;
 
45
}
 
46
 
 
47
int& Mesh::Iterator::operator[](int i) {
 
48
    return _state[i];
 
49
}
 
50
 
 
51
const int& Mesh::Iterator::operator[](int i) const {
 
52
    return _state[i];
 
53
}
 
54
 
 
55
const Mesh* Mesh::Iterator::GetMesh() const {
 
56
    return _mesh;
 
57
}
 
58
 
 
59
const Mesh::Iterator&  Mesh::Iterator::operator= (const Mesh::Iterator& rhs) {
 
60
    _mesh  = rhs._mesh;
 
61
    _state = rhs._state;
 
62
    return *this;
 
63
}
 
64
 
 
65
void Mesh::Iterator::Position(double* point) const {
 
66
    _mesh->Position(*this, point);
 
67
}
 
68
 
 
69
std::vector<double> Mesh::Iterator::Position() const {
 
70
    std::vector<double> PointV(_mesh->PositionDimension());
 
71
    _mesh->Position(*this, &PointV[0]);
 
72
    return PointV;
 
73
}
 
74
 
 
75
Mesh::Iterator& operator++(Mesh::Iterator& lhs) {
 
76
    return lhs._mesh->AddOne(lhs);
 
77
}
 
78
 
 
79
Mesh::Iterator& operator--(Mesh::Iterator& lhs) {
 
80
    return lhs._mesh->SubOne(lhs);
 
81
}
 
82
 
 
83
Mesh::Iterator  operator++(Mesh::Iterator& lhs, int) {
 
84
    Mesh::Iterator copy = lhs;
 
85
    lhs._mesh->AddOne(lhs);
 
86
    return copy;
 
87
}
 
88
 
 
89
Mesh::Iterator  operator--(Mesh::Iterator& lhs, int) {
 
90
    Mesh::Iterator copy = lhs;
 
91
    lhs._mesh->SubOne(lhs);
 
92
    return copy;
 
93
}
 
94
 
 
95
Mesh::Iterator  operator-
 
96
                        (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
97
    Mesh::Iterator lhsCopy(lhs);
 
98
    Mesh::Iterator lhsNew(lhs._mesh->SubEquals(lhsCopy, rhs));
 
99
    return lhsNew;
 
100
}
 
101
 
 
102
Mesh::Iterator  operator- (const Mesh::Iterator& lhs, const int& difference) {
 
103
    Mesh::Iterator lhsCopy(lhs);
 
104
    Mesh::Iterator lhsNew(lhs._mesh->SubEquals(lhsCopy, difference));
 
105
    return lhsNew;
 
106
}
 
107
 
 
108
Mesh::Iterator  operator+
 
109
                      (const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
110
    Mesh::Iterator lhsCopy(lhs);
 
111
    Mesh::Iterator lhsNew(lhs._mesh->AddEquals(lhsCopy, rhs));
 
112
    return lhsNew;
 
113
}
 
114
 
 
115
Mesh::Iterator  operator+ (const Mesh::Iterator& lhs, const int& difference) {
 
116
    Mesh::Iterator lhsCopy(lhs);
 
117
    Mesh::Iterator lhsNew(lhs._mesh->AddEquals(lhsCopy, difference));
 
118
    return lhsNew;
 
119
}
 
120
 
 
121
 
 
122
Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
123
    return lhs._mesh->AddEquals(lhs, rhs);
 
124
}
 
125
 
 
126
Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
127
    return lhs._mesh->SubEquals(lhs, rhs);
 
128
}
 
129
 
 
130
Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs) {
 
131
    return lhs._mesh->AddEquals(lhs, rhs);
 
132
}
 
133
 
 
134
Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs) {
 
135
    return lhs._mesh->SubEquals(lhs, rhs);
 
136
}
 
137
 
 
138
 
 
139
bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
140
    if (lhs._mesh->IsGreater(lhs, rhs) || lhs == rhs) return true;
 
141
    return false;
 
142
}
 
143
 
 
144
bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
145
    if (lhs._mesh->IsGreater(lhs, rhs)) return false;
 
146
    return true;
 
147
}
 
148
 
 
149
bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
150
    return !(lhs <= rhs);
 
151
}
 
152
 
 
153
bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
154
    return !(lhs >= rhs);
 
155
}
 
156
 
 
157
bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
158
    if (lhs._state == rhs._state)
 
159
        return true;
 
160
    return false;
 
161
}
 
162
 
 
163
bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
 
164
    if (lhs._mesh == rhs._mesh && lhs._state == rhs._state)
 
165
        return false;
 
166
    return true;
 
167
}