mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Use C++ QHull for finding tesselation/convex hull
This commit is contained in:
parent
7f1d4d053d
commit
a7fdb2ca93
3 changed files with 60 additions and 2 deletions
|
@ -6,8 +6,10 @@
|
|||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include "loadZobov.hpp"
|
||||
#include <CosmoTool/fortran.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
||||
bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
||||
const char *volName, ZobovRep& z)
|
||||
|
@ -18,6 +20,7 @@ bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
|||
int32_t numParticles, numZones, numPinZone;
|
||||
int32_t totalParticles;
|
||||
int32_t numVoids;
|
||||
int32_t minParticlesInZone, maxParticlesInZone;
|
||||
|
||||
adjFile.read((char *)&numParticles, sizeof(numParticles));
|
||||
adjFile.read((char *)&numZones, sizeof(numZones));
|
||||
|
@ -28,6 +31,10 @@ bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
|||
cout << "Number of zones = " << numZones << endl;
|
||||
|
||||
totalParticles = 0;
|
||||
|
||||
minParticlesInZone = -1;
|
||||
maxParticlesInZone = -1;
|
||||
|
||||
z.allZones.resize(numZones);
|
||||
for (int zone = 0; zone < numZones; zone++)
|
||||
{
|
||||
|
@ -41,10 +48,19 @@ bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
|||
z.allZones[zone].pId.resize(numPinZone);
|
||||
adjFile.read((char *)&z.allZones[zone].pId[0], sizeof(int)*numPinZone);
|
||||
|
||||
if (maxParticlesInZone < 0 || numPinZone > maxParticlesInZone)
|
||||
maxParticlesInZone = numPinZone;
|
||||
|
||||
if (minParticlesInZone < 0 || numPinZone < minParticlesInZone)
|
||||
minParticlesInZone = numPinZone;
|
||||
|
||||
totalParticles += numPinZone;
|
||||
}
|
||||
cout << "Zoned " << totalParticles << endl;
|
||||
|
||||
cout << "Minimum number of particles in zone = " << minParticlesInZone << endl;
|
||||
cout << "Maximum number of particles in zone = " << maxParticlesInZone << endl;
|
||||
|
||||
if (totalParticles != numParticles)
|
||||
{
|
||||
cerr << "The numbers of particles are inconsistent ! (" << totalParticles << " vs " << numParticles << ")"<< endl;
|
||||
|
@ -155,5 +171,40 @@ bool loadZobov(const char *descName, const char *adjName, const char *voidsName,
|
|||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool loadZobovParticles(const char *fname, std::vector<ZobovParticle>& particles)
|
||||
{
|
||||
UnformattedRead f(fname);
|
||||
int N;
|
||||
|
||||
f.beginCheckpoint();
|
||||
N = f.readInt32();
|
||||
f.endCheckpoint();
|
||||
|
||||
particles.resize(N);
|
||||
|
||||
f.beginCheckpoint();
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
particles[i].x = f.readReal32();
|
||||
}
|
||||
f.endCheckpoint();
|
||||
|
||||
f.beginCheckpoint();
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
particles[i].y = f.readReal32();
|
||||
}
|
||||
f.endCheckpoint();
|
||||
|
||||
f.beginCheckpoint();
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
particles[i].z = f.readReal32();
|
||||
}
|
||||
f.endCheckpoint();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,15 @@ struct ZobovRep
|
|||
std::vector<float> particleVolume;
|
||||
};
|
||||
|
||||
struct ZobovParticle
|
||||
{
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
bool loadZobov(const char *descName,
|
||||
const char *adjName, const char *voidName,
|
||||
const char *volName, ZobovRep& z);
|
||||
|
||||
bool loadZobovParticles(const char *fname, std::vector<ZobovParticle>& particles);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,10 +53,10 @@ int delaunadj (coordT *points, int nvp, int nvpbuf, int nvpall, PARTADJ **adjs)
|
|||
/* 'qh facet_list' contains the convex hull */
|
||||
|
||||
/* From qh_printvneighbors */
|
||||
qh_countfacets(qh facet_list, NULL, NULL, &numfacets, &numsimplicial,
|
||||
qh_countfacets(qh facet_list, NULL, 0, &numfacets, &numsimplicial,
|
||||
&totneighbors, &numridges, &numcoplanars, &numtricoplanars);
|
||||
qh_vertexneighbors();
|
||||
vertices= qh_facetvertices (qh facet_list, NULL, NULL);
|
||||
vertices= qh_facetvertices (qh facet_list, NULL, 0);
|
||||
vertex_points= qh_settemp (nvpall);
|
||||
coplanar_points= qh_settemp (nvpall);
|
||||
qh_setzero (vertex_points, 0, nvpall);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue