/* Last edited on 2009-11-09 17:43:37 by stolfilocal */ /*************************************************************************** * 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. * ***************************************************************************/ #include "plota.h" #define SLEEP_MIN 1 void plotando(int d, gnuplot_ctrl *h1) { gnuplot_resetplot(h1) ; switch(d) { case 1: gnuplot_cmd(h1, "set xlabel \"x\""); gnuplot_cmd(h1, "set ylabel \"y\""); //gnuplot_cmd(h1, "set xrange [-1:1]"); //gnuplot_cmd(h1, "set yrange [-0.1:1.1]"); gnuplot_cmd(h1, "plot \"solucao.txt\" using 1:2 with lines") ; break; case 2: gnuplot_cmd(h1, "set xrange [-1:1]"); gnuplot_cmd(h1, "set yrange [-1:1]"); gnuplot_cmd(h1, "set zrange [-0.1:1.1]"); gnuplot_cmd(h1, "set xlabel \"x\""); gnuplot_cmd(h1, "set ylabel \"y\""); gnuplot_cmd(h1, "set zlabel \"z\""); gnuplot_cmd(h1, "splot \"solucao.txt\" using 1:2:3 with points") ; break; case 3: gnuplot_cmd(h1, "set xrange [-1:1]"); gnuplot_cmd(h1, "set yrange [-1:1]"); gnuplot_cmd(h1, "set zrange [-1:1]"); gnuplot_cmd(h1, "set xlabel \"x\""); gnuplot_cmd(h1, "set ylabel \"y\""); gnuplot_cmd(h1, "set zlabel \"z\""); gnuplot_cmd(h1, "splot \"solucao.txt\" using 1:2:3 with points") ; break; default: fprintf(stderr," Dimensao nao contemplada, ainda...plota.c\n"); } fflush(h1->gnucmd); sleep(SLEEP_MIN) ; } void exportando(int d, gnuplot_ctrl *h1) { gnuplot_resetplot(h1) ; switch(d) { case 1: gnuplot_cmd(h1, "set xlabel \"t\""); gnuplot_cmd(h1, "set ylabel \"u(t)\""); gnuplot_cmd(h1, "set xrange [-1:1]"); gnuplot_cmd(h1, "set yrange [-0.1:1.1]"); gnuplot_cmd(h1, "set term postscript eps enhanced"); gnuplot_cmd(h1, "set output \"adaptive1d.eps\""); gnuplot_cmd(h1, "plot \"solucao.txt\" using 1:2 with lines") ; break; case 2: gnuplot_cmd(h1, "set xrange [-1:1]"); gnuplot_cmd(h1, "set yrange [-1:1]"); gnuplot_cmd(h1, "set zrange [-0.1:1.1]"); gnuplot_cmd(h1, "set xlabel \"x\""); gnuplot_cmd(h1, "set ylabel \"y\""); gnuplot_cmd(h1, "set zlabel \"z\""); gnuplot_cmd(h1, "set term postscript eps enhanced"); gnuplot_cmd(h1, "set output \"adaptive2d.eps\""); gnuplot_cmd(h1, "splot \"solucao.txt\" using 1:2:3 with points") ; break; case 3: gnuplot_cmd(h1, "set xrange [-1:1]"); gnuplot_cmd(h1, "set yrange [-1:1]"); gnuplot_cmd(h1, "set zrange [-1:1]"); gnuplot_cmd(h1, "set xlabel \"x\""); gnuplot_cmd(h1, "set ylabel \"y\""); gnuplot_cmd(h1, "set zlabel \"z\""); gnuplot_cmd(h1, "set term postscript eps enhanced"); gnuplot_cmd(h1, "set output \"adaptive3d.eps\""); gnuplot_cmd(h1, "splot \"solucao.txt\" using 1:2:3 with points") ; break; default: fprintf(stderr," Dimensao nao contemplada, ainda...plota.c\n"); } } void grafica(int d, int n, int N, int PS, VNo pac[], Preditor pred, double xmin[], double xmax[], gnuplot_ctrl *h1, bool_t op) { if ((n <= 10) || (n == N-1) || (n % PS == 0)) { int kc = ipow(5,d)/2; /* plot */ FILE *disco = fopen("solucao.txt", "w"); escreve_em_arquivo( d, 0, disco, pac, xmin, xmax, pred, 0, FALSE,op); fclose(disco); int nn = 0; conta_nos(pac[kc].p, &nn); fprintf(stderr, "plotando: passo = %d nos = %d\n",n,nn); plotando(d,h1); sleep(nn/1000 + 2); } }