Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2339 - in trunk: Model/Readers scenes/csafe/python scenes/csafe/src


Chronological Thread 
  • From:
  • To:
  • Subject: [Manta] r2339 - in trunk: Model/Readers scenes/csafe/python scenes/csafe/src
  • Date: Thu, 23 Oct 2008 13:07:00 -0600 (MDT)

Author: brownlee
Date: Thu Oct 23 13:06:58 2008
New Revision: 2339

Modified:
   trunk/Model/Readers/ParticleNRRD.cc
   trunk/Model/Readers/ParticleNRRD.h
   trunk/Model/Readers/VolumeNRRD.h
   trunk/scenes/csafe/python/csafe_demo.py
   trunk/scenes/csafe/src/CDGridSpheres.cc
   trunk/scenes/csafe/src/CDGridSpheres.h
   trunk/scenes/csafe/src/CDTest.h
Log:
changed particleNRRD to store keyValue pairs

Modified: trunk/Model/Readers/ParticleNRRD.cc
==============================================================================
--- trunk/Model/Readers/ParticleNRRD.cc (original)
+++ trunk/Model/Readers/ParticleNRRD.cc Thu Oct 23 13:06:58 2008
@@ -41,6 +41,17 @@
   nvars=pnrrd->axis[0].size;
   nparticles=pnrrd->axis[1].size;
 
+  int ki, nk;
+  char* key = NULL, *val = NULL;
+  nk = nrrdKeyValueSize(pnrrd);
+  for(ki=0;ki<nk;ki++) {
+    nrrdKeyValueIndex(pnrrd, &key, &val, ki);
+    keyValuePairs.push_back(pair<string, string>(key, val));
+    free(key);
+    free(val);
+    key = val = NULL;
+  }
+
   cout<<"Loading "<<nparticles<<" particles ("<<nvars
       <<" data values/particles) from \""<<filename<<"\"\n";
 

Modified: trunk/Model/Readers/ParticleNRRD.h
==============================================================================
--- trunk/Model/Readers/ParticleNRRD.h  (original)
+++ trunk/Model/Readers/ParticleNRRD.h  Thu Oct 23 13:06:58 2008
@@ -2,6 +2,7 @@
 #define Manta_Model_ParticleNRRD_h
 
 #include <string>
+#include <vector>
 
 using namespace std;
 
@@ -18,12 +19,16 @@
     float* getParticleData(void) { return pdata; }
 
     void readFile(string const& filename);
+    
+    std::vector<std::pair<std::string, std::string> >& getKeyValuePairs()
+      { return keyValuePairs; }
 
   private:
     float* pdata;
     unsigned int nvars;
     unsigned int nparticles;
     bool nuke;
+    std::vector<std::pair<std::string, std::string> > keyValuePairs;
   };
 }
 

Modified: trunk/Model/Readers/VolumeNRRD.h
==============================================================================
--- trunk/Model/Readers/VolumeNRRD.h    (original)
+++ trunk/Model/Readers/VolumeNRRD.h    Thu Oct 23 13:06:58 2008
@@ -62,7 +62,7 @@
       for(ki=0; ki<nk; ki++) {
         nrrdKeyValueIndex(new_nrrd, &key, &val, ki);
         printf("%s = %s\n", key, val);
-         keyValuePairs->push_back(std::pair<std::string, std::string>(key, 
val));
+        keyValuePairs->push_back(std::pair<std::string, std::string>(key, 
val));
         free(key); free(val);
         key = NULL; val = NULL;
       }
@@ -78,6 +78,8 @@
         
     //_minBound = -size/2.0;
     //_maxBound = size/2.0;
+    double min = FLT_MAX;
+    double max = -FLT_MAX;
     std::cout << "resizing grid\n";      
     grid->resize(new_nrrd->axis[0].size, new_nrrd->axis[1].size, 
new_nrrd->axis[2].size);
     std::cout << "copying nrrd data\n";
@@ -108,7 +110,13 @@
             //                                  (*grid)(k,j,i) = 
