-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_curv.cpp
52 lines (43 loc) · 1.55 KB
/
read_curv.cpp
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
// Demo program that reads per-vertex data from a curv file.
// To compile this with g++ 9.3:
//
// g++ -I../../include/ read_curv.cpp -o read_curv
//
// or with clang 10:
//
// clang++ -I../../include/ read_curv.cpp -o read_curv
//
#include "libfs.h"
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
int main(int argc, char** argv) {
std::string curv_fname = "lh.thickness";
if(argc == 2) {
curv_fname = argv[1];
}
std::cout << "Reading input curv file '" << curv_fname << "'.\n";
std::vector<float> data = fs::read_curv_data(curv_fname);
float min_entry = *std::min_element(data.begin(), data.end());
float max_entry = *std::max_element(data.begin(), data.end());
if(data.size() > 0) {
std::cout << "Received " << data.size() << " values in range " << min_entry << " to " << max_entry << ".\n";
} else {
std::cout << "Received empty vector.\n";
}
std::cout << "=== Writing and re-reading ===.\n";
// Write again.
std::string write_filename = "tmp.lh.thickness";
fs::write_curv(write_filename, data);
std::vector<float> data2 = fs::read_curv_data(write_filename);
float min_entry2 = *std::min_element(data2.begin(), data2.end());
float max_entry2 = *std::max_element(data2.begin(), data2.end());
if(data.size() > 0) {
std::cout << "Received " << data2.size() << " values in range " << min_entry2 << " to " << max_entry2 << ".\n";
} else {
std::cout << "Received empty vector.\n";
}
exit(0);
}