/*************************************************************************** * Copyright (C) 2009 by Douglas Castro * * douglas@ime.unicamp.br * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #define PROG_NAME "makefigs" #define PROG_DESC "generate figures for the Vanderbilt 2003 dyadic grid paper" #define PROG_VERS "1.0" /* Copyright © 2004 by the State University of Campinas (UNICAMP). */ /* See the copyright, authorship, and warranty notice at end of file. */ /* Last edited on 2007-10-11 00:32:20 by stolfi */ /* Created may/2004 by Jorge Stolfi, UNICAMP */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "mdg_grid.h" #include "dg_tree.h" #include "udg_pulse.h" #include "dg_tent.h" #include "dg_plot.h" #include "bz_basic.h" #include "bz_patch.h" #include "pswr.h" #include "somegrids.h" //#include "slowplot.h" #include "figtools.h" //#include "plot1d.h" //#include "figs1d.h" #include "plot2d.h" #include "figs2d.h" //#include "figs3d.h" #include "figstree.h" /* INTERNAL PROTOTYPES */ int main(int argc, char **argv); //void figs_1d(PlotOptions *o); /* Outputs all 1D figures. */ void figs_2d(PlotOptions *o); /* Outputs all 2D figures. */ //void figs_3d(PlotOptions *o); /* Outputs all 3D figures. */ void parse_options(int argc, char **argv, PlotOptions **op); void get_arg_double(double *varp, int *argnp, int argc, char **argv, char *usage); void get_arg_string(char **varp, int *argnp, int argc, char **argv, char *usage); void arg_error(char *msg, char *arg, char *pname, char *usage); /* IMPLEMENTATIONS */ int main(int argc, char **argv) { PlotOptions *o; parse_options(argc, argv, &o); start_document(o); // figs_1d(o); figs_2d(o); // figs_3d(o); fprintf(stderr, "OK so far...\n"); finish_document(o); return(0); } // void figs_1d(PlotOptions *o) // { // /* Plots of mother pulses: */ // figs_1d_mother_pulse_catalog(o, udg_PK_B, -1, 2, 0); // figs_1d_mother_pulse_catalog(o, udg_PK_H, 0, 2, 0); // figs_1d_mother_pulse_catalog(o, udg_PK_N, -1, 2, 2); // // /* Plots of tent bases for adaptive grids: */ // figs_1d_some_grid_both_bases(o, 3, 3, udg_PK_H, 0, 1); // figs_1d_some_grid_both_bases(o, 2, 4, udg_PK_H, 0, 1); // } void figs_2d(PlotOptions *o) { interval_t rootCell[2]; mdg_cell_box_canonical(2, mdg_ROOT_CELL, rootCell); mdg_rank_t tree_rank; dg_tree_node_t *G; int i; for(i=0;i<2;i++) { fprintf(stderr,"v[%d].end[0] = %7.6f v[%d].end[1] = %7.6f\n",i,rootCell[i].end[0],i,rootCell[i].end[1]); } /* Green-magenta scale: */ /* figs2d_set_negative_color (0.000, 0.833, 0.000); */ /* figs2d_set_zero_color (1.000, 1.000, 1.000); */ /* figs2d_set_positive_color (1.000, 0.167, 1.000); */ /* Cyan-brown scale: */ /* figs2d_set_negative_color (0.333, 0.667, 1.000); */ /* figs2d_set_zero_color (1.000, 1.000, 1.000); */ /* figs2d_set_positive_color (0.667, 0.333, 0.000); */ /* Blue-red scale: */ figs2d_set_negative_color (0.000, 0.667, 1.000); figs2d_set_zero_color (1.000, 1.000, 1.000); figs2d_set_positive_color (1.000, 0.333, 0.000); /* ADAPTIVE GRID FIGURES */ tree_rank = 10; G = somegrid_adaptive(2, tree_rank, NULL); fig_tree(o, "d2-tree", G); figs_2d_tree(o, "d2-t", G, rootCell, tree_rank); fig_2d_sample_spline(o, "d2-gh-inf-1-0-smp", G, rootCell, udg_PK_H, 0, 1, FALSE); /* 1 - A folha onde esta sendo feita a impressao da malha nao esta na escala [0,1]x[0,0.70...] */ /* UNIFORM GRID FIGURES */ // mdg_rank_t max_full_rank = 7; // figs_2d_full(o, "d2-f", rootCell, max_full_rank); /* BASIS FIGURES */ /* dg_rank_t tree_rank = 4; */ /* dg_tree_node_t *G = somegrid_adaptive(2, 1, tree_rank, NULL); */ tree_rank = 7; /* G = somegrid_varied(2, 3, tree_rank, NULL); */ // G = somegrid_adaptive(2, tree_rank, NULL); // figs_2d_basis(o, "d2-gh-inf-1-0", G, rootCell, udg_PK_H, 0, 1, FALSE); // figs_2d_basis(o, "d2-gh-sup-1-0", G, rootCell, udg_PK_H, 0, 1, TRUE); /* figs_2d_basis(o, "d2-gh-inf-3-1", G, rootCell, dg_PK_H, 1, 3, FALSE); */ /* MOTHER TENT FIGURES */ /* fig_2d_bezier_constraints(o, "d2-bc", 2, 7); */ /* fig_2d_bezier_array(o, "d2-bz", 4); */ // figs_2d_mother_pulse_catalog(o, udg_PK_B, -1, 2, 0); // figs_2d_mother_pulse_catalog(o, udg_PK_H, 0, 2, 0); // figs_2d_mother_pulse_catalog(o, udg_PK_N, -1, 2, 2); } // void figs_3d(PlotOptions *o) // { // interval_t rootCell[3]; // dg_cell_box_canonical(3, dg_ROOT_CELL, rootCell); // // dg_rank_t max_full_rank = 7; // figs_3d_full(o, "d3-f", rootCell, max_full_rank); // } #define ARG_ERROR(Msg,Arg) arg_error((Msg),(Arg),argv[0],usage) #define GET_STRING(Var) get_arg_string(&(Var), &argn, argc, argv, usage) #define GET_DOUBLE(Var) get_arg_double(&(Var), &argn, argc, argv, usage) void parse_options(int argc, char **argv, PlotOptions **op) { PlotOptions *o = (PlotOptions *)malloc(sizeof(PlotOptions)); char* usage = "\n [ -help ] [ -outName PREFIX ] [ -eps | -ps ]"; int argn; /* Defaults: */ o->outName = "dg"; o->eps = FALSE; o->paperSize = "letter"; o->color = TRUE; o->scale = 25.4; o->margin[0] = 1.0; o->margin[1] = 1.0; o->meshSize = 1.0; /* Default depends on {color} option: */ Color defColorFill = (Color){{1.00, 0.95, 0.85}}; Color defGrayFill = (Color){{0.90, 0.90, 0.90}}; o->fill = (Color){{-1.0, -1.0, -1.0}}; argn = 1; /* Scan command line options. */ while ((argn < argc) && (argv[argn][0] == '-') && (argv[argn][1] != '\0')) { char *key = argv[argn]; if ((key[0] == '-') && (key[1] == '-') && (key[2] != '\0')) { key++; } if (strcmp(key, "-help") == 0) { fprintf(stderr, "usage: %s %s\n", argv[0], usage); exit(0); } else if (strcmp(key, "-outName") == 0) { GET_STRING(o->outName); } else if (strcmp(key, "-eps") == 0) { o->eps = TRUE; } else if (strcmp(key, "-ps") == 0) { o->eps = FALSE; } else if (strcmp(key, "-paperSize") == 0) { GET_STRING(o->paperSize); } else if (strcmp(key, "-color") == 0) { o->color = TRUE; } else if ((strcmp(key, "-gray") == 0) || (strcmp(key, "-grey") == 0)) { o->color = FALSE; } else if (strcmp(key, "-fill") == 0) { GET_DOUBLE(o->fill.c[0]); GET_DOUBLE(o->fill.c[1]); GET_DOUBLE(o->fill.c[2]); } else if (strcmp(key, "-scale") == 0) { GET_DOUBLE(o->scale); } else if (strcmp(key, "-margin") == 0) { GET_DOUBLE(o->margin[0]); GET_DOUBLE(o->margin[1]); } else if (strcmp(key, "-meshSize") == 0) { GET_DOUBLE(o->meshSize); } else { ARG_ERROR("unknown option", argv[argn]); } ++argn; } if (argn != argc) { ARG_ERROR("extraneous arguments", argv[argn]); } if (o->fill.c[0] == -1) { o->fill = (o->color ? defColorFill : defGrayFill); } (*op) = o; } void get_arg_string(char **varp, int *argnp, int argc, char **argv, char *usage) /* Stores the next command line argument (as a string) into "*varp" */ { int argn = *argnp; if (argn+1 >= argc) { ARG_ERROR("missing arg value", argv[argn]); } (*varp) = argv[argn+1]; (*argnp) = argn+1; } void get_arg_double(double *varp, int *argnp, int argc, char **argv, char *usage) /* Stores the next command line argument (as a double) into "*varp" */ { int argn = *argnp; char *end; if (argn+1 >= argc) { ARG_ERROR("missing arg value", argv[argn]); } (*varp) = strtod(argv[argn+1], &end); if ((*end) != '\0') { ARG_ERROR("invalid numeric argument", argv[argn+1]); } (*argnp) = argn+1; } void arg_error(char *msg, char *arg, char *pname, char *usage) /* Prints "msg", "arg", the "usage" message, and exits. Handy while parsing the command line arguments. */ { fprintf(stderr, "%s %s\n", msg, arg); fprintf(stderr, "usage: %s %s\n", pname, usage); exit(1); }