Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1153 - in trunk: DynLT Interface Model/Groups scenes


Chronological Thread 
  • From: cgribble@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1153 - in trunk: DynLT Interface Model/Groups scenes
  • Date: Fri, 21 Jul 2006 09:27:24 -0600 (MDT)

Author: cgribble
Date: Fri Jul 21 09:27:23 2006
New Revision: 1153

Added:
   trunk/DynLT/DynLTParticles.cc
   trunk/DynLT/DynLTParticles.h
Removed:
   trunk/DynLT/DynTimeSteppedParticles.cc
   trunk/DynLT/DynTimeSteppedParticles.h
Modified:
   trunk/DynLT/CMakeLists.txt
   trunk/DynLT/DynLTGridSpheres.h
   trunk/Interface/Callback.h
   trunk/Interface/CallbackHelpers.h
   trunk/Model/Groups/TimeSteppedParticles.cc
   trunk/Model/Groups/TimeSteppedParticles.h
   trunk/scenes/dynlt.cc
Log:
I was hoping there was a more elegant solution to the circular dependency 
between
Manta_DynLT and Manta_Model, but Abe's hack seemed to do the trick; luckily, 
the
time stepped particles is a pretty light-weight class so wont' be a lot of 
code
duplication

scenes/dynlt.cc
  Reflect changes to naming, etc.

DynLT/DynLTGridSpheres.h
  Added accessor for getting the number of particles

DynLT/CMakeLists.txt
DynLT/DynLTParticles.cc
DynLT/DynLTParticles.h
DynLT/DynTimeSteppedParticles.cc
DynLT/DynTimeSteppedParticles.h
  Moved DynTimeSteppedParticles.{h,cc} to DynLTParticles.{h,cc}
  Added accessor for getting the number of particles of a given time step

Model/Groups/TimeSteppedParticles.h
Model/Groups/TimeSteppedParticles.cc
  Removed unused DynLTQueue pointer

Interface/Callback.h
Interface/CallbackHelpers.h
  Added CallbackBase_1Data create(...) function for static 1 Data, 0 Arg
    callbacks
  Added Callback_Static_1Data_0Arg class for static 1 Data, 0 Arg callbacks


Modified: trunk/DynLT/CMakeLists.txt
==============================================================================
--- trunk/DynLT/CMakeLists.txt  (original)
+++ trunk/DynLT/CMakeLists.txt  Fri Jul 21 09:27:23 2006
@@ -4,14 +4,14 @@
     DynLTContext.cc
     DynLTGridSpheres.h
     DynLTGridSpheres.cc
+    DynLTParticles.h
+    DynLTParticles.cc
     DynLTQueue.h
     DynLTQueue.cc
     DynLTStatsCollector.h
     DynLTStatsCollector.cc
     DynLTWorker.h
     DynLTWorker.cc
-    DynTimeSteppedParticles.h
-    DynTimeSteppedParticles.cc
     )
 
 INCLUDE_DIRECTORIES(${FOUND_TEEM_INCLUDE})

Modified: trunk/DynLT/DynLTGridSpheres.h
==============================================================================
--- trunk/DynLT/DynLTGridSpheres.h      (original)
+++ trunk/DynLT/DynLTGridSpheres.h      Fri Jul 21 09:27:23 2006
@@ -52,6 +52,8 @@
 
     void shade(const RenderContext& context, RayPacket& rays) const;
 
+    unsigned int getNParticles(void) const { return nspheres; }
+
     const LightSet* getActiveLights(void) const { return activeLights; }
 
     unsigned int getTextureMode(void) const { return textureMode; }

Added: trunk/DynLT/DynLTParticles.cc
==============================================================================
--- (empty file)
+++ trunk/DynLT/DynLTParticles.cc       Fri Jul 21 09:27:23 2006
@@ -0,0 +1,83 @@
+
+#include <Core/Exceptions/InputError.h>
+#include <Core/Exceptions/OutputError.h>
+
+
+#include <DynLT/DynLTGridSpheres.h>
+#include <DynLT/DynLTParticles.h>
+#include <Model/Primitives/GridSpheres.h>
+#include <Model/Readers/ParticleNRRD.h>
+
+#include <fstream>
+using std::ifstream;
+
+#include <iostream>
+using std::cerr;
+
+using namespace Manta;
+
+DynLTParticles::DynLTParticles(const string& filename, int ncells, int depth,
+                               Real radius, int ridx, RegularColorMap* cmap,
+                               int cidx, DynLTQueue* queue, int min, int 
max) :
+  tstep(0)
+{
+  // Check for a single timestep
+  string::size_type pos=filename.find(".nrrd", 0);
+  if (pos != string::npos) {
+    ParticleNRRD pnrrd(filename);
+    add(new DynLTGridSpheres(queue, pnrrd.getParticleData(),
+                             pnrrd.getNParticles(), pnrrd.getNVars(), ncells,
+                             depth, radius, ridx, cmap, cidx));
+    return;
+  }
+
+  // Load multiple timesteps
+  ifstream in(filename.c_str());
+  if (!in.is_open())
+    throw InputError("Failed to open \"" + filename + "\" for reading\n");
+
+  string fname;
+  unsigned int nskipped=0;
+  unsigned int nloaded=0;
+  while (!in.eof() && min + nloaded < max) {
+    // Read the timestep filename
+    in>>fname;
+
+    // Ignore timesteps below the minimum
+    if (nskipped<min) {
+      ++nskipped;
+      continue;
+    }
+
+    // Load the particle data
+    ParticleNRRD pnrrd(fname);
+    add(new DynLTGridSpheres(queue, pnrrd.getParticleData(),
+                             pnrrd.getNParticles(), pnrrd.getNVars(), ncells,
+                             depth, radius, ridx, cmap, cidx));
+
+    ++nloaded;
+  }
+
+  in.close();
+}
+
+DynLTParticles::~DynLTParticles(void)
+{
+  // Do nothing
+}
+
+void DynLTParticles::intersect(const RenderContext& context,
+                               RayPacket& rays) const
+{
+  // Fetch the current timestep
+  const Object* obj=get(tstep);
+  obj->intersect(context, rays);
+}
+
+void DynLTParticles::computeBounds(const PreprocessContext& context,
+                                   BBox& bbox) const
+{
+  // Fetch the current timestep
+  const Object* obj=get(tstep);
+  obj->computeBounds(context, bbox);
+}

