~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to imagery/i.smap/bouman/reg_util.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "bouman.h"
2
 
#include "region.h"
3
 
 
4
 
int levels_reg(struct Region *region)
5
 
{
6
 
    int D;
7
 
    int wd, ht;
8
 
    struct Region region_buff;
9
 
 
10
 
    /* save region stucture */
11
 
    copy_reg(region, &region_buff);
12
 
 
13
 
    D = 0;
14
 
    reg_to_wdht(region, &wd, &ht);
15
 
    while ((wd > 2) && (ht > 2)) {
16
 
        D++;
17
 
        dec_reg(region);
18
 
        reg_to_wdht(region, &wd, &ht);
19
 
    }
20
 
 
21
 
    /* restore region structure */
22
 
    copy_reg(&region_buff, region);
23
 
 
24
 
    return (D);
25
 
}
26
 
 
27
 
void dec_reg(struct Region *region)
28
 
{
29
 
    region->xmin = region->xmin / 2;
30
 
    region->xmax = region->xmax / 2;
31
 
    region->ymin = region->ymin / 2;
32
 
    region->ymax = region->ymax / 2;
33
 
}
34
 
 
35
 
void copy_reg(struct Region *region1, struct Region *region2)
36
 
{
37
 
    region2->xmin = region1->xmin;
38
 
    region2->xmax = region1->xmax;
39
 
    region2->ymin = region1->ymin;
40
 
    region2->ymax = region1->ymax;
41
 
 
42
 
    region2->free.left = region1->free.left;
43
 
    region2->free.right = region1->free.right;
44
 
    region2->free.top = region1->free.top;
45
 
    region2->free.bottom = region1->free.bottom;
46
 
}
47
 
 
48
 
void reg_to_wdht(struct Region *region, int *wd, int *ht)
49
 
{
50
 
    *wd = region->xmax - region->xmin;
51
 
    *ht = region->ymax - region->ymin;
52
 
}