This is a patch for "ifsplot" 0.5.1. This patch makes three changes: (a) It adds support for Fractint IFS format, which appears to be a superset of "ifsplot" IFS format. (b) The "ifsplot -h" usage message tells the user where to find sample IFS files. (c) If standard input isn't redirected [for example, if the user simply executes "ifsplot" without any parameters], the modi- fied program prints the "ifsplot -h" usage message and ex- its. --- ifsplot-0.5.1.old/Makefile.in +++ ifsplot-0.5.1/Makefile.in @@ -91,7 +91,7 @@ ifsplot_LDADD = $(LDADD) ifsplot_DEPENDENCIES = ifsplot_LDFLAGS = -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ -D__PKGDATADIR__=\"$(pkgdatadir)\" COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ --- ifsplot-0.5.1.old/cmdline.c +++ ifsplot-0.5.1/cmdline.c @@ -33,11 +33,10 @@ { cmdline_parser_print_version (); printf("\n" - "Purpose:\n" - " This program plots the attractor (fractal) of an IFS.\n" + " ifsplot plots the attractor (fractal) of an IFS.\n" " \n" " You can provide as many affine transformations you like. Each affine\n" - " transformation is represented as one line with seven quantities, read\n" + " transformation is represented as one line with seven quantities, taken\n" " from the standart input. These quantities, namely a b c d e f p,\n" " represent an affine transformation of the form\n" " \n" @@ -48,40 +47,37 @@ " control the density of points on w(A), where w is the affine\n" " transformation and A is the attractor.\n" " \n" - " Remember that the propabilities must sum up one.\n" + " Remember that the propabilities must add up to one.\n" " \n" - " For further informations on IFS fractals, we report interested people\n" - " to the classical IFS book:\n" - " Fractals Everywhere\n" - " Michael Barnsley\n" - " Addison-Wesley, 2nd ed., 2000.\n" + " For more information on IFS fractals, read the book:\n" + " Fractals Everywhere by Michael Barnsley, Addison-Wesley, 2nd ed., 2000.\n" " \n" " Several output drivers are supported: X, Xdrawable, pnm,\n" " gif, ai, png, ps, fig, pcl, hpgl, tek, or meta.\n" " \n" - " This program is distributed under the terms of the\n" - " GNU Public License.\n" + " This program is distributed under the terms of the GNU Public License.\n" " \n" " Copyright (c) 2005, 2004, 2003 Ricardo Biloti \n" - " Department of Applied Mathematics\n" - " State University of Campinas, Brazil.\n" + " Department of Applied Mathematics, State University of Campinas, Brazil.\n" " \n" - "\n" - "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); + "Usage: %s [OPTIONS] ... < /path/foo.ifs\n", CMDLINE_PARSER_PACKAGE); printf(" -h --help Print help and exit\n"); printf(" -V --version Print version and exit\n"); printf(" -c --color Color each transformation (default=off)\n"); printf(" -DSTRING --driver=STRING Output driver (see above) (default='X')\n"); - printf(" -NLONG --maxint=LONG Iteration number (default='100000')\n"); - printf(" -nLONG --minint=LONG Initial iterations to discard (default='200')\n"); - printf(" --nmax=INT Maximun number of transformations (default='50')\n"); - printf(" --xi=DOUBLE x min coordinate\n"); - printf(" --xf=DOUBLE x max coordinate\n"); - printf(" --yi=DOUBLE y min coordinate\n"); - printf(" --yf=DOUBLE y max coordinate\n"); + printf(" -NLONG --maxint=LONG Iteration number (default=100000)\n"); + printf(" -nLONG --minint=LONG Initial iterations to discard (default=200)\n"); + printf(" --nmax=INT Maximum number of transformations (default=50)\n"); + printf("--xi=DOUBLE x min coordinate --xf=DOUBLE x max coordinate\n"); + printf("--yi=DOUBLE y min coordinate --yf=DOUBLE y max coordinate\n"); + +#ifdef __PKGDATADIR__ + printf ("\nYou'll find sample IFS files %s:\n%s/examples\n\n", + "in the following directory", + __PKGDATADIR__); +#endif } - static char *gengetopt_strdup (const char *s); /* gengetopt_strdup() */ --- ifsplot-0.5.1.old/ifsplot.c 2005-08-06 05:53:17.000000000 -0700 +++ ifsplot-0.5.1/ifsplot.c 2006-04-24 15:53:50.000000000 -0700 @@ -94,6 +94,7 @@ int N, nmax, ic; long int i, n, npre; div_t d; + char xbuf [256]; int nc = 13; int color[][3]={{ 0,65535, 0}, /* green */ @@ -122,6 +123,16 @@ if (!arg.color_flag) nc=1; +//-------------------------------------------------------------------- + + if (isatty (fileno (stdin))) + { + cmdline_parser_print_help(); + exit (1); + } + +//-------------------------------------------------------------------- + /* Allocate space for the IFS transformations */ ifs = (float **) malloc(sizeof(float *) * nmax); for (i=0; i= 'a') && (*xp <= 'z')) continue; + if ((*xp >= 'A') && (*xp <= 'Z')) continue; + if (*xp == '}') break; + + switch (*xp) + { + case '\000': case '{': case '\n': continue; + } + + if (sscanf (xp, "%f %f %f %f %f %f %f", &ifs[N][0], &ifs[N][1], &ifs[N][2], &ifs[N][3], - &ifs[N][4], &ifs[N][5], &ifs[N][6]) == 7) && - (N < nmax)){ - if (N > 0) - ifs[N][6] += ifs[N-1][6]; + &ifs[N][4], &ifs[N][5], &ifs[N][6]) != 7) + { + if (sscanf (xp, "%f %f %f %f %f %f", + &ifs[N][0], &ifs[N][1], &ifs[N][2], + &ifs[N][3], &ifs[N][4], &ifs[N][5]) == 6) + { // For Fractint format, last number is + // apparently optional - We'll default + // it arbitrarily to 0.5 + ifs [N][6] = 0.5; + } + else + { +fprintf (stderr, + "Error: ifsplot requires either 6 or 7 values per data line\n"); +exit (1); + } + } + if (N < nmax) + { + if (N > 0) ifs[N][6] += ifs[N-1][6]; N++; } + } + ifs[N-1][6] = 1; /* Pre iterations */