Eigene Dateien/FlowVis/src/VFlowData.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #ifndef _v_flow_data_h
00004 #define _v_flow_data_h
00005 
00006 #include "VVector.h"
00007 
00008 #include <string>
00009 #include <vector>
00010 
00011 #include "VgridHeader.h"
00012 #include "VtimeStep.h"
00013 #include "VProgram.h"
00014 #include "VMatrix.h"
00015 #include "VFramebufferObject.h"
00016 #include "VStreamLine.h"
00017 #include "VIcon.h"
00018 
00019 struct vVector4Dim
00020 {
00021         float x;
00022         float y;
00023         float z;
00024         float w;
00025 };
00026 
00030 enum PlacingMethod
00031 {
00032         LEFT = 0,               
00033         TOP,                    
00034         BOTTOM,                 
00035         RIGHT,
00036         ALL,
00037         RANDOM,
00038         MANUAL,
00039         EVEN
00040 };
00041 
00045 class VFlowData
00046 {
00047 public:
00048 
00052         VFlowData();
00053 
00057         ~VFlowData();
00058 
00064         VFlowData( std::string m_FileName );
00065 
00071         bool loadData( std::string m_FileName );
00072 
00079         bool loadData( std::string m_FileName, std::string m_DatFilename);
00080 
00085         void draw( int m_TimeStep = 0 );
00086 
00091         void drawPoints( int m_TimeStep = 0 );
00092 
00096         void drawStreamLines( VVector  *col);
00097 
00101         void drawIcons();
00102 
00108         void addIconPoint(float x, float y);
00109 
00114         void drawTextureTest( int m_TimeStep = 0 );
00115 
00120         int getNumDataValues()
00121         {
00122                 return mHeader.mNF + 1;
00123         }
00124 
00129         int getNumTimeSteps()
00130         {
00131                 return mHeader.mNT;
00132         }
00133 
00138         VVector getFlowCenter()
00139         {
00140                 return mCenterPos;
00141         }
00142 
00147         VVector getMinPos()
00148         {
00149                 return mMinPos;
00150         }
00151 
00156         VVector getMaxPos()
00157         {
00158                 return mMaxPos;
00159         }
00160 
00165         VVector getFlowExtends()
00166         {
00167                 return mExtends;
00168         }
00169 
00170         float * getExtends()
00171         {
00172                 return mExtends.getPtr();
00173         }
00174 
00179         float getMaximalMagnitude()
00180         {
00181                 return maxDataValues[ 0 ];
00182         }
00183 
00188         float getMinimalMagnitude()
00189         {
00190                 return minDataValues[ 0 ];
00191         }
00192 
00193 
00199         float getMaximalDatavalue( int index )
00200         {
00201                 return maxDataValues[ index ];
00202         }
00203 
00209         float getMinimalDatavalue( int index )
00210         {
00211                 return minDataValues[ index ];
00212         }
00213 
00218         bool getTexturesGenerated()
00219         {
00220                 return mTexturesGenerated;
00221         }
00222 
00227         void setStreamlinesSeedSeparation( float val )
00228         {
00229                 mStreamlinesSeedSeparation = val;
00230         }
00231 
00236         void setStreamlinesTestSeparation( float val )
00237         {
00238                 mStreamlinesTestSeparation = val;
00239         }
00240 
00245         void setStreamlinesSteps( float val )
00246         {
00247                 mStreamlinesSteps = val;
00248         }
00249 
00254         void setStreamlinesDt( float val )
00255         {
00256                 mStreamlinesDt = val;
00257         }
00258 
00263         void setTaperingState( bool state )
00264         {
00265                 mTapering = state;
00266         }
00267 
00272         void setStrGlyphes( bool state )
00273         {
00274                 mStrGlyphes = state;
00275         }
00276 
00277         void setTaperingScale( float val )
00278         {
00279                 mTaperingScale = val;
00280         }
00281 
00285         void setIntegrationMethod( bool val )
00286         {
00287                 mEuler = (val) ? 1.0f : 0.0f;
00288         }
00289 
00295         void generateGlyphIndices( int m_NumX, int m_NumY );
00296 
00300         void generateTextures();
00301 
00308         void generateCPUStreamLines(  float m_MaxSteps, float m_StreamSeparation, int m_TimeStep = 0 );
00309 
00321         std::vector<VVector> VFlowData::generateCPUStreamSingleWithTests( std::vector<VStreamLine> otherStreamlines, 
00322                 float x, float y, float m_MaxSteps, float dtest, int m_TimeStep /* = 0  */);
00323 
00333         std::vector<VVector> VFlowData::generateCPUStreamSingleWithoutTests( float x, float y, float dtest, 
00334                 float m_MaxSteps, int m_TimeStep /* = 0  */ );
00335 
00336 
00343         void VFlowData::generateCPUStreamLinesLEFT( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00344 
00351         void VFlowData::generateCPUStreamLinesTOP( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00352  
00359         void VFlowData::generateCPUStreamLinesRIGHT( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00360          
00367         void VFlowData::generateCPUStreamLinesBOTTOM( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00368          
00375         void VFlowData::generateCPUStreamLinesALL( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00376          
00383         void VFlowData::generateCPUStreamLinesRANDOM( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00384          
00391         void VFlowData::generateCPUStreamLinesMANUAL( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00392  
00399         void VFlowData::generateCPUStreamLinesEVEN( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00400 
00407         void VFlowData::generateCPUStreamLinesLEFT_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00408 
00415         void VFlowData::generateCPUStreamLinesTOP_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00416  
00423         void VFlowData::generateCPUStreamLinesRIGHT_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00424          
00431         void VFlowData::generateCPUStreamLinesBOTTOM_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00432          
00439         void VFlowData::generateCPUStreamLinesALL_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00440          
00447         void VFlowData::generateCPUStreamLinesRANDOM_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00448          
00455         void VFlowData::generateCPUStreamLinesMANUAL_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00456  
00463         void VFlowData::generateCPUStreamLinesEVEN_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep /* = 0  */ );
00464 
00470         void VFlowData::addManualSeedpoint( float x, float y );
00471 
00473         // * pushes the new seedpoint in texture space to the evenly sp. seedpoints list
00474         // * @param x is the world x-coordinate of the seedpoint in texture space to be added
00475         // * @param y is the world y-coordinate of the seedpoint in texture space to be added
00476         // */
00477         //void VFlowData::addManualSeedpointWithDsepTest( float m_TimeStep, float m_MaxSteps  );
00478 
00482         void drawStreamlinesFromSeedpoints( float m_MaxSteps, float m_TimeStep );
00483 
00485         // * draws the evenly spaced streamlines
00486         // */
00487         //void VFlowData::drawEvenlySpacedStreamlines( float m_TimeStep, float m_MaxSteps  );
00488 
00493         bool isIndexOfManualPlacingMethod( int val );
00494 
00499         bool isIndexOfEvenPlacingMethod( int val );
00500 
00505         void setPlacingMethod( int val );
00506 
00512         unsigned int getVelocityHandle( int m_TimeStep )
00513         {
00514                 if(m_TimeStep > (int)mTimeSteps.size())
00515                 {
00516                         m_TimeStep = 0;
00517                 }
00518                 return mTimeSteps[m_TimeStep].mFrameBufferObject->getTextureHandle();
00519         }
00520 
00521         float * getVertexToTexture()
00522         {
00523                 return &mVertexToTexture[0];
00524         }
00525 
00526         float * getTextureToVertex()
00527         {
00528                 return &mTextureToVertex[0];
00529         }
00530 
00535         void loadStreamLines( std::string m_FileName );
00536 
00541         void saveStreamLines( std::string m_FileName );
00542 
00547         void setIconScale( int m_IconScale )
00548         {
00549                 if ( mIcons.empty() ) return;
00550 
00551                 mIconScale = m_IconScale;
00552                 mIcons[ mIcons.size() - 1 ].setScale( ( float )m_IconScale / 100.0f );
00553                 mIcons[ mIcons.size() - 1 ].computeIcon( &mTimeSteps[0] , mActiveTimeStep );
00554         }
00555 
00560         void setTailLength( int m_TailLength )
00561         {
00562                 if ( mIcons.empty() ) return;
00563 
00564                 mTailLength = m_TailLength;
00565                 mIcons[ mIcons.size() - 1 ].setTailLength( ( float )m_TailLength / 100.0f );
00566                 mIcons[ mIcons.size() - 1 ].computeIcon( &mTimeSteps[0] , mActiveTimeStep );
00567         }
00568 
00573         void setTimeStep( int val )
00574         {
00575                 mActiveTimeStep = val;
00576         }
00577 
00581         void computeIcons();
00582 
00583 private:
00584 
00590         bool getPointAt( VVector *next, std::vector<float> pixeldata, float px, float py, int texsize_x, int texsize_y);
00591 
00597         bool readGrid( std::string m_FileName );
00598 
00604         bool readDat( std::string m_FileName );
00605 
00609         void generateVBO();
00610 
00615         void activateVBO( int m_TimeStep = 0 );
00616 
00620         void deactivateVBO();
00621 
00625         void clear();
00626 
00627 
00634         double round(double Zahl, int Stellen)
00635         {
00636                 double v[] = { 1, 10, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8 };  // mgl. verlängern
00637                 return floor(Zahl * v[Stellen] + 0.5) / v[Stellen];
00638         }
00639 
00640         
00641         vGridHeader mHeader;                                                    
00643         std::vector<VVector> mVertexGrid;                               
00644         unsigned int mVertexVbo;                                                
00646         VMatrix mVertexToTexture;                                               
00648         VMatrix mTextureToVertex;                                               
00650         std::vector<int> mIndexGrid;                                    
00651         unsigned int mIndexVbo;                                                 
00653         std::vector<vTimeStep> mTimeSteps;                              
00654         int mActiveTimeStep;                                                    
00656         float mNumTriplets;                                                             
00658         std::vector<int> mGlyphIndexGrid;                               
00659         unsigned int mGlyphIndexVbo;                                    
00661         VVector mMinPos;                                                                
00662         VVector mMaxPos;                                                                
00663         VVector mCenterPos;                                                             
00664         VVector mExtends;                                                               
00666         VVector mMinDistance;                                                   
00667         bool mReverseX;                                                                 
00668         bool mReverseY;                                                                 
00670         std::vector< float > maxDataValues;                             
00671         std::vector< float > minDataValues;                             
00673         bool mTexturesGenerated;                                                
00675         float mStreamlinesTestSeparation;                               
00676         float mStreamlinesSeedSeparation;                               
00677         float mStreamlinesSteps;                                                
00678         float mStreamlinesDt;                                                   
00679         float mEuler;                                                                   
00680         bool mTapering;                                                                 
00681         float mTaperingScale;                                                           
00682         PlacingMethod mSeedPlacing;                                             
00683         std::vector<VVector> mManualSeedpoints;                                         
00684         std::vector<VVector> mEvenlySeedpoints;                                         
00686         VStreamLine *streamlines;
00687         int mNumStreamlines;
00688 
00689         static VProgram * mRenderTextureProgram;                
00691         float mIconScale;                                                               
00692         float mTailLength;                                                              
00693         std::vector<VIcon> mIcons;                                              
00695         bool mStrGlyphes;                                                               
00698 };
00699 
00700 #endif // _v_flow_data_h

Generated on Mon Jan 21 01:15:16 2008 for FlowVis by  doxygen 1.5.4