-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket.h
More file actions
78 lines (62 loc) · 1.9 KB
/
bucket.h
File metadata and controls
78 lines (62 loc) · 1.9 KB
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
71
72
73
74
75
76
77
78
#ifndef SPH_PHYSICS_BUCKET_H
#define SPH_PHYSICS_BUCKET_H
#include <list>
#include <vector>
#include "particle.h"
namespace Physics {
class Bucket;
typedef std::vector<Bucket> BucketVec1;
typedef std::vector<BucketVec1> BucketVec2;
typedef std::vector<BucketVec2> BucketVec3;
typedef std::list<Particle *> ParticleVec;
typedef std::list<Particle *>::iterator ParticleIter;
typedef std::list<Bucket *> BucketVec;
typedef std::list<Bucket *>::iterator BucketIter;
class Bucket
{
public:
ParticleVec particles;
BucketVec neighbours;
public:
void add_particle(Particle *particle);
void remove_particle(Particle *particle);
void add_neighbour(Bucket *other);
class neighbour_iterator: public std::iterator<std::input_iterator_tag, Particle *>
{
BucketIter bucket_iter;
BucketIter bucket_end;
ParticleIter particle_iter;
ParticleIter particle_end;
bool valid;
public:
neighbour_iterator() = delete;
neighbour_iterator(Bucket *bucket);
neighbour_iterator(Bucket *bucket, bool isend);
neighbour_iterator(neighbour_iterator const &other);
neighbour_iterator &operator++();
neighbour_iterator const operator++(int);
bool operator==(neighbour_iterator const &other) const;
bool operator!=(neighbour_iterator const &other) const;
Particle *operator*();
Particle **operator->();
// Method to increase performance. The iterator evaluates as false
// when the end is reached.
operator bool() const {return valid;}
};
neighbour_iterator begin();
neighbour_iterator end();
};
class Buckets
{
BucketVec3 buckets;
size_t x_size;
size_t y_size;
size_t z_size;
public:
Buckets(size_t x, size_t y, size_t z);
Bucket *get_bucket(float pos[3]);
private:
void add_neighbours(Bucket &bucket, size_t i, size_t j, size_t k);
};
}
#endif