((long*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
             //                          if (new_nrrd->type == nrrdTypeULong)
             //                                  (*grid)(k,j,i) = ((unsigned 
long*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+        double val = (*grid)(k,j,i);
+        if ( val < min)
+          min = val;
+        if (val > max)
+          max = val;
     }
+    std::cout << "min/max computed in volume: " << min << " " << max << 
std::endl;
     nrrdNuke(new_nrrd);
     std::cout << "done\n";
     return grid;

Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py     (original)
+++ trunk/scenes/csafe/python/csafe_demo.py     Thu Oct 23 13:06:58 2008
@@ -266,7 +266,7 @@
         for  i in range(0, len(self.scene.nrrdFiles)):
                 self.test.addSphereNrrd(self.scene.nrrdFiles[i])
         #self.test.loadSphereNrrds()
-        self.test.setVolColorMinMax(300, 2100)
+        #self.test.setVolColorMinMax(300, 1800)
         self.test.reloadData()
        
        #self.test.loadVolNrrds()

Modified: trunk/scenes/csafe/src/CDGridSpheres.cc
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.cc     (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.cc     Thu Oct 23 13:06:58 2008
@@ -32,11 +32,11 @@
 CDGridSpheres** CDGridSpheres::__grids = new CDGridSpheres*[256];
 
 CDGridSpheres::CDGridSpheres(float* spheres, int nspheres, int nvars, int 
ncells,
-                                                         int depth, Real 
radius, int ridx, RGBAColorMap* cmap,
-                                                         int cidx) :
+                                    int depth, Real radius, int ridx, 
RGBAColorMap* cmap,
+                                    int cidx, int xindex_) :
 barrier("CDGRidSpheres barrier"), mutex("CDGridSpheres mutex"), 
spheres(spheres), nspheres(nspheres), nvars(nvars),
 radius(radius), ridx(ridx), ncells(ncells), depth(depth),
-cmap(cmap), cidx(cidx), _useAmbientOcclusion(false)
+cmap(cmap), cidx(cidx), _useAmbientOcclusion(false), xindex(xindex_)
 {
   __grids[__numGrids] = this;
   __numGrids++;
@@ -180,12 +180,12 @@
 
 
         // Build grid
-        cerr<<"Building GridSpheres\n";
+        cerr<<"Building GridSpheres xindex: " << xindex << "\n";
 
         timer.start();
 
-        cerr<<"  min:  ("<<min[0]<<", "<<min[1]<<", "<<min[2]<<")\n";
-        cerr<<"  max:  ("<<max[0]<<", "<<max[1]<<", "<<max[2]<<")\n";
+        cerr<<"  min:  ("<<min[xindex]<<", "<<min[xindex+1]<<", 
"<<min[xindex+2]<<")\n";
+        cerr<<"  max:  ("<<max[xindex]<<", "<<max[xindex+1]<<", 
"<<max[xindex+2]<<")\n";
 
         // Determine the maximum radius
         if (ridx>0) {
@@ -274,7 +274,7 @@
                         current_radius=Vector(radius, radius, radius);
                 }
 
-                Vector center(data[0], data[1], data[2]);
+                Vector center(data[xindex], data[xindex+1], data[xindex+2]);
                 BBox box(center - current_radius, center + current_radius);
                 int sx, sy, sz, ex, ey, ez;
                 transformToLattice(box, sx, sy, sz, ex, ey, ez);
@@ -346,7 +346,7 @@
                         current_radius=Vector(radius, radius, radius);
                 }
 
-                Vector center(data[0], data[1], data[2]);
+                Vector center(data[xindex], data[xindex+1], data[xindex+2]);
                 BBox box(center - current_radius, center + current_radius);
                 int sx, sy, sz, ex, ey, ez;
                 transformToLattice(box, sx, sy, sz, ex, ey, ez);
@@ -452,8 +452,8 @@
 
         // Bound the spheres
         Vector mr(max_radius, max_radius, max_radius);
-        bbox.reset(Vector(min[0], min[1], min[2]) - mr,
-                           Vector(max[0], max[1], max[2]) + mr);
+        bbox.reset(Vector(min[xindex], min[xindex+1], min[xindex+2]) - mr,
+                           Vector(max[xindex], max[xindex+1], max[xindex+2]) 
+ mr);
 
         const Vector eps3(1.e-3, 1.e-3, 1.e-3);
         bbox.extendByPoint(bbox.getMin() - eps3);
@@ -630,7 +630,7 @@
   rays.computeHitPositions();
   for (int i=int(rays.begin()); i<int(rays.end()); ++i) {
     float* data=spheres + rays.scratchpad<int>(i);
-    Vector n=rays.getHitPosition(i) - Vector(data[0], data[1], data[2]);
+    Vector n=rays.getHitPosition(i) - Vector(data[xindex], data[xindex+1], 
data[xindex+2]);
 
 /*if (ridx>0) {
      if (data[ridx] <= 0.0)
@@ -921,11 +921,11 @@
 
 #ifdef USE_OPTIMIZED_FCNS
                                 // Intersect the sphere using the 
appropriately optimized function
-                                (*this.*intersectSphere)(rays, ray_idx, 
start + j,
-                                                                             
    Vector(data[0], data[1], data[2]), radius2);
+                                (*this.*intersectSphere)(rays, ray_idx, 
start + j,                                                                    
            
+                                          Vector(data[xindex], 
data[xindex+1], data[xindex+2]), radius2);
 #else
                                 intersectSphereDefault(rays, ray_idx, start 
+ j,
-                                                                           
Vector(data[0], data[1], data[2]), radius2);
+                                       Vector(data[xindex], data[xindex+1], 
data[xindex+2]), radius2);
 #endif
                                }
                         }

Modified: trunk/scenes/csafe/src/CDGridSpheres.h
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.h      (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.h      Thu Oct 23 13:06:58 2008
@@ -30,8 +30,13 @@
     public TexCoordMapper, public Texture<Color>
     {
     public:
+      //! constructor
+      /*! \param ncells affects the grenularity of cells, higher numbers mean
+      // more memory
+      // \param xindex is the index of the x values (y and z should be after)
+      */
       CDGridSpheres(float* spheres, int nspheres, int nvars, int ncells, int 
depth,
-                    Real radius, int ridx, RGBAColorMap* cmap, int cidx);
+                    Real radius, int ridx, RGBAColorMap* cmap, int cidx, int 
xindex = 0);
       ~CDGridSpheres(void);
                
       void preprocess(const PreprocessContext&);
