-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVtkWriter.cpp
43 lines (35 loc) · 1.23 KB
/
VtkWriter.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
/*
* VtkWriter.cpp
*
* Created on: Aug 3, 2015
* Author: friedrich
*/
#include "VtkWriter.h"
VtkWriter::VtkWriter() {
// TODO Auto-generated constructor stub
}
VtkWriter::~VtkWriter() {
// TODO Auto-generated destructor stub
}
void VtkWriter::writeHeader(std::ofstream &outfile) {
outfile << "# vtk DataFile Version 2.0\n";
outfile << "BGCE Project 2015-16\n";
outfile << "ASCII\n";
outfile << "\n";
}
void VtkWriter::writeStructuredGrid(std::ofstream &outfile,std::vector<int> dimensions,const float spacing){
outfile << "DATASET STRUCTURED_POINTS\n";
outfile << "DIMENSIONS " << (int)dimensions[0] << " " << (int)dimensions[1] << " " << (int)dimensions[2] << "\n";
outfile << "ORIGIN " << 0 << " " << 0 << " " << 0 << "\n";
outfile << "SPACING " << spacing << " " << spacing << " " << spacing << "\n";
outfile << "\n";
}
void VtkWriter::writeScalars(std::ofstream &outfile, std::string scalarType, const std::vector<int> &scalars){
int totalSize = scalars.size();
outfile << "POINT_DATA " << totalSize << " \n";
outfile << "SCALARS " << scalarType << " float 1 \n";
outfile << "LOOKUP_TABLE default \n";
for (int i = 0; i < totalSize; i++){
outfile << (float)scalars[i] << "\n";
}
}