Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis12/test/lic2.diderot
ViewVC logotype

View of /branches/vis12/test/lic2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2366 - (download) (annotate)
Fri Apr 12 19:41:04 2013 UTC (6 years, 3 months ago) by jhr
File size: 1420 byte(s)
  Fixed bug
// lic.diderot
// 
// simple demo of the line integral convolution (LIC) method
// of vector field viz
//
// process output with:
// unu reshape -i mip.txt -s 300 200 | unu quantize -b 8  -o lic.png

int imgSizeX = 300;
int imgSizeY = 200;
real h = 0.01;    // step size of integration
int stepNum = 25; // take this many steps both upstream and downstream

field#1(2)[2] V = image("../data/vorttest.nrrd") ⊛ ctmr;
field#0(2)[] R = image("../data/vorttest-rand.nrrd") ⊛ tent;

strand LIC (int xi, int yi) {
    real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
    real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
    vec2 pos0 = [xx,yy];
    vec2 pos = [xx,yy];
    bool forw = true;
    output real sum = R(pos0);
    output int step = 0;

    update {
        if (forw) {
            pos += h*V(pos + 0.5*h*V(pos));
            sum += R(pos);
            if (step == stepNum) {
                forw = false;
                pos = pos0;
		step = 0;
            }
        } else {  // going backwards, not forward
            pos -= h*V(pos - 0.5*h*V(pos));
            sum += R(pos);
            if (step == stepNum) {
                // modulate output by velocity at initial position
                sum = |V(pos0)|*sum/real(1 + 2*stepNum);
                stabilize;
            }
        }
	step += 1;
    }
}

initially [ LIC(xi, yi) | yi in 0..(imgSizeY-1), xi in 0..(imgSizeX-1) ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0