28 #define FIRST_SURF_ID 110658 31 static int Invertmask;
68 for (gs = Surf_top; gs; gs = gs->
next) {
90 G_debug(5,
"gs_get_prev_surface");
92 for (ps = Surf_top;
ps; ps = ps->
next) {
113 for (i = 0, gs = Surf_top; gs; gs = gs->
next, i++) {
117 G_debug(5,
"gs_num_surfaces(): num=%d", i);
132 for (i = 0, gs = Surf_top; gs; gs = gs->
next, i++) ;
134 G_debug(5,
"gs_num_surfaces(): num=%d", i);
158 for (gs = Surf_top; gs; gs = gs->
next) {
180 for (ls = Surf_top; ls->
next; ls = ls->
next) ;
233 double xres,
double yres)
268 gs->
xmax = ox + (cols - 1) * xres;
271 gs->
ymax = oy + (rows - 1) * yres;
318 size = gs->
rows * gs->
cols *
sizeof(
unsigned long);
339 fprintf(stderr,
"FROM: %f, %f, %f\n", ft[
FROM][
X], ft[
FROM][
Y],
341 fprintf(stderr,
"TO: %f, %f, %f\n", ft[
TO][X], ft[
TO][Y], ft[
TO][Z]);
355 fprintf(stderr,
"REAL TO: %f, %f, %f\n", rt[
X], rt[
Y], rt[
Z]);
371 for (i = 0; i < 256; i++) {
373 fprintf(stderr,
"\n");
376 fprintf(stderr,
"%x ", buff[i]);
379 fprintf(stderr,
"\n");
393 fprintf(stderr,
"ID: %d\n", s->
gsurf_id);
394 fprintf(stderr,
"rows: %d cols: %d\n", s->
rows, s->
cols);
395 fprintf(stderr,
"draw_mode: %x\n", s->
draw_mode);
396 fprintf(stderr,
"wire_color: %lx\n", s->
wire_color);
397 fprintf(stderr,
"ox: %lf oy: %lf\n", s->
ox, s->
oy);
398 fprintf(stderr,
"xres: %lf yres: %lf\n", s->
xres, s->
yres);
399 fprintf(stderr,
"z_exag: %f \n", s->
z_exag);
400 fprintf(stderr,
"x_trans: %f y_trans: %f z_trans: %f\n",
402 fprintf(stderr,
"xmin: %f ymin: %f zmin: %f\n",
404 fprintf(stderr,
"xmax: %f ymax: %f zmax: %f\n",
406 fprintf(stderr,
"x_mod: %d y_mod: %d x_modw: %d y_modw: %d\n",
421 fprintf(stderr,
"coord_sys: %d\n", gv->
coord_sys);
422 fprintf(stderr,
"view_proj: %d\n", gv->
view_proj);
423 fprintf(stderr,
"infocus: %d\n", gv->
infocus);
425 fprintf(stderr,
"twist: %d fov: %d\n", gv->
twist, gv->
fov);
426 fprintf(stderr,
"incl: %d look: %d\n", gv->
incl, gv->
look);
427 fprintf(stderr,
"real_to: %f %f %f\n",
429 fprintf(stderr,
"vert_exag: %f scale: %f \n", gv->
vert_exag, gv->
scale);
495 if (fs == Surf_top) {
496 if (Surf_top->
next) {
517 for (gs = Surf_top; gs && !found; gs = gs->
next) {
519 if (gs->
next == fs) {
563 G_debug(5,
"gs_free_unshared_buffs");
571 if (0 < (old_datah = fs->
att[i].
hdata)) {
573 for (gs = Surf_top; gs; gs = gs->
next) {
575 if ((old_datah == gs->
att[j].
hdata) && (fs != gs)) {
602 G_debug(5,
"gs_num_datah_reused");
610 for (gs = Surf_top; gs; gs = gs->
next) {
687 G_debug(5,
"gs_get_att_typbuff(): id=%d desc=%d to_write=%d",
695 if (gsref && gsref != gs) {
719 int hdata, dims[2], ndims;
721 G_debug(5,
"gs_malloc_att_buff");
724 if (0 < (hdata = gs->
att[desc].
hdata)) {
750 G_debug(5,
"gs_malloc_lookup");
760 size = 32768 *
sizeof(int);
770 size = 256 *
sizeof(int);
806 G_debug(5,
"gs_set_att_type(): desc=%d, type=%d", desc, type);
830 G_debug(5,
"gs_set_att_src(): id=%d desc=%d src=%d",
837 G_debug(5,
"gs_set_att_src(): replacing existing map");
876 G_debug(5,
"gs_set_att_const(): id=%d, desc=%d, const=%f",
943 ret = tb->
cb[offset];
946 ret = tb->
sb[offset];
949 ret = tb->
ib[offset];
952 ret = tb->
fb[offset];
955 return (Invertmask ? ret : !ret);
974 return (coloratt->
lookup[cobuff->
cb[offset]]);
977 return (cobuff->
ib[offset]);
1002 *mid = (*max + *
min) / 2.;
1059 *min = Surf_top->
zmin;
1060 *max = Surf_top->
zmax;
1066 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1067 if (gs->
zmin < *min) {
1071 if (gs->
zmax > *max) {
1091 float tmin, tmax, tmid;
1102 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1140 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1178 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1209 zmax = *azmax = 0.0;
1212 for (i = 0, gs = Surf_top; gs; i++, gs = gs->
next) {
1213 zmax += (gs->zmax + gs->z_trans);
1234 float zmin, zmax, ymin, ymax, xmin, xmax;
1238 zmin = Surf_top->
zmin;
1239 zmax = Surf_top->
zmax;
1240 ymin = Surf_top->
ymin;
1241 ymax = Surf_top->
ymax;
1242 xmin = Surf_top->
xmin;
1243 xmax = Surf_top->
xmax;
1245 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1246 if (gs->
zmin < zmin) {
1250 if (gs->
zmax > zmax) {
1254 if (gs->
ymin < ymin) {
1258 if (gs->
ymax > ymax) {
1262 if (gs->
xmin < xmin) {
1266 if (gs->
xmax > xmax) {
1271 cen[
X] = (xmin + xmax) / 2. - xmin;
1272 cen[
Y] = (ymin + ymax) / 2. - ymin;
1273 cen[
Z] = (zmin + zmax) / 2.;
1278 cen[
X] = cen[
Y] = cen[
Z] = 0.0;
1301 for (gs = Surf_top->
next; gs; gs = gs->
next) {
1319 int vrow, vcol, drow, dcol;
1320 int retmask = 0, npts = 0;
1372 return (retmask | npts);
1380 if ((pt[X] - p2[X]) /
VXRES(gs) > (pt[Y] - p2[Y]) /
VYRES(gs)) {
1385 return (retmask | npts);
1388 return (retmask | npts);
1390 if ((pt[X] - p2[X]) /
VXRES(gs) <= (pt[Y] - p2[Y]) /
VYRES(gs)) {
1395 return (retmask | npts);
1398 return (retmask | npts);
1435 for (i = 0; i < (np - 1); i++) {
1436 tmp[i + 1][
Z] *= exag;
1441 for (i = 0; i < (np - 1); i++) {
int gs_init_surf(geosurf *gs, double ox, double oy, int rows, int cols, double xres, double yres)
Initialize allocated geosurf struct.
int gs_num_datah_reused(int dh)
Get number of reused values.
void gs_delete_surf(int id)
Remove geosurf struct from list.
typbuff * gsds_get_typbuff(int, IFLAG)
Get data buffer.
int gs_get_datacenter(float *cen)
Get data center point.
void gs_set_maskmode(int invert)
Set geosurf mask mode.
int gs_get_data_avg_zmax(float *azmax)
Get average z-max value.
int Gs_update_attrange(geosurf *, int)
Update no_zero ranges for attribute (actually no_null now)
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
int gs_mask_defined(geosurf *gs)
Check if mask is defined.
void G_free(void *)
Free allocated memory.
size_t gs_malloc_att_buff(geosurf *gs, int desc, int type)
Allocate attribute buffer.
int gs_get_yextents(geosurf *gs, float *min, float *max)
Get y-extent values.
geosurf * gs_get_prev_surface(int id)
Get previous geosurf struct.
int gs_get_yrange(float *min, float *max)
Get y-range.
int gs_att_is_set(geosurf *surf, IFLAG att)
Check if attribute is set.
void print_frto(float(*ft)[4])
Debugging, print 'from/to' model coordinates to stderr.
void gs_set_defaults(geosurf *gs, float *defs, float *null_defs)
Set default attribute values.
void gs_init(void)
Initialize library.
int gs_set_att_type(geosurf *gs, int desc, int type)
Set attribute type.
void print_view_fields(geoview *gv)
Debugging, print geoview fields to stderr.
float GS_distance(float *, float *)
Calculate distance.
void print_surf_fields(geosurf *s)
Debugging, print geosurf fields to stderr.
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
float gsdiff_do_SD(float, int)
ADD.
int in_vregion(geosurf *, float *)
ADD.
void gs_err(const char *msg)
int gs_num_surfaces(void)
Get number of surfaces.
int gs_masked(typbuff *tb, int col, int row, int offset)
Should only be called when setting up the current mask (gs_bm.c)
void print_realto(float *rt)
Debugging, print 'to' real coordinates to stderr.
int gs_set_att_const(geosurf *gs, int desc, float constant)
Set attribute constant value.
int gs_getall_surfaces(geosurf **gsurfs)
Get array of geosurf structs.
int BM_get(struct BM *, int, int)
Gets 'val' from the bitmap.
int gs_free_surf(geosurf *fs)
Free geosurf struct.
int gs_get_xrange(float *min, float *max)
Get x-range.
int gs_get_zextents(geosurf *gs, float *min, float *max, float *mid)
Get z-extent values.
float GS_global_exag(void)
Get global z-exag value.
int gs_set_att_src(geosurf *gs, int desc, int src)
Set attribute source.
int gs_malloc_lookup(geosurf *gs, int desc)
Allocate attribute lookup.
int gs_get_xextents(geosurf *gs, float *min, float *max)
Get x-extent values.
void print_256lookup(int *buff)
Debugging, 256 integer values from buffer.
int gs_get_att_type(geosurf *gs, int desc)
Get attribute type.
geosurf * gs_get_surf(int id)
Get geosurf struct.
int gs_get_zrange0(float *min, float *max)
Get z-range.
int gs_setall_norm_needupdate(void)
Set for geosurf need-to-update mark.
float(* tfunc)(float, int)
geosurf * gs_get_last_surface(void)
Get last allocated geosurf struct from list.
void G_warning(const char *,...) __attribute__((format(printf
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
geosurf * gsdiff_get_SDref(void)
ADD.
#define VCOL2DCOL(gs, vcol)
size_t gsds_alloc_typbuff(int, int *, int, int)
Allocates correct buffer according to type, keeps track of total mem.
Point3 * gsdrape_get_segments(geosurf *, float *, float *, int *)
ADD.
int gs_init_normbuff(geosurf *gs)
Init geosurf normbuff.
geosurf * gs_get_new_surface(void)
Allocate new geosurf struct.
void gs_free_unshared_buffs(geosurf *fs)
Free unshared buffers of geosurf struct.
int gs_mapcolor(typbuff *cobuff, gsurf_att *coloratt, int offset)
Call this one when you already know att_src is MAP_ATT.
#define VROW2DROW(gs, vrow)
int gs_get_zrange(float *min, float *max)
Get z-range.
int gs_distance_onsurf(geosurf *gs, float *p1, float *p2, float *dist, int use_exag)
Calculate distance on surface.
int G_debug(int, const char *,...) __attribute__((format(printf
int gsds_free_datah(int)
Free allocated dataset.