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

« back to all changes in this revision

Viewing changes to raster3d/r3.mkdspf/main.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:
40
40
 *     to use new GRASS 3dgrid data files & API
41
41
 */
42
42
 
43
 
#define MAIN
44
43
#include <stdlib.h>
45
44
#include <math.h>
46
45
#include "vizual.h"
47
46
#include <grass/gis.h>
48
 
#include <grass/G3d.h>
 
47
#include <grass/raster3d.h>
49
48
#include "local_proto.h"
50
49
#include <grass/glocale.h>
51
50
 
 
51
file_info Headfax;      /* contains info about command line */
 
52
Cube_data CUBE;         /* and the data for a single cube */
 
53
int NTHRESH;
 
54
 
52
55
int main(int argc, char *argv[])
53
56
{
54
 
    char *dspout, element[160];
 
57
    char element[GNAME_MAX+10];
 
58
    const char *dspout;
55
59
    void *g3map;
56
 
    G3D_Region g3reg;
57
 
    char *mapset;
 
60
    RASTER3D_Region g3reg;
 
61
    const char *mapset;
58
62
    double dmin, dmax;
59
63
    struct GModule *module;
60
64
 
72
76
    G_gisinit(argv[0]);
73
77
 
74
78
    module = G_define_module();
75
 
    module->keywords = _("raster3d, voxel");
 
79
    G_add_keyword(_("raster3d"));
 
80
    G_add_keyword(_("display"));
 
81
    G_add_keyword(_("voxel"));
76
82
    module->description =
77
 
        _("Creates a display file from an existing grid3 file according to specified threshold levels.");
 
83
        _("Creates a display file from an existing 3D raster map according to specified threshold levels.");
78
84
 
79
85
    name = G_define_option();
80
86
    name->key = "input";
81
87
    name->type = TYPE_STRING;
82
88
    name->required = YES;
83
 
    name->gisprompt = "old,grid3,3dcell";
 
89
    name->gisprompt = "old,grid3,3d-raster";
84
90
    /* should still find the DIRECTORY */
85
 
    name->description = _("Name of an existing 3d raster map");
 
91
    name->description = _("Name of an existing 3D raster map");
86
92
 
87
 
    out = G_define_option();
 
93
    out = G_define_standard_option(G_OPT_F_OUTPUT);
88
94
    out->key = "dspf";
89
 
    out->type = TYPE_STRING;
90
95
    out->required = YES;
91
 
    out->description = _("Name of output display file");
 
96
    out->description = _("Name for output display file");
92
97
 
93
98
    levels = G_define_option();
94
99
    levels->key = "levels";
133
138
    if (G_parser(argc, argv))
134
139
        exit(EXIT_FAILURE);
135
140
 
136
 
    G3d_initDefaults();
 
141
    Rast3d_init_defaults();
137
142
 
138
 
    G3d_getWindow(&g3reg);
 
143
    Rast3d_get_window(&g3reg);
139
144
    G_message(_("Region from getWindow: %d %d %d"),
140
145
              g3reg.rows, g3reg.cols, g3reg.depths);
141
146
 
144
149
         check_get_any_dspname(out->answer, name->answer, G_mapset())))
145
150
        exit(EXIT_FAILURE);
146
151
 
147
 
    G3d_setErrorFun(G3d_printError);
 
152
    Rast3d_set_error_fun(Rast3d_print_error);
148
153
 
149
154
    /* open g3 file for reading and writing */
150
155
    if (NULL == (mapset = G_find_file2("grid3", name->answer, "")))
151
156
        G_fatal_error(_("Not able to find grid3 file for [%s]"),
152
157
                      name->answer);
153
158
 
154
 
    g3map = G3d_openCellOld(name->answer, mapset, &g3reg,
155
 
                            G3D_TILE_SAME_AS_FILE, G3D_USE_CACHE_DEFAULT);
 
159
    g3map = Rast3d_open_cell_old(name->answer, mapset, &g3reg,
 
160
                            RASTER3D_TILE_SAME_AS_FILE, RASTER3D_USE_CACHE_DEFAULT);
156
161
    /*
157
 
       g3map = G3d_openCellOld (name->answer, mapset, G3D_DEFAULT_WINDOW,
158
 
       G3D_TILE_SAME_AS_FILE,
159
 
       G3D_USE_CACHE_DEFAULT);
 
162
       g3map = Rast3d_open_cell_old (name->answer, mapset, RASTER3D_DEFAULT_WINDOW,
 
163
       RASTER3D_TILE_SAME_AS_FILE,
 
164
       RASTER3D_USE_CACHE_DEFAULT);
160
165
     */
161
166
 
162
167
    if (NULL == g3map)
163
 
        G_fatal_error(_("Error opening grid3 file [%s]"), name->answer);
 
168
        G_fatal_error(_("Unable to open 3D raster map <%s>"), name->answer);
164
169
 
165
 
    if (0 == G3d_range_load(g3map))
166
 
        G_fatal_error(_("Error reading range for [%s]"), name->answer);
 
170
    if (0 == Rast3d_range_load(g3map))
 
171
        G_fatal_error(_("Unable to read range of 3D raster map <%s>"), name->answer);
167
172
 
168
173
    /* TODO: look at this - should use current 3dregion rather than
169
174
       region represented by original 3dgrid file */
170
175
    /*
171
 
       G3d_getRegionStructMap (g3map, &g3reg);
 
176
       Rast3d_get_region_struct_map (g3map, &g3reg);
172
177
     */
173
178
 
174
179
    /* DONT USE Headfax any more ?
175
180
       g3read_header(&Headfax);
176
181
     */
177
 
    G3d_range_min_max(g3map, &dmin, &dmax);
 
182
    Rast3d_range_min_max(g3map, &dmin, &dmax);
178
183
    viz_make_header(&Headfax, dmin, dmax, &g3reg);
179
184
 
180
185
    /* puts command line options into cmndln_info structure */
192
197
    /* open display file for writing */
193
198
    sprintf(element, "grid3/%s/dsp", name->answer);
194
199
    if ((Headfax.dspfoutfp = G_fopen_new(element, dspout)) == NULL)
195
 
        G_fatal_error(_("Error opening display file [%s]"), dspout);
 
200
        G_fatal_error(_("Unable to open display file <%s>"), dspout);
196
201
 
197
202
    /* write display file header info */
198
203
    /* have to adjust dimensions  -dpg */
221
226
        fprintf(stderr, "\n");
222
227
 
223
228
    /* tries to write a header! */
224
 
    G3d_closeCell(g3map);
 
229
    Rast3d_close(g3map);
225
230
 
226
231
    fclose(Headfax.dspfoutfp);
227
232