File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #pragma once
2+ #include < vector>
3+ #include < string>
4+ #include < fstream>
5+ #include " ../struct/particle.h"
6+
7+ inline void SaveVTK (const std::vector<Particle>& p, const std::string& filename)
8+ {
9+ std::ofstream out (filename);
10+ if (!out) return ;
11+
12+ const size_t N = p.size ();
13+ out << " # vtk DataFile Version 3.0\n " ;
14+ out << " NEXT snapshot\n " ;
15+ out << " ASCII\n " ;
16+ out << " DATASET POLYDATA\n " ;
17+
18+ // draw points
19+ out << " POINTS " << N << " float\n " ;
20+ for (const auto & a : p)
21+ out << a.x << " " << a.y << " " << a.z << " \n " ;
22+
23+ // draw vertices
24+ out << " VERTICES " << N << " " << N*2 << " \n " ;
25+ for (size_t i = 0 ; i < N; i++)
26+ out << " 1 " << i << " \n " ;
27+
28+ // that too
29+ out << " POINT_DATA " << N << " \n " ;
30+ out << " VECTORS velocity float\n " ;
31+ for (const auto & a : p)
32+ out << a.vx << " " << a.vy << " " << a.vz << " \n " ;
33+
34+ out << " SCALARS mass float 1\n " ;
35+ out << " LOOKUP_TABLE default\n " ;
36+ for (const auto & a : p)
37+ out << a.m << " \n " ;
38+ }
You can’t perform that action at this time.
0 commit comments