From: Kevin M. Rosenberg Date: Fri, 28 Apr 2000 13:02:42 +0000 (+0000) Subject: r3: Initial revision X-Git-Tag: debian-4.5.3-3~1013 X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=commitdiff_plain;h=13838bda88b63a2535b5baaf7197006767de4b8e r3: Initial revision --- 13838bda88b63a2535b5baaf7197006767de4b8e diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e3a6c0e --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Kevin M. Rosenberg, M.D. +kevin@rosenberg.net \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..89fd6da --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,23 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: COPYRIGHT,v 1.1 2000/04/28 13:02:43 kevin Exp $ +** $Log: COPYRIGHT,v $ +** Revision 1.1 2000/04/28 13:02:43 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..8dbe5e5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,12 @@ +0.5.1 - 4/28/2000 + Cleaned out library that wasn't being used by CTSim + +0.5.0 - 4/27/2000 + First open source distribution for GNU/Linux + +6/1999 + Converted to GNU/Linux + added MPI support via LAM library + +1983-84 + Developed under MS-DOS and IBM EGA graphics \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..ff8c4a6 --- /dev/null +++ b/INSTALL @@ -0,0 +1,227 @@ +CTSim Installation +================== + +Additional Libraries Recommended +-------------------------------- + +zlib (ftp://ftp.uu.net/pub/archiving/zip/zlib) + Tested with version 1.13 + This library is required for libpng (see below) + +libpng (ftp://ftp.uu.net/graphics/png/src) + Version 1.0.3 or greater is required. Version 0.89 definitely will + not work. + +lam (http://www.mpi.nd.edu/lam/) + There is support is MPI clustering. I use this code at home for my + beowulf cluster. + +perl/apache + There is support for web-driven CT Simulation. To use this, the + --with-cgibin-dir=..., --with-cgibin-url=..., --with-webdata-dir=..., + --with-webdata-url=..., and --with-html-dir=... must be set. + +CTSim Specific Configuration Help +--------------------------------- + + --enable-verbose-warnings + Enable verbose compiler warnings. + --enable-debug Turn on debugging + --with-png[=PATH] Set path of lib PNG installation + --with-lam[=PATH] Set path of LAM MPI + --with-cgibin-dir=PATH Set path of CGI binaries directory + --with-cgibin-url=PATH Set URL path of CGI binaries + --with-webdata-dir=PATH Set path of webdata + --with-webdata-url=PATH Set URL path of webdata + --with-html-dir=PATH Set directory of html files + --with-x use the X Window System + +Platforms Supported +------------------- + +Recent development is with GNU/Linux. I have tested compilation on +FreeBSD v4.0, BSD/OS v3.0, and Solaris v8. + + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dc4cd87 --- /dev/null +++ b/Makefile @@ -0,0 +1,378 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = . +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = . + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true +EXTRA_DIRS = getopt +EXTRA_DIRS = + +SUBDIRS = $(EXTRA_DIRS) libcio libk libkmath libgraph libezplot libir src man html cgi-bin include +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 config.h.in \ +configure configure.in install-sh missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DIST_SUBDIRS = getopt libcio libk libkmath libgraph libezplot libir src \ +man html cgi-bin include +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.in + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + + + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(DIST_SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: +uninstall: uninstall-recursive +all-am: Makefile config.h +all-redirect: all-recursive-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: installdirs-recursive +installdirs-am: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +install-data-recursive uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..8619c5b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,12 @@ +if INCLUDED_GETOPT_LONG +EXTRA_DIRS=getopt +else +EXTRA_DIRS= +endif + +SUBDIRS=$(EXTRA_DIRS) libcio libk libkmath libgraph libezplot libir src man html cgi-bin include + + + + + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..75a9633 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,378 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ +@INCLUDED_GETOPT_LONG_TRUE@EXTRA_DIRS = getopt +@INCLUDED_GETOPT_LONG_FALSE@EXTRA_DIRS = + +SUBDIRS = $(EXTRA_DIRS) libcio libk libkmath libgraph libezplot libir src man html cgi-bin include +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 config.h.in \ +configure configure.in install-sh missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DIST_SUBDIRS = getopt libcio libk libkmath libgraph libezplot libir src \ +man html cgi-bin include +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.in + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(DIST_SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: +uninstall: uninstall-recursive +all-am: Makefile config.h +all-redirect: all-recursive-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: installdirs-recursive +installdirs-am: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +install-data-recursive uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..6ecfdb9 --- /dev/null +++ b/NEWS @@ -0,0 +1,4 @@ +0.5.0 +April 27, 2000 + +This is the first open source release diff --git a/README b/README new file mode 100644 index 0000000..30cca64 --- /dev/null +++ b/README @@ -0,0 +1,102 @@ +COPYRIGHT +--------- +This program is written by Kevin M. Rosenberg, M.D. + +It is covered by the GNU General Public License (GPL) which +allows copying and modifying this code with restrictions. See the +file COPYING for complete details. + +HISTORY +------ + +CTSim development began in 1983 while I was in medical school. It was +written using Lattice C and MS-DOS. I used assembly language to write +directly to an IBM EGA video adapter. + +In 1999, I ported CTsim to GNU/Linux. In April 2000, the source code +for CTSim was published on the Internet. + +STATUS +------ + +The official home for CTsim is http://www.ctsim.org. From this site, +you can download the CTsim source code and use CTSim online using a +beowulf cluster. + +I would be very pleased to have other developers join me in the +development of CTSim. Please see the TODO list for the most obvious +ideas. + +In this release, the main issue that needs addressing is the inclusion +of old graphic library code. This code is not being used by +CTSim. Compilation warnings will occur in these files. Please ignore +these warnings. In the next major release of CTSim, there will be +support for interactive graphics. I just need to write the low-level +drivers to support X-window rather than IBM EGA hardware. + +OVERVIEW +-------- + +CTSim simulates the collection of x-rays by a CT scanner. These x-rays +of objects are called projections or raysums. + +Phantom objects are defined. Several built-in phantoms are included, +as well as an extension to load files of phantom definitions. + +CTsim uses .sdf (standard data files) to represent 2-dimensional image +data. It uses a 32-bit floating-point pixel format. SDF is loosely +based on a image file format used by the Jet Propulsion Laboratory +(JPL). It supports multiple text labels per image. + +THE PROGRAMS +------------ + +phm2sdf - generates an SDF image of a phantom object + +phm2rs - Simulates the collection of CT data, or raysums, of a phantom +object + +ctrec - Performs an CT reconstruction, also known as image +reconstruction from projections. Reads a raysum file and writes a SDF +file. + +rs2sdf - Converts raysum data to a raw sinugram image + +sdf2img - Converts an SDF file to a variety of 8-bit image formats + +sdfinfo - Show statistics and history labels of SDF files + +TYPICAL USAGE +------------- + +When evaluating CT simulation, in general, these steps are followed: + +Create a phantom image and viewable image file + phm2sdf ... + sdf2img ... + +Simulate CT data collection and create a viewable image of raw raysums + phm2rs ... + rs2sdf ... + sdf2img ... + +Perform CT reconstruction and create viewable image file + ctrec ... + sdf2img ... + +These functions are convert output image to a PNG file performed by +the CGI program ctsim.cgi which can be installed as described in +INSTALL file. + +There is a sample shell script installed called 'sample-ctrec'. + + +CLOSING +------- + +Please enjoy CTSim. I'd like to hear any feedback + +Kevin M. Rosenberg, M.D. +kevin@rosenberg.net + + diff --git a/TODO b/TODO new file mode 100644 index 0000000..d0df363 --- /dev/null +++ b/TODO @@ -0,0 +1,7 @@ +Integrate low-level X11 graphics, replace all low-level driver code in +libgraph. All the high-level graphics routines are in place. + +Strip out unused functions from libk and libkmath. + +Integrate audio drivers into libcio -- used for the interactive CT display. + diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 0000000..ce38590 --- /dev/null +++ b/acconfig.h @@ -0,0 +1,56 @@ +/* Define to be the version of the distribution. */ +#undef VERSION + +/* Define to signal compiler support for void and void * types */ +#define HAVE_VOID 1 + +/* Define (if compiling as C++) to signal compiler support for bool type */ +#undef HAVE_BOOL + +/* Define under HP/UX to get matherr-related things from math.h. */ +#undef _HPUX_SOURCE + +/* Define to signal that fflush(NULL) works: it flushes all outstreams. */ +#undef HAVE_NULL_FLUSH + +/* Redundant and unused: Define to signal that fflush(NULL) doesn't work. */ +#undef DONT_HAVE_NULL_FLUSH + +/* Define to signal that Motif should be used, if X11 is used */ +#undef USE_MOTIF + +/* Define to signal support in libc for the pthread threads library */ +#undef PTHREAD_SUPPORT + +/* Define if we have the thread-safe library function ctime_r() */ +#undef HAVE_CTIME_R + +/* Define if we have the thread-safe library function localtime_r() */ +#undef HAVE_LOCALTIME_R + +/* Define to signal support in libXt/libX11 for multithreading */ +#undef X_THREAD_SUPPORT + +/* Define to signal support in -lXext for the DBE X11 protocol extension */ +#undef HAVE_DBE_SUPPORT + +/* Define to signal support in -lXext for the MBX X11 protocol extension */ +#undef HAVE_MBX_SUPPORT + +/* Define to enable support for the 45 LaserJet fonts in X output */ +#undef USE_LJ_FONTS_IN_X + +/* Define to enable support for the 45 LaserJet fonts in PS output */ +#undef USE_LJ_FONTS_IN_PS + +/* Define to enable support for the 35 PS fonts in PCL output */ +#undef USE_PS_FONTS_IN_PCL + +/* Define if have getopt_long function */ +#undef HAVE_GETOPT_LONG + +/* Define if have PNG library */ +#undef HAVE_PNG + +/* Define is have interactive graphics */ +#undef HAVE_INTERACTIVE_GRAPHICS diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..8971ab4 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,142 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4a + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN(AM_INIT_AUTOMAKE, +[AC_REQUIRE([AC_PROG_INSTALL]) +dnl We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN(AM_SANITY_CHECK, +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN(AM_MISSING_PROG, +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN(AM_CONFIG_HEADER, +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + +# Define a conditional. + +AC_DEFUN(AM_CONDITIONAL, +[AC_SUBST($1_TRUE) +AC_SUBST($1_FALSE) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + diff --git a/acsite.m4 b/acsite.m4 new file mode 100644 index 0000000..a44ae52 --- /dev/null +++ b/acsite.m4 @@ -0,0 +1,24 @@ +dnl aclocal.m4 generated automatically by aclocal 1.3 + +dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +dnl This Makefile.in is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# +# acinclude.m4 +# + +dnl Add argument to CFLAGS if using gcc. +AC_DEFUN(AC_ADD_GCC_CFLAGS, +[AC_REQUIRE([AC_PROG_CC]) + if test -n "$GCC"; then + CFLAGS="$CFLAGS $1" + fi + ]) + diff --git a/batch-update b/batch-update new file mode 100755 index 0000000..3e9d4f8 --- /dev/null +++ b/batch-update @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +foreach $file (@ARGV) +{ + open(IN,$file) || die "Can not open $file"; + open(OUT,"> /tmp/upd.$$") || die "Can not open /tmp/upd.$$"; + while () { + if (/Copyright \(C\) 1983-2000 Kevin Rosenberg/) { + print OUT '** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: batch-update,v 1.1 2000/04/28 13:02:43 kevin Exp $ +** $Log: batch-update,v $ +** Revision 1.1 2000/04/28 13:02:43 kevin +** Initial revision +** +'; + } else { + print OUT $_; + } + } + close(IN); + close(OUT); + unlink($file); + `mv /tmp/upd.$$ $file`; +} + diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile new file mode 100644 index 0000000..0fd76fa --- /dev/null +++ b/cgi-bin/Makefile @@ -0,0 +1,219 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +cgibin_SCRIPTS = ctsim.cgi +EXTRA_SCRIPTS = ctsim.cgi +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = ctsim.cgi +SCRIPTS = $(cgibin_SCRIPTS) + +DIST_COMMON = Makefile.am Makefile.in ctsim.cgi.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu cgi-bin/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +ctsim.cgi: $(top_builddir)/config.status ctsim.cgi.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-cgibinSCRIPTS: $(cgibin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(cgibindir) + @list='$(cgibin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-cgibinSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(cgibin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + done +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = cgi-bin + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu cgi-bin/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-cgibinSCRIPTS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-cgibinSCRIPTS +uninstall: uninstall-am +all-am: Makefile $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(cgibindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-cgibinSCRIPTS install-cgibinSCRIPTS tags distdir \ +info-am info dvi-am dvi check check-am installcheck-am installcheck \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/cgi-bin/Makefile.am b/cgi-bin/Makefile.am new file mode 100644 index 0000000..d523a20 --- /dev/null +++ b/cgi-bin/Makefile.am @@ -0,0 +1,2 @@ +cgibin_SCRIPTS=@cgiprograms@ +EXTRA_SCRIPTS=ctsim.cgi diff --git a/cgi-bin/Makefile.in b/cgi-bin/Makefile.in new file mode 100644 index 0000000..4e7f032 --- /dev/null +++ b/cgi-bin/Makefile.in @@ -0,0 +1,219 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +cgibin_SCRIPTS = @cgiprograms@ +EXTRA_SCRIPTS = ctsim.cgi +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = ctsim.cgi +SCRIPTS = $(cgibin_SCRIPTS) + +DIST_COMMON = Makefile.am Makefile.in ctsim.cgi.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu cgi-bin/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +ctsim.cgi: $(top_builddir)/config.status ctsim.cgi.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-cgibinSCRIPTS: $(cgibin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(cgibindir) + @list='$(cgibin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-cgibinSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(cgibin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(cgibindir)/`echo $$p|sed '$(transform)'`; \ + done +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = cgi-bin + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu cgi-bin/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-cgibinSCRIPTS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-cgibinSCRIPTS +uninstall: uninstall-am +all-am: Makefile $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(cgibindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-cgibinSCRIPTS install-cgibinSCRIPTS tags distdir \ +info-am info dvi-am dvi check check-am installcheck-am installcheck \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/cgi-bin/ctsim.cgi b/cgi-bin/ctsim.cgi new file mode 100644 index 0000000..10f7549 --- /dev/null +++ b/cgi-bin/ctsim.cgi @@ -0,0 +1,289 @@ +#!/usr/bin/perl +# Generated automatically from ctsim.cgi.in by configure. + +use strict; +use CGI; +use File::Basename; +use Fcntl ':flock'; + +my $opt_d = 0; +my $bindir = "/opt/ctsim/bin"; +$ENV{'PATH'} = $bindir; + +my $fromhost = $ENV{'REMOTE_HOST'}; + +my $gmt_start = time(); +my $gmt_end; +my $execution_time; + +my %in; +CGI::ReadParse(\%in); + +# Incoming variables +# Phantom_Name, Phantom_Nx, Phantom_Ny, Phantom_NSample +# RS_NDet, RS_NRot, RS_NRay, RS_RotAngle, +# IR_Nx, IR_Ny, IR_Filter, IR_Filter_Param + +my $error = ""; + +my $Phantom_Name = FilterMetaChars($in{'Phantom_Name'}); +my $Phantom_Nx = FilterToNumber($in{'Phantom_Nx'}); +my $Phantom_Ny = FilterToNumber($in{'Phantom_Ny'}); +my $Phantom_NSample = FilterToNumber($in{'Phantom_NSample'}); +$error .= "Phantom name must not be blank
" if ($Phantom_Name eq ""); +$error .= "Phantom NX and NY must be between 5 and 1024
" if ($Phantom_Nx < 5 || $Phantom_Nx > 1024 || $Phantom_Ny < 5 || $Phantom_Ny > 1024); +$error .= "Phantom NSample must be between 1 and 10
" if ($Phantom_NSample < 1 || $Phantom_NSample > 10); + +my $RS_NDet = FilterToNumber($in{'RS_NDet'}); +my $RS_NRot = FilterToNumber($in{'RS_NRot'}); +my $RS_NRay = FilterToNumber($in{'RS_NRay'}); +my $RS_RotAngle = FilterToNumber($in{'RS_RotAngle'}); +$error .= "Raysum NDet must be between 5 and 1800
" if ($RS_NDet < 5 || $RS_NDet > 1800); +$error .= "Raysum NRot must be between 5 and 2048
" if ($RS_NRot < 5 || $RS_NRot > 2048); +$error .= "Raysum RotAngle must be between 0.1 and 2
" if ($RS_RotAngle < 0.1 || $RS_RotAngle > 2); + +#my $IR_Nx = FilterToNumber($in{'IR_Nx'}); +#my $IR_Ny = FilterToNumber($in{'IR_Ny'}); +my $IR_Nx = $Phantom_Nx; +my $IR_Ny = $Phantom_Ny; +my $IR_Filter = FilterMetaChars($in{'IR_Filter'}); +my $IR_Filter_Param = FilterToNumber($in{'IR_Filter_Param'}); +my $IR_Interp = FilterMetaChars($in{'IR_Interp'}); +my $IR_Backproj = FilterMetaChars($in{'IR_Backproj'}); + +my $Disp_Min = "auto"; +my $Disp_Max = "auto"; +$Disp_Min = FilterToNumber($in{'Disp_Min'}) if ($in{'Disp_Min'} ne "auto" && $in{'Disp_Min'} ne ""); +$Disp_Max = FilterToNumber($in{'Disp_Max'}) if ($in{'Disp_Max'} ne "auto" && $in{'Disp_Max'} ne ""); +if ($Disp_Min ne 'auto' && ! ($Disp_Min =~ /^[\d\.]+$/)) { + $error .= "Display Minimum must be 'auto' or numeric (received '$Disp_Min')
"; +} +if ($Disp_Max ne 'auto' && ! ($Disp_Max =~ /^[\d\.]+$/)) { + $error .= "Display Maximum must be 'auto' or numeric (received '$Disp_Max')
"; +} + +my $MPI_Str = FilterMetaChars($in{'MPI'}); +my $MPI = 0; +$MPI = 1 if ($MPI_Str eq "yes"); + +$error .= "IR Nx and Ny must be between 5 and 1024
" if ($IR_Nx < 5 || $IR_Nx > 1024 || $IR_Ny < 5 || $IR_Ny > 1024); +$error .= "IR Filter Parameter must be between 0 and 1
" if ($IR_Filter_Param < 0 || $IR_Filter_Param > 1); + + +my $jobdir = "/opt/apache/htdocs/ctsim/webdata"; +my $tmpid = $$; +my $auto_window_img = "std0.1"; +my $auto_window_diff = "std1"; +my $auto_window_rs = "full"; +my $datadir = "/opt/apache/htdocs/ctsim/webdata"; +my $url_datadir = "/ctsim/webdata"; +my $logfile = "$jobdir/ctsim.log"; + +my $result_fname = "$datadir/result-$tmpid.html"; +my $phantom_fname = "$datadir/phantom-$tmpid.sdf"; +my $rs_fname = "$datadir/rs-$tmpid.rs"; +my $ir_fname = "$datadir/ir-$tmpid.sdf"; +my $rs_sdf_fname = "$datadir/rs-$tmpid.sdf"; +my $diff_fname = "$datadir/diff-$tmpid.sdf"; +my $phantom_png = "$datadir/phantom-$tmpid.png"; +my $ir_png = "$datadir/ir-$tmpid.png"; +my $rs_png = "$datadir/rs-$tmpid.png"; +my $diff_png = "$datadir/diff-$tmpid.png"; + +my $result_url = "$url_datadir/result-$tmpid.html"; +my $phantom_png_url = "$url_datadir/phantom-$tmpid.png"; +my $ir_png_url = "$url_datadir/ir-$tmpid.png"; +my $rs_png_url = "$url_datadir/rs-$tmpid.png"; +my $diff_png_url = "$url_datadir/diff-$tmpid.png"; + +my $ir_ver = "$bindir/ir"; +my $rs_ver = "$bindir/rs"; +my $gp_ver = "$bindir/gp"; +my $diff_ver = "$bindir/sdf-2"; +$ir_ver = "/opt/lam/bin/mpirun N N $bindir/ir-mpi" if $MPI; +$rs_ver = "/opt/lam/bin/mpirun N N $bindir/rs-mpi" if $MPI; +$gp_ver = "/opt/lam/bin/mpirun N N $bindir/gp-mpi" if $MPI; + +my $gp_cmd = "$gp_ver $phantom_fname $Phantom_Nx $Phantom_Ny --phantom $Phantom_Name --nsample $Phantom_NSample"; +my $rs_cmd = "$rs_ver $rs_fname $RS_NDet $RS_NRot --phantom $Phantom_Name --nray $RS_NRay --rotangle $RS_RotAngle"; +my $rs_sdf_cmd = "$bindir/rs2sdf $rs_fname $rs_sdf_fname"; +my $ir_cmd = "$ir_ver $rs_fname $ir_fname $IR_Nx $IR_Ny --filter $IR_Filter --filter-param $IR_Filter_Param --interp $IR_Interp --backproj $IR_Backproj"; +my $diff_cmd = "$diff_ver $phantom_fname $ir_fname $diff_fname --comp"; + +my $window_options = "--auto $auto_window_img"; +if ($Disp_Min ne 'auto') { + $window_options .= " --min $Disp_Min"; +} +if ($Disp_Max ne 'auto') { + $window_options .= " --max $Disp_Max"; +} + +my $png1_cmd = "$bindir/sdf2img $phantom_fname $phantom_png $window_options --stats --format png"; +my $png2_cmd = "$bindir/sdf2img $ir_fname $ir_png $window_options --stats --format png"; +my $png3_cmd = "$bindir/sdf2img $rs_sdf_fname $rs_png --auto $auto_window_rs --stats --format png"; +my $png4_cmd = "$bindir/sdf2img $diff_fname $diff_png --auto $auto_window_diff --stats --format png"; + +my $title = "CT Simulation Results"; + +my $out = head(); +$out .= " $title \n"; +$out .= "\n"; +$out .= "

$title


\n"; + +if ($opt_d) { + $out .= "

Commands

\n"; + $out .= "$gp_cmd
\n$rs_cmd
\n$rs_sdf_cmd
\n$ir_cmd
\n$diff_cmd
\n$png1_cmd
\n$png2_cmd
\n" . + "$png3_cmd
\n$png4_cmd
\n"; +} + +my $cmdout = ""; +if ($error ne "") { + $out .= "The following errors were present in your request.
\n"; + $out .= "Please correct them and try submitting your request again.

\n"; + $out .= "$error"; +} else { + my $gp_out; + my $rs_out; + my $rs_sdf_out; + my $ir_out; + my $diff_out; + my $png_gp_out; + my $png_ir_out; + my $png_rs_out; + my $png_diff_out; + if (1) { + $gp_out = `$gp_cmd`; + $rs_out .= `$rs_cmd`; + $rs_sdf_out .= `$rs_sdf_cmd`; + $ir_out .= `$ir_cmd`; + $diff_out .= `$diff_cmd`; + $png_gp_out .= `$png1_cmd`; + $png_ir_out .= `$png2_cmd`; + $png_rs_out .= `$png3_cmd`; + $png_diff_out .= `$png4_cmd`; + } else { + $gp_out = `$gp_cmd 2>&1`; + $rs_out .= `$rs_cmd 2>&1`; + $rs_sdf_out .= `$rs_sdf_cmd 2>&1`; + $ir_out .= `$ir_cmd 2>&1`; + $diff_out .= `$diff_cmd 2>&1`; + $png_gp_out .= `$png1_cmd 2>&1`; + $png_ir_out .= `$png2_cmd 2>&1`; + $png_rs_out .= `$png3_cmd 2>&1`; + $png_diff_out .= `$png4_cmd 2>&1`; + } + $cmdout = "$gp_cmd\n $gp_out $rs_cmd\n $rs_out $rs_sdf_cmd\n $rs_sdf_out $ir_cmd\n $ir_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_ir_out $png3_cmd\n $png_rs_out $png4_cmd\n $png_diff_out"; + if (open(LOGFILE,">> $logfile")) { + flock(LOGFILE,LOCK_EX); + seek(LOGFILE, 0, 2); + print LOGFILE "Job $tmpid\n"; + print LOGFILE $cmdout; + print LOGFILE "----------------------------------------------------\n"; + flock(LOGFILE,LOCK_UN); + close(LOGFILE); + } + $gmt_end = time(); + $execution_time = $gmt_end - $gmt_start; + if ($opt_d) + { + $out .= "

Command Output

$cmdout
\n"; + } + my $png_gp_out_html = $png_gp_out; + my $png_ir_out_html = $png_ir_out; + my $png_rs_out_html = $png_rs_out; + my $png_diff_out_html = $png_diff_out; + $png_gp_out_html =~ s/\n/
/gms; + $png_ir_out_html =~ s/\n/
/gms; + $png_rs_out_html =~ s/\n/
/gms; + $png_diff_out_html =~ s/\n/
/gms; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "
Phantom ImageReconstructed Image

$png_gp_out

$png_ir_out
Raysum SinusoidPhantom/Reconst Error

$png_rs_out

$diff_out
$png_diff_out
"; + $out .= "Execution time: $execution_time seconds\n"; +} + +$out .= "
\n"; +$out .= "Return to CT Simulation Designer.
\n"; +$out .= "Return to Med-Info.\n"; +$out .= " "; +$out .= "\n"; + +if (open(OUTFILE,"> $result_fname")) +{ + flock(OUTFILE,LOCK_EX); + print OUTFILE $out; + flock(OUTFILE,LOCK_UN); + close OUTFILE; + print "Location: $result_url\n\n"; +} +else +{ + print "Content-type: text/plain\n\n"; + print "The simulator was unable to create an result file.\n"; +} +if (open(JOBFILES,"> $jobdir/$tmpid")) +{ + flock(JOBFILES,LOCK_EX); + print JOBFILES "gmt_start=$gmt_start\n"; + print JOBFILES "gmt_end=$gmt_end\n"; + print JOBFILES "execution_time=$execution_time\n"; + print JOBFILES "Phantom_Name=$Phantom_Name\n"; + print JOBFILES "Phantom_Nx=$Phantom_Nx\n"; + print JOBFILES "Phantom_Ny=$Phantom_Nx\n"; + print JOBFILES "Phantom_NSample=$Phantom_NSample\n"; + print JOBFILES "RS_NDet=$RS_NDet\n"; + print JOBFILES "RS_NRot=$RS_NRot\n"; + print JOBFILES "RS_NRay=$RS_NRay\n"; + print JOBFILES "RS_RotAngle=$RS_RotAngle\n"; + print JOBFILES "IR_Nx=$IR_Nx\n"; + print JOBFILES "IR_Ny=$IR_Ny\n"; + print JOBFILES "IR_Interp=$IR_Interp\n"; + print JOBFILES "IR_Filter=$IR_Filter\n"; + print JOBFILES "IR_Filter_Param=$IR_Filter_Param\n"; + print JOBFILES "IR_Backproj=$IR_Backproj\n"; + print JOBFILES "Disp_Min=$Disp_Min\n"; + print JOBFILES "Disp_Max=$Disp_Max\n"; + print JOBFILES "MPI=$MPI\n"; + print JOBFILES "Files=$result_fname,$phantom_fname,$rs_fname,$ir_fname,$phantom_png,$ir_png,$rs_sdf_fname,$rs_png\n" if ($error eq ""); + printf JOBFILES "cmdout=$cmdout\n"; + flock(JOBFILES,LOCK_UN); + close JOBFILES; +} + + +exit; + + +sub internal_error +{ + my $out = head(); + $out .= "

Internal error

+ Please notify webmaster\@med-info.com + "; + print $out; + exit; +} + +sub head +{ +# "Content: text/html\n\n"; +} + + +sub FilterMetaChars +{ + my $var = pop(@_); + $var =~ /^(\w+)$/; + $1; +} + +sub FilterToNumber +{ + my $var = pop(@_); + $var =~ /^(\d*\.*\d*)$/; + $1; +} diff --git a/cgi-bin/ctsim.cgi.in b/cgi-bin/ctsim.cgi.in new file mode 100755 index 0000000..c4d9e53 --- /dev/null +++ b/cgi-bin/ctsim.cgi.in @@ -0,0 +1,289 @@ +#!/usr/bin/perl +# @configure_input@ + +use strict; +use CGI; +use File::Basename; +use Fcntl ':flock'; + +my $opt_d = 0; +my $bindir = "@prefix@/bin"; +$ENV{'PATH'} = $bindir; + +my $fromhost = $ENV{'REMOTE_HOST'}; + +my $gmt_start = time(); +my $gmt_end; +my $execution_time; + +my %in; +CGI::ReadParse(\%in); + +# Incoming variables +# Phantom_Name, Phantom_Nx, Phantom_Ny, Phantom_NSample +# RS_NDet, RS_NRot, RS_NRay, RS_RotAngle, +# IR_Nx, IR_Ny, IR_Filter, IR_Filter_Param + +my $error = ""; + +my $Phantom_Name = FilterMetaChars($in{'Phantom_Name'}); +my $Phantom_Nx = FilterToNumber($in{'Phantom_Nx'}); +my $Phantom_Ny = FilterToNumber($in{'Phantom_Ny'}); +my $Phantom_NSample = FilterToNumber($in{'Phantom_NSample'}); +$error .= "Phantom name must not be blank
" if ($Phantom_Name eq ""); +$error .= "Phantom NX and NY must be between 5 and 1024
" if ($Phantom_Nx < 5 || $Phantom_Nx > 1024 || $Phantom_Ny < 5 || $Phantom_Ny > 1024); +$error .= "Phantom NSample must be between 1 and 10
" if ($Phantom_NSample < 1 || $Phantom_NSample > 10); + +my $RS_NDet = FilterToNumber($in{'RS_NDet'}); +my $RS_NRot = FilterToNumber($in{'RS_NRot'}); +my $RS_NRay = FilterToNumber($in{'RS_NRay'}); +my $RS_RotAngle = FilterToNumber($in{'RS_RotAngle'}); +$error .= "Raysum NDet must be between 5 and 1800
" if ($RS_NDet < 5 || $RS_NDet > 1800); +$error .= "Raysum NRot must be between 5 and 2048
" if ($RS_NRot < 5 || $RS_NRot > 2048); +$error .= "Raysum RotAngle must be between 0.1 and 2
" if ($RS_RotAngle < 0.1 || $RS_RotAngle > 2); + +#my $IR_Nx = FilterToNumber($in{'IR_Nx'}); +#my $IR_Ny = FilterToNumber($in{'IR_Ny'}); +my $IR_Nx = $Phantom_Nx; +my $IR_Ny = $Phantom_Ny; +my $IR_Filter = FilterMetaChars($in{'IR_Filter'}); +my $IR_Filter_Param = FilterToNumber($in{'IR_Filter_Param'}); +my $IR_Interp = FilterMetaChars($in{'IR_Interp'}); +my $IR_Backproj = FilterMetaChars($in{'IR_Backproj'}); + +my $Disp_Min = "auto"; +my $Disp_Max = "auto"; +$Disp_Min = FilterToNumber($in{'Disp_Min'}) if ($in{'Disp_Min'} ne "auto" && $in{'Disp_Min'} ne ""); +$Disp_Max = FilterToNumber($in{'Disp_Max'}) if ($in{'Disp_Max'} ne "auto" && $in{'Disp_Max'} ne ""); +if ($Disp_Min ne 'auto' && ! ($Disp_Min =~ /^[\d\.]+$/)) { + $error .= "Display Minimum must be 'auto' or numeric (received '$Disp_Min')
"; +} +if ($Disp_Max ne 'auto' && ! ($Disp_Max =~ /^[\d\.]+$/)) { + $error .= "Display Maximum must be 'auto' or numeric (received '$Disp_Max')
"; +} + +my $MPI_Str = FilterMetaChars($in{'MPI'}); +my $MPI = 0; +$MPI = 1 if ($MPI_Str eq "yes"); + +$error .= "IR Nx and Ny must be between 5 and 1024
" if ($IR_Nx < 5 || $IR_Nx > 1024 || $IR_Ny < 5 || $IR_Ny > 1024); +$error .= "IR Filter Parameter must be between 0 and 1
" if ($IR_Filter_Param < 0 || $IR_Filter_Param > 1); + + +my $jobdir = "@webdatadir@"; +my $tmpid = $$; +my $auto_window_img = "std0.1"; +my $auto_window_diff = "std1"; +my $auto_window_rs = "full"; +my $datadir = "@webdatadir@"; +my $url_datadir = "@webdataurl@"; +my $logfile = "$jobdir/ctsim.log"; + +my $result_fname = "$datadir/result-$tmpid.html"; +my $phantom_fname = "$datadir/phantom-$tmpid.sdf"; +my $rs_fname = "$datadir/rs-$tmpid.rs"; +my $ir_fname = "$datadir/ir-$tmpid.sdf"; +my $rs_sdf_fname = "$datadir/rs-$tmpid.sdf"; +my $diff_fname = "$datadir/diff-$tmpid.sdf"; +my $phantom_png = "$datadir/phantom-$tmpid.png"; +my $ir_png = "$datadir/ir-$tmpid.png"; +my $rs_png = "$datadir/rs-$tmpid.png"; +my $diff_png = "$datadir/diff-$tmpid.png"; + +my $result_url = "$url_datadir/result-$tmpid.html"; +my $phantom_png_url = "$url_datadir/phantom-$tmpid.png"; +my $ir_png_url = "$url_datadir/ir-$tmpid.png"; +my $rs_png_url = "$url_datadir/rs-$tmpid.png"; +my $diff_png_url = "$url_datadir/diff-$tmpid.png"; + +my $ir_ver = "$bindir/ir"; +my $rs_ver = "$bindir/rs"; +my $gp_ver = "$bindir/gp"; +my $diff_ver = "$bindir/sdf-2"; +$ir_ver = "/opt/lam/bin/mpirun N N $bindir/ir-mpi" if $MPI; +$rs_ver = "/opt/lam/bin/mpirun N N $bindir/rs-mpi" if $MPI; +$gp_ver = "/opt/lam/bin/mpirun N N $bindir/gp-mpi" if $MPI; + +my $gp_cmd = "$gp_ver $phantom_fname $Phantom_Nx $Phantom_Ny --phantom $Phantom_Name --nsample $Phantom_NSample"; +my $rs_cmd = "$rs_ver $rs_fname $RS_NDet $RS_NRot --phantom $Phantom_Name --nray $RS_NRay --rotangle $RS_RotAngle"; +my $rs_sdf_cmd = "$bindir/rs2sdf $rs_fname $rs_sdf_fname"; +my $ir_cmd = "$ir_ver $rs_fname $ir_fname $IR_Nx $IR_Ny --filter $IR_Filter --filter-param $IR_Filter_Param --interp $IR_Interp --backproj $IR_Backproj"; +my $diff_cmd = "$diff_ver $phantom_fname $ir_fname $diff_fname --comp"; + +my $window_options = "--auto $auto_window_img"; +if ($Disp_Min ne 'auto') { + $window_options .= " --min $Disp_Min"; +} +if ($Disp_Max ne 'auto') { + $window_options .= " --max $Disp_Max"; +} + +my $png1_cmd = "$bindir/sdf2img $phantom_fname $phantom_png $window_options --stats --format png"; +my $png2_cmd = "$bindir/sdf2img $ir_fname $ir_png $window_options --stats --format png"; +my $png3_cmd = "$bindir/sdf2img $rs_sdf_fname $rs_png --auto $auto_window_rs --stats --format png"; +my $png4_cmd = "$bindir/sdf2img $diff_fname $diff_png --auto $auto_window_diff --stats --format png"; + +my $title = "CT Simulation Results"; + +my $out = head(); +$out .= " $title \n"; +$out .= "\n"; +$out .= "

$title


\n"; + +if ($opt_d) { + $out .= "

Commands

\n"; + $out .= "$gp_cmd
\n$rs_cmd
\n$rs_sdf_cmd
\n$ir_cmd
\n$diff_cmd
\n$png1_cmd
\n$png2_cmd
\n" . + "$png3_cmd
\n$png4_cmd
\n"; +} + +my $cmdout = ""; +if ($error ne "") { + $out .= "The following errors were present in your request.
\n"; + $out .= "Please correct them and try submitting your request again.

\n"; + $out .= "$error"; +} else { + my $gp_out; + my $rs_out; + my $rs_sdf_out; + my $ir_out; + my $diff_out; + my $png_gp_out; + my $png_ir_out; + my $png_rs_out; + my $png_diff_out; + if (1) { + $gp_out = `$gp_cmd`; + $rs_out .= `$rs_cmd`; + $rs_sdf_out .= `$rs_sdf_cmd`; + $ir_out .= `$ir_cmd`; + $diff_out .= `$diff_cmd`; + $png_gp_out .= `$png1_cmd`; + $png_ir_out .= `$png2_cmd`; + $png_rs_out .= `$png3_cmd`; + $png_diff_out .= `$png4_cmd`; + } else { + $gp_out = `$gp_cmd 2>&1`; + $rs_out .= `$rs_cmd 2>&1`; + $rs_sdf_out .= `$rs_sdf_cmd 2>&1`; + $ir_out .= `$ir_cmd 2>&1`; + $diff_out .= `$diff_cmd 2>&1`; + $png_gp_out .= `$png1_cmd 2>&1`; + $png_ir_out .= `$png2_cmd 2>&1`; + $png_rs_out .= `$png3_cmd 2>&1`; + $png_diff_out .= `$png4_cmd 2>&1`; + } + $cmdout = "$gp_cmd\n $gp_out $rs_cmd\n $rs_out $rs_sdf_cmd\n $rs_sdf_out $ir_cmd\n $ir_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_ir_out $png3_cmd\n $png_rs_out $png4_cmd\n $png_diff_out"; + if (open(LOGFILE,">> $logfile")) { + flock(LOGFILE,LOCK_EX); + seek(LOGFILE, 0, 2); + print LOGFILE "Job $tmpid\n"; + print LOGFILE $cmdout; + print LOGFILE "----------------------------------------------------\n"; + flock(LOGFILE,LOCK_UN); + close(LOGFILE); + } + $gmt_end = time(); + $execution_time = $gmt_end - $gmt_start; + if ($opt_d) + { + $out .= "

Command Output

$cmdout
\n"; + } + my $png_gp_out_html = $png_gp_out; + my $png_ir_out_html = $png_ir_out; + my $png_rs_out_html = $png_rs_out; + my $png_diff_out_html = $png_diff_out; + $png_gp_out_html =~ s/\n/
/gms; + $png_ir_out_html =~ s/\n/
/gms; + $png_rs_out_html =~ s/\n/
/gms; + $png_diff_out_html =~ s/\n/
/gms; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "\n"; + $out .= "
Phantom ImageReconstructed Image

$png_gp_out

$png_ir_out
Raysum SinusoidPhantom/Reconst Error

$png_rs_out

$diff_out
$png_diff_out
"; + $out .= "Execution time: $execution_time seconds\n"; +} + +$out .= "
\n"; +$out .= "Return to CT Simulation Designer.
\n"; +$out .= "Return to Med-Info.\n"; +$out .= " "; +$out .= "\n"; + +if (open(OUTFILE,"> $result_fname")) +{ + flock(OUTFILE,LOCK_EX); + print OUTFILE $out; + flock(OUTFILE,LOCK_UN); + close OUTFILE; + print "Location: $result_url\n\n"; +} +else +{ + print "Content-type: text/plain\n\n"; + print "The simulator was unable to create an result file.\n"; +} +if (open(JOBFILES,"> $jobdir/$tmpid")) +{ + flock(JOBFILES,LOCK_EX); + print JOBFILES "gmt_start=$gmt_start\n"; + print JOBFILES "gmt_end=$gmt_end\n"; + print JOBFILES "execution_time=$execution_time\n"; + print JOBFILES "Phantom_Name=$Phantom_Name\n"; + print JOBFILES "Phantom_Nx=$Phantom_Nx\n"; + print JOBFILES "Phantom_Ny=$Phantom_Nx\n"; + print JOBFILES "Phantom_NSample=$Phantom_NSample\n"; + print JOBFILES "RS_NDet=$RS_NDet\n"; + print JOBFILES "RS_NRot=$RS_NRot\n"; + print JOBFILES "RS_NRay=$RS_NRay\n"; + print JOBFILES "RS_RotAngle=$RS_RotAngle\n"; + print JOBFILES "IR_Nx=$IR_Nx\n"; + print JOBFILES "IR_Ny=$IR_Ny\n"; + print JOBFILES "IR_Interp=$IR_Interp\n"; + print JOBFILES "IR_Filter=$IR_Filter\n"; + print JOBFILES "IR_Filter_Param=$IR_Filter_Param\n"; + print JOBFILES "IR_Backproj=$IR_Backproj\n"; + print JOBFILES "Disp_Min=$Disp_Min\n"; + print JOBFILES "Disp_Max=$Disp_Max\n"; + print JOBFILES "MPI=$MPI\n"; + print JOBFILES "Files=$result_fname,$phantom_fname,$rs_fname,$ir_fname,$phantom_png,$ir_png,$rs_sdf_fname,$rs_png\n" if ($error eq ""); + printf JOBFILES "cmdout=$cmdout\n"; + flock(JOBFILES,LOCK_UN); + close JOBFILES; +} + + +exit; + + +sub internal_error +{ + my $out = head(); + $out .= "

Internal error

