-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvaluator.h
170 lines (138 loc) · 5.36 KB
/
Evaluator.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef _EVALUATOR_H_
#define _EVALUATOR_H_
#include "PixelManager.h"
#include "Computation.h"
#include <complex>
using real2 = HRReal;
enum class FractalTypeEnum {
Mandelbrot,
Tricorn,
BurningShip,
Nova,
Custom,
};
struct ReferenceTrivialContent {
HRReal AbsolutePrecision;
HRReal RelativePrecision;
HRReal ValidRadius;
};
struct Reference : ReferenceTrivialContent {
Coordinate CenterCoordinate;
virtual ~Reference();
};
class Evaluator {
public:
class Feature {
public:
virtual ~Feature();
virtual std::wstring_view Name();
virtual std::wstring_view Information();
virtual IntIter ItLimForZoomLevel(HRReal HalfH);
virtual void GetCoordinate(HRReal &X, HRReal &Y) = 0;
virtual bool GetRadius(HRReal &targetRadius);
virtual bool CanLocatePrecisely();
};
class FeatureFinder {
public:
class PreciseLocatingTask : public virtual Task {
public:
Coordinate coordinate;
virtual std::string_view GetDetailedProgress();
};
virtual ~FeatureFinder();
virtual Feature *FindFeature(HRReal x, HRReal y, HRReal radius, Reference *reference) = 0;
virtual PreciseLocatingTask *CreatePreciseLocatingTask(Feature *feature, size_t Precision, const Coordinate ¢erCoordinate);
virtual bool LocatePrecisely(Feature *feature, size_t Precision, Coordinate &featureCoordinate, const Coordinate ¢erCoordinate);
};
class ReferenceTask : public virtual Task {
public:
Reference *reference;
};
virtual ~Evaluator();
virtual ReferenceTask *CreateReferenceTask(const EvaluationParameters ¶meters) = 0;
virtual void FreeReference(Reference *reference);
virtual Task *CreateEvaluationTask(const EvaluationParameters ¶meters, PixelManager *pixelManager, Reference *reference) = 0;
virtual FeatureFinder *GetFeatureFinder();
virtual size_t SaveReference(std::ostream &stream, const Reference *reference);
virtual size_t LoadReference(std::istream &stream, Reference *&reference);
};
class SimpleEvaluator : public Evaluator {
protected:
class StandardReferenceTask : public ReferenceTask {
SimpleEvaluator *evaluator;
EvaluationParameters parameters;
public:
StandardReferenceTask(SimpleEvaluator *evaluator, const EvaluationParameters ¶meters) : evaluator(evaluator), parameters(parameters) {}
virtual std::string_view GetDescription() const override;
virtual void Execute() override;
};
class StandardEvaluationTask : public ParallelTask, public ProgressTrackable {
SimpleEvaluator *evaluator;
EvaluationParameters parameters;
PixelManager *rasterizer;
Reference *reference;
public:
StandardEvaluationTask(SimpleEvaluator *evaluator, const EvaluationParameters ¶meters, PixelManager *rasterizer, Reference *reference) : evaluator(evaluator), parameters(parameters), rasterizer(rasterizer), reference(reference) {}
virtual std::string_view GetDescription() const override;
virtual void Execute() override;
virtual bool GetProgress(SRReal &Numerator, SRReal &Denoninator) const override;
};
virtual Reference *GenerateReference(const EvaluationParameters ¶meters);
virtual void Evaluate(const EvaluationParameters ¶meters, PixelManager &rasterizer, Reference *Reference) = 0;
public:
virtual ReferenceTask *CreateReferenceTask(const EvaluationParameters ¶meters);
virtual Task *CreateEvaluationTask(const EvaluationParameters ¶meters, PixelManager *pixelManager, Reference *reference);
};
template<FractalTypeEnum FractalType>
class PerturbationEvaluator : public SimpleEvaluator {
static constexpr size_t VSize = VectorSize;
static constexpr size_t CommitSize = 256 * 1024;
size_t ReserveSize;
struct _PTReference : Reference {
const std::type_info &Type;
size_t RefIt;
size_t MaxIt;
_PTReference(const std::type_info &type) : Type(type) {}
};
template <typename real2, FractalTypeEnum>
struct PTReference : _PTReference {
ReservedMemoryArray<real2> Refr, Refi;
PTReference(size_t ReserveSize) : _PTReference(typeid(real2)), Refr(ReserveSize), Refi(ReserveSize) {}
};
public:
PerturbationEvaluator();
template <typename real2>
Reference *_GenerateReference(const EvaluationParameters ¶meters);
template <typename real2>
void _Evaluate(PixelManager &rasterizer, Reference *Reference);
virtual Reference *GenerateReference(const EvaluationParameters ¶meters) override;
virtual void Evaluate(const EvaluationParameters ¶meters, PixelManager &rasterizer, Reference *Reference) override;
};
class NovaEvaluator : public SimpleEvaluator {
static constexpr size_t CommitSize = 256 * 1024;
size_t ReserveSize;
struct _PTReference : Reference {
const std::type_info &Type;
_PTReference(const std::type_info &type) : Type(type) {}
};
template <typename real2>
struct PTReference : _PTReference {
ReservedMemoryArray<real2> Zr;
ReservedMemoryArray<std::complex<real2>> Zsqr;
ReservedMemoryArray<std::complex<real2>> Zpow3m1;
ReservedMemoryArray<std::complex<real2>> Zm1;
size_t RefIt;
size_t MaxIt;
std::complex<real2> Refc;
PTReference() : _PTReference(typeid(real2)) {}
};
public:
NovaEvaluator();
template <typename real2>
Reference *_GenerateReference(const Coordinate &coordinate);
template <typename real2>
void _Evaluate(PixelManager &rasterizer, Reference *Reference);
virtual Reference *GenerateReference(const EvaluationParameters ¶meters) override;
virtual void Evaluate(const EvaluationParameters ¶meters, PixelManager &rasterizer, Reference *Reference) override;
};
#endif