Added: trunk/DynLT/DynLTParticles.h
==============================================================================
--- (empty file)
+++ trunk/DynLT/DynLTParticles.h        Fri Jul 21 09:27:23 2006
@@ -0,0 +1,41 @@
+
+#ifndef Manta_DynLT_DynLTParticles_h
+#define Manta_DynLT_DynLTParticles_h
+
+#include <MantaTypes.h>
+#include <Model/Groups/Group.h>
+#include <SCIRun/Core/Thread/Mailbox.h>
+
+#include <limits.h>
+
+namespace Manta
+{
+  class DynLTQueue;
+  class RegularColorMap;
+
+  class DynLTParticles : public Group
+  {
+  public:
+    DynLTParticles(const string& filename, int ncells, int depth, Real 
radius,
+                   int ridx, RegularColorMap* cmap, int cidx, DynLTQueue* 
queue,
+                   int min=0, int max=INT_MAX);
+    ~DynLTParticles(void);
+
+    void intersect(const RenderContext& context, RayPacket& rays) const;
+    void computeBounds(const PreprocessContext& context, BBox& bbox) const;
+
+    unsigned int getNParticles(int tstep) const
+    {
+      return dynamic_cast<const 
DynLTGridSpheres*>(get(tstep))->getNParticles();
+    }
+
+    // GUI interface
+    void next(void) { tstep=(tstep + 1)%getSize(); }
+    void previous(void) { tstep=(tstep + getSize() - 1)%getSize(); }
+
+  private:
+    int tstep;
+  };
+}
+
+#endif // Manta_DynLT_DynLTParticles_h

Modified: trunk/Interface/Callback.h
==============================================================================
--- trunk/Interface/Callback.h  (original)
+++ trunk/Interface/Callback.h  Fri Jul 21 09:27:23 2006
@@ -26,6 +26,8 @@
 
     ////////////////////////////////////////////////////////////
     // Global functin or static class member functions
+
+    // 0 Data
     static
     CallbackBase_0Data*
     create(void (*pmf)()) {
@@ -44,6 +46,14 @@
       return new Callback_Static_0Data_2Arg<Arg1,Arg2>(pmf, arg1, arg2);
     }
 
+    // 1 Data
+    template<typename Data1> static
+    CallbackBase_1Data<Data1>*
+    create(void (*pmf)(Data1)) {
+      return new Callback_Static_1Data_0Arg<Data1>(pmf);
+    }
+
+    // 2 Data
     template<typename Data1, typename Data2,
              typename Arg1, typename Arg2> static
     CallbackBase_2Data<Data1, Data2>*
@@ -58,6 +68,7 @@
       return new Callback_Static_2Data_0Arg<Data1, Data2>(pmf);
     }
 
+    // 3 Data
     template<typename Data1, typename Data2, typename Data3,
              typename Arg1, typename Arg2> static
     CallbackBase_3Data<Data1, Data2, Data3>*

Modified: trunk/Interface/CallbackHelpers.h
==============================================================================
--- trunk/Interface/CallbackHelpers.h   (original)
+++ trunk/Interface/CallbackHelpers.h   Fri Jul 21 09:27:23 2006
@@ -187,6 +187,25 @@
     Arg2 arg2;
   };
   