@@ -156,6 +161,7 @@
   AmbientOcclusion* _ao;
   bool _useAmbientOcclusion;
   Material* _matl;
+  int xindex;
 
   static CDGridSpheres** __grids;
   static int __numGrids;

Modified: trunk/scenes/csafe/src/CDTest.h
==============================================================================
--- trunk/scenes/csafe/src/CDTest.h     (original)
+++ trunk/scenes/csafe/src/CDTest.h     Thu Oct 23 13:06:58 2008
@@ -51,6 +51,7 @@
 
 #include <vector>
 #include <string>
+#include <sstream>
 
 #define PRECOMPUTE_GRIDS 1
 #define USE_GRIDSPHERES 1
@@ -219,7 +220,7 @@
     }
   void setClippingBBoxHelper(int, int)
     {
-      Vector min = tempMin;
+      /*Vector min = tempMin;
       Vector max = tempMax;
       for(int i =0; i < 3; i++)
         setClipMinMax(i, min[i], max[i]);
@@ -242,7 +243,7 @@
             tmax[j] = std::min(maxB[j], bounds[1][j]) - T_EPSILON;
           }
          _volPrims[i]->setMinMax(tmin, tmax);
-       }
+          }*/
     }
   void useClippingBBox(bool st)
     {
@@ -351,12 +352,21 @@
            cerr << "fatal IO error: expected a sphere file with at least 3 
data indices\n";
            exit(2);
          }
+          int xindex = 0;
+          std::vector<std::pair<string, string> >& keyValuePairs = 
pnrrd->getKeyValuePairs();
+          for(int i =0; i < keyValuePairs.size(); i++) {
+            if (keyValuePairs[i].first == "p.x (x) index") {
+              stringstream stream(keyValuePairs[i].second);
+              stream >> xindex;
+              cout << "found xindex: " << xindex << endl;
+            }
+          }
          _spherePNrrds.push_back(pnrrd);
          Group* group = new Group();
                 
 #if USE_GRIDSPHERES
          RGBAColorMap* cmap = new RGBAColorMap(1);
-         CDGridSpheres* grid = new CDGridSpheres(pnrrd->getParticleData(), 
pnrrd->getNParticles(), pnrrd->getNVars(), 4, 2,_radius, _ridx, cmap , 
_cidx); 
+         CDGridSpheres* grid = new CDGridSpheres(pnrrd->getParticleData(), 
pnrrd->getNParticles(), pnrrd->getNVars(), 4, 2,_radius, _ridx, cmap , _cidx, 
xindex); 
          //grid->setCMinMax(4, 299.50411987304688, 500.59423828125);
          //Material* matl = new Phong(Color(RGB(1,0,0)), Color(RGB(1,0,0)), 
10);
          //Material* matl = new AmbientOcclusion(colormap, 0.01, 10);
@@ -371,7 +381,8 @@
            float* data = pnrrd->getParticleData() + i*pnrrd->getNVars();
            if (_ridx > -1)
              radius = data[_ridx];
-           g->add(new CSAFEPrim(new Sphere(_sphereMatl, 
Vector(data[0],data[1],data[2]),radius), data));
+            g->add(new Sphere(new Lambertian(Color(RGB(1,0,0))), 
Vector(data[xindex], data[xindex+1], data[xindex+2]), radius));
+           //g->add(new CSAFEPrim(new Sphere(_sphereMatl, 
Vector(data[xindex],data[xindex+1],data[xindex+2]),radius), data));
            //          g->add( new ValuePrimitive<float>(new Sphere(matl, 
Vector(data[0],data[1],data[2]),data[_ridx]), data[_cidx]));
            //                          g->add(new Sphere(matl, 
Vector(data[0], data[1], data[2]), data[_ridx]));
          }
@@ -465,7 +476,7 @@
                     min[2], max[0], max[1], max[2]); 
             }
             }
-         Volume<float>* mat = new Volume<float>(grid, _volCMap, BBox(min, 
max), 0.00125, 3, NULL, _forceDataMin, _forceDataMax);
+         Volume<float>* mat = new Volume<float>(grid, _volCMap, BBox(min, 
max), 0.0125, 3, NULL, _forceDataMin, _forceDataMax);
          Cube* vol = new Cube(mat, min, max);
           group->add(vol);
           //#  group->add(vol);


  • [Manta] r2339 - in trunk: Model/Readers scenes/csafe/python scenes/csafe/src, brownlee, 10/23/2008

Archive powered by MHonArc 2.6.16.

Top of page