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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1664 - (view) (download)

1 : lamonts 1664 /*! \file ridge3d.diderot
2 :     *
3 :     * \author Gordon Kindlmann
4 :     */
5 : glk 1565
6 : lamonts 1664 /*
7 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
8 :     * All rights reserved.
9 :     */
10 :    
11 : glk 1565 int gridSize = 120;
12 :     field#2(3)[] F = bspln3 ⊛ load("../data/lungcrop.nrrd");
13 : lamonts 1664 input int stepsMax = 30;
14 :     input real epsilon = 0.001;
15 :     input real travelMax = 5.0;
16 :     input real strnMin = 170.0;
17 : glk 1565
18 :     strand sample (int ui, int vi, int wi) {
19 :     output vec3 pos = [lerp(21.6401, 21.6401 + 140.0*0.5,
20 :     -0.5, real(ui), real(gridSize)-0.5),
21 :     lerp(-175.8792, -175.8792 + 200.0*0.5,
22 :     -0.5, real(vi), real(gridSize)-0.5),
23 :     lerp(-188.0000, -188.0000 + 140.0*0.5,
24 :     -0.5, real(wi), real(gridSize)-0.5)];
25 :     int steps = 0;
26 :     real travel = 0.0;
27 :     update {
28 : lamonts 1664 if (!inside(pos, F) || steps > stepsMax || travel > travelMax)
29 : glk 1565 die;
30 :     real gmag = |∇F(pos)|;
31 : lamonts 1664 if (gmag == 0.0) // can't compute step if |∇F|, so have to bail
32 : glk 1565 die;
33 :     vec3 grad = ∇F(pos);
34 :     tensor[3,3] hess = ∇⊗∇F(pos);
35 : lamonts 1664
36 : glk 1565 real{3} eval = evals(hess);
37 : lamonts 1664 real strn = -eval{1};
38 : glk 1565 vec3{3} evec = evecs(hess);
39 :     vec3 dir = normalize((evec{2}⊗evec{2} + evec{1}⊗evec{1})•grad);
40 : lamonts 1664
41 : glk 1565 real fdd = grad•dir;
42 :     real sdd = dir•hess•dir;
43 :     vec3 delta = (0.1 if sdd >= 0.0 else -fdd/sdd)*dir;
44 :     if (|delta| < epsilon) {
45 : lamonts 1664 if (strn >= strnMin)
46 : glk 1565 stabilize;
47 :     die;
48 :     }
49 :     pos += delta;
50 :     steps += 1;
51 :     travel += |delta|;
52 :     }
53 :     }
54 :    
55 :     initially { sample(ui, vi, wi) |
56 :     wi in 0..(gridSize-1),
57 :     vi in 0..(gridSize-1),
58 :     ui in 0..(gridSize-1) };

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