Initial snark14m import
[snark14.git] / src / snark / blob_setparam.cpp
1 /*
2 ***********************************************************
3 $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/blob_setparam.cpp $
5 $LastChangedRevision: 85 $
6 $Date: 2014-07-02 16:07:08 -0400 (Wed, 02 Jul 2014) $
7 $Author: agulati $
8 ***********************************************************
9
10  Given the grid resolution (Blob.delta), this subroutine computes the number of (hexagonal) grids points, so that the picture region of area = GeoPar.nelem * GeoPar.pixsiz is covered by the voronoi neighbourhoods of the grid points. 
11
12  The number of horizontal and vertical grid points of the underlying square grid are respectively Blob.M and Blob.H
13
14  Both Blob.M and Blob.H are assumed to be odd number, so 
15  Blob.M = 2*m1+1 and Blob.H = 2*h1 + 1
16
17  The total number of grid points of the underlying square grid is denoted by Blob.area that is equal to Blob.M * Blob.H 
18
19 */
20  
21 #include <cstdio>
22 #include <cmath>
23
24 #include "blkdta.h"
25 #include "blob.h"
26 #include "geom.h"
27 #include "consts.h"
28 #include "uiod.h"
29
30
31 void Blob_class::setparam()
32 {  
33
34   INTEGER m1, h1, mid0, mid1, pr0, pr1;
35  
36
37   m1 = (INTEGER)floor(GeoPar.nelem * GeoPar.pixsiz/(Blob.delta));
38   h1 = (INTEGER)floor(GeoPar.nelem * GeoPar.pixsiz/(Consts.sqrt3 * Blob.delta));
39
40   pr0  = m1 % 2;
41   pr1 = (m1 + 1) % 2;
42
43   mid0  = m1 + 1 - pr0;
44   mid1 = m1 + 1 - pr1;
45   
46   Blob.M = (INTEGER)(2 * m1 + 1);
47   Blob.H = (INTEGER)(2 * h1 + 1);
48   Blob.diag = (Blob.M + Blob.H) / 2;
49   Blob.area = Blob.M * Blob.H; 
50   Blob.ljf = 0;
51   Blob.ljl = GeoPar.nelem - 1;
52   Blob.lkf = 0;
53   Blob.lkl = GeoPar.nelem - 1;
54   Blob.lhf = (INTEGER)(-1 * (INTEGER)(Blob.H / 2));
55   Blob.lhl = (INTEGER)((Blob.H - 1) / 2);
56   Blob.lmf = -1 * (INTEGER)(Blob.M / 2);
57   Blob.lml = (INTEGER)((Blob.M - 1) / 2);
58   Blob.H2 = (INTEGER)(Blob.H / 2);
59   Blob.M2 = (INTEGER)(Blob.M / 2);
60   Blob.pr = (M2+H2)%2;  
61   Blob.sampiblob = samp / Blob.support;
62   Blob.di2 = (REAL) 0.5 * Blob.delta; 
63   Blob.di2sq3 = Consts.sqrt3 * di2;
64   
65   fprintf(output, "\n          hexagonal grid: there are %5i rows, the middle row has %5i grid points and the row next to the middle one has %5i grid points", Blob.H, mid0, mid1);
66 }
67