source: nanovis/trunk/LIC.cpp @ 5722

Last change on this file since 5722 was 4901, checked in by ldelgass, 9 years ago

sync with release branch

  • Property svn:eol-style set to native
File size: 14.9 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[587]2/*
[3502]3 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
[587]4 *
[3612]5 *  Authors:
[4894]6 *    Insoo Woo <iwoo@purdue.edu>
[3612]7 *    Wei Qiao <qiaow@purdue.edu>
[587]8 */
9#include <stdlib.h>
10#include <math.h>
11#include <assert.h>
12
[2967]13#include "nanovis.h"
14#include "define.h"
[2831]15
[3611]16#include "LIC.h"
[3612]17#include "Shader.h"
[2831]18#include "Trace.h"
[587]19
[2847]20#define NPN 256   //resolution of background pattern
21#define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines
22#define SCALE 3.0 //scale for background pattern. small value -> fine texture
23
[3611]24using namespace nv;
[3492]25using namespace vrmath;
26
[4901]27LIC::LIC(FlowSliceAxis axis, float offset) :
[3630]28    _width(NPIX),
29    _height(NPIX),
30    _size(NMESH),
[2920]31    _scale(1.0f, 1.0f, 1.0f),
32    _origin(0, 0, 0),
33    _offset(offset),
34    _axis(axis),
35    _iframe(0),
36    _Npat(64),
37    _alpha((int)0.12*255),
38    _tmax(NPIX/(SCALE*NPN)),
39    _dmax(SCALE/NPIX),
40    _max(1.0f),
41    _disListID(0),
[1515]42    _vectorFieldId(0),
[3630]43    _visible(false)
[587]44{
[3630]45    _sliceVector = new float[_size * _size * 4];
[2920]46    memset(_sliceVector, 0, sizeof(float) * _size * _size * 4);
[1370]47
[2920]48    int fboOrig;
49    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[587]50
[851]51    //initialize the pattern texture
[2920]52    glGenTextures(1, &_patternTex);
53    glBindTexture(GL_TEXTURE_2D, _patternTex);
[1431]54    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
55    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
[2967]56    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
57    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
[2920]58    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
59                 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
60
[851]61    //initialize frame buffer objects
62    //render buffer for projecting 3D velocity onto a 2D plane
[2920]63    glGenFramebuffersEXT(1, &_velFbo);
64    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
[587]65
[4167]66    glGenTextures(1, &_sliceVectorTex);
[2920]67    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _sliceVectorTex);
[2884]68    glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
69    glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
[4901]70    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
71    glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
[2920]72    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA32F_ARB, _size, _size,
73                 0, GL_RGBA, GL_FLOAT, NULL);
[851]74
75    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
[2920]76                              GL_TEXTURE_RECTANGLE_ARB, _sliceVectorTex, 0);
[587]77
[851]78    //render buffer for the convolution
[2920]79    glGenFramebuffersEXT(1, &_fbo);
80    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
[587]81
[851]82    //initialize color texture for lic
[4167]83    glGenTextures(1, &_colorTex);
[2920]84    glBindTexture(GL_TEXTURE_2D, _colorTex);
85    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
86    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
[4901]87    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
88    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
[2920]89    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, _width, _height, 0,
90                 GL_RGB, GL_UNSIGNED_BYTE, NULL);
[851]91
[2920]92    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
93                              GL_TEXTURE_2D, _colorTex, 0);
[587]94
[851]95    // Check framebuffer completeness at the end of initialization.
96    CHECK_FRAMEBUFFER_STATUS();
[587]97
[2920]98    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[587]99
[3612]100    _renderVelShader = new Shader();
[3630]101    _renderVelShader->loadFragmentProgram("render_vel.cg");
[2847]102
[2920]103    makePatterns();
[587]104}
105
[3611]106LIC::~LIC()
[851]107{
[2920]108    glDeleteTextures(1, &_patternTex);
109    glDeleteTextures(1, &_magTex);
[1481]110
[2920]111    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
112    glDeleteTextures(1, &_sliceVectorTex);
[587]113
[2920]114    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
115    glDeleteTextures(1, &_colorTex);
[587]116
[2920]117    GLuint buffers[2] = {_velFbo, _fbo};
[851]118    glDeleteFramebuffersEXT(2, buffers);
[587]119
[2920]120    glDeleteLists(_disListID, _Npat);
[851]121
[2920]122    delete _renderVelShader;
123
124    delete [] _sliceVector;
[587]125}
126
[984]127void
[3611]128LIC::makePatterns()
[587]129{
[3452]130    TRACE("Enter");
131
[2920]132    if (_disListID > 0) {
133        glDeleteLists(_disListID, _Npat);
[1510]134    }
[2920]135    _disListID = glGenLists(_Npat);
[2847]136
[3452]137    TRACE("DisplayList : %d", _disListID);
[2847]138
[984]139    int lut[256];
140    int phase[NPN][NPN];
141    GLubyte pat[NPN][NPN][4];
142    int i, j, k, t;
[2847]143
[984]144    for (i = 0; i < 256; i++) {
[1028]145        lut[i] = i < 127 ? 0 : 255;
[984]146    }
147    for (i = 0; i < NPN; i++) {
[1028]148        for (j = 0; j < NPN; j++) {
[2847]149            phase[i][j] = rand() >> 8;
[851]150        }
[984]151    }
[2920]152    for (k = 0; k < _Npat; k++) {
153        t = (k << 8) / _Npat;
[1028]154        for (i = 0; i < NPN; i++) {
155            for (j = 0; j < NPN; j++) {
156                pat[i][j][0] = pat[i][j][1] = pat[i][j][2] =
157                    lut[(t + phase[i][j]) % 255];
[2920]158                pat[i][j][3] = _alpha;
[1028]159            }
160        }
[2920]161        glNewList(_disListID + k, GL_COMPILE);
162        glBindTexture(GL_TEXTURE_2D, _patternTex);
163        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
164                     GL_RGBA, GL_UNSIGNED_BYTE, pat);
[1028]165        glEndList();
[984]166    }
[2847]167
[2920]168    glBindTexture(GL_TEXTURE_2D, _patternTex);
169    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NPN, NPN, 0,
[1028]170                 GL_RGBA, GL_UNSIGNED_BYTE, pat);
[3452]171
172    TRACE("Leave");
[587]173}
174
[3630]175void
176LIC::makeMagnitudes()
[587]177{
[851]178    GLubyte mag[NMESH][NMESH][4];
[587]179
[2847]180    //read vector field
181    for (int i = 0; i < NMESH; i++) {
182        for (int j = 0; j < NMESH; j++) {
183            float x = DM*i;
184            float y = DM*j;
185 
[1028]186            float magnitude = sqrt(x*x+y*y)/1.414;
[2847]187
[1028]188            //from green to red
[2847]189            GLubyte r = (GLubyte)floor(magnitude*255);
[1028]190            GLubyte g = 0;
191            GLubyte b = 255 - r;
192            GLubyte a = 122;
[2847]193
[1028]194            mag[i][j][0] = r;
195            mag[i][j][1] = g;
196            mag[i][j][2] = b;
197            mag[i][j][3] = a;
[851]198        }
[587]199    }
[2920]200    glGenTextures(1, &_magTex);
201    glBindTexture(GL_TEXTURE_2D, _magTex);
[851]202    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
203    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
204    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
205    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
[1028]206    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, NMESH, NMESH, 0, GL_RGBA,
207                 GL_UNSIGNED_BYTE, mag);
[851]208    glBindTexture(GL_TEXTURE_2D, 0);
[587]209}
210
[1028]211void
[3611]212LIC::getSlice()
[851]213{
[2920]214    int fboOrig;
215    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[587]216
[2920]217    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _velFbo);
218
219    glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT);
220
[851]221    glClear(GL_COLOR_BUFFER_BIT);
[2920]222    glDisable(GL_DEPTH_TEST);
223    glDisable(GL_BLEND);
[587]224
[2920]225    glViewport(0, 0, _size, _size);
[851]226    glMatrixMode(GL_PROJECTION);
[2920]227    glPushMatrix();
[851]228    glLoadIdentity();
[2920]229    gluOrtho2D(0, _size, 0, _size);
[851]230    glMatrixMode(GL_MODELVIEW);
[2920]231    glPushMatrix();
[851]232    glLoadIdentity();
[587]233
[851]234    glEnable(GL_TEXTURE_3D);
[1515]235    glBindTexture(GL_TEXTURE_3D, _vectorFieldId);
[587]236
[2920]237    _renderVelShader->bind();
[2967]238    _renderVelShader->setFPTextureParameter("vel_tex", _vectorFieldId);
239    _renderVelShader->setFPParameter1f("timestep", 0.0005);
240    _renderVelShader->setFPParameter1f("vmax", _max > 100.0 ? 100.0 : _max);
[851]241
[2967]242    switch (_axis) {
[3630]243    case AXIS_X:
[2967]244        _renderVelShader->setFPParameter3f("projection_vector", 0., 1., 1.);
245        break;
[3630]246    case AXIS_Y:
[2967]247        _renderVelShader->setFPParameter3f("projection_vector", 1., 0., 1.);
248        break;
249    default:
[3630]250    case AXIS_Z:
[2967]251        _renderVelShader->setFPParameter3f("projection_vector", 1., 1., 0.);
252        break;
253    }
254
[851]255    glBegin(GL_QUADS);
[1028]256    {
[2920]257        switch (_axis) {
[3630]258        case AXIS_X:
[2951]259            glTexCoord3f(_offset, 0., 0.); glVertex2f(0.,    0.);
260            glTexCoord3f(_offset, 1., 0.); glVertex2f(_size, 0.);
261            glTexCoord3f(_offset, 1., 1.); glVertex2f(_size, _size);
262            glTexCoord3f(_offset, 0., 1.); glVertex2f(0.,    _size);
[2967]263            break;
[3630]264        case AXIS_Y:
[2951]265            glTexCoord3f(0., _offset, 0.); glVertex2f(0.,    0.);
266            glTexCoord3f(1., _offset, 0.); glVertex2f(_size, 0.);
267            glTexCoord3f(1., _offset, 1.); glVertex2f(_size, _size);
268            glTexCoord3f(0., _offset, 1.); glVertex2f(0.,    _size);
[2967]269            break;
[3630]270        case AXIS_Z:
[2951]271            glTexCoord3f(0., 0., _offset); glVertex2f(0.,    0.);
272            glTexCoord3f(1., 0., _offset); glVertex2f(_size, 0.);
273            glTexCoord3f(1., 1., _offset); glVertex2f(_size, _size);
274            glTexCoord3f(0., 1., _offset); glVertex2f(0.,    _size);
[2920]275            break;
276        }
[1028]277    }
[851]278    glEnd();
[2847]279
[2967]280    _renderVelShader->disableFPTextureParameter("vel_tex");
[2920]281    _renderVelShader->unbind();
[2847]282
[851]283    glBindTexture(GL_TEXTURE_3D, 0);
284    glDisable(GL_TEXTURE_3D);
285
286    //read the vectors
[2920]287    glReadPixels(0, 0, _size, _size, GL_RGBA, GL_FLOAT, _sliceVector);
[851]288
[2920]289    int lim = _size * _size * 4;
290    float *v = _sliceVector;
[1028]291    for (int i = 0; i < lim; ++i) {
292        if (isnan(*v)) {
293            *v = 0.0f;   
294        }
[851]295        ++v;
296    }
[2920]297
298    glMatrixMode(GL_PROJECTION);
299    glPopMatrix();
300    glMatrixMode(GL_MODELVIEW);
301    glPopMatrix();
302
303    glPopAttrib();
304
305    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[587]306}
307
308//line integral convolution
[1028]309void
[3611]310LIC::convolve()
[851]311{
[1515]312    if (_vectorFieldId == 0) {
[2920]313        return;
[1431]314    }
[1370]315
[851]316    int   i, j;
317    float x1, x2, y, px, py;
[2847]318
[2920]319    int fboOrig;
320    glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fboOrig);
[2847]321
[2920]322    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
323
[4167]324    glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_TEXTURE_BIT);
[2920]325
[851]326    glMatrixMode(GL_PROJECTION);
[2920]327    glPushMatrix();
328    glLoadIdentity();
[1429]329
[851]330    glViewport(0, 0, (GLsizei) NPIX, (GLsizei) NPIX);
331    //glTranslatef(-1.0, -1.0, 0.0);
332    //glScalef(2.0, 2.0, 1.0);
333    glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -10.0f, 10.0f);
[2847]334
[851]335    glMatrixMode(GL_MODELVIEW);
[2920]336    glPushMatrix();
337    glLoadIdentity();
[2847]338
[2920]339    glClear(GL_COLOR_BUFFER_BIT);
340    //glDepthMask(GL_FALSE);
341    glDisable(GL_DEPTH_TEST);
342    glDisable(GL_LIGHTING);
343    glDisable(GL_ALPHA_TEST);
[2847]344
[2920]345    //_sa = 0.010*cos(_iframe*2.0*M_PI/200.0);
[851]346    glEnable(GL_TEXTURE_2D);
[2920]347    glBindTexture(GL_TEXTURE_2D, _patternTex);
[4167]348    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
[2920]349    _sa = 0.01;
[2847]350 
[2920]351    glColor4f(1, 1, 1, 1);
[1028]352    for (i = 0; i < NMESH-1; i++) {
[851]353        x1 = DM*i; x2 = x1 + DM;
354        glBegin(GL_QUAD_STRIP);
355        for (j = 0; j < NMESH-1; j++) {
[1028]356            y = DM*j;
[2967]357            glTexCoord2f(x1, y);
[2920]358            getVelocity(x1, y, &px, &py);
[1028]359            glVertex2f(px, py);
[2920]360
[2967]361            glTexCoord2f(x2, y);
362            getVelocity(x2, y, &px, &py);
[1028]363            glVertex2f(px, py);
[851]364        }
365        glEnd();
[1028]366    }
[2920]367    _iframe = _iframe + 1;
[2847]368
369    glEnable(GL_BLEND);
370
[851]371    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[2847]372
[851]373    glEnable(GL_TEXTURE_2D);
[2920]374    glCallList(_iframe % _Npat + _disListID);
[2967]375    glBegin(GL_QUADS);
[1028]376    {
[2920]377        glTexCoord2f(0.0,   0.0);   glVertex2f(0.0, 0.0);
378        glTexCoord2f(_tmax, 0.0);   glVertex2f(1.0, 0.0);
379        glTexCoord2f(_tmax, _tmax); glVertex2f(1.0, 1.0);
[2967]380        glTexCoord2f(0.0,   _tmax); glVertex2f(0.0, 1.0);
[1028]381    }
[2967]382    glEnd();
[851]383    glDisable(GL_TEXTURE_2D);
[2847]384
[1028]385    /*
386    //inject dye
387    glDisable(GL_TEXTURE_2D);
388    glColor4f(1.,0.8,0.,1.);
389    glBegin(GL_QUADS);
390    glVertex2d(0.6, 0.6);
391    glVertex2d(0.6, 0.62);
392    glVertex2d(0.62, 0.62);
393    glVertex2d(0.62, 0.6);
394    glEnd();
395    */
[2847]396
[1028]397    glDisable(GL_BLEND);
398    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, NPIX, NPIX, 0);
[2847]399
[1028]400    /*
401    //blend magnitude texture
[2920]402    glBindTexture(GL_TEXTURE_2D, _magTex);
[1028]403    glEnable(GL_TEXTURE_2D);
404    glEnable(GL_BLEND);
405    glBegin(GL_QUADS);
406    glTexCoord2f(0.0,  0.0);  glVertex2f(0.0, 0.0);
407    glTexCoord2f(0.0,  1.0); glVertex2f(0.0, 1.);
408    glTexCoord2f(1.0, 1.0);  glVertex2f(1., 1.);
409    glTexCoord2f(1.0, 0.0); glVertex2f(1., 0.0);
410    glEnd();
411    */
[851]412
[2920]413    glMatrixMode(GL_PROJECTION);
[851]414    glPopMatrix();
415    glMatrixMode(GL_MODELVIEW);
[2920]416    glPopMatrix();
[587]417
[2920]418    glPopAttrib();
419
420    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
[2837]421}
[587]422
[1028]423void
[3611]424LIC::render()
[851]425{
[3630]426    if (_vectorFieldId == 0 || !_visible) {
[2920]427        return;
[1431]428    }
[1370]429
[2920]430    //draw line integral convolution quad
431
[4167]432    glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
[2920]433    glBindTexture(GL_TEXTURE_2D, _colorTex);
[4167]434    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
[1028]435    glEnable(GL_TEXTURE_2D);
[2920]436    //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
437    //glEnable(GL_LIGHTING);
438    glDisable(GL_LIGHTING);
[1028]439    glEnable(GL_DEPTH_TEST);
[2847]440
[2920]441    glMatrixMode(GL_MODELVIEW);
[1028]442    glPushMatrix();
[2847]443
[2920]444    glTranslatef(_origin.x, _origin.y, _origin.z);
[2967]445    glScalef(_scale.x, _scale.y, _scale.z);
[2847]446
[2920]447    glColor4f(1, 1, 1, 1);
[1028]448    glBegin(GL_QUADS);
[2920]449    switch (_axis) {
[3630]450    case AXIS_X:
[2920]451        glNormal3f(1, 0, 0);
[2951]452        glTexCoord2f(0, 0); glVertex3f(_offset, 0, 0);
453        glTexCoord2f(1, 0); glVertex3f(_offset, 1, 0);
454        glTexCoord2f(1, 1); glVertex3f(_offset, 1, 1);
455        glTexCoord2f(0, 1); glVertex3f(_offset, 0, 1);
[2920]456        break;
[3630]457    case AXIS_Y:
[2920]458        glNormal3f(0, 1, 0);
[2951]459        glTexCoord2f(0, 0); glVertex3f(0, _offset, 0);
460        glTexCoord2f(1, 0); glVertex3f(1, _offset, 0);
461        glTexCoord2f(1, 1); glVertex3f(1, _offset, 1);
462        glTexCoord2f(0, 1); glVertex3f(0, _offset, 1);
[2920]463        break;
[3630]464    case AXIS_Z:
[2920]465        glNormal3f(0, 0, 1);
[2951]466        glTexCoord2f(0, 0); glVertex3f(0, 0, _offset);
467        glTexCoord2f(1, 0); glVertex3f(1, 0, _offset);
468        glTexCoord2f(1, 1); glVertex3f(1, 1, _offset);
469        glTexCoord2f(0, 1); glVertex3f(0, 1, _offset);
[2920]470        break;
[1028]471    }
472    glEnd();
[2847]473
[1028]474    glPopMatrix();
[2847]475
[2920]476    glBindTexture(GL_TEXTURE_2D, 0);
[2847]477
[2920]478    glPopAttrib();
[1028]479}
[851]480
[1028]481void
[3630]482LIC::setVectorField(Volume *volume)
[851]483{
[3630]484    TRACE("LIC: vector field is assigned [%d]", volume->textureID());
[1370]485
[3630]486    _vectorFieldId = volume->textureID();
487    Vector3f bmin, bmax;
488    volume->getBounds(bmin, bmax);
489    _origin = bmin;
490    _scale.set(bmax.x-bmin.x, bmax.y-bmin.y, bmax.z-bmin.z);
491    _max = volume->wAxis.max();
492
[2920]493    makePatterns();
[2847]494
[2920]495    getSlice();
[851]496}
497
[1028]498void
[3611]499LIC::getVelocity(float x, float y, float *px, float *py)
[587]500{
[851]501   float vx, vy, r;
[587]502
[2920]503   int xi = (int)(x*_size);
504   int yi = (int)(y*_size);
[587]505
[1984]506    //TRACE("(xi yi) = (%d %d), ", xi, yi);
[2967]507   switch (_axis) {
[3630]508   case AXIS_X:
[2967]509       vx = _sliceVector[4 * (xi+yi*_size)+2];
510       vy = _sliceVector[4 * (xi+yi*_size)+1];
511       break;
[3630]512   case AXIS_Y:
[2967]513       vx = _sliceVector[4 * (xi+yi*_size)];
514       vy = _sliceVector[4 * (xi+yi*_size)+2];
515       break;
[3630]516   case AXIS_Z:
[2967]517   default:
518       vx = _sliceVector[4 * (xi+yi*_size)];
519       vy = _sliceVector[4 * (xi+yi*_size)+1];
520       break;
521   }
[587]522   r  = vx*vx + vy*vy;
[851]523
[1984]524    //TRACE("(vx vx) = (%f %f), r=%f, ", vx, vy, r);
[2920]525   if (r > (_dmax * _dmax)) {
[2847]526      r  = sqrt(r);
[2920]527      vx *= _dmax/r;
528      vy *= _dmax/r;
[587]529   }
[851]530
[2847]531   *px = x + vx;
[587]532   *py = y + vy;
[851]533
[3452]534    //TRACE("vel %f %f -> %f %f, (dmax = %f)", x, y, *px, *py, dmax);
[587]535}
536
[1028]537void
[3630]538LIC::setSlicePosition(float offset)
[587]539{
[2951]540    _offset = offset;
[2920]541    getSlice();
[587]542}
[1311]543
[3630]544void LIC::setSliceAxis(FlowSliceAxis axis)
[1311]545{
[2920]546    _axis = axis;
[1311]547}
548
[3611]549void LIC::reset()
[1370]550{
[2920]551    makePatterns();
[1370]552}
Note: See TracBrowser for help on using the repository browser.