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

SCM Repository

[diderot] Annotation of /branches/vis12/bugs/open/bug027.diderot
ViewVC logotype

Annotation of /branches/vis12/bugs/open/bug027.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2334 - (view) (download)

1 : glk 2334 // bug: won't work: field#1(2)[] F = bspln3 ⊛ image("../data/ddro.nrrd") - isoval;
2 :     // field#2(2)[] F = bspln3 ⊛ image("../data/ddro.nrrd") - isoval;
3 :    
4 :    
5 :     /*
6 :     $DDRO_HOME/branches/vis12/bin/diderotc --exec bug027.diderot \
7 :     && ./bug027 \
8 :     && unu jhisto -i x.nrrd -b 800 800 -min 0 0 -max 1 1 \
9 :     | unu 2op neq - 0 \
10 :     | unu quantize -b 8 -o bug027.png
11 :     */
12 :    
13 :     input real isoval = 0.5;
14 :     /* BUG: it looks like the type promotion from field#2 to field#1
15 :     doesn't work with subtracting a constant
16 :     error converting OffsetField
17 :     uncaught exception Fail [Fail: bogus operator OffsetField]
18 :     raised at common/phase-timer.sml:76.50-76.52
19 :     raised at common/phase-timer.sml:76.50-76.52
20 :     raised at high-to-mid/high-to-mid.sml:297.85-297.87
21 :     raised at high-to-mid/high-to-mid.sml:294.32-294.78
22 :     */
23 :     field#1(2)[] F = bspln3 ⊛ image("../data/ddro.nrrd") - isoval;
24 :    
25 :     int grid = 150;
26 :     int stepsMax = 10;
27 :     real epsilon = 0.000001;
28 :    
29 :     strand RootFind(vec2 x0) {
30 :     output vec2 x = x0;
31 :     int steps = 0;
32 :     update {
33 :     // Stop if we're no longer inside or taken too many steps.
34 :     if (!inside(x, F) || steps > stepsMax)
35 :     die;
36 :     vec2 grad = ∇F(x);
37 :     // subsequent expressions are undefined if |∇F| is zero
38 :     if (|grad| == 0.0)
39 :     die;
40 :     // the Newton-Raphson step
41 :     vec2 delta = normalize(grad) * F(x)/|grad|;
42 :     // we've converged if the change is small enough
43 :     if (|delta| < epsilon)
44 :     stabilize;
45 :     x -= delta;
46 :     steps += 1;
47 :     }
48 :     }
49 :    
50 :     initially { RootFind([lerp(0, 1, -0.5, ui, grid-0.5),
51 :     lerp(0, 1, -0.5, vi, grid-0.5)])
52 :     | vi in 0..(grid-1), ui in 0..(grid-1) };
53 :    
54 :     /*
55 :     different in 3D:
56 :     vec2 -> vec3
57 :     field#1(2)[] F -> field#1(3)[] F
58 :     initially over 3D grid
59 :     */

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