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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/lic.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/lic.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 935 - (view) (download)

1 : glk 934 // lic.diderot
2 :     //
3 :     // simple demo of the line integral convolution (LIC) method
4 :     // of vector field viz
5 :     //
6 :     // process output with:
7 :     // unu reshape -i mip.txt -s 300 200 | unu quantize -b 8 -o lic.png
8 : glk 935 //
9 :     // NOTE: this computes a streamline along only one direction of
10 :     // field at starting point; it would be more correct to go
11 :     // in both directions (both upstream and downstream)
12 : glk 934
13 :     int imgSizeX = 300;
14 :     int imgSizeY = 200;
15 :     real h = 0.01;
16 :     int stepNum = 20;
17 :    
18 :     image(2)[2] Vimg = load("../data/vorttest.nrrd");
19 :     field#1(2)[2] V = Vimg ⊛ ctmr;
20 :     image(2)[] Rimg = load("../data/vorttest-rand.nrrd");
21 :     field#0(2)[] R = Rimg ⊛ tent;
22 :    
23 :     strand LIC (int xi, int yi) {
24 :     real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
25 :     real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
26 :     vec2 pos0 = [xx,yy];
27 :     vec2 pos = pos0;
28 :     output real avg = 0.0;
29 :     int step = 0;
30 :    
31 :     update {
32 :     avg = avg + R(pos);
33 :     // pos = pos + h*V(pos); // Euler step
34 :     pos = pos + h*V(pos + 0.5*h*V(pos)); // RK2 step
35 :     step = step + 1;
36 :     if (step == stepNum) {
37 :     // modulate output by velocity at initial position
38 :     avg = |V(pos0)|*avg/real(stepNum);
39 :     stabilize;
40 :     }
41 :     }
42 :     }
43 :    
44 :     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