-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtcmp.h
128 lines (112 loc) · 3.62 KB
/
rtcmp.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
/* R T C M P . H
* RtCmp
*
* Copyright (c) 2007-2024 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file rtcmp.h
*
* Brief description
*
*/
#ifndef RTCMP_H
#define RTCMP_H
#include <string>
#include <unordered_map>
#include "json.hpp"
#include <brlcad/vmath.h>
#include <brlcad/bu.h>
#include <brlcad/bn.h>
#include <brlcad/raytrace.h>
/* Defines used when setting up shotline inputs */
#define NUMVIEWS 6 /* this refers to data in perfcomp.c */
class diff_output_info {
public:
std::string json_ofile = std::string("shots.json");
std::string plot3_file = std::string("diff.plot3");
std::string nirt_file = std::string("diff.nrt");
std::string dbfile;
std::string obj_name;
};
/* Do a performance testing run - the purpose of this run is to
* compare the relative performance of two raytracers (or the impact
* of changes to the same raytracer) so outputs are not captured -
* instead, run time is measured by the caller */
void do_perf_run(const char *prefix, int argc, const char **argv, int ncpus, int nvrays,
void*(*constructor)(const char *, int, const char**),
int(*getbox)(void *, point_t *, point_t *),
double(*getsize)(void*),
void (*shoot)(void*, struct xray *),
int(*destructor)(void *));
/* Do a run to generate a file used to identify differences between
* raytracing results. This will produce a sizable output file, and
* may run rather slowly since shotline intersection data is being captured
* for output. */
void
do_diff_run(const char *prefix, int argc, const char **argv, int ncpus, int nvrays,
void*(*constructor)(const char *, int, const char**, nlohmann::json *),
int(*getbox)(void *, point_t *, point_t *),
double(*getsize)(void*),
void (*shoot)(void*, struct xray *),
int(*destructor)(void *),
diff_output_info &dinfo);
/* Structures and functions for comparing outputs between raytrace runs */
class run_part {
public:
bool different(class run_part &o, double tol, diff_output_info &dinfo);
void plot(FILE *pf);
void plot(FILE *pf, const class run_part &o);
void print();
std::string region;
double in_dist;
point_t in;
vect_t innorm;
double out_dist;
point_t out;
vect_t outnorm;
};
class run_shot {
public:
bool different(class run_shot &o, double tol, diff_output_info &dinfo);
void print();
unsigned long long ray_hash();
point_t ray_pt;
vect_t ray_dir;
std::vector<run_part> partitions;
private:
unsigned long long rhash = 0;
};
class run_shotset {
public:
bool different(class run_shotset &o, double tol, diff_output_info &dinfo);
void print();
std::string data_version;
std::string engine;
std::unordered_map<unsigned long long, size_t> shot_lookup;
std::vector<run_shot> shots;
};
run_shotset *
parse_shots_file(const char *fname);
bool shots_differ(const char *file1, const char *file2, double tol, diff_output_info &dinfo);
#endif // RTCMP_H
// Local Variables:
// tab-width: 8
// mode: C++
// c-basic-offset: 4
// indent-tabs-mode: t
// c-file-style: "stroustrup"
// End:
// ex: shiftwidth=4 tabstop=8