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

SCM Repository

[diderot] Annotation of /examples/curve-lic/lic.diderot
ViewVC logotype

Annotation of /examples/curve-lic/lic.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 2872 /*! \file lic.diderot
2 :     *
3 :     * \author John Reppy
4 :     *
5 :     * This Diderot program implements a lic on an iso surface that was discovered by
6 :     * the rcast.diderot program.
7 :     */
8 :    
9 :     /*
10 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
11 :     *
12 :     * COPYRIGHT (c) 2015 The University of Chicago
13 : jhr 2872 * All rights reserved.
14 :     */
15 :    
16 :     input image(2)[] nDepth; // depth output from RCast phase
17 :     field D = tent ⊛ nDepth;
18 :    
19 :     field#1(2)[2] V = image("data/vfrhand-nohip-smooth.nrrd") ⊛ bspln3;
20 :     field#0(2)[] R = image("data/turb2d.nrrd") ⊛ tent; // noise field
21 :    
22 :     strand LIC (int xi, int yi) {
23 :    
24 :     vec3 pos0 = [xx, yy, -D([xx,yy])]; // viewing plane is X-Y plane looking toward -Z
25 :     vec3 forw = pos0;
26 :     vec3 back = pos0;
27 :     int step = 0;
28 :     output real sum = R(pos0);
29 :    
30 :     /* what I'd like to be able to write:
31 :     initially {
32 :     if (isNan(sum)) {
33 :     stabilize;
34 :     }
35 :     }
36 :     */
37 :    
38 :     update {
39 :     if (isNan(sum)) {
40 :     sum = 0;
41 :     stabilize;
42 :     }
43 :     // Euler integration step
44 :     // forw = forw + h*V(forw);
45 :     // back = back - h*V(back);
46 :     // Midpoint method step
47 :     forw += h*V(forw + 0.5*h*V(forw));
48 :     back -= h*V(back - 0.5*h*V(back));
49 :     sum += R(forw) + R(back);
50 :     step += 1;
51 :     if (step == stepNum) {
52 :     // modulate output by velocity at initial position
53 :     sum = |V(pos0)|*sum/real(1 + 2*stepNum);
54 :     stabilize;
55 :     }
56 :     }
57 :    
58 :     } /* strand LIC */
59 :    
60 :    
61 :     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