-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobservable.hpp
51 lines (39 loc) · 1.12 KB
/
observable.hpp
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
// Copyright 2020 Joren Brunekreef and Andrzej Görlich
#pragma once
#include <string>
#include <vector>
#include "universe.hpp"
class Observable {
public:
std::string name;
Observable(std::string identifier_) {
identifier = identifier_;
}
void measure() {
process();
write();
}
void clear();
private:
std::string identifier;
protected:
static std::default_random_engine rng;
virtual void process() = 0;
void write();
// toolbox
static std::vector<Vertex::Label> sphere(Vertex::Label origin, int radius);
static std::vector<Triangle::Label> sphereDual(Triangle::Label origin, int radius);
static int distance(Vertex::Label v1, Vertex::Label v2);
static int distanceDual(Triangle::Label t1, Triangle::Label t2);
static Vertex::Label randomVertex() {
std::uniform_int_distribution<> rv(0, Universe::vertices.size()-1);
return Universe::vertices.at(rv(rng));
}
static Triangle::Label randomTriangle() {
std::uniform_int_distribution<> rt(0, Universe::triangles.size()-1);
return Universe::triangles.at(rt(rng));
}
std::string data_dir = "out/";
std::string extension = ".dat";
std::string output;
};