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

SCM Repository

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

Annotation of /branches/pure-cfg/test/zslice-k1k2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 871 - (view) (download)
Original Path: branches/pure-cfg/test/quad-k1k2.diderot

1 : glk 866
2 :     // quad-k1k2: demo of curvature calculation on quad patch dataset
3 :    
4 :     int imgRes = 200;
5 :     int dataRes = 110;
6 :     vec3 orig = [0.0, 0.0, 10.0];
7 :     vec3 uVec = [1.0, 0.0, 0.0];
8 :     vec3 vVec = [0.0, 1.0, 0.0];
9 :     image(3)[] vol = load("../data/quad-patches-pad.nrrd");
10 :     field#2(3)[] F = vol ⊛ bspln3;
11 :     // HEY ( want) some kind of error upon redeclaration
12 :     // of variables; was getting confused by error messages
13 :     // associated with having used G both for green image (here)
14 :     // and geometry tensor (below)
15 :     image(2)[] imgR = load("../data/hue-0.nrrd"); field#0(2)[] RR = imgR ⊛ tent;
16 :     image(2)[] imgG = load("../data/hue-1.nrrd"); field#0(2)[] GG = imgG ⊛ tent;
17 :     image(2)[] imgB = load("../data/hue-2.nrrd"); field#0(2)[] BB = imgB ⊛ tent;
18 :     //image(2)[3] imgRGB = load("../data/hue.nhdr"); field#0(2)[3] RGB = imgRGB ⊛ tent;
19 :    
20 :     strand RayCast (int ui, int vi)
21 :     {
22 :     real uu = lerp(-0.5, real(dataRes)-0.5, -0.5, real(ui), real(imgRes)-0.5);
23 :     real vv = lerp(-0.5, real(dataRes)-0.5, -0.5, real(vi), real(imgRes)-0.5);
24 :     output vec3 rgb = [0.0,0.0,0.0];
25 :    
26 :     update
27 :     {
28 :     vec3 pos = orig + uu*uVec + vv*vVec;
29 :     if (inside (pos,F)) {
30 :     vec3 g = ∇F@pos;
31 :     // the "if (g[2] < -0.10)" test is specific to this dataset;
32 :     // it assesses if we're within one of the quadratic patches
33 :     if (g[2] < -0.10) {
34 :     vec3 n = normalize(g);
35 :     tensor[3,3] H = ∇(∇F)@pos;
36 :     tensor[3,3] P = identity[3] - n⊗n;
37 :     tensor[3,3] G = (P•H•P)/|g|;
38 :     real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2));
39 :     real k1 = (trace(G) + disc)/2.0;
40 :     real k2 = (trace(G) - disc)/2.0;
41 :     // correct curvature computation ends here
42 : glk 871 k1 = max(-0.99, min(0.99, 4.2*k1));
43 :     k2 = max(-0.99, min(0.99, 4.2*k2));
44 : glk 866 vec2 kk = [k1,k2];
45 :     rgb = [RR@kk,GG@kk,BB@kk] if inside(kk,RR)
46 :     else [0.0,0.0,0.0];
47 :     //rgb = RGB@kk if inside(kk,RGB) else [0.0,0.0,0.0];
48 :     }
49 :     }
50 :     stabilize;
51 :     }
52 :     }
53 :    
54 :     initially [ RayCast(ui, vi) | vi in 0..(imgRes-1), ui in 0..(imgRes-1) ];

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