mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
Preliminary reimplementation of voz1b1 in C++ with more modularity
This commit is contained in:
parent
9786812b2c
commit
15d6825f5d
6 changed files with 697 additions and 4 deletions
64
c_tools/zobov2/voz1b1/voz_io.cpp
Normal file
64
c_tools/zobov2/voz1b1/voz_io.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "voz_io.hpp"
|
||||
#include "CosmoTool/fortran.hpp"
|
||||
#include <cmath>
|
||||
|
||||
using namespace CosmoTool;
|
||||
using namespace std;
|
||||
|
||||
bool PositionData::readFrom(const string& fname)
|
||||
{
|
||||
try
|
||||
{
|
||||
UnformattedRead f(fname.c_str());
|
||||
|
||||
f.beginCheckpoint();
|
||||
np = f.readInt32();
|
||||
f.endCheckPoint();
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
xyz[j] = new float[np];
|
||||
|
||||
f.beginCheckpoint();
|
||||
for (int p = 0; p < np; p++)
|
||||
xyz[j][p] = f.readReal32();
|
||||
f.endCheckpoint();
|
||||
}
|
||||
}
|
||||
catch (const NoSuchFileException& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (const InvalidUnformattedAccess& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (const EndOfFileException& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PositionData::findExtrema()
|
||||
{
|
||||
const float BF = std::numeric_limits<float>::max();
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
xyz_min[i] = BF;
|
||||
xyz_max[i] = -BF;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (pid_t p = 0; p < np; p++)
|
||||
{
|
||||
xyz_min[p] = min(xyz_min[p], xyz[p][i]);
|
||||
xyz_max[p] = max(xyz_max[p], xyz[p][i]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue