00001 #include "VFlowData.h"
00002 #include <time.h>
00003
00004 #define MINNUMBER 5.0f
00005 #define MAXNUMBER 100.0f
00006 #define MAXSTEPS 3 * 4096
00007
00008 void VFlowData::generateCPUStreamLinesLEFT_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
00009 {
00010 if( mNumStreamlines != 0 )
00011 {
00012 if ( streamlines )
00013 {
00014 delete[] streamlines;
00015 streamlines = NULL;
00016 mNumStreamlines = 0;
00017 }
00018 }
00019
00020 std::vector< float > pixeldata;
00021
00022 int texsize_x, texsize_y;
00023
00024 float dataextent_x, dataextent_y;
00025 float datacenter_x, datacenter_y;
00026 float minx, miny;
00027
00028 dataextent_x = mExtends.getX();
00029 dataextent_y = mExtends.getY();
00030 datacenter_x = mCenterPos.getX();
00031 datacenter_y = mCenterPos.getY();
00032 minx = mMinPos.getX();
00033 miny = mMinPos.getY();
00034
00035 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
00036 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
00037
00038
00039 float numbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
00040 float spacing = 1.0f / numbersteamlines ;
00041
00042 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
00043 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
00044 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
00045
00046 int size = (int)pixeldata.size();
00047
00048
00049 mNumStreamlines = (int)numbersteamlines;
00050 streamlines = new VStreamLine[ (int)mNumStreamlines + 1 ];
00051
00052 for ( int j = 0; j <= mNumStreamlines; j++ )
00053 {
00054
00055 std::vector< VVector > streamlinevertices;
00056
00057 bool outofdata = false;
00058
00059 float offset = (float)( j + 1 ) / ( (float)numbersteamlines + 1.0f );
00060
00061
00062 float sactualpoint_y = offset - 0.5f * ( 1.0f / texsize_x );
00063 float sactualpoint_x = 0.0025f - 0.5f * ( 1.0f / texsize_x );
00064
00065 VVector start_tex = VVector();
00066 start_tex.setX( sactualpoint_x );
00067 start_tex.setY( sactualpoint_y );
00068
00069 VVector start_world = VVector( start_tex );
00070
00071
00072
00073 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
00074 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
00075 streamlinevertices.push_back( start_world );
00076
00077 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
00078 {
00079 if (outofdata ) break;
00080
00081 {
00082
00083 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00084 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00085 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00086 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00087 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00088
00089 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00090 {
00091
00092 outofdata = true;
00093 break;
00094 }
00095
00096
00097
00098 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00099 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00100 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00101
00102
00103 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00104 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00105 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00106
00107
00108 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00109 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00110 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00111
00112
00113 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00114 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00115 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00116
00117 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00118 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00119 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00120
00121 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00122 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00123 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00124
00125 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00126 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00127 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00128
00129 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00130 VVector interp_mult = VVector( interpolatedval );
00131 interp_mult.setX( -interp_mult.getX( ) );
00132 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
00133
00134
00135 VVector oldpos_world = VVector();
00136 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00137 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00138
00139 VVector newpos_world = oldpos_world + interp_mult;
00140
00141 VVector newpos_tex = VVector();
00142 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00143 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00144
00145 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00146 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00147 {
00148 outofdata = true;
00149 break;
00150 }
00151
00152 sactualpoint_x = newpos_tex.getX();
00153 sactualpoint_y = newpos_tex.getY();
00154 }
00155
00156
00157 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00158 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00159 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00160 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00161 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00162
00163 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00164 {
00165
00166 outofdata = true;
00167 break;
00168 }
00169
00170
00171
00172 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00173 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00174 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00175
00176
00177 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00178 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00179 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00180
00181
00182 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00183 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00184 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00185
00186
00187 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00188 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00189 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00190
00191 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00192 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00193 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00194
00195 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00196 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00197 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00198
00199 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00200 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00201 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00202
00203 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00204 VVector interp_mult = VVector( interpolatedval );
00205 interp_mult.setX( -interp_mult.getX( ) );
00206 interp_mult *= 0.05f *mStreamlinesDt;
00207
00208
00209 VVector oldpos_world = VVector();
00210 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00211 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00212
00213 VVector newpos_world = oldpos_world + interp_mult;
00214
00215 VVector newpos_tex = VVector();
00216 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00217 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00218
00219 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00220 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00221 {
00222 outofdata = true;
00223 break;
00224 }
00225
00226 sactualpoint_x = newpos_tex.getX();
00227 sactualpoint_y = newpos_tex.getY();
00228
00229
00230
00231 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
00232 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
00233 streamlinevertices.push_back( newpos_tex );
00234
00235
00236 float epsilon = 0.0000001f;
00237 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
00238 if ( posdifference.getMagnitude() < epsilon)
00239 {
00240 outofdata = true;
00241 break;
00242 }
00243
00244 }
00245 if( !streamlinevertices.empty() )
00246 {
00247 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
00248 streamlines[ j ].regenerateVBO();
00249 }
00250 }
00251
00252
00253
00254 pixeldata.clear();
00255
00256 }
00257
00258
00259 void VFlowData::generateCPUStreamLinesTOP_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
00260 {
00261 if( mNumStreamlines != 0 )
00262 {
00263 if ( streamlines )
00264 {
00265 delete[] streamlines;
00266 streamlines = NULL;
00267 mNumStreamlines = 0;
00268 }
00269 }
00270
00271 std::vector< float > pixeldata;
00272
00273 int texsize_x, texsize_y;
00274
00275 float dataextent_x, dataextent_y;
00276 float datacenter_x, datacenter_y;
00277 float minx, miny;
00278
00279 dataextent_x = mExtends.getX();
00280 dataextent_y = mExtends.getY();
00281 datacenter_x = mCenterPos.getX();
00282 datacenter_y = mCenterPos.getY();
00283 minx = mMinPos.getX();
00284 miny = mMinPos.getY();
00285
00286 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
00287 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
00288
00289
00290 float numbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
00291 float spacing = 1.0f / numbersteamlines ;
00292
00293 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
00294 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
00295 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
00296
00297 int size = (int)pixeldata.size();
00298
00299
00300 mNumStreamlines = (int)numbersteamlines;
00301 streamlines = new VStreamLine[ (int)mNumStreamlines + 1 ];
00302
00303 for ( int j = 0; j <= mNumStreamlines; j++ )
00304 {
00305
00306 std::vector< VVector > streamlinevertices;
00307
00308 bool outofdata = false;
00309
00310 float offset = (float)( j + 1 ) / ( (float)numbersteamlines + 1.0f );
00311
00312
00313 float sactualpoint_x = offset - 0.5f * ( 1.0f / texsize_x );
00314 float sactualpoint_y = 1.0f - 0.5f * ( 1.0f / texsize_y );
00315
00316 VVector start_tex = VVector();
00317 start_tex.setX( sactualpoint_x );
00318 start_tex.setY( sactualpoint_y );
00319
00320 VVector start_world = VVector( start_tex );
00321
00322
00323
00324 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
00325 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
00326 streamlinevertices.push_back( start_world );
00327
00328 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
00329 {
00330 if (outofdata ) break;
00331
00332 {
00333
00334 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00335 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00336 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00337 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00338 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00339
00340 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00341 {
00342
00343 outofdata = true;
00344 break;
00345 }
00346
00347
00348
00349 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00350 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00351 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00352
00353
00354 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00355 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00356 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00357
00358
00359 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00360 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00361 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00362
00363
00364 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00365 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00366 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00367
00368 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00369 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00370 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00371
00372 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00373 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00374 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00375
00376 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00377 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00378 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00379
00380 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00381 VVector interp_mult = VVector( interpolatedval );
00382 interp_mult.setX( -interp_mult.getX( ) );
00383
00384
00385 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
00386
00387
00388 VVector oldpos_world = VVector();
00389 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00390 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00391
00392 VVector newpos_world = oldpos_world + interp_mult;
00393
00394 VVector newpos_tex = VVector();
00395 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00396 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00397
00398 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00399 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00400 {
00401 outofdata = true;
00402 break;
00403 }
00404 sactualpoint_x = newpos_tex.getX();
00405 sactualpoint_y = newpos_tex.getY();
00406 }
00407
00408
00409
00410 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00411 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00412 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00413 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00414 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00415
00416 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00417 {
00418
00419 outofdata = true;
00420 break;
00421 }
00422
00423
00424
00425 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00426 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00427 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00428
00429
00430 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00431 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00432 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00433
00434
00435 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00436 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00437 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00438
00439
00440 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00441 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00442 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00443
00444 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00445 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00446 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00447
00448 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00449 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00450 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00451
00452 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00453 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00454 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00455
00456 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00457 VVector interp_mult = VVector( interpolatedval );
00458 interp_mult.setX( -interp_mult.getX( ) );
00459
00460 interp_mult *= 0.05f *mStreamlinesDt;
00461
00462
00463 VVector oldpos_world = VVector();
00464 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00465 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00466
00467 VVector newpos_world = oldpos_world + interp_mult;
00468
00469 VVector newpos_tex = VVector();
00470 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00471 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00472
00473 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00474 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00475 {
00476 outofdata = true;
00477 break;
00478 }
00479
00480
00481 sactualpoint_x = newpos_tex.getX();
00482 sactualpoint_y = newpos_tex.getY();
00483
00484
00485
00486 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
00487 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
00488 streamlinevertices.push_back( newpos_tex );
00489
00490
00491 float epsilon = 0.0000001f;
00492 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
00493 if ( posdifference.getMagnitude() < epsilon)
00494 {
00495 outofdata = true;
00496 break;
00497 }
00498
00499 }
00500 if( !streamlinevertices.empty() )
00501 {
00502 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
00503 streamlines[ j ].regenerateVBO();
00504 }
00505 }
00506
00507
00508
00509 pixeldata.clear();
00510 }
00511
00512 void VFlowData::generateCPUStreamLinesRIGHT_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
00513 {
00514 if( mNumStreamlines != 0 )
00515 {
00516 if ( streamlines )
00517 {
00518 delete[] streamlines;
00519 streamlines = NULL;
00520 mNumStreamlines = 0;
00521 }
00522 }
00523
00524 std::vector< float > pixeldata;
00525
00526 int texsize_x, texsize_y;
00527
00528 float dataextent_x, dataextent_y;
00529 float datacenter_x, datacenter_y;
00530 float minx, miny;
00531
00532 dataextent_x = mExtends.getX();
00533 dataextent_y = mExtends.getY();
00534 datacenter_x = mCenterPos.getX();
00535 datacenter_y = mCenterPos.getY();
00536 minx = mMinPos.getX();
00537 miny = mMinPos.getY();
00538
00539 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
00540 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
00541
00542
00543 float numbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
00544 float spacing = 1.0f / numbersteamlines ;
00545
00546 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
00547 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
00548 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
00549
00550 int size = (int)pixeldata.size();
00551
00552
00553 mNumStreamlines = (int)numbersteamlines;
00554 streamlines = new VStreamLine[ (int)mNumStreamlines + 1 ];
00555
00556 for ( int j = 0; j <= mNumStreamlines; j++ )
00557 {
00558
00559 std::vector< VVector > streamlinevertices;
00560
00561 bool outofdata = false;
00562
00563 float offset = (float)( j + 1 ) / ( (float)numbersteamlines + 1.0f );
00564
00565
00566 float sactualpoint_y = offset - 0.5f * ( 1.0f / texsize_y );
00567 float sactualpoint_x = 1.0f - 0.5f * ( 1.0f / texsize_x );
00568
00569 VVector start_tex = VVector();
00570 start_tex.setX( sactualpoint_x );
00571 start_tex.setY( sactualpoint_y );
00572
00573 VVector start_world = VVector( start_tex );
00574
00575
00576
00577 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
00578 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
00579 streamlinevertices.push_back( start_world );
00580
00581 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
00582 {
00583 if (outofdata ) break;
00584
00585
00586 {
00587
00588
00589 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00590 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00591 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00592 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00593 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00594
00595 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00596 {
00597
00598 outofdata = true;
00599 break;
00600 }
00601
00602
00603
00604 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00605 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00606 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00607
00608
00609 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00610 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00611 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00612
00613
00614 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00615 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00616 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00617
00618
00619 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00620 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00621 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00622
00623 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00624 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00625 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00626
00627 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00628 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00629 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00630
00631 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00632 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00633 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00634
00635 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00636 VVector interp_mult = VVector( interpolatedval );
00637 interp_mult.setX( -interp_mult.getX( ) );
00638 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
00639
00640
00641 VVector oldpos_world = VVector();
00642 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00643 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00644
00645 VVector newpos_world = oldpos_world + interp_mult;
00646
00647 VVector newpos_tex = VVector();
00648 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00649 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00650
00651 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00652 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00653 {
00654 outofdata = true;
00655 break;
00656 }
00657
00658 sactualpoint_x = newpos_tex.getX();
00659 sactualpoint_y = newpos_tex.getY();
00660 }
00661
00662
00663 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00664 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00665 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00666 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00667 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00668
00669 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00670 {
00671
00672 outofdata = true;
00673 break;
00674 }
00675
00676
00677
00678 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00679 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00680 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00681
00682
00683 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00684 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00685 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00686
00687
00688 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00689 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00690 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00691
00692
00693 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00694 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00695 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00696
00697 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00698 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00699 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00700
00701 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00702 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00703 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00704
00705 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00706 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00707 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00708
00709 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00710 VVector interp_mult = VVector( interpolatedval );
00711 interp_mult.setX( -interp_mult.getX( ) );
00712 interp_mult *= 0.05f *mStreamlinesDt;
00713
00714
00715 VVector oldpos_world = VVector();
00716 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00717 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00718
00719 VVector newpos_world = oldpos_world + interp_mult;
00720
00721 VVector newpos_tex = VVector();
00722 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00723 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00724
00725 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00726 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00727 {
00728 outofdata = true;
00729 break;
00730 }
00731
00732 sactualpoint_x = newpos_tex.getX();
00733 sactualpoint_y = newpos_tex.getY();
00734
00735
00736
00737 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
00738 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
00739 streamlinevertices.push_back( newpos_tex );
00740
00741
00742 float epsilon = 0.0000001f;
00743 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
00744 if ( posdifference.getMagnitude() < epsilon)
00745 {
00746 outofdata = true;
00747 break;
00748 }
00749
00750 }
00751 if( !streamlinevertices.empty() )
00752 {
00753 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
00754 streamlines[ j ].regenerateVBO();
00755 }
00756 }
00757
00758
00759
00760 pixeldata.clear();
00761 }
00762
00763 void VFlowData::generateCPUStreamLinesBOTTOM_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
00764 {
00765 if( mNumStreamlines != 0 )
00766 {
00767 if ( streamlines )
00768 {
00769 delete[] streamlines;
00770 streamlines = NULL;
00771 mNumStreamlines = 0;
00772 }
00773 }
00774
00775 std::vector< float > pixeldata;
00776
00777 int texsize_x, texsize_y;
00778
00779 float dataextent_x, dataextent_y;
00780 float datacenter_x, datacenter_y;
00781 float minx, miny;
00782
00783 dataextent_x = mExtends.getX();
00784 dataextent_y = mExtends.getY();
00785 datacenter_x = mCenterPos.getX();
00786 datacenter_y = mCenterPos.getY();
00787 minx = mMinPos.getX();
00788 miny = mMinPos.getY();
00789
00790 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
00791 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
00792
00793
00794 float numbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
00795 float spacing = 1.0f / numbersteamlines ;
00796
00797 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
00798 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
00799 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
00800
00801 int size = (int)pixeldata.size();
00802
00803
00804 mNumStreamlines = (int)numbersteamlines;
00805 streamlines = new VStreamLine[ (int)mNumStreamlines + 1 ];
00806
00807 for ( int j = 0; j <= mNumStreamlines; j++ )
00808 {
00809
00810 std::vector< VVector > streamlinevertices;
00811
00812 bool outofdata = false;
00813
00814 float offset = (float)( j + 1 ) / ( (float)numbersteamlines + 1.0f );
00815
00816
00817 float sactualpoint_x = offset - 0.5f * ( 1.0f / texsize_x );
00818 float sactualpoint_y = 0.0025f - 0.5f * ( 1.0f / texsize_y );
00819
00820
00821 VVector start_tex = VVector();
00822 start_tex.setX( sactualpoint_x );
00823 start_tex.setY( sactualpoint_y );
00824
00825 VVector start_world = VVector( start_tex );
00826
00827
00828
00829 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
00830 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
00831 streamlinevertices.push_back( start_world );
00832
00833 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
00834 {
00835 if (outofdata ) break;
00836
00837 {
00838
00839 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00840 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00841 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00842 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00843 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00844
00845 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00846 {
00847
00848 outofdata = true;
00849 break;
00850 }
00851
00852
00853
00854 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00855 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00856 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00857
00858
00859 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00860 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00861 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00862
00863
00864 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00865 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00866 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00867
00868
00869 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00870 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00871 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00872
00873 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00874 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00875 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00876
00877 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00878 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00879 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00880
00881 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00882 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00883 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00884
00885 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00886 VVector interp_mult = VVector( interpolatedval );
00887 interp_mult.setX( -interp_mult.getX( ) );
00888 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
00889
00890
00891 VVector oldpos_world = VVector();
00892 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00893 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00894
00895 VVector newpos_world = oldpos_world + interp_mult;
00896
00897 VVector newpos_tex = VVector();
00898 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00899 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00900
00901 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00902 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00903 {
00904 outofdata = true;
00905 break;
00906 }
00907
00908 sactualpoint_x = newpos_tex.getX();
00909 sactualpoint_y = newpos_tex.getY();
00910 }
00911
00912
00913 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
00914 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
00915 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
00916 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
00917 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
00918
00919 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
00920 {
00921
00922 outofdata = true;
00923 break;
00924 }
00925
00926
00927
00928 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
00929 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
00930 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
00931
00932
00933 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
00934 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
00935 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
00936
00937
00938 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
00939 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
00940 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
00941
00942
00943 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
00944 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
00945 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
00946
00947 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
00948 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
00949 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
00950
00951 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
00952 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
00953 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
00954
00955 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
00956 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
00957 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
00958
00959 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
00960 VVector interp_mult = VVector( interpolatedval );
00961 interp_mult.setX( -interp_mult.getX( ) );
00962 interp_mult *= 0.05f *mStreamlinesDt;
00963
00964
00965 VVector oldpos_world = VVector();
00966 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
00967 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
00968
00969 VVector newpos_world = oldpos_world + interp_mult;
00970
00971 VVector newpos_tex = VVector();
00972 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
00973 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
00974
00975 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
00976 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
00977 {
00978 outofdata = true;
00979 break;
00980 }
00981
00982 sactualpoint_x = newpos_tex.getX();
00983 sactualpoint_y = newpos_tex.getY();
00984
00985
00986
00987 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
00988 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
00989 streamlinevertices.push_back( newpos_tex );
00990
00991
00992 float epsilon = 0.0000001f;
00993 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
00994 if ( posdifference.getMagnitude() < epsilon)
00995 {
00996 outofdata = true;
00997 break;
00998 }
00999
01000 }
01001 if( !streamlinevertices.empty() )
01002 {
01003 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
01004 streamlines[ j ].regenerateVBO();
01005 }
01006 }
01007
01008
01009
01010 pixeldata.clear();
01011
01012 }
01013
01014 void VFlowData::generateCPUStreamLinesALL_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
01015 {
01016
01017 if( mNumStreamlines != 0 )
01018 {
01019 if ( streamlines )
01020 {
01021 delete[] streamlines;
01022 streamlines = NULL;
01023 mNumStreamlines = 0;
01024 }
01025 }
01026
01027 std::vector< float > pixeldata;
01028
01029 int texsize_x, texsize_y;
01030
01031 float dataextent_x, dataextent_y;
01032 float datacenter_x, datacenter_y;
01033 float minx, miny;
01034
01035 dataextent_x = mExtends.getX();
01036 dataextent_y = mExtends.getY();
01037 datacenter_x = mCenterPos.getX();
01038 datacenter_y = mCenterPos.getY();
01039 minx = mMinPos.getX();
01040 miny = mMinPos.getY();
01041
01042 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
01043 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
01044
01045
01046 float qnumbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
01047 float spacing = 1.0f / qnumbersteamlines ;
01048
01049 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
01050 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
01051 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
01052
01053 int size = (int)pixeldata.size();
01054
01055
01056 mNumStreamlines = 4 * (int)qnumbersteamlines;
01057 streamlines = new VStreamLine[ (int)mNumStreamlines + 4 ];
01058
01059
01060 for ( int j = 0; j <= qnumbersteamlines; j++ )
01061 {
01062
01063 std::vector< VVector > streamlinevertices;
01064
01065 bool outofdata = false;
01066
01067 float offset = (float)( j + 1 ) / ( (float)qnumbersteamlines + 1.0f );
01068
01069
01070 float sactualpoint_x = offset - 0.5f * ( 1.0f / texsize_x );
01071 float sactualpoint_y = 0.0025f - 0.5f * ( 1.0f / texsize_y );
01072
01073 VVector start_tex = VVector();
01074 start_tex.setX( sactualpoint_x );
01075 start_tex.setY( sactualpoint_y );
01076
01077 VVector start_world = VVector( start_tex );
01078
01079
01080
01081 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
01082 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
01083 streamlinevertices.push_back( start_world );
01084
01085 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
01086 {
01087 if (outofdata ) break;
01088
01089 {
01090
01091 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01092 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01093 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01094 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01095 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01096
01097 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01098 {
01099
01100 outofdata = true;
01101 break;
01102 }
01103
01104
01105
01106 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01107 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01108 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01109
01110
01111 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01112 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01113 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01114
01115
01116 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01117 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01118 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01119
01120
01121 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01122 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01123 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01124
01125 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01126 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01127 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01128
01129 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01130 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01131 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01132
01133 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01134 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01135 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01136
01137 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01138 VVector interp_mult = VVector( interpolatedval );
01139 interp_mult.setX( -interp_mult.getX( ) );
01140 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
01141
01142
01143 VVector oldpos_world = VVector();
01144 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01145 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01146
01147 VVector newpos_world = oldpos_world + interp_mult;
01148
01149 VVector newpos_tex = VVector();
01150 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01151 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01152
01153 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01154 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01155 {
01156 outofdata = true;
01157 break;
01158 }
01159
01160 sactualpoint_x = newpos_tex.getX();
01161 sactualpoint_y = newpos_tex.getY();
01162 }
01163
01164
01165 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01166 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01167 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01168 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01169 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01170
01171 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01172 {
01173
01174 outofdata = true;
01175 break;
01176 }
01177
01178
01179
01180 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01181 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01182 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01183
01184
01185 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01186 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01187 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01188
01189
01190 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01191 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01192 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01193
01194
01195 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01196 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01197 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01198
01199 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01200 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01201 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01202
01203 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01204 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01205 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01206
01207 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01208 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01209 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01210
01211 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01212 VVector interp_mult = VVector( interpolatedval );
01213 interp_mult.setX( -interp_mult.getX( ) );
01214 interp_mult *= 0.05f *mStreamlinesDt;
01215
01216
01217 VVector oldpos_world = VVector();
01218 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01219 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01220
01221 VVector newpos_world = oldpos_world + interp_mult;
01222
01223 VVector newpos_tex = VVector();
01224 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01225 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01226
01227 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01228 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01229 {
01230 outofdata = true;
01231 break;
01232 }
01233
01234 sactualpoint_x = newpos_tex.getX();
01235 sactualpoint_y = newpos_tex.getY();
01236
01237
01238
01239 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
01240 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
01241 streamlinevertices.push_back( newpos_tex );
01242
01243
01244 float epsilon = 0.0000001f;
01245 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
01246 if ( posdifference.getMagnitude() < epsilon)
01247 {
01248 outofdata = true;
01249 break;
01250 }
01251
01252
01253 }
01254 if( !streamlinevertices.empty() )
01255 {
01256 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
01257 streamlines[ j ].regenerateVBO();
01258 }
01259 }
01260
01261
01262 for ( int j = 0; j <= qnumbersteamlines; j++ )
01263 {
01264
01265 std::vector< VVector > streamlinevertices;
01266
01267 bool outofdata = false;
01268
01269 float offset = (float)( j + 1 ) / ( (float)qnumbersteamlines + 1.0f );
01270
01271
01272 float sactualpoint_y = offset - 0.5f * ( 1.0f / texsize_x );
01273 float sactualpoint_x = 0.0025f - 0.5f * ( 1.0f / texsize_x );
01274
01275 VVector start_tex = VVector();
01276 start_tex.setX( sactualpoint_x );
01277 start_tex.setY( sactualpoint_y );
01278
01279 VVector start_world = VVector( start_tex );
01280
01281
01282
01283 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
01284 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
01285 streamlinevertices.push_back( start_world );
01286
01287 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
01288 {
01289 if (outofdata ) break;
01290
01291 {
01292
01293 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01294 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01295 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01296 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01297 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01298
01299 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01300 {
01301
01302 outofdata = true;
01303 break;
01304 }
01305
01306
01307
01308 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01309 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01310 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01311
01312
01313 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01314 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01315 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01316
01317
01318 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01319 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01320 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01321
01322
01323 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01324 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01325 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01326
01327 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01328 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01329 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01330
01331 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01332 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01333 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01334
01335 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01336 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01337 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01338
01339 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01340 VVector interp_mult = VVector( interpolatedval );
01341 interp_mult.setX( -interp_mult.getX( ) );
01342 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
01343
01344
01345 VVector oldpos_world = VVector();
01346 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01347 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01348
01349 VVector newpos_world = oldpos_world + interp_mult;
01350
01351 VVector newpos_tex = VVector();
01352 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01353 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01354
01355 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01356 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01357 {
01358 outofdata = true;
01359 break;
01360 }
01361
01362 sactualpoint_x = newpos_tex.getX();
01363 sactualpoint_y = newpos_tex.getY();
01364 }
01365
01366
01367 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01368 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01369 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01370 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01371 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01372
01373 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01374 {
01375
01376 outofdata = true;
01377 break;
01378 }
01379
01380
01381
01382 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01383 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01384 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01385
01386
01387 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01388 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01389 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01390
01391
01392 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01393 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01394 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01395
01396
01397 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01398 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01399 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01400
01401 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01402 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01403 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01404
01405 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01406 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01407 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01408
01409 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01410 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01411 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01412
01413 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01414 VVector interp_mult = VVector( interpolatedval );
01415 interp_mult.setX( -interp_mult.getX( ) );
01416 interp_mult *= 0.05f *mStreamlinesDt;
01417
01418
01419 VVector oldpos_world = VVector();
01420 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01421 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01422
01423 VVector newpos_world = oldpos_world + interp_mult;
01424
01425 VVector newpos_tex = VVector();
01426 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01427 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01428
01429 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01430 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01431 {
01432 outofdata = true;
01433 break;
01434 }
01435
01436 sactualpoint_x = newpos_tex.getX();
01437 sactualpoint_y = newpos_tex.getY();
01438
01439
01440
01441 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
01442 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
01443 streamlinevertices.push_back( newpos_tex );
01444
01445
01446 float epsilon = 0.0000001f;
01447 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
01448 if ( posdifference.getMagnitude() < epsilon)
01449 {
01450 outofdata = true;
01451 break;
01452 }
01453
01454 }
01455 if( !streamlinevertices.empty() )
01456 {
01457 streamlines[ j + (int)qnumbersteamlines ] = VStreamLine( streamlinevertices ) ;
01458 streamlines[ j + (int)qnumbersteamlines ].regenerateVBO();
01459 }
01460 }
01461
01462
01463 for ( int j = 0; j <= qnumbersteamlines; j++ )
01464 {
01465
01466 std::vector< VVector > streamlinevertices;
01467
01468 bool outofdata = false;
01469
01470 float offset = (float)( j + 1 ) / ( (float)qnumbersteamlines + 1.0f );
01471
01472
01473 float sactualpoint_x = offset - 0.5f * ( 1.0f / texsize_x );
01474 float sactualpoint_y = 1.0f - 0.5f * ( 1.0f / texsize_y );
01475
01476 VVector start_tex = VVector();
01477 start_tex.setX( sactualpoint_x );
01478 start_tex.setY( sactualpoint_y );
01479
01480 VVector start_world = VVector( start_tex );
01481
01482
01483
01484 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
01485 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
01486 streamlinevertices.push_back( start_world );
01487
01488 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
01489 {
01490 if (outofdata ) break;
01491
01492 {
01493
01494 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01495 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01496 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01497 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01498 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01499
01500 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01501 {
01502
01503 outofdata = true;
01504 break;
01505 }
01506
01507
01508
01509 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01510 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01511 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01512
01513
01514 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01515 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01516 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01517
01518
01519 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01520 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01521 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01522
01523
01524 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01525 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01526 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01527
01528 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01529 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01530 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01531
01532 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01533 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01534 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01535
01536 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01537 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01538 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01539
01540 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01541 VVector interp_mult = VVector( interpolatedval );
01542 interp_mult.setX( -interp_mult.getX( ) );
01543 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
01544
01545
01546 VVector oldpos_world = VVector();
01547 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01548 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01549
01550 VVector newpos_world = oldpos_world + interp_mult;
01551
01552 VVector newpos_tex = VVector();
01553 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01554 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01555
01556 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01557 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01558 {
01559 outofdata = true;
01560 break;
01561 }
01562
01563 sactualpoint_x = newpos_tex.getX();
01564 sactualpoint_y = newpos_tex.getY();
01565 }
01566
01567
01568 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01569 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01570 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01571 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01572 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01573
01574 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01575 {
01576
01577 outofdata = true;
01578 break;
01579 }
01580
01581
01582
01583 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01584 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01585 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01586
01587
01588 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01589 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01590 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01591
01592
01593 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01594 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01595 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01596
01597
01598 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01599 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01600 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01601
01602 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01603 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01604 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01605
01606 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01607 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01608 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01609
01610 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01611 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01612 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01613
01614 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01615 VVector interp_mult = VVector( interpolatedval );
01616 interp_mult.setX( -interp_mult.getX( ) );
01617 interp_mult *= 0.05f *mStreamlinesDt;
01618
01619
01620 VVector oldpos_world = VVector();
01621 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01622 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01623
01624 VVector newpos_world = oldpos_world + interp_mult;
01625
01626 VVector newpos_tex = VVector();
01627 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01628 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01629
01630 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01631 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01632 {
01633 outofdata = true;
01634 break;
01635 }
01636
01637 sactualpoint_x = newpos_tex.getX();
01638 sactualpoint_y = newpos_tex.getY();
01639
01640
01641
01642 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
01643 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
01644 streamlinevertices.push_back( newpos_tex );
01645
01646
01647 float epsilon = 0.0000001f;
01648 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
01649 if ( posdifference.getMagnitude() < epsilon)
01650 {
01651 outofdata = true;
01652 break;
01653 }
01654
01655 }
01656 if( !streamlinevertices.empty() )
01657 {
01658 streamlines[ j + 2 * (int)qnumbersteamlines ] = VStreamLine( streamlinevertices ) ;
01659 streamlines[ j + 2 * (int)qnumbersteamlines ].regenerateVBO();
01660 }
01661 }
01662
01663
01664 for ( int j = 0; j <= qnumbersteamlines; j++ )
01665 {
01666
01667 std::vector< VVector > streamlinevertices;
01668
01669 bool outofdata = false;
01670
01671 float offset = (float)( j + 1 ) / ( (float)qnumbersteamlines + 1.0f );
01672
01673
01674 float sactualpoint_y = offset - 0.5f * ( 1.0f / texsize_y );
01675 float sactualpoint_x = 1.0f - 0.5f * ( 1.0f / texsize_x );
01676
01677 VVector start_tex = VVector();
01678 start_tex.setX( sactualpoint_x );
01679 start_tex.setY( sactualpoint_y );
01680
01681 VVector start_world = VVector( start_tex );
01682
01683
01684
01685 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
01686 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
01687 streamlinevertices.push_back( start_world );
01688
01689 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
01690 {
01691 if (outofdata ) break;
01692
01693 {
01694
01695 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01696 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01697 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01698 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01699 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01700
01701 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01702 {
01703
01704 outofdata = true;
01705 break;
01706 }
01707
01708
01709
01710 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01711 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01712 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01713
01714
01715 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01716 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01717 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01718
01719
01720 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01721 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01722 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01723
01724
01725 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01726 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01727 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01728
01729 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01730 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01731 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01732
01733 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01734 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01735 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01736
01737 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01738 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01739 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01740
01741 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01742 VVector interp_mult = VVector( interpolatedval );
01743 interp_mult.setX( -interp_mult.getX( ) );
01744 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
01745
01746
01747 VVector oldpos_world = VVector();
01748 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01749 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01750
01751 VVector newpos_world = oldpos_world + interp_mult;
01752
01753 VVector newpos_tex = VVector();
01754 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01755 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01756
01757 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01758 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01759 {
01760 outofdata = true;
01761 break;
01762 }
01763
01764 sactualpoint_x = newpos_tex.getX();
01765 sactualpoint_y = newpos_tex.getY();
01766 }
01767
01768
01769 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01770 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01771 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01772 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01773 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01774
01775 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01776 {
01777
01778 outofdata = true;
01779 break;
01780 }
01781
01782
01783
01784 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01785 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01786 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01787
01788
01789 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01790 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01791 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01792
01793
01794 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01795 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01796 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01797
01798
01799 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01800 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01801 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01802
01803 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01804 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01805 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01806
01807 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01808 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01809 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01810
01811 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01812 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01813 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01814
01815 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01816 VVector interp_mult = VVector( interpolatedval );
01817 interp_mult.setX( -interp_mult.getX( ) );
01818 interp_mult *= 0.05f *mStreamlinesDt;
01819
01820
01821 VVector oldpos_world = VVector();
01822 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
01823 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
01824
01825 VVector newpos_world = oldpos_world + interp_mult;
01826
01827 VVector newpos_tex = VVector();
01828 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
01829 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
01830
01831 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
01832 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
01833 {
01834 outofdata = true;
01835 break;
01836 }
01837
01838 sactualpoint_x = newpos_tex.getX();
01839 sactualpoint_y = newpos_tex.getY();
01840
01841
01842
01843 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
01844 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
01845
01846 streamlinevertices.push_back( newpos_tex );
01847
01848
01849 float epsilon = 0.0000001f;
01850 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
01851 if ( posdifference.getMagnitude() < epsilon)
01852 {
01853 outofdata = true;
01854 break;
01855 }
01856
01857 }
01858 if( !streamlinevertices.empty() )
01859 {
01860 streamlines[ j + 3 * (int)qnumbersteamlines ] = VStreamLine( streamlinevertices ) ;
01861 streamlines[ j + 3 * (int)qnumbersteamlines ].regenerateVBO();
01862 }
01863 }
01864
01865
01866
01867 pixeldata.clear();
01868
01869 }
01870
01871 void VFlowData::generateCPUStreamLinesRANDOM_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
01872 {
01873 if( mNumStreamlines != 0 )
01874 {
01875 if ( streamlines )
01876 {
01877 delete[] streamlines;
01878 streamlines = NULL;
01879 mNumStreamlines = 0;
01880 }
01881 }
01882
01883 std::vector< float > pixeldata;
01884
01885 int texsize_x, texsize_y;
01886
01887 float dataextent_x, dataextent_y;
01888 float datacenter_x, datacenter_y;
01889 float minx, miny;
01890
01891 dataextent_x = mExtends.getX();
01892 dataextent_y = mExtends.getY();
01893 datacenter_x = mCenterPos.getX();
01894 datacenter_y = mCenterPos.getY();
01895 minx = mMinPos.getX();
01896 miny = mMinPos.getY();
01897
01898 float keepratiox = ( dataextent_x > dataextent_y ) ? 1.0f : dataextent_x / dataextent_y;
01899 float keepratioy = ( dataextent_y > dataextent_x ) ? 1.0f : dataextent_y / dataextent_x;
01900
01901
01902 float numbersteamlines = MINNUMBER + ( 1.0f - m_StreamSeparation ) * ( MAXNUMBER - MINNUMBER );
01903 float spacing = 1.0f / numbersteamlines ;
01904
01905 pixeldata = mTimeSteps[m_TimeStep].getFullFBODataVector();
01906 texsize_x = mTimeSteps[m_TimeStep].mFrameBufferObject->getWidth();
01907 texsize_y = mTimeSteps[m_TimeStep].mFrameBufferObject->getHeight();
01908
01909 int size = (int)pixeldata.size();
01910
01911
01912
01913 mNumStreamlines = (int)numbersteamlines;
01914 streamlines = new VStreamLine[ (int)numbersteamlines + 1];
01915
01916 srand ( time(NULL) );;
01917
01918 for ( int j = 0; j < numbersteamlines; j++ )
01919 {
01920 float randomf[ 2 ];
01921 randomf[ 0 ] = ( float )( rand( ) % 10000 + 1 ) / 10000.0f;
01922 randomf[ 1 ] = ( float )( rand( ) % 10000 + 1 ) / 10000.0f;
01923
01924 std::vector< VVector > streamlinevertices;
01925
01926 bool outofdata = false;
01927
01928 float offset = 0.9f * (float)( j ) / (float)numbersteamlines;
01929
01930 float sactualpoint_x = randomf[ 0 ];
01931 float sactualpoint_y = randomf[ 1 ];
01932
01933 VVector start_tex = VVector();
01934 start_tex.setX( sactualpoint_x );
01935 start_tex.setY( sactualpoint_y );
01936
01937 VVector start_world = VVector( start_tex );
01938
01939
01940
01941 start_world.setX( -( start_world.getX() * dataextent_x ) + minx + dataextent_x);
01942 start_world.setY( ( start_world.getY() * dataextent_y ) + miny );
01943 streamlinevertices.push_back( start_world );
01944
01945 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
01946 {
01947 if (outofdata ) break;
01948
01949 {
01950
01951 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
01952 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
01953 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
01954 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
01955 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
01956
01957 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
01958 {
01959
01960 outofdata = true;
01961 break;
01962 }
01963
01964
01965
01966 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
01967 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
01968 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
01969
01970
01971 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
01972 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
01973 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
01974
01975
01976 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
01977 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
01978 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
01979
01980
01981 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
01982 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
01983 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
01984
01985 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
01986 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
01987 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
01988
01989 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
01990 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
01991 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
01992
01993 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
01994 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
01995 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
01996
01997 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
01998 VVector interp_mult = VVector( interpolatedval );
01999 interp_mult.setX( -interp_mult.getX( ) );
02000 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
02001
02002
02003 VVector oldpos_world = VVector();
02004 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
02005 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
02006
02007 VVector newpos_world = oldpos_world + interp_mult;
02008
02009 VVector newpos_tex = VVector();
02010 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
02011 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
02012
02013 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
02014 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
02015 {
02016 outofdata = true;
02017 break;
02018 }
02019
02020 sactualpoint_x = newpos_tex.getX();
02021 sactualpoint_y = newpos_tex.getY();
02022 }
02023
02024
02025 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
02026 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
02027 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
02028 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
02029 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
02030
02031 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
02032 {
02033
02034 outofdata = true;
02035 break;
02036 }
02037
02038
02039
02040 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
02041 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
02042 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
02043
02044
02045 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
02046 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
02047 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
02048
02049
02050 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
02051 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
02052 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
02053
02054
02055 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
02056 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
02057 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
02058
02059 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
02060 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
02061 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
02062
02063 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
02064 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
02065 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
02066
02067 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
02068 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
02069 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
02070
02071 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
02072 VVector interp_mult = VVector( interpolatedval );
02073 interp_mult.setX( -interp_mult.getX( ) );
02074 interp_mult *= 0.05f *mStreamlinesDt;
02075
02076
02077 VVector oldpos_world = VVector();
02078 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
02079 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
02080
02081 VVector newpos_world = oldpos_world + interp_mult;
02082
02083 VVector newpos_tex = VVector();
02084 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
02085 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
02086
02087 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
02088 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
02089 {
02090 outofdata = true;
02091 break;
02092 }
02093
02094 sactualpoint_x = newpos_tex.getX();
02095 sactualpoint_y = newpos_tex.getY();
02096
02097
02098
02099 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
02100 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
02101 streamlinevertices.push_back( newpos_tex );
02102
02103 float epsilon = 0.0000001f;
02104 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
02105 if ( posdifference.getMagnitude() < epsilon)
02106 {
02107 outofdata = true;
02108 break;
02109 }
02110
02111 }
02112
02113
02114
02115
02116 if( !streamlinevertices.empty() )
02117 {
02118 std::vector< VVector > _streamlinesvertices;
02119 for( int k = 0; k < streamlinevertices.size(); k++)
02120 {
02121 _streamlinesvertices.push_back( streamlinevertices[ streamlinevertices.size() - k - 1 ] );
02122
02123 }
02124
02125 streamlinevertices.clear();
02126 streamlinevertices.swap( _streamlinesvertices );
02127 _streamlinesvertices.clear();
02128 }
02129
02130
02131 sactualpoint_x = randomf[ 0 ];
02132 sactualpoint_y = randomf[ 1 ];
02133
02134 outofdata = false;
02135
02136 for ( int i = 0; i < MAXSTEPS * m_MaxSteps ; i++)
02137 {
02138 if (outofdata ) break;
02139
02140 {
02141
02142 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
02143 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
02144 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
02145 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
02146 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
02147
02148 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
02149 {
02150
02151 outofdata = true;
02152 break;
02153 }
02154
02155
02156
02157 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
02158 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
02159 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
02160
02161
02162 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
02163 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
02164 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
02165
02166
02167 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
02168 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
02169 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
02170
02171
02172 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
02173 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
02174 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
02175
02176 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
02177 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
02178 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
02179
02180 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
02181 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
02182 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
02183
02184 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
02185 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
02186 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
02187
02188 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
02189 VVector interp_mult = VVector( interpolatedval );
02190 interp_mult.setX( -interp_mult.getX( ) );
02191 interp_mult *= 0.5f * 0.05f *mStreamlinesDt;
02192
02193
02194 VVector oldpos_world = VVector();
02195 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
02196 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
02197
02198 VVector newpos_world = oldpos_world - interp_mult;
02199
02200 VVector newpos_tex = VVector();
02201 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
02202 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
02203
02204 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
02205 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
02206 {
02207 outofdata = true;
02208 break;
02209 }
02210
02211 sactualpoint_x = newpos_tex.getX();
02212 sactualpoint_y = newpos_tex.getY();
02213 }
02214
02215
02216 VVector arrayindex = VVector( texsize_x * sactualpoint_x, texsize_y * sactualpoint_y, 0.0f );
02217 int xfloor = (int) ( arrayindex.getX() - 0.5f ) - 1;
02218 int yfloor = (int) ( arrayindex.getY() - 0.5f ) - 1;
02219 int xceil = (int) ( arrayindex.getX() + 0.5f ) - 1;
02220 int yceil = (int) ( arrayindex.getY() + 0.5f ) - 1;
02221
02222 if ( xfloor < 0 || yfloor < 0 || xceil >= texsize_x || yceil >= texsize_x )
02223 {
02224
02225 outofdata = true;
02226 break;
02227 }
02228
02229
02230
02231 float velocity_x_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 ];
02232 float velocity_y_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 1 ];
02233 float velocity_z_ff = pixeldata[ xfloor * 4 + yfloor * texsize_x * 4 + 2 ];
02234
02235
02236 float velocity_x_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 ];
02237 float velocity_y_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 1 ];
02238 float velocity_z_fc = pixeldata[ xfloor * 4 + yceil * texsize_x * 4 + 2 ];
02239
02240
02241 float velocity_x_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 ];
02242 float velocity_y_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 1 ];
02243 float velocity_z_cf = pixeldata[ xceil * 4 + yfloor* texsize_x * 4 + 2 ];
02244
02245
02246 float velocity_x_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 ];
02247 float velocity_y_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 1 ];
02248 float velocity_z_cc = pixeldata[ xceil * 4 + yceil * texsize_x * 4 + 2 ];
02249
02250 float interpolval_x_L = ( arrayindex.getX() - xfloor ) * velocity_x_cf + ( xceil - arrayindex.getX() ) * velocity_x_ff;
02251 float interpolval_y_L = ( arrayindex.getX() - xfloor ) * velocity_y_cf + ( xceil - arrayindex.getX() ) * velocity_y_ff;
02252 float interpolval_z_L = ( arrayindex.getX() - xfloor ) * velocity_z_cf + ( xceil - arrayindex.getX() ) * velocity_z_ff;
02253
02254 float interpolval_x_H = ( arrayindex.getX() - xfloor ) * velocity_x_cc + ( xceil - arrayindex.getX() ) * velocity_x_fc;
02255 float interpolval_y_H = ( arrayindex.getX() - xfloor ) * velocity_y_cc + ( xceil - arrayindex.getX() ) * velocity_y_fc;
02256 float interpolval_z_H = ( arrayindex.getX() - xfloor ) * velocity_z_cc + ( xceil - arrayindex.getX() ) * velocity_z_fc;
02257
02258 float interpolval_x = ( arrayindex.getY() - yfloor ) * interpolval_x_H + ( yceil - arrayindex.getY() ) * interpolval_x_L;
02259 float interpolval_y = ( arrayindex.getY() - yfloor ) * interpolval_y_H + ( yceil - arrayindex.getY() ) * interpolval_y_L;
02260 float interpolval_z = ( arrayindex.getY() - yfloor ) * interpolval_z_H + ( yceil - arrayindex.getY() ) * interpolval_z_L;
02261
02262 VVector interpolatedval = VVector( interpolval_x, interpolval_y, interpolval_z );
02263 VVector interp_mult = VVector( interpolatedval );
02264 interp_mult.setX( -interp_mult.getX( ) );
02265 interp_mult *= 0.05f *mStreamlinesDt;
02266
02267
02268 VVector oldpos_world = VVector();
02269 oldpos_world.setX( sactualpoint_x * dataextent_x + minx );
02270 oldpos_world.setY( sactualpoint_y * dataextent_y + miny );
02271
02272 VVector newpos_world = oldpos_world - interp_mult;
02273
02274 VVector newpos_tex = VVector();
02275 newpos_tex.setX( ( newpos_world.getX() - minx ) / dataextent_x );
02276 newpos_tex.setY( ( newpos_world.getY() - miny ) / dataextent_y );
02277
02278 if( ( newpos_tex.getX() ) > 1.0f || ( newpos_tex.getY() ) > 1.0f
02279 || ( newpos_tex.getX() ) < 0.0f || ( newpos_tex.getY() ) < 0.0f )
02280 {
02281 outofdata = true;
02282 break;
02283 }
02284
02285 sactualpoint_x = newpos_tex.getX();
02286 sactualpoint_y = newpos_tex.getY();
02287
02288
02289
02290 newpos_tex.setX( -( newpos_tex.getX() * dataextent_x ) + minx + dataextent_x);
02291 newpos_tex.setY( ( newpos_tex.getY() * dataextent_y ) + miny );
02292 streamlinevertices.push_back( newpos_tex );
02293
02294 float epsilon = 0.0000001f;
02295 VVector posdifference = streamlinevertices[ streamlinevertices.size() - 1 ] - streamlinevertices[ streamlinevertices.size() - 2 ];
02296 if ( posdifference.getMagnitude() < epsilon)
02297 {
02298 outofdata = true;
02299 break;
02300 }
02301
02302 }
02303
02304 if( !streamlinevertices.empty() )
02305 {
02306 streamlines[ j ] = VStreamLine( streamlinevertices ) ;
02307 streamlines[ j ].regenerateVBO();
02308 }
02309 }
02310
02311
02312
02313 pixeldata.clear();
02314 }
02315 void VFlowData::generateCPUStreamLinesMANUAL_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
02316 {}
02317
02318 void VFlowData::generateCPUStreamLinesEVEN_RK2( float m_MaxSteps, float m_StreamSeparation, int m_TimeStep )
02319 {
02320 }