Text archives Help
- From: cgribble@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1535 - in trunk: Model/Groups/private scenes
- Date: Mon, 23 Jul 2007 11:16:43 -0600 (MDT)
Author: cgribble
Date: Mon Jul 23 11:16:42 2007
New Revision: 1535
Modified:
trunk/Model/Groups/private/ParticleCGT.cc
trunk/Model/Groups/private/ParticleCGT.h
trunk/scenes/pcgt.cc
Log:
Some cleanup; color mapping for values [0,7] working ; most of this code is
ugly and the internal data structures need redesigned, but we've got less
than a week to deadline, so we'll take what works for now...
Modified: trunk/Model/Groups/private/ParticleCGT.cc
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.cc (original)
+++ trunk/Model/Groups/private/ParticleCGT.cc Mon Jul 23 11:16:42 2007
@@ -1,10 +1,13 @@
+#include <Core/Geometry/BBox.h>
+#include <Interface/MantaInterface.h>
#include <Model/Groups/private/ParticleCGT.h>
+#include <Model/Materials/Lambertian.h>
+#include <Model/Primitives/Triangle.h>
+#include <Model/Readers/ParticleNRRD.h>
+#include <Model/Textures/ColorMap.h>
#include <SCIRun/Core/Thread/Time.h>
#include <SCIRun/Core/Thread/Thread.h>
-#include <Core/Geometry/BBox.h>
-#include <Model/Primitives/Triangle.h>
-#include <Interface/MantaInterface.h>
#ifdef USE_NUMA
#include <numa.h>
@@ -67,6 +70,100 @@
#endif //SSE
+ParticleGrid::ParticleGrid(const ParticleNRRD& pnrrd, Real radius, int ridx,
+ int cidx_) :
+ cidx(cidx_),
+ firstTime(true),
+ mutex("generic build mutex"),
+ barrier("CGT build barrier"),
+ buildQueue_resize_mutex("build queue resize mutex"),
+ buildQueue_was_resized(false)
+{
+ unsigned int nparticles = pnrrd.getNParticles();
+ unsigned int nvars = pnrrd.getNVars();
+
+ // Create color map
+ unsigned int type = RegularColorMap::parseType("InvRainbowIso");
+ RegularColorMap cmap(type);
+ float vmin = FLT_MAX;
+ float vmax = -FLT_MAX;
+ for (unsigned int i = 0; i < nparticles; ++i) {
+ float* data = pnrrd.getParticleData() + i*nvars;
+ vmin = std::min(vmin, data[cidx]);
+ vmax = std::max(vmax, data[cidx]);
+ }
+
+ Material* material = new Lambertian(new ColorMap(cmap, vmin, vmax));
+
+ // Create sphere primitives --> (x, y, z) radius
+ currGroup = new Group;
+ for (unsigned int i = 0; i < nparticles; ++i) {
+ float* data = pnrrd.getParticleData() + i*nvars;
+ Vector position(data[0], data[1], data[2]);
+ if (ridx >= 0)
+ radius = data[ridx];
+
+ currGroup->add(new Sphere(material, position, radius));
+ }
+
+ // Allocate and initialize (v0, v1, v2, v3)
+ currData = new Real*[nparticles];
+ for (unsigned int i = 0; i < nparticles; ++i) {
+ currData[i] = new Real[4];
+ currData[i][0] = currData[i][1] = currData[i][2] = currData[i][3] = 0.;
+ }
+
+ // Populate (v0, v1, v2, v3) from dataset if necessary
+ if (nvars > 3) {
+ for (unsigned int i = 0; i < nparticles; ++i) {
+ float* data = pnrrd.getParticleData() + i*nvars;
+ for (unsigned int j = 0; j < nvars - 4; ++j)
+ currData[i][j] = data[j + 4];
+ }
+ }
+
+#ifdef MACRO_CELLS
+ oldN_mc[0] = oldN_mc[1] = oldN_mc[2] = -1;
+#endif
+ oldN[0] = oldN[1] = oldN[2] = -1;
+
+ // Rebuild grid to initialize remaining structures
+ rebuild(currGroup);
+}
+
+ParticleGrid::ParticleGrid(int cidx_) :
+ cidx(cidx_),
+ firstTime(true),
+ mutex("generic build mutex"),
+ barrier("CGT build barrier"),
+ buildQueue_resize_mutex("build queue resize mutex"),
+ buildQueue_was_resized(false)
+{
+#ifdef MACRO_CELLS
+ oldN_mc[0] = oldN_mc[1] = oldN_mc[2] = -1;
+#endif
+ oldN[0] = oldN[1] = oldN[2] = -1;
+
+
+ particles = NULL;// TODO: FILL PARTICLES FROM CURRGROUP
+ tsparticles = NULL; //TODO:FILL ME
+
+ //vtx = vtx_; //TODO: What are these??? gathered from particle data
+ //vars = 0;
+ //vtxs = vtxs_; // number of spheres
+ setMinMaxVars();
+}
+
+
+ParticleGrid::~ParticleGrid()
+{
+ for (unsigned int i = 0; i < currGroup->size(); ++i)
+ delete [] currData[i];
+
+ delete [] currData;
+}
+
+
void ParticleGrid::newFrame() {}
@@ -80,14 +177,6 @@
if (currGroup)
currGroup->preprocess(context);
- else
-{
- return;
-}
-
-
-
-
}
void ParticleGrid::preFrameSetup(int proc, int numProcs)
@@ -139,29 +228,30 @@
{
currGroup = group;
- //load tsparticles with data from currGroup
+ //load tsparticles with data from currGroup
CDTimeSteppedParticles* tmpTSParticles = &tsparticlesA;//new
CDTimeSteppedParticles();
//CDParticle* tmpParticles = //new CDParticle[currGroup->size()];
//cout << hex << tmpParticles << endl;
tmpTSParticles->vtxs = currGroup->size();
- if (tmpTSParticles->vtxs > MAX_PARTICLES)
- {
- cerr << "WARNING: ParticleCGT: number of particles over maximum
size\n";
- tmpTSParticles->vtxs = MAX_PARTICLES;
- }
+ if (tmpTSParticles->vtxs > MAX_PARTICLES) {
+ cerr << "WARNING: ParticleCGT: number of particles over maximum size\n";
+ tmpTSParticles->vtxs = MAX_PARTICLES;
+ }
tmpTSParticles->max_radius = 0;
- for(int i = 0; i < tmpTSParticles->vtxs; i++)
- {
- float radius = ((Sphere*)currGroup->get(i))->getRadius();
- Vector position = ((Sphere*)currGroup->get(i))->getCenter();
- if (radius > tmpTSParticles->max_radius)
- tmpTSParticles->max_radius = radius;
- //cout << &tmpParticles[i] << endl;
- tmpTSParticles->particles[i].sphere = set44(radius, position.z(),
position.y(), position.x());
- //cout << "sphere position: " << position.x() << " " << position.y()
<< " " << position.z() << endl;
- tmpTSParticles->particles[i].data = set44(-FLT_MAX, -FLT_MAX, FLT_MAX,
FLT_MAX);
- tmpTSParticles->particles[i].index = i;
+ for(int i = 0; i < tmpTSParticles->vtxs; i++) {
+ float radius = ((Sphere*)currGroup->get(i))->getRadius();
+ Vector position = ((Sphere*)currGroup->get(i))->getCenter();
+ if (radius > tmpTSParticles->max_radius)
+ tmpTSParticles->max_radius = radius;
+ //cout << &tmpParticles[i] << endl;
+ tmpTSParticles->particles[i].sphere = set44(radius, position.z(),
position.y(),
+ position.x());
+ //cout << "sphere position: " << position.x() << " " << position.y() <<
" " << position.z() << endl;
+ tmpTSParticles->particles[i].data = set44(currData[i][3], currData[i][2],
+ currData[i][1],
currData[i][0]);
+ tmpTSParticles->particles[i].index = i;
}
+
//tmpTSParticles->particles = tmpParticles;
tsparticles = tmpTSParticles;
//TODO: set these values for range culling in the dataset
@@ -1081,7 +1171,7 @@
for (int u = uv01[0]; u <= uv01[2]; u++) {
//incrementCounter(cells_t);
- int hit = 0;
+ // int hit = 0;
const vector<CDParticle> &cell_particles =
cellVector[id].particles;
@@ -1092,7 +1182,7 @@
for (int i=0;i<items;i++) {
const sse_t& idat=cell_particles[i].sphere; // idat --> (x, y,
z, r)
- const sse_t& ivar=cell_particles[i].data; // ivar --> (v0, v1,
v2, v3)
+ const sse_t& ivar=cell_particles[i].data; // ivar --> (v0,
v1, v2, v3)
#ifdef FRUSTUM_CULLING
#ifdef FC_STATS
//StatsCollector::NumSpheres.Increment();
@@ -1118,67 +1208,27 @@
#endif
// incrementCounter(isect_before);
//cout << "hitTest\n";
+
+#ifdef COLOR_MAPPING
float ts[ray.end()];
- for(int z = ray.begin(); z < ray.end(); z++)
+ for(int z = ray.begin(); z < ray.end(); ++z)
ts[z] = ray.getMinT(z);
+#endif // COLOR_MAPPING
+
+ // Intersect particles
currGroup->get(cell_particles[i].index)->intersect(context, ray);
#ifdef COLOR_MAPPING
- // Extract and normalize the data value to use for color
mapping
- sse_union value;
- sse_t rmin4;
- sse_t inv_range;
- if (cidx<4) {
- value.sse = set4(((float*)&(idat))[cidx]);
- rmin4 =
set4(((float*)&(tsparticles->bounds.min))[cidx]);
-
inv_range=set4(((float*)&(tsparticles->inv_prange))[cidx]);
- } else {
- value.sse = set4(((float*)&(ivar))[cidx-4]);
- rmin4 =
set4(((float*)&(tsparticles->vars_min))[cidx-4]);
-
inv_range=set4(((float*)&(tsparticles->inv_vrange))[cidx-4]);
- }
-
- const sse_t diff = sub4(value.sse, rmin4);
- const sse_t norm_value = mul4(diff, inv_range);
+ // Extract/set value for color mapping
+ const float value = (cidx < 4 ?
+ ((float*)(&idat))[cidx] :
+ ((float*)(&ivar))[cidx-4]);
+ for (int j = ray.begin(); j < ray.end(); ++j) {
+ if (ray.getMinT(j) < ts[j])
+ ray.scratchpad<Real>(j) = value;
+ anyHit = true;
+ }
#endif // COLOR_MAPPING
- for( int j = ray.begin(); j < ray.end(); j++)
- {
- if (ray.getMinT(j) < ts[j])
- {
- float v = 0.0f;
- if (cidx < 3) // use position information for
colormap
- {
- //TODO: use sphere postion instead of hit
postioin?
- // THis explodes for some reason:
- //ray.computeHitPositions();
- //v = ray.data->hitPosition[0][j];
- //cout << "v: " << v << endl;
- //per pixel colormap: //v =
ray.getMinT(j)*ray.getDirection(j, cidx) + ray.getOrigin(j, cidx);
- //v = ((float*)&(value))[0];
- Vector pos =
((Sphere*)currGroup->get(cell_particles[i].index))->getCenter();
- v = pos.x();
- }
- else // use data values
- {
- //TODO: set v here
- }
-
- Real& val = ray.scratchpad<Real>(j);
- val = v;
- }
- anyHit = true;
- }
-
-
- // anyHit = true; // TODO: actually set this based on
hit?
-// anyHit +=
intersectSphere<SHADOWS_ONLY,COMMON_ORIGIN,true>(idat,
-// #ifdef COLOR_MAPPING
-//
ivar,
-// #endif // COLOR_MAPPING
-//
ray);
-// #ifdef PRANGE_CULLING
-// }
-// #endif //PRANGE_CULLING
#ifdef FRUSTUM_CULLING
} else {
#ifdef FC_STATS
Modified: trunk/Model/Groups/private/ParticleCGT.h
==============================================================================
--- trunk/Model/Groups/private/ParticleCGT.h (original)
+++ trunk/Model/Groups/private/ParticleCGT.h Mon Jul 23 11:16:42 2007
@@ -2,17 +2,16 @@
#ifndef Manta_Model_ParticleCGT_h
#define Manta_Model_ParticleCGT_h
-#include <Model/Groups/Group.h>
-#include <Interface/AccelerationStructure.h>
-#include <Interface/RayPacket.h>
-#include <Interface/Context.h>
-#include <Model/Primitives/WaldTriangle.h>
#include <Core/Math/SSEDefs.h>
#include <Core/Thread/Barrier.h>
-#include <SCIRun/Core/Thread/Mutex.h>
#include <Core/Util/AlignedAllocator.h>
-#include <Model/Groups/TimeSteppedParticles.h>
+#include <Interface/AccelerationStructure.h>
+#include <Interface/Context.h>
+#include <Interface/RayPacket.h>
+#include <Model/Groups/Group.h>
#include <Model/Primitives/Sphere.h>
+#include <Model/Readers/ParticleNRRD.h>
+#include <SCIRun/Core/Thread/Mutex.h>
#include "SIMD.hxx"
@@ -25,72 +24,66 @@
#define MAX_PARTICLES 5000000
#define COLOR_MAPPING
-
#define MACRO_CELLS 6
-
-#if MACRO_CELLS == 1 //1 is just overhead for normal grid!
-#undef MACRO_CELLS
+#if MACRO_CELLS == 1 // 1 is just overhead for normal grid!
+# undef MACRO_CELLS
#endif
-#define NUM_BUILD_THREADS 1 //hardcoded for now...
-
-
-namespace Manta {
+#define NUM_BUILD_THREADS 1 // hardcoded for now...
+namespace Manta
+{
struct MANTA_ALIGN(16) Box4: public AlignedAllocator<Box4>
{
sse_t min, max; //NO, it goes 0,x,y,z. the first one is the unused
one... 0,1,2 floats are the xyz. 3 is undefined?
sse_t diameter() const { return sub4(max,min); }
- sse_t extend(sse_t sphere) {
+ void extend(sse_t sphere) {
sse_union s;
s.sse = sphere;
//TODO: optimiize this ugly code
//TODO: I think it is infact
sse_t sMin = sub4(s.sse, set4(s.f[3])); // sphere min = position -
radius
sse_t sMax = add4(s.sse, set4(s.f[3])); // sphere max = position +
radius
- sse_t mask = cmp4_lt(sMin, min);
- min = or4((mask, sMin), andnot4(mask, min));
- mask = cmp4_gt(sMax, max);
- max = or4((mask, sMax), andnot4(mask, max));
+ min = min4(min, sMin);
+ max = max4(max, sMax);
+ /*
+ sse_t mask = cmp4_lt(sMin, min);
+ min = or4((mask, sMin), andnot4(mask, min));
+ mask = cmp4_gt(sMax, max);
+ max = or4((mask, sMax), andnot4(mask, max));
+ */
+ }
+ void setEmpty()
+ {
+ min = set44(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
+ max = set44(-FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX);
}
- void setEmpty() { min = max = set4(0); }
};
struct Weedo{
sse_t mmm;
sse_t hmmh;
};
struct MANTA_ALIGN(16) CDParticle : public AlignedAllocator<CDParticle>
-{
- sse_t sphere; // x,y,z,r (postion, radius)
- sse_t data; // v0,v1,v2,v3
- int index; //index in currGroup
-};
+ {
+ sse_t sphere; // x,y,z,r (postion, radius)
+ sse_t data; // v0,v1,v2,v3
+ int index; //index in currGroup
+ };
struct MANTA_ALIGN(16) CDTimeSteppedParticles : public
AlignedAllocator<CDTimeSteppedParticles>
-{
- Box4 bounds;
- sse_t inv_vrange;
- sse_t inv_prange;
- sse_t vars_max;
- sse_t vars_min;
- CDParticle particles[MAX_PARTICLES];
- int vtxs;
- float max_radius;
-};
-
- //using namespace Manta;
-
-
+ {
+ Box4 bounds;
+ sse_t inv_vrange;
+ sse_t inv_prange;
+ sse_t vars_max;
+ sse_t vars_min;
+ CDParticle particles[MAX_PARTICLES];
+ int vtxs;
+ float max_radius;
+ };
std::ostream &operator<< (std::ostream &o, const Box4 &v);
- /*
- o << "(" << v.min << ".." << v.max << ")";
- return o;
- }
- */
-
-
struct ParticleGrid : public AccelerationStructure,
public AlignedAllocator<ParticleGrid>
@@ -99,7 +92,7 @@
sse_union sse_M, sse_N;
sse_t sse_one_over_N;
sse_union diam, // diameter of grid
- scale, // 1 / diam
+ scale, // 1 / diam
scaleM, // scale * M
scaleN; // scale * N == N / diam == number of cells per unit distance
//length of cell in k direction divided by u or v direction cell length.
@@ -124,130 +117,130 @@
sse_t dmin, dmax;
sse_t vmin, vmax;
- int cidx;
- void setCidx(int new_cidx)
- {
- cidx = new_cidx;
- }
+ unsigned int cidx;
+ void setCidx(unsigned int new_cidx)
+ {
+ cidx = new_cidx;
+ }
mutable float max_radius;
void extendBoundsBySphere(int i,Box4 &bounds) const
- {
- const sse_t sphere = getPos(i);
- // union {
- // float radius[4];
- // sse_t vec_radius;
- // };
+ {
+ const sse_t sphere = getPos(i);
+ // union {
+ // float radius[4];
+ // sse_t vec_radius;
+ // };
- // vec_radius = splat4(sphere,3);
- //const float my_radius=radius[0];
- sse_union tmp;
- tmp.sse = sphere;
- float my_radius = tmp.f[3]; // Carson: modified because radius[0]
seems like x coord to me..
- if (my_radius>max_radius)
- //this could be called fr
- max_radius=my_radius;
+ // vec_radius = splat4(sphere,3);
+ //const float my_radius=radius[0];
+ sse_union tmp;
+ tmp.sse = sphere;
+ float my_radius = tmp.f[3]; // Carson: modified because radius[0]
seems like x coord to me..
+ if (my_radius>max_radius)
+ //this could be called fr
+ max_radius=my_radius;
bounds.extend(sphere);
- }
- inline Box4 getSphereBounds(int i)
- {
- Box4 tmp; tmp.setEmpty(); extendBoundsBySphere(i,tmp); return tmp;
- }
- sse_t &getPos(int i) const
- {
- assert(particles);
- assert(0 <= i && i < vtxs);
- return particles[i].sphere;
- }
+ }
+ inline Box4 getSphereBounds(int i)
+ {
+ Box4 tmp; tmp.setEmpty(); extendBoundsBySphere(i,tmp); return tmp;
+ }
+ sse_t &getPos(int i) const
+ {
+ assert(particles);
+ assert(0 <= i && i < vtxs);
+ return particles[i].sphere;
+ }
- sse_t &getVar(int i) const
- {
- assert(particles);
- assert(0 <= i && i < vtxs);
- return particles[i].data;
- }
+ sse_t &getVar(int i) const
+ {
+ assert(particles);
+ assert(0 <= i && i < vtxs);
+ return particles[i].data;
+ }
- // These are attached to the key strokes that change the valid ranges
- void setMinMaxVars(float* min=0, float* max=0)
- {
- /*
- cerr<<"enter:\n";
- cerr<<" dmin = "<<dmin<<'\n';
- cerr<<" dmax = "<<dmax<<'\n';
- cerr<<'\n';
- cerr<<" vmin = "<<vmin<<'\n';
- cerr<<" vmax = "<<vmax<<'\n';
- cerr<<'\n';
- */
-
- if (min) {
- dmin=set44(min[0], min[1], min[2], min[3]);
- vmin=set44(min[4], min[5], min[6], min[7]);
- } else {
- dmin=set4(-FLT_MAX);
- vmin=set4(-FLT_MAX);
- }
-
- if (max) {
- dmax=set44(max[0], max[1], max[2], max[3]);
- vmax=set44(max[4], max[5], max[6], max[7]);
- } else {
- dmax=set4(FLT_MAX);
- vmax=set4(FLT_MAX);
- }
-
- /*
- cerr<<"exit:\n";
- cerr<<" dmin = "<<dmin<<'\n';
- cerr<<" dmax = "<<dmax<<'\n';
- cerr<<'\n';
- cerr<<" vmin = "<<vmin<<'\n';
- cerr<<" vmax = "<<vmax<<'\n';
- cerr<<'\n';
- cerr<<'\n';
- */
- }
-
- void getMinMaxValues(float min[8], float max[8]) {
- // min/max (x, y, z)
- union {
- sse_t bsse;
- float bf[4];
- };
- //BBox bbox;
- //PreprocessContext tmp;
- Box4 bounds = tsparticles->bounds;
- bsse=bounds.min;
- min[0]=bf[0];
- min[1]=bf[1];
- min[2]=bf[2];
- min[3]=0.f;
-
- bsse=bounds.max;
- max[0]=bf[0];
- max[1]=bf[1];
- max[2]=bf[2];
- max[3]=tsparticles->max_radius;
-
- // min/max (v0, v1, v2, v3)
- union {
- sse_t vsse;
- float vf[4];
- };
+ // These are attached to the key strokes that change the valid ranges
+ void setMinMaxVars(float* min=0, float* max=0)
+ {
+ /*
+ cerr<<"enter:\n";
+ cerr<<" dmin = "<<dmin<<'\n';
+ cerr<<" dmax = "<<dmax<<'\n';
+ cerr<<'\n';
+ cerr<<" vmin = "<<vmin<<'\n';
+ cerr<<" vmax = "<<vmax<<'\n';
+ cerr<<'\n';
+ */
+
+ if (min) {
+ dmin=set44(min[0], min[1], min[2], min[3]);
+ vmin=set44(min[4], min[5], min[6], min[7]);
+ } else {
+ dmin=set4(-FLT_MAX);
+ vmin=set4(-FLT_MAX);
+ }
+
+ if (max) {
+ dmax=set44(max[0], max[1], max[2], max[3]);
+ vmax=set44(max[4], max[5], max[6], max[7]);
+ } else {
+ dmax=set4(FLT_MAX);
+ vmax=set4(FLT_MAX);
+ }
+
+ /*
+ cerr<<"exit:\n";
+ cerr<<" dmin = "<<dmin<<'\n';
+ cerr<<" dmax = "<<dmax<<'\n';
+ cerr<<'\n';
+ cerr<<" vmin = "<<vmin<<'\n';
+ cerr<<" vmax = "<<vmax<<'\n';
+ cerr<<'\n';
+ cerr<<'\n';
+ */
+ }
- vsse=tsparticles->vars_min;
- min[4]=vf[0];
- min[5]=vf[1];
- min[6]=vf[2];
- min[7]=vf[3];
-
- vsse=tsparticles->vars_max;
- max[4]=vf[0];
- max[5]=vf[1];
- max[6]=vf[2];
- max[7]=vf[3];
- }
+ void getMinMaxValues(float min[8], float max[8]) {
+ // min/max (x, y, z)
+ union {
+ sse_t bsse;
+ float bf[4];
+ };
+ //BBox bbox;
+ //PreprocessContext tmp;
+ Box4 bounds = tsparticles->bounds;
+ bsse=bounds.min;
+ min[0]=bf[0];
+ min[1]=bf[1];
+ min[2]=bf[2];
+ min[3]=0.f;
+
+ bsse=bounds.max;
+ max[0]=bf[0];
+ max[1]=bf[1];
+ max[2]=bf[2];
+ max[3]=tsparticles->max_radius;
+
+ // min/max (v0, v1, v2, v3)
+ union {
+ sse_t vsse;
+ float vf[4];
+ };
+
+ vsse=tsparticles->vars_min;
+ min[4]=vf[0];
+ min[5]=vf[1];
+ min[6]=vf[2];
+ min[7]=vf[3];
+
+ vsse=tsparticles->vars_max;
+ max[4]=vf[0];
+ max[5]=vf[1];
+ max[6]=vf[2];
+ max[7]=vf[3];
+ }
struct CellData {
@@ -291,7 +284,7 @@
#ifdef MCRANGE_CULLING
inline void set_mc(int x, int y, int z, int d, sse_t* minmax)
{l
- assert(x >= 0);
+ assert(x >= 0);
assert(y >= 0);
assert(z >= 0);
assert(x < N_mc[0]);
@@ -299,41 +292,41 @@
assert(z < N_mc[2]);
int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
assert(ofs
- < cellVector_mc.size());
+ < cellVector_mc.size());
cellVector_mc[ofs].ntris = d;
cellVector_mc[ofs].minmax[0]=minmax[0];
cellVector_mc[ofs].minmax[1]=minmax[1];
cellVector_mc[ofs].minmax[2]=minmax[2];
cellVector_mc[ofs].minmax[3]=minmax[3];
}
- inline const sse_t* getMCMinMax(int idx[3]) const
- {
- int x = idx[0];
- int y = idx[1];
- int z = idx[2];
- assert(x >= 0);
- assert(y >= 0);
- assert(z >= 0);
- assert(x < N_mc[0]);
- assert(y < N_mc[1]);
- assert(z < N_mc[2]);
- int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
- assert(ofs < cellVector_mc.size());
- return cellVector_mc[ofs].minmax;
- }
+ inline const sse_t* getMCMinMax(int idx[3]) const
+ {
+ int x = idx[0];
+ int y = idx[1];
+ int z = idx[2];
+ assert(x >= 0);
+ assert(y >= 0);
+ assert(z >= 0);
+ assert(x < N_mc[0]);
+ assert(y < N_mc[1]);
+ assert(z < N_mc[2]);
+ int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
+ assert(ofs < cellVector_mc.size());
+ return cellVector_mc[ofs].minmax;
+ }
#else
- inline void set_mc(int x, int y, int z, int d)
- {
- assert(x >= 0);
- assert(y >= 0);
- assert(z >= 0);
- assert(x < N_mc[0]);
- assert(y < N_mc[1]);
- assert(z < N_mc[2]);
- int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
- assert(ofs < cellVector_mc.size());
- cellVector_mc[ofs].ntris = d;
- }
+ inline void set_mc(int x, int y, int z, int d)
+ {
+ assert(x >= 0);
+ assert(y >= 0);
+ assert(z >= 0);
+ assert(x < N_mc[0]);
+ assert(y < N_mc[1]);
+ assert(z < N_mc[2]);
+ int ofs = x+N_mc[0]*(y+N_mc[1]*(z));
+ assert(ofs < cellVector_mc.size());
+ cellVector_mc[ofs].ntris = d;
+ }
#endif // MCRANGE_CULLING
#endif // MACROCELLS
inline int idx(int x, int y, int z) const
@@ -369,29 +362,9 @@
return cell;
}
- ParticleGrid(int cidxn = 0) :
- firstTime(true), mutex("generic build mutex"),
- barrier("CGT build barrier"),
- buildQueue_resize_mutex("build queue resize mutex"),
- buildQueue_was_resized(false),
- currGroup(NULL), cidx(cidxn)
- {
-#ifdef MACRO_CELLS
- oldN_mc[0] = oldN_mc[1] = oldN_mc[2] = -1;
-#endif
- oldN[0] = oldN[1] = oldN[2] = -1;
-
-
- particles = NULL;// TODO: FILL PARTICLES FROM CURRGROUP
- tsparticles = NULL; //TODO:FILL ME
-
- //vtx = vtx_; //TODO: What are these??? gathered from particle data
- //vars = 0;
- //vtxs = vtxs_; // number of spheres
- setMinMaxVars();
- }
-
- virtual ~ParticleGrid() {}
+ ParticleGrid(const ParticleNRRD& pnrrd, Real radius, int ridx, int
cidx_);
+ ParticleGrid(int cidx_);
+ virtual ~ParticleGrid();
void computeBounds(const PreprocessContext& context, BBox& bbox) const;
@@ -411,6 +384,9 @@
protected:
+ Group *currGroup; // Spheres --> (x, y, z) radius
+ Real** currData; // Data --> (v0, v1, v2, v3)
+ //vector<Particle> particles; // set to homogenous spheres
bool firstTime;
SCIRun::Mutex mutex;
@@ -418,9 +394,6 @@
SCIRun::Barrier barrier;
SCIRun::Mutex buildQueue_resize_mutex;
bool buildQueue_was_resized;
-
- Group *currGroup;
- //vector<Particle> particles; // set to homogenous spheres
#ifdef MACRO_CELLS
int oldN_mc[3];
Modified: trunk/scenes/pcgt.cc
==============================================================================
--- trunk/scenes/pcgt.cc (original)
+++ trunk/scenes/pcgt.cc Mon Jul 23 11:16:42 2007
@@ -1,5 +1,4 @@
-#include <Core/Color/RegularColorMap.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Geometry/Vector.h>
#include <Core/Util/Args.h>
@@ -10,12 +9,7 @@
#include <Model/AmbientLights/ConstantAmbient.h>
#include <Model/Backgrounds/ConstantBackground.h>
#include <Model/Backgrounds/EnvMapBackground.h>
-#include <Model/Groups/TimeSteppedParticles.h>
#include <Model/Lights/PointLight.h>
-#include <Model/Materials/Lambertian.h>
-#include <Model/Primitives/GridSpheres.h>
-#include <Model/Primitives/Sphere.h>
-#include <Model/Textures/ColorMap.h>
#include <Model/Readers/ParticleNRRD.h>
#include <Model/Groups/private/ParticleCGT.h>
@@ -67,8 +61,8 @@
cerr<<"Valid options for scene pcgt:\n";
cerr<<" -cidx <int> data value index for color mapping\n";
cerr<<" -envmap <string> environment map filename\n";
- cerr<<" -i <string> filename\n";
- cerr<<" -radius <float> particle radius\n";
+ cerr<<" -i <string> input filename\n";
+ cerr<<" -radius <float> constant radius value\n";
cerr<<" -ridx <int> radius index\n";
throw IllegalArgument("scene pcgt", i, args);
}
@@ -77,46 +71,9 @@
// Create scene
Scene* scene = new Scene();
- // Read the data
+ // Read particle data and create grid
ParticleNRRD pnrrd(fname);
- unsigned int nparticles = pnrrd.getNParticles();
- unsigned int nvars = pnrrd.getNVars();
-
- // Create color map
- unsigned int type = RegularColorMap::parseType("InvRainbowIso");
- RegularColorMap cmap(type);
- float vmin = FLT_MAX;
- float vmax = -FLT_MAX;
- for (unsigned int i = 0; i < nparticles; ++i) {
- float* data = pnrrd.getParticleData() + i*nvars;
- vmin = std::min(vmin, data[cidx]);
- vmax = std::max(vmax, data[cidx]);
- }
-
- // XXX(cpg) - Why adjust by the radius? First, radius may vary per
particle.
- // Second, it's unclear why this is necessary at all.
- /*
- if (cidx < 3) {
- vmin -= radius;
- vmax += radius;
- }
- */
-
- Material* material = new Lambertian(new ColorMap(cmap, vmin, vmax));
-
- // Create particles
- Group* particles = new Group;
- for (unsigned int i = 0; i < nparticles; ++i) {
- float* data = pnrrd.getParticleData() + i*nvars;
- Vector position(data[0], data[1], data[2]);
- if (ridx >= 0)
- radius = data[ridx];
-
- particles->add(new Sphere(material, position, radius));
- }
-
- ParticleGrid* grid = new ParticleGrid(cidx);
- grid->rebuild(particles);
+ ParticleGrid* grid = new ParticleGrid(pnrrd, radius, ridx, cidx);
scene->setObject(grid);
// Set background
- [MANTA] r1535 - in trunk: Model/Groups/private scenes, cgribble, 07/23/2007
Archive powered by MHonArc 2.6.16.