X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FGrid.hs;h=5ff4aa28ab95b4e3ad62c9798ccb836327d57164;hb=ec2bcae0167bcc09c30e7618a5d7601510593610;hp=742360f5d799993f47ce2cb38adf3f3cfc46ae6f;hpb=638f544b522157f83b075e07a70b2f106e01ec68;p=spline3.git diff --git a/src/Grid.hs b/src/Grid.hs index 742360f..5ff4aa2 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -6,7 +6,8 @@ module Grid ( grid_tests, make_grid, slow_tests, - zoom + zoom, + zoom_chunk ) where @@ -71,8 +72,9 @@ cubes delta fvs j <- [0..ymax], k <- [0..zmax], let tet_vol = (1/24)*(delta^(3::Int)), + let fvs' = make_values fvs i j k, let cube_ijk = - Cube delta i j k (make_values fvs i j k) tet_vol] + Cube delta i j k fvs' tet_vol] where xmax = xsize - 1 ymax = ysize - 1 @@ -150,7 +152,8 @@ zoom_result g (sfx, sfy, sfz) (R.Z R.:. m R.:. n R.:. o) = cube = find_containing_cube g p t = find_containing_tetrahedron cube p f = polynomial t - + + zoom :: Grid -> ScaleFactor -> Values3D zoom g scale_factor | xsize == 0 || ysize == 0 || zsize == 0 = empty3d @@ -164,6 +167,43 @@ zoom g scale_factor +{-# INLINE zoom_chunk_lookup #-} +zoom_chunk_lookup :: Grid -> ScaleFactor -> a -> (R.DIM3 -> Double) +zoom_chunk_lookup g scale_factor _ = + zoom_chunk_result g scale_factor + + +{-# INLINE zoom_chunk_result #-} +zoom_chunk_result :: Grid -> ScaleFactor -> R.DIM3 -> Double +zoom_chunk_result g (sfx, sfy, sfz) (R.Z R.:. m R.:. n R.:. o) + | m /= 1 = 0 -- We're going to drop these anyway. + | otherwise = f p + where + offset = (h g)/2 + sfx' = fromIntegral sfx + sfy' = fromIntegral sfy + sfz' = fromIntegral sfz + m' = (fromIntegral m) / sfx' - offset + n' = (fromIntegral n) / sfy' - offset + o' = (fromIntegral o) / sfz' - offset + p = (m', n', o') :: Point + cube = find_containing_cube g p + t = find_containing_tetrahedron cube p + f = polynomial t + + +zoom_chunk :: Grid -> ScaleFactor -> Values3D +zoom_chunk g scale_factor + | xsize == 0 || ysize == 0 || zsize == 0 = empty3d + | otherwise = + R.force $ R.unsafeTraverse arr transExtent (zoom_chunk_lookup g scale_factor) + where + arr = function_values g + (xsize, ysize, zsize) = dims arr + transExtent = zoom_shape scale_factor + + + -- | Check all coefficients of tetrahedron0 belonging to the cube -- centered on (1,1,1) with a grid constructed from the trilinear -- values. See example one in the paper.