/* * ACE/vis - Visualization of Flow and Transport * * Paul J. Turner and Antonio M. Baptista * * Copyright 1990-2004 Oregon Health and Science University * All Rights Reserved * */ /* * utilities for stations */ #include "symdefs.h" #include "defines.h" #include "globals.h" /* Station *sta; * int nsta; */ /* * typedef struct _Station { int active; int type; char label[256]; double x; double y; int display; Props p; Isolparms ip; } Station; */ int ReadStations(char *fname, int *n, Station **s); Station *NewStations(int n) { Station *s; s = (Station *) malloc(n * sizeof(Station)); return s; } void DeleteStations(int *n, Station *s) { *n = 0; free(s); } int ReadStations(char *fname, int *n, Station **s) { char buf[256], label[256]; int i, nn, type; Station *stmp; FILE *fp = fopen(fname, "r"); if (fp == NULL) { errwin("Unable to open file"); return 1; } fgets(buf, 255, fp); sscanf(buf, "%d", &nn); stmp = (Station *) malloc(nn * sizeof(Station)); for (i = 0; i < nn; i++) { fgets(buf, 255, fp); strcpy(stmp[i].label, buf); stmp[i].label[strlen(buf) - 1] = 0; fgets(buf, 255, fp); sscanf(buf, "%lf %lf", &stmp[i].x, &stmp[i].y); //printf("%d, %s: %lf %lf\n", i, stmp[i].label, stmp[i].x, stmp[i].y); stmp[i].type = 0; stmp[i].active = ON; stmp[i].p.color = 1; stmp[i].p.symbol = 2; } fclose(fp); *n = nn; *s = stmp; return 0; } int ReadBuildPoints(char *fname, int *n, Station **s) { char buf[256], label[256]; int i, nn, type; Station *stmp; FILE *fp = fopen(fname, "r"); if (fp == NULL) { errwin("Unable to open file"); return 1; } fgets(buf, 255, fp); fgets(buf, 255, fp); sscanf(buf, "%d", &nn); stmp = (Station *) malloc(nn * sizeof(Station)); for (i = 0; i < nn; i++) { sprintf(stmp[i].label, "%d", i + 1); fgets(buf, 255, fp); sscanf(buf, "%*d %lf %lf", &stmp[i].x, &stmp[i].y); //printf("%d, %s: %lf %lf\n", i, stmp[i].label, stmp[i].x, stmp[i].y); stmp[i].type = 0; stmp[i].active = ON; stmp[i].p.color = 1; stmp[i].p.symbol = 2; } fclose(fp); *n = nn; *s = stmp; return 0; } void DrawStations(int n, Station *s) { int i; for (i=0;i tmp) { cmin = tmp; *ind = i; } } } }