+  // 1 Data
+  template<typename Data1>
+  class Callback_Static_1Data_0Arg : public CallbackBase_1Data<Data1> {
+  public:
+    Callback_Static_1Data_0Arg(void (*pmf)(Data1))
+      : pmf(pmf)
+    {
+    }
+    virtual ~Callback_Static_1Data_0Arg()
+    {
+    }
+    virtual void call(Data1 data1)
+    {
+      pmf(data1);
+    }
+  private:
+    void (*pmf)(Data1);
+  };
+
   // 2 Data
   template<typename Data1, typename Data2>
   class Callback_Static_2Data_0Arg : public CallbackBase_2Data<Data1, Data2> 
{

Modified: trunk/Model/Groups/TimeSteppedParticles.cc
==============================================================================
--- trunk/Model/Groups/TimeSteppedParticles.cc  (original)
+++ trunk/Model/Groups/TimeSteppedParticles.cc  Fri Jul 21 09:27:23 2006
@@ -1,7 +1,6 @@
 
 #include <Core/Exceptions/InputError.h>
 #include <Core/Exceptions/OutputError.h>
-
 #include <Model/Groups/TimeSteppedParticles.h>
 #include <Model/Primitives/GridSpheres.h>
 #include <Model/Readers/ParticleNRRD.h>
@@ -17,7 +16,6 @@
 TimeSteppedParticles::TimeSteppedParticles(const string& filename, int 
ncells,
                                            int depth, Real radius, int ridx,
                                            RegularColorMap* cmap, int cidx,
-                                           DynLTQueue* queue,
                                            int min, int max) :
   tstep(0)
 {
@@ -25,9 +23,9 @@
   string::size_type pos=filename.find(".nrrd", 0);
   if (pos != string::npos) {
     ParticleNRRD pnrrd(filename);
-      add(new GridSpheres(pnrrd.getParticleData(), pnrrd.getNParticles(),
-                          pnrrd.getNVars(), ncells, depth, radius, ridx, 
cmap,
-                          cidx));
+    add(new GridSpheres(pnrrd.getParticleData(), pnrrd.getNParticles(),
+                        pnrrd.getNVars(), ncells, depth, radius, ridx, cmap,
+                        cidx));
 
     return;
   }
@@ -53,9 +51,9 @@
     // Load the particle data
     ParticleNRRD pnrrd(fname);
 
-      add(new GridSpheres(pnrrd.getParticleData(), pnrrd.getNParticles(),
-                          pnrrd.getNVars(), ncells, depth, radius, ridx, 
cmap,
-                          cidx));
+    add(new GridSpheres(pnrrd.getParticleData(), pnrrd.getNParticles(),
+                        pnrrd.getNVars(), ncells, depth, radius, ridx, cmap,
+                        cidx));
 
 
     ++nloaded;

Modified: trunk/Model/Groups/TimeSteppedParticles.h
==============================================================================
--- trunk/Model/Groups/TimeSteppedParticles.h   (original)
+++ trunk/Model/Groups/TimeSteppedParticles.h   Fri Jul 21 09:27:23 2006
@@ -13,7 +13,6 @@
 
 namespace Manta
 {
-  class DynLTQueue;
   class RegularColorMap;
 
   class TimeSteppedParticles : public Group
@@ -21,8 +20,7 @@
   public:
     TimeSteppedParticles(const string& filename, int ncells, int depth,
                          Real radius, int ridx, RegularColorMap* cmap, int 
cidx,
-                         DynLTQueue* queue=0, int min=0,
-                         int max=INT_MAX);
+                         int min=0, int max=INT_MAX);
     ~TimeSteppedParticles(void);
 
     void intersect(const RenderContext& context, RayPacket& rays) const;

Modified: trunk/scenes/dynlt.cc
==============================================================================
--- trunk/scenes/dynlt.cc       (original)
+++ trunk/scenes/dynlt.cc       Fri Jul 21 09:27:23 2006
@@ -3,12 +3,12 @@
 #include <Core/Exceptions/IllegalArgument.h>
 #include <Core/Geometry/Vector.h>
 #include <Core/Util/Args.h>
+#include <DynLT/DynLTContext.h>
 #include <DynLT/DynLTGridSpheres.h>
+#include <DynLT/DynLTParticles.h>
 #include <DynLT/DynLTQueue.h>
 #include <DynLT/DynLTStatsCollector.h>
 #include <DynLT/DynLTWorker.h>
-#include <DynLT/DynLTContext.h>
-#include <DynLT/DynTimeSteppedParticles.h>
 #include <Interface/Context.h>
 #include <Interface/LightSet.h>
 #include <Interface/MantaInterface.h>
@@ -239,9 +239,9 @@
     RegularColorMap* cmap=new RegularColorMap(type);
 
     // Load particle data, add particles to group
-    DynTimeSteppedParticles* tsteps=new DynTimeSteppedParticles(fname, 
ncells, depth,
-                                                          radius, ridx, 
cmap, cidx,
-                                                          queue);
+    DynLTParticles* tsteps=new DynLTParticles(fname, ncells, depth, radius,
+                                              ridx, cmap, cidx, queue);
+    queue->resizeHeapIdx(tsteps->getNParticles(0));
 
     // Initialize the scene
     if (env_fname != "" && use_envmap)




  • [MANTA] r1153 - in trunk: DynLT Interface Model/Groups scenes, cgribble, 07/21/2006

Archive powered by MHonArc 2.6.16.

Top of page