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

SCM Repository

[diderot] View of /branches/charisee/test/ridge3d.diderot
ViewVC logotype

View of /branches/charisee/test/ridge3d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (download) (annotate)
Tue Oct 27 15:16:36 2015 UTC (4 years ago) by jhr
File size: 1827 byte(s)
making copyrights consistent for all code in the repository
/*! \file ridge3d.diderot
 *
 * \author Gordon Kindlmann
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 */

int gridSize = 120;
field#2(3)[] F = bspln3 ⊛ image("../data/lungcrop.nrrd");
input int stepsMax = 30;
input real epsilon = 0.001;
input real travelMax = 5.0;
input real strnMin = 170.0;

strand sample (int ui, int vi, int wi) {
    output vec3 pos = [lerp(21.6401, 21.6401 + 140.0*0.5,
                              -0.5, real(ui), real(gridSize)-0.5),
                       lerp(-175.8792, -175.8792 + 200.0*0.5, 
                              -0.5, real(vi), real(gridSize)-0.5),
                       lerp(-188.0000, -188.0000 + 140.0*0.5,
                              -0.5, real(wi), real(gridSize)-0.5)];
    int steps = 0;
    real travel = 0.0;
    update {
        if (!inside(pos, F) || steps > stepsMax || travel > travelMax)
	    die;
        real gmag = |∇F(pos)|;
        if (gmag == 0.0)    // can't compute step if |∇F|, so have to bail
	    die;
        vec3 grad = ∇F(pos);
        tensor[3,3] hess = ∇⊗∇F(pos);

        real{3} eval = evals(hess);
        real strn = -eval{1};
        vec3{3} evec = evecs(hess);
        vec3 dir = normalize((evec{2}⊗evec{2} + evec{1}⊗evec{1})•grad);

        real fdd = grad•dir;
        real sdd = dir•hess•dir;
        vec3 delta = (0.1 if sdd >= 0.0 else -fdd/sdd)*dir;
        if (|delta| < epsilon) {
           if (strn >= strnMin)
             stabilize;
           die;
        }
        pos += delta;
        steps += 1;
        travel += |delta|;
    }
}

initially { sample(ui, vi, wi) | 
             wi in 0..(gridSize-1), 
             vi in 0..(gridSize-1), 
             ui in 0..(gridSize-1) };

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