From a969852064b6e15915d7c9e24e956ad0bd01e16e Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 24 Feb 2011 14:15:26 -0500 Subject: [PATCH] Correct scaling factor for particle positions --- mytools/particleInfo.cpp | 70 ++++++++++++++++++++++------------------ mytools/voidTree.hpp | 7 ---- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/mytools/particleInfo.cpp b/mytools/particleInfo.cpp index e651263..22fda35 100644 --- a/mytools/particleInfo.cpp +++ b/mytools/particleInfo.cpp @@ -9,37 +9,6 @@ bool loadParticleInfo(ParticleInfo& info, const std::string& particles, const std::string& extra_info) { - try - { - UnformattedRead f(particles); - - int numpart; - - f.beginCheckpoint(); - numpart = f.readInt32(); - f.endCheckpoint(); - - info.particles.resize(numpart); - - f.beginCheckpoint(); - for (int i = 0; i < numpart; i++) - info.particles[i].x = f.readReal32(); - f.endCheckpoint(); - - f.beginCheckpoint(); - for (int i = 0; i < numpart; i++) - info.particles[i].y = f.readReal32(); - f.endCheckpoint(); - - f.beginCheckpoint(); - for (int i = 0; i < numpart; i++) - info.particles[i].z = f.readReal32(); - f.endCheckpoint(); - } - catch (const NoSuchFileException& e) - { - return false; - } NcFile f_info(extra_info.c_str()); @@ -53,5 +22,44 @@ bool loadParticleInfo(ParticleInfo& info, info.ranges[2][0] = f_info.get_att("range_z_min")->as_double(0); info.ranges[2][1] = f_info.get_att("range_z_max")->as_double(0); + try + { + UnformattedRead f(particles); + + int numpart; + float mul, offset; + + f.beginCheckpoint(); + numpart = f.readInt32(); + f.endCheckpoint(); + + info.particles.resize(numpart); + + offset = info.ranges[0][0]; + mul = info.ranges[0][1] - info.ranges[0][0]; + f.beginCheckpoint(); + for (int i = 0; i < numpart; i++) + info.particles[i].x = info.ranges[0][0] + mul*f.readReal32(); + f.endCheckpoint(); + + offset = info.ranges[0][0]; + mul = info.ranges[0][1] - info.ranges[0][0]; + f.beginCheckpoint(); + for (int i = 0; i < numpart; i++) + info.particles[i].y = f.readReal32(); + f.endCheckpoint(); + + offset = info.ranges[0][0]; + mul = info.ranges[0][1] - info.ranges[0][0]; + f.beginCheckpoint(); + for (int i = 0; i < numpart; i++) + info.particles[i].z = f.readReal32(); + f.endCheckpoint(); + } + catch (const NoSuchFileException& e) + { + return false; + } + return true; } diff --git a/mytools/voidTree.hpp b/mytools/voidTree.hpp index c28d6c6..126a871 100644 --- a/mytools/voidTree.hpp +++ b/mytools/voidTree.hpp @@ -181,13 +181,6 @@ public: int p = lookupParent(i, voids_for_zones); if ((i % 1000) == 0) std::cout << i << std::endl; - if (p < 0) - { - if (i != 0) - std::cerr << "Warning ! Voids without parent and it is not the root !" << std::endl; - continue; - } - nodes[p].children.push_back(&nodes[i]); nodes[i].parent = &nodes[p]; inserted++;