+ Please notify webmaster\@med-info.com + "; + print $out; + exit; +} + +sub head +{ +# "Content: text/html\n\n"; +} + + +sub FilterMetaChars +{ + my $var = pop(@_); + $var =~ /^(\w+)$/; + $1; +} + +sub FilterToNumber +{ + my $var = pop(@_); + $var =~ /^(\d*\.*\d*)$/; + $1; +} diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..7cdca48 --- /dev/null +++ b/config.h.in @@ -0,0 +1,101 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if you don't have vprintf but do have _doprnt. */ +#undef HAVE_DOPRNT + +/* Define if you have the vprintf function. */ +#undef HAVE_VPRINTF + +/* Define to `long' if doesn't define. */ +#undef off_t + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if your declares struct tm. */ +#undef TM_IN_SYS_TIME + +/* Define if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Define to signal support in libXt/libX11 for multithreading */ +#undef X_THREAD_SUPPORT + +/* Define to signal support in -lXext for the DBE X11 protocol extension */ +#undef HAVE_DBE_SUPPORT + +/* Define to signal support in -lXext for the MBX X11 protocol extension */ +#undef HAVE_MBX_SUPPORT + +/* Define if have getopt_long function */ +#undef HAVE_GETOPT_LONG + +/* Define if have PNG library */ +#undef HAVE_PNG + +/* Define if you have the strtod function. */ +#undef HAVE_STRTOD + +/* Define if you have the strtol function. */ +#undef HAVE_STRTOL + +/* Define if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XDBE_H + +/* Define if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_MULTIBUF_H + +/* Define if you have the header file. */ +#undef HAVE_CTYPE_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_GETOPT_H + +/* Define if you have the header file. */ +#undef HAVE_MATH_H + +/* Define if you have the header file. */ +#undef HAVE_SETJMP_H + +/* Define if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM + +/* Name of package */ +#undef PACKAGE + +/* Version number of package */ +#undef VERSION + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..36c74b6 --- /dev/null +++ b/configure.in @@ -0,0 +1,288 @@ +dnl Process this file with autoconf to produce a configure script. + +dnl Must reset CDPATH so that bash's cd does not print to stdout +dnl CDPATH= + +AC_INIT(src/ctrec.c) +AM_INIT_AUTOMAKE(ctsim,0.5.0) +AM_CONFIG_HEADER(config.h) + +dnl Checks for programs. +AC_PROG_AWK +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PROG_RANLIB +AC_PROG_CC + +dnl Checks for libraries. +AC_CHECK_LIB(z, main, +[ + zlib="true" +], +[ + zlib="false" + AC_MSG_WARN([zlib missing. Will need zlib for PNG support]) +]) +AC_CHECK_LIB(m, main) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h sys/fcntl.h setjmp.h stdarg.h stddef.h sys/types.h sys/stat.h string.h ctype.h math.h stdio.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_STRUCT_TM + +dnl Checks for library functions. +AC_FUNC_VPRINTF +AC_CHECK_FUNCS(strtod strtol) +AC_CHECK_FUNC(basename) +AC_CHECK_FUNC(setjmp) +AC_CHECK_FUNC(getopt_long, +[ + getopt_long=true +], +[ + getopt_long=false + my_includes="$myincludes -I../getopt" + AC_DEFINE(HAVE_GETOPT_LONG) + ctlibs_base="$ctlibs_base -lgetopt" + LDFLAGS="$LDFLAGS -L../getopt" + AM_CONDITIONAL(INCLUDED_GETOPT_LONG, test 1==1) +]) + + +AC_ADD_GCC_CFLAGS([-Wall]) +AC_MSG_CHECKING(whether to enable verbose warnings) +AC_ARG_ENABLE(verbose-warnings, +[ --enable-verbose-warnings + Enable verbose compiler warnings.], +[ case "$enableval" in + yes) + AC_MSG_RESULT(yes) + AC_ADD_GCC_CFLAGS([-W]) + AC_ADD_GCC_CFLAGS([-Wshadow -Wpointer-arith -Wbad-function-cast]) + AC_ADD_GCC_CFLAGS([-Wcast-align -Wwrite-strings -Waggregate-return]) + AC_ADD_GCC_CFLAGS([-Wmissing-prototypes -Wstrict-prototypes]) + AC_ADD_GCC_CFLAGS([-pedantic]) + AC_ADD_GCC_CFLAGS([-Wredundant-decls]) + + ;; + *) + AC_MSG_RESULT(no) + ;; + esac ], AC_MSG_RESULT(no) +) + +dnl Check for debug mode +AC_ARG_ENABLE(debug, +[ --enable-debug Turn on debugging], +[case "${enableval}" in + yes) debug=true ;; + no) debug=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; +esac],[debug=false]) +AM_CONDITIONAL(DEBUG, test "$debug" = "true") + +dnl Set PNG directory +AC_MSG_CHECKING([for PNG library installation]) +AC_ARG_WITH(png, +[ --with-png[=PATH] Set path of lib PNG installation ], +[ + if test "$withval" != "no" ; then + trypngdir=$withval + if test "$prefix" != "NONE" ; then + trypngdir="$trypngdir $prefix" + fi + fi +] +) + +if test "$withval" != "no" -a "$zlib" = "true" ; then + for testpngdir in "." $trypngdir /usr/local /usr /opt ; do + if test -f "$testpngdir/lib/libpng.a" ; then + if test ! -f "$testpngdir/include/png.h" ; then + AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation]) + else + grep PNG_LIBPNG_VER_STRING "$testpngdir/include/png.h" | grep 9 > /dev/null + if test "$?" = "0" ; then + AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade]) + fi + fi + LDFLAGS="$LDFLAGS -L$testpngdir/lib" + CFLAGS="$CFLAGS -I$testpngdir/include" + pngdir="$testpngdir" + AC_DEFINE(HAVE_PNG) + break + elif test -f "$testpngdir/libpng.a" ; then + if test ! -f "$testpngdir/png.h" ; then + AC_MSG_ERROR([PNG library found, but png.h not found. Check PNG installation]) + else + grep PNG_LIBPNG_VER_STRING "$testpngdir/png.h" | grep 9 > /dev/null + if test "$?" = "0" ; then + AC_MSG_ERROR([Your version of libpng in $testpngdir is too old -- please upgrade]) + fi + fi + LDFLAGS="$LDFLAGS -L$testpngdir" + CFLAGS="$CFLAGS -I$testpngdir" + pngdir="$testpngdir" + AC_DEFINE(HAVE_PNG) + break + fi + done + AC_MSG_RESULT($pngdir) + AM_CONDITIONAL(HAVE_PNG, test -n "$pngdir") +else + AC_MSG_RESULT([no]) +fi + +dnl Set LAM path +AC_ARG_WITH(lam, +[ --with-lam[=PATH] Set path of LAM MPI ], +[ if test "$withval" != "no" ; then + trylamdir=$withval + fi ] +) + +if test "$withval" != "no" ; then + if test "$prefix" != "NONE" ; then + trylamdir="$trylamdir $prefix" + fi + + AC_MSG_CHECKING([for LAM MPI installation]) + for testlamdir in "." $trylamdir /usr/local /usr/local/lam /usr /usr/lam /opt /opt/lam ; do + if test -x "$testlamdir/bin/hcc" ; then + LDFLAGS="$LDFLAGS -L$testlamdir/lib" + CFLAGS="$CFLAGS -I$testlamdir/include" + lamdir="$testlamdir" + AC_SUBST(lamdir) + break + fi + done + AC_MSG_RESULT($lamdir) +fi + +AC_MSG_CHECKING([for web access]) +dnl Set cgi-bin directory +AC_ARG_WITH(cgibin-dir, [ --with-cgibin-dir=PATH Set path of CGI binaries directory ], +[ cgibindir=$withval ; AC_SUBST(cgibindir) ] ) + +AC_ARG_WITH(cgibin-url, [ --with-cgibin-url=PATH Set URL path of CGI binaries ], +[ cgibinurl=$withval ; AC_SUBST(cgibinurl) ] ) + +AC_ARG_WITH(webdata-dir, [ --with-webdata-dir=PATH Set path of webdata], +[ webdatadir=$withval ; AC_SUBST(webdatadir) ] ) + +AC_ARG_WITH(webdata-url, [ --with-webdata-url=PATH Set URL path of webdata], +[ webdataurl=$withval ; AC_SUBST(webdataurl) ] ) + +AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Set directory of html files], +[ htmldir=$withval ; AC_SUBST(htmldir) ] ) + +if test -n "$cgibindir" -o -n "$cgibinurl" ; then + cgiprograms=ctsim.cgi + AC_SUBST(cgiprograms) +fi + +if test -n "$htmldir" ; then + htmldata=ctsim.html + AC_SUBST(htmldata) +fi +AM_CONDITIONAL(USE_HTML, test -n "$htmldir") + +if test -n "$cgibindir" -o -n "$cgibinurl" -o -n "$webdatadir" -o -n "$webdataurl" -o -n "$htmldir" ; then + webenabled=true + AC_SUBST(webenabled) + AC_MSG_RESULT([yes]) + if test -z "$cgibindir" ; then + AC_MSG_ERROR([--with-cgibin-dir not set for web access]) + elif test -z "$cgibinurl" ; then + AC_MSG_ERROR([--with-cgibin-url not set for web access]) + elif test -z "$webdatadir" ; then + AC_MSG_ERROR([--with-webdata-dir not set for web access]) + elif test -z "$webdataurl" ; then + AC_MSG_ERROR([--with-webdata-url not set for web access]) + elif test -z "$htmldir" ; then + AC_MSG_ERROR([--with-html-dir not set for web access]) + fi +else + AC_MSG_RESULT([no]) +fi + +dnl Setting projet libraries and includes +LDFLAGS="$LDFLAGS -L../libezplot -L../libgraph -L../libkmath -L../libk -L../libcio -L../libir" +ctlibs_base="$ctlibs_base -lezplot -lgraph -lkmath -lk -lcio" +if test -n "$pngdir" ; then + ctlibs_base="$ctlibs_base -lpng" +fi +if test "$zlib" = "true" ; then + ctlibs_base="$ctlibs_base -lz" +fi +ctlibs="-lir $ctlibs_base" + +AC_SUBST(ctlibs) + +if test -n "$lamdir" ; then + ctlamlibs="-lir_lam $ctlibs_base" + lamprograms="ctrec-lam phm2sdf-lam phm2rs-lam" + AC_SUBST(lamprograms) + AC_SUBST(ctlamlibs) +fi + +AM_CONDITIONAL(USE_LAM, test -n "$lamdir") + +dnl Prepare to support X. If the user gave the command-line option +dnl --without-x, AC_PATH_XTRA will set no_x to "yes". Otherwise, it will +dnl add appropriate preprocessor flags to X_CFLAGS, and appropriate linker +dnl flags to X_LIBS. It also checks for system-specific X libraries, and +dnl adds them to X_PRE_LIBS or X_EXTRA_LIBS, as appropriate. (The former +dnl is where "-lSM -lICE" goes, in X11R6.) We define the X_TOOLKIT_LIBS +dnl and X_BASIC_LIBS argument vectors ourselves, and if X is to be +dnl supported, we'll concatenate the whole lot of these into a command line +dnl for libtool. See, e.g., the libplot_la_LIBADD line in +dnl libplot/Makefile.am. + +AC_PATH_XTRA +AC_SUBST(X_CFLAGS) +dnl Following five are concatenated together into a linker specification. +AC_SUBST(X_LIBS) +AC_SUBST(X_TOOLKIT_LIBS) +AC_SUBST(X_PRE_LIBS) +AC_SUBST(X_BASIC_LIBS) +AC_SUBST(X_EXTRA_LIBS) + +X_TOOLKIT_LIBS="-lXt" +X_BASIC_LIBS="-lXext -lX11" + +dnl Check whether libXt has thread support. Some platforms may have +dnl pthread support in libc, but no thread support in libXt/libX11. +our_saved_LDFLAGS="$LDFLAGS" +LDFLAGS="$X_LIBS $LDFLAGS" +AC_CHECK_LIB(Xt, XtToolkitThreadInitialize, AC_DEFINE(X_THREAD_SUPPORT), , $X_PRE_LIBS $X_BASIC_LIBS $X_EXTRA_LIBS) +LDFLAGS="$our_saved_LDFLAGS" + +dnl Check in -lXext for double buffering extensions to X11, and check +dnl whether appropriate header files are present. (Some systems have one +dnl but not the other.) +our_saved_LDFLAGS="$LDFLAGS" +LDFLAGS="$X_LIBS $LDFLAGS" +AC_CHECK_LIB(Xext, XdbeQueryExtension, AC_DEFINE(HAVE_DBE_SUPPORT), , -lX11 "$X_EXTRA_LIBS") +AC_CHECK_LIB(Xext, XmbufQueryExtension, AC_DEFINE(HAVE_MBX_SUPPORT), , -lX11 "$X_EXTRA_LIBS") +LDFLAGS="$our_saved_LDFLAGS" +our_saved_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$X_CFLAGS $CPPFLAGS" +AC_CHECK_HEADERS(X11/extensions/Xdbe.h X11/extensions/multibuf.h) +CPPFLAGS="$our_saved_CPPFLAGS" + +dnl Our Makefile.am files test the automake variable NO_X to determine +dnl whether X should be supported. +AM_CONDITIONAL(NO_X, test "x$no_x" = "xyes") + +my_includes="$my_includes -I../include -I.." +AC_SUBST(my_includes) + +AM_CONDITIONAL(HAVE_INTERACTIVE_GRAPHICS, test 1==0) + +AC_OUTPUT(Makefile libezplot/Makefile src/Makefile libgraph/Makefile libkmath/Makefile Makefile libk/Makefile libir/Makefile libcio/Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/ctsim.html html/Makefile include/Makefile getopt/Makefile src/sample-ctrec.sh) diff --git a/getopt/Makefile b/getopt/Makefile new file mode 100644 index 0000000..86d9f47 --- /dev/null +++ b/getopt/Makefile @@ -0,0 +1,318 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +noinst_LIBRARIES = libgetopt.a +libgetopt_a_SOURCES = getopt.c getopt1.c +noinst_HEADERS = getopt.h +INCLUDES = -I../include -I.. +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I.. +CPPFLAGS = +LDFLAGS = -L/usr/lib -L/opt/lam/lib -L../libezplot -L../libgraph -L../libkmath -L../libk -L../libcio -L../libir +LIBS = -lm +libgetopt_a_LIBADD = +libgetopt_a_OBJECTS = getopt.o getopt1.o +AR = ar +CFLAGS = -g -O2 -Wall -I/usr/include -I/opt/lam/include +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/getopt.P .deps/getopt1.P +SOURCES = $(libgetopt_a_SOURCES) +OBJECTS = $(libgetopt_a_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu getopt/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLIBRARIES: + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +distclean-noinstLIBRARIES: + +maintainer-clean-noinstLIBRARIES: + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +libgetopt.a: $(libgetopt_a_OBJECTS) $(libgetopt_a_DEPENDENCIES) + -rm -f libgetopt.a + $(AR) cru libgetopt.a $(libgetopt_a_OBJECTS) $(libgetopt_a_LIBADD) + $(RANLIB) libgetopt.a + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = getopt + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu getopt/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-tags distclean-depend distclean-generic \ + clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/getopt/Makefile.am b/getopt/Makefile.am new file mode 100644 index 0000000..1625b94 --- /dev/null +++ b/getopt/Makefile.am @@ -0,0 +1,4 @@ +noinst_LIBRARIES=libgetopt.a +libgetopt_a_SOURCES=getopt.c getopt1.c +noinst_HEADERS=getopt.h +INCLUDES=@my_includes@ diff --git a/getopt/Makefile.in b/getopt/Makefile.in new file mode 100644 index 0000000..41441a4 --- /dev/null +++ b/getopt/Makefile.in @@ -0,0 +1,318 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +noinst_LIBRARIES = libgetopt.a +libgetopt_a_SOURCES = getopt.c getopt1.c +noinst_HEADERS = getopt.h +INCLUDES = @my_includes@ +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libgetopt_a_LIBADD = +libgetopt_a_OBJECTS = getopt.o getopt1.o +AR = ar +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/getopt.P .deps/getopt1.P +SOURCES = $(libgetopt_a_SOURCES) +OBJECTS = $(libgetopt_a_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu getopt/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLIBRARIES: + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +distclean-noinstLIBRARIES: + +maintainer-clean-noinstLIBRARIES: + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +libgetopt.a: $(libgetopt_a_OBJECTS) $(libgetopt_a_DEPENDENCIES) + -rm -f libgetopt.a + $(AR) cru libgetopt.a $(libgetopt_a_OBJECTS) $(libgetopt_a_LIBADD) + $(RANLIB) libgetopt.a + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = getopt + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu getopt/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-tags distclean-depend distclean-generic \ + clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/getopt/getopt.c b/getopt/getopt.c new file mode 100644 index 0000000..4744e43 --- /dev/null +++ b/getopt/getopt.c @@ -0,0 +1,1055 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +# ifdef HAVE_LIBINTL_H +# include +# define _(msgid) gettext (msgid) +# else +# define _(msgid) (msgid) +# endif +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H +# include +# else +# include +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#ifdef _LIBC + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#ifdef _LIBC + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int print_errors = opterr; + if (optstring[0] == ':') + print_errors = 0; + + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#ifdef _LIBC +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (print_errors) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + } + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (print_errors) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (print_errors) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/getopt/getopt.h b/getopt/getopt.h new file mode 100644 index 0000000..b0147e9 --- /dev/null +++ b/getopt/getopt.h @@ -0,0 +1,169 @@ +/* Declarations for getopt. + Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +# if defined __STDC__ && __STDC__ + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if defined __STDC__ && __STDC__ +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int __argc, char *const *__argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/getopt/getopt1.c b/getopt/getopt1.c new file mode 100644 index 0000000..3d264f2 --- /dev/null +++ b/getopt/getopt1.c @@ -0,0 +1,188 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "getopt.h" + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/html/Makefile b/html/Makefile new file mode 100644 index 0000000..c6bb600 --- /dev/null +++ b/html/Makefile @@ -0,0 +1,218 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +html_DATA = ctsim.html +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = ctsim.html +DATA = $(html_DATA) + +DIST_COMMON = Makefile.am Makefile.in ctsim.html.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu html/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +ctsim.html: $(top_builddir)/config.status ctsim.html.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-htmlDATA: $(html_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(htmldir) + @list='$(html_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(htmldir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(htmldir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/$$p; \ + fi; fi; \ + done + +uninstall-htmlDATA: + @$(NORMAL_UNINSTALL) + list='$(html_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(htmldir)/$$p; \ + done +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = html + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu html/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-htmlDATA +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-htmlDATA +uninstall: uninstall-am +all-am: Makefile $(DATA) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(htmldir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-htmlDATA install-htmlDATA tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/html/Makefile.am b/html/Makefile.am new file mode 100644 index 0000000..ec027a5 --- /dev/null +++ b/html/Makefile.am @@ -0,0 +1,3 @@ +if USE_HTML +html_DATA=@htmldata@ +endif diff --git a/html/Makefile.in b/html/Makefile.in new file mode 100644 index 0000000..c09d80d --- /dev/null +++ b/html/Makefile.in @@ -0,0 +1,218 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +@USE_HTML_TRUE@html_DATA = @htmldata@ +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = ctsim.html +DATA = $(html_DATA) + +DIST_COMMON = Makefile.am Makefile.in ctsim.html.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu html/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +ctsim.html: $(top_builddir)/config.status ctsim.html.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-htmlDATA: $(html_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(htmldir) + @list='$(html_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(htmldir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(htmldir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/$$p; \ + fi; fi; \ + done + +uninstall-htmlDATA: + @$(NORMAL_UNINSTALL) + list='$(html_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(htmldir)/$$p; \ + done +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = html + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu html/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-htmlDATA +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-htmlDATA +uninstall: uninstall-am +all-am: Makefile $(DATA) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(htmldir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: uninstall-htmlDATA install-htmlDATA tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/html/cstim.html b/html/cstim.html new file mode 100644 index 0000000..e69de29 diff --git a/html/ctsim.html b/html/ctsim.html new file mode 100644 index 0000000..e013614 --- /dev/null +++ b/html/ctsim.html @@ -0,0 +1,77 @@ + + +Perform CT Simulation + + +

Perform CT Simulation

+
+ +
+

Select Image and Size

+Phantom Name:
+G.T. Herman
+Rowland
+Bordered Rowland
+Unit Pulse
+

+Nx:
+Ny:
+

+Number of Samples
per pixel:
+

+Display Window:
+Minium:
+Maximum:
+

+MPI Supercomputing:
+Yes (Multiple CPUs)
+No (Single CPU)
+

+

Simulate X-Ray acquistion

+Number of detectors:

+Number of Rotations:

+Number of Rays
(samples) per detector:

+Rotation Angle
as a multiple of PI:
+

+

Image Reconstruction

+Interpolation:
+Linear
+Nearest Neighbor
+B-Spline
+

+Filter for Backprojection:
+Abs*Bandlimit
+Abs*Cosine
+Abs*Hamming
+Shepp-Logan
+Bandlimit
+Hamming
+Cosine
+Sinc
+Triangle

+Hamming alpha factor (0.0-1.0):

+Backprojection Method:
+Trig
+Trig Table
+Difference
+Difference Optimized
+Difference Optimized (integer math)
+

+

+ +

+ + + + + + + + + + + + + + + diff --git a/html/ctsim.html.in b/html/ctsim.html.in new file mode 100644 index 0000000..17c3828 --- /dev/null +++ b/html/ctsim.html.in @@ -0,0 +1,77 @@ + + +Perform CT Simulation + + +

Perform CT Simulation

+
+ +
+

Select Image and Size

+Phantom Name:
+G.T. Herman
+Rowland
+Bordered Rowland
+Unit Pulse
+

+Nx:
+Ny:
+

+Number of Samples
per pixel:
+

+Display Window:
+Minium:
+Maximum:
+

+MPI Supercomputing:
+Yes (Multiple CPUs)
+No (Single CPU)
+

+

Simulate X-Ray acquistion

+Number of detectors:

+Number of Rotations:

+Number of Rays
(samples) per detector:

+Rotation Angle
as a multiple of PI:
+

+

Image Reconstruction

+Interpolation:
+Linear
+Nearest Neighbor
+B-Spline
+

+Filter for Backprojection:
+Abs*Bandlimit
+Abs*Cosine
+Abs*Hamming
+Shepp-Logan
+Bandlimit
+Hamming
+Cosine
+Sinc
+Triangle

+Hamming alpha factor (0.0-1.0):

+Backprojection Method:
+Trig
+Trig Table
+Difference
+Difference Optimized
+Difference Optimized (integer math)
+

+

+ +

+ + + + + + + + + + + + + + + diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..cc27ee4 --- /dev/null +++ b/include/Makefile @@ -0,0 +1,224 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +noinst_HEADERS = ascii.h cio.h ct.h ezplot.h getargs.h ir.h keyboard.h kmath.h kstddef.h pol.h sdf.h sgp.h +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = include + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu include/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-tags distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags mostlyclean-tags distclean-tags clean-tags \ +maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..60b9d32 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +noinst_HEADERS=ascii.h cio.h ct.h ezplot.h getargs.h ir.h keyboard.h kmath.h kstddef.h pol.h sdf.h sgp.h diff --git a/include/Makefile.in b/include/Makefile.in new file mode 100644 index 0000000..b96f840 --- /dev/null +++ b/include/Makefile.in @@ -0,0 +1,224 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +noinst_HEADERS = ascii.h cio.h ct.h ezplot.h getargs.h ir.h keyboard.h kmath.h kstddef.h pol.h sdf.h sgp.h +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = include + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu include/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-tags distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags mostlyclean-tags distclean-tags clean-tags \ +maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/include/ascii.h b/include/ascii.h new file mode 100644 index 0000000..44c6b55 --- /dev/null +++ b/include/ascii.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * + * FILE IDENTIFICATION + * + * File Name: ASCII.H + * Author: Kevin Rosenberg + * Purpose: Header file with definitions for ASCII characrers + * Date Started: Jan 84 + * + * DESCRIPTION + * Header file contains values for ASCII characters + * + * MODIFICATION LOG + * + *****************************************************************************/ + +#ifndef ASCII_H +#define ASCII_H + +#define BACKSPACE 8 +#define LF 0x0A +#define CR 0x0D +#define BELL 0x07 + +#define SQUOTE '\'' +#define DQUOTE '\"' +#define BSLASH '\\' +#define BACKSLASH '\\' +#define SHARP '#' +#define SLASH '/' +#define ASTERICK '*' +#define COLON ':' +#define LBRACE '{' +#define RBRACE '}' +#define LPAREN '(' +#define RPAREN ')' +#define LBRACK '[' +#define RBRACK ']' +#define LANBRACK '<' +#define RANBRACK '>' +#define SEMICOL ';' +#define UNDERLIN '_' +#define COMMA ',' +#define CARET '^' +#define TILDE '~' +#define ATSIGN '@' +#define AMPERSAND '&' +#define EXCLAM '!' +#define DOLLAR '$' +#define PERCENT '%' +#define PLUS '+' +#define HYPHEN '-' +#define EQUALS '=' +#define QUESTION '?' +#define PERIOD '.' +#define VERTBAR '|' + +#endif /* #ifndef ASCII_H */ diff --git a/include/cio.h b/include/cio.h new file mode 100644 index 0000000..0bfd15d --- /dev/null +++ b/include/cio.h @@ -0,0 +1,194 @@ +#ifndef __CIO_H +#define __CIO_H + +struct crtv_st { + int init; /* True if initialized */ + int bios_mode; /* Current BIOS crt mode */ + int text_attr; /* Current text attribute */ + int act_page; /* Active page */ + int tcols, trows; /* Maximum text coords */ + int xmax, ymax; /* Maximum x, y for both text & graphic modes */ + int cx, cy; /* Current x, y position */ +}; + +#ifndef DEFINE_CRTV + extern struct crtv_st crtv; +#endif + +/*----------------------------------------------------------------------*/ + +#define CRT_ROWS 25 +#define CRT_COLS 80 + +/* crt modes */ + +#define GM_TEXT40 1 /* color */ +#define GM_TEXT80 3 /* color */ +#define GM_320x200 4 /* color */ +#define GM_640x200 6 +#define GM_MONOTEXT 7 +#define GM_E320x200 13 +#define GM_E640x200 14 +#define GM_MONOGRF 15 +#define GM_ENHANCED 16 + +#define GM_640x480x16 0x12 +#define GM_640x480x256 0x2E +#define GM_1024x768x16 0x37 +#define GM_1024x768x256 0x38 + + + +#define GM_TEXT -1 +#define GM_HIGHRES -2 +#define GM_MEDRES -3 + +#define CRT_NONE -1 +#define CRT_MONO 0 +#define CRT_COLOR 1 +#define CRT_ENHANCED 2 + +/*----------------------------------------------------------------------*/ + +#define ATTR_NORMAL 7 +#define ATTR_REVERSE 14 +#define ATTR_HIGHLIGHT 15 + +#define C_BLACK 0 /* color codes */ +#define C_BLUE 1 +#define C_GREEN 2 +#define C_CYAN 3 +#define C_RED 4 +#define C_MAGENTA 5 +#define C_BROWN 6 +#define C_WHITE 7 +#define C_GREY 8 +#define C_LTBLUE 9 +#define C_LTGREEN 10 +#define C_LTCYAN 11 +#define C_LTRED 12 +#define C_LTMAGENTA 13 +#define C_YELLOW 14 +#define C_LTWHITE 15 + +/*----------------------------------------------------------------------*/ + +/* screen character codes */ + +#define SC_BKSP 8 +#define SC_TAB 9 +#define SC_BLANK ' ' + +#define SC_TOP_LEFT 218 +#define SC_TOP_RIGHT 191 +#define SC_BOTT_LEFT 192 +#define SC_BOTT_RIGHT 217 +#define SC_HORIZ 196 +#define SC_VERTICAL 179 + + +#define WAITKEY() {cio_kb_clr(); while (cio_kb_read() == 0);} + +/* biosf.c */ +void b_setcpos(int col, int row, int page); +void crt_wrt_cca(int c, int attr, int count, int page); +void crt_wrt_ca(int c, int attr, int page); +void crt_wrt_stra(const char *str, int count, int attr, int row, int col, int page); +/* c_restor.c */ +void crt_restore(const char *fname); +/* c_save.c */ +int crt_save(const char *fname); +/* center.c */ +int crt_center_line(const char *str); +/* clreol.c */ +void crt_clreol(void); +/* clrline.c */ +void crt_clrline(unsigned int line); +/* clrscrn.c */ +void crt_clrscrn(void); +/* cpos.c */ +void crt_tab(unsigned int n); +void crt_save_cpos(void); +void crt_restore_cpos(void); +/* cprintf.c */ +void cio_printf(const char *cs, ...); +void cio_aprintf(const int attr, const char *cs, ...); +/* cputs.c */ +void cputs(const char *s); +/* crt_data.c */ +/* ctype.c */ +void crt_set_ctype(int start, int end); +void crt_cursor_off(void); +void crt_cursor_on(void); +/* dispcard.c */ +int crt_disp_card(void); +/* fill_eol.c */ +void crt_fill_eol(int c, int attr); +/* frame.c */ +int crt_frame(int ulcol, int ulrow, int lrcol, int lrrow, int attr, int nlines); +/* get_ca.c */ +void crt_get_ca(int *c, int *attr); +/* getmon.c */ +int crt_get_mon(void); +void crt_set_mon(int mon); +/* getstate.c */ +void crt_get_state(void); +/* mode.c */ +void crt_set_mode(int mode, int cls); +int crt_get_mode(void); +int crt_bios_code(int mode); +/* put_ca.c */ +void crt_set_text_clr(int fclr, int bclr); +int crt_get_texta(void); +void crt_set_texta(int a); +int crt_blank_attr(void); +void crt_put_ca(int c, int attr); +void crt_put_c(int c); +void crt_put_cc(int c, int count); +void crt_put_cca(int c, int attr, int count); +void crt_put_str(const char *str); +void crt_put_stra(const char *str, int attr); +void crt_inc_col(int count); +void crt_dec_col(int count); +void crt_dec_row(int count); +/* scrollup.c */ +void crt_scrollup(int xmin, int ymin, int xmax, int ymax, int nline, int attr); +/* setcpos.c */ +void crt_set_cpos(int col, int row); +void crt_get_cpos(int *col, int *row); +/* setpage.c */ +void crt_set_page(int page); +/* setpal.c */ +void crt_set_palette(int id, int color); +void crt_set_color_table(char *color_table); +void crt_set_border(int bcolor); +int crt_calc_color(double nr, double ng, double nb); +int crt_icalc_color(int r, int g, int b); + +/* beep.c */ +void cio_beep(void); +/* kb_chk.c */ +int cio_kb_chk(void); +/* kb_clr.c */ +void cio_kb_clr(void); +/* kb_getc.c */ +unsigned int cio_kb_getc(void); +void cio_kb_ungetc(unsigned int c); +/* kb_gets.c */ +char *cio_kb_gets(char *str, int maxlen); +/* kb_read.c */ +unsigned int cio_kb_read(void); +void cio_kb_unread(unsigned int c); +/* kb_waitc.c */ +unsigned int cio_kb_waitc(const char *astr, const char *estr, int beep_on_error); +/* speaker.c */ +void cio_spkr_freq(double freq); +void cio_spkr_divisor(unsigned int div); +void cio_spkr_on(void); +void cio_spkr_off(void); +/* tone.c */ +void cio_tone(double freq, double length); +/* check_kb */ +int cio_check_kb_escape(void); + +#endif diff --git a/include/ct.h b/include/ct.h new file mode 100644 index 0000000..0ad813e --- /dev/null +++ b/include/ct.h @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------*/ +/* HEADER FILE FOR TOMOGRAPY SYSTEM */ +/*---------------------------------------------------------------------*/ + +#ifndef CT_H +#define CT_H + +#ifdef HAVE_CONFIG_H +#include +#endif +#ifdef HAVE_PNG +#include "png.h" +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STDDEF_H +#include +#endif +#include +#ifdef HAVE_STDARG_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_CTYPE_H +#include +#endif +#ifdef HAVE_MATH_H +#include +#endif +#ifdef HAVE_SYS_FCNTL_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#if defined(HAVE_GETOPT_H) || defined(HAVE_GETOPT_LONG) +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SETJMP_H +#include +#endif + +#ifdef MPI_CT +#include "mpi.h" +#endif + +#include "kstddef.h" +#include "kmath.h" +#include "sgp.h" +#include "sdf.h" +#include "ir.h" +#include "getargs.h" +#include "keyboard.h" +#include "cio.h" +#include "ezplot.h" + +#ifndef basename +extern char *basename (__const char *__filename); +#endif + + +#endif + diff --git a/include/ezplot.h b/include/ezplot.h new file mode 100644 index 0000000..c5838c0 --- /dev/null +++ b/include/ezplot.h @@ -0,0 +1,311 @@ +/*----------------------------------------------------------------------*/ +/* EZPLOT */ +/* */ +/*----------------------------------------------------------------------*/ + +#ifndef __H_EZPLOT +#define __H_EZPLOT + +#include +#include +#include "kstddef.h" +#include +#include "sgp.h" +#include +#include "kmath.h" +#include "cio.h" + +#define MAXLABEL 40 /* maximum length of axis label */ +#define MAXTITLE 40 /* maximum length of a title */ +#define MAXLEGEND 20 /* maximum length of a legend */ +#define MAXCURVES 10 /* maximum number of curves that can be plotted */ +#define MAXPTS 200 /* max number of points that can be read with + DATA command in INTERACTIVE mode */ + +struct ezp_curve_st { + int numpts; + double *x, *y; + int linestyle; + int symbol; + int symfreq; + int color; + char legend[MAXLEGEND+1]; +}; + +#define XBUF_DEF 600 +#define YBUF_DEF XBUF_DEF * (72. / 120.) * 0.75 +#define PRTMODE_DEF 1 + +/*----------------------------------------------------------------------*/ +/* Codes from LEX */ +/*----------------------------------------------------------------------*/ + +#define S_DATA 2 +#define S_HELP 3 +#define S_EXIT 4 + +#define S_SOLID -10 +#define S_DASH -11 +#define S_NOLINE -12 +#define S_BLACK -13 +#define S_RED -14 +#define S_BLUE -15 +#define S_GREEN -16 +#define S_PEN -17 +#define S_SYMBOL -18 +#define S_EVERY -19 +#define S_NONE -20 +#define S_CURVES -21 +#define S_UNKNOWN -22 +#define S_END -23 +#define S_LEGEND -24 +#define S_XLEGEND -25 +#define S_YLEGEND -26 +#define S_XLIN -27 +#define S_YLIN -28 +#define S_XLOG -29 +#define S_YLOG -30 +#define S_XLABEL -31 +#define S_YLABEL -32 +#define S_XLENGTH -33 +#define S_YLENGTH -34 +#define S_XTICKS -35 +#define S_YTICKS -36 +#define S_ABOVE -37 +#define S_LABEL -38 +#define S_BELOW -39 +#define S_NOLABEL -40 +#define S_RIGHT -41 +#define S_LEFT -42 +#define S_XAUTOSCALE -43 +#define S_YAUTOSCALE -44 +#define S_XMIN -45 +#define S_YMIN -46 +#define S_XMAX -47 +#define S_YMAX -48 +#define S_LXFRAC -49 +#define S_LYFRAC -50 +#define S_XCROSS -51 +#define S_YCROSS -52 +#define S_NOXAXIS -53 +#define S_NOYAXIS -54 +#define S_XPORIGIN -55 +#define S_YPORIGIN -56 +#define S_TITLE -57 +#define S_XTITLE -58 +#define S_YTITLE -59 +#define S_REPLOT -60 +#define S_CLEAR -61 +#define S_STORE -62 +#define S_RESTORE -63 +#define S_USTART -64 +#define S_UFINISH -65 +#define S_AMARK -66 +#define S_NO -67 +#define S_INTERACTIVE -68 +#define S_UNITS -69 +#define S_INCHES -70 +#define S_USER -71 + +#define S_BOX -100 +#define S_NOBOX -101 +#define S_GRID -102 +#define S_NOGRID -103 +#define S_MAJOR -104 +#define S_MINOR -105 +#define S_COLOR -106 +#define S_LEGENDBOX -107 +#define S_TAG -108 + +#define S_EPSON -110 +#define S_CRT -111 + +#define S_TEXTSIZE -120 +#define S_XBUF -121 +#define S_YBUF -122 +#define S_PRTMODE -123 + +/*----------------------------------------------------------------------*/ +/* GLOBAL VARIABLES */ +/*----------------------------------------------------------------------*/ + +/* axis definitions */ +#define LINEAR 1 /* linear axis */ +#define LOG 2 /* logrithmic axis */ +#define NOAXIS 3 /* don't plot axis */ + +/* tick definitions */ +#define ABOVE 1 +#define BELOW 2 +#define RIGHT 4 +#define LEFT 8 + +/* line types */ +#define NOLINE 0 +#define SOLID 1 +#define DASH 2 +#define DASH1 10 +#define DASH2 11 +#define DASH3 12 +#define DASH4 13 + +/* symbol definitions */ +#define SB_CROSS 1 +#define SB_PLUS 2 +#define SB_BOX 3 +#define SB_CIRCLE 4 +#define SB_ERRORBAR 5 +#define MAXSYMBOL 5 + +#define INSIDE 1 /* values of o_legendbox */ +#define OUTSIDE 2 +#define NOLEGEND 3 + +/*----------------------------------------------------------------------------- + * GLOBAL VARIABLES + * + * Naming Convention: + * i_ Internal variable + * Not user changable + * o_ Option variable + * Normal variable that is user modifiable + * These variables must always have a valid value + * d_ Device variable + * Variables controlling devices + * clr_ Color variable + * Holds a color value + * c_ Character string variable + * Contains a character string + * v_ Value variable + * User modifiable variable associated with the set variable (s_) + * These variables do not always have a valid value + * These variables change assumption EZPLOT makes about the plot + * s_ Set variable. + * TRUE if associated value variable (v_) has been set by the user + *---------------------------------------------------------------------------*/ + + +struct ezplot_var { + +/*-------------*/ +/* USER CURVES */ +/*-------------*/ + +struct ezp_curve_st curve[MAXCURVES]; + +/*--------------------*/ +/* INTERNAL VARIABLES */ +/*--------------------*/ + +bool i_plotimmediate; /* indicates that a call to EZPLOT is a signal + to print all received arrays. EZSET uses + this variable to force EZPLOT to replot + its stored curves */ +int i_numcurves; /* number of curves received by EZPLOT */ + +/*------------------*/ +/* DEVICE VARIABLES */ +/*------------------*/ + +bool d_usecrt; /* TRUE if want to use CRT as output device */ +bool d_useprt; /* TRUE if wamt to use printer as output device */ + +int d_crtmode; /* Controls which crt mode to use for plot */ +int d_prtmode; /* Controls mode of printer output */ + +int d_xprtbuf, d_yprtbuf; /* Size of printer buffer in pixels */ + +/*-----------------*/ +/* COLOR VARIABLES */ +/*-----------------*/ + +int clr_axis; /* color of all axis lines */ +int clr_title; /* color of main title */ +int clr_label; /* color of axis labels */ +int clr_legend; /* color of legend box */ +int clr_grid; /* color of grid lines */ +int clr_number; /* color of axis number labels */ + +/*------------------*/ +/* OPTION VARIABLES */ +/*------------------*/ + +int o_reqcurves; /* # of curves specified in CURVES command */ + /* default value is 1, so that a call to EZPLOT + will force a plot */ +bool o_unknowncurves; /* TRUE when the user specifies that the + number of curves is unknown */ + +bool o_ustart, o_ufinish; /* TRUE if user initiates or terminate sgp */ + +double o_xporigin, o_yporigin; /* origin of plot frame in NDC */ +double o_xlength, o_ylength; /* length of plot frame in NDC */ + +char c_xlabel[MAXLABEL+1]; /* label for x axis */ +char c_ylabel[MAXLABEL+1]; /* label for y axis */ +char c_title[MAXTITLE+1]; /* title to print above graph */ +char c_legend[MAXLEGEND+1]; /* current legend specified */ + +int o_linestyle, o_color; /* style to use for curves all subsequent */ + /* curves to EZPLOT */ +bool o_xaxis, o_yaxis; /* Specifies where axis & labels are drawn */ +bool o_grid; /* Flag to draw a grid at major ticks */ +bool o_box; /* Flag to draw a box around the graph */ + +int o_xticks, o_yticks; /* direction to draw tick marks */ +bool o_xtlabel, o_ytlabel; /* TRUE if label tick marks */ + +int o_xmajortick, o_ymajortick; /* number of major ticks to draw */ +int o_xminortick, o_yminortick; /* number of minor ticks between major ticks */ + +int o_symbol; /* Symbol type, (0 = no symbol) */ +int o_symfreq; /* frequency to draw symbols at curve points */ + +int o_legendbox; /* controls whether legend is inside */ + /* or outside of the axis extents */ +int o_tag; /* controls whether to draw tag at end of axes */ + +/*-----------------------*/ +/* VALUE & SET variables */ +/*-----------------------*/ + +double v_xmin, v_xmax, v_ymin, v_ymax; /* user supplied axis endpoints */ +bool s_xmin, s_xmax, s_ymin, s_ymax; /* TRUE is endpoint has been set */ + +double v_xtitle, v_ytitle; /* NDC position to plot title */ +bool s_xtitle, s_ytitle; /* TRUE if set position for title */ +double v_xcross, v_ycross; /* position that axes cross */ +bool s_xcross, s_ycross; /* TRUE if set axes cross position */ + +double v_xlegend, v_ylegend; /* upper-left position of legend box in NDC */ +bool s_xlegend, s_ylegend; /* TRUE if set position of legend box */ + +int v_lxfrac, v_lyfrac; /* number of digits to right of decimal place */ +bool s_lxfrac, s_lyfrac; /* TRUE if set number of fractional digits */ + +double v_textsize; /* size of text in NDC */ +bool s_textsize; /* TRUE if user set size of text */ + +}; /* end of EZPLOT VARIABLES */ + + + +extern struct ezplot_var ez; +extern bool ezplot_firstcall; /* set to false on first call to EZSET or EZPLOT */ + + +/* axis.c */ +int axis_scale(double min, double max, int nint, double *minp, double *maxp, int *nintp); +/* ezplot.c */ +int ezplot(double x[], double y[], int num); +void ezinit(void); +void ezfree(void); +void ezclear(void); +/* ezplot1d.c */ +void ezplot_1d(double *y, int n); +/* ezset.c */ +int ezset(char *command); +/* makefmt.c */ +void make_numfmt(char *fmtstr, int *fldwid, int *nfrac, double min, double max, int nint); + +#endif diff --git a/include/getargs.h b/include/getargs.h new file mode 100644 index 0000000..dd5d8a9 --- /dev/null +++ b/include/getargs.h @@ -0,0 +1,25 @@ +/* getargs.h Typedefs and defines for getargs + */ + + +#ifndef GETARGS_H +#define GETARGS_H + +#define INTEGER 0 +#define BOOLEAN 1 +#define CHARACTER 2 +#define STRING 3 +#define PROC 4 + + +typedef struct +{ + unsigned arg : 7 ; /* Command line switch */ + unsigned type : 4 ; /* variable type */ + int *variable ; /* pointer to variable */ + char *errmsg ; /* pointer to error message */ +} + ARG; + +#endif /* GETARGS_H */ + diff --git a/include/ir.h b/include/ir.h new file mode 100644 index 0000000..407b02b --- /dev/null +++ b/include/ir.h @@ -0,0 +1,465 @@ +/* FILE IDENTIFICATION + * + * Name: ir.h Header File for Image Reconstruction System + * Programmer: Kevin Rosenberg + * Date Started: 7-1-84 + * Last Change: 1-20-85 + */ + +#ifndef IR_H +#define IR_H + +#ifdef MPI_CT +#define MPI_MAX_PROCESS 128 +struct mpi_ct_st +{ + int my_rank; + int nproc; + int base_local_work_units; + int remainder_work_units; + int local_work_units[MPI_MAX_PROCESS]; + int start_work_unit[MPI_MAX_PROCESS]; + MPI_Comm comm; +}; + +extern struct mpi_ct_st mpi_ct; +void mpi_ct_calc_work_units(const unsigned int global_work_units); +#endif + + +struct histo_st { + int *b; /* Histogram array (# of elements in each bin) */ + int nbin; /* Number of histogram bins */ + double xmin, xmax, xinc; /* Limits of histogram boundaries */ +}; + +typedef struct histo_st HISTOGRAM; + +/*---------------------------------------------------------------------------*/ + +#define POINTS_PER_CIRCLE 36 + +#define MAXREMARK 99 +#define LENREMARK (MAXREMARK+1) +#define IMAGE_VAL FMTX_2D /* use 2d floating point matrix */ +#define IMAGE_ELEM_TYPE DT_FLOAT /* use floats for images */ +typedef float IMAGE_ELEM_VAL; /* use floats for image storing */ + +struct image_st { + IMAGE_VAL v; /* values of voxels in matrix form */ + SDF_2D *dfp_2d; /* Pointer to disk image file */ + int nx, ny; /* size of voxel matrix */ + double xmin, xmax, ymin, ymax; /* extent of voxel matrix in pic coord */ + char remark[LENREMARK]; /* description of voxel data */ + float calctime; /* time to calculate voxels in seconds */ +}; + +struct object_st { + int type; /* object type (box, ellipse, etc) */ + double atten; /* X-ray attenuation coefficient */ + double cx,cy; /* center of object */ + double u,v; /* size of object */ + double rot; /* object rotation angle (in radians) */ + double *x, *y; /* ptr to array of points in obj world coord */ + int pts; /* number of points in outline arrays */ + double xmin, xmax, ymin, ymax; /* object limits */ + double radius; /* " */ + struct { /* transform matrices */ + GRFMTX_2D p_to_o; /* map from pic to standard obj coords */ + GRFMTX_2D o_to_p; /* map from std object coords to pic coords */ + } xform; + struct object_st *next; /* pointer to next object in picture */ +}; + +typedef struct object_st OBJECT; + +struct pic_st { /* Picture structure */ + OBJECT *objlist; /* object list */ + int type; + int numobj; /* number of objects in picture */ + double xmin, xmax, ymin, ymax; /* extent of objects in object coordinates */ + double radius; /* " " */ +}; + +typedef struct image_st IMAGE; +typedef struct pic_st PICTURE; + +#define P_OBJECTS 0 /* Picture made of objects */ +#define P_UNIT_PULSE 1 /* Special picture, not made of objects */ +#define P_FILTER 9 /* defined only by a type */ + +/*----------------------------------------------------------------------*/ +/* RAYSUM SYMBOLS */ +/*----------------------------------------------------------------------*/ + +/* Ray sums are collected along an array of ndet detectors. The data + * for these detectors is stored in the structure DETECTARRAY + */ + +#define DETECT_TYPE float + +struct detarray_st { + DETECT_TYPE *detval; /* Pointer to array of values recorded by detector */ + int ndet; /* Number of detectors in array */ + double view_angle; /* View angle in radians */ +}; + +struct detect_st { + int ndet; /* Number of detectors in array */ + int nview; /* Number of rotated views */ + int nsample; /* Number of rays per detector */ + double detlen; /* Total length of detector array */ + double rotlen; /* Rotation angle length in radians (norm 2PI) */ + double det_inc; /* Increment between centers of detectors */ + double rot_inc; /* Increment in rotation angle between views */ + double radius; /* Radius of rotation. Distance from */ + /* center of pic to center of det */ + double piclen; /* Maximum Length of picture or area of interest */ + struct { + double xd1,yd1,xd2,yd2; /* Coordinates of detector endpoints */ + double xs1,ys1,xs2,ys2; /* Coordinates of source endpoints */ + double angle; /* Starting angle */ + } init; +}; + +struct raysum_st { + int fd; + int file_mode; + int header_size; + struct detarray_st **view; /* Pointer to array of detarray_st pointers */ + + char remark[LENREMARK]; /* description of raysum data */ + double calctime; /* time required to calculate raysums */ + + int ndet; /* number of detectors in array */ + int nview; /* number of rotated views */ + double rot_start; /* starting view rotation */ + double rot_inc; /* angle between rotations */ + double det_start; /* distance of beginning detector to center */ + /* of picture */ + double det_inc; /* increment between detectors */ + double piclen; /* Length of picture edge (pic is square) */ +}; + +typedef struct detarray_st DETARRAY; +typedef struct detect_st DETECTOR; +typedef struct raysum_st RAYSUM; + +/*----------------------------------------------------------------------*/ +/* USER SYMBOLS */ +/*----------------------------------------------------------------------*/ + +/* codes for object types, passed to add_obj() */ + +#define O_RECTANGLE 1 +#define O_TRIANGLE 2 +#define O_ELLIPSE 3 +#define O_SECTOR 4 +#define O_SEGMENT 5 + +/* Codes for Coordinate Types */ +/* Defines coords for inside_obj() */ + +#define OBJ_COORD -1 /* Normalized Object Coordinates */ +#define PIC_COORD -2 /* User's Picture Coordinates */ + +/* Codes for Filter types */ + +#define W_BANDLIMIT 1 /* filter types for genfilter() */ +#define W_SINC 2 +#define W_G_HAMMING 3 +#define W_COSINE 4 +#define W_TRIANGLE 5 + +#define W_A_BANDLIMIT 11 /* filters times abs() of function */ +#define W_A_SINC 12 +#define W_AG_HAMMING 13 +#define W_A_COSINE 14 + +#define W_SHEPP 21 + +/* function domains */ + +#define O_FREQ_STR "freq" +#define O_SPATIAL_STR "spatial" + +#define D_FREQ 1 /* Domain names */ +#define D_SPATIAL 2 + +/* function symmetry */ + +#define FUNC_EVEN 1 /* function types, f[-n] = f[n] */ +#define FUNC_ODD 2 /* f[-n] = -f[n] */ +#define FUNC_BOTH 3 /* function has both odd & even components */ + +/* interpolation methods */ + +#define I_NEAREST 1 /* Interpolation methods */ +#define I_LINEAR 2 /* Linear interpolation */ +#define I_BSPLINE 3 +#define I_1BSPLINE 3 /* 1st order B-Spline */ +#define I_2BSPLINE 4 +#define I_3BSPLINE 5 + +/* Constants for sizing picture */ + +#define PERCENT_PIC_SIZE_INCR 0.0 /* Fractional increase in picture */ + /* limits compared to object size */ +#define N_EXTRA_DETECTORS 4 /* Number of extra detectors */ + /* widths when calculating detlen */ + +#define DET_PARALLEL 1 +#define DET_FAN 2 + +#define O_TRACE_NONE_STR "none" +#define O_TRACE_TEXT_STR "text" +#define O_TRACE_PIC_STR "pic" +#define O_TRACE_RAYS_STR "rays" +#define O_TRACE_PLOT_STR "plot" +#define O_TRACE_CLIPPING_STR "clipping" + + +#define TRACE_NONE 0 /* No tracing */ +#define TRACE_TEXT 1 /* Minimal status */ +#define TRACE_PIC 2 /* Show picture */ +#define TRACE_RAYS 3 /* Show all rays */ +#define TRACE_PLOT 4 /* Plot raysums */ +#define TRACE_CLIPPING 5 /* Plot clipping */ + +#define O_PIC_HERMAN 1 /* Herman head phantom */ +#define O_PIC_ROWLAND 2 /* Rowland head phantom */ +#define O_PIC_BROWLAND 3 /* Bordered Rowland head phantom */ +#define O_PIC_UNITPULSE 4 /* Unit pulse phantom */ + +#define O_PIC_HERMAN_STR "herman" +#define O_PIC_ROWLAND_STR "rowland" +#define O_PIC_BROWLAND_STR "browland" +#define O_PIC_UNITPULSE_STR "unitpulse" + +#define O_INTERP_NEAREST_STR "nearest" +#define O_INTERP_LINEAR_STR "linear" +#define O_INTERP_BSPLINE_STR "bspline" + +#define O_FILTER_ABS_BANDLIMIT_STR "abs_bandlimit" +#define O_FILTER_ABS_SINC_STR "abs_sinc" +#define O_FILTER_ABS_COS_STR "abs_cos" +#define O_FILTER_ABS_HAMMING_STR "abs_hamming" +#define O_FILTER_SHEPP_STR "shepp" +#define O_FILTER_BANDLIMIT_STR "bandlimit" +#define O_FILTER_SINC_STR "sinc" +#define O_FILTER_COS_STR "cos" +#define O_FILTER_HAMMING_STR "hamming" +#define O_FILTER_TRIANGLE_STR "triangle" + +#define O_BPROJ_TRIG 1 +#define O_BPROJ_TABLE 2 +#define O_BPROJ_DIFF 3 +#define O_BPROJ_DIFF2 4 +#define O_BPROJ_IDIFF2 5 + +#define O_BPROJ_TRIG_STR "trig" +#define O_BPROJ_TABLE_STR "table" +#define O_BPROJ_DIFF_STR "diff" +#define O_BPROJ_DIFF2_STR "diff2" +#define O_BPROJ_IDIFF2_STR "idiff2" + +#define RS_TRACE_ROW_TITLE 1 +#define RS_TRACE_ROW_TITLE2 2 +#define RS_TRACE_ROW_PHANT_ID 4 +#define RS_TRACE_ROW_CHROMATIC 7 +#define RS_TRACE_ROW_SCATTER 8 +#define RS_TRACE_ROW_PHOT_STAT 9 +#define RS_TRACE_ROW_NDET 12 +#define RS_TRACE_ROW_NVIEW 13 +#define RS_TRACE_ROW_SAMPLES 14 +#define RS_TRACE_ROW_CURR_VIEW 17 +#define RS_TRACE_ROW_ATTEN 18 + + +/*----------------------------------------------------------------------*/ +/* GRAY SCALE STRUCTURES */ +/*----------------------------------------------------------------------*/ + +#define GS_MAX_CELL_SIZE 4 + +typedef int GS_BITMASK[4][4]; + +struct greyscale_st { + int dev; /* Device to output to */ + int (*dotfunc)(int x, int y, int color); /* Pointer to dot function for device */ + int cur_x, cur_y; /* Current cell location */ + int nxcell, nycell; /* size of cell in pixels */ + int xmin, ymin; /* starting position of grey scale */ + int num_color; /* Number of primary colors available */ + int num_intens; /* Number of intensities available */ + int max_level; /* gs levels range from 0 to max_level */ + char *fg_color_tbl; /* Hold foreground color for each level */ + char *bg_color_tbl; /* Holds background color */ + char *level_sub_tbl; /* Holds value to subtract for level */ + /* before accessing bit mask */ + GS_BITMASK *bm; /* Holds grey-scale bit mask */ + struct greyscale_st *next_dev; /* Pointer to next open device */ + /* == NULL when no more devices */ +}; + +typedef struct greyscale_st GREYSCALE; + + +/* From reconstr.c */ +IMAGE *image_reconst (IMAGE *im, RAYSUM *rs, int filt_type, double filt_param, int interp_type, int interp_param, const int backproj_type, int ir_trace); + +/* From bproj.c */ +void backproj_init (const RAYSUM *rs, IMAGE *im, const int bproj_method); +int backproj_calc (const RAYSUM *rs, IMAGE *im, const double *t, const double view_angle, + const int interp_type, const int bproj_method); +void backproj_term (const RAYSUM *rs, IMAGE *im, const int bproj_method); + +void backproj_init_trig (const RAYSUM *rs, IMAGE *im); +int backproj_calc_trig (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_trig (const RAYSUM *rs, IMAGE *im); +void backproj_init_table (const RAYSUM *rs, IMAGE *im); +int backproj_calc_table (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_table (const RAYSUM *rs, IMAGE *im); +void backproj_init_d (const RAYSUM *rs, IMAGE *im); +int backproj_calc_d (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_d (const RAYSUM *rs, IMAGE *im); +void backproj_init_d2 (const RAYSUM *rs, IMAGE *im); +int backproj_calc_d2 (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_d2 (const RAYSUM *rs, IMAGE *im); +void backproj_init_id (const RAYSUM *rs, IMAGE *im); +int backproj_calc_id (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_id (const RAYSUM *rs, IMAGE *im); +void backproj_init_id2 (const RAYSUM *rs, IMAGE *im); +int backproj_calc_id2 (const RAYSUM *rs, IMAGE *im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_id2 (const RAYSUM *rs, IMAGE *im); + +void usage (const char *program); +int main(const int argc, char * const argv[]); + + + +/* bspline.c */ +int bspline(int samples, int zoom_factor, int spline_order, double input[], double output[]); +/* clip.c */ +int inside_obj(const OBJECT *obj, double x, double y, const int coord_type); +int clipsegment(double *x1, double *y1, double *x2, double *y2, const double u, const double v); +int clipsector(double *x1, double *y1, double *x2, double *y2, const double u, const double v); +int clipcircle(double *x1, double *y1, double *x2, double *y2, const double cx, const double cy, const double radius, double t1, double t2); +int cliptriangle(double *x1, double *y1, double *x2, double *y2, const double u, const double v, const int clip_xaxis); +/* convolve.c */ +double convolve(const double f1[], const double f2[], const double dx, const int n, const int np, const int func_type); +double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np); +/* ctsub.c */ +OBJECT *alloc_obj(int n); +void dminmax(const double array[], const int pts, double *xmin, double *xmax); +void rotate2d(double x[], double y[], int pts, double angle); +void xlat2d(double x[], double y[], int pts, double xoffset, double yoffset); +void scale2d(double x[], double y[], int pts, double xfact, double yfact); +int circle_pts(double theta); +/* filt.c */ +const char *interp_name_of(int interp_type); +const char *filter_name_of(int filt_type); +int interp_select(void); +int filter_select(double *filt_param); +double d_filtfunc(int filt_type, double x, double bw, double param, int n); +double filter_freq(int filt_type, double u, double bw, double param); +double a_filtfunc(int filt_type, double x, double bw, double param); +double sinc(double x, double mult); +double abscos_int(double u, double w); +double *filter_generate(int filt_type, double bw, double xmin, double xmax, int n, double param, int domain, int numint); +void image_filter_init(IMAGE *im, int domain, double bw, int filt_type, double filt_param, int opt_trace); +/* im_draw.c */ +void image_show(IMAGE *im, int nxcell, int nycell, double densmin, double densmax, bool disp_scale); +int image_paint(int dev, IMAGE *im, int xmin, int ymin, int nxcell, int nycell, double densmin, double densmax, bool disp_scale); +int gs_image(GREYSCALE *gs, IMAGE *im, double densmin, double densmax, bool disp_scale); +void paint_cscale(GREYSCALE *gs, int nx, int ny); +GREYSCALE *gs_init(int dev, int xmin, int ymin, int nxcell, int nycell); +void gs_pixel(GREYSCALE *gs, int x, int y, int gs_level); +void gs_set_pos(GREYSCALE *gs, int x, int y); +void gs_set_at_addr(GREYSCALE *gs, int gs_level); +void gs_set_color_scale(void); +/* image.c */ +IMAGE *image_create(const char *fname, const int nx, const int ny); +int image_clear(IMAGE *im); +int image_save(IMAGE *im); +IMAGE *image_load(const char *fname); +/* ir_vars.c */ +/* options.c */ +int opt_set_trace(const char *optarg, const char *program); +const char *name_of_picture(const int picnum); +int opt_set_picture(const char *optarg, const char *program); +int opt_set_interpolation(const char *optarg, const char *program); +int opt_set_filter(const char *optarg, const char *program); +const char *name_of_filter(const int filter); +int opt_set_filter_domain(const char *optarg, const char *program); +const char *name_of_filter_domain(const int domain); +int opt_set_backproj(const char *optarg, const char *program); +const char *name_of_backproj(const int backproj); +/* pic.c */ +PICTURE *select_pic(void); +PICTURE *create_pic_from_file(const char *fname); +PICTURE *create_pic(const int picnum); +PICTURE *init_pic(void); +int add_objs_kb(PICTURE *pic); +int add_objs_file(PICTURE *pic, const char *fname); +void addobject(PICTURE *pic, const int type, const double cx, const double cy, + const double u, const double v, const double rot, const double atten); +int makeobjpts(OBJECT *obj); +void makeobjxform(OBJECT *obj); +void calc_arc(double x[], double y[], const int pts, const double xcent, const double ycent, + const double r, const double start, const double stop); +void calc_ellipse(double x[], double y[], const int pts, const double u, const double v); +void prt_pic(PICTURE *pic); +void show_pic(const PICTURE *pic); +void draw_pic(const PICTURE *pic); +/* pic2image.c */ +void pic_to_image(const PICTURE *pic, IMAGE *im, const int col_start, const int col_count, + const int nsample, const int trace); +/* ray.c */ +void rs_trace_showprm (const char *label, const char *fmt, int row, int color, ...); +DETECTOR *detect_create(const PICTURE *pic, int ndet, int nview, int nsample, const double rot_anglen); +void detect_free(DETECTOR *det); +int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PICTURE *pic, const int start_view, + const int trace, const int unit_pulse); +void rayview(const PICTURE *pic, DETARRAY *darray, const DETECTOR *det, + const double xd1, const double yd1, const double xd2, const double yd2, + const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse); +double calc_rsum(const PICTURE *pic, const double x1, const double y1, const double x2, const double y2); +double calc_objsum(const OBJECT *obj, const double x1, const double y1, const double x2, const double y2); +int clipobj(const OBJECT *obj, double *x1, double *y1, double *x2, double *y2); +/* rayio.c */ +RAYSUM *raysum_create(const char *fname, const int nview, const int ndet, const int in_memory); +RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det, const int in_memory); +RAYSUM *raysum_open(const char *filename); +void raysum_alloc_views(RAYSUM *rs); +void raysum_free(RAYSUM *rs); +int raysum_is_open(RAYSUM *rs); +int raysum_close(RAYSUM *rs); +int raysum_read_header(RAYSUM *rs); +int raysum_write_header(RAYSUM *rs); +int raysum_read(RAYSUM *rs); +int raysum_write(RAYSUM *rs); +DETARRAY *detarray_alloc(const int n); +void detarray_free(DETARRAY *darray); +int detarray_read(RAYSUM *rs, DETARRAY *darray, const int view_num); +int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num); +int raysum_print(const RAYSUM *rs); +/* phantom.c */ +void herm_head(PICTURE *pic); +void row_head(PICTURE *pic); +void row_bord_head(PICTURE *pic); +/* xform.c */ +void indent_mtx2(GRFMTX_2D m); +void xlat_mtx2(GRFMTX_2D m, const double x, const double y); +void scale_mtx2(GRFMTX_2D m, const double sx, const double sy); +void rot_mtx2(GRFMTX_2D m, const double theta); +void mult_mtx2(GRFMTX_2D m1, GRFMTX_2D m2, GRFMTX_2D result); +void xform_mtx2(GRFMTX_2D m, double *x, double *y); + +#endif diff --git a/include/keyboard.h b/include/keyboard.h new file mode 100644 index 0000000..8f867a9 --- /dev/null +++ b/include/keyboard.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * FILE IDENTIFICATION + * + * File Name: KEYBOARD.H + * Author: Kevin Rosenberg + * Purpose: Header file for IBM-PC keyboard definitions + * Date Started: Jan 85 + * + * DESCRIPTION + * + * MODIFICATION LOG + * + *****************************************************************************/ + +#ifndef KEYBOARD_H +#define KEYBOARD_H + +#define KEY_BKSP 8 +#define KEY_TAB 9 +#define KEY_RETURN 13 +#define KEY_ESCAPE 27 + +#define KEY_HOME 0x4700 +#define KEY_UP 0x4800 +#define KEY_PGUP 0x4900 +#define KEY_LEFT 0x4B00 +#define KEY_CENTER 0x4C00 /* center of numeric keypad = 5 */ +#define KEY_RIGHT 0x4D00 +#define KEY_END 0x4F00 +#define KEY_DOWN 0x5000 +#define KEY_PGDOWN 0x5100 + +#define KEY_F1 0x3B00 +#define KEY_F2 0x3C00 +#define KEY_F3 0x3D00 +#define KEY_F4 0x3E00 +#define KEY_F5 0x3F00 +#define KEY_F6 0x4000 +#define KEY_F7 0x4100 +#define KEY_F8 0x4200 +#define KEY_F9 0x4300 +#define KEY_F10 0x4400 + +#define KEY_SHIFTF1 0x5400 +#define KEY_SHIFTF2 0x5500 +#define KEY_SHIFTF3 0x5600 +#define KEY_SHIFTF4 0x5700 +#define KEY_SHIFTF5 0x5800 +#define KEY_SHIFTF6 0x5900 +#define KEY_SHIFTF7 0x5A00 +#define KEY_SHIFTF8 0x5B00 +#define KEY_SHIFTF9 0x5C00 +#define KEY_SHIFTF10 0x5D00 + +#define KEY_CTRLF1 0x5E00 +#define KEY_CTRLF2 0x5F00 +#define KEY_CTRLF3 0x6000 +#define KEY_CTRLF4 0x6100 +#define KEY_CTRLF5 0x6200 +#define KEY_CTRLF6 0x6300 +#define KEY_CTRLF7 0x6400 +#define KEY_CTRLF8 0x6500 +#define KEY_CTRLF9 0x6600 +#define KEY_CTRLF10 0x6700 + +#define KEY_ALTF1 0x6800 +#define KEY_ALTF2 0x6900 +#define KEY_ALTF3 0x6A00 +#define KEY_ALTF4 0x6B00 +#define KEY_ALTF5 0x6C00 +#define KEY_ALTF6 0x6D00 +#define KEY_ALTF7 0x6E00 +#define KEY_ALTF8 0x6F00 +#define KEY_ALTF9 0x7000 +#define KEY_ALTF10 0x7100 + + +#endif /* #ifndef KEYBOARD_H */ diff --git a/include/kmath.h b/include/kmath.h new file mode 100644 index 0000000..636339a --- /dev/null +++ b/include/kmath.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * + * FILE IDENTIFICATION + * + * File Name: NUMR.H + * Author: Kevin Rosenberg + * Purpose: Header file containing definitions for numerical app's + * Date Started: Nov 84 + * + * DESCRIPTION + * + * MODIFICATION LOG + * + *****************************************************************************/ + +#ifndef _H_kmath +#define _H_kmath + +#include +#include + +#define PI 3.14159265358979323846 +#define HALFPI 1.57079632679489661923 /* PI divided by 2 */ +#define QUARTPI 0.78539816339744830962 /* PI divided by 4 */ +#define I_PI 0.31830988618379067154 /* Inverse of PI */ +#define I_PID2 0.63661977236758134308 /* Inverse of PID2 */ + +#define TWOPI 6.28318530717958647692 +#define SQRT2 1.414213562373095049 + +#define F_EPSILON 1.0E-6 +#define D_EPSILON 1.0E-10 + +#define DEG_TO_RAD(x) (x*(PI/180.)) +#define RAD_TO_DEG(x) (x*(180./PI)) + + +#define ASSUMEDZERO 1E-10 + +/* codes for C data types */ + +#define DT_CHAR 1 +#define DT_INT 2 +#define DT_LONG 3 +#define DT_FLOAT 4 +#define DT_DOUBLE 5 +#define DT_STRING 6 + +typedef char *CMTX_1D; +typedef CMTX_1D *CMTX_2D; +typedef CMTX_2D *CMTX_3D; + +typedef int *IMTX_1D; +typedef IMTX_1D *IMTX_2D; +typedef IMTX_2D *IMTX_3D; + +typedef float *FMTX_1D; +typedef FMTX_1D *FMTX_2D; +typedef FMTX_2D *FMTX_3D; + +typedef double *DMTX_1D; +typedef DMTX_1D *DMTX_2D; +typedef DMTX_2D *DMTX_3D; + +union elem_val_un { /* holds an element value */ + char c; + int i; + long int l; + float f; + double d; +}; + +typedef union elem_val_un MTX_ELEM_VAL; + + +union elem_ptr_un { /* holds a pointer to a 1D vector of any type */ + char *c; + int *i; + long int *l; + float *f; + double *d; +}; + +typedef union elem_ptr_un MTX_1D; +typedef MTX_1D *MTX_2D; +typedef MTX_2D *MTX_3D; + +union mtx_val_ptr_un { /* pointer to matrix values */ + MTX_1D m1; + MTX_2D m2; + MTX_3D m3; +}; + +typedef union mtx_val_ptr_un MTX_PTR; + +struct matrix_st { + unsigned int order; /* order, or dimension, of matrix */ + unsigned int elemtype; /* element type */ + unsigned int elemsize; /* size of element in bytes */ + unsigned int nx, ny, nz; /* size of matrix in each dimension */ + MTX_PTR val; /* pointer to matrix values */ +}; + +typedef struct matrix_st MTX; +typedef struct matrix_st *MTXP; + +/* DEFINITION IDENTIFICATION + * + * Definitions to access a matrix element from an matrix + * + +#define me1(mtx,x)\ + (mtx->elemtype == DT_FLOAT ? mtx->val.m1.f[x] :\ + (mtx->elemtype == DT_DOUBLE ? mtx->val.m1.d[x] :\ + (mtx->elemtype == DT_INT ? mtx->val.m1.i[x] :\ + (mtx->elemtype == DT_LONG ? mtx->val.m1.l[x] :\ + (mtx->elemtype == DT_CHAR ? mtx->val.m1.c[x] :\ + 0\ + ))))) + +#define me2(mtx,x,y)\ + (mtx->elemtype == DT_FLOAT ? mtx->val.m2[x].f[y] :\ + (mtx->elemtype == DT_DOUBLE ? mtx->val.m2[x].d[y] :\ + (mtx->elemtype == DT_INT ? mtx->val.m2[x].i[y] :\ + (mtx->elemtype == DT_LONG ? mtx->val.m2[x].l[y] :\ + (mtx->elemtype == DT_CHAR ? mtx->val.m2[x].c[y] :\ + 0\ + ))))) + + +#define me3(mtx,x,y,z)\ + (mtx->elemtype == DT_FLOAT ? mtx->val.m3[x][y].f[z] :\ + (mtx->elemtype == DT_DOUBLE ? mtx->val.m3[x][y].d[z] :\ + (mtx->elemtype == DT_INT ? mtx->val.m3[x][y].i[z] :\ + (mtx->elemtype == DT_LONG ? mtx->val.m3[x][y].l[z] :\ + (mtx->elemtype == DT_CHAR ? mtx->val.m3[x][y].c[z] :\ + 0\ + ))))) +*/ + + +/* calc_x.c */ +int calc_x(double *x, const double xmin, const double xmax, const int n); +/* calcpoly.c */ +void calcpoly(const double *a, const int degree, const double *x, double *y, const int n); +/* gauss.c */ +int gauss(double **a, double *b, double *x, const int num); +/* lnearest.c */ +long int lnearest(double x); +/* lsfit.c */ +int lsfit(double *x, double *y, int n, int degree, double *coeff, FILE *fp); +/* matprt.c */ +void matprt(const double **m, const int row, const int col, FILE *fp); +/* mtx_disp.c */ +void mtx_show(const MTX *mtx); +void mtx_prt(const MTX *mtx, FILE *fp); +int mtx_prt_elem(const MTX *mtx, FILE *fp, unsigned int x, unsigned int y, unsigned int z); +/* mtx_elem.c */ +int mtx_get_elem(const MTX *mtx, MTX_ELEM_VAL *me, const int x, const int y, const int z); +int mtx_put_elem(MTX *mtx, const MTX_ELEM_VAL *me, unsigned int x, unsigned int y, unsigned int z); +/* mtx_inp.c */ +int mtx_inp_elem(const char *prompt, MTX_ELEM_VAL *mev, const int dtype); +/* mtx_main.c */ +MTX *mtx_init(const unsigned int order, const unsigned int elem_type, const unsigned int nx, const unsigned int ny, const unsigned int nz); +MTX *mtx_clr(MTX *mtx); +int mtx_free(MTX *mtx); +int mtx_elem_size(const int dt); +int mtx_check(const MTX *mtx, const char *func_name); +/* norm_ang.c */ +double norm_ang(double theta); +/* pntprt.c */ +void pntprt(const double *x, const double *y, const int n, FILE *fp); +/* pntread.c */ +int pntread(double *x, double *y, int *num, const int maxn, FILE *fp); +/* poly.c */ +double poly(const double *a, const int degree, const double x); +/* simpson.c */ +double simpson(const double xmin, const double xmax, const double *y, const int np); +/* stddev.c */ +double stddev(const double *y1, const double *y2, const int n, const int df_lost); +/* vectprt.c */ +void vectprt(const double *v, const int n, FILE *fp); +/* vectread.c */ +int vectread(double *v, int *n, const int maxn, FILE *fp); +/* vectsort.c */ +int vectsort(int num_vec, const int dtype, const int num_pts, char *vec1, char *vec2, char *vec3); + +#endif diff --git a/include/kstddef.h b/include/kstddef.h new file mode 100644 index 0000000..0d052f0 --- /dev/null +++ b/include/kstddef.h @@ -0,0 +1,253 @@ +/****************************************************************************** + * + * FILE IDENTIFICATION + * + * File Name: STDDEF.H + * Author: Kevin Rosenberg + * Purpose: Header file containing KRL standard C definitions + * Date Started: Dec. 83 + * + * DESCRIPTION + * Header file contains KRL standard C definitions + * + * MODIFICATION LOG + * + *****************************************************************************/ + +#ifndef STDDEF_H +#define STDDEF_H + +#include +#include +#include +#include +#include "getargs.h" + +#undef SHELL + +#define STR_MAX_LEN 255 +#define STR_SIZE STR_MAX_LEN+1 + +#ifndef bool +typedef signed int bool; /* Boolean variable type */ +#endif + +typedef unsigned char string[STR_SIZE]; + +#define UNSIGNLONG unsigned long int +#define UNSIGNCHAR unsigned char + +#define TRUE 1 +#define FALSE 0 +#define OK TRUE +#define ERROR FALSE +#define YES TRUE +#define NO FALSE +#define ON TRUE +#define OFF FALSE + +/*----------------------------------------------------------------------*/ + +#define SHOW(var, fmt) fprintf (stderr, "var = fmt\n", var) + +/*----------------------------------------------------------------------*/ + +#define INTERNAL_FUNC static +#define INTERNAL_VAR static + +/*----------------------------------------------------------------------*/ + +#define NEWLINE '\n' +#define TAB '\t' +#define EOS '\0' +#define BLANK ' ' +#define ETX 26 /* end of text signal for PC-DOS */ + +/*----------------------------------------------------------------------*/ + +#define MAXPATHNAME 65 /* max length of pathname + 1 */ +#define MAXFILENAME 13 /* rootname(8) + '.'(1) + extension(3) + EOS */ +#define MAXROOTNAME 8 +#define MAXEXTNAME 3 +#define MAXFULLNAME MAXPATHNAME + MAXFILENAME + +/*----------------------------------------------------------------------*/ + +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#define SQR(x) ((x) * (x)) + +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define MIN(a,b) ((a) <= (b) ? (a) : (b)) +#define ISWAP(a,b) {int i; i = a; a = b; b = i;} + +#define CLIP(n,lb,ub) if (n < lb) n = lb; else if (n > ub) n = ub +#define FOREVER for (;;) +#define STR_EQUAL(s1,s2) (strcmp (s1, s2) == 0) + +/*----------------------------------------------------------------------*/ + +struct time_st { + int hour, minute, second, hs; +}; + +struct date_st { + int year, month, date, dow; +}; + +struct timedate_st { + struct time_st t; + struct date_st d; +}; + +typedef struct time_st TIME; +typedef struct date_st DATE; +typedef struct timedate_st TIMEDATE; + +/*----------------------------------------------------------------------*/ + +#define ERR_WARNING 0 +#define ERR_SEVERE 1 +#define ERR_FATAL 2 + +/*----------------------------------------------------------------------*/ + +/* codes for open command */ + +#ifdef LATTICE +#define OPEN_RDONLY 0x8000 /* Lattice codes for binary i/o */ +#define OPEN_WRONLY 0x8001 +#define OPEN_RDWR 0x8002 +#elif MICROSOFT +#define OPEN_RDONLY O_RDONLY /* other system use standard codes */ +#define OPEN_WRONLY O_WRONLY /* for binary */ +#define OPEN_RDWR O_RDWR +#else +#define OPEN_RDONLY 0 /* other system use standard codes */ +#define OPEN_WRONLY 1 /* for binary */ +#define OPEN_RDWR 2 +#endif + +/*----------------------------------------------------------------------*/ + +/* codes for input (inp_*) routines */ + +#define INP_ERROR -1 +#define INP_NO FALSE +#define INP_YES TRUE +#define INP_NEITHER 'b' +#define INP_RETURN 'r' +#define INP_BREAK 0x8000 + +#ifndef O_BINARY +#define O_BINARY (0) +#endif + +#ifndef S_IWRITE +#define S_IWRITE S_IWUSR +#endif + +/* alloc.c */ +void *alloc(unsigned int nbytes); +/* allocnum.c */ +float *alloc_float(int n); +double *alloc_double(int n); +int *alloc_int(int n); +/* cant.c */ +void cant(const char *fname); +/* cdate.c */ +char *td_str_cdate(DATE *d); +char *td_month_name(int n); +char *td_day_name(int n); +/* ctoi.c */ +char *ctoi(const char *s, int *ival); +/* fexist.c */ +int file_exists(const char *fname); +/* fmax.c */ +double fmax(double a, double b); +/* get_yn.c */ +int get_yn(const char *prompt); +/* getbits.c */ +unsigned int getbits(unsigned int x, int p, int n); +/* getch.c */ +int getch(void); +void ungetch(int c); +/* getdate.c */ +DATE *td_get_date(DATE *d); +/* gettime.c */ +TIME *td_get_time(TIME *t); +/* iclip.c */ +int iclip(int n, int lb, int ub); +/* infofn.c */ +int infofn(unsigned int *attrib, long int *filesize, TIMEDATE *td); +/* irand.c */ +unsigned int irand(unsigned int n); +/* itostr.c */ +int itostr(int n, char str[], int size); +/* ltostr.c */ +int ltostr(long val, char *cp, int base); +/* makefnam.c */ +int makefnam(const char *rawfn, const char *template_str, char *result); +int getfnam(const char fullname[], char pathname[], char filename[]); +int getexten(const char *fullname, char *exten); +int validfn(const char filename[]); +/* putdec.c */ +void putdec(const int n, int w, FILE *fd_out); +/* s_clip.c */ +char *str_clip_tail(char *str, unsigned int nclip); +/* s_esc.c */ +char *str_conv_esc(const char *from, char *to); +/* s_esc_c.c */ +char *s_esc_char(const char *str, char *c); +/* s_get.c */ +unsigned int str_get_last_char(const char *str); +/* s_head.c */ +char *str_skip_head(const char *str, const char *charlist); +/* s_lower.c */ +char *str_lower(char *s); +/* s_make.c */ +char *str_make(char *str, int c, const int n); +/* s_revers.c */ +char *str_reverse(char *s); +/* s_rmhead.c */ +char *str_wrm_head(char *str); +char *str_rm_head(char *str, const char *skip_str); +/* s_rmtail.c */ +char *str_rm_tail(char *str, const char *charlist); +/* s_save.c */ +char *str_save(const char *s); +/* s_upper.c */ +char *str_upper(char *str); +/* s_wtail.c */ +char *str_wrm_tail(char *str); +/* searchfn.c */ +int searchfn(const char pat[], const unsigned int attrib); +int getfn(const char name[]); +/* stime.c */ +double td_current_sec(void); +double td_time_to_sec(TIME *t); +TIME *td_time_sub(const TIME *t1, const TIME *t2, TIME *tdiff); +TIME *td_time_add(const TIME *t1, const TIME *t2, TIME *tsum); +TIME *td_time_copy(TIME *to, const TIME *from); +TIME *td_time_norm(TIME *t); +/* strncmpc.c */ +int strncmpc(const char *s, const char *t, int n); +/* sysalloc.c */ +void *sys_alloc(const int nbytes, const char *name); +/* syserror.c */ +void sys_error(int severity, const char *msg, ...); +void sys_verror(int severity, const char *msg, va_list arg); +void sys_error_level(int severity); +/* sysfopen.c */ +FILE *sys_fopen(const char *filename, const char *mode, const char *progname); +/* sysfree.c */ +void sys_free(void *ptr, const char *name); +/* timedate.c */ +void td_get_tmdt(TIMEDATE *td); +const char *td_str_tmdt(const TIMEDATE *td); +const char *td_str_time(const TIME *t); +const char *td_str_stime(const TIME *t); +const char *td_str_date(const DATE *d); +/* kbasename.c */ +char *kbasename(const char *filename); + +#endif diff --git a/include/pol.h b/include/pol.h new file mode 100644 index 0000000..42afdad --- /dev/null +++ b/include/pol.h @@ -0,0 +1,92 @@ +#ifndef __H_POL +#define __H_POL + +/* codes for pol_usefile */ + +#define P_USE_STR 1 /* use string as input source */ +#define P_USE_FILE 2 /* use file as input source */ + +/* codes for pol_int and pol_float */ +/* if in reject catagory, get new number from terminal */ + +#define P_FLTINT 1 /* get a real or integer number */ +#define P_BFLTINT 2 /* get a real or integer number, clip against bounds */ +#define P_CBFLTINT 3 /* get real or int, reject if outside bounds */ + +#define P_FLT 4 /* get a real number */ +#define P_BFLT 5 /* get a real, clip against bounds */ +#define P_CBFLT 6 /* get a floating, reject if outside bounds */ + +#define P_INT 7 /* get a integer number */ +#define P_BINT 8 /* get a integer, clip against bounds */ +#define P_CBINT 9 /* get a integer, reject if outside bounds */ + +#define LETTER 'a' +#define DIGIT '0' + +#define MAXTOK 200 /* maximum length of a token */ +#define MAXLINE 255 +#define MAXIDENT 20 +#define MAXSKIPWORD 20 +#define MAXSKIPCHAR 20 + +#define MIN_INT -32768 +#define MAX_INT 32767 + +/* token types */ + +#define TT_STRING 1 /* string token */ +#define TT_INT 2 /* integer token */ +#define TT_REAL 3 /* floating point token */ +#define TT_ALPHA 4 /* alphabetic token */ +#define TT_ALPNUM 5 /* alphanumeric token */ +#define TT_NUMALPHA 6 +#define TT_SPECLCHAR 7 + +#define TT_EOF 8 /* end of file reached */ +#define TT_ERROR 9 /* error in token, caused by call to wrong */ + /* type of token reader */ +#define TT_BLANK 10 /* white space token. pol_tok() skips these */ +#define TT_USERTOK 11 /* user defined token */ + +struct symlist { + char *name; + int code; + struct symlist *next; +}; + +typedef struct symlist SYMBOL; + +struct token_st { + int ready; /* TRUE if token is ready */ + char tokstr[MAXTOK+1]; /* token string */ + int type; /* type of token 'TT_' */ + int code; /* holds code for user defined tokens */ + double fnum; /* real value of token */ + int inum; /* integer value of token */ +}; + +typedef struct token_st TOKEN; + +/* pol.c */ +void pol_init(void); +void pol_skpword(char *w); +void pol_skpchar(char *s); +int pol_install(char *str, int code); +int pol_word(char *search, int nlet); +int pol_usertok(char *str, int *code); +int pol_string(char *str); +int pol_integer(int *n, int typecode, int boundcode, int bb1, int bb2); +int pol_float(double *n, double typecode, double boundcode, double bb1, double bb2); +int pol_skip(void); +void pol_reader(void); +void gettext(char *str, int lim); +void pol_usefile(int source, char *fn); +void pol_closefile(void); +int pol_lookchar(void); +int pol_inchar(void); +void pol_ungetch(int c); +int get_inputline(FILE *fp); +void set_inputline(char *line); + +#endif diff --git a/include/sdf.h b/include/sdf.h new file mode 100644 index 0000000..e22efe3 --- /dev/null +++ b/include/sdf.h @@ -0,0 +1,318 @@ +/* FILE IDENTIFICATION + * + * Name: sdf.h Header file for Standard Data FIle system + * Programmer: Kevin Rosenberg + * Date Started: 9-18-84 + * Last Change: 12-24-84 + */ + +#ifndef __H_SDF +#define __H_SDF + +#include "kmath.h" + + +/*----------------*/ +/* SYSTEM ALIASES */ +/*----------------*/ + +#define SDF_VERSION 2 +#define SDF_ID_STR "SDF" + +/*------------------*/ +/* DEFINITION BLOCK */ +/*------------------*/ + +/* fixed system constants */ + +#define BLK_SIZE 256 /* Size of a header block */ +#define NUM_DIRBLK 1 /* number of directory blocks */ + +/* block types */ + +#define BT_EMPTY 0 /* Not being used */ +#define BT_DIRECTORY 1 /* First blocks in file */ +#define BT_LABEL 2 /* Label block */ + +/* label types */ + +#define LT_EMPTY 0 /* label record is available for use */ +#define LT_TITLE 1 /* descriptive label given by user */ +#define LT_HISTORY 2 /* history label generated by application */ + /* program */ +#define LT_NOTE 3 /* A note created with a label editor */ + +/* codes for open_sdf and create_sdf */ + +#define SDF_RDONLY 0 +#define SDF_WRONLY 1 +#define SDF_RDWR 2 + +/* function return codes */ + +#define SDF_ERROR ERROR +#define SDF_2D_ERROR SDF_ERROR +#define SDF_OK OK + +/* types of sdf file, this area is EXPANDABLE */ + +#define SDF_FTYPE_2D 10 /* Two-dimensional data file */ + + +/* BLOCK IDENTIFICATION + * + * Name: Directory Header Block + * Size: Multiple of BLK_SIZE + * + * DESCRIPTION + * This is the first block of a sdf file. It contains information on the + * size of the users' data plus the number and type of header blocks. + */ + +struct dir_blk_st { + int block_type; /* required at the beginning of every block */ + /* to identify type of block */ + + char id_str[4]; /* identification string == SDF_ID_STR */ + int sdf_version; /* which version of sdf system == SDF_VERSION */ + + int blk_size; /* size of a header block in bytes */ + + int df_type; /* type of data file, used as identification */ + /* by application programs */ + + unsigned int num_dirblk; /* number of directory header blocks */ + /* currently, only 1 block long */ + +/* label directory */ + + unsigned int start_label; /* starting position of label header blocks */ + unsigned int num_label; /* number of label header blocks */ + +/* data header info */ + + unsigned int start_dhead; /* block number of the start of the users' */ + /* data header blocks */ + unsigned int num_dhead; /* number of data header blocks */ + unsigned int dhead_len; /* length of data header in bytes */ + +/* data record info */ + + unsigned int start_drec; /* block number of start of data records */ + unsigned int num_drec; /* number of of user data records */ + unsigned int drec_size; /* size of users' record */ + int num_dval; /* number of values in each data record */ + int dval_size; /* size of data value in bytes */ + /* NOTE: drec_size = dval_size * num_dval */ +}; + + +/* BLOCK IDENTIFICATION + * + * Name: Label block + * Size: BLK_SIZE + * + * DESCRIPTION + * This block contains both user and history labels. Labels are alpha- + * numeric. History labels include time & date stamp plus calculation time. + */ + +#define LABEL_LEN 159 /* size of alphanumeric label */ +#define LABELS_PER_BLOCK 1 + /* number of labels in each block */ + +struct label_blk_st { + int block_type; /* required at the beginning of every block */ + int label_type; /* type of label */ + char label_str[LABEL_LEN+1];/* alpha numeric label */ + +/* history label time stamping */ + + TIMEDATE timedate; /* time and date of operation */ + float calc_time; /* calculation time in seconds */ +}; + + +/* BLOCK IDENTIFICATION + * + * Name: Data Header Block + * Size: Variable, but always integer multiple of BLK_SIZE + * + * DESCRIPTION + * This block hold information entirely specific to the data in the sdf + * file, such as the user coordinates of the extent of an image, or the + * the rotation increment of raysum data. When an application program + * reads or writes the data header, it passes the size in bytes of the + * data header to be read or written. If the length of a data header + * being read doesn't match the length of the data header in the file, + * the header is still read, but a WARNING message is given. + */ + + + +/* STRUCTURE IDENTIFICATION + * + * Name: Data File Structure Contains all information on open files + * + * DESCRIPTION + * This structure is generated by open_file() and create_file(), it is + * passed to all subroutines of the sdf system. + */ + +struct sdfile_st { + bool open; /* if file is open or not */ + int mode; /* read-write mode */ + int fd; /* file descriptor gotten from C library */ + bool error; /* TRUE if error occurred, all further */ + /* procesing is stopped */ + bool error_report; /* Error reporting flag */ + + unsigned int blk_size; /* size of a header block */ + unsigned int num_dirblk; /* number of directory header blocks */ + char fname[MAXFULLNAME+1]; /* operating system filename */ + + int df_type; /* identification type of data file */ + +/* variables that are used when writing to a file, they define what parts + * of the file have been written + */ + + struct wrt { + unsigned dir : 1; /* 1 if directory header has been written */ + unsigned label : 1; /* 1 if labels have been written */ + unsigned dhead : 1; /* 1 if data header has been written */ + unsigned drec : 1; /* 1 when data records have been written */ + } written; + +/* Directory information to have about the file */ + + unsigned int start_label; /* starting position of labels */ + unsigned int num_label; /* number of labels in file */ + + unsigned int dhead_len; /* length of data header in bytes */ + + unsigned int num_drec; /* number of data records */ + unsigned int drec_size; /* size of data records in bytes */ + int num_dval; /* number of values in each data record */ + int dval_size; /* size of data value in bytes */ + /* NOTE: drec_size = dval_size * num_dval */ + +/* ffset pointers into sdf file */ + + long int pos_dhead; /* starting position of data header */ + long int pos_drec; /* starting position of users' data */ +}; + + +union sdf_blk_un { + char buf[BLK_SIZE]; + struct dir_blk_st dir; + struct label_blk_st lab; +}; + +typedef struct dir_blk_st DIR_BLK; +typedef struct label_blk_st LABEL_BLK; +typedef struct sdfile_st SDFILE; +typedef union sdf_blk_un SDF_BLK; + + +/*----------------------------------------------------------------------*/ +/* 2-Dimensional Standard Data File Header */ +/*----------------------------------------------------------------------*/ + + +/* STRUCTURE IDENTIFICATION + * + * Name: sdf_2d_dhead_st Data header for 2d data files + * + * DESCRIPTION + * + * This structure holds the data that is stored in an image sdf file's + * data header. It contains all data needed to use 2d data records + */ + +struct sdf_2d_dhead_st { + int file_type; /* type of data making up this file */ + /* currenty, DFT_2D_IMAGE or DFT_2D_RAYSUM */ + int nx; /* number of rows */ + int ny; /* number of columns in row */ + int val_type; /* type of pixel value, eg, DT_FLOAT */ + int val_size; /* size of pixel value in bytes */ + + bool axis_ext_kwn; /* TRUE if picture extent is known */ + /* stored in xmin,xmax,ymin,ymax */ + double xmin, ymin; /* position of lower left corner of picture */ + double xmax, ymax; /* position of upper right corner of picture */ + + bool axis_incr_kwn; /* TRUE if increments are known */ + double xinc, yinc; + + bool val_ext_kwn; /* TRUE if pixel extent is known */ + double dvalmin, dvalmax;/* min & max data value for FLOAT & DOUBLE */ + long lvalmin, lvalmax; /* data extent for INT & LONG */ +}; + + +/* STRUCTURE IDENTIFICATION + * + * Name: sdf_2d_st Information about an sdf image + * + * DESCRIPTION + * + * This structure holds all the information need to access an sdf + * image. + */ + +struct sdf_2d_st { + struct sdf_2d_dhead_st dhead; /* image information that is stored in data header */ + SDFILE *dfp; /* pointer to image's standard data file */ + MTX *mtx; /* data values */ + int memory_only; /* TRUE if sdf_2d file is stored in memory only */ +}; + +typedef struct sdf_2d_dhead_st SDF_2D_DHEAD; +typedef struct sdf_2d_st SDF_2D; + +/* types of 2d data files */ + +#define SDF_2D_IMAGE 100 /* data file type is an image */ +#define SDF_2D_RAYSUM 101 /* raysum data file type */ + + +/* sdf.c */ +SDFILE *sdf_open(const char *filename, const int mode); +SDFILE *sdf_create(const char *filename, const int mode, const unsigned int num_drec, const unsigned int num_dval, const int dval_size, const int df_type); +int sdf_read_label(LABEL_BLK *lrec, const int nlab, SDFILE *dfp); +int sdf_write_label(LABEL_BLK *lrec, const int nlab, SDFILE *dfp); +int sdf_add_label(const int ltype, const char *lstr, const double calc_time, SDFILE *dfp); +int sdf_add_empty_label(SDFILE *dfp); +int sdf_copy_labels(SDFILE *dfp_to, SDFILE *dfp_from); +int sdf_read_dhead(void *dh_buf, const unsigned int dhead_len, SDFILE *dfp); +int sdf_write_dhead(const void *dh_buf, const unsigned int dhead_len, SDFILE *dfp); +int sdf_read_drec(void *drec, const int start_rec, const int num_rec, SDFILE *dfp); +int sdf_write_drec(const void *drec, const int start_rec, const int num_rec, SDFILE *dfp); +int sdf_read_dval(void *dval, const int rec, const int start_val, const int num_val, SDFILE *dfp); +int sdf_write_dval(const void *dval, const int rec, const int start_val, const int num_val, SDFILE *dfp); +int sdf_close(SDFILE *dfp); +void sdf_error_report(SDFILE *dfp, const int flag); +void sdf_error(const SDFILE *dfp, const char *str, ...); +bool sdf_check_dfp(const SDFILE *dfp, const int mode, const char *name); +void *sdf_alloc_blk(const int n, SDFILE *dfp, const char *name); +int sdf_free_blk(void *hb, SDFILE *dfp, const char *name); +/* sdf_2d.c */ +SDF_2D *sdf_2d_open(const char *fname, const int mode); +SDF_2D *sdf_2d_create(const char *fname, const int mode, const int nx, const int ny, const int val_type, const int df_type); +int sdf_2d_save(SDF_2D *imp); +int sdf_2d_restore(SDF_2D *imp); +int sdf_2d_alloc_mtx(SDF_2D *imp); +int sdf_2d_free_mtx(SDF_2D *sdf_2d); +int sdf_2d_read_row(char *row_buf, const unsigned int row, SDF_2D *imp); +int sdf_2d_write_row(const char *row_buf, const unsigned int row, SDF_2D *imp); +int sdf_2d_read_col(char *col_buf, const unsigned int col, SDF_2D *imp); +int sdf_2d_write_col(const char *col_buf, const unsigned int col, SDF_2D *imp); +int sdf_2d_close(SDF_2D *imp); +char *sdf_2d_alloc_row(const int nrow, SDF_2D *imp); +char *sdf_2d_alloc_col(const int ncol, SDF_2D *imp); +void sdf_2d_error(const SDF_2D *imp, const char *str, ...); + +#endif diff --git a/include/sgp.h b/include/sgp.h new file mode 100644 index 0000000..32ac084 --- /dev/null +++ b/include/sgp.h @@ -0,0 +1,322 @@ +/*----------------------------------------------------------------------*/ +/* Standard Graphics Package Header File */ +/*----------------------------------------------------------------------*/ + +#ifndef __H_SGP +#define __H_SGP + +#include "kstddef.h" + +/* Write modes for CPIX_?????() routines */ + +#define CPIX_WRT 0 +#define CPIX_XOR 1 +#define CPIX_AND 2 +#define CPIX_OR 3 + +/* device names */ + +#define CRTDEV 1 +#define PRTDEV 2 +#define MEMDEV 4 +#define FILEDEV 8 + +/* linestyles */ + +#define LS_NOLINE 0 +#define LS_SOLID 0xffff +#define LS_DASH1 0xff00 +#define LS_DASH2 0xf0f0 +#define LS_DASH3 0xcccc +#define LS_DASH4 0xff3e +#define LS_DOTTED 0xaaaa + +#define MAXDASH 4 +#define MAXCOLOR 63 + +/* data structures */ + +struct device_st { + int open; /* TRUE if device is open for output */ + int xsize, ysize; /* Size of device in pixels */ + int xmin, ymin; /* smallest coordinates */ + int xmax, ymax; /* Maximum coordinates */ + int colormax; /* Maximum color number of device */ + int style; /* Current linestyle of device */ + int width; /* Current width of device */ + int color; /* Current color of device */ + int icurx, icury; /* Current position */ + int icwidth, icheight; /* Size of characters in pixels */ + int cfore, cback; /* Character foregnd & backgnd colors */ + float asp; /* Aspect ratio. Multipy x coord */ + int (*dotfunc)(int x1, int y1, int color); /* Dot function for device */ + int (*linefunc)(int x1, int y1, int x2, int y2, int color); /* Line function for device */ + unsigned int nbytes; /* Size of buffer in bytes */ + char *buf; /* Pointer to buffer */ + unsigned int bufseg, bufoff; /* Buffer memory location */ + int mode; /* Device mode */ +}; + +struct charsp_st { + float width, height; /* size of characters in NDC */ + float textangle; /* text angle in radians */ + float charupangle; /* character up angle */ + int font; /* font for characters */ + int updir, textdir; /* text direct & character orientation */ + int fore, back; /* foreground & background color */ + /* if back = -1, then transparent back */ +}; + +struct state_st { + int foregnd, backgnd; /* current foregound & background colors */ + int linestyle; /* current 16 bit linestyle */ + int linewidth; /* current width of line (in pixels) */ + int marktype; /* current marker type */ + int markcolor; /* current marker color */ + float xndc, yndc; /* current position in NDC */ +}; + +typedef struct device_st DEVICE; +typedef struct charsp_st CHARSPEC; +typedef struct state_st GRFSTATE; + +struct point {double x, y, z;}; + + +/****************************************************************** + * * + * GRAPH.H * + * * + * Max R. Dursteler Dec 1983 * + * 12405 Village Square Terrace * + * Rockville Md. 20852 * + ****************************************************************** + */ + +/* Constants */ + +/* Flagcodes for motion directions */ +#define XPLUS 001 /* right */ +#define XMINUS 002 /* left */ +#define YPLUS 004 /* up */ +#define YMINUS 010 /* down */ + +/* Codes for marker symbols */ +#define POINT 0 /* small dot */ +#define SQUARE 1 /* empty square */ +#define FSQUARE 2 /* filled square */ +#define DIAMOND 3 /* empty diamond */ +#define FDIAMOND 4 /* filled diamond */ +#define CROSS 5 /* cross */ +#define XCROSS 6 /* x */ +#define CERCLE 7 /* open circle */ +#define FCERCLE 8 /* filled circle */ +#define BSQUARE 9 /* big open square */ +#define BDIAMOND 10 /* big open diamond */ + +#define NMARKERS 11 /* Number of available symbol types */ + +/*-------------------------------------------------------------------------*/ + +#define PSET 0 /* codes for raster merging */ +#define PRESET 1 +#define OR 2 +#define AND 3 +#define XOR 4 + +/*-------------------------------------------------------------------------*/ + +#define X_STKMIN 10 /* joystick specific values */ +#define X_STKMAX 313 +#define Y_STKMIN 10 +#define Y_STKMAX 313 + +#define X_LOCMAX (X_STKMAX - X_STKMIN); /* range from readloc() */ +#define Y_LOCMAX (Y_STKMAX - Y_STKMIN); /* = 0 to LOCMAX */ + +#define JOYSTK1 0 /* device names */ +#define JOYSTK2 1 + +#define BUTT_DONE 2 /* Right joystick button to end a command */ +#define BUTT_START 1 /* Left joystick button to start a command */ +#define BUTT_BOTH 3 /* Both buttons pressed */ + +#define RL_ERROR -1 /* readloc() return codes */ +#define RL_OFF 0 +#define RL_ON 1 + +/*-------------------------------------------------------------------------*/ + +struct raster_st { + int type; + int xmin, ymin; + int xmax, ymax; +}; + +typedef struct raster_st RASTER; + +/*-------------------------------------------------------------------------*/ + +typedef double GRFMTX_2D[3][3]; +typedef double GRFMTX_3D[4][4]; + + +/* circle.c */ +void circle(const double r); +void drawarc(double start, double stop, const double r); +/* cliprect.c */ +int cliprect(double *x1, double *y1, double *x2, double *y2, const double rect[4]); +/* crt_line.c */ +void crt_line(int x1, int y1, int x2, int y2, int color); +int prtline(int func, int x1, int y1, int x2, int y2, int arg1, int arg2); +void crt_line_style(int style); +/* crt_wdot.c */ +void crt_wdot(int x, int y, int c); +void ega_wdot(int x, int y, int c); +void prtdot(int x, int y, int c); +void prtndc(void); +void cpix_set(int x, int y, int c); +void cpix_init(void); +void cpix_set_wrt_mode(int mode); +void cpix_calc_addr(void); +void cpix_set_addr(int addr); +void cpix_inc_col(void); +int cpix_get_addr(void); +void cpix_term(void); +void cpix_setcolor(int c); +void cpix_set_at_addr(int addr, int c); +void cpix_inc_row(void); +void cpix_set_color(int c); +/* ctm.c */ +int ctm_xlat_pre_2(double x, double y); +int ctm_xlat_post_2(double x, double y); +int ctm_scale_pre_2(double sx, double sy); +int ctm_scale_post_2(double sx, double sy); +int ctm_rotate_pre_2(double theta); +int ctm_rotate_post_2(double theta); +int ctm_shear_pre_2(double shrx, double shry); +int ctm_shear_post_2(double shrx, double shry); +int xlat_gmtx_2(GRFMTX_2D m, double x, double y); +int scale_gmtx_2(GRFMTX_2D m, double sx, double sy); +int shear_gmtx_2(GRFMTX_2D m, double shrx, double shry); +int rotate_gmtx_2(GRFMTX_2D m, double theta); +int ident_gmtx_2(GRFMTX_2D m); +int mult_gmtx_2(GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c); +int invert_gmtx_2(GRFMTX_2D a, GRFMTX_2D b); +double determ_gmtx_2(GRFMTX_2D a); +/* drawbox.c */ +int drawbox(double xmin, double ymin, double xmax, double ymax); +/* gp.c */ +int gptrace(int state); +int viewprt3(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax); +int window3(double xmin, double ymin, double xmax, double ymax); +int setproj(int pr, double x, double y, double z); +int setvrp(double x, double y, double z); +int setvpn(double x, double y, double z); +int setvup(double x, double y, double z); +int viewdepth(double front, double back); +int gpfrontclip(int on_off); +int gpbackclip(int on_off); +int calcnper(void); +int calcnpar(void); +int calcrot(double rot[5][5]); +int calcpertrans(void); +int calcpartrans(void); +int matident(double mtx[5][5]); +int matmult(double premtx[5][5], double postmtx[5][5], double result[5][5]); +int crossprod(struct point *v, struct point *w, struct point *result); +int transform(double mtx[5][5], double *x, double *y, double *z); +int homotrans(double mtx[5][5], double *x, double *y, double *z, double *w); +int moveabs3(double x, double y, double z); +int moverel3(double xr, double yr, double zr); +int lineabs3(double x, double y, double z); +int linerel3(double xr, double yr, double zr); +int drawline(double xinput, double yinput, double zinput); +int mastertondc(double *x, double *y, double *z); +int checkchange(void); +int initgrf3(void); +int termgrf3(void); +int matwrite(double mtx[5][5]); +int pyr_edge(double x, double y, double z, int *pos); +int clippyramid(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept); +int cube_edge(double x, double y, double z, int *pos); +int clipcube(double *x1, double *y1, double *z1, double *x2, double *y2, double *z2, int *accept); +/* pickbox.c */ +int pickbox(int dev, int *xmin, int *ymin, int *xmax, int *ymax, int xtab[], int ytab[]); +/* pickloc.c */ +int pickloc(int dev, int *xloc, int *yloc, int xtab[], int ytab[]); +/* pixblock.c */ +int readblock(char array[], int x1, int y1, int x2, int y2); +int writeblock(char array[], int x1, int y1, int mode); +char *allocblock(int x1, int y1, int x2, int y2); +/* readloc.c */ +int readloc(int dev, int *x, int *y); +int loc_to_ndc(int xloc, int yloc, float *xndc, float *yndc); +int readbutt(int dev); +/* sgp.c */ +int gp_init_2(void); +int window2(double xmin, double ymin, double xmax, double ymax); +int window_2(double xmin, double ymin, double xmax, double ymax); +int viewprt2(double xmin, double ymin, double xmax, double ymax); +int viewport_2(double xmin, double ymin, double xmax, double ymax); +int framevpt(void); +int calc_wc_to_ndc(void); +int calc_ndc_to_mc(void); +int wc_to_ndc(double xw, double yw, double *xn, double *yn); +int ndc_to_wc(double xn, double yn, double *xw, double *yw); +int color(int icol); +int linestyle(int style); +int line_abs_2(double x, double y); +int lineabs2(double x, double y); +int move_abs_2(double x, double y); +int moveabs2(double x, double y); +int line_rel_2(double x, double y); +int linerel2(double x, double y); +int move_rel_2(double x, double y); +int moverel2(double x, double y); +int draw_text(char *message); +int drawtext(char *message); +int polylnabs2(double x[], double y[], int n); +int markabs2(double x, double y); +int markrel2(double x, double y); +int pntabs2(double x, double y); +int pntrel2(double x, double y); +int ctm_clr_2(void); +int ctm_get_2(GRFMTX_2D m); +int ctm_set_2(GRFMTX_2D m); +int ctm_pre_mult_2(GRFMTX_2D m); +int ctm_post_mult_2(GRFMTX_2D m); +/* sgpdrive.c */ +int initgrf2(void); +int initdevice(int dev, int mode, int xsize, int ysize); +int opendevice(int dev); +int closedevice(int dev); +int termdevice(int dev); +void stylus(double x, double y, int beam); +int pntndc(double x, double y); +int markndc(double x, double y); +GRFSTATE *inqstate(void); +int gp_set_aspect(int dev, double asp); +void setlinestyle(int style); +int setlinewidth(int wid); +DEVICE *inqdev(int dev); +int settext(double width, double height, double textangle, int font); +int settextclr(int fore, int back); +int setcolor(int fore); +int setbackg(int back); +int initmarker(int marker, int color); +int settextdir(int direction); +int charsize(double wid, double height); +int textangle(double angle); +int drivtext(char *message); +int termgrf2(void); +int flushdevice(int dev); +/* sgptext.c */ +int wrtsymbol(int sym, int x, int y, DEVICE *dev); +int wrtchar(int ch, int x, int y, CHARSPEC *cspec, DEVICE *dev); +int wrttext(char txtstr[], int x, int y, CHARSPEC *cspec, DEVICE *dev); +void crtcolor(int mode, int *f, int *b); +/* trackloc.c */ +int trackloc(int dev, int *xloc, int *yloc, int (*loc_on)(int x, int y), int (*loc_off)(int x, int y)); + +#endif diff --git a/include/stamp-h b/include/stamp-h new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/include/stamp-h @@ -0,0 +1 @@ +timestamp diff --git a/include/stamp-h.in b/include/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/include/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..e9de238 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/man/Makefile b/man/Makefile new file mode 100644 index 0000000..163dc6c --- /dev/null +++ b/man/Makefile @@ -0,0 +1,239 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +man_MANS = ctrec.1 phm2rs.1 phm2sdf.1 sdf2img.1 sdfinfo.1 +EXTRA_DIST = $(man_MANS) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +man1dir = $(mandir)/man1 +MANS = $(man_MANS) + +NROFF = nroff +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-man1: + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done + +uninstall-man1: + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man1 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = man + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu man/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-man +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-man +uninstall: uninstall-am +all-am: Makefile $(MANS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: install-man1 uninstall-man1 install-man uninstall-man tags \ +distdir info-am info dvi-am dvi check check-am installcheck-am \ +installcheck install-exec-am install-exec install-data-am install-data \ +install-am install uninstall-am uninstall all-redirect all-am all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/man/Makefile.am b/man/Makefile.am new file mode 100644 index 0000000..11c7702 --- /dev/null +++ b/man/Makefile.am @@ -0,0 +1,2 @@ +man_MANS=ctrec.1 phm2rs.1 phm2sdf.1 sdf2img.1 sdfinfo.1 +EXTRA_DIST = $(man_MANS) diff --git a/man/Makefile.in b/man/Makefile.in new file mode 100644 index 0000000..7975ec5 --- /dev/null +++ b/man/Makefile.in @@ -0,0 +1,239 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +man_MANS = ctrec.1 phm2rs.1 phm2sdf.1 sdf2img.1 sdfinfo.1 +EXTRA_DIST = $(man_MANS) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +man1dir = $(mandir)/man1 +MANS = $(man_MANS) + +NROFF = nroff +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +install-man1: + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done + +uninstall-man1: + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man1 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = man + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu man/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-man +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-man +uninstall: uninstall-am +all-am: Makefile $(MANS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: install-man1 uninstall-man1 install-man uninstall-man tags \ +distdir info-am info dvi-am dvi check check-am installcheck-am \ +installcheck install-exec-am install-exec install-data-am install-data \ +install-am install uninstall-am uninstall all-redirect all-am all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/man/ctrec.1 b/man/ctrec.1 new file mode 100644 index 0000000..4e13b12 --- /dev/null +++ b/man/ctrec.1 @@ -0,0 +1,63 @@ +.\" -*- nroff -*- +.\" +.\" ctrec.1 +.\" +.\" Author: Kevin Rosenberg +.\" +.\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland +.\" All rights reserved +.\" +.\" Created: Thu Apr 20 07:54:42 MDT 2000 +.\" +.\" $Id: ctrec.1,v 1.1 2000/04/28 13:02:44 kevin Exp $ +.\" +.Dd April 19, 2000 +.Dt CTREC 1 +.Os +.Sh NAME +.Nm ctrec +.Nd Image Reconstruction (reconstruct computed tomography data) +.Sh SYNOPSIS +.Nm ctrec raysum-file image-file nx-image ny-image [OPTIONS] +.Sh DESCRIPTION +.Nm +reconstucts image data from raysum projections collected by CT scanner. It uses +.Xr rs 1 +for projection data generation. +.Pp +.Nm +is configured to use a variety of reconstruction filters. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl Fl interp Ar interp-method +Select interpolation mode (default is linear) +.It Fl Fl filter Ar filter-name +Select filter for reconstruction +.It Fl Fl filter-param Ar x +Set alpha level for Hamming filter +.It Fl Fl backproj Ar bj-method +Select backprojection method (default is diff2) +.It Fl Fl desc Ar description +Save description in image file +.It Fl Fl trace Ar level +Set trace level (default is none) +.It Fl Fl verbose +Turn on verbose mode +.It Fl Fl debug +Turn on debug mode +.It Fl Fl version +Print version +.It Fl Fl help +Print terse help summary +.Sh AUTHORS +Kevin Rosenberg, M.D. +.Sh HISTORY +.Nm +was first written in 1983 using MS-DOS and an EGA display adapter. In 1999 it was ported to GNU/Linux. +.Sh SEE ALSO +.Xr phm2sdf 1 , +.Xr phm2rs 1 , +.Xr rs2sdf 1 , +.Xr sdf2img 1 , +.Xr sdfinfo 1 \ No newline at end of file diff --git a/man/phm2rs.1 b/man/phm2rs.1 new file mode 100644 index 0000000..295a276 --- /dev/null +++ b/man/phm2rs.1 @@ -0,0 +1,60 @@ +.\" -*- nroff -*- +.\" +.\" phm2rs.1 +.\" +.\" Author: Kevin Rosenberg +.\" +.\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland +.\" All rights reserved +.\" +.\" Created: Thu Apr 20 07:54:42 MDT 2000 +.\" +.\" $Id: phm2rs.1,v 1.1 2000/04/28 13:02:44 kevin Exp $ +.\" +.Dd April 19, 2000 +.Dt PHM2RS 1 +.Os +.Sh NAME +.Nm phm2rs +.Nd Raysum generation (Simulation of CT data collection) +.Sh SYNOPSIS +.Nm phm2rs outfile ndet nview [--phantom phantom-name] [--picfile filename] [OPTIONS] +.Sh DESCRIPTION +.Nm +generates raysum from phantom objects. +.Nm +simulates the collection of CT data. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl Fl phantom Ar predefined-phantom-name +Selects a predefined phantom name +.It Fl Fl picfile Ar picfile +Reads a picture file that defines a phantom +.It Fl Fl rotangle Ar angle +Angle to rotate projections, multiple of PI (default is 1) +.It Fl Fl inmemory +Use RAM for temporary storage +.It Fl Fl desc Ar description +Save description in image file +.It Fl Fl trace Ar level +Set trace level (default is none) +.It Fl Fl verbose +Turn on verbose mode +.It Fl Fl debug +Turn on debug mode +.It Fl Fl vephm2rsion +Print vephm2rsion +.It Fl Fl help +Print tephm2rse help summary +.Sh AUTHOPHM2RS +Kevin Rosenberg, M.D. +.Sh HISTORY +.Nm +was fiphm2rst written in 1983 using MS-DOS and an EGA display adapter. In 1999 it was ported to GNU/Linux. +.Sh SEE ALSO +.Xr ctrec 1 , +.Xr phm2sdf 1 , +.Xr rs2img 1 , +.Xr sdf2img 1 , +.Xr sdfinfo 1 \ No newline at end of file diff --git a/man/phm2sdf.1 b/man/phm2sdf.1 new file mode 100644 index 0000000..45a4473 --- /dev/null +++ b/man/phm2sdf.1 @@ -0,0 +1,63 @@ +.\" -*- nroff -*- +.\" +.\" phm2sdf.1 +.\" +.\" Author: Kevin Rosenberg +.\" +.\" Created: Thu Apr 20 07:54:42 MDT 2000 +.\" +.\" $Id: phm2sdf.1,v 1.1 2000/04/28 13:02:44 kevin Exp $ +.\" +.Dd April 19, 2000 +.Dt PHM2SDF 1 +.Os +.Sh NAME +.Nm phm2sdf +.Nd Generate Phantom (generate phantom for computed tomography simulator) +.Sh SYNOPSIS +.Nm phm2sdf outfile nx ny [--phantom phantom-name] [--picfile filename] [OPTIONS] +.Sh DESCRIPTION +.Nm +generates phantom images for comparisons to reconstructions for CTsim. +.Pp +.Nm +is configured to use a variety of options for phantom generation. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl Fl phantom Ar predefined-phantom-name +Selects a predefined phantom name +.It Fl Fl picfile Ar picfile +Reads a picture file that defines a phantom +.It Fl Fl filter Ar filter-name +Generate a phantom image from a filter +.It Fl Fl filter-param Ar x +Set alpha level for Hamming filter +.It Fl Fl filter-bw Ar bw +Filter bandwidth (default is 1) +.It Fl Fl filter-domain Ar domain +Set domain to "spatial" or "freq" +.It Fl Fl nsample Ar n +Use n samples per X & Y direction for each pixel +.It Fl Fl trace Ar level +Set trace level (default is none) +.It Fl Fl desc Ar description +Save description in image file +.It Fl Fl verbose +Turn on verbose mode +.It Fl Fl debug +Turn on debug mode +.It Fl Fl version +Print version +.It Fl Fl help +Print terse help summary +.Sh AUTHORS +Kevin Rosenberg, M.D. +.Sh HISTORY +.Nm +was first written in 1983 using MS-DOS and an EGA display adapter. In 1999 it was ported to GNU/Linux. +.Sh SEE ALSO +.Xr rs2sdf 1 , +.Xr ctrec 1 , +.Xr sdf2img 1 , +.Xr sdfstats 1 \ No newline at end of file diff --git a/man/sdf2img.1 b/man/sdf2img.1 new file mode 100644 index 0000000..bdb6928 --- /dev/null +++ b/man/sdf2img.1 @@ -0,0 +1,63 @@ +.\" -*- nroff -*- +.\" +.\" sdf2img.1 +.\" +.\" Author: Kevin Rosenberg +.\" +.\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland +.\" All rights reserved +.\" +.\" Created: Thu Apr 20 07:54:42 MDT 2000 +.\" +.\" $Id: sdf2img.1,v 1.1 2000/04/28 13:02:44 kevin Exp $ +.\" +.Dd April 19, 2000 +.Dt SDF2IMG 1 +.Os +.Sh NAME +.Nm sdf2img +.Nd SDF (Standard Data File) to Image +.Sh SYNOPSIS +.Nm sdf2img sdffile outfile [OPTIONS] +.Sh DESCRIPTION +.Pp +.Nm +converts an 2D SDF file to a viewable image file. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl Fl format Ar format-name +Choose output image format +.It Fl Fl center Ar center-mode +Choose center of window (default is mode) +.It Fl Fl auto Ar auto-mode +Set automatic window mode (default is full) +.It Fl Fl scaling Ar multiple +Set scaling factor for output image (default is 1) +.It Fl Fl min Ar minimum +Set minimum intensity of window (overrides --auto) +.It Fl Fl max Ar maximum +Set maximum intensity of window (overrides --auto) +.It Fl Fl stats +Print image statistics +.It Fl Fl labels +Print SDF labels +.It Fl Fl debug +Set debug mode +.It Fl Fl verbose +Set verbose mode +.It Fl Fl version +Print version +.It Fl Fl help +Print terse help summary +.Sh AUTHORS +Kevin Rosenberg, M.D. +.Sh HISTORY +.Nm +was first written in 1983 using MS-DOS and an EGA display adapter. In 1999 it was ported to GNU/Linux. +.Sh SEE ALSO +.Xr ctrec 1 , +.Xr phm2rs 1 , +.Xr phm2sdf 1 , +.Xr rs2sdf 1 , +.Xr sdfinfo 1 \ No newline at end of file diff --git a/man/sdfinfo.1 b/man/sdfinfo.1 new file mode 100644 index 0000000..2278463 --- /dev/null +++ b/man/sdfinfo.1 @@ -0,0 +1,55 @@ +.\" -*- nroff -*- +.\" +.\" sdf2info.1 +.\" +.\" Author: Kevin Rosenberg +.\" +.\" Copyright (c) 1995 Tatu Ylonen , Espoo, Finland +.\" All rights reserved +.\" +.\" Created: Thu Apr 20 07:54:42 MDT 2000 +.\" +.\" $Id: sdfinfo.1,v 1.1 2000/04/28 13:02:44 kevin Exp $ +.\" +.Dd April 19, 2000 +.Dt SDF2INFO 1 +.Os +.Sh NAME +.Nm sdfinfo +.Nd Print SDF (Standard Data File) Information +.Sh SYNOPSIS +.Nm sdfinfo sdffile [OPTIONS] +.Sh DESCRIPTION +.Pp +.Nm +prints information about an SDF file +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl Fl labels +Print history labels (default) +.It Fl Fl stats +Print image statistics (default) +.It Fl Fl no-labels +Do not print history labels +.It Fl Fl no-stats +Do not print image statistics +.It Fl Fl debug +Set debug mode +.It Fl Fl verbose +Set verbose mode +.It Fl Fl version +Print version +.It Fl Fl help +Print terse help summary +.Sh AUTHORS +Kevin Rosenberg, M.D. +.Sh HISTORY +.Nm +was first written in 1983 using MS-DOS and an EGA display adapter. In 1999 it was ported to GNU/Linux. +.Sh SEE ALSO +.Xr ctrec 1 , +.Xr phm2rs 1 , +.Xr phm2sdf 1 , +.Xr rs2sdf 1 , +.Xr sdf2img 1 \ No newline at end of file diff --git a/man/sgp.1 b/man/sgp.1 new file mode 100644 index 0000000..f6f56d6 --- /dev/null +++ b/man/sgp.1 @@ -0,0 +1,183 @@ + Simple Graphics Package (SGP) Documentation + ------------------------------------------- + + + Documentation and Software Written by Kevin Rosenberg + Copyright (c) 1984, Kevin Rosenberg + + + + + + OVERVIEW + -------- + + +------------------------+ + | World Coordinate level | + +-----------+------------+ + | + | + +------------+-------------+ + | Convert to Normalized | + | device coordinates (NDC) | + +------------+-------------+ + | + | + +------+-------+ +--------------+ + | Segmentation +-----------+ Disk Storage | + +------+-------+ +--------------+ + | + +------------+-------------+ + | Convert to Physical | + | device coordinates (PDC) | + +--------------------------+ + + +World Coordinate Level +---------------------- + initgrf2 () Initialize 2 dimensional graphics + termgrf2 () Terminate 2 dimensional graphics + window2 (xmin, ymin, xmax, ymax) Set window for world coord + viewprt2 (xmin, ymin, xmax, ymax) Viewport for window in NDC + moveabs2 (x, y) Move graphics cursor + moverel2 (dx, dy) + pntabs2 (x, y) Plot point at current position + pntrel2 (dx, dy) + lineabs2 (x, y) Draw line from current point to point + linerel2 (dx, dy) + markabs2 (x, y) Draw marker at current position + markrel2 (dx, dy) + polylnabs (x[], y[], n) Draw a set of lines + polylnrel (dx[]. dy[]. n) + wc_to_ndc (xwc, ywc, xndc, yndc) Convert from world coord to NDC + ndc_to_wc (xndc, yndc, xwc, ywc) Convert from NDC to world coord + drawtext (str) Draw text string at current positon + + INTERNAL: + calc_map () Calculate wc to ndc factors + clip(rectangle[4], x1, y1, x2, y2) Clip a line againt rectangle + + +Normalized Coordinate level +-------------------------- + stylus (x, y, beam) Draw a line from current position + opendevice (device) Open a device for output + closedevice (device) Close a device for output + flushdevice (device) Put all pending data on device + inqdev (device, xmax, ymax) Return data on device + setcolor (color) Set current drawing color + setlinestyle (style) Set current line style + setlinewidth (width) Set current line width + settext (h, w, orientation, dir, font) Set text attributes + settextclr (foreground, background) If back=-1, then transparent backg + inqtext(h, w, o, dir, font, fore, back) Get current text attributes + charndc (c, xndc, yndc) Draw char at NDC position + textndc (str, xndc, yndc) Draw text string at NDC position + + setmarker (marker_type, color) Set marker attibutes + markndc (xndc, yndc) Draw marker at NDC position + + ndc_to_pdc (device, xndc, yndc, xpdc, ypdc) + savescrn (filename, xmin, ymin, xmax, ymax) + readscrn (filename) + +Physical Device Level +--------------------- + crtdot (x, y, c) + crtline (x1, y1, x2, y2, color, style) + wrtchar (char, x, y, dotfunc()) + wrttext (str, x, y, dotfunc()) + + readblock (array, xmin, ymin, xmax, ymax) + writeblock (array, xmin, ymin, mode) + + prtdot (x, y, c) + prtline (func, x1, y1, x2, y2, color, style) + + +Input Functions +--------------- +Physical device level + joystk (sticknum, x, y) + +Normalized Coordinate level + readloc (xndc, yndc) + inithcur (height, width, color) Initialize haircross cursor + movhcurabs (xndc, yndc) Move haircross cursor to point + movhcurrel (dxndc, dyndc) Move relatively + termhcur () Turn off haircross cursor + readpnt (xndc, yndc) Have cursor track joystick + User press button at desired point + + DATA STRUCTURES + --------------- +struct DEVICE { + int xsize, ysize; Size of device in pixels + int xmax, ymax; Maximum coordinates + int colormax; Maximum color number of device + int style; Current linestyle of device + int width; Current width of device + int color; Current color of device + int curx, cury; Current position + int charwidth, charheight; Size of characters in pixels + float aspt Aspect ratio Multiple coord + int (*dot)(); Dot function for device + int (*line)(); Line function for device + int mode; Device mode +}; + +struct CHARSPEC { + float width, height; size of characters in NDC + int dirflag, orientflag text direction, character orientation + int fore, back; foreground & background color +}; + +struct CURRENT { + int color; + int linestyle; + int linewidth; + float xndc, yndc; +} + + Map directly from world coords to physical device coords + -------------------------------------------------------- + +Window: xwmin, xwmax, ywmin, ywmax +Viewport: xvmin, xvmax, yvmin, yvmax +Physical: xpmax, ypmax + +To convert from wc to ndc: + xndc = xvmin + (xwc - xwmin) / (xwmax - xwmin) + yndc = yvmin + (ywc - ywmin) / (ywmax - ywmin) + +To convert from ndc to pdc: + xpdc = xndc * xpmax + ypdc = yndc * ypmax + +So, for each device set up the following composite transformation: + xpdc = xpmax * (xvmin + (xwc - xwmin) / (xwmax - xwmin)) + ypdc = ypmax * (yvmin + (ywc - ywmin) / (ywmax - ywmin)) + + xpdc = xpmax * xvmin + (xwc - xwmin) * (xpmax / (xwmax - xwmin)) + = xadd + (xwc - xsub) * xfact + +Characters +---------- + Fonts: + NORMAL Regular character set + BOLD Overstike chars with x offset by 1 pixel + ITALICS Shear characters along character height + + NORMAL BOLD ITALICS + X XX X + XXX XXXX XXX + X X XX XX X X + X X XX XX X X + XXXXX XXXXXX XXXXX + X X XX XX X X + X X XX XX X X + + + + + diff --git a/missing b/missing new file mode 100755 index 0000000..7789652 --- /dev/null +++ b/missing @@ -0,0 +1,190 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# 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, 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. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 0000000..7a59aab --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1 2000/04/28 13:02:44 kevin Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/r b/r new file mode 100755 index 0000000..836daf5 --- /dev/null +++ b/r @@ -0,0 +1,6 @@ +aclocal +autoconf +automake +./configure --prefix=/opt/ctsim --with-cgibin-dir=/opt/apache/cgi-bin --with-cgibin-url=/cgi-bin --with-webdata-dir=/opt/apache/htdocs/ctsim/webdata --with-webdata-url=/ctsim/webdata --with-html-dir=/opt/apache/htdocs/ctsim --with-lam-dir=/opt/lam + + diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..3322437 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,449 @@ +# Generated automatically from Makefile.in by configure. +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = /bin/sh + +srcdir = . +top_srcdir = .. +prefix = /opt/ctsim +exec_prefix = ${prefix} + +bindir = ${exec_prefix}/bin +sbindir = ${exec_prefix}/sbin +libexecdir = ${exec_prefix}/libexec +datadir = ${prefix}/share +sysconfdir = ${prefix}/etc +sharedstatedir = ${prefix}/com +localstatedir = ${prefix}/var +libdir = ${exec_prefix}/lib +infodir = ${prefix}/info +mandir = ${prefix}/man +includedir = ${prefix}/include +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/ctsim +pkglibdir = $(libdir)/ctsim +pkgincludedir = $(includedir)/ctsim + +top_builddir = .. + +ACLOCAL = aclocal +AUTOCONF = autoconf +AUTOMAKE = automake +AUTOHEADER = autoheader + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} +INSTALL_STRIP_FLAG = +transform = s,x,x, + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = gawk +CC = gcc +MAKEINFO = makeinfo +PACKAGE = ctsim +RANLIB = ranlib +VERSION = 0.5.0 +X_BASIC_LIBS = -lXext -lX11 +X_CFLAGS = -I/usr/X11R6/include +X_EXTRA_LIBS = +X_LIBS = -L/usr/X11R6/lib +X_PRE_LIBS = -lSM -lICE +X_TOOLKIT_LIBS = -lXt +cgibindir = /opt/apache/cgi-bin +cgibinurl = /cgi-bin +cgiprograms = ctsim.cgi +ctlamlibs = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +ctlibs = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +htmldata = ctsim.html +htmldir = /opt/apache/htdocs/ctsim +lamdir = /opt/lam +lamprograms = ctrec-lam phm2sdf-lam phm2rs-lam +my_includes = -I../include -I.. +webdatadir = /opt/apache/htdocs/ctsim/webdata +webdataurl = /ctsim/webdata +webenabled = true + +bin_PROGRAMS = sdf2img ctrec phm2rs phm2sdf rs2sdf sdf-1 sdf-2 sdfinfo ctrec-lam phm2sdf-lam phm2rs-lam +bin_SCRIPTS = sample-ctrec.sh +EXTRA_PROGRAMS = ctrec-lam phm2sdf-lam phm2rs-lam +INCLUDES = -I../include -I.. + +ctrec_SOURCES = ctrec.c +ctrec_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +phm2rs_SOURCES = phm2rs.c +phm2rs_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +phm2sdf_SOURCES = phm2sdf.c +phm2sdf_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +sdf2img_SOURCES = sdf2img.c +sdf2img_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +rs2sdf_SOURCES = rs2sdf.c +rs2sdf_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +sdf_1_SOURCES = sdf-1.c +sdf_1_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +sdf_2_SOURCES = sdf-2.c +sdf_2_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +sdfinfo_SOURCES = sdfinfo.c +sdfinfo_LDADD = -lir -lezplot -lgraph -lkmath -lk -lcio -lpng -lz + +ctrec_lam_SOURCES = ctrec.c +ctrec_lam_LDADD = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +phm2sdf_lam_SOURCES = phm2sdf.c +phm2sdf_lam_LDADD = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz +phm2rs_lam_SOURCES = phm2rs.c +phm2rs_lam_LDADD = -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz + +CC_LAM = $(lamdir)/bin/hcc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = sample-ctrec.sh +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I.. +CPPFLAGS = +LDFLAGS = -L/usr/lib -L/opt/lam/lib -L../libezplot -L../libgraph -L../libkmath -L../libk -L../libcio -L../libir +LIBS = -lm +ctrec_lam_OBJECTS = ctrec.o +ctrec_lam_DEPENDENCIES = +ctrec_lam_LDFLAGS = +phm2sdf_lam_OBJECTS = phm2sdf.o +phm2sdf_lam_DEPENDENCIES = +phm2sdf_lam_LDFLAGS = +phm2rs_lam_OBJECTS = phm2rs.o +phm2rs_lam_DEPENDENCIES = +phm2rs_lam_LDFLAGS = +sdf2img_OBJECTS = sdf2img.o +sdf2img_DEPENDENCIES = +sdf2img_LDFLAGS = +ctrec_OBJECTS = ctrec.o +ctrec_DEPENDENCIES = +ctrec_LDFLAGS = +phm2rs_OBJECTS = phm2rs.o +phm2rs_DEPENDENCIES = +phm2rs_LDFLAGS = +phm2sdf_OBJECTS = phm2sdf.o +phm2sdf_DEPENDENCIES = +phm2sdf_LDFLAGS = +rs2sdf_OBJECTS = rs2sdf.o +rs2sdf_DEPENDENCIES = +rs2sdf_LDFLAGS = +sdf_1_OBJECTS = sdf-1.o +sdf_1_DEPENDENCIES = +sdf_1_LDFLAGS = +sdf_2_OBJECTS = sdf-2.o +sdf_2_DEPENDENCIES = +sdf_2_LDFLAGS = +sdfinfo_OBJECTS = sdfinfo.o +sdfinfo_DEPENDENCIES = +sdfinfo_LDFLAGS = +SCRIPTS = $(bin_SCRIPTS) + +CFLAGS = -g -O2 -Wall -I/usr/include -I/opt/lam/include +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in sample-ctrec.sh.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/ctrec.P .deps/phm2rs.P .deps/phm2sdf.P .deps/rs2sdf.P \ +.deps/sdf-1.P .deps/sdf-2.P .deps/sdf2img.P .deps/sdfinfo.P +SOURCES = $(ctrec_lam_SOURCES) $(phm2sdf_lam_SOURCES) $(phm2rs_lam_SOURCES) $(sdf2img_SOURCES) $(ctrec_SOURCES) $(phm2rs_SOURCES) $(phm2sdf_SOURCES) $(rs2sdf_SOURCES) $(sdf_1_SOURCES) $(sdf_2_SOURCES) $(sdfinfo_SOURCES) +OBJECTS = $(ctrec_lam_OBJECTS) $(phm2sdf_lam_OBJECTS) $(phm2rs_lam_OBJECTS) $(sdf2img_OBJECTS) $(ctrec_OBJECTS) $(phm2rs_OBJECTS) $(phm2sdf_OBJECTS) $(rs2sdf_OBJECTS) $(sdf_1_OBJECTS) $(sdf_2_OBJECTS) $(sdfinfo_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +sample-ctrec.sh: $(top_builddir)/config.status sample-ctrec.sh.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +sdf2img: $(sdf2img_OBJECTS) $(sdf2img_DEPENDENCIES) + @rm -f sdf2img + $(LINK) $(sdf2img_LDFLAGS) $(sdf2img_OBJECTS) $(sdf2img_LDADD) $(LIBS) + +ctrec: $(ctrec_OBJECTS) $(ctrec_DEPENDENCIES) + @rm -f ctrec + $(LINK) $(ctrec_LDFLAGS) $(ctrec_OBJECTS) $(ctrec_LDADD) $(LIBS) + +phm2rs: $(phm2rs_OBJECTS) $(phm2rs_DEPENDENCIES) + @rm -f phm2rs + $(LINK) $(phm2rs_LDFLAGS) $(phm2rs_OBJECTS) $(phm2rs_LDADD) $(LIBS) + +phm2sdf: $(phm2sdf_OBJECTS) $(phm2sdf_DEPENDENCIES) + @rm -f phm2sdf + $(LINK) $(phm2sdf_LDFLAGS) $(phm2sdf_OBJECTS) $(phm2sdf_LDADD) $(LIBS) + +rs2sdf: $(rs2sdf_OBJECTS) $(rs2sdf_DEPENDENCIES) + @rm -f rs2sdf + $(LINK) $(rs2sdf_LDFLAGS) $(rs2sdf_OBJECTS) $(rs2sdf_LDADD) $(LIBS) + +sdf-1: $(sdf_1_OBJECTS) $(sdf_1_DEPENDENCIES) + @rm -f sdf-1 + $(LINK) $(sdf_1_LDFLAGS) $(sdf_1_OBJECTS) $(sdf_1_LDADD) $(LIBS) + +sdf-2: $(sdf_2_OBJECTS) $(sdf_2_DEPENDENCIES) + @rm -f sdf-2 + $(LINK) $(sdf_2_LDFLAGS) $(sdf_2_OBJECTS) $(sdf_2_LDADD) $(LIBS) + +sdfinfo: $(sdfinfo_OBJECTS) $(sdfinfo_DEPENDENCIES) + @rm -f sdfinfo + $(LINK) $(sdfinfo_LDFLAGS) $(sdfinfo_OBJECTS) $(sdfinfo_LDADD) $(LIBS) + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS install-binSCRIPTS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-depend distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +ctrec-lam: ctrec.c + $(CC_LAM) -DHAVE_CONFIG_H $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.c -o ctrec-lam $(LDFLAGS) -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz + +phm2sdf-lam: phm2sdf.c + $(CC_LAM) -DHAVE_CONFIG_H $(CFLAGS) $(INCLUDES) -DMPI_CT phm2sdf.c -o phm2sdf-lam $(LDFLAGS) -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz + +phm2rs-lam: phm2rs.c + $(CC_LAM) -DHAVE_CONFIG_H $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.c -o phm2rs-lam $(LDFLAGS) -lir_lam -lezplot -lgraph -lkmath -lk -lcio -lpng -lz + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..32ca90c --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,46 @@ +bin_PROGRAMS = sdf2img ctrec phm2rs phm2sdf rs2sdf sdf-1 sdf-2 sdfinfo @lamprograms@ +bin_SCRIPTS = sample-ctrec.sh +EXTRA_PROGRAMS = ctrec-lam phm2sdf-lam phm2rs-lam +INCLUDES=@my_includes@ + +ctrec_SOURCES = ctrec.c +ctrec_LDADD=@ctlibs@ +phm2rs_SOURCES=phm2rs.c +phm2rs_LDADD=@ctlibs@ +phm2sdf_SOURCES = phm2sdf.c +phm2sdf_LDADD=@ctlibs@ +sdf2img_SOURCES = sdf2img.c +sdf2img_LDADD=@ctlibs@ +rs2sdf_SOURCES = rs2sdf.c +rs2sdf_LDADD=@ctlibs@ +sdf_1_SOURCES=sdf-1.c +sdf_1_LDADD=@ctlibs@ +sdf_2_SOURCES=sdf-2.c +sdf_2_LDADD=@ctlibs@ +sdfinfo_SOURCES = sdfinfo.c +sdfinfo_LDADD=@ctlibs@ + +ctrec_lam_SOURCES=ctrec.c +ctrec_lam_LDADD=@ctlamlibs@ +phm2sdf_lam_SOURCES=phm2sdf.c +phm2sdf_lam_LDADD=@ctlamlibs@ +phm2rs_lam_SOURCES=phm2rs.c +phm2rs_lam_LDADD=@ctlamlibs@ + +if USE_LAM +CC_LAM = $(lamdir)/bin/hcc + +ctrec-lam: ctrec.c + $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.c -o ctrec-lam $(LDFLAGS) @ctlamlibs@ + +phm2sdf-lam: phm2sdf.c + $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2sdf.c -o phm2sdf-lam $(LDFLAGS) @ctlamlibs@ + +phm2rs-lam: phm2rs.c + $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.c -o phm2rs-lam $(LDFLAGS) @ctlamlibs@ + +endif + + + + diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..1228bf8 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,449 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +X_BASIC_LIBS = @X_BASIC_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_TOOLKIT_LIBS = @X_TOOLKIT_LIBS@ +cgibindir = @cgibindir@ +cgibinurl = @cgibinurl@ +cgiprograms = @cgiprograms@ +ctlamlibs = @ctlamlibs@ +ctlibs = @ctlibs@ +htmldata = @htmldata@ +htmldir = @htmldir@ +lamdir = @lamdir@ +lamprograms = @lamprograms@ +my_includes = @my_includes@ +webdatadir = @webdatadir@ +webdataurl = @webdataurl@ +webenabled = @webenabled@ + +bin_PROGRAMS = sdf2img ctrec phm2rs phm2sdf rs2sdf sdf-1 sdf-2 sdfinfo @lamprograms@ +bin_SCRIPTS = sample-ctrec.sh +EXTRA_PROGRAMS = ctrec-lam phm2sdf-lam phm2rs-lam +INCLUDES = @my_includes@ + +ctrec_SOURCES = ctrec.c +ctrec_LDADD = @ctlibs@ +phm2rs_SOURCES = phm2rs.c +phm2rs_LDADD = @ctlibs@ +phm2sdf_SOURCES = phm2sdf.c +phm2sdf_LDADD = @ctlibs@ +sdf2img_SOURCES = sdf2img.c +sdf2img_LDADD = @ctlibs@ +rs2sdf_SOURCES = rs2sdf.c +rs2sdf_LDADD = @ctlibs@ +sdf_1_SOURCES = sdf-1.c +sdf_1_LDADD = @ctlibs@ +sdf_2_SOURCES = sdf-2.c +sdf_2_LDADD = @ctlibs@ +sdfinfo_SOURCES = sdfinfo.c +sdfinfo_LDADD = @ctlibs@ + +ctrec_lam_SOURCES = ctrec.c +ctrec_lam_LDADD = @ctlamlibs@ +phm2sdf_lam_SOURCES = phm2sdf.c +phm2sdf_lam_LDADD = @ctlamlibs@ +phm2rs_lam_SOURCES = phm2rs.c +phm2rs_lam_LDADD = @ctlamlibs@ + +@USE_LAM_TRUE@CC_LAM = $(lamdir)/bin/hcc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = sample-ctrec.sh +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +ctrec_lam_OBJECTS = ctrec.o +ctrec_lam_DEPENDENCIES = +ctrec_lam_LDFLAGS = +phm2sdf_lam_OBJECTS = phm2sdf.o +phm2sdf_lam_DEPENDENCIES = +phm2sdf_lam_LDFLAGS = +phm2rs_lam_OBJECTS = phm2rs.o +phm2rs_lam_DEPENDENCIES = +phm2rs_lam_LDFLAGS = +sdf2img_OBJECTS = sdf2img.o +sdf2img_DEPENDENCIES = +sdf2img_LDFLAGS = +ctrec_OBJECTS = ctrec.o +ctrec_DEPENDENCIES = +ctrec_LDFLAGS = +phm2rs_OBJECTS = phm2rs.o +phm2rs_DEPENDENCIES = +phm2rs_LDFLAGS = +phm2sdf_OBJECTS = phm2sdf.o +phm2sdf_DEPENDENCIES = +phm2sdf_LDFLAGS = +rs2sdf_OBJECTS = rs2sdf.o +rs2sdf_DEPENDENCIES = +rs2sdf_LDFLAGS = +sdf_1_OBJECTS = sdf-1.o +sdf_1_DEPENDENCIES = +sdf_1_LDFLAGS = +sdf_2_OBJECTS = sdf-2.o +sdf_2_DEPENDENCIES = +sdf_2_LDFLAGS = +sdfinfo_OBJECTS = sdfinfo.o +sdfinfo_DEPENDENCIES = +sdfinfo_LDFLAGS = +SCRIPTS = $(bin_SCRIPTS) + +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in sample-ctrec.sh.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/ctrec.P .deps/phm2rs.P .deps/phm2sdf.P .deps/rs2sdf.P \ +.deps/sdf-1.P .deps/sdf-2.P .deps/sdf2img.P .deps/sdfinfo.P +SOURCES = $(ctrec_lam_SOURCES) $(phm2sdf_lam_SOURCES) $(phm2rs_lam_SOURCES) $(sdf2img_SOURCES) $(ctrec_SOURCES) $(phm2rs_SOURCES) $(phm2sdf_SOURCES) $(rs2sdf_SOURCES) $(sdf_1_SOURCES) $(sdf_2_SOURCES) $(sdfinfo_SOURCES) +OBJECTS = $(ctrec_lam_OBJECTS) $(phm2sdf_lam_OBJECTS) $(phm2rs_lam_OBJECTS) $(sdf2img_OBJECTS) $(ctrec_OBJECTS) $(phm2rs_OBJECTS) $(phm2sdf_OBJECTS) $(rs2sdf_OBJECTS) $(sdf_1_OBJECTS) $(sdf_2_OBJECTS) $(sdfinfo_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +sample-ctrec.sh: $(top_builddir)/config.status sample-ctrec.sh.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +sdf2img: $(sdf2img_OBJECTS) $(sdf2img_DEPENDENCIES) + @rm -f sdf2img + $(LINK) $(sdf2img_LDFLAGS) $(sdf2img_OBJECTS) $(sdf2img_LDADD) $(LIBS) + +ctrec: $(ctrec_OBJECTS) $(ctrec_DEPENDENCIES) + @rm -f ctrec + $(LINK) $(ctrec_LDFLAGS) $(ctrec_OBJECTS) $(ctrec_LDADD) $(LIBS) + +phm2rs: $(phm2rs_OBJECTS) $(phm2rs_DEPENDENCIES) + @rm -f phm2rs + $(LINK) $(phm2rs_LDFLAGS) $(phm2rs_OBJECTS) $(phm2rs_LDADD) $(LIBS) + +phm2sdf: $(phm2sdf_OBJECTS) $(phm2sdf_DEPENDENCIES) + @rm -f phm2sdf + $(LINK) $(phm2sdf_LDFLAGS) $(phm2sdf_OBJECTS) $(phm2sdf_LDADD) $(LIBS) + +rs2sdf: $(rs2sdf_OBJECTS) $(rs2sdf_DEPENDENCIES) + @rm -f rs2sdf + $(LINK) $(rs2sdf_LDFLAGS) $(rs2sdf_OBJECTS) $(rs2sdf_LDADD) $(LIBS) + +sdf-1: $(sdf_1_OBJECTS) $(sdf_1_DEPENDENCIES) + @rm -f sdf-1 + $(LINK) $(sdf_1_LDFLAGS) $(sdf_1_OBJECTS) $(sdf_1_LDADD) $(LIBS) + +sdf-2: $(sdf_2_OBJECTS) $(sdf_2_DEPENDENCIES) + @rm -f sdf-2 + $(LINK) $(sdf_2_LDFLAGS) $(sdf_2_OBJECTS) $(sdf_2_LDADD) $(LIBS) + +sdfinfo: $(sdfinfo_OBJECTS) $(sdfinfo_DEPENDENCIES) + @rm -f sdfinfo + $(LINK) $(sdfinfo_LDFLAGS) $(sdfinfo_OBJECTS) $(sdfinfo_LDADD) $(LIBS) + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS install-binSCRIPTS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-depend distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +@USE_LAM_TRUE@ctrec-lam: ctrec.c +@USE_LAM_TRUE@ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.c -o ctrec-lam $(LDFLAGS) @ctlamlibs@ + +@USE_LAM_TRUE@phm2sdf-lam: phm2sdf.c +@USE_LAM_TRUE@ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2sdf.c -o phm2sdf-lam $(LDFLAGS) @ctlamlibs@ + +@USE_LAM_TRUE@phm2rs-lam: phm2rs.c +@USE_LAM_TRUE@ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.c -o phm2rs-lam $(LDFLAGS) @ctlamlibs@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/ctrec.c b/src/ctrec.c new file mode 100644 index 0000000..56297d2 --- /dev/null +++ b/src/ctrec.c @@ -0,0 +1,436 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: ctrec.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: ctrec.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * ctrec.c Reconstruct an image from raysums + * + * DATE + * Aug 84 + * Jul 99 -- Converted to ANSI C + * Added MPI parallel processing + */ + +#include "ct.h" + +#define O_INTERP 1 +#define O_FILTER 2 +#define O_FILTER_PARAM 3 +#define O_BACKPROJ 4 +#define O_VERBOSE 5 +#define O_TRACE 6 +#define O_HELP 7 +#define O_DEBUG 8 +#define O_VERSION 9 + +static struct option my_options[] = +{ + {"interp", 1, 0, O_INTERP}, + {"filter", 1, 0, O_FILTER}, + {"filter-param", 1, 0, O_FILTER_PARAM}, + {"backproj", 1, 0, O_BACKPROJ}, + {"trace", 1, 0, O_TRACE}, + {"debug", 0, 0, O_DEBUG}, + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ + fprintf(stdout,"usage: %s raysum-file image-file nx-image ny-image [OPTIONS]\n", kbasename(program)); + fprintf(stdout,"Image reconstruction from raysum projections\n"); + fprintf(stdout,"\n"); + fprintf(stdout," raysum-file Input raysum file\n"); + fprintf(stdout," image-file Output image file in SDF2D format\n"); + fprintf(stdout," nx-image Number of columns in output image\n"); + fprintf(stdout," ny-image Number of rows in output image\n"); + fprintf(stdout," --interp Interpolation method during backprojection\n"); + fprintf(stdout," nearest Nearest neighbor interpolation\n"); + fprintf(stdout," linear Linear interpolation\n"); + fprintf(stdout," bspline B-spline interpolation\n"); + fprintf(stdout," --filter Filter name\n"); + fprintf(stdout," abs_bandlimit Abs * Bandlimiting (default)\n"); + fprintf(stdout," abs_sinc Abs * Sinc\n"); + fprintf(stdout," abs_cos Abs * Cosine\n"); + fprintf(stdout," abs_hamming Abs * Hamming\n"); + fprintf(stdout," shepp Shepp-Logan\n"); + fprintf(stdout," bandlimit Bandlimiting\n"); + fprintf(stdout," sinc Sinc\n"); + fprintf(stdout," cos Cosine\n"); + fprintf(stdout," triangle Triangle\n"); + fprintf(stdout," hamming Hamming\n"); + fprintf(stdout," --backproj Backprojection Method\n"); + fprintf(stdout," trig Trigometric functions at every point\n"); + fprintf(stdout," table Trigometric functions with precalculated table\n"); + fprintf(stdout," diff Difference method\n"); + fprintf(stdout," diff2 Optimized difference method (default)\n"); + fprintf(stdout," idiff2 Optimized difference method with integer math\n"); + fprintf(stdout," --filter-param Alpha level for Hamming filter\n"); + fprintf(stdout," --trace Set tracing to level\n"); + fprintf(stdout," none No tracing (default)\n"); + fprintf(stdout," status Status tracing\n"); + fprintf(stdout," pic Trace picture\n"); + fprintf(stdout," rays Trace allrays\n"); + fprintf(stdout," plot Trace plotting\n"); + fprintf(stdout," clipping Trace clipping\n"); + fprintf(stdout," --verbose Turn on verbose mode\n"); + fprintf(stdout," --debug Turn on debug mode\n"); + fprintf(stdout," --version Print version\n"); + fprintf(stdout," --help Print this help message\n"); + exit(1); +} + + +#ifdef MPI_CT +void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int debug); +#endif +void print_raysum_info(const RAYSUM *rs); + +int +main (const int argc, char *const argv[]) +{ + IMAGE *im_global; + RAYSUM *rs_global; + char *rs_name, *im_filename; + char remark[MAXREMARK]; + char filt_name[80]; + int nx, ny; + double time_start, time_end; + char *endptr; + int opt_verbose = 0; + int opt_debug = 0; + int opt_trace = TRACE_NONE; + double opt_filter_param; + int opt_filter = W_A_BANDLIMIT; + int opt_interp = I_LINEAR; + int opt_interp_param = 1; + int opt_backproj = O_BPROJ_DIFF2; +#ifdef MPI_CT + IMAGE *im_local; + RAYSUM *rs_local; + int mpi_argc = argc; + char **mpi_argv = (char **) argv; + int mpi_nview, mpi_ndet; + double mpi_detinc, mpi_rotinc, mpi_piclen; + double mpi_t1, mpi_t2, mpi_t, mpi_t_g; + int ix; + + MPI_Init(&mpi_argc, &mpi_argv); + MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm); + MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc); + MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank); + + if (mpi_ct.nproc > MPI_MAX_PROCESS) { + sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)", + mpi_ct.nproc, MPI_MAX_PROCESS); + exit(1); + } +#endif + +#ifdef MPI_CT + time_start = MPI_Wtime(); +#else + time_start = td_current_sec(); +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { +#endif + while (1) { + int c = getopt_long(argc, argv, "", my_options, NULL); + char *endptr = NULL; + + if (c == -1) + break; + + switch (c) + { + case O_INTERP: + opt_interp = opt_set_interpolation(optarg, argv[0]); + break; + case O_FILTER: + opt_filter = opt_set_filter(optarg, argv[0]); + break; + case O_BACKPROJ: + opt_backproj = opt_set_backproj(optarg, argv[0]); + break; + case O_FILTER_PARAM: + opt_filter_param = strtod(optarg, &endptr); + if (endptr != optarg + strlen(optarg)) { + usage(argv[0]); + exit(1); + } + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 1; + break; + case O_TRACE: + opt_trace = opt_set_trace(optarg, argv[0]); + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (optind + 4 != argc) { + usage(argv[0]); + exit(1); + } + + rs_name = argv[optind]; + + im_filename = argv[optind + 1]; + + nx = strtol(argv[optind + 2], &endptr, 10); + ny = strtol(argv[optind + 3], &endptr, 10); + + if (opt_filter == W_G_HAMMING || opt_filter == W_AG_HAMMING) + sprintf (filt_name, "%s: alpha = %.2f", + filter_name_of (opt_filter), opt_filter_param); + else + sprintf (filt_name, "%s", filter_name_of (opt_filter)); + + sprintf (remark, + "Reconstruct: %dx%d, %s, %s, %s", + nx, ny, filt_name, interp_name_of (opt_interp), name_of_backproj(opt_backproj)); + + if (opt_verbose) + fprintf (stdout, "%s\n", remark); +#ifdef MPI_CT + } +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { + if (file_exists(rs_name) == FALSE) { + fprintf (stderr, "File %s does not exist\n", rs_name); + exit(1); + } + rs_global = raysum_open (rs_name); + raysum_read (rs_global); + print_raysum_info(rs_global); + if (opt_verbose) { + printf ("Number of detectors: %d\n", rs_global->ndet); + printf (" Number of views: %d\n", rs_global->nview); + printf (" Remark: %s\n", rs_global->remark); + } + + mpi_ndet = rs_global->ndet; + mpi_nview = rs_global->nview; + mpi_detinc = rs_global->det_inc; + mpi_piclen = rs_global->piclen; + mpi_rotinc = rs_global->rot_inc; + } + + + mpi_t1 = MPI_Wtime(); + MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_interp, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&opt_interp_param, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_backproj, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&mpi_ndet, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&mpi_nview, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&mpi_detinc, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&mpi_piclen, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&mpi_rotinc, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&nx, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&ny, 1, MPI_INT, 0, mpi_ct.comm); + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g); + } + + mpi_ct_calc_work_units(mpi_nview); + + rs_local = raysum_create (NULL, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ndet, TRUE); + // rs_local->ndet = mpi_ndet; + // rs_local->nview = mpi_nview; + rs_local->det_inc = mpi_detinc; + rs_local->piclen = mpi_piclen; + rs_local->rot_inc = mpi_rotinc; + + if (opt_debug) + fprintf(stderr, "Bcast'd rs vars, my nview=%d, local_work_units=%d, start_work_units=%d (process %d)\n", + mpi_nview, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ct.start_work_unit[mpi_ct.my_rank], mpi_ct.my_rank); + + if (opt_verbose) + mpi_t1 = MPI_Wtime(); + mpi_scatter_rs(rs_global, rs_local, opt_debug); + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to scatter rs = %f secs, Max time = %f sec\n", mpi_t, mpi_t_g); + } + + if (mpi_ct.my_rank == 0) { + im_global = image_create (im_filename, nx, ny); + sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp); + sdf_add_empty_label (im_global->dfp_2d->dfp); + } + im_local = image_create (NULL, nx, ny); + +#else + rs_global = raysum_open (rs_name); + raysum_read (rs_global); + if (opt_debug) + print_raysum_info(rs_global); + + im_global = image_create (im_filename, nx, ny); + sdf_add_label (LT_HISTORY, rs_global->remark, rs_global->calctime, im_global->dfp_2d->dfp); + sdf_add_empty_label (im_global->dfp_2d->dfp); +#endif + +#ifdef MPI_CT + mpi_t1 = MPI_Wtime(); + image_reconst (im_local, rs_local, opt_filter, opt_filter_param, + opt_interp, opt_interp_param, opt_backproj, opt_trace); + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) { + printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g); + } +#else + image_reconst (im_global, rs_global, opt_filter, opt_filter_param, + opt_interp, opt_interp_param, opt_backproj, opt_trace); +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { + raysum_close (rs_global); + } + + if (opt_verbose) + mpi_t1 = MPI_Wtime(); + for (ix = 0; ix < im_local->nx; ix++) { + MPI_Reduce(im_local->v[ix], im_global->v[ix], + im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm); + } + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g); + } + if (mpi_ct.my_rank == 0) { + strncpy (im_global->remark, remark, MAXREMARK); + image_save (im_global); + time_end = MPI_Wtime(); + im_global->calctime = time_end - time_start; + if (opt_verbose) + fprintf (stdout, "Time active = %.2f\n", im_global->calctime); + } +#else + raysum_close (rs_global); + strncpy (im_global->remark, remark, MAXREMARK); + image_save (im_global); + + time_end = td_current_sec(); + im_global->calctime = time_end - time_start; + if (opt_verbose) + fprintf (stdout, "Time active = %.2f secs\n", im_global->calctime); +#endif + +#ifdef MPI_CT + MPI_Finalize(); +#endif + + return (0); +} + + +#ifdef MPI_CT +void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug) +{ + int iproc; + int end_work_unit; + int iw; + + if (mpi_ct.my_rank == 0) { + for (iproc = 0; iproc < mpi_ct.nproc; iproc++) { + end_work_unit = mpi_ct.start_work_unit[iproc] + + mpi_ct.local_work_units[iproc] + - 1; + + if (opt_debug) + fprintf(stdout, "Sending rs data to process %d\n", iproc); + + for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) { + MPI_Send(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm); + MPI_Send(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm); + MPI_Send(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm); + } + } + } + + end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1; + for (iw = 0; iw <= end_work_unit; iw++) { + MPI_Status status; + + MPI_Recv(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm, &status); + MPI_Recv(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm, &status); + MPI_Recv(rs_local->view[iw]->detval, rs_global->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm, &status); + } + rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank]; +} + +#endif + +void print_raysum_info(const RAYSUM *rs) +{ + printf ("Number of detectors: %d\n", rs->ndet); + printf (" Number of views: %d\n", rs->nview); + printf (" Remark: %s\n", rs->remark); + printf ("Piclen: %f\n", rs->piclen); + printf ("det_start: %f\n", rs->det_start); + printf ("det_inc: %f\n", rs->det_inc); + printf ("rot_start: %f\n", rs->rot_start); + printf ("rot_inc: %f\n", rs->rot_inc); +} diff --git a/src/mpitest.c b/src/mpitest.c new file mode 100644 index 0000000..ce118de --- /dev/null +++ b/src/mpitest.c @@ -0,0 +1,21 @@ +#include "ct.h" + +int main(const int argc, char * const argv[]) +{ + int i; + +#ifdef MPI_CT + MPI_Init(&argc, (char ***) &argv); +#endif + + for (i = 0; i < argc; i++) + { + printf("%d: %s\n", i, argv[i]); + } + +#ifdef MPI_CT + MPI_Finalize(); +#endif + return(0); + +} diff --git a/src/phm2rs.c b/src/phm2rs.c new file mode 100644 index 0000000..13a4e85 --- /dev/null +++ b/src/phm2rs.c @@ -0,0 +1,402 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: phm2rs.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: phm2rs.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * phm2rs.c Generate raysum projections from phantom object + * + * HISTORY + * 1984 -- Final DOS version + * 1999 -- First UNIX version + */ + +#include "ct.h" + +#define O_PHANTOM 1 +#define O_DESC 2 +#define O_NRAY 3 +#define O_ROTANGLE 4 +#define O_TRACE 5 +#define O_VERBOSE 6 +#define O_HELP 7 +#define O_PICFILE 8 +#define O_INMEMORY 9 +#define O_DEBUG 10 +#define O_VERSION 11 + +static struct option my_options[] = +{ + {"phantom", 1, 0, O_PHANTOM}, + {"picfile", 1, 0, O_PICFILE}, + {"desc", 1, 0, O_DESC}, + {"nray", 1, 0, O_NRAY}, + {"rotangle", 1, 0, O_ROTANGLE}, + {"trace", 1, 0, O_TRACE}, + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"debug", 0, 0, O_DEBUG}, + {"inmemory", 0, 0, O_INMEMORY}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ +#ifdef MPI_CT +if (mpi_ct.my_rank == 0) + { +#endif + fprintf(stdout,"usage: %s outfile ndet nview [--phantom phantom-name] [--picfile filename] [OPTIONS]\n", kbasename(program)); + fprintf(stdout,"Calculate raysums (projections) through phantom object, either\n"); + fprintf(stdout,"a predefined --phantom or a --picfile\n"); + fprintf(stdout,"\n"); + fprintf(stdout," outfile Name of output file for raysums\n"); + fprintf(stdout," ndet Number of detectors\n"); + fprintf(stdout," nview Number of rotated views\n"); + fprintf(stdout," --phantom Phantom to use for projection\n"); + fprintf(stdout," herman Herman head phantom\n"); + fprintf(stdout," rowland Rowland head phantom\n"); + fprintf(stdout," browland Bordered Rowland head phantom\n"); + fprintf(stdout," unitpulse Unit pulse phantom\n"); + fprintf(stdout," --picfile Get Phantom from picture file\n"); + fprintf(stdout," --desc Description of raysum\n"); + fprintf(stdout," --nray Number of rays per detector (default = 1)\n"); + fprintf(stdout," --rotangle Degrees to rotate view through, multiple of PI (default = 1)\n"); + fprintf(stdout," --trace Trace level to use\n"); + fprintf(stdout," none No tracing (default)\n"); + fprintf(stdout," text Trace text level\n"); + fprintf(stdout," pic Trace picture\n"); + fprintf(stdout," rays Trace rays\n"); + fprintf(stdout," plot Trace plot\n"); + fprintf(stdout," clipping Trace clipping\n"); + fprintf(stdout," --inmemory Use memory storage\n"); + fprintf(stdout," --verbose Verbose mode\n"); + fprintf(stdout," --debug Debug mode\n"); + fprintf(stdout," --version Print version\n"); + fprintf(stdout," --help Print this help message\n"); +#ifdef MPI_CT + } + MPI_Abort(mpi_ct.comm, 1); +#endif + exit(1); +} + + +void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug); + +int +main (const int argc, char *const argv[]) +{ + DETECTOR *det; + PICTURE *pic = NULL; + RAYSUM *rs_global; + char str[256], *opt_outfile, opt_desc[MAXREMARK+1]; + char opt_picfilename[256]; + char *endptr, *endstr; + int opt_ndet, opt_nview; + int opt_nray = 1; + int opt_trace = 0, opt_picnum = -1; + int opt_verbose = 0; + int opt_debug = 0; + int opt_in_memory = FALSE; + double opt_rotangle = 1; + double time_start, time_end; +#ifdef MPI_CT + RAYSUM *rs_local; + int mpi_argc = argc; + char **mpi_argv = (char **) argv; + double mpi_t1, mpi_t2, mpi_t, mpi_t_g; + + MPI_Init(&mpi_argc, &mpi_argv); + MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm); + MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc); + MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank); + + if (mpi_ct.nproc > MPI_MAX_PROCESS) { + sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)", + mpi_ct.nproc, MPI_MAX_PROCESS); + exit(1); + } +#endif + +#ifdef MPI_CT + time_start = MPI_Wtime(); +#else + time_start = td_current_sec(); +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { +#endif + strcpy(opt_desc, ""); + strcpy(opt_picfilename, ""); + while (1) { + int c = getopt_long(argc, argv, "", my_options, NULL); + char *endptr = NULL; + char *endstr; + + if (c == -1) + break; + + switch (c) { + case O_PHANTOM: + opt_picnum = opt_set_picture(optarg, argv[0]); + pic = create_pic(opt_picnum); + break; + case O_PICFILE: +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) + fprintf(stderr, "Can not read picture from file in MPI mode\n"); + exit(1); +#endif + strncpy(opt_picfilename, optarg, sizeof(opt_picfilename)); + pic = create_pic_from_file(opt_picfilename); + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 1; + break; + case O_INMEMORY: + opt_in_memory = 1; + break; + case O_TRACE: + opt_trace = opt_set_trace(optarg, argv[0]); + break; + case O_DESC: + strncpy(opt_desc, optarg, sizeof(opt_desc)); + break; + case O_ROTANGLE: + opt_rotangle = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + fprintf(stderr,"Error setting --rotangle to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_NRAY: + opt_nray = strtol(optarg, &endptr, 10); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + fprintf(stderr,"Error setting --nray to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (pic == NULL) { + fprintf(stderr, "No phantom defined\n"); + usage(argv[0]); + exit(1); + } + if (optind + 3 != argc) { + usage(argv[0]); + exit(1); + } + opt_outfile = argv[optind]; + opt_ndet = strtol(argv[optind+1], &endptr, 10); + endstr = argv[optind+1] + strlen(argv[optind+1]); + if (endptr != endstr) { + fprintf(stderr,"Error setting --ndet to %s\n", argv[optind+1]); + usage(argv[0]); + exit(1); + } + opt_nview = strtol(argv[optind+2], &endptr, 10); + endstr = argv[optind+2] + strlen(argv[optind+2]); + if (endptr != endstr) { + fprintf(stderr,"Error setting --nview to %s\n", argv[optind+2]); + usage(argv[0]); + exit(1); + } + + snprintf(str, sizeof(str), + "Raysum_Collect: NDet=%d, Nview=%d, NRay=%d, RotAngle=%.2f, ", + opt_ndet, opt_nview, opt_nray, opt_rotangle); + if (opt_picfilename[0]) { + strncat(str, "Phantom=", sizeof(str)); + strncat(str, opt_picfilename, sizeof(str)); + } else if (opt_picnum != -1) { + strncat(str, "Phantom=", sizeof(str)); + strncat(str, name_of_picture(opt_picnum), sizeof(str)); + } + if (opt_desc[0]) { + strncat(str, ": ", sizeof(str)); + strncat(str, opt_desc, sizeof(str)); + } + strncpy(opt_desc, str, sizeof(opt_desc)); +#ifdef MPI_CT + } +#endif + +#ifdef MPI_CT + MPI_Barrier(mpi_ct.comm); + MPI_Bcast(&opt_rotangle, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&opt_nview, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_ndet, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_nray, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_picnum, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm); + + if (mpi_ct.my_rank > 0 && opt_picnum > 0) + pic = create_pic(opt_picnum); +#endif + + opt_rotangle *= PI; + det = detect_create (pic, opt_ndet, opt_nview, opt_nray, opt_rotangle); + +#ifdef MPI_CT + mpi_ct_calc_work_units(opt_nview); + if (mpi_ct.my_rank == 0) { + rs_global = raysum_create_from_det (opt_outfile, det, TRUE); + } + + rs_local = raysum_create_from_det (NULL, det, TRUE); + rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank]; + if (opt_debug) + printf("rs_local->nview = %d (process %d)\n", rs_local->nview, mpi_ct.my_rank); + + if (opt_verbose) + mpi_t1 = MPI_Wtime(); + raysum_collect (rs_local, det, pic, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE); + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to collect rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g); + } + + if (opt_verbose) + mpi_t1 = MPI_Wtime(); + mpi_gather_rs(rs_global, rs_local, opt_debug); + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to gather rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g); + } +#else + rs_global = raysum_create_from_det (opt_outfile, det, opt_in_memory); + raysum_collect (rs_global, det, pic, 0, opt_trace, FALSE); +#endif + +#ifdef MPI_CT + time_end = MPI_Wtime(); + if (mpi_ct.my_rank == 0) { + rs_global->calctime = time_end - time_start; + strncpy (rs_global->remark, opt_desc, sizeof(rs_global->remark)); + if (opt_verbose) { + fprintf(stdout, "Remark: %s\n", rs_global->remark); + fprintf(stdout, "Time active = %.2f secs\n", rs_global->calctime); + } + } +#else + time_end = td_current_sec(); + rs_global->calctime = time_end - time_start; + strncpy (rs_global->remark, opt_desc, sizeof(rs_global->remark)); + if (opt_verbose) { + fprintf(stdout, "Remark: %s\n", rs_global->remark); + fprintf(stdout, "Time active = %.2f secs\n", rs_global->calctime); + } +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { + raysum_write (rs_global); + raysum_close (rs_global); + } +#else + if (opt_in_memory) + raysum_write (rs_global); + raysum_close (rs_global); +#endif + + detect_free (det); + + if (opt_trace >= TRACE_PIC) + { + crt_set_mode (GM_TEXT, TRUE); + crt_set_cpos (1, 1); + printf("Finished\n"); + } + + return (0); +} + + +#ifdef MPI_CT +void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug) +{ + int iproc; + int end_work_unit; + int iw; + + end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1; + for (iw = 0; iw <= end_work_unit; iw++) { + MPI_Send(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm); + MPI_Send(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm); + MPI_Send(rs_local->view[iw]->detval, rs_local->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm); + } + + if (mpi_ct.my_rank == 0) { + for (iproc = 0; iproc < mpi_ct.nproc; iproc++) { + end_work_unit = mpi_ct.start_work_unit[iproc] + + mpi_ct.local_work_units[iproc] + - 1; + + if (opt_debug) + fprintf(stdout, "Recv rs data from process %d\n", iproc); + + for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) { + MPI_Status status; + + MPI_Recv(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm, &status); + MPI_Recv(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm, &status); + MPI_Recv(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status); + } + } + } + +} +#endif diff --git a/src/phm2sdf.c b/src/phm2sdf.c new file mode 100644 index 0000000..0174eef --- /dev/null +++ b/src/phm2sdf.c @@ -0,0 +1,470 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: phm2sdf.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: phm2sdf.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * phm2sdf.c Generate a SDF image from a phantom + * + * HISTORY + * 1984 - Final DOS verion + * 1999 - First UNIX version + */ + +#include "ct.h" + +#define O_PHANTOM 1 +#define O_DESC 2 +#define O_NSAMPLE 3 +#define O_FILTER 4 +#define O_TRACE 5 +#define O_VERBOSE 6 +#define O_HELP 7 +#define O_PICFILE 8 +#define O_FILTER_DOMAIN 9 +#define O_FILTER_BW 10 +#define O_FILTER_PARAM 11 +#define O_DEBUG 12 +#define O_VERSION 13 + +static struct option my_options[] = +{ + {"phantom", 1, 0, O_PHANTOM}, + {"picfile", 1, 0, O_PICFILE}, + {"desc", 1, 0, O_DESC}, + {"nsample", 1, 0, O_NSAMPLE}, + {"filter", 1, 0, O_FILTER}, + {"filter-domain", 1, 0, O_FILTER_DOMAIN}, + {"filter-bw", 1, 0, O_FILTER_BW}, + {"filter-param", 1, 0, O_FILTER_PARAM}, + {"trace", 1, 0, O_TRACE}, + {"verbose", 0, 0, O_VERBOSE}, + {"debug", 0, 0, O_DEBUG}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ + fprintf(stdout,"usage: %s outfile nx ny [--phantom phantom-name] [--picfile filename] [--filter filter-name] [OPTIONS]\n",kbasename(program)); + fprintf(stdout,"Generate phantom image from a predefined --phantom or a --picfile\n"); + fprintf(stdout,"\n"); + fprintf(stdout," outfile Name of output file for image\n"); + fprintf(stdout," nx Number of pixels X-axis\n"); + fprintf(stdout," ny Number of pixels Y-axis\n"); + fprintf(stdout," --phantom Phantom to use for projection\n"); + fprintf(stdout," herman Herman head phantom\n"); + fprintf(stdout," rowland Rowland head phantom\n"); + fprintf(stdout," browland Bordered Rowland head phantom\n"); + fprintf(stdout," unitpulse Unit pulse phantom\n"); + fprintf(stdout," --picfile Generate Phantom from picture file\n"); + fprintf(stdout," --filter Generate Phantom from a filter function\n"); + fprintf(stdout," abs_bandlimit Abs * Bandlimiting\n"); + fprintf(stdout," abs_sinc Abs * Sinc\n"); + fprintf(stdout," abs_cos Abs * Cosine\n"); + fprintf(stdout," abs_hamming Abs * Hamming\n"); + fprintf(stdout," shepp Shepp-Logan\n"); + fprintf(stdout," bandlimit Bandlimiting\n"); + fprintf(stdout," sinc Sinc\n"); + fprintf(stdout," cos Cosine\n"); + fprintf(stdout," triangle Triangle\n"); + fprintf(stdout," hamming Hamming\n"); + fprintf(stdout," --filter-param Alpha level for Hamming filter\n"); + fprintf(stdout," --filter-domain Set domain of filter\n"); + fprintf(stdout," spatial Spatial domain (default)\n"); + fprintf(stdout," freq Frequency domain\n"); + fprintf(stdout," --filter-bw Filter bandwidth (default = 1)\n"); + fprintf(stdout," --desc Description of raysum\n"); + fprintf(stdout," --nsample Number of samples per axis per pixel (default = 1)\n"); + fprintf(stdout," --trace Trace level to use\n"); + fprintf(stdout," none No tracing (default)\n"); + fprintf(stdout," text Trace text level\n"); + fprintf(stdout," pic Trace picture\n"); + fprintf(stdout," rays Trace rays\n"); + fprintf(stdout," plot Trace plot\n"); + fprintf(stdout," clipping Trace clipping\n"); + fprintf(stdout," --debug Debug mode\n"); + fprintf(stdout," --verbose Verbose mode\n"); + fprintf(stdout," --version Print version\n"); + fprintf(stdout," --help Print this help message\n"); + exit(1); +} + +#ifdef MPI_CT +void mpi_gather_image (IMAGE *im_global, IMAGE *im_local, const int opt_debug); +#endif + +int +main (const int argc, char *const argv[]) +{ + IMAGE *im_global = NULL; + PICTURE *pic = NULL; + int opt_nx = 0, opt_ny = 0; + int opt_nsample = 1; + int opt_picnum = -1; + int opt_filter = -1; + int opt_filter_domain = D_SPATIAL; + char *opt_outfile; + int opt_debug = 0; + char str[256]; + char opt_desc[256], opt_picfilename[256]; + char *endstr, *endptr; + double opt_filter_param; + double opt_filter_bw = 1.; + int opt_trace = TRACE_NONE; + int opt_verbose = 0; + double time_start, time_end; +#ifdef MPI_CT + IMAGE *im_local = NULL; + int mpi_argc = argc; + char **mpi_argv = (char **) argv; + double mpi_t1, mpi_t2, mpi_t, mpi_t_g; + + MPI_Init(&mpi_argc, &mpi_argv); + MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm); + MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc); + MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank); + + if (mpi_ct.nproc > MPI_MAX_PROCESS) { + sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)", + mpi_ct.nproc, MPI_MAX_PROCESS); + exit(1); + } +#endif + +#ifdef MPI_CT + time_start = MPI_Wtime(); +#else + time_start = td_current_sec(); +#endif + +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) { +#endif + + strcpy(opt_desc, ""); + strcpy(opt_picfilename, ""); + while (1) { + int c = getopt_long(argc, argv, "", my_options, NULL); + char *endptr = NULL; + char *endstr; + + if (c == -1) + break; + + switch (c) { + case O_PHANTOM: + opt_picnum = opt_set_picture(optarg, argv[0]); + break; + case O_PICFILE: + strncpy(opt_picfilename, optarg, sizeof(opt_picfilename)); + pic = create_pic_from_file(opt_picfilename); +#ifdef MPI_CT + if (mpi_ct.my_rank == 0) + fprintf(stderr, "Can't use picture from file in MPI mode\n"); + exit(1); +#endif + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 1; + break; + case O_TRACE: + opt_trace = opt_set_trace(optarg, argv[0]); + break; + case O_FILTER: + opt_filter = opt_set_filter(optarg, argv[0]); + break; + case O_FILTER_DOMAIN: + opt_filter_domain = opt_set_filter_domain(optarg, argv[0]); + break; + case O_DESC: + strncpy(opt_desc, optarg, sizeof(opt_desc)); + break; + case O_FILTER_BW: + opt_filter_bw = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + fprintf(stderr,"Error setting --filter-bw to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_FILTER_PARAM: + opt_filter_param = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + fprintf(stderr,"Error setting --filter-param to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_NSAMPLE: + opt_nsample = strtol(optarg, &endptr, 10); + endstr = optarg + strlen(optarg); + if (endptr != endstr) { + fprintf(stderr,"Error setting --nsample to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (pic == NULL && opt_picnum == -1 && opt_filter == -1) { + fprintf(stderr, "No phantom defined\n"); + usage(argv[0]); + exit(1); + } + + if (opt_trace >= TRACE_PIC) + show_pic(pic); + + if (optind + 3 != argc) { + usage(argv[0]); + exit(1); + } + opt_outfile = argv[optind]; + opt_nx = strtol(argv[optind+1], &endptr, 10); + endstr = argv[optind+1] + strlen(argv[optind+1]); + if (endptr != endstr) { + fprintf(stderr,"Error setting nx to %s\n", argv[optind+1]); + usage(argv[0]); + exit(1); + } + opt_ny = strtol(argv[optind+2], &endptr, 10); + endstr = argv[optind+2] + strlen(argv[optind+2]); + if (endptr != endstr) { + fprintf(stderr,"Error setting ny to %s\n", argv[optind+2]); + usage(argv[0]); + exit(1); + } + + snprintf(str, sizeof(str), "nx=%d, ny=%d, nsample=%d, ", opt_nx, opt_ny, opt_nsample); + if (opt_picfilename[0]) { + strncat(str, "phantom=", sizeof(str)); + strncat(str, opt_picfilename, sizeof(str)); + } + else if (opt_picnum != -1) { + strncat(str, "phantom=", sizeof(str)); + strncat(str, name_of_picture(opt_picnum), sizeof(str)); + } + else if (opt_filter != -1) { + strncat(str, "filter=", sizeof(str)); + strncat(str, name_of_filter(opt_filter), sizeof(str)); + strncat(str, " - ", sizeof(str)); + strncat(str, name_of_filter_domain(opt_filter_domain), sizeof(str)); + } + if (opt_desc[0]) { + strncat(str, ": ", sizeof(str)); + strncat(str, opt_desc, sizeof(str)); + } + strncpy(opt_desc, str, sizeof(opt_desc)); + + if (opt_verbose) + printf("Compile Phantom to Image\n\n"); +#ifdef MPI_CT + } +#endif + +#ifdef MPI_CT + mpi_t1 = MPI_Wtime(); + MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_nx, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_ny, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_nsample, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_picnum, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter_domain, 1, MPI_INT, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm); + MPI_Bcast(&opt_filter_bw, 1, MPI_DOUBLE, 0, mpi_ct.comm); + + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g); + } + + mpi_ct_calc_work_units(opt_nx); + + if (mpi_ct.my_rank == 0) + im_global = image_create (opt_outfile, opt_nx, opt_ny); + + im_local = image_create(NULL, opt_nx, opt_ny); +#else + im_global = image_create (opt_outfile, opt_nx, opt_ny); +#endif + + if (opt_picnum > 0) + pic = create_pic(opt_picnum); +#ifdef MPI_CT + else { + if (mpi_ct.my_rank == 0) + fprintf(stderr, "picnum < 0\n"); + exit(1); + } +#endif + +#ifdef MPI_CT + if (pic->type == P_UNIT_PULSE) { + if (mpi_ct.my_rank == 0) { + im_global->v[opt_nx/2][opt_ny/2] = 1.; + im_global->calctime = 0; + } + } else if (opt_filter != -1) { + if (mpi_ct.my_rank == 0) { + image_filter_init (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); + im_global->calctime = 0; + } + } else { + if (opt_verbose) + mpi_t1 = MPI_Wtime(); + pic_to_image (pic, im_local, mpi_ct.start_work_unit[mpi_ct.my_rank], + mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace); + if (opt_verbose) { + mpi_t2 = MPI_Wtime(); + mpi_t = mpi_t2 - mpi_t1; + MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm); + if (mpi_ct.my_rank == 0) + printf("Time to compile pic = %f secs, Max time = %f\n", mpi_t, mpi_t_g); + } + mpi_gather_image(im_global, im_local, opt_debug); + } +#else + if (pic->type == P_UNIT_PULSE) { + im_global->v[opt_nx/2][opt_ny/2] = 1.; + im_global->calctime = 0; + } else if (opt_filter != -1) { + image_filter_init (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); + im_global->calctime = 0; + } else { + pic_to_image (pic, im_global, 0, opt_nx, opt_nsample, opt_trace); + } +#endif + +#ifdef MPI_CT + time_end = MPI_Wtime(); + if (mpi_ct.my_rank == 0) { + im_global->calctime = time_end - time_start; + strncpy (im_global->remark, opt_desc, sizeof(im_global->remark)); + } + + if (mpi_ct.my_rank == 0) { + image_save (im_global); + if (opt_verbose) + fprintf (stdout, "Time to compile image = %.2f sec\n\n", im_global->calctime); + } +#else + time_end = td_current_sec(); + im_global->calctime = time_end - time_start; + strncpy (im_global->remark, opt_desc, sizeof(im_global->remark)); + image_save (im_global); + + if (opt_trace >= TRACE_PIC) + { + crt_set_mode (GM_TEXT, TRUE); + crt_set_cpos (1, 1); + } + + if (opt_verbose) + fprintf (stdout, "Time to compile image = %.2f sec\n\n", im_global->calctime); +#endif + + if (opt_trace >= TRACE_PIC) + { + double dmin, dmax; + int nx, ny; + + printf ("Enter size of cell (nx, ny): "); + scanf ("%d %d", &nx, &ny); + printf ("Enter minimum and maximum densities (min, max): "); + scanf ("%lf %lf", &dmin, &dmax); + crt_set_mode (GM_HIGHRES, TRUE); + image_paint (CRTDEV, im_global, 0, 0, nx, ny, dmin, dmax, 0); + WAITKEY(); + + crt_set_mode (GM_TEXT, TRUE); + crt_set_palette (0, crt_calc_color (0., 0., 2.)); + crt_put_stra ("Finished", 8 + C_WHITE); + crt_set_cpos (1, 2); + } + + return (0); +} + + + +#ifdef MPI_CT +void mpi_gather_image (IMAGE *im_global, IMAGE *im_local, const int opt_debug) +{ + int iproc; + int end_work_unit; + int iw; + + end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1; + for (iw = 0; iw <= end_work_unit; iw++) { + MPI_Send(im_local->v[iw], im_local->ny, MPI_FLOAT, 0, 0, mpi_ct.comm); + } + + if (mpi_ct.my_rank == 0) { + for (iproc = 0; iproc < mpi_ct.nproc; iproc++) { + end_work_unit = mpi_ct.start_work_unit[iproc] + + mpi_ct.local_work_units[iproc] + - 1; + + if (opt_debug) { + fprintf(stdout, "Recv rs data from process %d (%d-%d)\n", iproc, + mpi_ct.start_work_unit[iproc], end_work_unit); + fflush(stdout); + } + + + for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) { + MPI_Status status; + + MPI_Recv(im_global->v[iw], im_global->ny, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status); + } + } + } + +} +#endif diff --git a/src/rs2sdf.c b/src/rs2sdf.c new file mode 100644 index 0000000..9ea63c6 --- /dev/null +++ b/src/rs2sdf.c @@ -0,0 +1,138 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: rs2sdf.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: rs2sdf.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * rs2sdf.c Convert Raysum to image + * + * DATE + * Apr 1999 + */ + +#include "ct.h" + +#define O_VERBOSE 7 +#define O_HELP 8 +#define O_VERSION 9 + +static struct option my_options[] = +{ + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + + +void +usage (const char *program) +{ + fprintf(stdout, "usage: %s in-rs-file out-sdf-file [OPTIONS]\n", kbasename(program)); + fprintf(stdout, "This program converts a raysum file to a SDF2D file\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " --verbose Verbose mode\n"); + fprintf(stdout, " --version Print version\n"); + fprintf(stdout, " --help Print this help message\n"); + exit(1); +} + + +int +main (const int argc, char *const argv[]) +{ + IMAGE *im; + RAYSUM *rs; + DETARRAY *detarray; + char *rs_name, *im_name; + int ix, iy; + int opt_v = 0; + extern int optind; + + while (1) + { + int c = getopt_long (argc, argv, "", my_options, NULL); + if (c == -1) + break; + + switch (c) + { + case O_VERBOSE: + opt_v = 1; + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (argc - optind != 2) + usage(argv[0]); + + rs_name = argv[optind]; + im_name = argv[optind + 1]; + + if (file_exists(rs_name) == FALSE) { + fprintf (stderr, "Raysum file %s does not exist\n", rs_name); + exit(1); + } + + rs = raysum_open (rs_name); + + if (opt_v) + { + printf ("Number of detectors: %d\n", rs->ndet); + printf (" Number of views: %d\n", rs->nview); + printf (" Remark: %s\n", rs->remark); + } + + im = image_create (im_name, rs->ndet, rs->nview); + + sdf_add_label (LT_HISTORY, rs->remark, rs->calctime, im->dfp_2d->dfp); + sdf_add_empty_label (im->dfp_2d->dfp); + + detarray = detarray_alloc (rs->ndet); + for (iy = 0; iy < rs->nview; iy++) + { + detarray_read (rs, detarray, iy); + for (ix = 0; ix < rs->ndet; ix++) + { + im->v[ix][iy] = detarray->detval[ix]; + } + } + detarray_free (detarray); + + raysum_close (rs); + image_save (im); + + return(0); +} diff --git a/src/sample-ctrec.sh b/src/sample-ctrec.sh new file mode 100644 index 0000000..5daa07e --- /dev/null +++ b/src/sample-ctrec.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +bin="/opt/ctsim/bin/" + +# Generate phantom image + +${bin}phm2sdf sample-phm.sdf 256 256 --nsample 2 +${bin}sdf2img sample-phm.sdf sample-phm.png --format png + +# Simulate CT data collection and generate raysum sinugram for display +${bin}phm2rs sample-rs.rs 367 320 --nray 2 +${bin}rs2sdf sample-rs.rs sample-rs.sdf +${bin}sdf2img sample-rs.sdf sample-rs.png --format png + +# Reconstruct raysums and generate image for display +${bin}ctrec sample-rs.rs sample-rec.sdf 256 256 +${bin}sdf2img sample-rec.sdf sample-rec.png --format png + +# Files sample-phm.png, sample-rs.png, and sample-rec.png are ready for display diff --git a/src/sample-ctrec.sh.in b/src/sample-ctrec.sh.in new file mode 100755 index 0000000..bf7410d --- /dev/null +++ b/src/sample-ctrec.sh.in @@ -0,0 +1,19 @@ +#!/bin/sh + +bin="@prefix@/bin/" + +# Generate phantom image + +${bin}phm2sdf sample-phm.sdf 256 256 --nsample 2 +${bin}sdf2img sample-phm.sdf sample-phm.png --format png + +# Simulate CT data collection and generate raysum sinugram for display +${bin}phm2rs sample-rs.rs 367 320 --nray 2 +${bin}rs2sdf sample-rs.rs sample-rs.sdf +${bin}sdf2img sample-rs.sdf sample-rs.png --format png + +# Reconstruct raysums and generate image for display +${bin}ctrec sample-rs.rs sample-rec.sdf 256 256 +${bin}sdf2img sample-rec.sdf sample-rec.png --format png + +# Files sample-phm.png, sample-rs.png, and sample-rec.png are ready for display diff --git a/src/sdf-1.c b/src/sdf-1.c new file mode 100644 index 0000000..79e01d3 --- /dev/null +++ b/src/sdf-1.c @@ -0,0 +1,123 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: sdf-1.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: sdf-1.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * sdf-1.c Filter a single SDF file + */ + +#include "ct.h" + +#define O_INVERT 6 +#define O_VERBOSE 7 +#define O_HELP 8 +#define O_VERSION 9 + +static struct option my_options[] = +{ + {"invert", 0, 0, O_INVERT}, + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ + fprintf(stdout, "usage: %s infile outfile [OPTIONS]\n", kbasename(program)); + fprintf(stdout, "Generate a SDF2D file from a SDF2D file\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " --invert Invert image\n"); + fprintf(stdout, " --verbose Verbose modem\n"); + fprintf(stdout, " --version Print version\n"); + fprintf(stdout, " --help Print this help message\n"); + exit(1); +} + +int +main (int argc, char *const argv[]) +{ + IMAGE *im_in; + IMAGE *im_out; + char *in_file; + char *out_file; + int opt_verbose = 0; + int opt_invert = 0; + + while (1) + { + int c = getopt_long (argc, argv, "", my_options, NULL); + + if (c == -1) + break; + + switch (c) + { + case O_INVERT: + opt_invert = 1; + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (optind + 2 != argc) + { + usage(argv[0]); + exit(1); + } + + in_file = argv[optind]; + out_file = argv[optind + 1]; + + + if (opt_invert) { + int ix, iy; + + im_in = image_load (in_file); + im_out = image_create (out_file, im_in->nx, im_in->ny); + + for (ix = 0; ix < im_in->nx; ix++) + for (iy = 0; iy < im_in->ny; iy++) + im_out->v[ix][iy] = - im_in->v[ix][iy]; + + image_save(im_out); + } + + return (0); +} diff --git a/src/sdf-2.c b/src/sdf-2.c new file mode 100644 index 0000000..3a18438 --- /dev/null +++ b/src/sdf-2.c @@ -0,0 +1,196 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: sdf-2.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: sdf-2.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * sdf-2.c Generate a SDF file from two input SDF files + */ + +#include "ct.h" + +#define O_ADD 1 +#define O_SUB 2 +#define O_MUL 3 +#define O_COMP 4 +#define O_VERBOSE 7 +#define O_HELP 8 +#define O_VERSION 9 + +static struct option my_options[] = +{ + {"add", 0, 0, O_ADD}, + {"sub", 0, 0, O_SUB}, + {"mul", 0, 0, O_MUL}, + {"comp", 0, 0, O_COMP}, + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ + fprintf(stdout, "usage: %s infile1 infile2 outfile [OPTIONS]\n", kbasename(program)); + fprintf(stdout, "Generate an SDF2D file from two input SDF2D files\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " infile1 Name of first input SDF file\n"); + fprintf(stdout, " infile2 Name of second input SDF file\n"); + fprintf(stdout, " outfile Name of output SDF file\n"); + fprintf(stdout, " --add Add images\n"); + fprintf(stdout, " --sub Subtract image 2 from image 1\n"); + fprintf(stdout, " --mul Multiply images\n"); + fprintf(stdout, " --comp Compare images\n"); + fprintf(stdout, " --verbose Verbose modem\n"); + fprintf(stdout," --version Print version\n"); + fprintf(stdout, " --help Print this help message\n"); + exit(1); +} + +int +main (int argc, char *const argv[]) +{ + IMAGE *im_in1; + IMAGE *im_in2; + IMAGE *im_out; + char *in_file1; + char *in_file2; + char *out_file; + int opt_verbose = 0; + int opt_add = 0; + int opt_sub = 0; + int opt_mul = 0; + int opt_comp = 0; + + while (1) + { + int c = getopt_long (argc, argv, "", my_options, NULL); + + if (c == -1) + break; + + switch (c) + { + case O_ADD: + opt_add = 1; + break; + case O_SUB : + opt_sub = 1; + break; + case O_MUL: + opt_mul = 1; + break; + case O_COMP: + opt_comp = 1; + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (optind + 3 != argc) + { + usage(argv[0]); + exit(1); + } + + in_file1 = argv[optind]; + in_file2 = argv[optind + 1]; + out_file = argv[optind + 2]; + + im_in1 = image_load (in_file1); + im_in2 = image_load (in_file2); + if (im_in1->nx != im_in2->nx || im_in1->ny != im_in2->ny) { + fprintf(stderr, "Size of image 1 (%d,%d) and image 2 (%d,%d) do not match\n", + im_in1->nx, im_in1->ny, im_in2->nx, im_in2->ny); + exit(1); + } + im_out = image_create (out_file, im_in1->nx, im_in1->ny); + + if (opt_add) { + int ix, iy; + for (ix = 0; ix < im_in1->nx; ix++) + { + IMAGE_ELEM_VAL *in1 = &im_in1->v[ix][0]; + IMAGE_ELEM_VAL *in2 = &im_in2->v[ix][0]; + IMAGE_ELEM_VAL *out = &im_out->v[ix][0]; + for (iy = 0; iy < im_in1->ny; iy++) + *out++ = *in1++ + *in2++; + } + } else if (opt_sub) { + int ix, iy; + for (ix = 0; ix < im_in1->nx; ix++) + { + IMAGE_ELEM_VAL *in1 = &im_in1->v[ix][0]; + IMAGE_ELEM_VAL *in2 = &im_in2->v[ix][0]; + IMAGE_ELEM_VAL *out = &im_out->v[ix][0]; + for (iy = 0; iy < im_in1->ny; iy++) + *out++ = *in1++ - *in2++; + } + } else if (opt_mul) { + int ix, iy; + for (ix = 0; ix < im_in1->nx; ix++) + { + IMAGE_ELEM_VAL *in1 = &im_in1->v[ix][0]; + IMAGE_ELEM_VAL *in2 = &im_in2->v[ix][0]; + IMAGE_ELEM_VAL *out = &im_out->v[ix][0]; + for (iy = 0; iy < im_in1->ny; iy++) + *out++ = *in1++ * *in2++; + } + } else if (opt_comp) { + int ix, iy; + double abs_error = 0.; + for (ix = 0; ix < im_in1->nx; ix++) + { + IMAGE_ELEM_VAL *in1 = &im_in1->v[ix][0]; + IMAGE_ELEM_VAL *in2 = &im_in2->v[ix][0]; + IMAGE_ELEM_VAL *out = &im_out->v[ix][0]; + for (iy = 0; iy < im_in1->ny; iy++) + { + double diff = *in1++ - *in2++; + *out++ = diff; + abs_error += fabs(diff); + } + } + abs_error /= (im_in1->nx * im_in1->ny); + fprintf(stdout, "Average Error = %f\n", abs_error); + } + + image_save(im_out); + + return (0); +} diff --git a/src/sdf2img.c b/src/sdf2img.c new file mode 100644 index 0000000..4972ac6 --- /dev/null +++ b/src/sdf2img.c @@ -0,0 +1,700 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: sdf2img.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: sdf2img.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * sdf2img.c Convert an SDF file to a viewable format image + */ + +#include "ct.h" + +#if HAVE_PNG +void sdf2d_to_png (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax); +#endif +#if HAVE_GIF +void sdf2d_to_gif (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax); +#endif +void sdf2d_to_pgm (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax); +void sdf2d_to_pgmasc (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax); + +#define O_SCALE 1 +#define O_MIN 2 +#define O_MAX 3 +#define O_AUTO 4 +#define O_CENTER 5 +#define O_STATS 6 +#define O_VERBOSE 7 +#define O_HELP 8 +#define O_FORMAT 9 +#define O_LABELS 10 +#define O_VERSION 11 +#define O_DEBUG 12 + +static struct option my_options[] = +{ + {"scale", 1, 0, O_SCALE}, + {"min", 1, 0, O_MIN}, + {"max", 1, 0, O_MAX}, + {"auto", 1, 0, O_AUTO}, + {"center", 1, 0, O_CENTER}, + {"format", 1, 0, O_FORMAT}, + {"labels", 0, 0, O_LABELS}, + {"stats", 0, 0, O_STATS}, + {"verbose", 0, 0, O_VERBOSE}, + {"debug", 0, 0, O_DEBUG}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +#define O_AUTO_FULL 1 +#define O_AUTO_STD0_1 2 +#define O_AUTO_STD0_5 3 +#define O_AUTO_STD1 4 +#define O_AUTO_STD2 5 +#define O_AUTO_STD3 6 + +#define O_AUTO_FULL_STR "full" +#define O_AUTO_STD0_1_STR "std0.1" +#define O_AUTO_STD0_5_STR "std0.5" +#define O_AUTO_STD1_STR "std1" +#define O_AUTO_STD2_STR "std2" +#define O_AUTO_STD3_STR "std3" + +#define O_CENTER_MEAN 1 +#define O_CENTER_MODE 2 +#define O_CENTER_MEAN_STR "mean" +#define O_CENTER_MODE_STR "mode" + +#define O_FORMAT_GIF 1 +#define O_FORMAT_PNG 2 +#define O_FORMAT_PGM 3 +#define O_FORMAT_PGMASC 4 +#define O_FORMAT_GIF_STR "gif" +#define O_FORMAT_PNG_STR "png" +#define O_FORMAT_PGM_STR "pgm" +#define O_FORMAT_PGMASC_STR "pgmasc" + +void +usage (const char *program) +{ + fprintf(stdout, "usage: %s sdfname outfile [OPTIONS]\n", kbasename(program)); + fprintf(stdout, "Convert SDF2D file to an image file\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " sdfname Name of input SDF file\n"); + fprintf(stdout, " outfile Name of output file\n"); + fprintf(stdout, " --format Output format\n"); + fprintf(stdout, " pgm PGM (portable graymap) format (default)\n"); + fprintf(stdout, " pgmasc PGM (portable graymap) ASCII format\n"); +#ifdef HAVE_PNG + fprintf(stdout, " png PNG format\n"); +#endif +#ifdef HAVE_GIF + fprintf(stdout, " gif GIF format\n"); +#endif + fprintf(stdout, " --center Center of window\n"); + fprintf(stdout, " mode Mode is center of window (default)\n"); + fprintf(stdout, " mean Mean is center of window\n"); + fprintf(stdout, " --auto Set auto window\n"); + fprintf(stdout, " full Use full window (default)\n"); + fprintf(stdout, " std0.1 Use 0.1 standard deviation about center\n"); + fprintf(stdout, " std0.5 Use 0.5 standard deviation about center\n"); + fprintf(stdout, " std1 Use one standard deviation about center\n"); + fprintf(stdout, " std2 Use two standard deviations about center\n"); + fprintf(stdout, " std3 Use three standard deviations about center\n"); + fprintf(stdout, " --scale Scaling factor for output size\n"); + fprintf(stdout, " --min Set minimum intensity\n"); + fprintf(stdout, " --max Set maximum intensity\n"); + fprintf(stdout, " --stats Print image statistics\n"); + fprintf(stdout, " --labels Print image labels\n"); + fprintf(stdout, " --debug Set debug mode\n"); + fprintf(stdout, " --verbose Set verbose mode\n"); + fprintf(stdout, " --version Print version\n"); + fprintf(stdout, " --help Print this help message\n"); + exit(1); +} + +int +main (int argc, char *const argv[]) +{ + IMAGE *im; + double densmin = HUGE_VAL, densmax = -HUGE_VAL; + char *in_file, *out_file; + int opt_verbose = 0; + int opt_scale = 1; + int opt_auto = O_AUTO_FULL; + int opt_set_max = 0; + int opt_set_min = 0; + int opt_stats = 0; + int opt_debug = 0; + int opt_center = O_CENTER_MODE; + int opt_format = O_FORMAT_PGM; + int opt_labels = 0; + + while (1) + { + int c = getopt_long (argc, argv, "", my_options, NULL); + char *endptr = NULL; + char *endstr; + + if (c == -1) + break; + + switch (c) + { + case O_MIN: + opt_set_min = 1; + densmin = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) + { + fprintf(stderr, "Error setting --min to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_MAX: + opt_set_max = 1; + densmax = strtod(optarg, &endptr); + endstr = optarg + strlen(optarg); + if (endptr != endstr) + { + fprintf(stderr, "Error setting --max to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_SCALE: + opt_scale = strtol(optarg, &endptr, 10); + endstr = optarg + strlen(optarg); + if (endptr != endstr) + { + fprintf(stderr,"Error setting --scale to %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_AUTO: + if (strcmp(optarg, O_AUTO_FULL_STR) == 0) + opt_auto = O_AUTO_FULL; + else if (strcmp(optarg, O_AUTO_STD1_STR) == 0) + opt_auto = O_AUTO_STD1; + else if (strcmp(optarg, O_AUTO_STD0_5_STR) == 0) + opt_auto = O_AUTO_STD0_5; + else if (strcmp(optarg, O_AUTO_STD0_1_STR) == 0) + opt_auto = O_AUTO_STD0_1; + else if (strcmp(optarg, O_AUTO_STD2_STR) == 0) + opt_auto = O_AUTO_STD2; + else if (strcmp(optarg, O_AUTO_STD3_STR) == 0) + opt_auto = O_AUTO_STD3; + else + { + fprintf(stderr, "Invalid auto mode %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_CENTER: + if (strcmp(optarg, O_CENTER_MEAN_STR) == 0) + opt_center = O_CENTER_MEAN; + else if (strcmp(optarg, O_CENTER_MODE_STR) == 0) + opt_center = O_CENTER_MODE; + else + { + fprintf(stderr, "Invalid center mode %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_FORMAT: + if (strcmp(optarg, O_FORMAT_PGM_STR) == 0) + opt_format = O_FORMAT_PGM; + else if (strcmp(optarg, O_FORMAT_PGMASC_STR) == 0) + opt_format = O_FORMAT_PGMASC; +#if HAVE_PNG + else if (strcmp(optarg, O_FORMAT_PNG_STR) == 0) + opt_format = O_FORMAT_PNG; +#endif +#if HAVE_GIF + else if (strcmp(optarg, O_FORMAT_GIF_STR) == 0) + opt_format = O_FORMAT_GIF; +#endif + else { + fprintf(stderr, "Invalid format mode %s\n", optarg); + usage(argv[0]); + exit(1); + } + break; + case O_LABELS: + opt_labels = 1; + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 1; + break; + case O_STATS: + opt_stats = 1; + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (optind + 2 != argc) + { + usage(argv[0]); + exit(1); + } + + in_file = argv[optind]; + out_file = argv[optind+1]; + + if ((im = image_load (in_file)) == NULL) + { + fprintf(stderr, "File %s does not exist\n", in_file); + exit(1); + } + + if (opt_labels) + { + int nlabels = im->dfp_2d->dfp->num_label; + int i; + + for (i = 0; i < nlabels; i++) + { + SDF_BLK blk; + if (sdf_read_label(&blk.lab, i, im->dfp_2d->dfp) != SDF_OK) + break; + if (blk.lab.label_type == LT_HISTORY) { + fprintf(stdout, "History: %s\n", blk.lab.label_str); + fprintf(stdout, " calc time = %.2f secs\n", blk.lab.calc_time); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } else if (blk.lab.label_type == LT_TITLE) { + fprintf(stdout, "Title: %s\n", blk.lab.label_str); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } else if (blk.lab.label_type == LT_NOTE) { + fprintf(stdout, "Note: %s\n", blk.lab.label_str); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } + } + } + + if (opt_stats || (! (opt_set_max && opt_set_min))) + { + double minfound = HUGE_VAL, maxfound = -HUGE_VAL; + double mode = 0, mean = 0, stddev = 0, window = 0; + double spread; + int hist[256]; + int ibin, nbin = 256; + int max_bin, max_binindex; + double maxbin; + int ix, iy; + + maxbin = nbin - 1; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + if (im->v[ix][iy] > maxfound) + maxfound = im->v[ix][iy]; + if (im->v[ix][iy] < minfound) + minfound = im->v[ix][iy]; + mean += im->v[ix][iy]; + } + } + spread = maxfound - minfound; + if (spread == 0) + mode = minfound; + else + { + for (ibin = 0; ibin < nbin; ibin++) + hist[ibin] = 0; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + int b = (int) ((((im->v[ix][iy] - minfound) / spread) * (double) maxbin) + 0.5); + hist[b]++; + } + } + max_binindex = 0; + max_bin = -1; + for (ibin = 0; ibin < nbin; ibin++) + { + if (hist[ibin] > max_bin) + { + max_bin = hist[ibin]; + max_binindex = ibin; + } + } + mode = (((double) max_binindex) * spread / ((double) maxbin)) + minfound; + } + + if (opt_auto == O_AUTO_FULL) + { + if (! opt_set_max) + densmax = maxfound; + if (! opt_set_min) + densmin = minfound; + } + if (opt_stats || opt_auto != O_AUTO_FULL) + { + mean /= im->nx * im->ny; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + double diff = (im->v[ix][iy] - mean); + stddev += diff * diff; + } + } + stddev = sqrt(stddev / (im->nx * im->ny)); + if (opt_auto == O_AUTO_FULL) + ; + else if (opt_auto == O_AUTO_STD1) + window = stddev; + else if (opt_auto == O_AUTO_STD0_1) + window = stddev * 0.1; + else if (opt_auto == O_AUTO_STD0_5) + window = stddev * 0.5; + else if (opt_auto == O_AUTO_STD2) + window = stddev * 2; + else if (opt_auto == O_AUTO_STD3) + window = stddev * 3; + else + { + fprintf(stderr, "Internal Error: Invalid auto mode %d\n", opt_auto); + exit(1); + } + } + if (opt_stats) + { + fprintf(stdout,"nx=%d\n", im->nx); + fprintf(stdout,"ny=%d\n", im->ny); + fprintf(stdout,"min=%f\n", minfound); + fprintf(stdout,"max=%f\n", maxfound); + fprintf(stdout,"mean=%f\n", mean); + fprintf(stdout,"mode=%f\n", mode); + fprintf(stdout,"stddev=%f\n", stddev); + } + if (opt_auto != O_AUTO_FULL) + { + double center; + + if (opt_center == O_CENTER_MODE) + center = mode; + else if (opt_center == O_CENTER_MEAN) + center = mean; + else + { + fprintf(stderr, "Internal Error: Invalid center mode %d\n", opt_center); + exit(1); + } + if (! opt_set_max) + densmax = center + window; + if (! opt_set_min) + densmin = center - window; + } + } + + if (opt_stats) + { + fprintf(stdout,"min_disp=%f\n", densmin); + fprintf(stdout,"max_disp=%f\n", densmax); + } + + if (opt_format == O_FORMAT_PGM) + sdf2d_to_pgm (im, out_file, opt_scale, opt_scale, densmin, densmax); + else if (opt_format == O_FORMAT_PGMASC) + sdf2d_to_pgmasc (im, out_file, opt_scale, opt_scale, densmin, densmax); +#if HAVE_PNG + else if (opt_format == O_FORMAT_PNG) + sdf2d_to_png (im, out_file, opt_scale, opt_scale, densmin, densmax); +#endif +#if HAVE_GIF + else if (opt_format == O_FORMAT_GIF) + sdf2d_to_gif (im, out_file, opt_scale, opt_scale, densmin, densmax); +#endif + else + { + fprintf(stderr, "Internal Error: Invalid format mode %d\n", opt_format); + exit(1); + } + return (0); +} + + +void +sdf2d_to_pgm (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax) +{ + FILE *fp; + int irow; + unsigned char *rowp; + + rowp = (unsigned char *) sys_alloc(im->nx * nxcell,"sdf2d_to_img"); + if (rowp == NULL) + return; + + if ((fp = fopen (outfile, "wb")) == NULL) + return; + + fprintf(fp, "P5\n"); + fprintf(fp, "%d %d\n", im->nx, im->ny); + fprintf(fp, "255\n"); + + for (irow = im->ny - 1; irow >= 0; irow--) + { + int icol, ir; + + for (icol = 0; icol < im->nx; icol++) + { + double dens; + int p; + int pos = icol * nxcell; + dens = (im->v[icol][irow] - densmin) / (densmax - densmin); + if (dens < 0) + dens = 0; + else if (dens > 1) + dens = 1; + for (p = pos; p < pos + nxcell; p++) + { + rowp[p] = (unsigned int) (dens * 255.); + } + } + for (ir = 0; ir < nycell; ir++) + { + int ic; + for (ic = 0; ic < im->nx * nxcell; ic++) + fprintf(fp, "%c ", rowp[ic]); + } + } + sys_free(rowp, "sdf2img"); + + fclose(fp); +} + +void +sdf2d_to_pgmasc (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax) +{ + FILE *fp; + int irow; + unsigned char *rowp; + + rowp = (unsigned char *) sys_alloc(im->nx * nxcell,"sdf2d_to_img"); + if (rowp == NULL) + return; + + if ((fp = fopen (outfile, "wb")) == NULL) + return; + + fprintf(fp, "P2\n"); + fprintf(fp, "%d %d\n", im->nx, im->ny); + fprintf(fp, "255\n"); + + for (irow = im->ny - 1; irow >= 0; irow--) + { + int icol, ir; + + for (icol = 0; icol < im->nx; icol++) + { + double dens; + int p; + int pos = icol * nxcell; + dens = (im->v[icol][irow] - densmin) / (densmax - densmin); + if (dens < 0) + dens = 0; + else if (dens > 1) + dens = 1; + for (p = pos; p < pos + nxcell; p++) + { + rowp[p] = (unsigned int) (dens * 255.); + } + } + for (ir = 0; ir < nycell; ir++) + { + int ic; + for (ic = 0; ic < im->nx * nxcell; ic++) + fprintf(fp, "%d ", rowp[ic]); + fprintf(fp, "\n"); + } + } + sys_free(rowp, "sdf2img"); + + fclose(fp); +} + + +#ifdef HAVE_PNG +void +sdf2d_to_png (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax) +{ + FILE *fp; + png_structp png_ptr; + png_infop info_ptr; + int irow; + unsigned char *rowp; + + rowp = (unsigned char *) sys_alloc(im->nx * nxcell,"sdf2d_to_img"); + if (rowp == NULL) + return; + + if ((fp = fopen (outfile, "wb")) == NULL) + return; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (! png_ptr) + return; + + info_ptr = png_create_info_struct(png_ptr); + if (! info_ptr) + { + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); + fclose(fp); + return; + } + + if (setjmp(png_ptr->jmpbuf)) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + return; + } + + png_init_io(png_ptr, fp); + + png_set_IHDR(png_ptr, info_ptr, im->nx * nxcell, im->ny * nycell, 8, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr, info_ptr); + for (irow = im->ny - 1; irow >= 0; irow--) + { + png_bytep row_pointer; + int icol, ir; + + for (icol = 0; icol < im->nx; icol++) + { + double dens; + int p; + int pos = icol * nxcell; + dens = (im->v[icol][irow] - densmin) / (densmax - densmin); + if (dens < 0) + dens = 0; + else if (dens > 1) + dens = 1; + for (p = pos; p < pos + nxcell; p++) + { + rowp[p] = (unsigned int) (dens * 255.); + } + } + row_pointer = rowp; + for (ir = 0; ir < nycell; ir++) + { + png_write_rows (png_ptr, &row_pointer, 1); + } + } + sys_free(rowp, "sdf2img"); + + png_write_end(png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} +#endif + +#ifdef HAVE_GD +#include "gd.h" +#define N_GRAYSCALE 256 +#endif + +void +sdf2d_to_gif (IMAGE *im, char *outfile, int nxcell, int nycell, double densmin, double densmax) +{ +#ifdef HAVE_GD + gdImagePtr gif; + FILE *out; + int gs_indices[N_GRAYSCALE]; + int i; + int irow; + int lastrow; + unsigned char *rowp; + + rowp = (unsigned char *) sys_alloc(im->nx * nxcell,"sdf2d_to_img"); + if (rowp == NULL) + return; + + gif = gdImageCreate(im->nx * nxcell, im->ny * nycell); + for (i = 0; i < N_GRAYSCALE; i++) + gs_indices[i] = gdImageColorAllocate(gif, i, i, i); + + lastrow = im->ny * nycell - 1; + for (irow = 0; irow < im->ny; irow++) + { + int icol, ir; + int rpos = irow * nycell; + for (ir = rpos; ir < rpos + nycell; ir++) + { + for (icol = 0; icol < im->nx; icol++) + { + double dens; + int ic; + int cpos = icol * nxcell; + dens = (im->v[icol][irow] - densmin) / (densmax - densmin); + if (dens < 0) + dens = 0; + else if (dens > 1) + dens = 1; + for (ic = cpos; ic < cpos + nxcell; ic++) + { + rowp[ic] = (unsigned int) (dens * (double) (N_GRAYSCALE - 1)); + gdImageSetPixel(gif, ic, lastrow - ir, gs_indices[rowp[ic]]); + } + } + } + } + sys_free(rowp, "sdf2img"); + + if ((out = fopen(outfile,"w")) == NULL) + { + fprintf(stderr,"Error opening output file %s for writing\n", outfile); + exit(1); + } + gdImageGif(gif,out); + fclose(out); + gdImageDestroy(gif); +#else + fprintf(stderr, "This version does not support GIF"); +#endif +} + diff --git a/src/sdfinfo.c b/src/sdfinfo.c new file mode 100644 index 0000000..9f406de --- /dev/null +++ b/src/sdfinfo.c @@ -0,0 +1,230 @@ +/***************************************************************************** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: sdfinfo.c,v 1.1 2000/04/28 13:02:44 kevin Exp $ +** $Log: sdfinfo.c,v $ +** Revision 1.1 2000/04/28 13:02:44 kevin +** Initial revision +** +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** 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 +******************************************************************************/ +/* FILE + * sdfinfo.c Display info on sdf files + */ + +#include "ct.h" + +#define O_LABELS 5 +#define O_STATS 6 +#define O_VERBOSE 7 +#define O_HELP 8 +#define O_VERSION 9 +#define O_DEBUG 10 +#define O_NO_STATS 11 +#define O_NO_LABELS 12 + +static struct option my_options[] = +{ + {"labels", 0, 0, O_LABELS}, + {"no-labels", 0, 0, O_NO_LABELS}, + {"stats", 0, 0, O_STATS}, + {"no-stats", 0, 0, O_NO_STATS}, + {"debug", 0, 0, O_DEBUG}, + {"verbose", 0, 0, O_VERBOSE}, + {"help", 0, 0, O_HELP}, + {"version", 0, 0, O_VERSION}, + {0, 0, 0, 0} +}; + +void +usage (const char *program) +{ + fprintf(stdout, "usage: %s infile [OPTIONS]\n", kbasename(program)); + fprintf(stdout, "Analyze an SDF2D file\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " infile Name of input SDF file\n"); + fprintf(stdout, " --display Display image\n"); + fprintf(stdout, " --labels Print image labels (default)\n"); + fprintf(stdout, " --no-labels Do not print image labels\n"); + fprintf(stdout, " --stats Print image statistics (default)\n"); + fprintf(stdout, " --no-stats Do not print image statistics\n"); + fprintf(stdout, " --debug Debug mode\n"); + fprintf(stdout, " --verbose Verbose mode\n"); + fprintf(stdout, " --version Print version\n"); + fprintf(stdout, " --help Print this help message\n"); + exit(1); +} + +int +main (int argc, char *const argv[]) +{ + IMAGE *im; + char *in_file; + int opt_verbose = 0; + int opt_stats = 1; + int opt_labels = 1; + int opt_debug = 0; + + while (1) + { + int c = getopt_long (argc, argv, "", my_options, NULL); + + if (c == -1) + break; + + switch (c) + { + case O_LABELS: + opt_labels = 1; + break; + case O_STATS: + opt_stats = 1; + break; + case O_NO_LABELS: + opt_labels = 0; + break; + case O_NO_STATS: + opt_stats = 0; + break; + case O_VERBOSE: + opt_verbose = 1; + break; + case O_DEBUG: + opt_debug = 0; + break; + case O_VERSION: +#ifdef VERSION + fprintf(stdout, "Version %s\n", VERSION); +#else + fprintf(stderr, "Unknown version number"); +#endif + exit(0); + case O_HELP: + case '?': + usage(argv[0]); + exit(0); + default: + usage(argv[0]); + exit(1); + } + } + + if (optind + 1 != argc) + { + usage(argv[0]); + exit(1); + } + + in_file = argv[optind]; + + im = image_load (in_file); + + if (opt_labels) + { + int nlabels = im->dfp_2d->dfp->num_label; + int i; + + for (i = 0; i < nlabels; i++) + { + SDF_BLK blk; + if (sdf_read_label(&blk.lab, i, im->dfp_2d->dfp) != SDF_OK) + break; + if (blk.lab.label_type == LT_HISTORY) { + fprintf(stdout, "History: %s\n", blk.lab.label_str); + fprintf(stdout, " calc time = %.2f secs\n", blk.lab.calc_time); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } else if (blk.lab.label_type == LT_TITLE) { + fprintf(stdout, "Title: %s\n", blk.lab.label_str); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } else if (blk.lab.label_type == LT_NOTE) { + fprintf(stdout, "Note: %s\n", blk.lab.label_str); + fprintf(stdout, " Timestamp = %s\n", td_str_tmdt(&blk.lab.timedate)); + } + } + } + + if (opt_stats) + { + double minfound = HUGE_VAL, maxfound = -HUGE_VAL; + double mode = 0, mean = 0, stddev = 0; + double spread; + int hist[256]; + int ibin, nbin = 256; + int max_bin, max_binindex; + double maxbin; + int ix, iy; + + maxbin = nbin - 1; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + if (im->v[ix][iy] > maxfound) + maxfound = im->v[ix][iy]; + if (im->v[ix][iy] < minfound) + minfound = im->v[ix][iy]; + mean += im->v[ix][iy]; + } + } + spread = maxfound - minfound; + if (spread == 0) + mode = minfound; + else + { + for (ibin = 0; ibin < nbin; ibin++) + hist[ibin] = 0; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + int b = (int) ((((im->v[ix][iy] - minfound) / spread) * (double) maxbin) + 0.5); + hist[b]++; + } + } + max_binindex = 0; + max_bin = -1; + for (ibin = 0; ibin < nbin; ibin++) + { + if (hist[ibin] > max_bin) + { + max_bin = hist[ibin]; + max_binindex = ibin; + } + } + mode = (((double) max_binindex) * spread / ((double) maxbin)) + minfound; + } + + mean /= im->nx * im->ny; + for (ix = 0; ix < im->nx; ix++) + { + for (iy = 0; iy < im->ny; iy++) + { + double diff = (im->v[ix][iy] - mean); + stddev += diff * diff; + } + } + stddev = sqrt(stddev / (im->nx * im->ny)); + fprintf(stdout,"nx=%d\n", im->nx); + fprintf(stdout,"ny=%d\n", im->ny); + fprintf(stdout,"min=%f\n", minfound); + fprintf(stdout,"max=%f\n", maxfound); + fprintf(stdout,"mean=%f\n", mean); + fprintf(stdout,"mode=%f\n", mode); + fprintf(stdout,"stddev=%f\n", stddev); + } + + return (0); +}