mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Fixed erroneous handling of zones with exact same leakage value in jozov2.
This commit is contained in:
parent
85546379cf
commit
96b0ba3154
1 changed files with 36 additions and 16 deletions
|
@ -18,16 +18,17 @@ struct ZoneDensityPair
|
||||||
{
|
{
|
||||||
int h;
|
int h;
|
||||||
double density;
|
double density;
|
||||||
|
double core;
|
||||||
|
|
||||||
bool operator<(const ZoneDensityPair& p2) const
|
bool operator<(const ZoneDensityPair& p2) const
|
||||||
{
|
{
|
||||||
return density > p2.density;
|
return (density > p2.density) || (density==p2.density && core > p2.core);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef priority_queue<ZoneDensityPair> ZoneQueue;
|
typedef priority_queue<ZoneDensityPair> ZoneQueue;
|
||||||
|
|
||||||
static void build_process_queue(ZoneQueue& q, ZONE *z, char *inyet, int h)
|
static void build_process_queue(ZoneQueue& q, ZONE *z, PARTICLE *p, char *inyet, int h)
|
||||||
{
|
{
|
||||||
ZoneDensityPair zdp;
|
ZoneDensityPair zdp;
|
||||||
ZONE& z_h = z[h];
|
ZONE& z_h = z[h];
|
||||||
|
@ -38,6 +39,7 @@ static void build_process_queue(ZoneQueue& q, ZONE *z, char *inyet, int h)
|
||||||
{
|
{
|
||||||
zdp.h = z_h.adj[za];
|
zdp.h = z_h.adj[za];
|
||||||
zdp.density = z_h.slv[za];
|
zdp.density = z_h.slv[za];
|
||||||
|
zdp.core = p[z[zdp.h].core].dens;
|
||||||
if (inyet[zdp.h] == 0)
|
if (inyet[zdp.h] == 0)
|
||||||
{
|
{
|
||||||
q.push(zdp);
|
q.push(zdp);
|
||||||
|
@ -72,32 +74,34 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
for (int h = 0; h < numZones; h++)
|
for (int h = 0; h < numZones; h++)
|
||||||
{
|
{
|
||||||
int nhlcount = 0;
|
int nhlcount = 0;
|
||||||
float lowvol, z_cur_core_dens;
|
float previous_lowvol = BIGFLT, lowvol, z_cur_core_dens;
|
||||||
bool beaten;
|
bool beaten;
|
||||||
priority_queue<ZoneDensityPair> to_process;
|
priority_queue<ZoneDensityPair> to_process;
|
||||||
int link0;
|
int link0;
|
||||||
|
int save_nhl;
|
||||||
|
pid_t save_npjoin;
|
||||||
|
|
||||||
for (int hl = 0; hl < nhl; hl++)
|
for (int hl = 0; hl < nhl; hl++)
|
||||||
inyet[zonelist[hl]] = 0;
|
inyet[zonelist[hl]] = 0;
|
||||||
|
|
||||||
zonelist[0] = h;
|
zonelist[0] = h;
|
||||||
inyet[h] = 1;
|
inyet[h] = 1;
|
||||||
nhl = 1;
|
save_nhl = nhl = 1;
|
||||||
z[h].npjoin = z[h].np;
|
save_npjoin = z[h].npjoin = z[h].np;
|
||||||
z_cur_core_dens = p[z[h].core].dens;
|
z_cur_core_dens = p[z[h].core].dens;
|
||||||
|
|
||||||
build_process_queue(to_process, z, inyet, h);
|
build_process_queue(to_process, z, p, inyet, h);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Find the lowest-volume (highest-density) adjacency */
|
/* Find the lowest-volume (highest-density) adjacency */
|
||||||
int nl = 0;
|
|
||||||
|
|
||||||
beaten = false;
|
beaten = false;
|
||||||
|
|
||||||
if (to_process.empty())
|
if (to_process.empty())
|
||||||
{
|
{
|
||||||
beaten = true;
|
beaten = true;
|
||||||
z[h].leak = maxvol;
|
z[h].leak = maxvol;
|
||||||
|
save_npjoin = z[h].npjoin;
|
||||||
|
save_nhl = nhl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,12 +115,20 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
|
|
||||||
if (to_process.empty())
|
if (to_process.empty())
|
||||||
{
|
{
|
||||||
|
save_npjoin = z[h].npjoin;
|
||||||
|
save_nhl = nhl;
|
||||||
beaten = true;
|
beaten = true;
|
||||||
z[h].leak = maxvol;
|
z[h].leak = maxvol;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nl++;
|
/* See if there's a beater */
|
||||||
|
if (previous_lowvol != lowvol)
|
||||||
|
{
|
||||||
|
save_npjoin = z[h].npjoin;
|
||||||
|
save_nhl = nhl;
|
||||||
|
previous_lowvol = lowvol;
|
||||||
|
}
|
||||||
|
|
||||||
if (lowvol > voltol)
|
if (lowvol > voltol)
|
||||||
{
|
{
|
||||||
|
@ -177,16 +189,17 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
if (beaten) {
|
if (beaten) {
|
||||||
z[h].leak = lowvol;
|
z[h].leak = lowvol;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (int h2 = 0; h2 < nhl2; h2++) {
|
for (int h2 = 0; h2 < nhl2; h2++) {
|
||||||
int new_h = zonelist2[h2];
|
int new_h = zonelist2[h2];
|
||||||
|
|
||||||
zonelist[nhl] = new_h;
|
zonelist[nhl] = new_h;
|
||||||
assert(inyet[new_h] == 0);
|
assert(inyet[new_h] == 0);
|
||||||
|
z[h].npjoin += z[new_h].np;
|
||||||
inyet[new_h] = 1;
|
inyet[new_h] = 1;
|
||||||
if (inyet2[new_h] != 2)
|
if (inyet2[new_h] != 2)
|
||||||
build_process_queue(to_process, z, inyet, new_h);
|
build_process_queue(to_process, z, p, inyet, new_h);
|
||||||
nhl++;
|
nhl++;
|
||||||
z[h].npjoin += z[new_h].np;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +215,12 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
}
|
}
|
||||||
while((lowvol < BIGFLT) && (!beaten));
|
while((lowvol < BIGFLT) && (!beaten));
|
||||||
|
|
||||||
|
if (!beaten)
|
||||||
|
{
|
||||||
|
save_npjoin = z[h].npjoin;
|
||||||
|
save_nhl = nhl;
|
||||||
|
}
|
||||||
|
|
||||||
z[h].denscontrast = z[h].leak/p[z[h].core].dens;
|
z[h].denscontrast = z[h].leak/p[z[h].core].dens;
|
||||||
if (z[h].denscontrast < 1.)
|
if (z[h].denscontrast < 1.)
|
||||||
z[h].denscontrast = 1.;
|
z[h].denscontrast = 1.;
|
||||||
|
@ -214,15 +233,16 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
FF;
|
FF;
|
||||||
}
|
}
|
||||||
/* Calculate volume */
|
/* Calculate volume */
|
||||||
|
z[h].npjoin = save_npjoin;
|
||||||
z[h].voljoin = 0.;
|
z[h].voljoin = 0.;
|
||||||
z[h].zonelist = new int[nhl];
|
z[h].zonelist = new int[save_nhl];
|
||||||
z[h].numzones = nhl;
|
z[h].numzones = save_nhl;
|
||||||
for (int q = 0; q < nhl; q++) {
|
for (int q = 0; q < save_nhl; q++) {
|
||||||
z[h].voljoin += z[zonelist[q]].vol;
|
z[h].voljoin += z[zonelist[q]].vol;
|
||||||
z[h].zonelist[q] = zonelist[q];
|
z[h].zonelist[q] = zonelist[q];
|
||||||
}
|
}
|
||||||
|
|
||||||
z[h].nhl = nhl;
|
z[h].nhl = save_nhl;
|
||||||
}
|
}
|
||||||
delete[] zonelist;
|
delete[] zonelist;
|
||||||
delete[] zonelist2;
|
delete[] zonelist2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue