include/VoxelGrid.h
Go to the documentation of this file.
00001 #ifndef VOXELGRID_H
00002 #define VOXELGRID_H
00003 
00004 #include <ngl/Vec3.h>
00005 #include <ngl/VertexArrayObject.h>
00006 #include <ngl/VAOPrimitives.h>
00007 
00008 //----------------------------------------------------------------------------------------------------------------------
00018 
00019 enum BOUNDARYCONDITION {NOSLIP, FREESLIP, OUTFLOW};
00020 
00021 enum CELLTYPE {SMOKE, SOLID};
00022 
00023 enum {U, V, W};
00024 
00025 struct Voxel {
00026   CELLTYPE cellType;
00027   float pressure;
00028   float density;
00029   float temperature;
00030   float curlMag; //the magnitude (length) of the curl
00031   float tempCurlMag;
00032   float u [3];
00033   float tempU [3];
00034   float tempDensity;
00035   float tempPressure;
00036   float tempTemperature;
00037   float F,G,H;
00038   float rhs;
00039 };
00040 
00041 
00042 class VoxelGrid
00043 {
00044 public:
00045   //----------------------------------------------------------------------------------------------------------------------
00051   //----------------------------------------------------------------------------------------------------------------------
00052   VoxelGrid(
00053             const float _lengthX,
00054             const float _lengthY,
00055             const float _lengthZ,
00056             const int _baseRes
00057             );
00058   //----------------------------------------------------------------------------------------------------------------------
00060   //----------------------------------------------------------------------------------------------------------------------
00061   ~VoxelGrid();
00062   //----------------------------------------------------------------------------------------------------------------------
00068   //----------------------------------------------------------------------------------------------------------------------
00069   ngl::Vec3 array3DIndexesFromCoordinate(
00070                                           float _i,
00071                                           float _j,
00072                                           float _k
00073                                          ) const;
00074   //----------------------------------------------------------------------------------------------------------------------
00080   //----------------------------------------------------------------------------------------------------------------------
00081   int arrayIndexFromCoordinate(
00082                                 float _i,
00083                                 float _j,
00084                                 float _k
00085                                ) const;
00086   //----------------------------------------------------------------------------------------------------------------------
00093   //----------------------------------------------------------------------------------------------------------------------
00094   Voxel* at(
00095             float _i,
00096             float _j,
00097             float _k
00098            );
00099   //----------------------------------------------------------------------------------------------------------------------
00101   //----------------------------------------------------------------------------------------------------------------------
00102   void createLineGrids();
00103   //----------------------------------------------------------------------------------------------------------------------
00105   //----------------------------------------------------------------------------------------------------------------------
00106   void createVAO();
00107   //----------------------------------------------------------------------------------------------------------------------
00109   //----------------------------------------------------------------------------------------------------------------------
00110   void drawLineGrids();
00111   //----------------------------------------------------------------------------------------------------------------------
00117   //----------------------------------------------------------------------------------------------------------------------
00118   Voxel* freeSlip(
00119                   float _i,
00120                   float _j,
00121                   float _k
00122                  );
00123   //----------------------------------------------------------------------------------------------------------------------
00126   //----------------------------------------------------------------------------------------------------------------------
00127   inline float getBaseRes() const { return m_baseRes; }
00128   //----------------------------------------------------------------------------------------------------------------------
00131   //----------------------------------------------------------------------------------------------------------------------
00132   inline BOUNDARYCONDITION getBoundaryCondition() const { return m_boundaryCondition; }
00133   //----------------------------------------------------------------------------------------------------------------------
00136   //----------------------------------------------------------------------------------------------------------------------
00137   inline float getH() const { return m_h; }
00138   //----------------------------------------------------------------------------------------------------------------------
00141   //----------------------------------------------------------------------------------------------------------------------
00142   inline float getHX() const { return m_hX; }
00143   //----------------------------------------------------------------------------------------------------------------------
00146   //----------------------------------------------------------------------------------------------------------------------
00147   inline float getHY() const { return m_hY; }
00148   //----------------------------------------------------------------------------------------------------------------------
00151   //----------------------------------------------------------------------------------------------------------------------
00152   inline float getHZ() const { return m_hZ; }
00153   //----------------------------------------------------------------------------------------------------------------------
00156   //----------------------------------------------------------------------------------------------------------------------
00157   inline float getLengthX() const { return m_lengthX; }
00158   //----------------------------------------------------------------------------------------------------------------------
00161   //----------------------------------------------------------------------------------------------------------------------
00162   inline float getLengthY() const { return m_lengthY; }
00163   //----------------------------------------------------------------------------------------------------------------------
00166   //----------------------------------------------------------------------------------------------------------------------
00167   inline float getLengthZ() const { return m_lengthZ; }
00168   //----------------------------------------------------------------------------------------------------------------------
00171   //----------------------------------------------------------------------------------------------------------------------
00172   inline ngl::VertexArrayObject* getLineGridVAO() { return m_lineGridVAO; }
00173   //----------------------------------------------------------------------------------------------------------------------
00176   //----------------------------------------------------------------------------------------------------------------------
00177   inline int getPrecisionX() const { return m_precisionX; }
00178   //----------------------------------------------------------------------------------------------------------------------
00181   //----------------------------------------------------------------------------------------------------------------------
00182   inline int getPrecisionY() const { return m_precisionY; }
00183   //----------------------------------------------------------------------------------------------------------------------
00186   //----------------------------------------------------------------------------------------------------------------------
00187   inline int getPrecisionZ() const { return m_precisionZ; }
00188   //----------------------------------------------------------------------------------------------------------------------
00191   //----------------------------------------------------------------------------------------------------------------------
00192   inline  std::vector <Voxel>* getVoxels() { return &m_voxels; }
00193   //----------------------------------------------------------------------------------------------------------------------
00195   //----------------------------------------------------------------------------------------------------------------------
00196   void calcValues();
00197   //----------------------------------------------------------------------------------------------------------------------
00199   //----------------------------------------------------------------------------------------------------------------------
00200   void initVoxels();
00201   //----------------------------------------------------------------------------------------------------------------------
00207   //----------------------------------------------------------------------------------------------------------------------
00208   Voxel* outflow(
00209                   float _i,
00210                   float _j,
00211                   float _k
00212                  );
00213   //----------------------------------------------------------------------------------------------------------------------
00219   //----------------------------------------------------------------------------------------------------------------------
00220   Voxel* noSlip(
00221                 float _i,
00222                 float _j,
00223                 float _k
00224                );
00225   //----------------------------------------------------------------------------------------------------------------------
00228   //----------------------------------------------------------------------------------------------------------------------
00229   inline void setBaseRes(
00230                           int _res
00231                          ) { m_baseRes = _res;}
00232   //----------------------------------------------------------------------------------------------------------------------
00235   //----------------------------------------------------------------------------------------------------------------------
00236   inline void setBoundaryCondition(
00237                                     const BOUNDARYCONDITION _condition
00238                                    ) { m_boundaryCondition = _condition; }
00239   //----------------------------------------------------------------------------------------------------------------------
00242   //----------------------------------------------------------------------------------------------------------------------
00243   inline void setH(
00244                     float _val
00245                    ) { m_h = _val; }
00246   //----------------------------------------------------------------------------------------------------------------------
00249   //----------------------------------------------------------------------------------------------------------------------
00250   inline void setLengthX(
00251                           float _length
00252                          ) { m_lengthX = _length;}
00253   //----------------------------------------------------------------------------------------------------------------------
00256   //----------------------------------------------------------------------------------------------------------------------
00257   inline void setLengthY(
00258                           float _length
00259                          ) { m_lengthY = _length; }
00260   //----------------------------------------------------------------------------------------------------------------------
00263   //----------------------------------------------------------------------------------------------------------------------
00264   inline void setLengthZ(
00265                           float _length
00266                          ) { m_lengthZ = _length; }
00267   //----------------------------------------------------------------------------------------------------------------------
00270   //----------------------------------------------------------------------------------------------------------------------
00271   inline void setPrecisionX(
00272                             int _precision
00273                            ) { m_precisionX = _precision; }
00274   //----------------------------------------------------------------------------------------------------------------------
00277   //----------------------------------------------------------------------------------------------------------------------
00278   inline void setPrecisionY(
00279                             int _precision
00280                            ) { m_precisionY = _precision; }
00281   //----------------------------------------------------------------------------------------------------------------------
00284   //----------------------------------------------------------------------------------------------------------------------
00285   inline void setPrecisionZ(
00286                             int _precision
00287                            ) { m_precisionZ = _precision; }
00288 
00289 
00290 private:
00291   //----------------------------------------------------------------------------------------------------------------------
00293   //----------------------------------------------------------------------------------------------------------------------
00294   int m_baseRes;
00295   //----------------------------------------------------------------------------------------------------------------------
00297   //----------------------------------------------------------------------------------------------------------------------
00298   BOUNDARYCONDITION m_boundaryCondition;
00299   //----------------------------------------------------------------------------------------------------------------------
00301   //----------------------------------------------------------------------------------------------------------------------
00302   std::vector <ngl::vertData> m_data;
00303   //----------------------------------------------------------------------------------------------------------------------
00305   //----------------------------------------------------------------------------------------------------------------------
00306   Voxel m_boundaryVoxel;
00307   //----------------------------------------------------------------------------------------------------------------------
00309   //----------------------------------------------------------------------------------------------------------------------
00310   float m_h;
00311   //----------------------------------------------------------------------------------------------------------------------
00313   //----------------------------------------------------------------------------------------------------------------------
00314   float m_hX;
00315   //----------------------------------------------------------------------------------------------------------------------
00317   //----------------------------------------------------------------------------------------------------------------------
00318   float m_hY;
00319   //----------------------------------------------------------------------------------------------------------------------
00321   //----------------------------------------------------------------------------------------------------------------------
00322   float m_hZ;
00323   //----------------------------------------------------------------------------------------------------------------------
00325   //----------------------------------------------------------------------------------------------------------------------
00326   float m_lengthX;
00327   //----------------------------------------------------------------------------------------------------------------------
00329   //----------------------------------------------------------------------------------------------------------------------
00330   float m_lengthY;
00331   //----------------------------------------------------------------------------------------------------------------------
00333   //----------------------------------------------------------------------------------------------------------------------
00334   float m_lengthZ;
00335   //----------------------------------------------------------------------------------------------------------------------
00337   //----------------------------------------------------------------------------------------------------------------------
00338   int m_precisionX;
00339   //----------------------------------------------------------------------------------------------------------------------
00341   //----------------------------------------------------------------------------------------------------------------------
00342   int m_precisionY;
00343   //----------------------------------------------------------------------------------------------------------------------
00345   //----------------------------------------------------------------------------------------------------------------------
00346   int m_precisionZ;
00347   //----------------------------------------------------------------------------------------------------------------------
00349   //----------------------------------------------------------------------------------------------------------------------
00350   ngl::VertexArrayObject *m_lineGridVAO;
00351   //----------------------------------------------------------------------------------------------------------------------
00353   //----------------------------------------------------------------------------------------------------------------------
00354   std::vector <Voxel> m_voxels;
00355 
00356 };
00357 
00358 #endif // VOXELGRID_H
 All Classes Files Functions Variables