// Example 1: Reading an H2D file header #include "H2DReader.h" #includeint main() { H2DReader reader; if (reader.open("file.h2d")) { H2DHeader header = reader.getHeader(); std::cout << "Simulation width: " << header.width << "\n"; std::cout << "Simulation height: " << header.height << "\n"; std::cout << "Number of particles: " << header.numParticles << "\n"; } return 0; }
// Example 2: Reading particle data from an H2D file #include "H2DReader.h" #includeIn this example, we read the particle data from an H2D file using the getParticles() function. We then loop through all the particles and print their positions to the console. Based on the function names and header files, it seems that the H2DReader library is likely part of a larger HypeR physics engine package.int main() { H2DReader reader; if (reader.open("file.h2d")) { H2DHeader header = reader.getHeader(); std::vector particles = reader.getParticles(); for (int i = 0; i < particles.size(); i++) { Particle p = particles[i]; std::cout << "Particle " << i << " has position (" << p.x << ", " << p.y << ")\n"; } } return 0; }