-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplot.cpp
More file actions
62 lines (45 loc) · 1.12 KB
/
plot.cpp
File metadata and controls
62 lines (45 loc) · 1.12 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
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenQMC Project.
#include "write.h"
#include <plot.h>
#include <cstdio>
#include <cstdlib>
float* start(int resolution)
{
return new float[resolution * resolution];
}
void stop(const float* out)
{
delete[] out;
}
int main(int argc, char* argv[])
{
if(argc == 1)
{
std::fprintf(stderr, "No arguments passed; "
"user must specify a shape.\n");
return EXIT_FAILURE;
}
if(argc > 2)
{
std::fprintf(stderr, "Too many arguments passed; "
"user must specify a shape.\n");
return EXIT_FAILURE;
}
constexpr auto nsamples = 8;
constexpr auto resolution = 256;
auto out = start(resolution);
if(!oqmc_plot_shape(argv[1], nsamples, resolution, out))
{
std::fprintf(stderr, "Shape that was requested was not found; "
"options are qdisk, fdisk, qgauss, fgauss, bilin, "
"linx, liny, heavi.\n");
goto failure;
}
write::greyscales("shape.pfm", resolution, resolution, out);
stop(out);
return EXIT_SUCCESS;
failure:
stop(out);
return EXIT_FAILURE;
}