Compare commits

...
2 Commits
Author SHA1 Message Date
Christopher Sean Morrison 8aecc3d872 remove the rel-5-0beta cvs-to-svn relic as it's not actually the 5.0 beta release. the rel-5-0-beta tag has that so this one that just has tcl/tk can get gone. (svn branch delete)
svn:revision:46344
svn:tag:rel-5-0beta
svn:account:brlcad
2011-08-23 16:30:42 +00:00
cvs-fast-export e5f4f52e05 Synthetic commit for incomplete tag rel-5-0beta
svn:revision:16626
cvs:account:cvs-fast-export
1999-05-21 13:05:40 +00:00
2342 changed files with 0 additions and 873070 deletions
-65
View File
@@ -1,65 +0,0 @@
The US Army BRL-CAD Develoment Team would like to take this opportunity
to thank the many people and organizations who have contributed code or
suggestions for improving the BRL-CAD Package:
Sun Microsystems (William C. Lindemann)
mged/dm-sun.c
Sun Microsystems (Timothy G. Smith, Christopher J. Jackson, and James D. Fiori)
Substantial fixes to ease Solaris 2.X porting
24-bit LIBFB support
New improved XGL support for Solaris
University of Alabama in Huntsville
Research Institute, RI E-47
Sparkman DR NW
Huntsville, AL 35899
POC: Mark Huston Bowden or M. Shane Strickland
mged/hideline.c Hidden line removal
mged/dm-hp.c HP2397A terminal
mged/m-ps390.c color version for serial line connection
mged/dm-pss.c gsr routines
util/pl-hpgl.c convert UNIX-plot file to HP plotter language
Geometric Solutions, Inc (Christopher T. Johnson) <cjohnson@camelot.com>
Paladin Software
Cray Research, Inc.
halftone/*
remrt/rtsrv control support, movie speed ups, extra commands
A/UX support
mged push support, articulation support, animation support
located awf for brlman support.
some plotting tools
bug fixes
too many dinner time bug reports
format converter support (librt/cv_* routines), CV program
scriptsort
Geometric Solutions: reed@camelot.com (Harry J. Reed)
havoc.g
tank-car.g
t62a.g
Manchester-Computing-Centre, UK (Terry Hewitt)
Computer Graphics Unit, MCC" <HEWITT@vmsfe.mcc.ac.uk>
and
Mario Brand <mgbk1@tnofel.fel.tno.nl>
Support for BRL-CAD on HP-9000/730:
machinetype.sh, Cakefile.defs, libplot3/htond.c
Bill Laut (Gull Island Consultants, Inc.)
P.O. Box 627, Muskegon, MI 49440
rt/sh_marble.c -- substantial enhancements
rt/sh_wood.c -- a completely new shader
rt/light.h enhancements
rt/sh_light.c enhancements for more easily aimable lights.
Henry Spencer
Regular expression library
John Ousterhout <john.ousterhout@eng.sun.com>
Tcl/Tk
-14
View File
@@ -1,14 +0,0 @@
/*
* Top level Cakefile.
*
* This Cakefile serves the same purpose as the top level Makefile,
* ie, to run the "gen.sh" script with the given argument.
*
* $Header$
*/
%&:
/bin/sh gen.sh %
all&::
/bin/sh gen.sh
-2194
View File
File diff suppressed because it is too large Load Diff
-92
View File
@@ -1,92 +0,0 @@
/*
* C A K E F I L E . L I B
*
* Cakefile for building a single library archive.
* Symbol PRODUCTS should be name of a single library
*
* Author -
* Michael John Muuss
*
* Source -
* SECAD/VLD Computing Consortium, Bldg 394
* The U. S. Army Ballistic Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5066
*
* Distribution Status -
* Public Domain, Distribution Unlimitied.
*
* $Header$
*/
#ifndef PRODUCTS
# include "Symbol PRODUCTS required to make library"
#endif
#ifndef SRCDIR
# include "Symbol SRCDIR required"
#endif
#ifndef OBJ
# include "Symbol OBJ required"
#endif
#ifndef VERSION_VARIABLE
# include "Symbol VERSION_VARIABLE required"
#endif
#ifndef LIBRARY_TITLE
# include "Symbol LIBRARY_TITLE required"
#endif
#ifndef EXTRA_OBJ
# define EXTRA_OBJ /**/
#endif
#ifndef EXTRA_SETUP
# define EXTRA_SETUP /**/
#endif
#ifndef EXTRA_OBJ_NO_DEPENDENCY
# define EXTRA_OBJ_NO_DEPENDENCY /**/
#endif
#ifndef LIB_FLAGS
# define LIB_FLAGS /**/
#endif
#if !defined(BUILD_LIBRARY)
PRODUCTS:: EXTRA_OBJ OBJ
newvers.sh VERSION_VARIABLE LIBRARY_TITLE
CC CFLAGS -c vers.c
rm -f PRODUCTS; EXTRA_SETUP
AR r PRODUCTS OBJ EXTRA_OBJ EXTRA_OBJ_NO_DEPENDENCY vers.o
RANLIB PRODUCTS
/* If RANLIB is specified, be sure it is run when installing libraries */
# define AFTERINSTALL RANLIB
#else
/* Shared library support.
* Can't list SHARED_PRODUCT in 'rm' command, or will get wrong version number.
* (Cake won't re-run the LIBVERS shell script)
* If non-null, LIBVERS will start with a leading dot.
* Note that the RM command zaps anything starting with PRODUCTS.
* Note that if you have shared libraries, you better have symlinks.
*/
# define SHARED_PRODUCT PRODUCTS''[[LIBVERS]]
PRODUCTS&:: EXTRA_OBJ OBJ
newvers.sh VERSION_VARIABLE LIBRARY_TITLE
CC CFLAGS -c vers.c
rm -f PRODUCTS*; EXTRA_SETUP
BUILD_LIBRARY SHARED_PRODUCT OBJ EXTRA_OBJ EXTRA_OBJ_NO_DEPENDENCY vers.o
sharedliblink.sh SHARED_PRODUCT
/* Use this opportunity to build the symlink on install */
# define AFTERINSTALL sharedliblink.sh
#endif
%.o&: SRCDIR,,%,o if exist ../SRCDIR/%.c
%9,,%,o&: ../%9/%.c HDR_DEP9 if exist ../%9/%.c
CC CFLAGS LIB_FLAGS -c ../%9/%.c
/* Override the modes for the library */
#undef BINDIR
#undef BINPERM
#define BINDIR LIBDIR
#define BINPERM LIBPERM
-48
View File
@@ -1,48 +0,0 @@
/*
* C A K E F I L E . P R O G
*
* Like Cakefile.lib, this is the common part for compiling programs.
*
* Authors -
* Michael John Muuss
* Bob Parker
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Status -
* Public Domain, Distribution Unlimitied.
*
* $Header$
*/
/* Default rule */
everything&:: PRODUCTS
%.o: ../SRCDIR/%.c HDR_DEP if exist ../SRCDIR/%.c
@rm -f ./%.o
CC CFLAGS -c ../SRCDIR/%.c
%.o: ../SRCDIR/%.f if exist ../SRCDIR/%.f
@rm -f ./%.o
FC FFLAGS -c ../SRCDIR/%.f
/* There is a conflict here: When debugging, it's nice to
* be able to examine the intermediate .c file that LEX and YACC produce.
* When trying to port to a new platform, those leftovers can "trick"
* the unwary.
*/
/* Non-ANSI compilers can't take tab-# */
%.o: ../SRCDIR/%.l if exist ../SRCDIR/%.l
-rm -f ./%.c ./%.o
LEX -t LEX_OPTS ../SRCDIR/%.l | sed -e 's/^[ ]#/#/' > ./%.c
if test `wc -l < ./%.c` -lt 2; then rm -f ./%.c; exit 1; fi
CC CFLAGS -I. -c ./%.c
%.o: ../SRCDIR/%.y if exist ../SRCDIR/%.y
-rm -f ./%.c ./%.h ./%.o
YACC YACC_OPTS ../SRCDIR/%.y
mv ./y.tab.c ./%.c
CC CFLAGS -I. -c ./%.c
-266
View File
@@ -1,266 +0,0 @@
/*
* C A K E F I L E . R U L E S
*/
/*
* Patterns to handle the installation and uninstallation
* of products, manuals, and manual stubs.
* This is complicated by the fact that not all directories
* will contain all three types of items.
*/
#define MAN_EXISTS {{ls ../SRCDIR|grep -s .MANSECTION'$'}}
#define STUB_EXISTS {{ls ../SRCDIR|grep -s .MANSECTION.stub'$'}}
#define ARG_EXISTS {{ARGS="%"; test '%' != "$ARGS" -o -f %}}
/* Format sources for printing on stdout. Use macro to bypass ANSI cpp "bug" */
#define PRINT_STUFF [[SUB X X.print ../SRCDIR/Cakefile ]] \
[[SUB X X.print ../SRCDIR/''*.[h''MANSECTION] ]] \
[[SUB X X.nroff ../SRCDIR/''*.MANSECTION ]] \
[[SUB X ../SRCDIR/X''SRCSUFF.print FILES]]
print&: PRINT_SUFF
%.print&: do-%.print if ARG_EXISTS
%.print&: if not ARG_EXISTS
do-%.print&:
@pr %
/*
*/
nroff&: do-nroff if MAN_EXISTS
nroff&: if not MAN_EXISTS
do-nroff&: [[SUB X X.nroff ../SRCDIR/''*.MANSECTION ]]
%.nroff&: ../SRCDIR/%
@nroff -Tlp -man ../SRCDIR/%
/*
* Typeset all the non-stub manual pages. Do them all at once,
* to prevent lots of extra header sheets on the printer
*
* do-typeset-a creates the file "troff.out" with the macros in it
* %.troff adds each manual page to "troff.out"
*/
typeset&: do-typeset if MAN_EXISTS
typeset&: if not MAN_EXISTS
do-typeset&: do-typeset-a troff.out
( TYPESET_MAN2 ) < troff.out
@rm -f troff.out
do-typeset-a&:
TYPESET_MAN0 TYPESET_MAN1 > troff.out
troff.out&: [[SUB X X.troff ../SRCDIR/''*.MANSECTION ]]
%.troff&: if ARG_EXISTS
TYPESET_MAN0 % >> troff.out
#define SRC_LIST `SUB X ../SRCDIR/X''SRCSUFF FILES`
lint&:
LINT LFLAGS -I''INCDIR SRC_LIST LLIBES > SRCDIR.lint
tags: [[echo SRC_LIST]]
ctags SRC_LIST
TAGS: [[echo SRC_LIST]]
etags SRC_LIST
flow&: [[echo SRC_LIST]]
cflow -I''INCDIR SRC_LIST > SRCDIR.flow
xref&: [[echo SRC_LIST]]
cxref -c -s -w132 -I''INCDIR SRC_LIST > SRCDIR.xref
compare&: [[SUB X X.compare PRODUCTS]]
%.compare&: %
cmp BINDIR/% %
#if !defined(DONT_INSTALL)
uninstall&: uninstall-prod uninstall-man uninstall-stub
#else
uninstall&:
#endif
#ifdef PRODUCTS
uninstall-prod&: [[SUB X X.uninstall-prod PRODUCTS]]
#else
uninstall-prod&:
#endif
%.uninstall-prod&:
rm -f BINDIR/% BINDIR/%.bak
uninstall-man&: do-uninstall-man if MAN_EXISTS
uninstall-man&: if not MAN_EXISTS
do-uninstall-man&: [[SUB ../SRCDIR/X X.ui-man ../SRCDIR/''*.MANSECTION]]
%.ui-man&:
rm -f MANDIR''MANSECTION/% MANDIR''MANSECTION/%.bak
uninstall-stub&: do-uninstall-stub if STUB_EXISTS
uninstall-stub&: if not STUB_EXISTS
do-uninstall-stub&: [[SUB ../SRCDIR/X.stub X.uninstall-stub ../SRCDIR/''*.stub]]
%.uninstall-stub&:
rm -f MANDIR''MANSECTION/% MANDIR''MANSECTION/%.bak
#if !defined(EXTRA_INSTALL_TARGETS)
# define EXTRA_INSTALL_TARGETS /**/
#endif
#if !defined(DONT_INSTALL)
install&: install-prod install-man install-stub
install-nobak&: install-prod-nobak install-man install-stub
#else
install&:
install-nobak&:
#endif
#if defined(SHARED_PRODUCT)
install-prod&: [[SUB X X.iprod SHARED_PRODUCT]] EXTRA_INSTALL_TARGETS
install-prod-nobak&: [[SUB X X.iprod-nobak SHARED_PRODUCT]] EXTRA_INSTALL_TARGETS
#else
# if defined(PRODUCTS)
install-prod&: [[SUB X X.iprod PRODUCTS]] EXTRA_INSTALL_TARGETS
install-prod-nobak&: [[SUB X X.iprod-nobak PRODUCTS]] EXTRA_INSTALL_TARGETS
# else
install-prod&:
install-prod-nobak&:
# endif
#endif
/* Here is where we depend on having /bin/sh as the shell */
%.iprod&: %
@echo ......checking % 1>&2 ; \
if cmp -s BINDIR/% %; \
then exit 0; fi; \
mv -f BINDIR/% BINDIR/%.bak 2>/dev/null; \
if INS % BINDIR/%; \
then if test x''AFTERINSTALL != x'AFTERINSTALL'; \
then AFTERINSTALL BINDIR/%; fi; \
echo "++++++INSTALLED" BINDIR/% 1>&2; \
chmod BINPERM BINDIR/%; \
fi
%.iprod-nobak&: %
@echo ......checking % 1>&2 ; \
if cmp -s BINDIR/% %; \
then exit 0; fi; \
rm -f BINDIR/% 2>/dev/null; \
if INS % BINDIR/%; \
then if test x''AFTERINSTALL != x'AFTERINSTALL'; \
then AFTERINSTALL BINDIR/%; fi; \
echo "++++++INSTALLED" BINDIR/% 1>&2; \
chmod BINPERM BINDIR/%; \
fi
install-man&: do-install-man if MAN_EXISTS
install-man&: if not MAN_EXISTS
do-install-man&: [[SUB ../SRCDIR/X X.i-man ../SRCDIR/''*.MANSECTION ]]
%.i-man&: ../SRCDIR/%
@if cmp -s MANDIR''MANSECTION/% ../SRCDIR/%; \
then exit 0; fi; \
mv -f MANDIR''MANSECTION/% MANDIR''MANSECTION/%.bak 2>/dev/null; \
if INS ../SRCDIR/% MANDIR''MANSECTION/%; \
then echo "++++++INSTALLED" MANDIR''MANSECTION/% 1>&2; \
chmod MANPERM MANDIR''MANSECTION/%; \
fi
install-stub&: do-install-stub if STUB_EXISTS
install-stub&: if not STUB_EXISTS
do-install-stub&: [[SUB ../SRCDIR/X.stub X.install-stub ../SRCDIR/''*.stub]]
%.install-stub&: ../SRCDIR/%.stub
@if cmp -s MANDIR''MANSECTION/% ../SRCDIR/%.stub; \
then exit 0; fi; \
mv -f MANDIR''MANSECTION/% MANDIR''MANSECTION/%.bak 2>/dev/null; \
if INS ../SRCDIR/%.stub MANDIR''MANSECTION/%; \
then echo "++++++INSTALLED" MANDIR''MANSECTION/% 1>&2; \
chmod MANPERM MANDIR''MANSECTION/%; \
fi
/*
* Force installation of copies of all sources,
* whether configured in or not, into the distribution tree.
*/
#ifndef STATIC_PRODUCTS
# define STATIC_PRODUCTS /**/
#endif
#ifdef NFS
#define INSTALL_PATTERNS STATIC_PRODUCTS \
../SRCDIR/Cakefile ../SRCDIR/\\\\*.[hcsfyl] \
../SRCDIR/\\\\*.sh \
../SRCDIR/\\\\*.MANSECTION ../SRCDIR/\\\\*.MANSECTION.stub \
../SRCDIR/\\\\*.doc
#else
#define INSTALL_PATTERNS STATIC_PRODUCTS \
./Cakefile \\\\*.[hcsfyl] \\\\*.sh \
\\\\*.MANSECTION \\\\*.MANSECTION.stub \\\\*.doc
#endif
/* inst-dist is never run automatically, it has to be run by hand. */
/* inst-dist is run from gen.sh as part of the final packaging of a distribution */
inst-dist&: dist-clobber [[SUB X X.do-inst-dist INSTALL_PATTERNS]]
dist-clobber&:
-rm -fr DISTRIBUTION/SRCDIR
mkdir DISTRIBUTION/SRCDIR; chmod 775 DISTRIBUTION/SRCDIR
%.do-inst-dist&: %.inst-dist if ARG_EXISTS
%.do-inst-dist&: if not ARG_EXISTS
%.inst-dist&:
-INS % DISTRIBUTION/SRCDIR/.
#ifndef EXTRA_CLEAN
# define EXTRA_CLEAN /**/
#endif
/*
* clean remove all .o files and by-products
* noprod remove the final executables
* clobber perform clean & noprod
*/
clobber&: clean noprod
clean&:
-rm -f core *~ *.o EXTRA_CLEAN SRCDIR.out SRCDIR.err SRCDIR.xref SRCDIR.flow SRCDIR.lint
#if defined(LIBRARY_TITLE)
/*
* The asterisk is to glob all the variations of (shared) library names.
* This depends on the fact that for libraries, PRODUCTS is a single name,
* not a list of file names, and that there will be no source file called
* PRODUCTS.c, e.g., no librt.c file for making librt.so.10.
*/
noprod&:
-rm -f PRODUCTS*
#else
noprod&:
-rm -f PRODUCTS
#endif
#ifdef never
/*
* Insist that, by default, Cake work on making the products.
* THIS SHOULD BE THE LAST THING CAKE SEES!
* The double-colon marks this as the main target.
*/
"!MAINCAKE!"&:: PRODUCTS
#endif
-22
View File
@@ -1,22 +0,0 @@
This software was developed by and is proprietary to the United States
Government, and any use of the software without the written permission
of the Ballistic Research Laboratory is strictly prohibited. Any
unauthorized use of the software will be construed as an infringement of
the Government's rights and will subject the unauthorized user to
action(s) for infringement damages. (BRL MFR 380-15, Feb-88)
The terms and conditions for the use of this software are detailed
in your distribution agreement.
Please note that portions of this software and the associated databases
and images are Copyright (C) 1985, 1986, 1987, 1988, 1989 by the United
States Army. Unauthorized redistribution in any form is prohibited.
Recipients of this distribution are authorized unlimited use within
their corporation, organization, or agency.
There is no warranty or other guarantee of fitness for this software,
it is provided solely "as is". Bug reports or fixes must be sent
to BRL, which may or may not act on them.
The software in the "contributed" directory is Public Domain, Distribution
Unlimited. In addition, certain other modules in the BRL-CAD package
bear this designation. Files so marked are available for unlimited use.
-22
View File
@@ -1,22 +0,0 @@
This software was developed by and is proprietary to the United States
Government, and any use of the software without the written permission
of the Ballistic Research Laboratory is strictly prohibited. Any
unauthorized use of the software will be construed as an infringement of
the Government's rights and will subject the unauthorized user to
action(s) for infringement damages. (BRL MFR 380-15, Feb-88)
The terms and conditions for the use of this software are detailed
in your distribution agreement.
Please note that portions of this software and the associated databases
and images are Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991 by the United
States Army. Unauthorized redistribution in any form is prohibited.
Recipients of this distribution are authorized unlimited use within
their corporation, organization, or agency.
There is no warranty or other guarantee of fitness for this software,
it is provided solely "as is". Bug reports or fixes must be sent
to BRL, which may or may not act on them.
The software in the "contributed" directory is Public Domain, Distribution
Unlimited. In addition, certain other modules in the BRL-CAD package
bear this designation. Files so marked are available for unlimited use.
-28
View File
@@ -1,28 +0,0 @@
Re-distribution of this software is restricted, as described in your
"Statement of Terms and Conditions for the Release of The BRL-CAD
Package" agreement.
Portions of this software and the associated databases and images are
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1994 by the United
States Army in all countries except the USA. Unauthorized redistribution
in any form is prohibited. Recipients of this distribution are
authorized unlimited use within their corporation, organization, or
agency.
The mark "BRL-CAD" is a Registered Trademark of the United States Army.
All rights reserved.
There is no warranty or other guarantee of fitness for this software,
it is provided solely "as is". Bug reports or fixes must be sent
to ARL, which may or may not act on them.
This software was developed by and is proprietary to the United States
Government, and any use of the software without the written permission
of the US Army Research Laboratory is strictly prohibited. Any
unauthorized use of the software will be construed as an infringement of
the Government's rights and will subject the unauthorized user to
action(s) for infringement damages. (BRL MFR 380-15, Feb-88)
The software in the "contributed" directory is Public Domain, Distribution
Unlimited. In addition, certain other modules in the BRL-CAD package
bear this designation. Files so marked are available for unlimited use.
-28
View File
@@ -1,28 +0,0 @@
Re-distribution of this software is restricted, as described in your
"Statement of Terms and Conditions for the Release of The BRL-CAD
Package" agreement.
Portions of this software and the associated databases and images are
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1994, 1995 by the United
States Army in all countries except the USA. Unauthorized redistribution
in any form is prohibited. Recipients of this distribution are
authorized unlimited use within their corporation, organization, or
agency.
The mark "BRL-CAD" is a Registered Trademark of the United States Army.
All rights reserved.
There is no warranty or other guarantee of fitness for this software,
it is provided solely "as is". Bug reports or fixes must be sent
to ARL, which may or may not act on them.
This software was developed by and is proprietary to the United States
Government, and any use of the software without the written permission
of the US Army Research Laboratory is strictly prohibited. Any
unauthorized use of the software will be construed as an infringement of
the Government's rights and will subject the unauthorized user to
action(s) for infringement damages. (BRL MFR 380-15, Feb-88)
The software in the "contributed" directory is Public Domain, Distribution
Unlimited. In addition, certain other modules in the BRL-CAD package
bear this designation. Files so marked are available for unlimited use.
-78
View File
@@ -1,78 +0,0 @@
#################################################################
# #
# Makefile #
# #
# The top-level Makefile for the BRL CAD Software Distribution #
# #
# This exists mostly as a convienience, so folks can #
# type "make install" and such like, and get the expected #
# results, even in the face of the rather complex mechanism. #
# Thus, we make Make into a simple front-end for gen.sh #
# #
# Author - #
# Michael John Muuss #
# #
# Source - #
# SECAD/VLD Computing Consortium, Bldg 394 #
# The U. S. Army Ballistic Research Laboratory #
# Aberdeen Proving Ground, Maryland 21005-5066 #
# #
# $Header$ #
# #
#################################################################
SHELL = /bin/sh
# Main rule (default):
all:
-@sh gen.sh all
help:
-@sh gen.sh help
benchmark:
-@sh gen.sh $@
depend:
-@sh gen.sh $@
install:
-@sh gen.sh $@
inst-man:
-@sh gen.sh $@
uninstall:
-@sh gen.sh $@
inst-dist:
-@sh gen.sh $@
clean:
-@sh gen.sh $@
noprod:
-@sh gen.sh $@
clobber:
-@sh gen.sh $@
lint:
-@sh gen.sh $@
ls:
-@sh gen.sh $@
print:
-@sh gen.sh $@
typeset:
-@sh gen.sh $@
checkin:
-@sh gen.sh $@
dist:
-@sh gen.sh $@
arch:
-@sh gen.sh $@
mkdir:
-@sh gen.sh $@
relink:
-@sh gen.sh $@
rmdir:
-@sh gen.sh $@
tcl:
-@sh gen.sh $@
install-tcl:
-@sh gen.sh $@
tclIndex:
-@sh gen.sh $@
tags:
-@sh gen.sh $@
TAGS:
-@sh gen.sh $@
-451
View File
@@ -1,451 +0,0 @@
#################################################################
# #
# Makefile.defs #
# #
# This Makefile contains definitions common to most of the #
# software packages contained in this distribution. #
# Combined with Makefile.rules and a directory-specific #
# Makefile.loc to create full MAKE input. #
# #
# Each source directory contains a Makefile with these #
# contents: #
# #
#everything: #
# make $(MFLAGS) -$(MAKEFLAGS) \ #
# -f ../Makefile.defs -f Makefile.loc \ #
# -f ../Makefile.rules #
#.DEFAULT: #
# make $(MFLAGS) -$(MAKEFLAGS) \ #
# -f ../Makefile.defs -f Makefile.loc \ #
# -f ../Makefile.rules $@ #
# #
# so that the local rules and definitions for each directory #
# are combined with the common rules and definitions. #
# #
# Author - #
# Michael John Muuss #
# #
# Source - #
# SECAD/VLD Computing Consortium, Bldg 394 #
# The U. S. Army Ballistic Research Laboratory #
# Aberdeen Proving Ground, Maryland 21005 #
# #
# Acknowledgements - #
# This Makefile draws heavily on Doug Gwyn's #
# VLD Standard Makefile, and Doug Kingston's #
# MMDF Global Makefile. #
# #
# $Header$ #
# #
#################################################################
#################################################################
# #
# Operating System Definition and Compiler Flags #
# #
# Either "BSD" or "SYSV" *MUST* be defined #
# #
# Oddball compiler/loader directives should also go here #
# On parallel machines, if h/machine.h does not define #
# the PARALLEL flag, it should be done here. #
# #
#################################################################
#VAX#SYSTEM = -DBSD
#SYSV#SYSTEM = -DSYSV
#VLD#SYSTEM = -DSYSV -DVLDSYSV
# Silicon Graphics, -Zf if Weitek FP chip installed
#SGI#SYSTEM = -DSYSV -Zf
#SGI#SYSTEM = -DSYSV
#ALLIANT#SYSTEM = -DBSD -ce
#GOULD#SYSTEM = -DBSD -m 8
#XMP#SYSTEM = -DSYSV -DPARALLEL
#XMP2.1#SYSTEM = -DSYSV -DPARALLEL -holevel_0
#CRAY2#SYSTEM = -DSYSV -DPARALLEL -Dcray
# Sun3, select correct floating point flag, or -fswitch if unsure (slower)
#SUN3#SYSTEM = -DBSD -f68881
#SUN3#SYSTEM = -DBSD -ffpa
#SUN3#SYSTEM = -DBSD -fswitch
#PYRAMID#SYSTEM = -DBSD -Dvoid=int
#ULTRIX1#SYSTEM = -DBSD -Dvoid=int
#################################################################
# #
# System-Version information, for special handling within one #
# type of $SYSTEM. #
# #
# Currently meaningful settings are: #
# #
# SGI34 SGI release 3.4 and below, with EXCELAN TCP. #
# SGI35 SGI release 3.5 and above, with real TCP. #
# UNICOS20 Cray UNICOS 2.0, with TCP #
# SUN3 SUN UNIX version 3.2 or above #
# #
#################################################################
#SGI#SYSVERS = SGI34
#SGI#SYSVERS = SGI35
#4D#SYSVERS = 4D32
#XMP#SYSVERS = UNICOS20
#CRAY2#SYSVERS = UNICOS20
#SUN#SYSVERS = SUN3
#################################################################
# #
# Definitions specific to one portion of the CAD distribution, #
# but collected here for ease of configuration #
# #
#################################################################
#################################################################
# #
# Configuration for libpkg #
# #
#################################################################
#SGI34#LIBPKG_CONFIG = -I/usr/include/EXOS -DSGI_EXCELAN
#SGI35#LIBPKG_CONFIG = -I/usr/include/bsd -DBSD
#4D32#LIBPKG_CONFIG = -I/usr/include/bsd -DBSD
#XMP#LIBPKG_CONFIG = -I/usr/win-include -DBSD -DSHORT_IDENT -DCRAY
#CRAY2#LIBPKG_CONFIG = -I/usr/win-include -DBSD -DSHORT_IDENT -DCRAY
#################################################################
# #
# Configuration for remrt #
# #
#################################################################
#SGI34#REMRT_CONFIG = -I/usr/include/EXOS -DSGI_EXCELAN
#SGI35#REMRT_CONFIG = -I/usr/include/bsd -DBSD
#4D32#REMRT_CONFIG = -I/usr/include/bsd -DBSD
#XMP#REMRT_CONFIG = -I/usr/win-include -DBSD -DSHORT_IDENT -DCRAY
#CRAY2#REMRT_CONFIG = -I/usr/win-include -DBSD -DSHORT_IDENT -DCRAY
#################################################################
# #
# Configuration for rfbd #
# #
#################################################################
#SGI35#RFBD_CONFIG = -I/usr/include/bsd -DBSD
#4D32#RFBD_CONFIG = -I/usr/include/bsd -DBSD
#################################################################
# #
# Configuration for libfb #
# #
# Specify all OPTIONAL framebuffer interfaces to attach. #
# Select from: #
# if_remote Network access to remote display #
# if_adage Adage RDS-3000 ("Ikonas") #
# if_sgi SGI IRIS display #
# if_ptty AT&T 5620 w/special Moss layer #
# if_sun SUNView interface #
# if_ug Ultra Graphics device #
# if_rat Raster Technology One/80 (24-bit RGB) #
# if_4d SGI 4D/60T "clover" workstation
# #
# Edit all three LIBFB_* lines below similarly. #
# NOTES: #
# 1) When TCP exists and if_remote is desired, set #
# LIBFB_OBJS = if_remote.o pkg.o #
# to gain access to the PKG routines. #
# #
# 2) For SGI release 3.4 and below, but not 3.5 and above: #
# LIBFB_OBJS = if_remote.o ../libpkg/pkg.o sgiselect.o #
# #
# 3) For SGIs which have MC 68010 CPUs (not Turbos or #
# 30xx machines), be certain to uncomment -DMC_68010, #
# because the default is a 68020 #
# #
LIBFB_CFILES = if_remote.c \
if_ptty.c
#VAX# if_adage.c
#SGI# if_sgi.c
#SUN# if_sun.c
#4D32# if_4d.c
LIBFB_OBJS = if_remote.o pkg.o \
if_ptty.o
#VAX# if_adage.o
#SGI35# if_sgi.o
#SGI34# if_sgi.o sgiselect.o
#SUN# if_sun.o
#4D32# if_4d.o
LIBFB_CONFIG = -DIF_REMOTE \
-DIF_PTTY
#VAX# -DIF_ADAGE
#SGI# -DIF_SGI # -DMC_68010
#SUN# -DIF_SUN
#4D32# -DIF_4D
#USNA# -DIF_ADAGE -DGM256
# #
#################################################################
#################################################################
# #
# Configuration for librt #
# #
# Select one of: #
# timer42 4.2 BSD, 4.3 BSD (Berkeley UNIX) #
# timerunix Generic UNIX, System III, V, etc. #
# timer52brl For BRL's System 5-under-4.n BSD #
# timerhep Denelcor HEP #
# timercray Cray-X/MP UNICOS #
LIBRT_TIMER = timer42
#SYSV#LIBRT_TIMER = timerunix
#XMP#LIBRT_TIMER = timercray
# #
#################################################################
#################################################################
# #
# Configuration for RT #
# #
# Mostly useful for specification of multi-processing #
# versions of libc, etc. #
# #
#XMP#RT_CONFIG = -L/lib/multi -lu
#CRAY2#RT_CONFIG = -lmt
#4D32#RT_CONFIG = -lbsd
# #
#################################################################
#################################################################
# #
# Configuration for mged #
# #
# If you wish MGED usage logging, add #
# -DLOGFILE=/file/name to MGED_CONFIG #
# #
# At present, MGED operates on these types of #
# display hardware by default: #
# dm-plot any UNIX-plot filter #
# dm-tek Tektronix 4014 and family #
# dm-tek4109 Tektronix 4109 #
# and also supports these optional display devices: #
# dm-vg Vector General 3300 #
# dm-mg Megatek 7250 #
# dm-ir SGI IRIS 2400,3030 (uses lib -lgl2) #
# dm-sun SUN 3.2 Pixwin #
# dm-rat Raster Tech One/180,380 #
# dm-rat80 Raster Tech One/80 #
# dm-ps E&S Picture System 300 #
# dm-4d Silicon Graphics 4D/60T
# dm-mer Megatek Merlin 9200 [ Marginal ] #
# dm-sab Saber w/GOPS [ Marginal ] #
# #
# Specify all OPTIONAL display managers to attach. #
# #
#VAX#MGED_CFILES = dm-mg.c dm-vg.c
#VAX#MGED_OBJS = dm-mg.o dm-vg.o
#VAX#MGED_CONFIG = -DDM_MG -DDM_VG
#VAX#MGED_LIBES =
#
#4D32#MGED_CFILES = dm-4d.c
#4D32#MGED_OBJS = dm-4d.o
#4D32#MGED_CONFIG = -G 64 -DDM_4D
#4D32#MGED_LIBES = -lbsd -lgl
#
#SGI#MGED_CFILES = dm-ir.c
#SGI#MGED_OBJS = dm-ir.o
#SGI#MGED_CONFIG = -DDM_IR # -DMC_68010
#SGIXNS#MGED_CONFIG = -DDM_IR -DNONBLOCK # -DMC_68010
#SGI35#MGED_LIBES = -lbsd -lgl2
#SGI34#MGED_LIBES = ../libfb/sgiselect.o -lgl2
# #
#SUN#MGED_CFILES = dm-sun.c
#SUN#MGED_OBJS = dm-sun.o
#SUN#MGED_CONFIG = -DDM_SUNPW
#SUN#MGED_LIBES = -lsuntool -lsunwindow -lpixrect
# #
# Pick the right script for generating the version string: #
# Depends on differing behaviors of "echo" command #
# #
MGED_VERS = newvers.sh
#SYSV#MGED_VERS = newvers5.sh
#VLD#MGED_VERS = newversVLD.sh
# #
#################################################################
#################################################################
# #
# Paths for programs, libraries, etc #
# Defined here to provide "optimal managerial flexibility" #
# #
# Note: Don't add comments after a definition, #
# the extra white space can ruin some of the expansions. #
# #
#################################################################
CC = /bin/cc
#4D32#CC = /usr/bin/cc
#VLD#CC = /usr/5bin/cc
SHELL = /bin/sh
MAKE = /bin/make
# Makefiles to print
MAKEFILE = ../Makefile.defs ./Makefile.loc ../Makefile.rules ./Makefile
# Program to get name of current system
GETHOST = hostname
#SYSV#GETHOST = uname -n
#4D32#GETHOST = hostname
# If BSD42, use ranlib on archives. For SYSV, set to "echo" (except SGI).
RANLIB = ranlib
#SYSV#RANLIB = echo
#VLD#RANLIB = ranlib
#SGI#RANLIB = ranlib
#4D32#RANLIB = ar ts
# Place to install binary executable
BINDIR = /usr/brlcad/bin
#VLD#BINDIR = /vld/bin
# Place to install (and find) libraries
LIBDIR = /usr/brlcad/lib
#VLD#LIBDIR = /vld/lib
# Place to install daemons and other non-user-command type programs
ETCDIR = /usr/brlcad/etc
# Suffix for archives. Won't change for most UNIX machines, but...
ARCH_SUF = a
#XMP#ARCH_SUF = o
# For utilities that wish to USE our libraries, here are the popular ones:
LIBFB = ../libfb.'`sh ../mtype.sh`'/libfb.${ARCH_SUF}
LIBRT = ../librt.'`sh ../mtype.sh`'/librt.${ARCH_SUF}
LIBPLOT = ../libplot3.'`sh ../mtype.sh`'/libplot3.${ARCH_SUF}
LIBRLE = ../librle.'`sh ../mtype.sh`'/librle.${ARCH_SUF}
LIBPKG = ../libpkg.'`sh ../mtype.sh`'/libpkg.${ARCH_SUF}
LIBWDB = ../libwdb.'`sh ../mtype.sh`'/libwdb.${ARCH_SUF}
LIBSPL = ../libspl.'`sh ../mtype.sh`'/libspl.${ARCH_SUF}
LIBTERMLIB = -ltermlib
#XMP#LIBTERMLIB = -lcurses
LIBTERMIO = ../libtermio.'`sh ../mtype.sh`'/libtermio.${ARCH_SUF}
LIBCURSOR = ../libcursor.'`sh ../mtype.sh`'/libcursor.${ARCH_SUF}
LIBSYSV = ../libsysv.'`sh ../mtype.sh`'/libsysv.${ARCH_SUF}
#SYSV#LIBSYSV =
# For strictly serial machines, the Princeton malloc() in libmalloc
# uses address space and physical memory more efficiently than the
# Berkeley/CalTech malloc(), but with the same performance advantage.
# It works well on VAXen and Goulds and SGIs. Sadly, it does not work
# on the SUNs.
# For parallel machines, the vendor's malloc() typically needs to be
# used, to handle parallel stack frame expansion, etc. This is
# significant on the Cray and HEP, and perhaps others.
LIBMALLOC = ../libmalloc/libmalloc.${ARCH_SUF}
#SUN#LIBMALLOC = # Forced to use vendor malloc
#XMP#LIBMALLOC = # Forced to use vendor malloc
#CRAY2#LIBMALLOC = # Forced to use vendor malloc
# Directory within CAD Package for header files
INCDIR = ../h
# Directory where users can find installed copies of header files.
INCLUDE_DIR = /usr/include/brlcad
#VLD#INCLUDE_DIR = /vld/include
# Directory for Manual pages, when ${MANSECTION} appended
MANDIR = /usr/man/man
#SYSV#MANDIR = /usr/man/u_man/man
#VLD#MANDIR = /usr/5lib/man/local/man
# Permissions for files to be installed
BINPERM = 775
MANPERM = 664
LIBPERM = 664
DIRPERM = 775
# Compiler Flags
PROFILE =
CFLAGS = -O ${PROFILE} -I${INCDIR} ${SYSTEM} ${CONFIGDEFS}
#4D#CFLAGS = -O2 ${PROFILE} -I${INCDIR} ${SYSTEM} ${CONFIGDEFS}
# Loader Flags. Note that ${CC} is used to invoke the loader
LDFLAGS = ${SYSTEM} ${PROFILE}
#4D#LDFLAGS = -O2 ${SYSTEM} ${PROFILE}
# Lint Flags
LINT = lint
LFLAGS = -hbvxac ${SYSTEM} ${CONFIGDEFS}
#SYSV#LFLAGS = ${SYSTEM} ${CONFIGDEFS}
# Name of the object module archiver, for use with the loader.
AR = ar
#XMP#AR = ../cray-ar.sh
# Regular libraries. Everybody gets the math library; most need it.
LIBES = -lm
# Lint libraries
LLIBES = -lm
# Program to install executables
INS = cp
# Command string to typeset manual pages
# Usage is: ${TYPESET_MAN1} *.${MANSECTION} ${TYPESET_MAN2}
#
TYPESET_MAN1 = tbl /usr/lib/tmac/tmac.an
TYPESET_MAN2 = | /usr/5lib/troff -Ti300 | /usr/5bin/dimp -t | \
qpr -q im231
#TYPESET_MAN1 = tbl /usr/lib/tmac/tmac.an
#TYPESET_MAN2 = | /usr/5lib/troff -Ti10 | /usr/5bin/di10 -t | \
qpr -q im328-raw
#TYPESET_MAN1 = troff -man
#TYPESET_MAN2 =
#################################################################
# #
# Definition of master source machine, and master distribution #
# directory. Please don't change these values. #
# When the current host is == MASTERHOST, the "make install" #
# rules will also handle the distribution source management. #
# Even if you have lots of disk space, you don't want that #
# to happen. #
# #
#################################################################
MASTERHOST = brl-vgr
DISTRIBUTION = /m/dist
#################################################################
# #
# Variables that will be defined in xxx/Makefile.loc #
# #
#################################################################
# Full names of final products
PRODUCTS = product
# Names of local headers that contribute to product
HEADERS =
# Names of C source files that contribute to product
CFILES = cfiles.c
# Names of Shell files that contribute to product
SHFILES =
# Section of manual to install pages in.
# All the manual pages in a given directory MUST be in the same section.
MANSECTION = 99
# ASCII Test files: input, and expected output
TFILES =
# Any Configuration-specific definitions to pass to ${CC}, ie, -Dfoo=1
CONFIGDEFS =
# Name of directory that holds the sources
SRCDIR = xxx
# If special things (like ranlib) need doing after "make install",
# xxx/Makefile.loc should set AFTERINSTALL=${RANLIB}
AFTERINSTALL = echo
# #
#################################################################
-217
View File
@@ -1,217 +0,0 @@
#################################################################
# #
# Makefile.rules #
# #
# Author - #
# Michael John Muuss #
# #
# Source - #
# SECAD/VLD Computing Consortium, Bldg 394 #
# The U. S. Army Ballistic Research Laboratory #
# Aberdeen Proving Ground, Maryland 21005 #
# #
# $Header$ #
# #
#################################################################
# Define default list of targets to be made
all: ${PRODUCTS}
# Generic SCCS rule:
#.DEFAULT:
# $(GET) $(GFLAGS) -p s.$@ > $@
# touch $@
# This is how to make the product, but may not always apply (eg, libs).
# Also, this construct only works with the SysV make.
#${PRODUCTS}: $$@.o ${OBJS}
# $(CC) -o $@ ${LDFLAGS} $@.o ${OBJS} ${LIBES}
# size $@
# Format sources for printing on stdout.
# The invoker is responsible for diverting to their printer of choice.
print: ${MAKEFILE} ${HEADERS} ${CFILES} ${TFILES}
@pr ${MAKEFILE} ${HEADERS} ${CFILES} ${TFILES} *.${MANSECTION}
@nroff -Tlp -man *.${MANSECTION}
# Don't bother doing the stub pages
typeset:
${TYPESET_MAN1} *.${MANSECTION} ${TYPESET_MAN2}
lint: ${HEADERS} ${CFILES}
${LINT} ${LFLAGS} -I${INCDIR} ${CFILES} ${LLIBES} > ${SRCDIR}.lint
tags: ${HEADERS} ${CFILES}
ctags ${HEADERS} ${CFILES}
flow: ${HEADERS} ${CFILES}
cflow -I${INCDIR} ${CFILES} > ${SRCDIR}.flow
xref: ${HEADERS} ${CFILES}
cxref -c -s -w132 -I${INCDIR} ${CFILES} > ${SRCDIR}.xref
compare: all
for prod in ${PRODUCTS} ; \
do cmp ${BINDIR}/$$prod $$prod; \
done
uninstall: all
-@if test -n "${PRODUCTS}" ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) uninst-prod ; \
fi
-@files=`echo *.${MANSECTION}` ; \
if test "$$files" != '*'.${MANSECTION} ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) uninst-man ; \
fi
-@files=`echo *.${MANSECTION}.stub` ; \
if test "$$files" != '*'.${MANSECTION}.stub ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) uninst-stub ; \
fi
uninst-prod:
-@for prod in ${PRODUCTS} ; \
do rm -f ${BINDIR}/$$prod ${BINDIR}/$$prod.bak 2>/dev/null; \
done
uninst-man:
-@for man in *.${MANSECTION} ; \
do rm -f ${MANDIR}${MANSECTION}/$$man \
${MANDIR}${MANSECTION}/$$man.bak 2>/dev/null ; \
done
uninst-stub:
-@for stub in *.${MANSECTION}.stub ; \
do man=`basename $$stub .stub`; \
rm -f ${MANDIR}${MANSECTION}/$$man \
${MANDIR}${MANSECTION}/$$man.bak 2>/dev/null ; \
done
# Handle all phases of final installation
install: all
-@if test -n "${PRODUCTS}" ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) inst-prod ; \
fi
-@files=`echo *.${MANSECTION}` ; \
if test "$$files" != '*'.${MANSECTION} ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) inst-man ; \
fi
-@files=`echo *.${MANSECTION}.stub` ; \
if test "$$files" != '*'.${MANSECTION}.stub ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) inst-stub ; \
fi
-@sh -c "if test `${GETHOST}` = ${MASTERHOST} ; then $(MAKE) inst-dist; else exit 0 ; fi"
# Install all products
inst-prod: ${PRODUCTS}
-@for prod in ${PRODUCTS} ; \
do if cmp -s ${BINDIR}/$$prod $$prod; \
then echo $$prod unchanged; \
else mv -f ${BINDIR}/$$prod ${BINDIR}/$$prod.bak 2>/dev/null; \
${INS} $$prod ${BINDIR} && \
${AFTERINSTALL} ${BINDIR}/$$prod && \
echo "++++++INSTALLED" ${BINDIR}/$$prod && \
${AFTERINSTALL} ${BINDIR}/$$prod.bak && \
chmod ${BINPERM} ${BINDIR}/$$prod; \
fi \
done
# Install the actual manual pages
inst-man:
-@for man in *.${MANSECTION} ; \
do if cmp -s ${MANDIR}${MANSECTION}/$$man $$man; \
then echo $$man unchanged; \
else mv -f ${MANDIR}${MANSECTION}/$$man \
${MANDIR}${MANSECTION}/$$man.bak 2>/dev/null ; \
${INS} $$man ${MANDIR}${MANSECTION} && \
echo "++++++INSTALLED" ${MANDIR}${MANSECTION}/$$man && \
chmod ${MANPERM} ${MANDIR}${MANSECTION}/$$man; \
fi \
done
# Install the "stub" manual pages, which just source some other page
inst-stub:
-@for stub in *.${MANSECTION}.stub ; \
do man=`basename $$stub .stub`; \
if cmp -s ${MANDIR}${MANSECTION}/$$man $$stub; \
then echo $$man unchanged; \
else mv -f ${MANDIR}${MANSECTION}/$$man \
${MANDIR}${MANSECTION}/$$man.bak 2>/dev/null ; \
${INS} $$stub ${MANDIR}${MANSECTION}/$$man && \
echo "++++++INSTALLED" ${MANDIR}${MANSECTION}/$$man && \
chmod ${MANPERM} ${MANDIR}${MANSECTION}/$$man; \
fi \
done
# It might be better to say ${HEADERS} ${CFILES} ${SFILES},
# but that would miss routines that were not configured in a particular system.
inst-dist:
-rm -fr ${DISTRIBUTION}/${SRCDIR}/*
-${INS} ./Makefile.loc Makefile *.[hcfs] ${SHFILES} \
*.${MANSECTION} *.${MANSECTION}.stub \
*.doc \
${DISTRIBUTION}/${SRCDIR}/.
# running "make clobber" or "make clean noprod" will remove all binary files.
# "clean" is intended to remove .o files and by-products.
# "noprod" is intended to remove the final executables.
# Either can be used without the other, depending on the effect desired.
clobber: clean noprod
clean:
-rm -f core *~ *.o \
${SRCDIR}.out ${SRCDIR}.err ${SRCDIR}.xref \
${SRCDIR}.flow ${SRCDIR}.lint
noprod:
-rm -f ${PRODUCTS}
#
# Automaticly build #include dependencies.
#
# This code can't be simply replaced by the 4.3 BSD "cc -M".
#
# The convention for writing #include directives is:
# #include "./file" gives file in current directory
# #include "/file" gives file at absolute path
# #include "file" gives file in ${INCDIR}
# #include <file> leaves to CPP
#
# Note that there MUST be a SPACE after the "#include" in order to
# be seen; this allows conditional includes (if needed) to be indicated
# by a #include TAB, so as to not cause trouble.
depend:
-@if test -n "${CFILES}" ; \
then $(MAKE) $(MFLAGS) -$(MAKEFLAGS) do-depend ; \
fi
do-depend:
cd ../${SRCDIR}; \
mv -f Makefile.loc Makefile.bak; \
cp Makefile.bak Makefile.loc; \
chmod 664 Makefile.loc; \
for k in ${CFILES}; do \
i=`basename $$k .c`; \
echo $$i.o: ../${SRCDIR}/$$k >>makedep; \
grep '^#include ' /dev/null ../${SRCDIR}/$$k | sed \
-e 's,^../'${SRCDIR}'/,,' \
-e 's,c:[^"]*"\./\([^"]*\)".*,o: \1,' \
-e 's,c:[^"]*"/\([^"]*\)".*,o: /\1,' \
-e 's,c:[^"]*"\([^"]*\)".*,o: '${INCDIR}'/\1,' \
-e '/debug.h/d' \
-e '/c:[^<]*<\(.*\)>/d' \
>>makedep; \
echo ' $$(CC) $$(CFLAGS) -c ../'${SRCDIR}/$$k >>makedep; \
done; \
echo '# DO NOT DELETE THIS LINE -- make depend uses it' >>Makefile.loc; \
echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.loc; \
echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep; \
echo '$$r makedep' >>eddep; \
echo 'w' >>eddep; \
ed - Makefile.loc < eddep; \
rm eddep makedep; \
echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.loc; \
echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.loc; \
echo '# see make depend above' >> Makefile.loc
-154
View File
@@ -1,154 +0,0 @@
.\" $Header$
.\" groff -ms README | print-postscript
.TL
README
.sp
The BRL-CAD Package
.br
Release 4.4
.br
(October-1994)
.RT
.IP "VERSION"
.sp
This document is printed from the README file in the BRL-CAD distribution.
The version in the printed manuals are usually somewhat older
than the version on the actual distribution tape.
When attempting to
install the software, please refer to the documentation
versions actually contained on the distribution tape.
.sp
.IP CONTENTS
.sp
This README file exists only to provide you a brief roadmap to
the contents of the BRL-CAD distribution tape.
The information on how to read the tape,
install and operate the software,
and perform the benchmark tests have become sufficiently large
that they are now each a standalone document.
.sp
Please note that
this distribution package does \fInot\fR include
the various military-specific model
analysis tools such as MUVES, GIFT, SAR, SLAVE, VAST, etc., nor does it
include any military databases.
If you desire to have access to this material,
please contact Keith Applin at (410)-278-6647.
.sp
.IP "INSTALLATION"
.sp
To install the BRL-CAD Package see the instructions in doc/install.doc.
This file includes directions on the best way to read the distribution
tape,
as well as details on how to configure and install the software.
This file also includes directions on how to compile and run
the benchmark tests.
.sp
.IP "BENCHMARK"
.sp
See the paper in doc/benchmark.doc for information on
analyzing the results of the benchmark tests.
Comparisons between various different computers are listed.
.sp
.IP "BACKGROUND MATERIAL"
.sp
For overview information on the whole package, consult
the overview paper in the file papers/overview, and
the brlcad(1) manual page in the file util/brlcad.1.
For a discussion of the significance of this software,
read the paper "Understanding the Preparation and Analysis of Solid
Models", included in the file papers/solid-models.
.sp
.IP "DISTRIBUTION DETAILS"
.sp
This software is governed by a limited distribution agreement.
To obtain a copy of the BRL-CAD Package distribution materials, there
are two options:
.sp
1. Free distribution with no support privileges: Those users with
online access to the InterNet may obtain the BRL-CAD Package via
FTP file transfer, at no cost, after completing and returning a signed
copy of the printed distribution agreement. A blank agreement form is
available only via anonymous FTP from host ftp.arl.mil (address
128.63.16.158) from file "brl-cad/agreement". One printed set of BRL-CAD
documentation will be mailed to you at no cost. No installation
assistance or telephone support will be available.
.sp
2. Full service distribution: The Survivability/Vulnerability
Information Analysis Center (SURVIAC) administers the supported BRL-CAD
distributions and information exchange programs for ARL. Full service
distributions a copy of the full distribution materials on your choice
of magnetic tape media, or you may elect to obtain your copy via FTP.
One printed set of BRL-CAD documentation will be mailed to you.
Software upgrades will be provided at no additional charge,
and you will have access to full technical assistance by phone, FAX,
letter, or E-mail. Agencies of the Federal Government may acquire the
full service distribution with a simple MIPR or OGA funds transfer.
.sp
.nf
For further details, contact:
.sp .5
BRL-CAD Distribution
SURVIAC Aberdeen Satellite Office
1003 Old Philadelphia Road
Suite 103
Aberdeen MD 21001 USA
.fi
.sp .5
or call Ms. Carla Moyer at USA (410)-273-7794, send
E-mail to <cad-dist@arl.mil>, FAX your letter to USA (410)-272-6763,
or write to the above address.
.fi
.sp
.ne 1i
.IP "COMMUNICATION"
.sp
You are invited to participate in the InterNet (aka "ARPANET")
electronic mailing list on the BRL-CAD software, which is called
.sp .5
.ti +1i
<CAD @ ARL.MIL>.
.sp .5
Bug reports and discussions of new features
are the main topics; volume of messages has been light (so far).
Direct your bug reports to this address. Request a subscription by
sending to
.sp .5
.ti +1i
<CAD-REQUEST @ ARL.MIL>.
.sp .5
If you find bugs, please report your experiences via E-mail.
.sp
A variety of information on BRL-CAD is available via the World-Wide-Web.
Papers and documentation can be found at
.sp .5
.ti +1i
http://web.arl.mil/software/brl-cad/
.sp .5
The software repository can be found at
.sp .5
.ti +1i
http://ftp.arl.mil/ftp/brl-cad/
.sp
.IP "FUTURE EVENTS"
.sp
It is expected that new releases of this software will be issued
between once and twice a year.
Information about new releases will be routinely provided
by both paper and electronic mail
to recipients of this software.
If your address changes, please let us
know, so we can update our records.
.sp
.KS
.nf
Best Wishes,
-Mike Muuss
.sp
Leader, Advanced Computer Systems Team
The US Army Research Laboratory
APG, MD 21005-5068 USA
.sp
E-mail: <Mike @ ARL.MIL>
.KE
.fi
-69
View File
@@ -1,69 +0,0 @@
/*
* tab/Cakefile
*/
#define SRCDIR anim
#define PRODUCTS anim_cascade anim_fly anim_hardtrack anim_keyread \
anim_lookat anim_offset anim_orient anim_script \
anim_sort anim_time anim_track anim_turn chan_add \
chan_mult chan_permute \
#define SRCSUFF .c
#define MANSECTION 1
#include "../Cakefile.defs"
#include "../Cakefile.prog"
#define FILES anim_cascade anim_fly anim_hardtrack anim_keyread \
anim_lookat anim_offset anim_orient anim_script anim_sort \
anim-time anim_track anim_turn cattrack chan_add chan_mult \
chan_permute
/* Explicit composition of each product */
anim_cascade: anim_cascade.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_cascade.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_cascade
anim_fly: anim_fly.o LIBBU_DEP
CC LDFLAGS anim_fly.o LIBES LIBBU LIBBU_LIBES -o anim_fly
anim_hardtrack: anim_hardtrack.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_hardtrack.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_hardtrack
anim_keyread: anim_keyread.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_keyread.o LIBBN LIBBU LIBBU_LIBES LIBES -o anim_keyread
anim_lookat: anim_lookat.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_lookat.o LIBBN LIBBU LIBBU_LIBES LIBES -o anim_lookat
anim_offset: anim_offset.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_offset.o LIBBN LIBBU LIBBU_LIBES LIBES -o anim_offset
anim_orient: anim_orient.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_orient.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_orient
anim_script: anim_script.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_script.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_script
anim_sort: anim_sort.o LIBBU_DEP
CC LDFLAGS anim_sort.o LIBES LIBBU LIBBU_LIBES -o anim_sort
anim_time: anim_time.o
CC LDFLAGS anim_time.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_time
anim_track: anim_track.o cattrack.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_track.o cattrack.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_track
anim_turn: anim_turn.o LIBBN_DEP LIBBU_DEP
CC LDFLAGS anim_turn.o LIBRT LIBBN LIBBU LIBBU_LIBES LIBES -o anim_turn
chan_add: chan_add.o
CC LDFLAGS chan_add.o LIBES -o chan_add
chan_mult: chan_mult.o
CC LDFLAGS chan_mult.o LIBES -o chan_mult
chan_permute: chan_permute.o
CC LDFLAGS chan_permute.o LIBES -o chan_permute
#include "../Cakefile.rules"
-187
View File
@@ -1,187 +0,0 @@
.TH ANIM_CASCADE 1 BRL/CAD
.SH NAME
anim_cascade - evaluate movement of an object relative to a moving frame of
reference
.SH SYNOPSIS
.B anim_cascade [-s][-o(f|r|a)] [-(f|r|a)(c|y) # # #] <
.B input.table >
.B output.table
.SH DESCRIPTION
.I Anim_cascade
is designed to enable the user to control the movement of objects relative to
other objects. In the normal mode of operation, the user supplies
the position and orientation of a (possibly moving) frame of reference and
the position
and orientation of an object relative to the frame of reference,
and
.I anim_cascade
produces the absolute position and orientation of the object at each
point in time.
All orientations are specified as yaw, pitch, and roll.
The columns of the input table are:
.sp
time fx fy fz fyaw fpitch froll rx ry rz ryaw rpitch rroll
.sp
and the columns of the output table are:
.sp
time ax ay az ayaw apitch aroll
.sp
Here "f" refers to the frame of reference, "r" refers to the position
and orientation of the object relative to the frame, and "a"
refers to the absolute position and orientation of the object.
.SH OPTIONS
.TP
.B \-or
Output the relative position and orientation.
If this option is specified,
.I anim_cascade
will expect the absolute position and orientation of the frame of
reference and the object as input,
and will produce the position and orientation or the object relative to
the frame as output. The
input columns should be:
.sp
time fx fy fz fyaw fpitch froll ax ay az ayaw apitch aroll
.sp
and the output columns will be:
.sp
time rx ry rz ryaw rpitch rroll
.sp
.TP
.B \-of
Output the frame of reference.
If this option is specified,
.I anim_cascade
will expect the absolute and relative positions and orientations of the
object as input,
and will produce the corresponding frame of reference as output.
The input columns should be:
.sp
time ax ay az ayaw apitch aroll rx ry rz ryaw rpitch rroll
.sp
and the output columns will be:
.sp
time fx fy fz fyaw fpitch froll
.sp
.TP
.B \-fc # # #
Specify a constant position for the frame of reference. The
columns fx, fy, and fz should be omitted from the input table, and the
command-line arguments will be used instead.
This has no effect if used
in conjunction with
.B -of
.TP
.B \-fy # # #
Specify a constant orientation for the frame of reference. The
columns fyaw, fpitch, and froll should be omitted from the input table,
and the command-line arguments will be used instead.
This has no effect if used
in conjunction with
.BR -of .
.TP
.B \-rc # # #
Specify a constant position of the object relative to the frame
of reference. The
columns rx, ry, and rz should be omitted from the input table, and the
command-line arguments will be used instead.
This has no effect if used
in conjunction with
.BR -or .
.TP
.B \-ry # # #
Specify a constant orientation of the object relative to the
frame of reference. The
columns ryaw, rpitch, and rroll should be omitted from the input table,
and the command-line arguments will be used instead.
This has no effect if used
in conjunction with
.BR -or .
.TP
.B \-ac # # #
Specify a constant absolute position for the object. The
columns ax, ay, and az should be omitted from the input table, and the
command-line arguments will be used instead.
This has no effect unless used
in conjunction with
.B -or
or
.BR -of .
.TP
.B \-ay # # #
Specify a constant absolute orientation for the object. The
columns ayaw, apitch, and aroll should be omitted from the input table,
and the
command-line arguments will be used instead.
This has no effect unless used
in conjunction with
.B -or
or
.BR -of .
.TP
.B \-s
Suppress time column. No time column is read or written.
.sp
Note: When all of the input columns are specified with command-line arguments,
then standard input is not read and
only one line of output is produced. The time value will be set to zero,
unless it is suppressed.
.SH EXAMPLES
1. Suppose that you want the virtual camera to pan in a circle around a
moving vehicle, always staying a fixed distance from the vehicle.
There should already exist an animation table with the time, position,
and orientation of the vehicle in each frame. This will be the moving
frame of reference. Next, you should create an animation table which
describes how the camera would need to move if the vehicle stood still
at the origin. The columns of the second animation table should be
appended to the columns of the first table
(using
.IR paste ,
for example), to create the
input table.
.I Anim_cascade
will produce an absolute animation table for
the camera, suitable to use as input to
.IR anim_script :
.sp
anim_cascade < input.table | anim_script -v500 > view.script
.sp
2. Suppose that you have an animation path for an object and you want to
know when it crosses a given oblique plane. You can use the
.B -or
option to
find out what the position of the object is relative to the frame of
reference of the plane. Suppose that the plane is defined by the
equation:
.sp
x + z = 0
.sp
In a frame of reference located at the origin with a pitch of 45
degrees, the x-axis is perpendicular to the given plane.
To convert the absolute animation path into this frame of reference, the command
would be:
.sp
anim_cascade -or -fc 0 0 0 -fy 0 45 0 < absolute.table > relative.table
.sp
Wherever the x coordinate in the output table is positive, the object
lies above the plane.
.sp
3. Suppose that one object is situated at the point (1,2,3) with a yaw,
pitch, and roll of (45, 25, 10). Suppose further that you want to
position a camera so that to the camera, the first object seems to be 10
units straight ahead, facing to the right. You could find the required
position and orientation of the camera with the following command:
.sp
anim_cascade -s -of -ac 1 2 3 -ay 45 25 10 -rc 10 0 0 -ry -90 0 0
.sp
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-293
View File
@@ -1,293 +0,0 @@
/* A N I M _ C A S C A D E . C
*
* Purpose: Given position and orientation of main frame of reference,
* along with the position and orientation of another frame with respect
* to the main frame, give the absolute orientation and position of the
* second frame.
* For example, given the position and orientation of a tank, and of the
* turret relative to the tank, you can get the absolute position and
* orientation of the turret at each time.
* Or, optionally, given position and orientation of main frame of
* reference, and the absolute position and orientation of another frame,
* find the position and orientation of the second frame in terms of the main
* frame of reference. (-i option).
*
* Usage:
* anim_cascade main.table < relative.table > absolute.table
*
* The format of the tables is:
* time x y z yaw pitch roll
* unless specified otherwise by options.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI
#define RTOD 180.000/M_PI
#endif
#define CASCADE_A 0
#define CASCADE_R 1
#define CASCADE_F 2
extern int bu_optind;
extern char *bu_optarg;
vect_t fcenter, fypr, rcenter, rypr, acenter, aypr;
int cmd_fcen, cmd_fypr, cmd_rcen, cmd_rypr, cmd_acen, cmd_aypr;
int output_mode, read_time, print_time;
main (argc,argv)
int argc;
char **argv;
{
int i, val;
fastf_t time, yaw1, pitch1, roll1, yaw2, pitch2, roll2;
vect_t cen1, cen2, cen_ans, ang_ans, rad_ang_ans, rotated;
mat_t m_rot1, m_rot2, m_ans;
FILE *fp;
int one_time, read_cen1, read_cen2, read_rot1, read_rot2;
read_cen1 = read_cen2 = read_rot1 = read_rot2 = 1;
if (!get_args(argc,argv))
fprintf(stderr,"anim_cascade: Argument error.");
switch (output_mode) {
case CASCADE_A:
if (cmd_fcen) {
VMOVE(cen1, fcenter);
read_cen1 = 0;
}
if (cmd_rcen) {
VMOVE(cen2, rcenter);
read_cen2 = 0;
}
if (cmd_fypr){
anim_dy_p_r2mat(m_rot1, fypr[0], fypr[1], fypr[2]);
read_rot1 = 0;
}
if (cmd_rypr){
anim_dy_p_r2mat(m_rot2, rypr[0], rypr[1], rypr[2]);
read_rot2 = 0;
}
break;
case CASCADE_R:
if (cmd_fcen) {
VMOVE(cen1, fcenter);
read_cen1 = 0;
}
if (cmd_acen) {
VMOVE(cen2, acenter);
read_cen2 = 0;
}
if (cmd_fypr){
anim_dy_p_r2mat(m_rot1, fypr[0], fypr[1], fypr[2]);
read_rot1 = 0;
}
if (cmd_aypr){
anim_dy_p_r2mat(m_rot2, aypr[0], aypr[1], aypr[2]);
read_rot2 = 0;
}
break;
case CASCADE_F:
if (cmd_acen) {
VMOVE(cen1, acenter);
read_cen1 = 0;
}
if (cmd_rcen) {
VMOVE(cen2, rcenter);
read_cen2 = 0;
}
if (cmd_aypr){
anim_dy_p_r2mat(m_rot1, aypr[0], aypr[1], aypr[2]);
read_rot1 = 0;
}
if (cmd_rypr){
anim_dy_p_r2mat(m_rot2, rypr[0], rypr[1], rypr[2]);
read_rot2 = 0;
}
break;
default:
break;
}
one_time = (!(read_cen1||read_cen2||read_rot1||read_rot2));
read_time = one_time ? 0 : print_time;
time = 0.0;
val = 3;
while(1){
if (read_time) {
val=scanf("%lf",&time);
if (val < 1) break;
}
if (read_cen1)
val =scanf("%lf %lf %lf",cen1, cen1+1, cen1+2);
if (read_rot1) {
val=scanf("%lf %lf %lf", &yaw1, &pitch1, &roll1);
anim_dy_p_r2mat(m_rot1, yaw1, pitch1, roll1);
}
if (read_cen2) {
val=scanf("%lf %lf %lf", cen2, cen2+1,cen2+2);
}
if (read_rot2) {
val=scanf("%lf %lf %lf", &yaw2, &pitch2, &roll2);
anim_dy_p_r2mat(m_rot2, yaw2, pitch2, roll2);
}
if (val<3) break;
if (output_mode==CASCADE_R) {
anim_tran(m_rot1);
VSUB2(rotated,cen2,cen1);
MAT4X3PNT(cen_ans, m_rot1, rotated);
mat_mul(m_ans, m_rot1, m_rot2);
} else if (output_mode==CASCADE_F) {
anim_tran(m_rot2);
mat_mul(m_ans, m_rot1, m_rot2);
MAT4X3PNT(rotated, m_ans, cen2);
VSUB2(cen_ans, cen1, rotated);
} else {
MAT4X3PNT(rotated, m_rot1, cen2);
VADD2(cen_ans, rotated, cen1);
mat_mul(m_ans, m_rot1, m_rot2);
}
anim_mat2ypr(rad_ang_ans, m_ans);
VSCALE(ang_ans, rad_ang_ans, RTOD);
if (print_time){
printf("%g",time);
}
printf("\t%.12g\t%.12g\t%.12g", cen_ans[0], cen_ans[1], cen_ans[2]);
printf("\t%.12g\t%.12g\t%.12g", ang_ans[0], ang_ans[1], ang_ans[2]);
printf("\n");
if (one_time) break;
}
}
#define OPT_STR "so:f:r:a:"
int get_args(argc,argv)
int argc;
char **argv;
{
int c,d;
output_mode = CASCADE_A;
cmd_fcen = cmd_fypr = cmd_rcen = cmd_rypr = cmd_acen = cmd_aypr = 0;
print_time = 1;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'f':
d = *(bu_optarg);
if (d == 'c'){
sscanf(argv[bu_optind],"%lf",fcenter+0);
sscanf(argv[bu_optind+1],"%lf",fcenter+1);
sscanf(argv[bu_optind+2],"%lf",fcenter+2);
bu_optind += 3;
cmd_fcen = 1;
break;
} else if ( d =='y'){
sscanf(argv[bu_optind],"%lf",fypr+0);
sscanf(argv[bu_optind+1],"%lf",fypr+1);
sscanf(argv[bu_optind+2],"%lf",fypr+2);
bu_optind += 3;
cmd_fypr = 1;
break;
} else {
fprintf(stderr,"anim_cascade: unknown option -f%c\n", d);
}
break;
case 'r':
d = *(bu_optarg);
if (d == 'c'){
sscanf(argv[bu_optind],"%lf",rcenter+0);
sscanf(argv[bu_optind+1],"%lf",rcenter+1);
sscanf(argv[bu_optind+2],"%lf",rcenter+2);
bu_optind += 3;
cmd_rcen = 1;
break;
} else if ( d =='y'){
sscanf(argv[bu_optind],"%lf",rypr+0);
sscanf(argv[bu_optind+1],"%lf",rypr+1);
sscanf(argv[bu_optind+2],"%lf",rypr+2);
bu_optind += 3;
cmd_rypr = 1;
break;
} else {
fprintf(stderr,"anim_cascade: unknown option -r%c\n", d);
}
break;
case 'a':
d = *(bu_optarg);
if (d == 'c'){
sscanf(argv[bu_optind],"%lf",acenter+0);
sscanf(argv[bu_optind+1],"%lf",acenter+1);
sscanf(argv[bu_optind+2],"%lf",acenter+2);
bu_optind += 3;
cmd_acen = 1;
break;
} else if ( d =='y'){
sscanf(argv[bu_optind],"%lf",aypr+0);
sscanf(argv[bu_optind+1],"%lf",aypr+1);
sscanf(argv[bu_optind+2],"%lf",aypr+2);
bu_optind += 3;
cmd_aypr = 1;
break;
} else {
fprintf(stderr,"anim_cascade: unknown option -a%c\n", d);
}
break;
case 'o':
d = *(bu_optarg);
if (d == 'r'){
output_mode = CASCADE_R;
} else if (d == 'f') {
output_mode = CASCADE_F;
} else if (d == 'a') { /* default */
output_mode = CASCADE_A;
} else {
fprintf(stderr,"anim_cascade: unknown option -i%c\n",d);
}
break;
case 's':
print_time = 0;
break;
default:
fprintf(stderr,"anim_cascade: unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-94
View File
@@ -1,94 +0,0 @@
.TH ANIM_FLY 1 BRL/CAD
.SH NAME
anim_fly - make animation table to simulate flying motion
.SH SYNOPSIS
.B anim_fly
.B [-f factor]
.B [-r]
.B [-p integer]
.B [-b max_bank_angle]
.B [-s step]
.B < in.table
.B > out.table
.SH DESCRIPTION
This filter is designed to simulate the motion of an airplane.
Given a four-column table specifying the desired 3D position of the
airplane at each relevant time step,
.I anim_fly
produces a seven-column file
which also includes the orientation of the plane in terms of yaw,
pitch, and roll. The yaw and pitch are manipulated so that
the plane faces the direction of motion, while the roll is used to do
banking.
.SH OPTIONS
.TP
.B -f#
This option specifies a factor to control the severity of the banking.
The best factor is a subjective decision; a good starting point can best
be obtained by using the -b option. Animations representing aircraft
of different scales will need different factors.
If the
slightest curve throws the plane into a 90 degree bank, the factor is
too large; if it doesn't bank enough, the factor is too small. The size
of the best factor varies inversely with the size of the imagined
aircraft plane.
If a factor of 0 is used, there will
be no banking. This would be appropriate for animating a ground
vehicle.
.TP
.B -b#
This option is used to estimate a good value for the -f option. The
parameter is the maximum desired banking angle. Anim_fly then computes
the factor necessary to keep the banking below the specified angle. This
value is returned instead of anim_fly's usual output.
.TP
.B -r
Suppress vertical loop smoothing.
A special case occurs if the aircraft is to perform a vertical
loop. Normally, the algorithm likes to keep the aircraft right-side up.
This would cause the airplane to do an instantaneous 180 roll as it hits
the vertical portion of the loop. To counter this, a capability was
built in which prevents this sudden roll, allowing the aircraft to go
upside-down in a loop situation. This feature can be suppressed with the
.B -r
flag.
.TP
.B -p
Specify the ratio of input rows to output rows, which must be
an integer. The default, of course, is one. The accuracy of the output
depends on having a large number of input lines, which is not usually a
problem in animations, which require a large number of frames per
second, anyway. If a test animation with a small number of frames per
second is being created, the user should still use an input table
with a high number of input rows, reducing the frequency of the output
with the
.B -p
option. For example, if
.B in.table
contains 30 rows for each
second of the animation, then the command:
.sp
anim_fly -f0.001 -p10 < in.table > out.table
.sp
would produce an animation table containing 3 rows for each
second of the animation.
.TP
.B -s
Specify the minimum step size for the discrete-time differentiation. At any
given point on the flight path, the yaw, pitch, and roll are calculated based
on a past point, the current point, and a future point. Normally,
these are consecutive points from the input table. If the time
difference between the points falls below a certain threshold,
then non-consecutive points are used to avoid
numerical instability. The default time threshhold is 0.1 seconds - this
can be raised or lowered using the -s option.
Try raising the threshold if the output orientations experience random
jiter.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-318
View File
@@ -1,318 +0,0 @@
/* A N I M _ F L Y . C
*
* Simulate flying motion, for an airplane or virtual camera.
*
* This filter operates on animation tables. Given the desired position
* of the airplane in each frame, anim_fly produces a table including the
* plane's position and orientation. A "magic factor" should be supplied
* to control the severity of banking. Looping behavior can be toggled
* with another option.
*
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "externs.h"
#include "bu.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define MAXN 100
int estimate_f = 0;
fastf_t max_bank = 0;
fastf_t max_cross = 0;
int loop = 1;
int print_int = 1;
fastf_t magic_factor = 1.0;
fastf_t desired_step = 0.1;
#define PREP -1
#define START 0
#define MIDDLE 1
#define WANE 2
#define END 3
#define STOP 4
main(argc,argv)
int argc;
char **argv;
{
int count, endcount, status, num_read, enn, i, pp;
fastf_t *points, *cur;
fastf_t yaw, pch, rll, stepsize, first[4], second[4];
fastf_t f_prm_0(), f_prm_1(), f_prm_2();
void get_orientation();
yaw = pch = rll = 0.0;
if (!get_args(argc,argv))
fprintf(stderr,"Anim_fly: Get_args error");
/* read first two lines of table to determine the time step used */
/* (a constant time step is assumed throughout the rest of the file)*/
scanf("%lf %lf %lf %lf", first, first+1, first+2, first+3);
scanf("%lf %lf %lf %lf", second, second+1, second+2, second+3);
stepsize = second[0]-first[0];
/* determine n, the number of points to store ahead and behind
* the current point. 2n points are stored, minimum enn=2 */
enn = (int) (desired_step/stepsize);
if (enn>MAXN) enn=MAXN;
if (enn<1) enn=1;
/* allocate storage */
points = (fastf_t *) calloc((3*enn+1)*4, sizeof(fastf_t));
/* read the first 3n points into the storage array*/
VMOVEN(points+4, first, 4);
VMOVEN(points+8, second, 4);
num_read=4; /* in order to pass test if n=1 */
for (cur=points+12; cur<points+(4*(3*enn+1)); cur+=4){
num_read=scanf("%lf %lf %lf %lf", cur,cur+1,cur+2,cur+3);
}
if (num_read<4){
fprintf(stderr,"Anim_fly: Not enough lines in input table.\n");
fprintf(stderr,"Increase number of lines or reduce the minimum stepsize with -s.\n");
fprintf(stderr,"Currently the minumum step size is %g seconds.\n",desired_step);
exit(0);
}
max_cross = 0;
count = 0;
pp = 0;
status = START;
while (status != STOP) {
switch (status) {
case START: /* first n points */
pp += 4;
get_orientation(points+pp,points+pp+4*enn,points+pp+4*2*enn, f_prm_0, &yaw, &pch, &rll);
if (!(count%print_int)&&!estimate_f) {
printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\n",points[pp+0],points[pp+1],points[pp+2],points[pp+3],yaw,pch,rll);
}
if (pp >= 4*enn)
status=MIDDLE;
break;
case MIDDLE: /* middle points (at least one)*/
for (i=0; i<3*enn*4; i++){
VMOVEN(points+(4*i), points+(4*(i+1)), 4);
}
num_read=scanf("%lf %lf %lf %lf", points+(4*(3*enn)),points+(4*(3*enn)+1),points+(4*(3*enn)+2),points+(4*(3*enn)+3));
if (num_read < 4) {
pp = 0;
status = WANE;
}
get_orientation(points,points+(4*enn),points+4*(2*enn), f_prm_1, &yaw, &pch, &rll);
if (!(count%print_int)&&!estimate_f) {
printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\n",points[4*(enn)+0],points[4*(enn)+1],points[4*(enn)+2],points[4*(enn)+3],yaw,pch,rll);
}
break;
case WANE: /* last n - 1 middle points */
pp += 4;
if (pp >= 4*enn){
status = END;
count--;
pp = 0;
break;
}
get_orientation(points+pp,points+pp+4*enn,points+pp+4*2*enn, f_prm_1, &yaw, &pch, &rll);
if (!(count%print_int)&&!estimate_f) {
printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\n",points[4*(enn)+0+pp],points[4*(enn)+1+pp],points[4*(enn)+2+pp],points[4*(enn)+3+pp],yaw,pch,rll);
}
break;
case END: /* last n points */
get_orientation(points+pp,points+pp+4*enn,points+pp+4*2*enn, f_prm_2, &yaw, &pch, &rll);
if (!(count%print_int)&&!estimate_f) {
printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t%.10g\n",points[8*enn+pp+0],points[8*enn+pp+1],points[8*enn+pp+2],points[8*enn+pp+3],yaw,pch,rll);
}
pp += 4;
if (pp >= 4*enn)
status = STOP;
break;
}
count++;
}
/* Return the factor needed to achieve the requested max_bank */
if (estimate_f){
if (max_cross < VDIVIDE_TOL) {
printf("%.10g\n",0.0);
} else {
printf("%.10g\n", 1000.0 * max_bank/max_cross);
}
}
}
void
get_orientation(p0,p1,p2,function, p_yaw, p_pch, p_rll)
fastf_t p0[4],p1[4],p2[4], *p_yaw, *p_pch, *p_rll;
fastf_t (*function)();
{
int i;
fastf_t step,vel[3],accel[3];
fastf_t f_double_prm(),xyz2yaw(),xyz2pch(),bank();
static fastf_t last_yaw, last_pch, last_rll;
static int not_first_time, upside_down;
step = p2[0] - p1[0];
for (i=1;i<4;i++) {
vel[i-1] = (*function)(p0[i],p1[i],p2[i],step);
accel[i-1] = f_double_prm(p0[i],p1[i],p2[i],step);
}
*p_yaw = xyz2yaw(vel);
*p_pch = xyz2pch(vel);
*p_rll = bank(accel,vel);
if (fabs(*p_pch)==90.0) /* don't change yaw if velocity vertical */
*p_yaw = last_yaw;
/* avoid sudden yaw changes in vertical loops */
if (not_first_time&&loop){
if ((fabs(last_yaw - *p_yaw)<181.0)&&(fabs(last_yaw - *p_yaw)>179.0))
upside_down = (upside_down) ? 0 : 1;
if (upside_down)
(*p_rll) += 180;
}
last_yaw = *p_yaw;
last_pch = *p_pch;
last_rll = *p_rll;
not_first_time = 1;
}
/* determine the yaw of the given direction vector */
fastf_t xyz2yaw(d)
fastf_t d[3];
{
fastf_t yaw;
yaw = RTOD*atan2(d[1],d[0]);
if (yaw < 0.0) yaw += 360.0;
return yaw;
}
/* determine the pitch of the given direction vector */
fastf_t xyz2pch(d)
fastf_t d[3];
{
fastf_t x;
x = sqrt(d[0]*d[0] + d[1]*d[1]);
return (RTOD*atan2(d[2],x));
}
/* given the 3-d velocity and acceleration of an imaginary aircraft,
find the amount of bank the aircraft would need to undergo.
Algorithm: the bank angle is proportional to the cross product
of the horizontal velocity and horizontal acceleration, up to a
maximum bank of 90 degrees in either direction. */
fastf_t bank(acc,vel)
fastf_t acc[3],vel[3];
{
fastf_t cross;
cross = vel[1]*acc[0] - vel[0]*acc[1];
if (estimate_f) {
max_cross = ( fabs(cross) > max_cross) ? fabs(cross) : max_cross;
}
cross *= magic_factor;
if (cross > 90) cross = 90;
if (cross < -90) cross = -90;
return cross;
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t) */
fastf_t f_prm_0(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return -(3.0*x0 - 4.0*x1 + x2)/(2*h);
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+h) */
fastf_t f_prm_1(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x2 - x0)/(2*h);
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+2h) */
fastf_t f_prm_2(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x0 - 4.0*x1 + 3.0*x2)/(2*h);
}
/* given f(t), f(t+h), f(t+2*h), and h, calculate f'' */
fastf_t f_double_prm(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x0 - 2.0*x1 + x2)/(h*h);
}
/* code to read command line arguments*/
#define OPT_STR "b:f:p:s:r"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
estimate_f = 0;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'b':
sscanf(bu_optarg,"%lf",&max_bank);
estimate_f = 1;
break;
case 'f':
sscanf(bu_optarg,"%lf",&magic_factor);
magic_factor *= 0.001; /* to put factors in a more reasonable range */
break;
case 'p':
sscanf(bu_optarg,"%d",&print_int);
break;
case 'r':
loop = 0;
break;
case 's':
sscanf(bu_optarg, "%lf", &desired_step);
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-241
View File
@@ -1,241 +0,0 @@
/* A N I M _ F L Y . C
*
* Simulate flying motion, for an airplane or virtual camera.
*
* This filter operates on animation tables. Given the desired position
* of the airplane in each frame, anim_fly produces a table including the
* plane's position and orientation. A "magic factor" should be supplied
* to control the severity of banking. Looping behavior can be toggled
* with another option.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
extern int bu_optind;
extern char *bu_optarg;
int loop = 1;
int print_int = 1;
fastf_t magic_factor = 1.0;
#define PREP -1
#define START 0
#define MIDDLE 1
#define END 2
#define STOP 3
main(argc,argv)
int argc;
char **argv;
{
int count, status, num_read;
fastf_t point0[4],point1[4],point2[4],point3[4], yaw, pch, rll;
fastf_t f_prm_0(), f_prm_1(), f_prm_2();
VSETALL(point0,0.0);
VSETALL(point1,0.0);
VSETALL(point2,0.0);
VSETALL(point3,0.0);
yaw = pch = rll = 0.0;
if (!get_args(argc,argv))
fprintf(stderr,"Anim_fly: Get_args error");
count = -2;
status = PREP;
num_read = 4;
while (status != STOP) {
/* check for end of file status */
if (num_read < 4) status = END;
/*wait twice to prime the pump before starting calculations*/
if (!(count++)) status = START;
/* read one line of the table into point3, storing
previous values in point0, point1, and point2. */
if (status != END) {
VMOVEN(point0,point1,4);
VMOVEN(point1,point2,4);
VMOVEN(point2,point3,4);
num_read = scanf("%lf %lf %lf %lf", point3, point3+1, point3+2, point3+3);
}
if (status==START) { /* do calculations for the first point*/
get_orientation(point1,point2,point3, f_prm_0, &yaw, &pch, &rll);
if (!(count%print_int)) {
printf("%f %f %f %f %f %f %f\n",point1[0],point1[1],point1[2],point1[3],yaw,pch,rll);
}
status = MIDDLE;
}
else if (status==MIDDLE) {/*do calculations for all middle points*/
get_orientation(point0,point1,point2, f_prm_1, &yaw, &pch, &rll);
if (!(count%print_int)) {
printf("%f %f %f %f %f %f %f\n",point1[0],point1[1],point1[2],point1[3],yaw,pch,rll);
}
}
else if (status==END) { /*do calculations for the last point*/
get_orientation(point0,point1,point2, f_prm_2, &yaw, &pch, &rll);
if (!(count%print_int)) {
printf("%f %f %f %f %f %f %f\n",point2[0],point2[1],point2[2],point2[3],yaw,pch,rll);
}
status = STOP;
}
}
}
get_orientation(p0,p1,p2,function, p_yaw, p_pch, p_rll)
fastf_t p0[4],p1[4],p2[4], *p_yaw, *p_pch, *p_rll;
fastf_t (*function)();
{
int i;
fastf_t step,vel[3],accel[3];
fastf_t f_double_prm(),xyz2yaw(),xyz2pch(),bank();
static fastf_t last_yaw, last_pch, last_rll;
static int not_first_time, upside_down;
step = p2[0] - p1[0];
for (i=1;i<4;i++) {
vel[i-1] = (*function)(p0[i],p1[i],p2[i],step);
accel[i-1] = f_double_prm(p0[i],p1[i],p2[i],step);
}
*p_yaw = xyz2yaw(vel);
*p_pch = xyz2pch(vel);
*p_rll = bank(accel,vel);
if (fabs(*p_pch)==90.0) /* don't change yaw if velocity vertical */
*p_yaw = last_yaw;
/* avoid sudden yaw changes in vertical loops */
if (not_first_time&&loop){
if ((fabs(last_yaw - *p_yaw)<181.0)&&(fabs(last_yaw - *p_yaw)>179.0))
upside_down = (upside_down) ? 0 : 1;
if (upside_down)
(*p_rll) += 180;
}
last_yaw = *p_yaw;
last_pch = *p_pch;
last_rll = *p_rll;
not_first_time = 1;
}
/* determine the yaw of the given direction vector */
fastf_t xyz2yaw(d)
fastf_t d[3];
{
fastf_t yaw;
yaw = RTOD*atan2(d[1],d[0]);
if (yaw < 0.0) yaw += 360.0;
return yaw;
}
/* determine the pitch of the given direction vector */
fastf_t xyz2pch(d)
fastf_t d[3];
{
fastf_t x;
x = sqrt(d[0]*d[0] + d[1]*d[1]);
return (RTOD*atan2(d[2],x));
}
/* given the 3-d velocity and acceleration of an imaginary aircraft,
find the amount of bank the aircraft would need to undergo.
Algorithm: the bank angle is proportional to the cross product
of the horizontal velocity and horizontal acceleration, up to a
maximum bank of 90 degrees in either direction. */
fastf_t bank(acc,vel)
fastf_t acc[3],vel[3];
{
fastf_t cross;
cross = vel[1]*acc[0] - vel[0]*acc[1];
cross *= magic_factor;
if (cross > 90) cross = 90;
if (cross < -90) cross = -90;
return cross;
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t) */
fastf_t f_prm_0(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return -(3.0*x0 - 4.0*x1 + x2)/(2*h);
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+h) */
fastf_t f_prm_1(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x2 - x0)/(2*h);
}
/* given f(t), f(t+h), f(t+2h), and h, calculate f'(t+2h) */
fastf_t f_prm_2(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x0 - 4.0*x1 + 3.0*x2)/(2*h);
}
/* given f(t), f(t+h), f(t+2*h), and h, calculate f'' */
fastf_t f_double_prm(x0,x1,x2,h)
fastf_t x0,x1,x2,h;
{
return (x0 - 2.0*x1 + x2)/(h*h);
}
/* code to read command line arguments*/
#define OPT_STR "f:p:r"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'f':
sscanf(bu_optarg,"%lf",&magic_factor);
magic_factor *= 0.001; /* to put factors in a more reasonable range */
break;
case 'p':
sscanf(bu_optarg,"%d",&print_int);
break;
case 'r':
loop = 0;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-293
View File
@@ -1,293 +0,0 @@
.TH ANIM_HARDTRACK 1 BRL/CAD
.SH NAME
anim_hardtrack - make an animation script for the links and/or wheels of a
tracked vehicle with rigid axles.
.SH SYNOPSIS
.B
anim_hardtrack [-l num_links linkname] [-w wheelname] [options] wheelfile < in.table > out.script
.SH DESCRIPTION
.I Anim_hardtrack
is designed to produce an animation script for the
animation of a track and/or the wheels defining a track, where the wheels
are rigidly fixed in place with respect to the vehicle. The main
difference between
.I anim_hardtrack
and
.I anim_track
is that
.I anim_track
handles vehicles with dynamic axles. Both are designed to be use in
conjunction with
.I anim_script,
to achieve the final result.
.PP
.B in.table
is the file that will be used to animate the
vehicle itself. By default, it is assumed that it contains a time column,
three columns of translation information, and three columns specifying the
vehicle's yaw, pitch, and roll. If it is desired that the vehicle be steered
automatically, then the table should contain only time and position, and the
.B -s
option should be used.
.PP
The track's
geometry is defined by
.BR wheelfile ,
a table which contains one row for each wheel defining the track. The
first three columns of the table specify the x, y, and z coordinates of
the wheel centers. The fourth column specifies the radius of each wheel.
.PP
The order in which the wheels are listed should be the order in which a
link of the track would move around the wheels when the vehicle is moving
forward. (clockwise, when looking from the right of the vehicle).
The wheel centers should all lie in a plane perpendicular to the vehicle's
left-right axis. If this is not the case,
.I anim_hardtrack
uses the first wheel as the standard and projects all the other wheels into
the same plane as the first wheel. By default, it is assumed that the
vehicle's left-right axis is the y-axis. If the modeled vehicle has some
other orientation, this must be specified with the
.B -b
option.
.PP
By default, it is
assumed that
all of the link objects are modeled at the model origin,
with the wheel-contacting surface centered on the origin and the
ground-contacting surface facing up. The sides of each link which
connect to other links should face the positive and negative x-axes.
.I Anim_hardtrack
prints the appropriate
commands to move the links from
the origin to the correct place around the wheels.
.PP
If the links are modeled in place around the wheels to begin with, the
the
.B -p
and
.B -i
options are needed.
.SH OPTIONS:
.PP
One or both of the first two options should always be specified.
.TP
.B \-l num linkname
Print animation scripts to animate the links of the track. Animation
commands will be printed for
.I num
different links
named
.IR linkname .0, linkname .1,
up through
.IR linkname .( num -1).
A typical example of a linkname might
be "tank/righttrack/links/link". The full pathname must be specified,
because anim_hardtrack's method is to roll the links around within
the vehicle's tree structure so that when the whole vehicle "tank" is
animated, the complete combination of rolling around and translating is
achieved.
.TP
.B \-w wheelname
Print animation
scripts to rotate each wheel. The wheels are named wheelname.0, wheelname.1,
and so on, where wheelname.0 is the first wheel listed in
.BR wheelfile .
As with the links, the full pathname for the wheels should be specified.
.TP
.B \-b # # #
Specify the yaw, pitch, and roll of the vehicle's axes
with respect to the world axes. By default, the vehicle is assumed to
have a yaw, pitch, and roll of 0.
.TP
.B \-d # # #
Specify (in world coordinates) the centroid of the vehicle
of which the track is a part. By default, the vehicle is assumed
centered at the origin.
.PP
When calling
.I anim_script
to handle the animation of the vehicle
itself, the parameters following the
.B -b
and
.B -d
options should be identical
to those used for
.IR anim_hardtrack .
.TP
.B \-r #
Specify the common radius of all wheels. In this case the fourth column
should be omitted from the
.BR wheelfile .
.TP
.B \-s
Automatic steering. In this case,
.B in.table
specifies only the time and position
of the vehicle. The orientation is calculated to always face the vehicle
in the direction of motion.
This should be used when the
.B \-s
option is used by
.I anim_script
to animate the vehicle.
.PP
.TP
.B \-f#
Specify the integer with which to begin numbering frames.
Default is zero.
.TP
.B \-p
Animate placed links, rather than links stored at the origin.
In order for placed links to be animated, they must be equally spaced
around the wheels defining the track. The track must be formed of arcs
around the wheels and straight lines between the wheels, and the links
must be numbered clockwise as seen from the right.
By default, it is assumed that the
center of the first link, linkname.0, is at the beginning of the
straight track segment between wheel.(n-1) and wheel.0 . If this is
not the case, the position of the first link must be identified with the
.B \-i#
option.
.TP
.B \-i#
Specify the initial offset of the first link. If this option is
not used, the initial position of linkname.0 is assumed to be the
beginning of the straight track segment between wheel.(n-1) and wheel.0.
If it is used, the argument specifies the distance clockwise around the
track from the default position to the actual desired offset. If the
links are modeled at the origin, the user can choose any offset. This
can be useful for lining up the links with gears of a drive wheel, for
example.
If the
.B -p
option is being used to animated pre-placed links, then it is essential
that the actual offset of the first pre-placed link be specified.
.SS Output:
.PP
The output is a script containing as many frames as there
are positions in
.BR in.table .
If there are
.I n
links and
.I k
wheels, each
frame contains up to
.IR n + k
anim commands, either:
.nf
anim linkname.i matrix lmul
[... matrix ...] ;
or
anim wheelname.j matrix lmul
[... matrix ...] ;
for 0<=i<n and 0<=j<k.
.fi
.SH EXAMPLES
Suppose you want to make an animation of a tank rolling across
flat ground. A list of desired positions is created, perhaps by
interpolating between a few key positions; this information is placed
in a four column animation table, in.table. The model of the tank is stored in
model.g as a combination named "tank". Its centroid is at the
point (0,0,1000) and it faces the y-axis. An animation script for the
tank itself is created as follows:
.PP
anim_script -s -d 0 0 1000 -b 90 0 0 /tank < in.table > tank.script
.PP
Suppose that there are two
roadwheels and a drivewheel (tank/rwheel/wheel.i, 0<=i<3) which define
the shape of the right track.
A file called
.B rwheelfile
is created:
.nf
1500 -2000 30 30
1500 0 1000 35
1500 2000 30 30
.fi
This
.B rwheelfile
lists the position and
radius of each of the three wheels.
.PP
There are eighty links which make up the right track
(tank/rtrack/link.i, 0<=i<80).
The links of the right track are all modeled
at the origin with the outer, ground-contacting surface
facing up and the inner, wheel-contacting surface centered at the
origin.
.PP
The appropriate call to
.I anim_hardtrack
is now:
.sp
anim_hardtrack -d 0 0 1000 -b 90 0 0 -w tank/rwheel -l 80 tank/rtrack/link
rwheelfile < in.table > rtrack.script
.sp
Suppose that the left track is similar to the right track,
except that all the wheels are of radius 30 units, and the links, rather
than being stored at the origin, are actually placed in position around
the left wheels to begin with. The
.B lwheelfile
would be:
.nf
-1500 -2000 30
-1500 0 1000
-1500 2000 30
.fi
and the call would be:
.sp
anim_hardtrack -p -r 30 -d 0 0 1000 -b 90 0 0 -w tank/lwheel
-l 80 tank/ltrack/link lwheelfile <in.table > ltrack.script
.sp
Here, it is assumed that tank/ltrack/link.0 is initially at the
beginning of the straight track segment between lwheel.2 and lwheel.0,
that is, at the point (2000,1500,-1000) in the vehicle's coordinates.
If, instead, the first link is initially centered halfway between the
two roadwheels, this must be specified with the
.B -i#
option. If the link's
actual position is 2000 units farther around the track than expected:
.sp
anim_hardtrack -i 2000 -p -r 30 -d 0 0 1000 -b 90 0 0 -w tank/lwheel
-l 80 tank/ltrack/link lwheelfile <in.table > ltrack.script
.sp
One final step may remain. The above procedure produces a script with rigid
naming conventions, in order to make input simple. This may mean that
the names in the script do not match the names in model.g. An editor
should then be used at the end to replace all instances of the
conventional name with the real name; for example, in this case it may
be necessary to replace "rwheel.1" with "r_drivewheel".
.PP
.BR Tank.script ,
.BR rtrack.script ,
and
.B ltrack.script
can be combined
with
.I anim_sort
to make the complete script.
.PP
.SH BUGS
Tracks must have at least two wheels, and they must be listed in clockwise
order, or the results are unpredictable.
.SH SEE ALSO
anim_script(1), anim_track(1)
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-502
View File
@@ -1,502 +0,0 @@
/* A N I M _ H A R D T R A C K . C
*
* Animate the links and wheels of a tracked vehicle. It is assumed
* that the wheels do not translate with respect to the vehicle.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
#define M_PI_2 (M_PI*0.5)
#endif
#define NW num_wheels
#define NEXT(i) (i+1)%NW
#define PREV(i) (i+NW-1)%NW
#define TRACK_ANIM 0
#define TRACK_ARCED 1
typedef double *pdouble;
struct wheel {
vect_t pos; /* displacement of wheel from vehicle origin */
fastf_t rad; /* radius of wheel */
fastf_t ang0; /* angle where track meets wheel; 0 < a < 2pi */
fastf_t ang1; /* angle where track leaves wheel; 0 < a < 2pi */
fastf_t arc; /* arclength of contact between wheel and track */
};
struct track {
vect_t pos0; /* beginning point of track section */
vect_t pos1; /* end point of track section */
vect_t dir; /* unit vector: direction of track section */
fastf_t len; /* length of track section */
};
struct slope {
vect_t dir; /* vector from previous to current axle */
fastf_t len; /* length of vector described above */
};
struct all {
struct wheel w; /* parameters describing the track around a wheel */
struct track t; /* track between this wheel and the previous wheel */
struct slope s; /* vector between this axle and the previous axle */
};
struct rlink {
vect_t pos; /* reverse of initial position */
fastf_t ang; /* initial angle */
};
/* external variables */
extern int bu_optind;
extern char *bu_optarg;
/* variables describing track geometry - used by main, trackprep, get_link */
struct all *x;
struct rlink *r; /* reverse of initial locations of links */
int num_links, num_wheels;
fastf_t track_y, tracklen;
/* variables set by get_args */
int wheel_nindex; /* argv[wheel_nindex] = wheelname*/
int link_nindex; /* argv[link_nindex] = linkname*/
int print_wheel; /* flag: do wheel animation */
int print_link; /* flag: do link animation */
int print_mode; /* anim for rt or arced for mged */
int arced_frame; /* which frame to arced */
int links_placed; /* flag: links are initially on the track */
int axes, cent; /* flags: alternate axes, centroid specified */
int steer; /* flag: vehicle automatically steered */
int first_frame; /* integer with which to begin numbering frames */
fastf_t radius; /* common radius of all wheels */
fastf_t init_dist; /* initial distance of first link along track */
vect_t centroid, rcentroid; /* alternate centroid and its reverse */
mat_t m_axes, m_rev_axes; /* matrices to and from alternate axes */
char link_cmd[10]; /* default is "rarc" */
char wheel_cmd[10]; /* default is "lmul" */
int get_circumf; /* flag: just return circumference of track */
main(argc,argv)
int argc;
char **argv;
{
void anim_dir2mat(), anim_y_p_r2mat(), anim_add_trans(),anim_mat_print();
int get_args(), get_link(), track_prep(), val, frame, go, i, count;
fastf_t y_rot, distance, yaw, pitch, roll;
vect_t p1, p2, p3, dir, dir2, wheel_now, wheel_prev;
vect_t zero, position, vdelta, temp, to_track, to_front;
mat_t mat_v, wmat, mat_x;
FILE *stream;
int last_frame;
VSETALL(zero,0.0);
VSETALL(to_track,0.0);
VSETALL(centroid,0.0);
VSETALL(rcentroid,0.0);
init_dist = y_rot = radius= 0.0;
first_frame = num_wheels = steer = axes = cent = links_placed=0;
num_wheels = num_links = last_frame = 0;
MAT_IDN(mat_v);
MAT_IDN(mat_x);
MAT_IDN(wmat);
MAT_IDN(m_axes);
MAT_IDN(m_rev_axes);
if (!get_args(argc,argv)){
fprintf(stderr,"anim_hardtrack: argument error.");
return(-1);
}
if (axes || cent ){ /* vehicle has own reference frame */
anim_add_trans(m_axes,centroid,zero);
anim_add_trans(m_rev_axes,zero,rcentroid);
}
/* get track information from specified file */
if (!(stream = fopen(*(argv+bu_optind),"r"))){
fprintf(stderr,"Anim_hardtrack: Could not open file %s.\n",*(argv+bu_optind));
return(0);
}
num_wheels = -1;
if (radius) {
while (!feof(stream)) {
fscanf(stream,"%*lf %*lf %*lf");
num_wheels++;
}
} else {
while (!feof(stream)) {
fscanf(stream,"%*lf %*lf %*lf %*lf");
num_wheels++;
}
}
rewind(stream);
/*allocate memory for track information*/
x = (struct all *) calloc(num_wheels,sizeof(struct all));
/*read rest of track info */
for (i=0;i<NW;i++){
fscanf(stream,"%lf %lf %lf", temp, temp+1, temp+2);
if (radius)
x[i].w.rad = radius;
else
fscanf(stream,"%lf",& x[i].w.rad);
MAT4X3PNT(x[i].w.pos,m_rev_axes,temp);
if (i==0)
track_y = x[0].w.pos[1];
else
x[i].w.pos[1] = track_y;
}
(void) fclose(stream);
(void) track_prep();
if (get_circumf) {
printf("%.10g\n",tracklen);
return(0);
}
/* initialize to_track */
VSET(to_track, 0.0, track_y, 0.0);
VSET(to_front,1.0,0.0,0.0);
if ((!print_link)&&(!print_wheel)) {
fprintf(stderr,"anim_hardtrack: no ouput requested. Use -l or -w.\n");
exit(0);
}
/* main loop */
distance = 0.0;
if(!steer)
frame = first_frame;
else
frame = first_frame-1;
for (val = 3; val > 2; frame++) {
go = 1;
/*p2 is current position. p3 is next;p1 is previous*/
VMOVE(p1,p2);
VMOVE(p2,p3);
scanf("%*f");/*time stamp*/
val = scanf("%lf %lf %lf", p3, p3+1, p3 + 2);
if(!steer){
scanf("%lf %lf %lf",&yaw,&pitch,&roll);
anim_dy_p_r2mat(mat_v,yaw,pitch,roll);
anim_add_trans(mat_v,p3,rcentroid);
}
else { /* analyze positions for steering */
/*get useful direction unit vectors*/
if (frame == first_frame){ /* first frame*/
VSUBUNIT(dir,p3,p2);
VMOVE(dir2,dir);
}
else if (val < 3){ /*last frame*/
VSUBUNIT(dir,p2,p1);
VMOVE(dir2,dir);
}
else if (frame > first_frame){ /*normal*/
VSUBUNIT(dir,p3,p1);
VSUBUNIT(dir2,p2,p1);/*needed for vertical case*/
}
else go = 0;/*first time through loop;no p2*/
/*create matrix which would move vehicle*/
anim_dir2mat(mat_v,dir,dir2);
anim_add_trans(mat_v,p2,rcentroid);
}
/*determine distance traveled*/
VMOVE(wheel_prev,wheel_now);
MAT4X3PNT(wheel_now,mat_v,to_track);
if (frame > first_frame){ /* increment distance by distance moved */
VSUB2(vdelta,wheel_now,wheel_prev);
MAT3X3VEC(temp,mat_v,to_front);/*new front of vehicle*/
distance += VDOT(temp,vdelta);/*portion of vdelta in line with track*/
}
if (go){
if (print_mode==TRACK_ANIM) {
printf("start %d;\nclean;\n", frame);
} else if (print_mode==TRACK_ARCED) {
if (frame != arced_frame) continue;
last_frame = 1;
}
if (print_link) {
for (count=0;count<num_links;count++){
(void) get_link(position,&y_rot,distance+tracklen*count/num_links+init_dist);
anim_y_p_r2mat(wmat,0.0,y_rot+r[count].ang,0.0);
anim_add_trans(wmat,position,r[count].pos);
if ((axes || cent) && links_placed){ /* link moved from vehicle coords */
mat_mul(mat_x,wmat,m_rev_axes);
mat_mul(wmat,m_axes,mat_x);
}
else if (axes || cent){ /* link moved to vehicle coords */
MAT_MOVE(mat_x,wmat);
mat_mul(wmat,m_axes,mat_x);
}
if (print_mode==TRACK_ANIM) {
printf("anim %s.%d matrix %s\n", *(argv+link_nindex),count,link_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","\n",";\n");
} else if (print_mode==TRACK_ARCED) {
printf("arced %s.%d matrix %s ", *(argv+link_nindex),count,link_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","","\n");
}
}
}
if (print_wheel){
for (count = 0;count<num_wheels;count++){
anim_y_p_r2mat(wmat,0.0,-distance/x[count].w.rad,0.0);
VREVERSE(temp,x[count].w.pos);
anim_add_trans(wmat,x[count].w.pos,temp);
if (axes || cent){
mat_mul(mat_x,wmat,m_rev_axes);
mat_mul(wmat,m_axes,mat_x);
}
if (print_mode==TRACK_ANIM) {
printf("anim %s.%d matrix %s\n",*(argv+wheel_nindex),count,wheel_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","\n",";\n");
} else if (print_mode==TRACK_ARCED) {
printf("arced %s.%d matrix %s ",*(argv+wheel_nindex),count,wheel_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","","\n");
}
}
}
if (print_mode==TRACK_ANIM)
printf("end;\n");
}
if (last_frame) break;
}
}
int track_prep()/*run once at the beginning to establish important track info*/
{
int i;
fastf_t phi, costheta, link_angle, arc_angle;
vect_t difference, link_cent;
/* first loop - get inter axle slopes and start/end angles */
for (i=0;i<NW;i++){
/*calculate current slope vector*/
VSUB2(x[i].s.dir,x[i].w.pos,x[PREV(i)].w.pos);
x[i].s.len = MAGNITUDE(x[i].s.dir);
/*calculate end angle of previous wheel - atan2(y,x)*/
phi = atan2(x[i].s.dir[2],x[i].s.dir[0]);/*absolute angle of slope*/
costheta = (x[PREV(i)].w.rad - x[i].w.rad)/x[i].s.len;/*cosine of special angle*/
x[PREV(i)].w.ang1 = phi + acos(costheta);
while (x[PREV(i)].w.ang1 < 0.0)
x[PREV(i)].w.ang1 += 2.0*M_PI;
x[i].w.ang0 = x[PREV(i)].w.ang1;
}
/* second loop - handle concavities */
for (i=0;i<NW;i++){
arc_angle = x[i].w.ang0 - x[i].w.ang1;
while (arc_angle < 0.0)
arc_angle += 2.0*M_PI;
if (arc_angle > M_PI) { /* concave */
x[i].w.ang0 = 0.5*(x[i].w.ang0 + x[i].w.ang1);
x[i].w.ang1 = x[i].w.ang0;
x[i].w.arc = 0.0;
}
else { /* convex - angles are already correct */
x[i].w.arc = arc_angle;
}
}
/* third loop - calculate geometry of track segments */
tracklen = 0.0;
for (i=0;i<NW;i++){
/*calculate endpoints of track segment*/
x[i].t.pos1[0] = x[i].w.pos[0] + x[i].w.rad*cos(x[i].w.ang0);
x[i].t.pos1[1] = x[i].w.pos[1];
x[i].t.pos1[2] = x[i].w.pos[2] + x[i].w.rad*sin(x[i].w.ang0);
x[i].t.pos0[0] = x[PREV(i)].w.pos[0] + x[PREV(i)].w.rad*cos(x[PREV(i)].w.ang1);
x[i].t.pos0[1] = x[PREV(i)].w.pos[1];
x[i].t.pos0[2] = x[PREV(i)].w.pos[2] + x[PREV(i)].w.rad*sin(x[PREV(i)].w.ang1);
/*calculate length and direction*/
VSUB2(difference,x[i].t.pos1,x[i].t.pos0);
x[i].t.len = MAGNITUDE(difference);
VSCALE((x[i].t.dir),difference,(1.0/x[i].t.len));
/*calculate arclength and total track length*/
tracklen += x[i].t.len;
tracklen += x[i].w.arc*x[i].w.rad;
}
/* for a track with links already placed, get initial positions*/
r = (struct rlink *) calloc(num_links, sizeof(struct rlink));
if (links_placed)
for (i=0;i<num_links;i++){
get_link(link_cent,&link_angle,init_dist + tracklen*i/num_links);
VREVERSE(r[i].pos,link_cent);
r[i].ang = -link_angle;
}
return(0);
}
int get_link(pos,angle_p,dist)
fastf_t *angle_p, dist;
vect_t pos;
{
int i;
vect_t temp;
while (dist >= tracklen) /*periodicize*/
dist -= tracklen;
while (dist < 0.0)
dist += tracklen;
for (i=0;i<NW;i++){
if ( (dist -= x[i].t.len) < 0 ){
VSCALE(temp,(x[i].t.dir),dist);
VADD2(pos,x[i].t.pos1,temp);
*angle_p = atan2(x[i].t.dir[2],x[i].t.dir[0]);
return(2*i);
}
if ((dist -= x[i].w.rad*x[i].w.arc) < 0){
*angle_p = dist/x[i].w.rad;
*angle_p = x[i].w.ang1 - *angle_p;/*from x-axis to link*/
pos[0] = x[i].w.pos[0] + x[i].w.rad*cos(*angle_p);
pos[1] = x[i].w.pos[1];
pos[2] = x[i].w.pos[2] + x[i].w.rad*sin(*angle_p);
*angle_p -= M_PI_2; /*angle of clockwise tangent to circle*/
return(2*i+1);
}
}
return -1;
}
#define OPT_STR "b:d:f:i:l:pr:w:sg:m:c"
int get_args(argc,argv)
int argc;
char **argv;
{
fastf_t yaw, pch, rll;
void anim_dx_y_z2mat(), anim_dz_y_x2mat();
int c, i;
axes = cent = links_placed = print_wheel = print_link = 0;
get_circumf = 0;
print_mode = TRACK_ANIM;
strcpy(link_cmd, "rarc");
strcpy(wheel_cmd, "lmul");
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
i=0;
switch(c){
case 'b':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf", &yaw );
sscanf(argv[bu_optind+(i++)],"%lf", &pch );
sscanf(argv[bu_optind+(i++)],"%lf", &rll );
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
axes = 1;
break;
case 'd':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf",centroid);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+1);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+2);
bu_optind += 3;
VREVERSE(rcentroid,centroid);
cent = 1;
break;
case 'f':
sscanf(bu_optarg,"%d",&first_frame);
break;
case 'i':
sscanf(bu_optarg,"%lf",&init_dist);
break;
case 'p':
links_placed = 1;
break;
case 'r':
sscanf(bu_optarg,"%lf",&radius);
break;
case 'w':
wheel_nindex = bu_optind - 1;
/*sscanf(bu_optarg,"%s",wheel_name);*/
print_wheel = 1;
break;
case 'l':
sscanf(bu_optarg,"%d", &num_links);
link_nindex = bu_optind;
bu_optind += 1;
print_link = 1;
break;
case 's':
steer = 1;
break;
case 'g':
sscanf(bu_optarg,"%d",&arced_frame);
print_mode = TRACK_ARCED;
break;
case 'm':
switch (*bu_optarg) {
case 'l':
strncpy(link_cmd,argv[bu_optind], 10);
break;
case 'w':
strncpy(wheel_cmd,argv[bu_optind], 10);
break;
default:
fprintf(stderr,"Unknown option: -m%c\n",*bu_optarg);
return(0);
}
bu_optind += 1;
break;
case 'c':
get_circumf = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
void show_info(which)/* for debugging - -1:track 0:both 1:link*/
int which;
{
int i;
if (which <=0){
fprintf(stderr,"track length: %f\n",tracklen);
fprintf(stderr,"link length: %f\n",tracklen/num_links);
for (i=0;i<NW;i++){
fprintf(stderr,"wheel %d: %f %f %f %f %f %f\n",i,x[i].w.pos[0],x[i].w.pos[1],x[i].w.pos[2],x[i].w.rad,x[i].w.ang1,x[i].w.arc);
fprintf(stderr,"track %d: %f %f %f %f %f %f %f\n",i,x[i].t.pos1[0],x[i].t.pos1[1],x[i].t.pos1[2],x[i].t.dir[0],x[i].t.dir[1],x[i].t.dir[2],x[i].t.len);
fprintf(stderr,"slope %d: %f %f %f %f\n",i,x[i].s.dir[0],x[i].s.dir[1],x[i].s.dir[2],x[i].s.len);
}
}
/* if (which >= 0){
fprintf(stderr,"%d %f %f %f %f\n",count,position[0],position[1],position[2],y_rot);
}*/
}
-114
View File
@@ -1,114 +0,0 @@
.TH ANIM_KEYREAD 1 BRL/CAD
.SH NAME
anim_keyread - prepares key frames from the mged savekey command for interpolation
.SH SYNOPSIS
.B anim_keyread
.B [-y|z]
.B < key.file
.B > key.table
.SH DESCRIPTION
.I Anim_keyread
takes as input a file containing a series of keyframes
generated by the
.I mged
command `savekey', and produces a table containing
the same information, except that the view orientation matrix is
changed to a form that can be interpolated. The default form for the
orientation information is the quaternion.
For each such keyframe in the input file,
.I anim_keyread
will produce a
row in the output file containing the time, the viewsize, the position
of the camera, and the orientation of the camera, specified as a unit
quaternion in the order x, y, z, and w.
.SH OPTIONS
.TP
.B -y
Specify the orientation in terms of yaw, pitch, and roll.
.TP
.B -z
Specify the orientation as a rotation about the z-axis, y-axis,
and then x-axis, where the columns are in the order: x,y,z.
.SH EXAMPLES
The following is an example of a typical keyframe generated by the
`savekey' command. The time is 0, the viewsize is ten, the camera is at the
point (2.5,2.5,3.53) and the camera orientation is specified by a
matrix.
.nf
0.000000
1.000000000e+01
2.500000000e+00 2.500000000e+00 3.535533906e+00
-7.071067812e-01 7.071067812e-01 0.000000000e+00 0.000000000e+00
-5.000000000e-01 -5.000000000e-01 7.071067812e-01 0.000000000e+00
5.000000000e-01 5.000000000e-01 7.071067812e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00
.fi
For the key frame shown above, the output would
be:
.sp
0.000000 10.000000 2.500000 2.500000 3.535534 0.146447 0.353553 0.853553 0.353553
.sp
The last four numbers define the desired orientation as a
quaternion.
.PP
With the
.B -y
option, the output would be:
.sp
0.000000 10.000000 2.500000 2.500000 3.535534 -135.000000 -45.000000 0.000000
.sp
Here, the last three numbers are the yaw, pitch, and roll,
which can be interpreted as follows: Imagine a camera at the origin
originally facing the positive x-direction, with the z-axis going up
and the y-axis positive to the left. The camera should be rotated
+roll degrees about the x-axis, -pitch degrees about the y-axis,
and +yaw degrees about the z-axis. In this case, the camera ends up
pointing down and to the right of its original position.
.PP
With the -z option, the output would be:
.sp
0.000000 10.000000 2.500000 2.500000 3.535534 -35.264390 30.000000 144.735610
.sp
The last three numbers are x, y, and z rotation angles.
The camera is considered to be originally on the z-axis, looking toward
the origin with the x-axis to the right and the y-axis going up. The
camera is rotated 144.7 degrees about the model's z-axis, then 30
degrees about the model's y-axis, and finally -35.2 degrees about the
model x-axis.
.SH DIAGNOSTICS
Problems arise when using Eulers angles, because
certain orientations do not have a uniqe representation, and the program
must arbitrarily select among an infinite number of possibilities. For
example, when using yaw, pitch and roll, the yaw and roll
become indistinguishable when the pitch is 90 degrees.
.PP
When this happens, the roll is set to 0, and the following
messages appear on standard error:
.nf
Warning: roll arbitrarily set to 0.0; yaw set to -0.585334 radians.
Warning: yaw and roll arbitrarily defined at time = 1.000000.
.fi
A similar effect occurs in xyz format when the rotation about
the y-axis is 90 degrees.
.nf
Warning: x arbitrarily set to 0.0; z set to 0.000000.
Warning: x and z rotations arbitrarily defined at time = 9.000000.
.fi
One nice thing about quaternions is that you don't run into such
problems.
.SH SEE ALSO
mged(1), tabsub(1), anim_script(1), tabinterp(1)
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-156
View File
@@ -1,156 +0,0 @@
/* A N I M _ K E Y R E A D . C
*
* Convert an list of mged-style 'savekey' keyframes into an
* animation table
*
* The output table specifies the orientation in one of three ways:
*
* default - quaternions in the order x, y, z, w.
*
* -z option - Eulers angles, in the order xyz. The model axes are
* considered to be rotated about the camera's z, y, and
* x axes (in that order).
*
* -y option - Eulers angles in the form yaw, pitch, roll.
*
* This is more or less a special case of anim_orient.c
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define YPR 0
#define XYZ 1
#define QUATERNION 2
#define DEGREES 0
#define RADIANS 1
#define NORMAL 0
#define ERROR1 1
#define ERROR2 2
#define DTOR M_PI/180.0
#define RTOD 180.0/M_PI
int mode;
int units;
extern int bu_optind;
extern char *bu_optarg;
main(argc,argv)
int argc;
char **argv;
{
int c;
fastf_t time, viewsize;
fastf_t eyept[3], viewrot[16], angle[3], quat[4];
int anim_mat2ypr(), anim_mat2zyx(), anim_mat2quat();
if (!get_args(argc,argv))
fprintf(stderr,"anim_keyread: get_args error");
while (!feof(stdin)){ /* read one keyframe */
scanf("%lf", &time);
scanf("%lf", &viewsize);
scanf("%lf %lf %lf", eyept, eyept+1, eyept+2);
/* read in transposed matrix */
scanf("%lf %lf %lf %lf", viewrot+0, viewrot+4, viewrot+8, viewrot+12);
scanf("%lf %lf %lf %lf", viewrot+1, viewrot+5, viewrot+9, viewrot+13);
scanf("%lf %lf %lf %lf", viewrot+2, viewrot+6, viewrot+10, viewrot+14);
scanf("%lf %lf %lf %lf", viewrot+3, viewrot+7, viewrot+11, viewrot+15);
if (feof(stdin)) break;
printf("%.10g\t%.10g\t%.10g\t%.10g\t%.10g\t", time, viewsize,
eyept[0], eyept[1], eyept[2]);
if (mode==YPR) {
anim_v_unpermute(viewrot);
c = anim_mat2ypr(angle,viewrot);
if (c==ERROR1)
fprintf(stderr,"Warning: yaw and roll arbitrarily defined at time = %f.\n",time);
else if (c==ERROR2)
fprintf(stderr,"Keyread: can't interpret matrix at time = %f.\n",time);
if (units == DEGREES)
VSCALE(angle,angle,RTOD);
printf("%.10g\t%.10g\t%.10g\n",angle[0],angle[1],angle[2]);
}
else if (mode==XYZ) {
c = anim_mat2zyx(angle,viewrot);
if (c==ERROR1)
fprintf(stderr,"Warning: x and z rotations arbitrarily defined at time = %f.\n",time);
else if (c==ERROR2)
fprintf(stderr,"Keyread: can't interpret matrix at time = %f\n.",time);
if (units == DEGREES)
VSCALE(angle,angle,RTOD);
printf("%.10g\t%.10g\t%.10g\n",angle[X],angle[Y],angle[Z]);
}
else if (mode==QUATERNION){
anim_mat2quat(quat,viewrot);
printf("%.10g\t%.10g\t%.10g\t%.10g\n",quat[X],quat[Y],quat[Z],quat[W]);
}
}
}
#define OPT_STR "yzqr"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
mode = QUATERNION; /* default */
units = DEGREES;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'y':
mode = YPR;
break;
case 'z':
mode = XYZ;
break;
case 'q':
mode = QUATERNION;
break;
case 'r':
units = RADIANS;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-58
View File
@@ -1,58 +0,0 @@
.TH ANIM_LOOKAT 1 BRL/CAD
.SH NAME
anim_lookat - create a view animation script or table which looks from an eye point to
a specified point.
.SH SYNOPSIS
.B anim_lookat
.B [\-f #]
.B \[-v]
.B < in.table
.B > out.script
.PP
.B anim_lookat
.B \-[y|q]
.B \[-v]
.B < in.table
.B > out.table
.SH DESCRIPTION
This program takes as input a seven-column animation table
consisting of time, an eye point, and a "look-at point", and prints a
view animation script to control the virtual camera.
The camera always remains "right-side up"; that is, it yaws and pitches but
doesn't roll. In cases where the camera looks vertically up or down, the
yaw from the previous frame is retained. This avoids sudden jumps as much
as possible.
.PP
.SH OPTIONS
.TP
.B \-f#
Specify an integer with which to begin
numbering frames. The default is 0.
.TP
.B \-y
The output will be an animation table rather
than a view animation script. The output table has 7 columns:
a time column, three
columns representing position, and three columns representing yaw,
pitch, and roll.
.TP
.B \-q
The output will be an animation table rather than a view animation script.
The output table has eight columns:
a time column, three position columns, and four columns
representing the x,y,z, and w coordinates of an orientation quaternion.
.TP
.B \-v
Include the viewsize in the output script or table. The viewsize is
calculated in every frame as twice the distance from the eye point to
the lookat point. If the output is a table, then the viewsize is printed
in the second column.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-152
View File
@@ -1,152 +0,0 @@
/* A N I M _ L O O K A T . C
*
* Given animation tables for the position of the virtual camera
* and a point to look at at each time, this program produces an animation
* script to control the camera. The view is kept rightside up, whenever
* possible. When looking vertically up or down, the exact orientation
* depends on the previous orientation.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef RTOD
#define RTOD (180/M_PI)
#endif
#define LOOKAT_SCRIPT 0
#define LOOKAT_YPR 1
#define LOOKAT_QUAT 2
extern int bu_optind;
extern char *bu_optarg;
int frame = 0;
int print_mode = LOOKAT_SCRIPT;
int print_viewsize = 0;
main(argc,argv)
int argc;
char **argv;
{
fastf_t time, vsize;
vect_t eye,look,dir,prev_dir, angles, norm, temp;
quat_t quat;
mat_t mat;
int val = 0;
VSETALL(look,0.0);
VSETALL(eye,0.0);
if (argc > 1)
get_args(argc,argv);
VSET(norm, 0.0, 1.0, 0.0);
while (!feof(stdin)){
VMOVE(prev_dir,dir);
val=scanf("%lf %lf %lf %lf %lf %lf %lf",&time,eye,eye+1,eye+2,look,look+1,look+2);
if (val < 7){
break;
}
if (print_viewsize) {
VSUB2(temp, eye, look);
vsize = MAGNITUDE(temp);
vsize *= 2.0;
}
VSUBUNIT(dir,look,eye);
anim_dirn2mat(mat,dir,norm);
VSET(norm, mat[1],mat[5], 0.0);
switch (print_mode) {
case LOOKAT_SCRIPT:
printf("start %d;\n",frame++);
printf("clean;\n");
if (print_viewsize)
printf("viewsize %.10g;\n",vsize);
printf("eye_pt %.10g %.10g %.10g;\n",eye[0],eye[1],eye[2]);
printf("viewrot %.10g\t%.10g\t%.10g\t0\n", -mat[1], -mat[5], -mat[9]);
printf("%.10g\t%.10f\t%.10g\t0\n", mat[2], mat[6], mat[10]);
printf("%.10g\t%.10g\t%.10g\t0\n", -mat[0], -mat[4], -mat[8]);
printf("0\t0\t0\t1;\n");
printf("end;\n");
break;
case LOOKAT_YPR:
anim_mat2ypr(angles,mat);
angles[0] *= RTOD;
angles[1] *= RTOD;
angles[2] *= RTOD;
printf("%.10g",time);
if (print_viewsize)
printf("\t%.10g",vsize);
printf("\t%.10g\t%.10g\t%.10g",eye[0],eye[1],eye[2]);
printf("\t%.10g\t%.10g\t%.10g\n",angles[0],angles[1],angles[2]);
break;
case LOOKAT_QUAT:
anim_mat2quat(quat,mat);
printf("%.10g",time);
if (print_viewsize)
printf("\t%.10g",vsize);
printf("\t%.10g\t%.10g\t%.10g",eye[0],eye[1],eye[2]);
printf("\t%.10g\t%.10g\t%.10g\t%.10g\n",quat[0],quat[1],quat[2],quat[3]);
break;
}
}
}
#define OPT_STR "f:yqv"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'f':
sscanf(bu_optarg,"%d",&frame);
break;
case 'y':
print_mode = LOOKAT_YPR;
break;
case 'q':
print_mode = LOOKAT_QUAT;
break;
case 'v':
print_viewsize = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-97
View File
@@ -1,97 +0,0 @@
.TH ANIM_OFFSET 1 BRL/CAD
.SH NAME
anim_offset - create an animation table for an object rigidly attached to
another object.
.SH SYNOPSIS
.B anim_offset
.B -o # # #
.B [-r]
.B < in.table
.B > out.table
.SH DESCRIPTION
This filter operates on animation tables of the type used by
.I tabsub
and
.I anim_script.
Given a table specifying the position and
orientation of one object at every applicable time,
.I anim_offset
calculates
the position of another object which is rigidly attached to it.
.PP
The columns of the input table should be time, three columns of
position, followed by yaw, pitch, and roll. The output will be
normally be a four-column file specifying time and position. If the
.B -r
option is used, the output is a seven-column file in which the last
three columns are copies of the orientation information from the input
file.
.PP
The position of the object relative to the rigid body should be
given on the command line in the order x, y, z, with the
.B -o # # #
option. These offset values
should be as measured from the centroid of the rigid body.
.SH EXAMPLES
This filter could be used, for example, to do an animation where
the camera is placed inside a moving vehicle.
.PP
Suppose that truck.table contains the desired position of the
center of the front axle of the truck as well as its orientation at each
time. One row of the table might look like this:
.nf
35.2 12450 -140 600 90.0 0.0 0.0
.fi
Thus 35.2 seconds into the animation, the center of the front axle will
be at (12450, -140, 600), and the truck will be pointed in the positive
y direction. (yaw = 90).
.PP
Now, suppose we want the camera to ride along in the cab, above
and behind the front axle and somewhat to the left. To specify this
offset, we use the coordinate frame of the truck, with the origin at the
center of the front axle, the x-axis to the front, y to the left, and z
pointing up. Let the exact offset from the axle to the desired camera
position in this case be (-600, 900, 1200), in units of mm. Now we use
the routine:
.nf
anim_offset -o -600 900 1200 < truck.table > camera.table
.fi
The result is a four-column table giving the desired position of the
virtual camera at each time. The row corresponding to the sample row
above would be:
.nf
35.2 11550 -740 1800
.fi
With the
.B -r
option, the output would have been:
.nf
35.2 11550 -740 1800 90.0 0.0 0.0
.fi
Now
.I tabsub
and/or
.I anim_script
can be used to process these two animation
tables into an animation script.
.SH BUGS
The program will only use orientations specified as yaw,
pitch, and roll. You can get around this using
.IR anim_orient ,
which converts between different orientation representations.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-104
View File
@@ -1,104 +0,0 @@
/* A N I M _ O F F S E T . C
*
* Animate an object which is rigidly attached to another.
*
* Given an animation table specifying the position and orientation of
* one object, anim_offset produces a similar table specifying the
* position of an object rigidly attached to it.
*
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
extern int bu_optind;
extern char *bu_optarg;
int full_print = 0;
vect_t offset;
main(argc,argv)
int argc;
char **argv;
{
int val;
fastf_t yaw, pitch, roll, time;
vect_t temp,point,zero;
mat_t mat;
VSETALL( temp , 0.0 );
VSETALL( point , 0.0 );
VSETALL( zero , 0.0 );
(void) get_args(argc,argv);
while (1) {
/*read line from table */
val = scanf("%lf%*[^-0123456789]",&time); /*read time,ignore garbage*/
val = scanf("%lf %lf %lf", point, point+1, point +2);
val = scanf("%lf %lf %lf", &yaw, &pitch, &roll);
if (val < 3) {
break;
}
anim_dy_p_r2mat(mat,yaw, pitch,roll);
anim_add_trans(mat,point,zero);
MAT4X3PNT(temp,mat,offset);
printf("%.10g\t%.10g\t%.10g\t%.10g",time, temp[0], temp[1], temp[2]);
if (full_print)
printf("\t%.10g\t%.10g\t%.10g", yaw, pitch, roll);
printf("\n");
}
}
#define OPT_STR "ro:"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'r':
full_print = 1;
break;
case 'o':
sscanf(argv[bu_optind-1],"%lf",offset+0);
sscanf(argv[bu_optind],"%lf",offset+1);
sscanf(argv[bu_optind+1],"%lf",offset+2);
bu_optind += 2;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-217
View File
@@ -1,217 +0,0 @@
.TH ANIM_ORIENT 1 BRL/CAD
.SH NAME
anim_orient - convert between orientation formats
.SH SYNOPSIS
.B anim_orient
.B [q|y|a|z|m][vri]
.B [q|y|a|z|m][vriu]
.B < in.table
.B > out.table
.SH DESCRIPTION
.I Anim_orient
is a filter which translates a table of orientation
information from one format to another. The method used is to convert
the input format to a matrix, then convert the matrix to the desired
output format. The input format is specified in the first argument, and
the output format is specified in the second.
The orientation formats
must be one of the following:
.B q
(quaternion),
.B y
(yaw,pitch, and roll),
.B a
(azimuth, elevation, and twist),
.B z
(x-y-z angles), or
.B m
(rotation matrix).
In addition, the output format may be modified by the
.B u
option, and the input and output formats may be modified by the
.BR r ,
.BR i ,
and
.B v
options. The
.B r
option specifies that angles are read or written in radians, rather
than degrees. The
.BR i , v ,
and
.B u
options are explained below.
.PP
To clearly understand the operation of anim_orient, it is important to
examine the difference between orientation and rotation.
The matrices, quaternions, and angles
used by anim_orient specify rotations. These are transformations
which, when applied to an object, preserve its shape but change its
orientation with respect to a fixed set of axes. Given the initial
orientation of an object, a rotation defines the final orientation, but
different initial orientations will yield different final orientations.
In order
to represent orientations with rotations, we
must define a default initial orientation for the object.
Then a given matrix, quaternion, or set of angles represents the orientation
resulting from applying the rotation to the initial object orientation.
.PP
If no modifying codes are specified, anim_orient assumes that the
default orientation of the object in question faces the positive
x-direction, with the world y-axis pointing to the object's left and the
z-axis pointing up. This is the orientation in which many
.I brlcad
objects
are modeled, and the default assumed by other animation routines such as
anim_script. If the
.B v
code is specified, then the default orientation
is taken to be facing the negative z-direction, with the world x-axis
pointing to the object's right and the y-axis pointing up. This is the
default orientation of the eye in
.I mged
and
.IR rt .
Some common uses of the v
option are demonstrated in the examples section.
.PP
The input and output format codes are:
.TP
.BR q :
Quaternions, in the order x,y,z,w. This is the default input and
output format. The output will
always be unit quaternions. For a unit quaternion, the
xyz-vector represents an axis of rotation and and w represents
cos(omega/2), where
omega is the angle to be rotated about the given axis.
.TP
.BR z :
x-y-z angles, in the order x, y, z. They represent a rotation
of z degrees around the z-axis, followed by y degrees around the y-axis,
followed by x degrees around the x-axis. If the code
.B zr
is used
then the angles will be read or written in radians
rather than degrees.
.TP
.BR y :
yaw-pitch-roll format, in that order. They represent
a rotation of +roll degrees about the x-axis, -pitch degrees about
the y-axis, followed by +yaw degrees about the z-axis. If the code
.B yr
is used, angles are in radians rather than degrees.
.TP
.BR a :
azimuth, elevation, twist, in that order. They represent a rotation of
-twist degrees about the x-axis, +elevation degrees about the y-axis,
and +azimuth + 180 degrees about the z-axis. Alternatively, they can
be thought of as a 180 degree rotation about the z-axis followed by a
rotation of +twist degrees about the x-axis, -elevation degrees about
the y-axis, and +azimuth degrees about the z-axis.
.TP
.BR m :
pre-multiplication rotation matrix. Sixteen
numbers form a 4x4 matrix, although only the nine elements in the upper
left corner are actually used. This is the format used at the interior of
the conversion routine. It is a transformation from initial orientation to
a new orientation.
.PP
The input and ouput modification codes are:
.TP
.B i
This code is used in conjunction with any of the format codes to represent
the inverse transformation. Under the
.B i
code, a matrix, quaternion, or
set of angles represents the inverse of the rotation that it normally
represents.
For example, normally, the orientation
corresponding to a given matrix is the orientation that the default
object ends up in after the matrix is applied to it. With the
.B i
code,
a given matrix represents the orientation an object should be placed
in so that the applying the matrix puts it back in the default
orientation.
One common use of the
.B i
option is for handling "Viewrot" matrices used
by
.I mged
and
.IR rt .
The viewrot matrix is a model-to-view matrix, which is
the transpose (inverse) of the matrix which would conceptually be
applied to an eye object to put it in the desired place in the model.
.TP
.B v
When this option is specified, the corresponding rotation is considered
applied to the default view orientation, rather than the default object
orientation, as explained above.
.TP
.B u
This option forces the output orientation to be upright, or "right-side
up", where the z-axis is the up direction. In terms of yaw, pitch, and
roll, this means that the roll is forced to zero. Because this is a
one-way operation, it can only be applied to the output orientation, not
the input.
.SH EXAMPLES
.sp
Normalize a table of quaternions to unit magnitude. (quaternions are the
default format).
.sp
anim_orient < in.table > out.table
.sp
change xyz angles to a rotation matrix
.sp
anim_orient z m < in.table > out.table
.sp
change azimuth,elevation, and twist to a matrix suitable for the
.I rt
viewrot command
.sp
anim_orient a miv < in.table > out.table
.sp
transpose matrices
.sp
anim_orient m mi < in.table > out.table
.sp
change radian xyz angles to yaw-pitch-roll in degrees
.sp
anim_orient zr y < in.table > out.table
.sp
given a quaternion being applied to an object facing the x-axis,
find the quaternion needed
to turn the virtual camera in the same direction using
.IR rt 's
orientation command
.sp
anim_orient q qv < in.table > out.table
.sp
Given the yaw, pitch, and roll of an object, find the yaw, pitch, and
roll which would bring it back to the default position.
.sp
anim_orient y yi < in.table > out.table
.sp
Force a table of view quaternions to represent "right-side up"
orientations.
.sp
anim_orient qv qvu < in.table > out.table
.SH BUGS
There are built-in trouble spots which occur, in ypr, xyz, or aet
formats, when the pitch, y-rotation, or elevation is an odd multiple of 90
degrees, because at this point the other two angles become
indistinguishable. The program makes the arbitrary assumption that the
roll is zero or that the x-rotation is zero, depending on the format,
and gives a warning to that effect on standard error.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-279
View File
@@ -1,279 +0,0 @@
/* A N I M _ O R I E N T . C
*
* Convert between different orientation formats. The formats are:
* quaternion, yaw-pitch-roll, azimuth-elevation-twist, xyz angles,
* pre-multiplication rotation matrices, and transposed matrices (inverses).
* By default, the information is assumed to represent a transformation
* which should be an object which initially faces the x-axis, with the
* z-axis going up. Alternatively, the information can be interpreted as
* transformations which should be applied to an object initially facing the
* negative z-axis, with the y-axis going up.
* The conversion is done by converting each input form to a matrix,
* and then converting that matrix to the desired output form.
* Angles may be specified in radians or degrees.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define YPR 0
#define XYZ 1
#define AET 2
#define QUAT 3
#define MAT 4
#define DEGREES 0
#define RADIANS 1
#define ANIM_NORMAL 0
#define ANIM_ERROR1 1
#define ANIM_ERROR2 2
#define DTOR M_PI/180.0
#define RTOD 180.0/M_PI
extern int optind;
extern char *optarg;
int upright;
int input_mode, output_mode, length, input_units, output_units;
int input_perm, output_perm, input_inv, output_inv;
main(argc,argv)
int argc;
char **argv;
{
int num_read;
fastf_t temp[3], temp2[3],angle[3],quat[4],matrix[16],tmatrix[16];
void anim_zyx2mat(),anim_ypr2mat(),anim_quat2mat(), anim_mat_print();
int anim_mat2ypr(),anim_mat2zyx(),anim_mat2quat();
if(!parse_args(argc,argv)) {
fprintf(stderr,"Get_args error.\n");
exit(0);
}
/* read data */
num_read = length;
while (1){
switch (input_mode) {
case YPR:
case XYZ:
case AET:
num_read = scanf("%lf %lf %lf",angle,angle+1,angle+2);
/* convert to radians if in degrees */
if (input_units==DEGREES) {
VSCALE(angle,angle,DTOR);
}
break;
case QUAT:
num_read = scanf("%lf %lf %lf %lf", quat,quat+1,quat+2,quat+3);
break;
case MAT:
num_read = 0;
num_read += scanf("%lf %lf %lf %lf",matrix,matrix+1,matrix+2,matrix+3);
num_read += scanf("%lf %lf %lf %lf",matrix+4,matrix+5,matrix+6,matrix+7);
num_read += scanf("%lf %lf %lf %lf",matrix+8,matrix+9,matrix+10,matrix+11);
num_read += scanf("%lf %lf %lf %lf",matrix+12,matrix+13,matrix+14,matrix+15);
break;
}
if (num_read < length)
break;
/* convert to (object) matrix form */
switch (input_mode) {
case YPR:
anim_ypr2mat(matrix,angle);
break;
case AET:
anim_y_p_r2mat(matrix, angle[0]+M_PI, -angle[1],-angle[2]);
break;
case XYZ:
anim_zyx2mat(matrix,angle);
break;
case QUAT:
anim_quat2mat(matrix,quat);
break;
}
if (input_inv){
anim_tran(matrix);
}
if (input_perm){
anim_v_unpermute(matrix);
}
/* end of input conversion, begin output conversion*/
if (upright) { /* force right-side up */
VSET(temp, matrix[0], matrix[4], matrix[8]);
VSET(temp2, matrix[1], matrix[5], matrix[9]);
anim_dirn2mat(matrix,temp,temp2);
}
if (output_perm){
anim_v_permute(matrix);
}
if (output_inv){
anim_tran(matrix);
}
/* convert from matrix form and print result*/
switch (output_mode) {
case YPR:
anim_mat2ypr(angle,matrix);
if (output_units==DEGREES)
VSCALE(angle,angle,RTOD);
printf("%.12g\t%.12g\t%.12g\n",angle[0],angle[1],angle[2]);
break;
case AET:
anim_mat2ypr(angle,matrix);
if (angle[0] > 0.0) {
angle[0] -= M_PI;
} else {
angle[0] += M_PI;
}
angle[1] = -angle[1];
angle[2] = -angle[2];
if (output_units==DEGREES)
VSCALE(angle,angle,RTOD);
printf("%.12g\t%.12g\t%.12g\n",angle[0],angle[1],angle[2]);
break;
case XYZ:
anim_mat2zyx(angle,matrix);
if (output_units==DEGREES)
VSCALE(angle,angle,RTOD);
printf("%.12g\t%.12g\t%.12g\n",angle[0],angle[1],angle[2]);
break;
case QUAT:
anim_mat2quat(quat,matrix);
printf("%.12g\t%.12g\t%.12g\t%.12g\n",quat[0],quat[1],quat[2],quat[3]);
break;
case MAT:
anim_mat_print(stdout,matrix,0);
printf("\n");
}
}
}
int parse_args(argc,argv)
int argc;
char **argv;
{
int c;
char *cp;
/* defaults */
upright = 0;
input_mode = QUAT;
output_mode = QUAT;
input_units = DEGREES;
output_units = DEGREES;
input_perm = 0;
output_perm = 0;
input_inv = 0;
output_inv = 0;
length = 4;
if (argc > 2) { /*read output mode */
cp = argv[2];
while (c=*cp++) {
switch (c) {
case 'q':
output_mode = QUAT;
break;
case 'y':
output_mode = YPR;
break;
case 'a':
output_mode = AET;
break;
case 'z':
output_mode = XYZ;
break;
case 'm':
output_mode = MAT;
break;
case 'i':
output_inv = 1;
break;
case 'r':
output_units = RADIANS;
break;
case 'v':
output_perm = 1;
break;
case 'u':
upright = 1;
break;
default:
fprintf(stderr,"anim_orient: unknown output option: %c\n",c);
return(0);
}
}
}
if (argc > 1) { /*read input mode */
cp = argv[1];
while (c=*cp++) {
switch (c) {
case 'q':
input_mode = QUAT;
length = 4;
break;
case 'y':
input_mode = YPR;
length = 3;
break;
case 'a':
input_mode = AET;
length = 3;
break;
case 'z':
input_mode = XYZ;
length = 3;
break;
case 'm':
input_mode = MAT;
length = 16;
break;
case 'i':
input_inv = 1;
break;
case 'r':
input_units = RADIANS;
break;
case 'v':
input_perm = 1;
break;
default:
fprintf(stderr,"anim_orient: unknown input option: %c\n",c);
return(0);
}
}
}
return(1);
}
-339
View File
@@ -1,339 +0,0 @@
.TH ANIM_SCRIPT 1 BRL/CAD
.SH NAME
anim_script - make an animation script for one object
.SH SYNOPSIS
.B anim_script
.B [-v #]
.B [-r|t|s]
.B [-q][-p]
.B [-a|b # # #]
.B [-c|d # # #]
.B [-f #]
.B [-m cmd]
.B [objectname]
.B < in.table
.B > out.script
.SH DESCRIPTION
.I Anim_script
is designed to produce an animation script for the
animation of the virtual camera or one
.I brlcad
object at a time. It is
complementary to
.I tabsub
in that it performs a similar
function, but with a different philosophy.
.PP
Both
.I anim_script
and
.I tabsub
use one row of an animation table to
produce one frame of an animation script. With
.I tabsub,
the user supplies
a template file which controls the form of the animation frames. This
allows the maximum user control, but also requires a good understanding
of the script format. With
.I anim_script,
the user supplies all the necessary
information on the command line. The range of possible output scripts is
limited, but the user does not have to deal directly with the details.
Both routines have special features which make certain common situations
easy to do. One of the most important special features of
.I anim_script
is the
ability to specify a reference position and orientation, as explained
below.
.PP
The objectname is the name of the object which is to be
animated, as it will appear in the ouput script. For example, if
"hatch1"
is a member of "turret" which is a member of "tank" which is one of the
objects specified on the command line of the call to
.I rt,
then the objectname "tank/turret/hatch1" or simply "turret/hatch1" would be used to
animate the hatch. The tank itself would be referred to by the name,
"/tank". Note that toplevel objects should be preceeded by a slash.
If view animation is being performed, no objectname
should be included.
.PP
.B in.table
should be a seven-column animation table,
specifying the time, 3d position, yaw, pitch and roll of the
object (or camera), although this changes if the
.BR -r ,
.BR -t ,
.BR -s ,
or
.B -v#
options are used.
.SH OPTIONS
.TP
.B \-r
.B in.table
is a four-column file including time and rotation
information only. No translation will occur.
.TP
.B \-t
.B in.table
is a four-column file including time and translation
information only. No rotation will occur.
.TP
.B \-s
.B in.table
is a four-column file including time and translation
information only. The vehicle will be rotated (steered) to face the
direction of motion.
.TP
.B \-q
Quaternion orientation. Any orientation information in
.B in.table
will be in quaternion form, in the order x,y,z,w. The identity quaternion
representing no orientation change is (0,0,0,1).
.TP
.B \-p
Permuted orientation. This option indicates that transformations defined by
the quaternions should be applied to an object which has first been placed
in
.IR rt 's
default eye orientation. Thus, the identity quaternion represents yawing the
object 90 degrees to the left and then pitching it 90 degrees downward.
The quaternions produced by
.IR mged 's
saveview command and used by
.IR rt 's
orientation command
are quaternions of this type. See
.I anim_orient
for more information.
.TP
.B \-v#
The desired output is a view animation script, rather
than an object animation script. No object should be specified. The
argument can be any floating point number. If
the argument
is positive, the command:
.sp
viewsize #;
.sp
will be placed at the beginning of the ouput file. If it is
zero, the `viewsize' command is omitted from the output script. If it is
negative, then the
viewsize for each frame is expected to be in the first column after the
time in
.BR in.table .
A `viewsize' command would then be
included immediately after the `start' command of each frame.
.TP
.B \-f#
Specify the integer with which to begin
numbering the frames of the output script. The default is 0.
.PP
The remaining options give information about the object which is
to be animated.
.TP
.B \-a # # #
or
.TP
.B \-b # # #
These options take three arguments, which are the
yaw, pitch, and roll of the object's axes with respect to the
world axes. With
.B \-a,
rotations specified in the infile will be applied
with respect to the object's axes. With the
.B \-b
option, the object is
rotated so that its axes coincide with the world axes, and then all
rotations and translations are carried out with respect to the world
axes. The
.B \-b
option is particularly useful in conjunction with the
.B \-s
option, because it tells
.I anim_script
which way the front of the vehicle faces. See
the examples below.
.TP
.B \-c # # #
or
.TP
.B \-d # # #
These options take three arguments, which are the x, y,
and z coordinates of the point which is to be considered the "centroid"
of the object. All rotations will occur about this point. If
.B \-c
is used,
translations from the input table will be considered to be relative
displacements from this point. If
.B \-d
is used, the translations in the
input table will be interpreted as absolute displacement from the world
origin. The direction of translation in both cases is along the world
axes, unless the
.B \-a
option has been used, in which case the
translations are with respect to the object's axes. See the examples below.
.PP
When the
.B \-v
option is used, the virtual camera is the object
being animated, and so the meaning of the preceeding four options
changes somewhat. The
.B \-c
and
.B \-a
options are not useful in this context.
The
.B \-d
option can be thought of as specifying the position and
orientation of a virtual
tripod with respect to the camera lens. The translations and rotations
specified in
the input table will be applied to the tripod, to which the camera is
rigidly attached. For example, the option
.B \-d 10 0 \-2
in conjunction with
the
.B \-v#
option means that the virtual tripod is 10 units in front of the
camera and 2
units below the camera's line of sight. The option
.B \-b -90 0 0
in this
context would mean that the front of the virtual tripod faces 90 degrees
to the right of the virtual camera. As translation and rotation
information are read in from in.table, they are applied to the virtual
tripod, with the virtual camera rigidly attached. See below for examples
of how this might be used.
.TP
.B -m cmd
Specify a matrix command to use in, object animation. The default value
is "lmul", which means that matrices in the output script are
multiplied onto the
left of the matrix between the object being animated and its parent.
The matrix residing between the object and its parent is referred to as
the current arc. The possible matrix commands are the following:
.nf
lmul - left-multiply the matrix onto the current arc
rmul - right-multiply the matrix onto the current arc
rarc - replace the current arc with the matrix
rstack - replace the stack of ancestor matrices with the matrix
rboth - replace the current arc with the matrix and replace the
stack of ancestor matrices with the identity matrix.
.fi
This option is intended primarily to give expert users additional
flexibility, and shouldn't be needed by most animators.
.SH EXAMPLES
To animate a truck which is modeled with the front facing the positive
x-direction, the position of the center of the truck and its orientation at
each time should be in
.BR truck.table .
If the center of the modeled truck is at
the point (234,0,1200) then the following command could be used:
.sp
anim_script -d 234 0 1200 /truck < truck.table > truck.script.
.sp
If the front of the model truck faces (for some reason)
halfway
between the x and y axes, a
.B \-b
option is added, to show the relationship
between world and truck axes:
.sp
anim_script -b 45 0 0 -d 234 0 1200 /truck < truck.table > truck.script.
.sp
To steer the truck automatically to face the direction of motion,
the
.B \-s
option is added, and the orientation columns should be removed from
.BR truck.table .
.sp
anim_script -s -b 45 0 0 -d 234 0 1200 /truck < truck.table > truck.script.
.sp
.sp
Animating a steering wheel: Suppose the steering wheel is stored
in the database so that the axis it turns on is at an yaw of -135
degrees and an pitch of 30 degrees. It passes through the point
(700,800,2400). Then we select "rotation only" with
.B \-r
and specify the
relationship between the steering wheels axes and the world with the
.B \-a
and
.B \-c
options. In
.B roll.table
we put the time, two zero columns, and a
column specifying the roll of the wheel (How much it is to be twisted).
.sp
anim_script -r -a -135 30 0 -c 700 800 2400 truck/steering_column/wheel <
roll.table > steer.table
.sp
Alternativly, if the turning of the wheel was stored in the yaw
(second) column of a file,
.BR turn.table ,
a different set of axes would be
used to achieve the same effect:
.sp
anim_script -r -a 45 60 0 -c 700 800 2400 truck/steering_column/wheel <
turn.table > steer.table
.sp
.PP
To animate seven little men doing simultaneous backflips in different
places, you would want to use relative motion. That is, a translation
vector of (0,0,1) means move one unit upward, instead of move to the
point (0,0,1). For each little man, we specify his position in the
model using the
.B \-c
option. Then we can use the same backflip instuctions
for each of the little men.
.sp
anim_script -c 12 34 5 /little.man.one < generic.backflip.table >
little.man.one.script
.sp
anim_script -c -3 13 5 /little.man.two < generic.backflip.table >
little.man.two.script
.sp
and so on.
.sp
.sp
.SS Camera examples
If we know the desired postion of the camera and its orientation
at each time, it's very simple. The
.B -v#
option indicates that the view is
being animated; no object is specified.
.sp
anim_script -v0 < view.table > view.script
.sp
To follow a truck, so that the camera is always ten units behind and 4
units above it, we specify a virtual tripod in front of and below the
camera:
.sp
anim_script -v0 -d 10 0 -4 < truck.table > view.script
.sp
To do the same thing but with the camera turned to look at the right
side of the truck, we specify that the virtual tripod originally faces
to the right, so that the camera faces its right side. Thus when the
virtual tripod is placed in the same position and orientation as the
truck, the camera will be looking at the right side of the
truck.
.sp
anim_script -v0 -d 10 0 -4 -b -90 0 0 < truck.table > view.script
.SH BUGS
The reading of command line options which take more than one
argument are somewhat finicky. For example, it understands the
option "-d 1 1 1" but not "-d1 1 1".
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-257
View File
@@ -1,257 +0,0 @@
/* A N I M _ S C R I P T . C
*
* Turn an animation table into an animation script suitable for
* use by rt. Anim_script.c makes a script for one object at a time (or the
* virtual camera). Some of the available options include rotation
* only, translation only, automatic steering, and specifying reference
* coordinates.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
extern int bu_optind;
extern char *bu_optarg;
/* info from command line args */
int relative_a, relative_c, axes, translate, quaternion, rotate;/*flags*/
int steer, view, readview, permute; /* flags*/
int first_frame;
fastf_t viewsize;
vect_t centroid, rcentroid, front;
mat_t m_axes, m_rev_axes; /* rotational analogue of centroid */
char mat_cmd[10]; /* default is lmul */
main(argc,argv)
int argc;
char **argv;
{
void anim_dx_y_z2mat(), anim_add_trans();
fastf_t yaw, pitch, roll;
vect_t point, zero;
quat_t quat;
mat_t a, m_x;
int val, go, frame, last_steer;
frame=last_steer=go=view=relative_a=relative_c=axes=0;
VSETALL(centroid,0);
VSETALL(rcentroid,0);
VSETALL(front,0);
VSETALL(point,0);
VSETALL(zero,0);
yaw = pitch = roll = 0.0;
MAT_IDN(m_axes);
MAT_IDN(m_rev_axes);
MAT_IDN(a);
if (!get_args(argc,argv))
fprintf(stderr,"anim_script: Get_args error\n");
frame = (steer) ? first_frame -1 : first_frame;
if (view && (viewsize > 0.0))
printf("viewsize %.10g;\n", viewsize);
while (1) {
/* read one line of table */
val = scanf("%*f"); /*ignore time */
if (readview)
scanf("%lf",&viewsize);
if(translate)
val=scanf("%lf %lf %lf", point, point+1, point+2);
if(rotate&&quaternion){
val = scanf("%lf %lf %lf %lf", quat,quat+1,quat+2,quat+3);
val -= 1;
} else if (rotate) {
val=scanf("%lf %lf %lf",&yaw,&pitch,&roll);
}
if (val < 3){ /* ie. scanf not completely successful */
/* with steering option, must go extra loop after end of file */
if (steer && !last_steer)
last_steer = 1;
else break;
}
/* calculate basic rotation matrix a */
if (steer)
go = anim_steer_mat(a,point,last_steer); /* warning: point changed by anim_steer_mat */
else if (quaternion) {
anim_quat2mat(a,quat);
go = 1;
} else {
anim_dx_y_z2mat(a,roll,-pitch,yaw);/* make ypr matrix */
go = 1;
}
/* if input orientation (presumably from quaternion) was
* designed to manipulate the view, first move the object
* to the default object position */
if (permute)
anim_v_unpermute(a);
/* make final matrix, including translation etc */
if (axes){ /* add pre-rotation from original axes */
mat_mul(m_x,a,m_rev_axes);
MAT_MOVE(a,m_x);
}
anim_add_trans(a,point,rcentroid); /* add translation */
if (axes && relative_a){ /* add post-rotation back to original axes */
mat_mul(m_x,m_axes,a);
MAT_MOVE(a,m_x);
}
if (relative_c)
anim_add_trans(a,centroid,zero); /* final translation */
/* print one frame of script */
if (go && view){
printf("start %d;\n", frame);
printf("clean;\n");
if (readview)
printf("viewsize %.10g;\n", viewsize);
printf("eye_pt %.10g %.10g %.10g;\n",a[3],a[7],a[11]);
/* implicit anim_v_permute */
printf("viewrot %.10g %.10g %.10g 0\n",-a[1],-a[5],-a[9]);
printf("%.10g %.10g %.10g 0\n", a[2], a[6], a[10]);
printf("%.10g %.10g %.10g 0\n", -a[0], -a[4],-a[8]);
printf("0 0 0 1;\n");
printf("end;\n");
}
else if (go){
printf("start %d;\n", frame);
printf("clean;\n");
printf("anim %s matrix %s\n", *(argv+bu_optind), mat_cmd);
anim_mat_print(stdout,a,1);
printf("end;\n");
}
frame++;
}
}
#define OPT_STR "a:b:c:d:f:m:pqrstv:"
int get_args(argc,argv)
int argc;
char **argv;
{
int c, i, yes;
double yaw,pch,rll;
void anim_dx_y_z2mat(), anim_dz_y_x2mat();
rotate = translate = 1; /* defaults */
quaternion = permute = 0;
strcpy(mat_cmd, "lmul");
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
i=0;
switch(c){
case 'a':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf", &yaw );
sscanf(argv[bu_optind+(i++)],"%lf", &pch );
sscanf(argv[bu_optind+(i++)],"%lf", &rll );
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
axes = 1;
relative_a = 1;
break;
case 'b':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf", &yaw );
sscanf(argv[bu_optind+(i++)],"%lf", &pch );
sscanf(argv[bu_optind+(i++)],"%lf", &rll );
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
axes = 1;
relative_a = 0;
break;
case 'c':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf",centroid);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+1);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+2);
bu_optind += 3;
VREVERSE(rcentroid,centroid);
relative_c = 1;
break;
case 'd':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf",centroid);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+1);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+2);
bu_optind += 3;
VREVERSE(rcentroid,centroid);
relative_c = 0;
break;
case 'f':
sscanf(bu_optarg,"%d",&first_frame);
break;
case 'm':
strncpy(mat_cmd,bu_optarg, 10);
break;
case 'p':
permute = 1;
break;
case 'q':
quaternion = 1;
break;
case 'r':
rotate = 1;
translate = 0;
break;
case 's':
steer = 1;
relative_a = 0;
rotate = 0;
translate = 1;
break;
case 't':
translate = 1;
rotate = 0;
break;
case 'v':
yes = sscanf(bu_optarg,"%lf",&viewsize);
if (!yes) viewsize = 0.0;
if (viewsize < 0.0)
readview = 1;
view = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-143
View File
@@ -1,143 +0,0 @@
.TH ANIM_SORT 1 BRL/CAD
.SH NAME
anim_sort - combine concatenated animation scripts into one script
.SH SYNOPSIS
.B anim_sort
.B [-ic]
.B < mixed.script
.B > ordered.script
.SH DESCRIPTION
Note:
.I anim_sort
has been preempted in release 5.0 by
.IR scriptsort ,
which sorts scripts much faster.
.PP
.I Anim_sort
allows the user to combine several animation scripts
into a single script suitable for input to
.IR rt .
A convenient way to
prepare a complicated animation script is to develop each part
separately and then use
.I anim_sort
to combine the various parts. For
example, suppose that
.B view.script
is an animation script controlling the
movement of the virtual camera and the lighting,
.B mill.script
rotates
the blades of a windmill, and
.B quixote.script
controlls the movement of a
knight. These scripts should first be concatenated together:
.sp
cat view.script mill.script quixote.script > mixed.script
.sp
Calling
.I anim_sort
with
.B mixed.script
on standard input would
reorder the commands in
.B mixed.script
to make a viable script on standard
output.
.sp
Each of the input files to be concatenated is expected to be a
viable
.I rt
animation script, containing a series of frames of the
following form:
.sp
.nf
start framenumber;
any number of semi-colon terminated commands for rt;
end;
any number of post-raytracing commands
.fi
.sp
.I Anim_sort
reads the framenumber of the first start command, and uses
this to as the first frame number of the output file. The commands of
all frames in
.B mixed.script
with that framenumber are combined in the
ouput frame. The post-raytracing commands following all frames with that
framenumber are placed after the
.B end;
command of the output frame. This process is continued for each
successive integer,
until anim_sort reaches a framenumber which is not included in any of
the original scripts.
.sp
For example, if
.B view.script
contained frames numbered from 5 to
20,
.B mill.script
contained frames from 0 to 10, and
.B quixote.script
contained frames numbered from 15 to 25, the output script would start
at frame 5 (since
.B view.script
comes first in
.B mixed.script
) and end with
frame 25 (since frames 5 through 25 can be found somewhere in
.B mixed.script
). If the user wanted to include frames 0 through 4, which
are found only in
.B mill.script
, then
.B mill.script
should be concatenated
onto the beginning of
.B mixed.script
instead of the middle. In the
majority of animation situations, all of the input scripts would have
identical frame numbers anyway.
.sp
The first input script may also contain some lines preceeding
the first start command, which are copied to the beginning of the output
script. This is useful for commands such as 'viewsize', which are often
specified before the sequence of animations begins.
.sp
.SH OPTIONS
.TP
.B \-i
Incremental mode. The frames of the output script are printed in a scrambled
order which incrementally increases the time resolution of the animation.
For example, the frames of an eight-frame script would be printed in the
order: 0 4 2 6 1 3 5 7.
.TP
.B \-c
For most animation purposes, it is desirable to have a
.B clean
command immediately following the
.B start
command of each frame. The
default behavior of
.I anim_sort
is to include one
.B clean
command following the
.B start
command of each frame.
.B clean
commands from the input files are ignored. If the
.B -c
flag is activated, then no clean
commands are printed.
.SH SEE ALSO
rt(1), tabsub(1), anim_script(1)
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-184
View File
@@ -1,184 +0,0 @@
/* A N I M _ S O R T . C
*
* Combine multiple animation scripts on standard input into a
* single script on standard output. The output can be in natural order
* or in a scrambled order for incrementally increasing time
* resolution (-i option).
*
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "machine.h"
#include "externs.h"
#include "bu.h"
#define MAXLEN 50 /*maximum length of lines to be read */
#define MAXLINES 30 /* maximum length of lines to be stored*/
int suppressed; /* flag: suppress printing of 'clean;' commands */
int incremental; /* flag: order for incremental time resolution */
main(argc, argv)
int argc;
char **argv;
{
int length,frame_number, number, success, maxnum;
int first_frame,spread,reserve;
long last_pos;
char line[MAXLEN];
char pbuffer[MAXLEN*MAXLINES];
if (!get_args(argc,argv))
fprintf(stderr,"Get_args error\n");
/* copy any lines preceeding the first "start" command */
last_pos = ftell(stdin);
while (fgets(line,MAXLEN,stdin)!=NULL){
if (strncmp(line,"start",5)){
printf("%s",line);
last_pos = ftell(stdin);
}
else
break;
}
/* read the frame number of the first "start" command */
sscanf( strpbrk(line,"0123456789"),"%d", &frame_number);
/* find the highest frame number in the file */
maxnum = 0;
while(fgets(line,MAXLEN,stdin)!=NULL){
if(!strncmp(line,"start",5)){
sscanf(strpbrk(line,"0123456789"),"%d",&number);
maxnum = (maxnum>number)?maxnum:number;
}
}
length = maxnum - frame_number + 1;
/* spread should initially be the smallest power of two larger than
* or equal to length */
spread = 2;
while (spread < length)
spread = spread<<1;
first_frame = frame_number;
success = 1;
while (length--){
number = -1;
success = 0; /* tells whether or not any frames have been found which have the current frame number*/
if (incremental){
fseek(stdin, 0L, 0);
} else {
fseek(stdin, last_pos, 0);
}
reserve = MAXLEN*MAXLINES;
pbuffer[0] = '\0'; /* delete old pbuffer */
/* inner loop: search through the entire file for frames */
/* which have the current frame number */
while (!feof(stdin)){
/*read to next "start" command*/
while (fgets(line,MAXLEN,stdin)!=NULL){
if (!strncmp(line,"start",5)){
sscanf( strpbrk(line,"0123456789"),"%d", &number);
break;
}
}
if (number==frame_number){
if (!success){ /*first successful match*/
printf("%s",line);
if (!suppressed) printf("clean;\n");
success = 1;
last_pos = ftell(stdin);
}
/* print contents until next "end" */
while (fgets(line,MAXLEN,stdin)!=NULL){
if (!strncmp(line,"end;",4))
break;
else if (strncmp(line,"clean",5))
printf("%s",line);
}
/* save contents until next "start" */
while (fgets(line,MAXLEN,stdin)!=NULL){
if(!strncmp(line,"start",5))
break;
else {
reserve -= strlen(line);
reserve -= 1;
if (reserve > 0){
strncat(pbuffer,line,MAXLEN);
strcat(pbuffer,"\n");
}
}
}
}
}
if (success)
printf("end;\n");
/* print saved-up post-raytracing commands, if any */
printf("%s",pbuffer);
/* get next frame number */
if (incremental){
frame_number = frame_number + 2*spread;
while (frame_number > maxnum){
spread = spread>>1;
frame_number = first_frame + spread;
}
} else {
frame_number += 1;
}
}
}
#define OPT_STR "ci"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
suppressed = 0;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'c':
suppressed = 1;
break;
case 'i':
incremental = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-89
View File
@@ -1,89 +0,0 @@
.TH ANIM_TIME 1 BRL/CAD
.SH NAME
anim_time - estimate appropriate time parameters for path
.SH SYNOPSIS
.B anim_time
.B [-s start_speed (absolute)]
.B [-e end_speed (absolute)]
.B [-i initial_speed (relative)]
.B [-f final_speed (relative)]
.B [-m max_len]
.B [-v|q]
.B < in.table
.B > out.table
.SH DESCRIPTION
This filter is designed to estimate appropriate time parameters for
an animation curve in 3D space. Given a four-column table specifying
time and 3D position for an object,
.I anim_time
ignores all but the first and last time specifications and
calculates reasonable time values for each intermediate point in the table.
The
output time values are based on the distances between points and the
calculated speed of the object. Various options allow the user to
control the assumptions on the object's initial and final speeds, and the
form of the output.
.I Anim_time
is intended to be used in situations where the user knows what key points
an object should pass through and how long the entire motion should take,
but doesn't care exactly when the object
reaches each point. It is also useful for getting objects to accelerate
smoothly to and from rest.
.SH OPTIONS
.TP
.BR -m #
Specify the maximum number of points to be read. This default to 64, so
you must use this option if you want to use tables with more than 64
points.
.TP
.BR -s #
Specify the starting speed of the object. If this option is not
specified, then the object is assumed to be initially travelling on a
pace to negotiate the entire path in the given time at a constant rate.
The argument must be positive and no greater than three times the speed
needed to traverse the path at a constant rate.
.TP
.BR -e #
Specify the final speed of the object. If this option is not specified,
then the object is assumed to end up travelling on a pace to negotiate
the entire path in the given time at a constant rate. The argument must
be positive and no greater than three times the speed needed to traverse
the path at a constant rate.
.TP
.BR -i #
Specify the initial speed of the object, relative to the speed that
would negotiate the given path at a constant rate. For example, an
argument of 2.0 means twice the speed needed to traverse the path at a
constant rate. Must lie between 0.0 and 3.0.
.TP
.BR -f #
Specify the final speed of the object, relative to the speed that would
negotiate the given path at a constant rate. Must lie between 0.0 and
3.0.
.TP
.B -v
Verbose option. The output table will contain a time column and three
position columns. If this option is not specified, only the new time
column will be printed.
.TP
.B -q
Query the total distance. If this option is specified, the only output
will be a number representing the total length of the input path.
.SH BUGS
The algorithm fits a cubic polynomial to the distance vs time graph, and then
uses Newton's method to find the times corresponding to each given distance.
If for some reason convergence is not reached,
.I anim_time
will print a warning on standard error. If the
.B -d
option is specified, the results of each iteration will be printed.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1996 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-284
View File
@@ -1,284 +0,0 @@
/* A N I M _ T I M E . C
*
* Given an animation path consiting of time stamps and 3-d points,
* estimate new time stamps based on the distances between points, the
* given starting and ending times, and optionally specified starting
* and ending velocities.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "externs.h"
#include "vmath.h"
#include "bu.h"
#include "raytrace.h"
extern int bu_optind;
extern char *bu_optarg;
#define MAXLEN 64
#define DIVIDE_TOL (1.0e-10)
#define MAXITS 100
#define DELTA (1.0e-6)
#define TIME_NONE 0
#define TIME_ABSOLUTE 1
#define TIME_RELATIVE 2
/* command line variables */
fastf_t inv0,inv1;
int v0_set = TIME_NONE;
int v1_set = TIME_NONE;
int query = 0;
int verbose = 0;
int maxlines = 0;
int domem = 0;
int debug = 0;
fastf_t
gettime(dist, a, b, c, init)
fastf_t dist;
fastf_t a;
fastf_t b;
fastf_t c;
fastf_t init;
{
fastf_t old,new,temp,inv;
int countdown,success;
countdown = MAXITS;
old = init;
success = 0;
while(countdown-->0){
temp = (3.0*a*old+2.0*b)*old+c;
if (temp<DIVIDE_TOL){
new = 0.75*old;
} else {
new = old - (((a*old+b)*old+c)*old-dist)/temp;
}
if (((new-old)<DELTA)&&((old-new)<DELTA)){
success = 1;
break;
}
if (debug)
printf("c: %d %f\t%f\n",countdown,new,new-old);
old = new;
}
if (!success) fprintf(stderr,"warning - max iterations reached\n");
return (new);
}
main(argc,argv)
int argc;
char **argv;
{
fastf_t *l, *x, *y, *z;
fastf_t temp0,temp1,temp2,start,end,v0,v1;
int i,j , num,plen;
fastf_t time,dist,slope,a,b,c;
plen = 0;
if (!get_args(argc,argv))
fprintf(stderr,"Usage: anim_time [-s#] [-e#] [-d] < in.table\n");
if (!domem) {
maxlines = MAXLEN;
}
l = (fastf_t *) rt_malloc(maxlines*sizeof(fastf_t),"l[]");
if (verbose) {
x = (fastf_t *) rt_malloc(maxlines*sizeof(fastf_t),"x[]");
y = (fastf_t *) rt_malloc(maxlines*sizeof(fastf_t),"y[]");
z = (fastf_t *) rt_malloc(maxlines*sizeof(fastf_t),"z[]");
} else {
x = (fastf_t *) rt_malloc(2*sizeof(fastf_t),"x[]");
y = (fastf_t *) rt_malloc(2*sizeof(fastf_t),"y[]");
z = (fastf_t *) rt_malloc(2*sizeof(fastf_t),"z[]");
}
l[0] = 0.0;
while(plen<maxlines){
i = (verbose) ? plen : plen%2;
j = (verbose) ? (plen-1) : (plen+1)%2;
num = scanf("%lf %lf %lf %lf",&end,x+i,y+i,z+i);
if (num<4)
break;
if(plen){
temp0 = x[i]-x[j];
temp1 = y[i]-y[j];
temp2 = z[i]-z[j];
l[plen] = sqrt(temp0*temp0+temp1*temp1+temp2*temp2);
l[plen] += l[plen-1];
} else {
start = end;
}
plen++;
}
time = end - start;
dist = l[plen-1];
if (query){
printf("%f\n",dist);
return(0);
}
if (time < DIVIDE_TOL){
fprintf(stderr,"anim_time: time too small. Only %f s.\n",time);
exit(-1);
}
if (dist < DIVIDE_TOL){
fprintf(stderr,"anim_time: pathlength too small. Only %f\n",dist);
exit(-1);
}
slope = dist/time;
switch (v0_set) {
case TIME_ABSOLUTE:
v0 = inv0;
break;
case TIME_RELATIVE:
v0 = slope*inv0;
break;
default:
case TIME_NONE:
v0 = slope;
break;
}
switch (v1_set) {
case TIME_ABSOLUTE:
v1 = inv1;
break;
case TIME_RELATIVE:
v1 = slope*inv1;
break;
default:
case TIME_NONE:
v1 = slope;
break;
}
if (v0<0.0) {
fprintf(stderr,"anim_time: Start velocity must be non-negative.\n");
exit(-1);
}
if (v1<0.0) {
fprintf(stderr,"anim_time: End velocity must be non-negative.\n");
exit(-1);
}
if (v0>3*slope) {
fprintf(stderr,"anim_time: Start velocity must be not be greater than %f units/s for this path.\n", 3.0*slope);
exit (-1);
}
if (v1>3*slope) {
fprintf(stderr,"anim_time: End velocity must not be greater than %f for this path.\n", 3.0*slope);
exit(-1);
}
a = ((v1+v0) - 2.0*slope)/(time*time);
b = (3*slope - (v1+2.0*v0))/time;
c = v0;
temp2 = 1.0/slope;
if (verbose) {
printf("%.12e\t%.12e\t%.12e\t%.12e\n",start,x[0],y[0],z[0]);
for (i=1; i<plen-1; i++){
temp0 = gettime(l[i],a,b,c,l[i]*temp2);
printf("%.12e\t%.12e\t%.12e\t%.12e\n",temp0+start,x[i],y[i],z[i]);
}
printf("%.12e\t%.12e\t%.12e\t%.12e\n",end,x[plen-1],y[plen-1],z[plen-1]);
} else {
printf("%.12e\n",start);
for (i=1; i<plen-1; i++){
temp0 = gettime(l[i],a,b,c,l[i]*temp2);
printf("%.12e\n",temp0+start);
}
printf("%.12e\n",end);
}
rt_free((char *) l, "l[]");
rt_free((char *) x, "x[]");
rt_free((char *) y, "y[]");
rt_free((char *) z, "z[]");
}
/* code to read command line arguments*/
#define OPT_STR "ds:e:i:f:qm:v"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 's':
sscanf(bu_optarg,"%lf",&inv0);
v0_set = TIME_ABSOLUTE;
break;
case 'e':
sscanf(bu_optarg,"%lf",&inv1);
v1_set = TIME_ABSOLUTE;
break;
case 'i':
sscanf(bu_optarg,"%lf",&inv0);
v0_set = TIME_RELATIVE;
if ((inv0>3.0)||(inv0<0.0)) {
fprintf(stderr,"anim_time: -i argument must lie between 0.0 and 3.0\n");
exit(-1);
}
break;
case 'f':
sscanf(bu_optarg,"%lf",&inv1);
v1_set = TIME_RELATIVE;
if ((inv1>3.0)||(inv1<0.0)) {
fprintf(stderr,"anim_time: -f argument must lie between 0.0 and 3.0\n");
exit(-1);
}
break;
case 'q':
query = 1;
break;
case 'm':
sscanf(bu_optarg,"%d",&maxlines);
domem = 1;
break;
case 'v':
verbose = 1;
break;
case 'd':
debug = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-435
View File
@@ -1,435 +0,0 @@
.TH ANIM_TRACK 1 BRL/CAD
.SH NAME
anim_track - make an script to model or animate the pads and wheels of a
tracked vehicle.
.SH SYNOPSIS
.B
anim_track [options] wheelfile < in.table > out.script
.SH DESCRIPTION
.I anim_track
is designed to produce an animation script for the
animation of the track pads and/or the wheels which define the track.
Alternatively, track can output a file which produces a track model
when sourced by mged.
.PP
A track consists of a number of identical pads which
are wrapped in a chain around two or more ordered wheels. Normally, the
track is linear between the wheels. The exeption is that between the
first and last wheels, any extra track length is taken up in a hanging
caternary arc.
.PP
Anim_track requires two input files. The first, referred to above as
.BR wheelfile ,
is a table which
defines the initial track geometry by describing the wheels around which
the track is to be wrapped. The first three columns of the table give
the center point of the wheels, and the fourth column gives the radius
of each wheel. The table contains one line for each wheel; the
wheels should be listed in clockwise order as viewed from the right of
the vehicle. This is the direction that the track pads move around the
wheels when the vehicle is moving forward.
.PP
The track is part of a vehicle which has a front, back, left, right, up,
and down. By default these directions are +x, -x, +y, -y, +z, and -z,
respectively, but any orientation can be specified by the user with the
.B -b
option.
The track is always confined to a plane which has no left to right
variation; that is, the wheels can be in front of, behind, above, and
below each other, but may not be to the left or right of each other. If
the wheel positions specified in
.B wheelfile
do not lie in such a plane, then the first wheel defines the plane into
which all of the other wheels are projected.
.PP
The track pads are spread evenly along the entire length of the track.
The track segments between wheels are always linear, except for the
segment between the first and last wheels. If there is any extra track
length, it is taken up in a caternary arc which hangs down between the
first and last wheels. Thus if the the first wheel in
.B wheelfile
should be the top front wheel of the vehicle, and the last wheel in
.B wheelfile
should be the top back wheel of the vehicle. Depending on the track
length mode specified with the
.B -l
option, the caternary segment may or may not appear.
.PP
The second input file required by
.IR anim_track ,
referred to above as
.BR in.table ,
describes the state of the track in every frame of the animation. The
format of this second file can vary greatly according to the command-line
options. The first column of the file is ignored, but is expected to
contain the time values corresponding to each frame. Next come one or
more columns which specify directly or indirectly the distance that the
track has rolled around the wheels in each frame (see the
.BR -u ,
.BR -y ,
and
.B -s
options). Finally, the file may specify new wheel position for every
frame (see the
.B -v
option).
.PP
.SH MODEL REQUIREMENTS
Certain model conventions are needed in order for the animation to work
properly. First of all, if the wheels are to be animated, they must
all be named
.IR wheelname . i ,
where
.I i
ranges from 0 to one less than the number of wheels.
.I wheelname
is an arbitrary string.
.IR wheelname 0
must be
the top front wheel in a given track and
.IR wheelname (n-1)
must be the top
back wheel. The central axes of all the wheels should be parallel to
each other and perpendicular to a plane containing all of the wheel
centers.
.PP
The pads of the track should be identical instances or copies of a
prototype pad object, and they all should be named
.IR padname i,
where
.I i
ranges from 0 to one less than the number of pads.
The prototype pad should be centered on the origin in the x and y
directions. In the z direction, the inner, wheel-contacting surface of
the pad should lie on the z=0 plane. The outer, ground-contacting
surface should face the positive z-direction. The side of the pad which
would connect with the pad in front of it should face the positive x
direction, and the side which would connect with the pad behind it
should face the negative x direction. If the pads are a part of a higher
level combination, as they typically are, then the matrix between each
pad and the higher combination may be modified at will as long as the
prototype pad is not disturbed.
.SH OPTIONS
.TP
.B -p num_pads parent/basename
Animate the track pads. This option takes two arguments; the number of
pads in the track and a slash-separated path to the pad basename.
For
example, if there is a combination named "lpads" containing 80 track
pads with names ranging from "pad.0" to "pad.79", then the correct
arguments would be:
.sp
.B -p 79 lpads/pad.
.sp
Each frame of the output animation script will contain an animation
command for each of the track pads.
.TP
.B -w parent/basename
Animate the track wheels. This option takes one argument: a
slash-separated path to the wheel basename. The number of wheels is
obtained from the number of lines in the
.BR wheelfile .
If there is, for example, a combination named "rwheels" containing 4
wheels named wheel_0, wheel_1, wheel_2, and wheel_3, then the correct
argument is:
.sp
.B -w rwheels/wheel_
.sp
Each frame of the output animation script will contain an animation
command for each of the wheels.
.TP
.B \-b # # #
Specify the yaw, pitch, and roll of the vehicle's axes
with respect to the world axes. By default, the vehicle is assumed to
have a yaw, pitch, and roll of 0, and the track is therefore put into a
xz plane.
.TP
.B \-d # # #
Specify (in world coordinates) the centroid of the vehicle
of which the track is a part. By default, the vehicle is assumed
centered at the origin.
.TP
.B -u
User-specified track distance. The user
should provide, in the second column of
.IR in.table ,
the distance that the track should be rolled around the wheels in each
frame. This is the default.
.TP
.B -y
Derive the track distance from a table of position, yaw, pitch, and
roll. The second column through the seventh columns of the
.I in.table
should contain the position and orientation of the vehicle in every
frame. The distance that the track should be rolled around the wheels is
automatically calculated in every frame. If
.I anim_script
is being used with the same table to create the animaion script for the
vehicle itself, the
.B -b
and
.B -d
options to
.I anim_script
and
.I anim_track
should be the same.
.TP
.B -s
Derive the track distance from a table of positions, using automatic
steering. The second column through the fourth column of the
.I in.table
should contain the position of the vehicle in every frame. The distance
that the track should be rolled around the wheels is automatically
calculated in every frame, based on the assumption that the vehicle is
always steered to face the direction of motion.
If
.I anim_script
is being used with the same table to create the animaion script for the
vehicle itself, the
.B -b
and
.B -d
options to
.I anim_script
and
.I anim_track
should be the same.
.TP
.B -a
Enable anti-strobing measures. When the track is rolling fast enough, track
animations exhibit a strobing effect which may make the track appear to
slow down or rotate backwards. This is an artifact of the discrete time
nature of the animations, and occurs when the distance traveled by the
track in one frame is close to the pad length. If the
.B -a
option is selected,
.I anim_track
adds random jitter to the track's motion when the track speed is high
enough to cause strobing. This causes a motion blur effect rather than
strobing.
.TP
.B -v
Specify new wheel positions in every frame. This option allows dynamic
suspensions to be animated. If there are n wheels, then the last 2n
columns of
.I in.table
should contain the front-back and up-down coordinates of each wheel,
relative to the vehicle center and orientation specified with
.B -d
and
.BR -b .
The columns should be in pairs: The front-back coordinate of the first
wheel, followed by its up-down coordinate, followed by the front-back
coordinate of the second wheel, and so on.
.sp
If this option is not specified, then the wheel positions are fixed
throughout the animation.
.TP
.B -c
Calculate the track circumference, that is, the length of the shortest
track that can wrap around a given set of wheels. If the -v option is
specified, then
the output is a table containing the frame number and the track
circumference in each frame. Otherwise, a single value representing the
constant track circumference is returned.
.TP
.B -lm
Minimize the track length. With this option the length of the track is
set to the track circumference in every frame, ie the track shrinks to
fit the wheels.
.TP
.B -lf #
Specify a fixed track length. The argument specifies the track length, which
remains constant throughout the animation. If at any time the track
circumference exceeds the track length, the program is aborted and a
message is printed on standard error.
.TP
.B -ls #
Specify a stretchable track. The argument specifies the initial track
length. If at any time the track circumference exceeds the track length,
the track length is increased to meet the need. The track length never
decreases once it has been increased.
.TP
.B -le #
Specify an elastic track. The argument specifies the initial track
length. If at any time the track circumference exceeds the track length,
the track length is increased to meet the need. When the track
circumference decreases again, the track length also decreases, but it
never gets shorter than its original length.
.TP
.B -i #
Specify the initial offset of the track. By default, the first track pad
is initially placed at the point where the caternary arc meets the first
wheel. If an offset is specified, it represents the distance clockwise
around the track to from this point to the desired initiall point of
the first pad. This option is typically used to align the track pads
with drive wheel teeth.
.TP
.B -f #
Specify the integer with which to begin numbering the frames of the
animation script. The default is zero.
.TP
.B -r #
Specify the common radius of all the wheels. In this case, the fourth column
should be omitted from the
.BR wheelfile .
.TP
.B -g #
Instead of an animation script, create a file which can be sourced by
.I mged
to edit the track geometry. This will actually wrap the modeled pad
instances around the wheels.
The argument is the number of the frame which is to be emulated. For
example, to model the pads in the positions they will have in the first
frame of an animation, the specified frame number would be zero.
.TP
.B -mp command
Specify the animation matrix command to apply to the pads. The default
value is "rarc", meaning that the matrix between the pad and its parent
is replaced by a new matrix. See the
.I anim_script
man page for more information.
.TP
.B -mw command
Specify the animation matrix command to apply to the wheels. The default
value is "lmul", meaning that the new matrix is multiplied onto the left
of the old matrix between the pad and its parent combination. See the
.I anim_script
man page for more information.
.SH EXAMPLES
A typical use of
.I anim_track
would be to make an animation of a tank rolling across
bumpy ground. By some method (such as physical simulation)
you obtain the position of the center of
the tank and its orientation at each time. You also nead to obtain the
position of the each wheel relative to the vehicle center at each time.
All of this information is placed in
.BR in.table .
The model of the tank is stored in
model.g as a combination named "tank". Its centroid is at the
point (0,0,1005) and it faces the y-axis. An animation script for the
tank itself is created as follows:
.PP
anim_script -d 0 0 1005 -b 90 0 0 /tank < tank.table > tank.script
.PP
Here
.B tank.table
specifies the position and orientation of the tank in each frame; the
.B \-d
and
.B \-b
options specify the original position and orientation of the tank in the
database.
.PP
To create the model of the track, a prototype track pad is created,
centered on the origin in the x and y directions, with the
wheel-contacting surface face-down on the origin. The pad is 100mm
long and 5mm thick. Ninety-six instances of the pad are created, with names "rpad.0"
through "rpad.95", and grouped together in a combination called "rtrack".
.PP
Now, a file called
.B rwheelfile
is created, describing the positions and radii of the four wheels in the
right track:
.nf
1300 2000 1005 60
1300 1500 55 50
1300 -1500 55 50
1300 -2000 1005 60
.fi
Two roadwheels both have radius 50mm, while the idler and drivewheels
have a 60mm radius, and the wheels are named wh.0, wh.1, wh.2, and wh.3.
.PP
The following call checks the circumference of the track:
.nf
%> anim_track -c rwheelfile
9502.448956
.fi
The 96 100mm-long pads should be sufficient to wrap around the wheels,
leaving a shallow caternary arc between the idler and driver wheels.
.PP
The following call creates a file which can be used by
.I mged
to wrap the pads around the wheels in the model.
.nf
%> anim_track -g 0 -b 90 0 0 -d 0 0 100 -lf 9600 -p 96 rtrack/rpad.
rwheelfile <<EOF > rtrack.src
? 0 0
? EOF
.fi
In this case,
.I in.table
consisted of only one row and two columns. The two columns represented
time and the distance the track should be rolled from it's initial
position. The
.B -g
option was set to 0 since frame zero was the only frame in the
input table.
The changes are applied to the geometry in
.I mged
with the following command:
.nf
mged> source rtrack.src
.fi
The pads are now permanently modeled in their new positions.
.PP
In order to animate the pads and wheels, the following command would be
appropriate:
.PP
anim_track -p 96 rtrack/rpad. -w rwheel/wh. -d 0 0 1005 -b 90 0 0 -y -v -lf
9600 rwheelfile < in.table > rtrack.script
.PP
The in.table contains 15 columns specifying the time, the 3D position and
yaw, pitch, and roll of the vehicle, and the front-back and up-down
coordinates of each of the four wheels relative to the vehicle center.
For example, one row of
.B in.table
could be:
.PP
0.5 234.0 1415.6 1005 45 0 0 2000 0 1500 -950 -1500 -950 -2000 -10
.PP
This would specify the new position of the vehicle half of a second into
the animation, and indicate that
the first three wheels remained in their original positions
while the fourth wheel had dropped 10mm.
Note that the previous step (modeling) wasn't necessary in order for the
animation to work.
.PP
.B rtrack.script
by itself causes the wheels to move and rotate and the
pads to roll around them. When the entire tank, including to track,
is moved along across the ground by
.BR track.script ,
the full effect is acheived. The two scripts
could be combined
with a script for the left track, using
.IR script_sort ,
to make the complete script.
.PP
.SH BUGS
Tracks must have at least two wheels. The front edge of wheel.(n-1) must
stay behind the back edge of wheel.0, or the results are unpredictable.
(Usually a lot of NaN's on the output).
.SH SEE ALSO
anim_script(1)
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1996 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-685
View File
@@ -1,685 +0,0 @@
/* A N I M _ T R A C K . C
*
* Animate the links and wheels of a tracked vehicle. Handles tracks that
* change in shape during the animation.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "externs.h"
#include "vmath.h"
#include "raytrace.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#define GIVEN 0
#define CALCULATED 1
#define STEERED 2
#define PRINT_ANIM 0
#define PRINT_ARCED 1
#define TRACK_MIN 0
#define TRACK_FIXED 1
#define TRACK_STRETCH 2
#define TRACK_ELASTIC 3
#define NW num_wheels
#define NEXT(i) (i+1)%NW
#define PREV(i) (i+NW-1)%NW
typedef double *pdouble;
struct wheel {
vect_t pos; /* displacement of wheel from vehicle origin */
fastf_t rad; /* radius of wheel */
fastf_t ang0; /* angle where track meets wheel 0<a<2pi*/
fastf_t ang1; /* angle where track leaves wheel 0<a<p2i */
fastf_t arc; /* radian length of contact between wheel and track 0<a<pi*/
};
struct track {
vect_t pos0; /* beginning point of track section */
vect_t pos1; /* end of track section */
vect_t dir; /* unit vector:direction of track section ending here*/
fastf_t len; /* length of track section ending here*/
};
struct slope {
vect_t dir; /* vector from previous to current axle*/
fastf_t len; /* length of vector above*/
};
struct all {
struct wheel w; /* parameters describing the track around a wheel */
struct track t; /* track between this wheel and the previous wheel */
struct slope s; /* vector between this axle and the previous axle */
};
/* external variables */
extern int bu_optind;
extern char *bu_optarg;
/* variables describing track geometry - used by main, trackprep, get_link*/
struct all *x;
fastf_t curve_a, curve_b, curve_c, s_start;
int num_links, num_wheels;
fastf_t track_y, tracklen, first_tracklen;
/* variables set by get_args */
int wheel_nindex; /* argv[wheel_nindex] = wheelname*/
int link_nindex; /* argv[link_nindex] = linkname*/
int print_wheel; /* flag: do wheel animation */
int print_link; /* flag: do link animation */
int print_mode; /* anim for rt or arced for mged */
int arced_frame; /* which frame to arced */
int axes, cent; /* flags: alternate axes, centroid specified */
int dist_mode; /* given, steered, or calculated */
int first_frame; /* integer to begin numbering frames */
fastf_t init_dist; /* initial distance of first link along track */
int one_radius; /* flag: common radius specified */
fastf_t radius; /* common radius of all wheels */
vect_t centroid, rcentroid; /* alternate centroid and its reverse */
mat_t m_axes, m_rev_axes; /* matrices to and from alternate axes */
char link_cmd[10]; /* default is "rarc" */
char wheel_cmd[10]; /* default is "lmul" */
int get_circumf; /* flag: just return circumference of track */
int read_wheels; /* flag: read new wheel positions each frame */
int len_mode; /* mode for track_len */
int anti_strobe; /* flag: take measures against strobing effect */
main(argc,argv)
int argc;
char **argv;
{
void anim_y_p_r2mat(), anim_add_trans(), anim_mat_print();
int get_args(), get_link(), track_prep(), val, frame, i, count;
int go;
fastf_t y_rot, distance, yaw, pch, roll;
vect_t cent_pos, wheel_now, wheel_prev;
vect_t zero, position, vdelta, temp, to_track, to_front, norm;
mat_t wmat, mat_x;
FILE *stream;
struct wheel *wh;
int last_steer, last_frame;
int rndtabi;
fastf_t halfpadlen, delta, prev_dist;
VSETALL(zero,0.0);
VSETALL(to_track,0.0);
VSETALL(centroid,0.0);
VSETALL(rcentroid,0.0);
y_rot = 0.0;
num_wheels = 0;
last_steer = last_frame = 0;
MAT_IDN(mat_x);
MAT_IDN(wmat);
MAT_IDN(m_axes);
MAT_IDN(m_rev_axes);
if (!get_args(argc,argv))
fprintf(stderr,"Anim_track: Argument error.\n");
if (axes || cent ){ /* vehicle has own reference frame */
anim_add_trans(m_axes,centroid,zero);
anim_add_trans(m_rev_axes,zero,rcentroid);
}
/* get track information from specified file */
if (!(stream = fopen(*(argv+bu_optind),"r"))){
fprintf(stderr,"Track: Could not open file %s.\n",*(argv+bu_optind));
return(0);
}
num_wheels = -1;
if (one_radius) {
while (!feof(stream)) {
fscanf(stream,"%*lf %*lf %*lf");
num_wheels++;
}
} else {
while (!feof(stream)) {
fscanf(stream,"%*lf %*lf %*lf %*lf");
num_wheels++;
}
}
rewind(stream);
/*allocate memory for track information*/
/* x: contains track geometry for the current frame */
x = (struct all *) calloc(num_wheels,sizeof(struct all));
/* wh: contains geometry of wheels in mged database */
wh = (struct wheel *) calloc(num_wheels,sizeof(struct wheel));
/*read original wheel positions*/
for (i=0;i<NW;i++){
fscanf(stream,"%lf %lf %lf", temp, temp+1, temp+2);
if (one_radius)
x[i].w.rad = radius;
else
fscanf(stream,"%lf",& x[i].w.rad);
MAT4X3PNT(x[i].w.pos,m_rev_axes,temp);
if (i==0)
track_y = x[0].w.pos[1];
else
x[i].w.pos[1] = track_y;
wh[i].pos[0] = x[i].w.pos[0];
wh[i].pos[1] = x[i].w.pos[1];
wh[i].pos[2] = x[i].w.pos[2];
wh[i].rad = x[i].w.rad;
}
(void) fclose(stream);
/* initialize to_track */
VSET(to_track, 0.0, track_y, 0.0);
VSET(to_front,1.0,0.0,0.0);
if (get_circumf&& (!read_wheels)) {
track_prep();
printf("%.10g\n",tracklen);
return(0);
}
if (dist_mode==STEERED) {
/* prime the pumps */
scanf("%*f");/*time*/
val = scanf("%lf %lf %lf", cent_pos, cent_pos+1, cent_pos + 2);
if (val < 3)
return(0);
go = anim_steer_mat(mat_x, cent_pos, 0);
last_steer = 0;
} else {
go = 1;
}
if (anti_strobe) {
RT_RANDSEED(rndtabi, 0);
}
/* main loop */
prev_dist = distance = 0.0;
frame = first_frame;
for ( ; ; frame++) {
if (dist_mode==GIVEN){
scanf("%*f");/*time*/
val = scanf("%lf",&distance);
if (val < 1) {
break;
}
}
else if (dist_mode==CALCULATED){
scanf("%*f");/*time*/
scanf("%lf %lf %lf", cent_pos, cent_pos+1, cent_pos+2);
val = scanf("%lf %lf %lf",&yaw,&pch,&roll);
if (val < 3)
break;
anim_dy_p_r2mat(mat_x,yaw,pch,roll);
anim_dy_p_r2mat(mat_x,yaw,pch,roll);
anim_add_trans(mat_x,cent_pos,rcentroid);
}
if (read_wheels) {
/* read in all wheel positions */
for(i=0;i<NW;i++){
val=scanf("%lf %lf",x[i].w.pos, x[i].w.pos + 2);
if (val < 2) {
break;
}
}
}
if (dist_mode==STEERED) {
scanf("%*f");/*time*/
val = scanf("%lf %lf %lf", cent_pos, cent_pos+1, cent_pos + 2);
if (val < 3){
if (last_steer)
break;
else
last_steer = 1;
}
go = anim_steer_mat(mat_x, cent_pos, last_steer);
anim_add_trans(mat_x,cent_pos,rcentroid);
}
/* call track_prep to calculate geometry of track */
if ((frame==first_frame)||read_wheels) {
if ((track_prep())==-1){
fprintf(stderr,"Track: error in frame %d: track too short.\n",frame);
break;
}
if (get_circumf) {
printf("%d\t%.10g\n",frame,tracklen);
}
}
if ((dist_mode==CALCULATED)||(dist_mode==STEERED)){
/*determine distance traveled*/
VMOVE(wheel_prev,wheel_now);
MAT4X3PNT(wheel_now,mat_x,to_track);
if (frame > first_frame){ /* increment distance by distance moved*/
VSUB2(vdelta,wheel_now,wheel_prev);
MAT3X3VEC(temp,mat_x,to_front);/*new front of vehicle*/
distance += VDOT(temp,vdelta);/*portion of vdelta in line with track*/
}
}
if (anti_strobe) {
halfpadlen = 0.5 * tracklen/(fastf_t) num_links;
delta = distance - prev_dist;
prev_dist = distance;
if ((delta >= halfpadlen)||(delta <= -halfpadlen)) {
distance += RT_RANDOM(rndtabi) * 2.0* halfpadlen;
}
}
if (go && (!get_circumf)) {
if (print_mode==PRINT_ANIM) {
printf("start %d;\nclean;\n", frame);
} else if (print_mode==PRINT_ARCED) {
if (frame != arced_frame) continue;
last_frame = 1;
}
if (print_link) {
for (count=0;count<num_links;count++){
(void) get_link(position,&y_rot,distance+tracklen*count/num_links+init_dist);
anim_y_p_r2mat(wmat,0.0,y_rot,0.0);
anim_add_trans(wmat,position,zero);
if (axes || cent){ /* link moved to vehicle coords */
MAT_MOVE(mat_x,wmat);
mat_mul(wmat,m_axes,mat_x);
}
if (print_mode==PRINT_ANIM) {
printf("anim %s%d matrix %s\n", *(argv+link_nindex),count,link_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","\n",";\n");
} else if (print_mode==PRINT_ARCED) {
printf("arced %s%d matrix %s ", *(argv+link_nindex),count,link_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","","\n");
}
}
}
if (print_wheel){
for (count = 0;count<num_wheels;count++){
anim_y_p_r2mat(wmat,0.0,-distance/wh[count].rad,0.0);
VREVERSE(temp,wh[count].pos);
anim_add_trans(wmat,x[count].w.pos,temp);
if (axes || cent){
mat_mul(mat_x,wmat,m_rev_axes);
mat_mul(wmat,m_axes,mat_x);
}
if (print_mode==PRINT_ANIM) {
printf("anim %s%d matrix %s\n",*(argv+wheel_nindex),count,wheel_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","\n",";\n");
} else if (print_mode==PRINT_ARCED) {
printf("arced %s%d matrix %s ",*(argv+wheel_nindex),count,wheel_cmd);
anim_mat_printf(stdout,wmat,"%.10g ","","\n");
}
}
}
if (print_mode==PRINT_ANIM)
printf("end;\n");
}
if (last_frame) break;
}
free(x);
free(wh);
}
#define OPT_STR "sycuvb:d:f:i:r:p:w:g:m:l:a"
int get_args(argc,argv)
int argc;
char **argv;
{
int c, i;
fastf_t yaw, pch, rll;
void anim_dx_y_z2mat(), anim_dz_y_x2mat();
/* defaults*/
wheel_nindex = link_nindex = 0;
axes = cent = print_wheel = print_link = 0;
arced_frame = first_frame = 0;
init_dist = radius = 0.0;
one_radius = get_circumf = read_wheels = 0;
strcpy(link_cmd, "rarc");
strcpy(wheel_cmd, "lmul");
print_mode = PRINT_ANIM;
dist_mode = GIVEN;
len_mode = TRACK_MIN;
anti_strobe = 0;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
i=0;
switch(c){
case 's':
dist_mode = STEERED;
break;
case 'y':
dist_mode = CALCULATED;
break;
case 'c':
get_circumf = 1;
break;
case 'u':
dist_mode = GIVEN;
break;
case 'v':
read_wheels = 1;
break;
case 'b':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf", &yaw );
sscanf(argv[bu_optind+(i++)],"%lf", &pch );
sscanf(argv[bu_optind+(i++)],"%lf", &rll );
bu_optind += 3;
anim_dx_y_z2mat(m_axes, rll, -pch, yaw);
anim_dz_y_x2mat(m_rev_axes, -rll, pch, -yaw);
axes = 1;
break;
case 'd':
bu_optind -= 1;
sscanf(argv[bu_optind+(i++)],"%lf",centroid);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+1);
sscanf(argv[bu_optind+(i++)],"%lf",centroid+2);
bu_optind += 3;
VREVERSE(rcentroid,centroid);
cent = 1;
break;
case 'f':
sscanf(bu_optarg,"%d",&first_frame);
break;
case 'i':
sscanf(bu_optarg,"%lf",&init_dist);
break;
case 'r':
sscanf(bu_optarg,"%lf",&radius);
one_radius = 1;
break;
case 'p':
sscanf(bu_optarg,"%d", &num_links);
link_nindex = bu_optind;
bu_optind += 1;
print_link = 1;
break;
case 'w':
wheel_nindex = bu_optind - 1;
/*sscanf(bu_optarg,"%s",wheel_name);*/
print_wheel = 1;
break;
case 'g':
sscanf(bu_optarg,"%d",&arced_frame);
print_mode = PRINT_ARCED;
break;
case 'm':
switch (*bu_optarg) {
case 'p':
strncpy(link_cmd,argv[bu_optind], 10);
break;
case 'w':
strncpy(wheel_cmd,argv[bu_optind], 10);
break;
default:
fprintf(stderr,"Unknown option: -m%c\n",*bu_optarg);
return(0);
}
bu_optind += 1;
break;
case 'l':
switch (*bu_optarg) {
case 'm':
len_mode = TRACK_MIN;
break;
case 'f':
len_mode = TRACK_FIXED;
sscanf(argv[bu_optind],"%lf",&first_tracklen);
tracklen = first_tracklen;
bu_optind++;
break;
case 's':
len_mode = TRACK_STRETCH;
sscanf(argv[bu_optind],"%lf",&first_tracklen);
tracklen = first_tracklen;
bu_optind++;
break;
case 'e':
len_mode = TRACK_ELASTIC;
sscanf(argv[bu_optind],"%lf",&first_tracklen);
tracklen = first_tracklen;
bu_optind++;
break;
default:
fprintf(stderr,"Unknown option: -l%c\n",*bu_optarg);
return(0);
}
break;
case 'a':
anti_strobe = 1;
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
/* TRACK_PREP - Calculate the geometry of the track. Wheel positions and
* radii should already exist in the x[i] structs. Track_prep fills in the
* rest of the x[i] structs and also calculates values for curve_a, curve_b,
* curve_c, and s_start, which describe the caternary segment
* return values: 0 = GOOD
* -1 = BAD. Track too short to fit around wheels
*/
int track_prep()
{
int i;
fastf_t phi, costheta, link_angle, hyper_start_x, arc_angle;
fastf_t linearlen, hyperlen;
vect_t start, difference, link_cent;
int getcurve();
fastf_t hyper_get_s();
/* first loop - get inter axle slopes and start/end angles */
for (i=0;i<NW;i++){
/*calculate current slope vector*/
VSUB2(x[i].s.dir,x[i].w.pos,x[PREV(i)].w.pos);
x[i].s.len = MAGNITUDE(x[i].s.dir);
/*calculate end angle of previous wheel assuming all convex*/
phi = atan2(x[i].s.dir[2],x[i].s.dir[0]);/*absolute angle of slope*/
costheta = (x[PREV(i)].w.rad - x[i].w.rad)/x[i].s.len;/*cosine of special angle*/
x[PREV(i)].w.ang1 = phi + acos(costheta);
while (x[PREV(i)].w.ang1 < 0.0)
x[PREV(i)].w.ang1 += 2.0*M_PI;
x[i].w.ang0 = x[PREV(i)].w.ang1;
}
/* second loop - handle concavities */
for (i=0;i<NW;i++){
arc_angle = x[i].w.ang0 - x[i].w.ang1;
while (arc_angle < 0.0)
arc_angle += 2.0*M_PI;
if (arc_angle > M_PI) { /* concave */
x[i].w.ang0 = 0.5*(x[i].w.ang0 + x[i].w.ang1);
x[i].w.ang1 = x[i].w.ang0;
x[i].w.arc = 0.0;
}
else { /* convex - angles are already correct */
x[i].w.arc = arc_angle;
}
}
/* third loop - calculate geometry of straight track segments */
for (i=0;i<NW;i++){
/*calculate endpoints of track segment*/
x[i].t.pos1[0] = x[i].w.pos[0] + x[i].w.rad*cos(x[i].w.ang0);
x[i].t.pos1[1] = x[i].w.pos[1];
x[i].t.pos1[2] = x[i].w.pos[2] + x[i].w.rad*sin(x[i].w.ang0);
x[i].t.pos0[0] = x[PREV(i)].w.pos[0] + x[PREV(i)].w.rad*cos(x[PREV(i)].w.ang1);
x[i].t.pos0[1] = x[PREV(i)].w.pos[1];
x[i].t.pos0[2] = x[PREV(i)].w.pos[2] + x[PREV(i)].w.rad*sin(x[PREV(i)].w.ang1);
/*calculate length and direction of track segment*/
VSUB2(difference,x[i].t.pos1,x[i].t.pos0);
x[i].t.len = MAGNITUDE(difference);
VSCALE((x[i].t.dir),difference,(1.0/x[i].t.len));
}
/* calculate total track length used so far*/
linearlen = x[0].w.arc*x[0].w.rad;
for (i=1;i<NW;i++){
linearlen += x[i].t.len;
linearlen += x[i].w.arc*x[i].w.rad;
}
if (len_mode==TRACK_MIN) {
tracklen = linearlen + x[0].t.len;
curve_a = 0.0;
return(0); /* early return */
}
if (len_mode==TRACK_ELASTIC) {
tracklen = first_tracklen;
}
/* calculate geometry of hyperbolic segment */
hyperlen = tracklen - linearlen;
if(hyperlen < x[0].t.len){ /* desired length of hyperbola less than straight line*/
if((len_mode==TRACK_ELASTIC)||(len_mode==TRACK_STRETCH)){
tracklen += (x[0].t.len-hyperlen);
hyperlen = tracklen - linearlen;
}
else{
return(-1);/*bad, track is too short*/
}
}
getcurve(&curve_a,&curve_b,&curve_c,&(x[NW-1].w.ang1),&(x[0].w.ang0),hyperlen,x[NW-1].w.pos,x[0].w.pos,x[NW-1].w.rad,x[0].w.rad);
/* re-evaluate zeroth track section in light of curve information */
x[0].t.pos0[X] = x[NW-1].w.pos[X] + x[NW-1].w.rad * cos(x[NW-1].w.ang1);
x[0].t.pos0[Z] = x[NW-1].w.pos[Z] + x[NW-1].w.rad * sin(x[NW-1].w.ang1);
x[0].t.pos1[X] = x[0].w.pos[X] + x[0].w.rad * cos(x[0].w.ang0);
x[0].t.pos1[Z] = x[0].w.pos[Z] + x[0].w.rad * sin(x[0].w.ang0);
VSUB2(difference,x[0].t.pos1,x[0].t.pos0);
x[0].t.len = MAGNITUDE(difference);
VSCALE(x[0].t.dir,difference,(1.0/x[0].t.len));
if (curve_a > VDIVIDE_TOL)
s_start = hyper_get_s(curve_a, 0.0, x[0].t.pos0[X] - curve_c);
x[0].w.arc = x[0].w.ang0 - x[0].w.ang1;
if (x[0].w.arc<0.0)
x[0].w.arc += 2.0*M_PI;
x[NW-1].w.arc = x[NW-1].w.ang0 - x[NW-1].w.ang1;
if (x[NW-1].w.arc<0.0)
x[NW-1].w.arc += 2.0*M_PI;
return(0); /*good*/
}
/* GET_LINK - Find the position and angle of a link which is a given
* distance around the track, measured from the point where the caternary
* section meets wheel.0.
*/
int get_link(pos,angle_p,dist)
fastf_t *angle_p, dist;
vect_t pos;
{
int i;
vect_t temp;
fastf_t hyper_get_x(), hyper_get_z(), hyper_get_ang();
while (dist >= tracklen) /*periodicize*/
dist -= tracklen;
while (dist < 0.0)
dist += tracklen;
/* we want it to ignore the distance between wheel(n-1) and wheel(0)*/
dist += x[0].t.len;
for (i=0;i<NW;i++){
if ( (dist -= x[i].t.len) < 0 ){
VSCALE(temp,(x[i].t.dir),dist);
VADD2(pos,x[i].t.pos1,temp);
*angle_p = atan2(x[i].t.dir[2],x[i].t.dir[0]);
return(2*i);
}
if ((dist -= x[i].w.rad*x[i].w.arc) < 0){
*angle_p = dist/x[i].w.rad;
*angle_p = x[i].w.ang1 - *angle_p;/*from x-axis to link*/
pos[X] = x[i].w.pos[X] + x[i].w.rad*cos(*angle_p);
pos[Y] = x[i].w.pos[Y];
pos[Z] = x[i].w.pos[Z] + x[i].w.rad*sin(*angle_p);
*angle_p -= M_PI_2; /*angle of clockwise tangent to circle*/
return(2*i+1);
}
}
/* caternary section */
if ( curve_a > VDIVIDE_TOL){
pos[X] = hyper_get_x(curve_a, 0.0, s_start+dist);
pos[Y] = x[0].w.pos[Y];
pos[Z] = hyper_get_z(curve_a,curve_b,0.0, pos[X]);
pos[X] += curve_c;
*angle_p = hyper_get_ang(curve_a,curve_c, pos[X]);
}
else { /* practically linear */
VSCALE(temp,(x[0].t.dir),dist);
VADD2(pos,x[0].t.pos0,temp);
*angle_p = atan2(x[0].t.dir[Z],x[0].t.dir[X]);
}
return -1;
}
void show_info(which)/* for debugging - -1:track 0:both 1:link*/
int which;
{
int i;
if (which <=0){
fprintf(stderr,"track length: %f\n",tracklen);
fprintf(stderr,"link length: %f\n",tracklen/num_links);
for (i=0;i<NW;i++){
fprintf(stderr,"wheel %d: \n",i);
fprintf(stderr," pos\t%f\t%f\t%f\t\n",x[i].w.pos[X],x[i].w.pos[Y],x[i].w.pos[Z]);
fprintf(stderr," rad\t%f\tang0\t%f\tang1\t%f\tarc\t%f\n",x[i].w.rad,x[i].w.ang0,x[i].w.ang1,x[i].w.arc);
fprintf(stderr,"track %d: \n",i);
fprintf(stderr," pos0\t%f\t%f\tpos1\t%f\t%f\n",x[i].t.pos0[X],x[i].t.pos0[Z],x[i].t.pos1[X],x[i].t.pos1[Z]);
fprintf(stderr," dir\t%f\t%f\t%f\tlen\t%f\n",x[i].t.dir[X],x[i].t.dir[Y],x[i].t.dir[Z],x[i].t.len);
fprintf(stderr,"slope %d: %f %f %f %f\n",i,x[i].s.dir[0],x[i].s.dir[1],x[i].s.dir[2],x[i].s.len);
}
}
/* if (which >= 0){
fprintf(stderr,"%d %f %f %f %f\n",count,position[0],position[1],position[2],y_rot);
}*/
}
-95
View File
@@ -1,95 +0,0 @@
.TH ANIM_TURN 1 BRL/CAD
.SH NAME
anim_turn - make animation table for vehicle with front-wheel steering.
.SH SYNOPSIS
.B anim_turn -l length
.B [-a angle]
.B [-r radius]
.B [-f factor]
.B [-p integer]
.B < in.table
.B > out.table
.SH DESCRIPTION
The motion of a front wheel steered vehicle is not simple - the
instaneous velocity of the front wheels is in the direction they are
pointed, while the instantaneous velocity of the back wheels is the
direction the vehicle is pointed. The purpose of
.I anim_turn
is to
produce a complete animation table for such a vehicle, given a table
specifying the desired position of the front axle at each relevant
time step. The input table should contain four columns, specifying the
time and 3D position of the center of the front axle. Actually, the path
is assumed to be confined to an x-y plane, but the three columns are
included for consistency with other animation routines.
.PP
The output is normally a seven-column table which is a copy of
the input table with three extra columns specifying the yaw,
pitch, and roll of the truck at each time. The pitch and roll
are always zero, since the motion is assumed be in an x-y plane.
.PP
The
.B \-l#
option is not optional, and is used to specify the length
of the wheelbase (from the front axle to the rear axle).
.PP
.SH OPTIONS
.TP
.B \-a#
.I Track
assumes that the truck should initially be oriented
along the line defined by the first two positions in the input table.
Otherwise, the desired initial yaw of the truck can be specified with the
.B \-a#
option.
.TP
.B \-r#
Specify the radii of the front wheels. If this option is selected,
.I track
will create an animation script to animate the front wheels. The output
table would contain four columns: time, swivel-angle, roll, and a zero
channel. These represent the orientation of the front wheels, in terms
of yaw, pitch, and roll, and the table can be piped directly to
.IR anim_script .
.TP
.B \-f#
Specify a factor to be used to animate a steering wheel. If this option
is selected, the output table will contain four columns: time, swivel,
and two zero columns. This table can be used directly by
.I anim_script
to make an animation script for a steering wheel. The argument to the
option should be the factor by which to exagerate the swiveling of
the wheels. For
example, on a typical truck, you may need to turn the steering wheel 360
degrees in order for the wheels to swivel 20 degrees. To model this
effect, a factor of 18 would be used.
.TP
.B \-p#
Specify the ratio of input rows to output rows,
which must be an integer. The default, of course, is one. The accuracy
of the output depends on having a large number of input lines, which is
not usually a problem in animations, which require a large number of
frames per second. However, if a test animation with a small number of
frames per second is being created, the user should give an input table
with a high number of input rows and reduce the output with the
.B \-p#
option. For example, if
.B in.table
contains 30 rows for each second of the
animation, then the command
.sp
.B
anim_turn -l 3000 -p10 < in.table > out.table
.sp
would produce an animation table containing 3 rows for each second of
the animation.
.SH BUGS
The algorithm used only works for motion in an x-y plane.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-180
View File
@@ -1,180 +0,0 @@
/* A N I M _ T U R N . C
*
* Animate front-wheel steered vehicles.
*
* This is a filter which operates on animation tables. Given an
* animation table for the position of the front axle, anim_turn produces
* an animation table for position and orientation. Options provide for
* animating the wheels and/or steering wheel.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
extern int bu_optind;
extern char *bu_optarg;
int print_int = 1;
int angle_set = 0;
int turn_wheels = 0;
fastf_t length, angle, radius;
fastf_t factor = 1.0;
main(argc,argv)
int argc;
char **argv;
{
int count;
fastf_t val, time, roll_ang, yaw,sign;
vect_t v, point, front, back, zero, temp1, temp2;
mat_t m_from_world, m_to_world;
double mat_atan2();
/* initialize variables */
VSETALL(zero, 0.0);
VSETALL( v , 0.0 );
VSETALL( point, 0.0 );
VSETALL( front, 0.0 );
VSETALL( back, 0.0 );
VSETALL( temp1, 0.0 );
VSETALL( temp2, 0.0 );
for( count=0 ; count<ELEMENTS_PER_MAT ; count++ )
m_from_world[count]=m_to_world[count]=0.0;
length = angle = radius = roll_ang = 0.0;
if (!get_args(argc,argv))
fprintf(stderr,"ascript: Get_args error");
if (!angle_set) { /* set angle if not yet done */
scanf("%*f%*[^-0123456789]");
VSCAN(temp1);
scanf("%*f%*[^-0123456789]");
VSCAN(temp2);
angle = mat_atan2( (temp2[1]-temp1[1]),(temp2[0]-temp1[0]) );
rewind(stdin);
}
count = 0;
while (1) {
/* read one line of table */
val = scanf("%lf%*[^-0123456789]",&time); /*read time,ignore garbage*/
val = scanf("%lf %lf %lf", point, point+1, point +2);
if (val < 3) {
break;
}
/*update to and from matrices */
if (count) { /* not first time through */
/* calculate matrices corrsponding to last position*/
anim_y_p_r2mat(m_to_world,angle,0.0,0.0);
anim_add_trans(m_to_world,front,zero);
anim_y_p_r2mat(m_from_world,-angle,0.0,0.0);
VREVERSE(temp1,front);
anim_add_trans(m_from_world,zero,temp1);
/* calculate new position for front and back axles */
/* front goes to the point, back slides along objects*/
/* current front to back axis */
MAT4X3PNT(v,m_from_world,point);/* put point in vehicle coordinates*/
if (v[1] > length) {
fprintf(stderr,"anim_turn: Distance between positions greater than length of vehicle - ABORTING\n");
break;
}
temp2[0] = v[0] - sqrt(length*length - v[1]*v[1]); /*calculate back*/
temp2[1] = temp2[2] = 0.0;
MAT4X3PNT(back,m_to_world,temp2);/*put "back" in world coordinates*/
VMOVE(front,point);
/*calculate new angle of vehicle*/
VSUB2(temp1,front,back);
angle = mat_atan2(temp1[1],temp1[0]);
}
else { /*first time through */
/*angle is already determined*/
VMOVE(front, point);
}
/*calculate turn angles and print table*/
if (turn_wheels){
if (v[0] >= 0)
sign = 1.0;
else
sign = -1.0;
yaw = mat_atan2(sign*v[1],sign*v[0]);
if (radius > VDIVIDE_TOL)
roll_ang -= sign * MAGNITUDE(v) / radius;
if (!(count%print_int))
printf("%.10g %.10g %.10g 0.0\n",time,factor*RTOD*yaw,RTOD*roll_ang);
}
else { /* print position and orientation of vehicle */
if (!(count%print_int))
printf("%.10g %.10g %.10g %.10g %.10g 0.0 0.0\n",time,front[0],front[1],front[2], RTOD * angle);
}
count++;
}
}
#define OPT_STR "r:l:a:f:p:"
int get_args(argc,argv)
int argc;
char **argv;
{
int c;
while ( (c=bu_getopt(argc,argv,OPT_STR)) != EOF) {
switch(c){
case 'l':
sscanf(bu_optarg,"%lf",&length);
break;
case 'a':
sscanf(bu_optarg,"%lf",&angle);
angle *= DTOR; /* degrees to radians */
angle_set = 1;
break;
case 'r':
sscanf(bu_optarg,"%lf",&radius);
turn_wheels = 1;
break;
case 'f':
turn_wheels = 1;
sscanf(bu_optarg,"%lf",&factor);
break;
case 'p':
sscanf(bu_optarg,"%d",&print_int);
break;
default:
fprintf(stderr,"Unknown option: -%c\n",c);
return(0);
}
}
return(1);
}
-281
View File
@@ -1,281 +0,0 @@
/* C A T T R A C K . C
*
* Caternary curve routines used by anim_track.c
*
*/
#include "conf.h"
#include <math.h>
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "anim.h"
#define MAX_REACHED 0
#define SOLVED 1
/* the total maximum number of lowest level iterations possible is
* T_MAX_ITS*MAX_OUT_ITS*2*MAX_ITS
*/
#define MAX_ITS 25
#define MAX_OUT_ITS 25
#define T_MAX_ITS 50
/* these tolerances are guessed at, except that it seems to be important
* in elastic situations that T_TOL be significantly smaller than the others
*/
#define T_TOL 1.0e-14
#define G_TOL 1.0e-12
#define F_TOL 1.0e-12
/* HYPER_GET_X - get x value of a point which is a given distance along
* caternary curve.
* x(s) = arcsinh(a*s-sinh(a*c))/a + c
* Left to calling routine to avoid dividing by zero.
*/
fastf_t hyper_get_x(a,c, s, d, x, cos_ang)
fastf_t a, c; /* curve parameters */
fastf_t s; /* arclength value */
{
fastf_t arg, asinh_arg;
arg = a*s - sinh(a*c);
asinh_arg = log(arg + sqrt(arg*arg + 1.0));
return(asinh_arg/a + c);
}
/* HYPER_GET_S - calculate the arclength parameter of a caternary
* curve corresponding to the given value of x.
* s(x) = (sinh(a(x-c))+sinh(ac))/a
* Left to calling routime to avoid dividing by zero.
*/
fastf_t hyper_get_s(a, c, x)
fastf_t a, c, x;
{
return((sinh(a*(x-c))+sinh(a*c))/a);
}
/* HYPER_GET_Z - calculate point on the caternary curve:
* z(x) = cosh(a*(x-c))/a + b
* Left to calling routine to avoid dividing by zero.
*/
fastf_t hyper_get_z(a,b,c,x)
fastf_t a,b,c,x;
{
fastf_t z;
if (fabs(a)>VDIVIDE_TOL){
z = cosh(a*(x-c))/a + b;
} else {
z = b;
}
return(z);
}
/* HYPER_GET_ANG - calculate angle corresponding to the slope of
* caternary curve.
* z'(x) = sinh(a*(x-c))
*/
fastf_t hyper_get_ang(a,c,x)
fastf_t a,c,x;
{
fastf_t slope;
slope = sinh(a*(x-c));
return( atan2(slope, 1.0));
}
/* GET_CURVE - Find the constants a, b, and c such that the curve
* z = cosh(a*(x-c))/a + b
* is tangent to circles of radii r0 and r1 located at
* (x0,z0) and (x1,z1) and such that the curve has
* arclength delta_s between circles. Also find the angle where
* the curve touches each circle. When called successively,
* It uses the values of a,b, and c from the last call as a start.
*/
int getcurve(pa,pb,pc,pth0,pth1,delta_s, p_zero, p_one, r_zero, r_one)
fastf_t *pa, *pb, *pc; /* curve parameters */
fastf_t *pth0, *pth1; /* angle where curve contacts circle0,circle1 */
fastf_t delta_s; /* desired arclength */
fastf_t r_zero, r_one; /* radii of circle0 and circle1 */
vect_t p_zero, p_one; /* center of circle0 and circle1 */
{
int status, i, solved;
int ingetcurve();
fastf_t theta_one, theta_zero, new_theta_zero, new_theta_one;
fastf_t avg_theta_zero, avg_theta_one, arc_dist;
fastf_t tang_ang, costheta;
double stmp;
vect_t q_zero, q_one, diff;
static fastf_t last_a, last_b, last_c, last_theta_one, last_theta_zero;
static int called_before = 0;
/*first calculate angle at which tangent line would contact circles*/
VSUB2(diff,p_one,p_zero);
tang_ang = atan2(diff[Z],diff[X]);
costheta = (r_zero-r_one)/MAGNITUDE(diff);
tang_ang += acos(costheta);
if (!called_before){
theta_one = tang_ang;
theta_zero = tang_ang;
(*pa) = 1.0;
*pc = 0.5*(p_one[X]+p_zero[X]);
called_before = 1;
}
else {
theta_zero = last_theta_zero;
theta_one = last_theta_one;
*pa = last_a;
*pc = last_c;
}
status = MAX_REACHED;
for (i=0;i<T_MAX_ITS;i++){
q_zero[X] = p_zero[X] + r_zero * cos(theta_zero);
q_zero[Z] = p_zero[Z] + r_zero * sin(theta_zero);
q_one[X] = p_one[X] + r_one * cos(theta_one);
q_one[Z] = p_one[Z] + r_one * sin(theta_one);
/* determine distance taken by arc*/
arc_dist = r_zero * (tang_ang - theta_zero);
arc_dist += r_one * (theta_one - tang_ang);
ingetcurve(pa,pb,pc, delta_s-arc_dist, q_zero, q_one);
solved = 0;
/* refine theta_one */
stmp = sinh( (*pa)*(q_zero[X]-(*pc)) );
new_theta_zero = atan2(1.0,-stmp);
avg_theta_zero = 0.5 * (theta_zero + new_theta_zero);
if (fabs(theta_zero-avg_theta_zero)<T_TOL){
solved++;
}
theta_zero = avg_theta_zero;
/* refine theta_two */
stmp = sinh( (*pa)*(q_one[X]-(*pc)) );
new_theta_one = atan2(1.0,-stmp);
avg_theta_one = 0.5 * (theta_one + new_theta_one);
if (fabs(theta_one-avg_theta_one)<T_TOL){
solved++;
}
theta_one = avg_theta_one;
if (solved == 2){
status = SOLVED;
break;
}
}
last_theta_zero = theta_zero;
last_theta_one = theta_one;
last_a = *pa;
last_c = *pc;
*pth0 = theta_zero;
*pth1 = theta_one;
return(status);
}
/* INGETCURVE - find constants a, b, and c, such that the curve
* z = cosh(a*(x-c))/a + b
* passes through (x0,z0) and (x1,z1) and has arclength delta_s
* Appropriate first guesses for a,b, and c should be given.
*/
int ingetcurve(pa,pb,pc, delta_s, p_zero, p_one)
fastf_t *pa, *pb, *pc;
fastf_t delta_s;
vect_t p_zero, p_one;
{
int status, f_status, g_status, i, j, k;
fastf_t adjust;
fastf_t eff(),gee();
status = MAX_REACHED;
i=0;
while (i++<MAX_OUT_ITS){
f_status = MAX_REACHED;
for (j=0;j<MAX_ITS;j++){
adjust = eff(*pa,*pc,p_zero[X],p_one[X],delta_s);
if ((*pa-adjust)<=0.0){
*pa *= 0.5;
}
else {
*pa -= adjust;
}
if (adjust<F_TOL){
f_status = SOLVED;
break;
}
}
g_status = MAX_REACHED;
for (k=0;k<MAX_ITS;k++){
adjust = gee(*pa,*pc,p_zero[X],p_one[X],(p_one[Z]-p_zero[Z]));
*pc -= adjust;
if (adjust<G_TOL){
g_status = SOLVED;
break;
}
}
if ((j==0)&&(k==0)){
status = SOLVED;
break;
}
}
*pb = p_zero[Z] - cosh( (*pa)*(p_zero[X]-(*pc)) )/(*pa);
return(status);
}
/* find Newtonian adjustment for 'a', assuming 'c' fixed*/
fastf_t eff(a,c,x0,x1,delta_s)
fastf_t a,c,x0,x1,delta_s;
{
double f,fprime;
double arg0, arg1, sarg0, sarg1;
arg0 = a*(x0-c);
arg1 = a*(x1-c);
sarg0 = sinh(arg0);
sarg1 = sinh(arg1);
f = a*(sarg1-sarg0 - a*delta_s);
fprime = sarg0 - sarg1 - arg0*cosh(arg0) + arg1*cosh(arg1);
if (fabs(fprime) > VDIVIDE_TOL)
return(f/fprime);
else if ((a*a) > VDIVIDE_TOL)
return(f/(a*a));
else if (fabs(a) > VDIVIDE_TOL)
return(f/a);
else
return(f);
}
/* find Newtonian adjustment for c, assuming 'a' fixed*/
fastf_t gee(a,c,x0,x1,delta_z)
fastf_t a,c,x0,x1,delta_z;
{
double g, gprime, arg0, arg1;
arg0 = a*(x0-c);
arg1 = a*(x1-c);
g = cosh(arg1)-cosh(arg0) - a*delta_z;
gprime = a*(sinh(arg0) - sinh(arg1));
if (fabs(gprime) > VDIVIDE_TOL)
return(g/gprime);
else if (fabs(a) > VDIVIDE_TOL)
return(g/a);
else
return(g);
}
-64
View File
@@ -1,64 +0,0 @@
/* C H A N _ A D D . C
*
* Add a given value to specified columns of data.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
double addend, temp;
int i,j,doit, of, count, val, *col_list;
if (argc < 3) {
fprintf(stderr,"Usage: chan_add value num_columns column [column ...] < in.file > out.file\n");
return(-1);
}
sscanf(*(argv+1),"%lf",&addend);
sscanf(*(argv+2),"%d",&of);
col_list = (int *) calloc(argc-2,sizeof(int));
for (i=3;i<argc;i++){
sscanf(*(argv+i),"%d",col_list+(i-3));
}
count = 0;
while (!feof(stdin)){
val = scanf("%lf",&temp);
if (val<1)
;
else {
doit = 0;
for (j=0;j<argc-3;j++){
if (col_list[j]==count)
doit = 1;
}
if (doit)
printf("%.10g\t",temp + addend);
else
printf("%.10g\t",temp);
}
if ( count == (of-1))
printf("\n");
count = (count+1)%of;
}
}
-49
View File
@@ -1,49 +0,0 @@
.TH CHAN_MULT 1 BRL/CAD
.SH NAME
chan_mult - multiply columns of data by a given factor
.PP
chan_add - add a given value to columns of data
.SH SYNOPSIS
chan_mult factor num_columns column [column column ...] < infile > outfile
.PP
chan_add value num_columns column [column column ...] < infile > outfile
.SH DESCRIPTION
.I Mult_chan
will multiply all numbers in the specified columns by the given
factor. The infile is
an ASCII file, with columns separeted by white space. The columns are
numbered from 0 to (n-1).
.I Add_chan
behaves analogously, but with
addition rather than multiplication.
.SH EXAMPLES
These routines are useful for converting between units in animation
tables.
.PP
To multiply all but the first column of a four column file by 2.54:
.PP
.B
chan_mult 2.54 4 1 2 3
.PP
To add ten to the first six columns of an eight-column file:
.PP
.B
chan_add 10.0 8 0 1 2 3 4 5
.PP
To convert the second of three columns from Fahrenheit to Celcius:
.PP
.B
chan_add -32 3 1
.br
.B
chan_mult 0.56 3 1
.SH BUGS
The files must contain numbers and whitespaces only.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-63
View File
@@ -1,63 +0,0 @@
/* C H A N _ M U L T . C
*
* Multiply specified columns of data by a given factor.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include <stdio.h>
main(argc,argv)
int argc;
char **argv;
{
double factor, temp;
int i,j,doit, of, count, val, *col_list;
if (argc < 4){
fprintf(stderr,"Usage: chan_mult factor num_columnss column [col ... ] < in.file > out.file\n");
return(-1);
}
sscanf(*(argv+1),"%lf",&factor);
sscanf(*(argv+2),"%d",&of);
col_list = (int *) calloc(argc-2,sizeof(int));
for (i=3;i<argc;i++){
sscanf(*(argv+i),"%d",col_list+(i-3));
}
count = 0;
while (!feof(stdin)){
val = scanf("%lf",&temp);
if (val<1)
;
else {
doit = 0;
for (j=0;j<argc-3;j++){
if (col_list[j]==count)
doit = 1;
}
if (doit)
printf("%.10g\t",temp*factor);
else
printf("%.10g\t",temp);
}
if ( count == (of-1))
printf("\n");
count = (count+1)%of;
}
}
-70
View File
@@ -1,70 +0,0 @@
.TH CHAN_PERMUTE.C 1 BRL/CAD
.SH NAME
chan_permute - operate on columns of files.
.SH SYNOPSIS
.B chan_permute
.B -i infile1 id id ...
.B [-i infile2 id ...]
.B -o outfile1 id id ...
.B [-o outfile2 id ...]
.SH DESCRIPTION
This program mixes, matches, and merges ASCII files organized in
channels or columns. Each word, separated by whitespaces, should be less
than 40 characters long. The channels in each input file are specified
and then mapped to the desired channels in the output file(s). These are
the sort of things that can be done using
.I cut
and
.I paste,
but when
working on animation tables it's often nice to be able to do it in one
step.
.PP
.BR Infile s
are files to be read from,
.BR outfile s
are files to be written
to, and each
.B id
is a small positive integer identifying a channel. All of the
input
.BR id 's
should be distinct integers, or the results are not guaranteed.
.PP
.I Chan_permute
interprets
.B -i stdin
as standard input and
.B -o stdout
as
standard output.
.SH EXAMPLES
The command
.sp
chan_permute -i foo 0 1 2 -o stdout 2 1 0
.sp
reverses the order of foo's three columns and sends them to standard output.
.sp
.sp
The command
.sp
chan_permute -i file1 0 1 -i file2 2 3 -o file3 2 0 1 -o file4 3 0 1
.sp
creates file3 and file4, each containing one of the columns of file2
followed by both columns of file1.
.SH BUGS
A given file may be referenced
more than once for input, but may not be referenced for input and output
together or output and output together. In the latter case, the second
output reference overrides the other. The
.BR id 's
must be integers
somewhere between 0 and the number of arguments, inclusive.
.SH AUTHOR
Carl J. Nuzman
.SH COPYRIGHT
This software is Copyright (C) 1993 by the United States Army
in all countries except the USA. All rights reserved.
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-142
View File
@@ -1,142 +0,0 @@
/* C H A N _ P E R M U T E . C
*
* This program mixes, matches, and merges files organized in
* channels or columns.
* It's nothing cut and paste can't do, but sometimes it's nice to
* be able to do it in one step, especially when working with animation
* tables.
*Usage: channel -i infile1 id id id ... [-i infile2 ...] -o outfile1 id id ...
* [-o outfile2 ...]
*where infiles are files to be read from, outfiles are files to be written
*to, and each id is a small positive integer identifying a channel. All of the
*input id's should be distinct integers, or the results are not guaranteed.
*
* Author -
* Carl J. Nuzman
*
* Source -
* The U. S. Army Research Laboratory
* Aberdeen Proving Ground, Maryland 21005-5068 USA
*
* Distribution Notice -
* Re-distribution of this software is restricted, as described in
* your "Statement of Terms and Conditions for the Release of
* The BRL-CAD Pacakge" agreement.
*
* Copyright Notice -
* This software is Copyright (C) 1993 by the United States Army
* in all countries except the USA. All rights reserved.
*/
#include <stdio.h>
#define MAXLEN 40
typedef char Word[MAXLEN];
struct unit {
FILE *file;
int channels;
short *list;
unsigned i_o; /*i=1 o=0*/
};
char ihead[] = "-i";
char ohead[] = "-o";
main(argc,argv)
int argc;
char **argv;
{
int i,j, maxlength,num_done;
int icount, ocount;
struct unit *x, *y;
int *chan;
Word *arrayd;
i=j=icount = ocount = maxlength = 0;
for(i=1;i<argc;i++){
if( !strncmp(argv[i],ihead,2) ){
j=0;
icount++;
}
else if( !strncmp(argv[i],ohead,2) ){
j=0;
ocount++;
}
else
maxlength = (++j>maxlength) ? j : maxlength;
}
y = (struct unit *) calloc(icount+ocount,sizeof(struct unit));
x = y - 1;
for(i=1;i<argc;i++){
if( !strncmp(argv[i],"-",1) ){
j=0;
x++;
x->list = (short *) calloc(maxlength,sizeof(short));
if (argv[i][1] == 'i'){
i++;
(x)->i_o = 1;
if ( ! strcmp(argv[i],"stdin") )
x->file = stdin;
else if ( !(x->file = fopen(argv[i],"r")) )
fprintf(stderr,"Channel: can't open %s\n",argv[i]);
}
else if (argv[i][1] == 'o'){
i++;
(x)->i_o = 0;
if ( ! strcmp(argv[i],"stdout") )
x->file = stdout;
else if ( !(x->file = fopen(argv[i],"w")) )
fprintf(stderr,"Channel: can't write to %s\n",argv[i]);
}
else{
fprintf(stderr,"Illegal option %c\n",argv[i][1]);
exit(-1);
}
}
else{
sscanf(argv[i],"%hd",x->list+(j++));
x->channels++;
}
}
arrayd = (Word *) calloc(argc,sizeof(Word));/*may use more memory than absolutely necessary*/
num_done = 0;
while(num_done < icount ){ /* go until all in files are done */
num_done = 0;
for (x=y;x<y+ocount+icount;x++){ /* do one line */
if(num_done >= icount)
;/*chill - all in files done */
else if (x->i_o == 1){
if(feof(x->file))
num_done += 1;
else
for(j=0;j<x->channels;j++)
fscanf(x->file,"%s ",arrayd[x->list[j]]);
}
else if (x->i_o == 0){
for(j=0;j<x->channels;j++)
fprintf(x->file,"%s\t",arrayd[x->list[j]]);
fprintf(x->file,"\n");
}
}
}
free(arrayd);
for (x=y;x<y+ocount+icount;x++){
free(x->list);
}
free(y);
exit(0);
}
int max(m,n) /*return greatest of n integers, unless one is greater than n*/
int m[],n;
{
int i,j;
j = 0;
for (i=0;i<n;i++){
j = (m[i]>j) ? m[i] : j;
}
return( (j>n) ? 0 : j );
}
-51
View File
@@ -1,51 +0,0 @@
This is awf, the Amazingly Workable Formatter -- a "nroff -man" or
(subset) "nroff -ms" clone written entirely in (old) awk.
It is slow and has many restrictions, but does a decent job on most
manual pages and simple -ms documents, and isn't subject to AT&T's
brain-damaged licensing that denies many System V users any text
formatter at all. It is also a text formatter that is simple enough
to be tinkered with, for people who want to experiment.
Type "make r" to run a regression test, formatting the manual page
(awf.1) and comparing it to a preformatted copy (awf.1.out). Type
"make install" to install it. Pathnames may need changing.
I don't know whether awf will run on 16-bit machines. Data requirements
are modest, but I fear the programs are probably big enough to run awk
out of space.
I can't believe I really wrote this.
Henry Spencer at U of Toronto Zoology
henry@zoo.toronto.edu utzoo!henry
13 July 1990
/*
* Copyright 1990 University of Toronto. All rights reserved.
* Written by Henry Spencer.
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
*
* 4. This notice may not be removed or altered.
*/
As required by the above notice, you are informed that this software
has been slightly modified to become the formatter for the fallback
manual-page reading software for the BRL-CAD Package.
If you wish an unmodified copy of AWF, you should contact the original
author at the address above.
-33
View File
@@ -1,33 +0,0 @@
/*
* awf/Cakefile
*
* The actual formatter is located in "../brlman", because it needs to
* be installed in BINDIR.
*
* Note: The file "brlman/awf" needs to be modified when the definition of
* ETCDIR is changed.
*/
#include "../Cakefile.defs"
#define PRODUCTS common dev.dumb mac.man mac.ms \
pass1 pass2.base pass2.man pass2.ms pass3 \
AWF_COPYRIGHT
#define SRCDIR awf
#undef BINDIR
#define BINDIR ETCDIR
#define FILES /**/
#define SRCSUFF /**/
#define MANSECTION 1
#define STATIC_PRODUCTS PRODUCTS /* Force PRODUCTS into dist */
/*
* There is nothing to compile.
* The "install-prod" rule should install PRODUCTS,
* and "inst-dist" rule should take care of copying to distribution dir.
* Nothing else to do.
*/
all&:
@echo "SRCDIR: all done"
#include "../Cakefile.rules"
-212
View File
@@ -1,212 +0,0 @@
.\" Some of the stuff in this file is a bit contorted, because it's also
.\" the regression-test input.
.nr ES 5n
.de ES
.PP
.in +\\n(ESu
.nf
..
.de EE
.in -\\n(ESu
.fi
.PP
..
.de PT
.ie \\n(.$>1 .TP "\\$2"
.el .TP
.ie !'\\$1'' \\$1
.el \(bu
..
.ds Nr \fInroff\fR
.TH AWF 1 "13 July 1990"
.BY "U of Toronto"
.SH NAME
awf \- amazingly workable (text) formatter
.SH SYNOPSIS
.B awf
.BI \-m acros
[ file ] ...
.SH DESCRIPTION
.if t .tm OOPS -- AWF THINKS IT'S TROFF!!!
.I Awf
formats the text from the input \fIfile\fR(s)
(standard input if none)
in an imitation of
\*(Nr's style with the \fB\-man\fR or \fB\-ms\fR macro packages.
The
.BI \-m acro
option is mandatory and must be `\-man' or `\-ms'.
.PP
.I Awf
implements the following raw \*(Nr requests:
.LP
.\e" .ce .fi .in .ne .pl .sp
.ad .de .ft .it .nf .po .ta
.bp .ds .ie .ll .nr .ps .ti
.br .el .if .na .ns .rs .tm
.LP
and the following in-text codes:
.ES
\e$ \e% \e* \ec \ef \en \es
.EE
plus the full list of \*(Nr/\c
.I troff
special characters in
the original V7 \fItroff\fR manual.
.PP
Many restrictions are present; the behavior in general is a subset of
\*(Nr's. Of particular note are the following:
.IP \(bu 2
Point sizes do not exist;
.B .ps
and
.B \es
are ignored.
.PT
Conditionals implement only numeric comparisons on
.BR \en(.$ ,
string com\%par\%isons between a macro parameter and a literal,
and
.B n
(always true)
and
.BR t
(always false).
.PT
The implementation of strings is generally primitive.
.IP \(bu
Expressions in (e.g.)\&
.B .sp
are fairly general, but the
.BR | ,
.BR & ,
and
.BR :\&
operators do not exist, and the implementation of
.B \ew
requires that quote (') be used as the delimiter and
simply counts the characters inside (so that, e.g.,
\ew'\e(bu'
equals 4).
.P
White space at the beginning of lines,
and imbedded white space within lines, is dealt with properly.
Sentence terminators at ends of lines are understood to imply
extra space afterward in filled lines.
Tabs are im\%plemented crudely and not quite correctly, although
in most cases they work as expected.
Hyphenation is done only at explicit hyphens, em-dashes, and \*(Nr
discretionary hyphens.
.SH "MAN MACROS"
The
.B \-man
macro set implements the full V7 manual macros,
plus a few semi-random oddballs.
The full list is:
.ES
\&.B .DT .IP .P .RE .SM
\&.BI .HP .IR .PD .RI .TH
\&.BR .I .LP .PP .RS .TP
\&.BY .IB .NB .RB .SH .UC
.EE
.B .BY
and
.B .NB
each take a single string argument (respectively, an indi\%cation of
authorship and a note about the status of the manual page) and arrange
to place it in the page footer.
.SH "MS MACROS"
The
.B \-ms
macro set is a substantial subset of the V7 manuscript macros.
The implemented macros are:
.ES
\&.AB .CD .ID .ND .QP .RS .UL
\&.AE .DA .IP .NH .QS .SH .UX
\&.AI .DE .LD .NL .R .SM
\&.AU .DS .LG .PP .RE .TL
\&.B .I .LP .QE .RP .TP
.EE
Size changes are recognized but ignored, as are
.B .RP
and
.BR .ND .
.B .UL
just prints its argument in italics.
.BR .DS / .DE
does not do a keep,
nor do any of the other macros that normally imply keeps.
.PP
Assignments to the header/footer string variables are recognized and
implemented, but there is otherwise no control over header/footer
formatting.
The
.B DY
string variable is available.
The
.BR PD ,
.BR PI ,
and
.BR LL
number registers exist and can be changed.
.SH OUTPUT
The only output format supported by
.IR awf ,
in its distributed form,
is that appropriate to a dumb terminal,
using overprinting for italics (via underlining) and bold.
The \*(Nr special characters are printed as some vague approximation
(it's sometimes very vague) to their correct appearance.
.PP
.IR Awf 's
knowledge of the output device is established by a device file,
which is read before the user's input.
It is sought in
.IR awf 's
library directory, first as
.BI dev. term
(where \fIterm\fR is the value of the TERM environment variable)
and, failing that, as
.BR dev.dumb .
The device file
uses special internal commands
to set up resolution, special characters, fonts, etc.,
and more normal \*(Nr commands to set up page length etc.
.SH FILES
All in \fI/usr/lib/awf\fR (this can be overridden by the AWFLIB
environment variable):
.ta \w'pass2.base'u+((3n-1n)/2u)
.nf
common common device-independent initialization
dev.* device-specific initialization
mac.m* macro packages
pass1 macro substituter
pass2.base central formatter
pass2.m* macro-package-specific bits of formatter
pass3 line and page composer
.SH SEE ALSO
awk(1), nroff(1), man(7), ms(7)
.SH DIAGNOSTICS
.na
Unlike
.IR nroff ,
.I awf
complains whenever it sees unknown commands and macros.
All diagnostics (these and some internal ones) appear on standard error
at the end of the run.
.ad
.SH HISTORY
Written at University of Toronto by Henry Spencer,
more or less as a supplement to the C News project.
.LP
.ce 99
\(rh None of the above really want to admit it. \(lh
.ce 0
.SH BUGS
There are plenty, but what do you expect for a text formatter
written entirely in (old) \fIawk\fR?
.PP
The
.B \-ms
stuff has not been checked out very thoroughly.
-7
View File
@@ -1,7 +0,0 @@
.\" Common startup code, fully device-independent.
.\" --------------------------------
.fi
.ce 0
.ta +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5
.in 0
.ti 0
-154
View File
@@ -1,154 +0,0 @@
.\" Device-dependent but not macro-set-dependent definitions.
.\" --------------------------------
.\" overall formatting initialization
.\" 12 cpi horizontal exploits 80-column terminal well (6.5i@12 = 78)
.^r cpi 12 6
.\" call margin adjustment device-dependent for sake of some unusual cases
.ad
.\" page parameters
.pl 11i
.ll 6.5i
.po 0
.\" --------------------------------
.\" fonts, and their hyphens, last font change doubled to set up \fP
.^f R
.ft R
.^c hy 1 -
.^f I
.ft I
.^c hy 1 -
.^f B
.ft B
.^c hy 1 -\b-\b-
.ft R
.ft R
.\" --------------------------------
.\" definitions of nroff special characters
.\" The character definitions here operate on the "better ugly than invisible"
.\" principle, and try to approximate the character *somehow*. They were
.\" tuned for a Teletype 40 line printer, but should give vaguely plausible
.\" results on any overprinting ASCII device.
.\"
.\" first, things that nroff considered builtins
.^c \ 1 \\
.^c e 1 \\
.^c ' 1 '
.^c ` 1 `
.^c - 1 -
.\" some things seem to assume that \+ is like \-
.^c + 1 +
.\" we do not do backslash-space here, it can't be done with .^c, but the
.\" other forms of space we can do
.^c 0 1 "
.^c | 0
.^c ^ 0
.^c & 0
.\"
.\" and more normal characters
.\" note, the hyphenation logic knows about em
.^c em 2 --
.\" hy is a special case, see above
.^c bu 1 +\bo
.^c sq 2 []
.^c ru 1 _
.^c 12 3 1/2
.^c 14 3 1/4
.^c 34 3 3/4
.^c de 1 '\b`
.^c dg 1 -\b!
.^c fm 1 '
.^c ct 1 /\bc
.^c rg 3 (R)
.^c co 3 (c)
.^c pl 1 +
.^c mi 1 -
.^c eq 1 =
.^c ** 1 *
.^c sc 1 j\bf
.^c aa 1 '
.^c ga 1 `
.^c ul 1 _
.^c sl 1 /
.^c *a 1 <\ba
.^c *b 1 ,\bB
.^c *g 1 ,\by
.^c *d 1 S\bo
.^c *e 1 -\bc
.^c *z 1 ,\bL
.^c *y 1 ,\bn
.^c *h 1 -\b0
.^c *i 1 ,\bi
.^c *k 1 <\bK
.^c *l 1 \\\b>
.^c *m 1 ,\bu
.^c *n 1 ,\bv
.^c *c 1 ,\b3
.^c *o 1 o
.^c *p 1 -\bn
.^c *r 1 p
.^c *s 1 -\bo
.^c ts 1 s
.^c *t 1 ~\bt
.^c *u 1 u
.^c *f 1 /\bo
.^c *x 1 /\b\\
.^c *q 1 |\bu
.^c *w 1 u\bw
.^c *G 2 ~\b|~
.^c *D 2 _\b/_\b\\
.^c *H 1 -\bO
.^c *L 2 /\\
.^c *C 1 _\b-\b~
.^c *P 2 ~\b|~\b|
.^c *S 1 ~\b_\b>
.^c *U 1 Y
.^c *F 1 |\bO
.^c *Q 1 |\bU
.^c *W 2 _\b(_\b)
.^c sr 2 \\/
.^c rn 1 ~
.^c >= 1 _\b>
.^c <= 1 _\b<
.^c == 1 _\b=
.^c ~= 1 ~\b=
.^c ap 1 ~
.^c != 1 /\b=
.^c -> 2 ->
.^c <- 2 <-
.^c ua 1 |\b^
.^c da 1 |\bv
.^c mu 1 x
.^c di 1 -\b:
.^c +- 1 _\b+
.^c cu 1 U
.^c ca 3 (^)
.^c sb 2 (_\b~
.^c sp 2 _\b~)
.^c ib 2 (~\b_\b=
.^c ip 2 ~\b_\b=)
.^c if 2 oo
.^c pd 1 3\bo
.^c gr 1 ~\bV
.^c no 1 -
.^c is 1 '\b,\bI
.^c pt 2 oc
.^c es 1 /\bO
.^c mo 1 -\bC
.^c br 1 |
.^c dd 1 I\b|
.^c rh 1 =\b>
.^c lh 1 =\b<
.^c bs 4 (:-)
.^c or 1 |
.^c ci 1 O
.^c lt 1 ~\b(
.^c lb 1 _\b(
.^c rt 1 ~\b)
.^c rb 1 _\b)
.^c lk 1 -\b(
.^c rk 1 -\b)
.^c bv 1 |
.^c lf 1 _\b[
.^c rf 1 _\b]
.^c lc 1 ~\b[
.^c rc 1 ~\b]
-141
View File
@@ -1,141 +0,0 @@
.\"-----------------
.de TH
.ds LH "\\$1(\\$2)
.ds CH "Unix Programmer's Manual
.ds RH "\\$1(\\$2)
.ds LF "
.ds CF "\\$3
.ds RF "%
..
.\"-----------------
.de NB
.ds nb "\\$1
.lF
..
.\"-----------------
.de BY
.ds by "\\$1
.lF
..
.\"-----------------
.de UC
.BY "\\$1BSD"
..
.\"-----------------
.\" common initialization for headers and paragraphs: .In need
.de In
.ne \\$1
.sp \\n(PDu
.fi
.in \\n(inu
.ti 0
.it
.ft R
.ns
..
.\"-----------------
.de SH
.In 6
.in 0
.ft B
\&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
.ft R
.nr in 5n
.in \\n(inu
..
.\"-----------------
.de LP
.In 4
..
.\"-----------------
.de PP
.LP
..
.\"-----------------
.de P
.LP
..
.\"-----------------
.de HP
.In 4
.ti 0-\\n(tpu
..
.\"-----------------
.de TP
.In 4
.if \\n(.$>0 .nr tp \\$1n
.in \\n(inu+\\n(tpu
.ti 0-\\n(tpu
.it 1 tP
..
.\"-----------------
.de IP
.ie \\n(.$>1 .TP "\\$2"
.el .TP
\&\\$1
..
.\"-----------------
.de I
.ft I
.it 1 fP
.if \\n(.$>0 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.\"-----------------
.de B
.ft B
.it 1 fP
.if \\n(.$>0 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.\"-----------------
.de IR
\&\\fI\\$1\\fR\\$2\\fI\\$3\\fR\\$4\\fI\\$5\\fR\\$6\\fI\\$7\\fR\\$8\\fI\\$9\\fR
..
.\"-----------------
.de RI
\&\\$1\\fI\\$2\\fR\\$3\\fI\\$4\\fR\\$5\\fI\\$6\\fR\\$7\\fI\\$8\\fR\\$9
..
.\"-----------------
.de BR
\&\\fB\\$1\\fR\\$2\\fB\\$3\\fR\\$4\\fB\\$5\\fR\\$6\\fB\\$7\\fR\\$8\\fB\\$9\\fR
..
.\"-----------------
.de RB
\&\\$1\\fB\\$2\\fR\\$3\\fB\\$4\\fR\\$5\\fB\\$6\\fR\\$7\\fB\\$8\\fR\\$9
..
.\"-----------------
.de BI
\&\\fB\\$1\\fI\\$2\\fB\\$3\\fI\\$4\\fB\\$5\\fI\\$6\\fB\\$7\\fI\\$8\\fB\\$9\\fR
..
.\"-----------------
.de IB
\&\\fI\\$1\\fB\\$2\\fI\\$3\\fB\\$4\\fI\\$5\\fB\\$6\\fI\\$7\\fB\\$8\\fI\\$9\\fR
..
.\"-----------------
.de SM
.\" no-op
.if \\n(.$>0 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.\"-----------------
.de DT
.ta +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5 +5
..
.\"-----------------
.de RS
.in +5n
..
.\"-----------------
.de RE
.in -5n
..
.\"-----------------
.de PD
.ie \\n(.$=0 .nr PD 0.3v
.el .nr PD \\$1n
..
.\"-----------------
.\" misc. initialization
.nr tp 5n
.PD
.ds R \(rg
.ds S "
.ds Tm (TM)
-206
View File
@@ -1,206 +0,0 @@
.\"-----------------
.de R
.ie \\n(.$=0 .ft R
.el \\fR\\$1\\fP\\$2
..
.\"-----------------
.de I
.ie \\n(.$=0 .ft I
.el \\fI\\$1\\fP\\$2
..
.\"-----------------
.de B
.ie \\n(.$=0 .ft B
.el \\fB\\$1\\fP\\$2
..
.\"-----------------
.de UX
.\" old-fashioned capitalization -- I've never gotten used to the new one
\\$2Unix\\$1
..
.\"-----------------
.de DA
.ds DY "\\$1 \\$2 \\$3
.\" keep trailing spaces out of CF
.if \\n(.$=1 .ds CF "\\$1
.if \\n(.$=2 .ds CF "\\$1 \\$2
.if \\n(.$>2 .ds CF "\\$1 \\$2 \\$3
..
.\"-----------------
.de ND
.\" it's our default, ignore it
..
.\"-----------------
.de TL
.rs
.sp 5
.ft B
.ce 9999
..
.\"-----------------
.de AU
.sp 2
.ft R
..
.\"-----------------
.de AI
.sp
.ft R
..
.\"-----------------
.de AB
.sp 2
.ce 0
.ll -7n
.in +7n
..
.\"-----------------
.de AE
.sp
.ll
.in
..
.\"-----------------
.\" common initialization for headers and paragraphs: .In need extraspace
.de In
.ne \\$1
.sp \\n(Tsu
.nr Ts 0
.ie \\n(.$>1 .nr iN \\$2v
.el .nr iN 0
.sp \\n(PDu+\\n(iNu
.ce 0
.ft R
.in \\n(inu
.ll \\n(LLu
.ns
.fi
.ti 0
..
.\"-----------------
.de SH
.nr in 0
.In 6 1
.ft B
..
.\"-----------------
.de NH
.nr in 0
.In 6 1
.ft B
.\" punt to awk code to get the header numbering right
.nH \\$1
.\" and pick up the result
\&\\*(Nh
..
.\"-----------------
.de LP
.In 4
..
.\"-----------------
.de PP
.In 4
.ti \\n(PIu
..
.\"-----------------
.de TP
.In 4
.if \\n(.$>0 .nr tp \\$1n
.in \\n(inu+\\n(tpu
.ti 0-\\n(tpu
.it 1 tP
..
.\"-----------------
.de IP
.ie \\n(.$>1 .TP "\\$2"
.el .TP
\&\\$1
..
.\"-----------------
.de QP
.In 4
.in +5n
.ll -5n
..
.\"-----------------
.de QS
.nr in +5n
.nr LL -5n
.In 4
..
.\"-----------------
.de QE
.nr in -5n
.nr LL +5n
.In 4
..
.\"-----------------
.de DS
.In 5
.if '\\$1'C' .ce 9999
.if '\\$1'' .in +5n
.nf
..
.\"-----------------
.de CD
.In 5
.ce 9999
.nf
..
.\"-----------------
.de LD
.In 5
.nf
..
.\"-----------------
.de ID
.In 5
.in +5n
.nf
..
.\"-----------------
.de DE
.In 3
..
.\"-----------------
.de RS
.nr in +5n
.in \\n(inu
..
.\"-----------------
.de RE
.nr in -5n
.in \\n(inu
..
.\"-----------------
.de UL
\&\\fI$1\\fP
..
.\"-----------------
.de RP
..
.\"-----------------
.de LG
..
.\"-----------------
.de SM
..
.\"-----------------
.de NL
..
.\"-----------------
.\" the -ms accent strings
.ds ' "'\b
.ds ` "`\b
.ds : ":\b
.ds ^ "^\b
.ds ~ "~\b
.ds C "v\b
.ds , ",\b
.\" post-title spacing
.nr Ts 4v
.\" and parameter setup
.nr LL 6i
.ll \n(LLu
.nr PD 0.3v
.nr PI 5n
-212
View File
@@ -1,212 +0,0 @@
# first pass: macro expansion and .if
# We support macros, conditionals (of three quite limited forms), and macro
# argument substitution.
BEGIN {
curmacro = ""
macros[""] = 0 # just to make it an array
macrolen[""] = 0 # just to make it an array
macrotext[0] = "" # just to make it an array
args[""] = "" # just to make it an array
ntext = 1 # first slot in macrotext; cannot be 0
nroffset = 0 # offset between NR and "real" line numbers
inname = "?" # input filename
sp = 0 # stack "pointer" (number of stacked macros)
maxsp = 25 # limit on nesting depth
macrostack[sp] = "" # to make it an array
nleftstack[sp] = "" # to make it an array
ptrstack[sp] = "" # to make it an array
nargstack[sp] = "" # to make it an array
argstack[sp] = "" # to make it an array
condstack[sp] = "" # to make it an array
}
/^\.\^#/ { # filename and line no of next line: .^# no fn
nroffset = (NR+1) - $2
inname = $3
print
next
}
/^\.de/ { # macro start
curmacro = "." $2
macros[curmacro] = ntext
macrostart = ntext
next
}
curmacro != "" && $0 !~ /^\.\.$/ { # macro text - \\ becomes \
if ($0 !~ /\\/) # quick case, no backslashes
line = $0
else {
line = ""
for (n = 1; n <= length; n++) {
if (substr($0, n, 2) == "\\\\")
n++
line = line substr($0, n, 1)
}
}
macrotext[ntext++] = line
next
}
curmacro != "" && $0 ~ /^\.\.$/ { # macro end
macrolen[curmacro] = ntext - macrostart
curmacro = ""
print ".^#", NR - nroffset + 1, inname
next
}
$0 ~ /^\./ && ( macros[$1] != 0 || $0 ~ /^\.(i[ef]|el)/ ) {
# something that needs attention
print ".^=", NR - nroffset, inname
line = $0
nleft = 0
macro = "<none>"
nargs = 0
while (line != "") {
# conditionals; note that 1-n is !n (awk doesn't have !)
invert = 0
if (line ~ /^\.i[ef] !/)
invert = 1
prevcond = cond
cond = 0
if (line !~ /^\.(i[ef]|el)/) { # not conditional
cond = 1
iflen = 0
} else if (line ~ /^\.i[ef] !?\\n\(\.\$[<=>][0-9] /) {
# arithmetic comparison on arg count
iflen = length(".if .n(.$=x ") + invert
n = substr(line, iflen-1, 1) + 0
op = substr(line, iflen-2, 1)
if (op == "=" && nargs == n)
cond = 1
else if (op == "<" && nargs < n)
cond = 1
else if (op == ">" && nargs > n)
cond = 1
} else if (line ~ /^\.i[ef] !?'\\\$[0-9]'[^']*' /) {
# string equality on argument
iflen = length(".if '.$n'") + invert
n = substr(line, iflen-1, 1)+0
if (n <= nargs)
s1 = args[n]
else
s1 = ""
i = index(substr(line, iflen+1), "'")
s2 = substr(line, iflen+1, i-1)
iflen += i+1
if (s1 == s2)
cond = 1
} else if (line ~ /^\.i[ef] !?[nt] /) {
# nroff vs troff
iflen = length(".if n ") + invert
if (substr(line, iflen-1, 1) == "n")
cond = 1
} else if (line ~ /^\.el /) {
cond = 1 - prevcond
iflen = length(".el ")
} else {
line = ".tm unknown .if/.ie form: " line
cond = 1
iflen = 0
}
if (invert)
cond = 1 - cond
if (cond && iflen > 0) # trim true conditional off
line = substr(line, iflen+1)
# do argument substitution, if necessary
if (cond && line ~ /\\\$/) {
orig = line
line = ""
for (pos = index(orig, "\\$"); pos > 0; \
pos = index(orig, "\\$")) {
if (pos > 1)
line = line substr(orig, 1, pos-1)
c = substr(orig, pos+2, 1)
if (c ~ /[0-9]/ && c+0 <= nargs)
line = line args[c+0]
orig = substr(orig, pos+3)
}
line = line orig # the remnant
}
# is it an nroff command?
if (cond && line ~ /^\./) {
cmd = substr(line, 1, 3)
while (cmd ~ / $/)
cmd = substr(cmd, 1, length(cmd)-1)
} else
cmd = ""
# deal with it
if (!cond)
nop = 0 # nothing
else if (cmd == "" || macros[cmd] == 0)
print line # not a nested macro
else if (sp >= maxsp)
print ".tm macros nested too deeply (" sp " levels)"
else { # nesting
# stack old one
sp++
nleftstack[sp] = nleft
ptrstack[sp] = ptr
macrostack[sp] = macro
nargstack[sp] = nargs
condstack[sp] = cond
for (i = 1; i <= nargs; i++)
argstack[sp ":" i] = args[i]
# start new one, mostly pulling arguments apart
macro = cmd
nleft = macrolen[macro]
ptr = macros[macro]
cond = 0
argno = 1
pos = length(macro) + 1
for (;;) {
while (substr(line, pos, 1) ~ /[ \t]/)
pos++
if (pos > length(line))
break # NOTE BREAK OUT
arg = ""
if (substr(line, pos, 1) == "\"") {
pos++
while (substr(line, pos, 1) ~ /[^"]/) {
arg = arg substr(line, pos, 1)
pos++
}
pos++
} else
while (substr(line, pos, 1) ~ /[^ \t]/) {
arg = arg substr(line, pos, 1)
pos++
}
args[argno++] = arg
}
nargs = argno - 1
}
# clean up any completed macros
while (nleft <= 0 && sp > 0) {
nleft = nleftstack[sp]
ptr = ptrstack[sp]
macro = macrostack[sp]
nargs = nargstack[sp]
cond = condstack[sp]
for (i = 1; i <= nargs; i++)
args[i] = argstack[sp ":" i]
sp--
}
# finally, get next line
if (nleft > 0) {
line = macrotext[ptr++]
nleft--
} else
line = "" # signal loop to terminate
}
print ".^#", NR - nroffset + 1, inname
next
}
{
# it's ordinary
print
}
-587
View File
@@ -1,587 +0,0 @@
# second pass: interpretation of directives
# A macro-set-specific portion gets interpolated into this at the "#include"
# line. As a minimum, it must deal with .^b and .^e and with any input traps.
BEGIN {
# stuff for output to third pass
nobreak = -1
dobreak = -2
message = -3
OFS = "\t"
# special-character table; this one character needs to be hardcoded
chars[" "] = " " ; charwidths[" "] = 1
debug["e"] = 0 # just to make it an array
strings["a"] = "" # just to make it an array
numbers["a"] = 0 # just to make it an array
hyphens["a"] = "" # just to make it an array
hyphenwidths["a"] = "" # just to make it an array
# stuff for expression decoding
signfactor["+"] = 1
signfactor["-"] = -1
scale["i"] = 240
scale["c"] = 240*50/127
scale["P"] = 240/6
# we get m, n, and v when we see .^r
scale["p"] = 240/72
scale["u"] = 1
# stuff for basic parameters that just get passed to third pass
parms["in"] = 0 # just to make it an array
prevparms["in"] = 0 # just to make it an array
setcmd["ll"] = "linelen"
setcmd["in"] = "indent"
setcmd["ti"] = "tempindent"
setcmd["po"] = "pageoffset"
setcmd["pl"] = "pagelen"
# did last word end with \c ? (in which case, it's still in "word")
backc = 0
# stuff for error reporting
il = 0 # input line number
lockil = 0 # il is locked, we're inside a macro
inname = "?" # input filename
msg = message "\t" # later picks up filename etc.
# current input trap
afternext = ""
}
{
if (!lockil)
il++
msg = message "\t" inname "," il ": "
# fallthrough
}
/^[ \t]*$/ { # empty line
print dobreak, "space"
next
}
/^[ \t]/ { # line starting with white space
print dobreak, "flush"
print 0, "" # empty word
# fallthrough
}
/^[^.]/ { # text
# dispose of the easy case
if (font == "R" && $0 !~ /\\|\t|-| / && !backc && afternext == "") {
for (i = 1; i <= NF; i++)
print length($i), $i
if ($0 ~ /[.!?:]([)'"*]|])*$/)
print nobreak, "gap", 2
if (centering > 0) {
print dobreak, "center"
centering--
} else if (!fill)
print dobreak, "flush"
next
}
# the hard case, needs a character-by-character scan
s = $0 " " # the space flushes the last word
n = 1 # current position in s
inword = 0 # have we been processing a word?
period = "" # "." if this word ended a sentence
nsp = 0 # count of spaces seen so far
tabpos = 0 # which tab position was used last
while (n <= length(s)) {
c = substr(s, n, 1)
# handle state transitions
if (c == " " || c == "\t") {
if (inword) { # ends word
if (!backc) {
print wordlen, word
if (usedhyphen)
print nobreak, "nohyphen"
}
inword = 0
nsp = 0
}
} else {
if (!inword) { # begins word
if (!backc) {
word = ""
wordlen = 0
usedhyphen = 0
}
backc = 0
inword = 1
if (nsp > 1)
print nobreak, "gap", nsp
}
}
# deal with the character
if (c == " ") {
nsp++
if (n != length(s)) # not the trailing flusher
period = ""
} else if (c == "\t") {
# not really right, should be based on input position
# also, one space following tab gets ignored
tabpos++
if (tabpos <= ntabs)
print nobreak, "tabto", tabs[tabpos]
nsp = 0
period = ""
} else if (c == "-" && wordlen > 0) {
# hyphen within word
print wordlen, word, hyphenwidths[font]
print nobreak, "userhyphen", hyphens[font], hyphenwidths[font]
word = ""
wordlen = 0
period = ""
usedhyphen = 1
} else if (c != "\\") {
# ordinary character
if (font == "B")
word = word c "\b" c "\b" c
else if (font == "I" && c ~ /[a-zA-Z0-9]/)
word = word "_\b" c
else
word = word c
wordlen++
if (c ~ /[.!?:]/)
period = "."
else if (c !~ /([)'"*]|])/)
period = ""
} else { # backslash
n++
c = substr(s, n, 1)
if (c == "f") {
# font change
n++
code = substr(s, n, 1)
if (code == "(") {
n++
code = substr(s, n, 2)
n++
}
if (code == "P")
font = prevfont
else if (fontok[code] == "")
print msg "unknown font `" code "'"
else {
prevfont = font
font = code
}
} else if (c == "n") {
# number-register value
n++
code = substr(s, n, 1)
if (code == "(") {
n++
code = substr(s, n, 2)
n++
}
s = substr(s, 1, n) numbers[code] substr(s, n+1)
} else if (c == "s") {
# size change
n++
if (substr(s, n, 1) ~ /[0-9]/)
n++
# just ignore it
} else if (c == "c")
# word continuation
backc = 1
else if (c == "*") {
# string-variable value
n++
code = substr(s, n, 1)
if (code == "(") {
n++
code = substr(s, n, 2)
n++
}
s = substr(s, 1, n) strings[code] substr(s, n+1)
} else if (c == "%") {
# discretionary hyphen
if (wordlen > 0) {
print wordlen, word, hyphenwidths[font]
print nobreak, "hyphen", hyphens[font], hyphenwidths[font]
word = ""
wordlen = 0
usedhyphen = 1
}
} else if (c == "(" && substr(s, n+1, 2) == "em" && \
chars["em"] != "") {
# em-dash, special case due to hyphenation
n += 2
emw = charwidths["em"]
print wordlen, word, emw
print nobreak, "userhyphen", chars["em"], emw
word = ""
wordlen = 0
period = ""
usedhyphen = 1
} else {
# special-character name
code = c
if (code == "(") {
n++
code = substr(s, n, 2)
n++
}
word = word chars[code]
wordlen += charwidths[code]
period = ""
}
}
# on to the next character, at last
n++
}
# end-of-line processing
if (!backc) {
if (period == ".")
print nobreak, "gap", 2
if (centering > 0) {
print dobreak, "center"
centering--
} else if (!fill)
print dobreak, "flush"
}
# if no input trap, we're done
if (afternext == "")
next
# if there is an input trap, fall into the macro-dependent section
}
#
#
#
# at this point we plug in the macro-specific stuff, keyed on the next line
#include note that this is an awk comment
#
#
#
/^\.it/ { # plant an input trap, sort of
if (NF > 1 && $2 != 1)
print msg ".it first argument must be 1"
if (NF > 2)
afternext = afternext "," $3
else
afternext = ""
next
}
/^\.\^r cpi / { # set resolutions, in cpi: .^r cpi hor vert
scale["m"] = 240/$3
scale["n"] = 240/$3
scale["v"] = 240/$4
next
}
/^\.(ta|ll|in|ti|po|ne|sp|pl|nr)/ { # expression processing
# sort out default scale factor
if ($1 ~ /^\.(ne|sp|pl)/)
exprscale = "v"
else if ($1 ~ /^\.(nr)/)
exprscale = "u"
else
exprscale = "n"
# which argument should we start with?
offset = length($1) + 1
if ($1 == ".nr")
offset += length($2) + 1
# beginning of debugging message
if (debug["e"])
printf "%s ", msg substr($0, 1, offset)
# do the expressions
s = substr($0, offset+1)
n = 1
while (s != "") {
while (s ~ /^[ \t]/)
s = substr(s, 2)
# an initial sign is magic
ssign = ""
if (s ~ /^[+-]/) {
ssign = substr(s, 1, 1)
s = substr(s, 2)
}
s = "+" s # this is an un-magic addition operator
# process terms
sval = 0
while (s ~ /^([+*%)-]|\/)/) {
# figure out what it is and what it contributes
if (debug["e"] > 1)
print "s=`" s "'"
termop = substr(s, 1, 1)
s = substr(s, 2)
termscale = exprscale
if (termop == ")") {
if (debug["e"] > 1)
print "pop " valstack[vsp] " " opstack[vsp] " with " sval
termval = sval
sval = valstack[vsp]
termop = opstack[vsp]
vsp--
termscale = "u"
} else if (s ~ /^\(/) {
if (debug["e"] > 1)
print "push " sval " " termop
vsp++
valstack[vsp] = sval
opstack[vsp] = termop
sval = 0
termop = "+" # dummy op and value
termval = 0
s = "+" substr(s, 2)
} else if (s ~ /^\\w/) {
delim = substr(s, 3, 1)
s = substr(s, 4)
endp = index(s, delim)
if (endp == 0)
endp = length(s) + 1
termval = (endp - 1) * scale["n"] # crude
s = substr(s, endp+1)
} else if (s ~ /^\\n/) {
if (s ~ /^\\n\(/) {
code = substr(s, 4, 2)
s = substr(s, 6)
} else {
code = substr(s, 3, 1)
s = substr(s, 4)
}
termval = numbers[code]
} else if (s ~ /^[0-9.]/) {
for (endp = 1; endp <= length(s); endp++)
if (substr(s, endp, 1) !~ /[0-9.]/)
break
termval = substr(s, 1, endp-1) + 0
s = substr(s, endp)
}
# add it in, with scaling factor
c = substr(s, 1, 1)
if (scale[c] != "") {
termval *= scale[c]
s = substr(s, 2)
} else
termval *= scale[termscale]
if (termop == "+")
sval += termval
else if (termop == "-")
sval -= termval
else if (termop == "*")
sval *= termval
else if (termop == "/")
sval = int(sval) / int(termval)
else if (termop == "%")
sval = int(sval) % int(termval)
}
# remember the value, print if debugging
expr[n] = sval
exprsign[n] = ssign
iexpr[n] = signfactor[ssign] * sval # convenience
if (debug["e"])
printf "%s ", ssign "(" sval ")"
# proceed to next, skipping trash if necessary
while (s ~ /^[^ \t]/)
s = substr(s, 2)
n++
}
# final cleanup
nexprs = n - 1
if (debug["e"])
printf "\n"
# fallthrough
}
/^\.(ll|in|ti|po|pl)/ { # common code for set-parameter requests
# relies on expression processing, including setting of exprscale
name = substr($1, 2, 2)
n = parms[name]
if (nexprs == 0)
n = prevparms[name]
else if (exprsign[1] == "" || name == "ti")
n = expr[1] / scale[exprscale]
else
n += iexpr[1] / scale[exprscale]
prevparms[name] = parms[name]
parms[name] = int(n)
print dobreak, setcmd[name], parms[name]
next
}
/^\.nr/ {
# relies on expression processing
n = numbers[$2]
if (exprsign[1] == "")
n = expr[1]
else
n += iexpr[1]
numbers[$2] = int(n)
next
}
/^\.ne/ {
# relies on expression processing
print dobreak, "need", int(expr[1]/scale["v"] + 0.99)
next
}
/^\.sp/ {
# relies on expression processing
if (nexprs == 0)
i = 1
else
i = int(expr[1]/scale["v"] + 0.99)
for (; i > 0; i--)
print dobreak, "space"
next
}
/^\.ta/ {
# relies on expression processing
tabstop = 0
for (n = 1; n <= nexprs; n++) {
if (exprsign[n] == "")
tabstop = expr[n]
else
tabstop += iexpr[n]
tabs[n] = int(tabstop/scale["n"])
}
ntabs = nexprs
next
}
/^\.ft/ {
if (NF > 1)
code = $2
else
code = "P"
if (code == "P")
font = prevfont
else if (fontok[code] == "")
print msg "unknown font `" code "'"
else {
prevfont = font
font = code
}
next
}
/^\.br/ {
print dobreak, "flush"
next
}
/^\.ds/ {
# note, macro-set-specific code often looks at .ds as well
if ($3 !~ /^"/)
strings[$2] = $3
else
strings[$2] = substr($0, index($0, "\"")+1)
next
}
/^\.ns/ {
print nobreak, "nospace"
next
}
/^\.rs/ {
print nobreak, "yesspace"
next
}
/^\.ad/ {
print nobreak, "both"
next
}
/^\.na/ {
print nobreak, "left"
next
}
/^\.nf/ {
fill = 0
print dobreak, "flush"
next
}
/^\.fi/ {
fill = 1
print dobreak, "flush"
next
}
/^\.\^x/ { # direct errors to this file: .^x filename
print nobreak, "errsto", $2
next
}
/^\.\^c/ { # define character: .^c name width text
if ($4 ~ /^"/)
s = substr($0, index($0, "\"")+1)
else
s = $4
ns = ""
while ((n = index(s, "\\")) > 0) {
if (n > 1)
ns = ns substr(s, 1, n-1)
n++
c = substr(s, n, 1)
if (c == "\\")
ns = ns "\\"
else if (c == "b")
ns = ns "\b"
s = substr(s, n+1)
}
ns = ns s
if ($2 == "hy") {
hyphens[font] = ns
hyphenwidths[font] = $3
} else {
chars[$2] = ns
charwidths[$2] = $3
}
next
}
/^\.\^f/ { # this font is okay: .^f fontname
# someday, this might take font-change codes as further arguments
fontok[$2] = "yes"
next
}
/^\.tm/ {
print msg $0
next
}
/^\.ps/ {
# ignore
next
}
/^\.ce/ {
if (NF > 1)
centering = $2
else
centering = 1
next
}
/^\.bp/ {
print dobreak, "need", 999
next
}
/^\.\^d/ { # debug control: .^d debugvar value
debug[$2] = $3
next
}
/^\.\^#/ { # set line number of next line: .^# no file
il = $2 - 1
lockil = 0
inname = $3
next
}
/^\.\^=/ { # lock line number to value: .^= no file
il = $2
lockil = 1
inname = $3
next
}
/^\.\\"/ { # comment
next
}
/^\./ {
print msg "command `" $1 "' unsupported or unknown"
}
END {
print dobreak, "need", 999 # flush page
}
-33
View File
@@ -1,33 +0,0 @@
/^\.\^b/ { # initialization
print nobreak, "fph", 1
next
}
/^[^.]/ { # text line -- reached only for input traps
if (afternext ~ /,fP/)
font = prevfont
if (afternext ~ /,tP/)
print dobreak, "toindent"
afternext = ""
next
}
/^\.ds/ { # to catch special strings
if ($3 !~ /^"/)
v = $3
else
v = substr($0, index($0, "\"")+1)
if ($2 ~ /^[LCR][HF]$/)
print nobreak, $2, v
# fallthrough to normal .ds processing in macro-independent stuff
}
/^\.lF/ {
# special footer fiddling
if (strings["by"] != "" && strings["nb"] != "")
lf = strings["by"] "; " strings["nb"]
else
lf = strings["by"] strings["nb"]
print nobreak, "LF", lf
next
}
/^\.\^e/ { # finalization
next
}
-40
View File
@@ -1,40 +0,0 @@
/^\.\^b/ { # initialization
nhnos[1] = 0
next
}
/^[^.]/ { # text line -- reached only for input traps
if (afternext == ",tP")
print dobreak, "toindent"
afternext = ""
next
}
/^\.nH/ { # fooling around for numbered headings
no = 1
if (NF > 1)
no = $2
if (no == 0) {
nhnos[1] = 0
no = 1
}
nhnos[no]++
for (n in nhnos)
if (n > no)
nhnos[n] = 0
s = ""
for (n = 1; n <= no; n++)
s = s nhnos[n] "."
strings["Nh"] = s # result in string for macro to grab
next
}
/^\.ds/ { # to catch special strings
if ($3 !~ /^"/)
v = $3
else
v = substr($0, index($0, "\"")+1)
if ($2 ~ /^[LCR][HF]$/)
print nobreak, $2, v
# fallthrough to normal .ds processing in macro-independent stuff
}
/^\.\^e/ { # finalization
next
}
-332
View File
@@ -1,332 +0,0 @@
# third pass: setting lines and pages
# The input language of this pass is basically <width, word> pairs, where
# "word" may have imbedded strangeness (backspaces, etc.) for font changes
# and special characters. Zero width is not special. A third field may
# appear to indicate that this is a fragment of a word that can be
# hyphenated; the third field is the width of the hyphen that would have
# to be added if the line broke after this fragment.
# Negative widths denote special operations. -3 is an error message, the
# second field being the message. -1 and -2 are control messages to this
# pass, the difference being whether a break is implied or not. The second
# field is a message type string; more fields may appear as arguments. The
# semantics of control messages are often -- but not always! -- similar to
# those of troff commands. For example, "linelen" is .ll, but "center" is
# not semantically equivalent to .ce -- it is related but more primitive.
BEGIN {
# input and output details
FS = "\t"
nobreak = -1
dobreak = -2
message = -3
errs = "awf.errs" # default only, normally changed by "errsto"
# page setup -- some are defaults only, normally altered by pass 2
nextlineno = 1
thispageno = 1
topmargin = 5
botmargin = 5
ind = 0 # current indent
tmpind = 0
pageoffset = "" # string to emit at start of each line
nospacemode = 1
hdrs["CH"] = "- % -"
nop = split("LH,CH,RH,LF,CF,RF", hdrnames, ",")
fph = 0 # print header on first page?
fill = 1
adj = "both"
pagelen = 66
linelen = 78
# line-builder setup
line = "" # line so far, without padding
paddable = "" # x means corresp. char in "line" is paddable
thislinelen = -1 # -1 means nothing there
cont = " " # thing to append to continue line
contlen = 1
eol = "" # thing to append to break line
eollen = 0
padfrom = "R" # "L" or "R", alternating for river avoidance
# many spaces, so we can use substr to get any number we need
sps = " "
sps = sps sps sps sps sps sps sps sps sps sps
}
{
# process word, if any, causing a break if appropriate
if ($1 >= 0 && thislinelen < 0) { # word, and first on line
line = $2
paddable = substr(sps, 1, length($2))
thislinelen = $1
} else if ($1 >= 0 && thislinelen+contlen+$1+$3 <= linelen-ind-tmpind) {
# word, and it fits on line
line = line cont $2
if (cont == " ")
paddable = paddable "x"
else
paddable = paddable substr(sps, 1, length(cont))
paddable = paddable substr(sps, 1, length($2))
thislinelen += contlen + $1
} else if ($1 == nobreak || $1 == message)
nop = 0 # no attention (i.e. break) needed here
else if ($1 == dobreak && $2 == "need" && \
nextlineno + $3 < pagelen + 1 - botmargin)
nop = 0 # enough space is available, no action needed
else if ($1 == dobreak && $2 == "toindent" && \
ind + tmpind + thislinelen < ind) {
# move to indent position within line; there is room
n = ind - (ind + tmpind + thislinelen)
line = line substr(sps, 1, n)
# nothing before this is paddable
paddable = substr(sps, 1, length(line))
thislinelen += n
# prevent padding immediately after this point
cont = ""
contlen = 0
} else if (thislinelen >= 0 || ($1 == dobreak && $2 == "need")) {
# must emit output, either due to break or "need"
# if at top of page, header
if (nextlineno == 1) {
for (i = int((topmargin-1)/2); i > 0; i--) {
print ""
nextlineno++
}
for (hno in hdrnames) {
h = hdrnames[hno]
if (hdrs[h] ~ /%/) {
n = split(hdrs[h], t, "%")
thispagehdrs[h] = t[1] thispageno t[2]
} else
thispagehdrs[h] = hdrs[h]
}
if (fph || thispageno > 1) {
lh = thispagehdrs["LH"]
ch = thispagehdrs["CH"]
rh = thispagehdrs["RH"]
lsp = int((linelen - length(lh ch rh)) / 2)
rsp = linelen - length(lh ch rh) - lsp
print pageoffset lh substr(sps, 1, lsp) ch substr(sps, 1, rsp) rh
} else
print ""
nextlineno++
while (nextlineno <= topmargin) {
print ""
nextlineno++
}
}
# the current line
# first, add a trailing hyphen if any
line = line eol
paddable = paddable substr(sps, 1, length(eol))
thislinelen += eollen
# trim trailing spaces if any
while (line ~ / $/) {
line = substr(line, 1, length(line)-1)
paddable = substr(paddable, 1, length(line))
thislinelen--
}
# print it in a suitable way
if (line == "") # empty always prints as nothing
print ""
else if ($1 < 0 && $2 == "center") {
# center it
hsp = int((linelen - thislinelen) / 2)
if (hsp < 0)
hsp = 0
print pageoffset substr(sps, 1, ind+tmpind+hsp) line
} else if (adj == "left" || (adj == "both" && \
($1 < 0 || index(paddable, "x") == 0)))
# no right-margin adjustment (disabled, inappropriate
# (line ended by break), or impossible)
print pageoffset substr(sps, 1, ind+tmpind) line
else if (adj == "both") {
# hard case -- adjust right margin
# sanity check
if (length(paddable) != length(line)) # aieeeee
printf "awf: %f != %f!\n", length(paddable), \
length(line) >errs
# compute parameters
textlen = linelen - (ind+tmpind)
mustadd = textlen - thislinelen
npad = 0 # number of paddable spaces
for (tmp = paddable; (i = index(tmp, "x")) > 0; \
tmp = substr(tmp, i+1))
npad++
addatall = int(mustadd/npad) # all grow this much
spall = substr(sps, 1, addatall)
nmore = mustadd - addatall*npad # this many grow more
# build padded output text
out = substr(sps, 1, ind+tmpind)
padno = 0
while ((i = index(paddable, "x")) > 0) {
out = out substr(line, 1, i)
padno++
out = out spall
if (padfrom == "L") {
if (padno <= nmore)
out = out " "
} else {
if (padno > npad-nmore)
out = out " "
}
line = substr(line, i+1)
paddable = substr(paddable, i+1)
}
# print it, plus remnant not processed by loop
print pageoffset out line
# tidy up
if (padfrom == "L")
padfrom = "R"
else
padfrom = "L"
}
# tidy up after output line
nextlineno++
line = ""
paddable = ""
thislinelen = -1
tmpind = 0
nospacemode = 0
# if we broke from a "need", go to bottom of page
if ($1 == dobreak && $2 == "need")
while (nextlineno < pagelen + 1 - botmargin) {
print ""
nextlineno++
}
# footer, if at bottom of page
if (nextlineno >= pagelen + 1 - botmargin) {
for (i = int((botmargin-1)/2); i > 0; i--) {
print ""
nextlineno++
}
# header code prepared thispagehdrs
lf = thispagehdrs["LF"]
cf = thispagehdrs["CF"]
rf = thispagehdrs["RF"]
lsp = int((linelen - length(lf cf rf)) / 2)
rsp = linelen - length(lf cf rf) - lsp
print pageoffset lf substr(sps, 1, lsp) cf substr(sps, 1, rsp) rf
nextlineno++
while (nextlineno <= pagelen) {
print ""
nextlineno++
}
nextlineno = 1
thispageno++
# after page break, should not space unnecessarily,
# and should pad first line from right
nospacemode = 1
padfrom = "R"
}
# we are finally done with emitting output
# pick up input word, if any
if ($1 >= 0) {
line = $2
paddable = substr(sps, 1, length($2))
thislinelen = $1
}
}
# if we broke, next line should pad from right
if ($1 == dobreak)
padfrom = "R"
# cleanup and post-break command processing
if ($1 >= 0 || $2 == "nohyphen") {
# reset hyphenation trickery after each word (fragment)
cont = " "
contlen = 1
eol = ""
eollen = 0
} else if ($2 == "need" || $2 == "toindent")
nop = 0 # dealt with above
else if ($2 == "flush" || $2 == "center")
nop = 0 # exist only to cause break
else if ($1 == message)
print "awf: " $2 >errs
else if ($2 == "gap") {
# gap between last word and next one should be >= $3
if (thislinelen >= 0) {
line = line substr(sps, 1, $3-1)
paddable = paddable substr(sps, 1, $3-1)
thislinelen += $3-1
}
} else if ($2 == "tabto") {
# move to tab stop at $3
if (thislinelen < 0)
thislinelen = 0 # make line exist
n = $3 - thislinelen
if (n > 0) { # must emit some space
line = line substr(sps, 1, n)
# nothing before a tab is paddable
paddable = substr(sps, 1, length(line))
thislinelen += n
# suppress space following
cont = ""
contlen = 0
}
} else if ($2 == "errsto")
errs = $3
else if ($2 ~ /^[LCR][HF]$/)
hdrs[$2] = $3
else if ($2 == "fph")
fph = $3
else if ($2 == "space") {
if (!nospacemode) {
# generate an empty line, which will be flushed by
# the next word; NB we know "space" caused a flush
line = ""
paddable = ""
thislinelen = linelen + 1
nospacemode = 0
}
} else if ($2 == "left")
adj = "left"
else if ($2 == "both")
adj = "both"
else if ($2 == "indent")
ind = $3
else if ($2 == "tempindent")
tmpind = $3
else if ($2 == "linelen")
linelen = $3
else if ($2 == "pagelen")
pagelen = $3
else if ($2 == "nospace")
nospacemode = 1
else if ($2 == "yesspace")
nospacemode = 0
else if ($2 == "hyphen") {
# discretionary hyphen at this point
cont = ""
contlen = 0
eol = $3
eollen = $4
} else if ($2 == "userhyphen") {
# user-supplied hyphen at this point
cont = $3
contlen = $4
eol = $3
eollen = $4
} else if ($2 == "pageoffset")
pageoffset = substr(sps, 1, $3)
else
print "awf: URK -- INTERNAL OPCODE `" $2 "' UNKNOWN" >errs
}
END {
# second pass is supposed to fake a .ne to flush the last page
if (nextlineno != 1)
print "awf: last page not flushed!" >errs
}
-38
View File
@@ -1,38 +0,0 @@
/*
* bench/Cakefile
*/
#define SRCDIR bench
#define PRODUCTS pixcmp
#define SRCSUFF .c
#define MANSECTION 9
#define FILES pixcmp
#include "../Cakefile.defs"
/* These programs are not really for system-wide installation */
#define DONT_INSTALL 1
#ifdef NFS
/* Pick up any shell scripts needed */
%.sh: if exist ../SRCDIR/%.sh
rm -f %.sh
ln ../SRCDIR/%.sh %.sh
#endif
#include "../Cakefile.prog"
clobber&: xxclober
@echo "About to wipe out all pictures and binary files in this directory"
@echo "Send SIGINT (typ. ^C) within 3 seconds to abort"
@sleep 5
rm -f *.log.* *.pix.* # old versions
rm -f *.log *.pix # last try
#define clobber xxclober /* rename "clobber" in Cakefile.rules */
pixcmp: OBJ
CC LDFLAGS -o pixcmp OBJ
#include "../Cakefile.rules"
-158
View File
@@ -1,158 +0,0 @@
#!/bin/sh
# A Shell script to test LGT
# @(#)$Header$ (BRL)
# Ensure /bin/sh
export PATH || (echo "This isn't sh."; sh $0 $*; kill $$)
eval `machinetype.sh -b` # sets MACHINE, UNIXTYPE, HAS_TCP
if test -f ../.lgt.$MACHINE/lgt
then
LGT=../.lgt.$MACHINE/lgt
DB=../.db.$MACHINE
LD_LIBRARY_PATH=../.libcursor.$MACHINE:../.libtermio.$MACHINE:../.libbu.$MACHINE:../.libbn.$MACHINE:../.librt.$MACHINE:../.libfb.$MACHINE:../.libpkg.$MACHINE:../.libsysv.$MACHINE:$LD_LIBRARY_PATH
else
if test -f ../lgt/lgt
then
echo "Can't find LGT"
exit 1
fi
LGT=../lgt/lgt
DB=../db
LD_LIBRARY_PATH=../libcursor:../libtermio:../libbu:../libbn:../librt:../libfb:../libpkg:../libsysv:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
CMP=./pixcmp
if test ! -f $CMP
then
cake pixcmp
fi
# Alliant NFS hack
if test x${MACHINE} = xfx
then
cp ${LGT} /tmp/lgt
cp ${CMP} /tmp/pixcmp
LGT=/tmp/lgt
CMP=/tmp/pixcmp
fi
# This test of LGT assumes a "live" framebuffer here.
if test x$FB_FILE = x
then
echo "Environment variable FB_FILE must be set to a real framebuffer"
echo "for this test of LGT to operate correctly."
exit 1
fi
# Run the first set of tests
${LGT} ${DB}/lgt-test.g all.g << EOF
# read light source data base
v ../db/lgt-test.ldb
# read material data base
w ../db/lgt-test.mdb
# force display window to be 512x512 pixels, should cause 8-to-1 zoom
T 512
# clear frame buffer
E
# set maximum bounces to 20
K 20
# turn hidden-line drawing off
k 0
# configure grid: 64 rays across
G 64 0 0 0.0
# turn perspective off
p 0
# change background to mauve
b 111 66 66
# read key frame
j ../db/lgt-test.key
# display view #3
R
# save image in file
H lgt3a.pix
# change frame buffer to disk file
o lgt3b.pix
# save a script of previous commands, to produce the "b" version.
S script3
# disable reading of key frame file
j
# change frame buffer back to default
o
# configure grid: 2.45 mm cells, centered about model origin, view size 225 mm
G 2.45 1 1 225.0
# change background to firebrick
b 142 35 35
# force frame buffer size to be 455 pixels across, should cause 4-to-1 zoom
T 455
# set automatic perspective at 0.25
p 0.25
# set anti-aliasing over-sampling factor to 2
A 2
# set maximum bounces to 20
K 20
# display view #1
R
# save image in file
H lgt1a.pix
# change frame buffer to disk file
o lgt1b.pix
# save a script
S script1
# change frame buffer back to default
o
# turn off anti-aliasing
A 1
# revert to auto-sizing of frame buffer
T 0
# set automatic perspective at 0.25
p 0.25
# select hidden-line drawing, reverse video
k 2
# configure grid: 128 rays across, centered at model RPP, view size 225mm
G 128 0 0 225.0
# display view #2
R
# save image in file
H lgt2a.pix
# change frame buffer to disk file
o lgt2b.pix
# save a script
S script2
# change frame buffer back to default
o
# bye
q
EOF
if test $? = 0
then :;
else echo "Abnormal lgt exit"; exit 1
fi
# Run the second set of tests. The scripts were created above.
./script1 < /dev/null &&
./script2 < /dev/null &&
./script3 < /dev/null || { echo "Script test failed."; exit 1; }
FAIL=0
for i in 1 2 3
do
if ${CMP} ../pix/lgt${i}.pix lgt${i}a.pix
then :;
else echo "Test $i A failed."; FAIL=1
fi
if ${CMP} ../pix/lgt${i}.pix lgt${i}b.pix
then :;
else echo "Test $i B failed."; FAIL=1
fi
done
if test "$FAIL" -eq 0
then
echo "LGT Tested OK."
exit 0
fi
echo "*** LGT does NOT work on this platform ***"
exit 2
-74
View File
@@ -1,74 +0,0 @@
#!/bin/sh
# A Shell script to extract the benchmark statistics, and build an
# entry suitable for the tables in doc/benchmark.doc.
# Note well that the command-line args may have embedded spaces.
# Mike Muuss & Susan Muuss, 11-Sept-88.
# @(#)$Header$ (BRL)
# Ensure /bin/sh
export PATH || (sh $0 $*; kill $$)
NAME=$0
if test "x$1" = x
then
echo "Usage: $NAME hostname [note1] [note2]"
exit 1
fi
# Save three args, because arg list will be reused below.
# They may have embedded spaces in them.
HOST="$1"
NOTE1="$2"
NOTE2="$3"
NEW_FILES="moss.log world.log star.log bldg391.log m35.log"
REF_FILES="../pix/moss.log ../pix/world.log ../pix/star.log \
../pix/bldg391.log ../pix/m35.log"
for i in $NEW_FILES $REF_FILES
do
if test ! -f $i
then
echo "${NAME}: file $i does not exist, aborting"
exit 1
fi
done
# Use TR to convert newlines to tabs.
VGRREF=`grep RTFM $REF_FILES | \
sed -n -e 's/^.*= *//' -e 's/ rays.*//p' | \
tr '\012' '\011' `
CURVALS=`grep RTFM $NEW_FILES | \
sed -n -e 's/^.*= *//' -e 's/ rays.*//p' | \
tr '\012' '\011' `
RATIO_LIST=""
# Trick: Force args $1 through $5 to the numbers in $CURVALS
# This should be "set -- $CURVALS", but 4.2BSD /bin/sh can't handle it,
# and CURVALS are all positive (ie, no leading dashes), so this is safe.
set $CURVALS
while test $# != 5
do echo "${NAME}: Warning, only $# times found, adding a zero."
CURVALS="${CURVALS}0 "
set $CURVALS
done
for ref in $VGRREF
do
cur=$1
shift
RATIO=`echo "2k $cur $ref / p" | dc`
# Note: append new value and a trail TAB to existing list.
RATIO_LIST="${RATIO_LIST}$RATIO "
done
# The number of plus signs must be one less than the number of elements.
MEAN_ABS=`echo 2k $CURVALS ++++ 5/ p | dc`
MEAN_REL=`echo 2k $RATIO_LIST ++++ 5/ p | dc`
# Note: Both RATIO_LIST and CURVALS have an extra trailing tab.
# The question mark is for the mean field
echo "Abs ${HOST} ${CURVALS}${MEAN_ABS} $NOTE1"
echo "*vgr ${HOST} ${RATIO_LIST}${MEAN_REL} $NOTE2"
-126
View File
@@ -1,126 +0,0 @@
/*
* P I X C M P . C
*
* Compute the difference between two .pix files.
* To establish context, a monochrome image is produced when there
* are no differences; otherwise the channels that differ are
* highlighted on differing pixels.
*
* This routine operates on a pixel-by-pixel basis, and thus
* is independent of the resolution of the image.
*
* Author -
* Charles M. Kennedy
* Michael John Muuss
*
* Source -
* SECAD/VLD Computing Consortium, Bldg 394
* The U. S. Army Ballistic Research Laboratory
* Aberdeen Proving Ground, Maryland 21005
*
* Copyright Notice -
* This software is Copyright (C) 1988 by the United States Army.
* All rights reserved.
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include "conf.h"
#include <stdio.h>
long matching;
long off1;
long offmany;
char usage[] = "Usage: pixcmp f1.pix f2.pix\n";
main(argc, argv)
char **argv;
{
register FILE *f1, *f2;
if( argc != 3 ) {
fprintf(stderr, "%s", usage);
exit(0);
}
if( strcmp( argv[1], "-" ) == 0 )
f1 = stdin;
else if( (f1 = fopen( argv[1], "r" ) ) == NULL ) {
perror( argv[1] );
exit(1);
}
if( strcmp( argv[2], "-" ) == 0 )
f2 = stdin;
else if( (f2 = fopen( argv[2], "r" ) ) == NULL ) {
perror( argv[2] );
exit(1);
}
while(1) {
register int r1, g1, b1;
int r2, g2, b2;
r1 = fgetc( f1 );
g1 = fgetc( f1 );
b1 = fgetc( f1 );
r2 = fgetc( f2 );
g2 = fgetc( f2 );
b2 = fgetc( f2 );
if( feof(f1) || feof(f2) ) break;
if( r1 != r2 || g1 != g2 || b1 != b2 ) {
register int i;
/* Highlight differing channels */
if( r1 != r2 ) {
if( (i = r1 - r2) < 0 ) i = -i;
if( i > 1 ) {
offmany++;
} else {
off1++;
}
} else {
matching++;
}
if( g1 != g2 ) {
if( (i = g1 - g2) < 0 ) i = -i;
if( i > 1 ) {
offmany++;
} else {
off1++;
}
} else {
matching++;
}
if( b1 != b2 ) {
if( (i = b1 - b2) < 0 ) i = -i;
if( i > 1 ) {
offmany++;
} else {
off1++;
}
} else {
matching++;
}
} else {
/* Common case: equal. Give B&W NTSC average */
matching += 3;
}
}
fprintf(stderr,
"pixcmp bytes: %8ld matching, %8ld off by 1, %8ld off by many\n",
matching, off1, offmany );
/* If files were of different lengths, that is an error */
if( feof(f1) != feof(f2) )
exit(2);
/* If any pixels were off by more than +/- 1, that is an error */
if( offmany)
exit(1);
/* Success! */
exit(0);
}
-15
View File
@@ -1,15 +0,0 @@
#!/bin/sh
# WARNING THIS IS A REAL CPU HOG
../rt/rt -p90 -f1024 -H3 -M $*\
-o cube.pix\
../db/cube.g\
'all.g' \
2> cube.log\
<<EOF
6.847580140e+03
3.699276190e+03 3.032924070e+03 3.658674860e+03
-5.735762590e-01 8.191521640e-01 0.000000000e+00 0.000000000e+00
-3.461885920e-01 -2.424037690e-01 9.063078880e-01 0.000000000e+00
7.424040310e-01 5.198366640e-01 4.226181980e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00
EOF
-52
View File
@@ -1,52 +0,0 @@
#!/bin/sh
# A Shell script to re-check the most recent results of the benchmark
# @(#)$Header$ (BRL)
# Ensure /bin/sh
export PATH || (echo "This isn't sh."; sh $0 $*; kill $$)
eval `machinetype.sh -b` # sets MACHINE, UNIXTYPE, HAS_TCP
if test -f ../.util.$MACHINE/pixdiff
then
PIXDIFF=../.util.$MACHINE/pixdiff
PIX_FB=../.fb.$MACHINE/pix-fb
LD_LIBRARY_PATH=../.libbu.$MACHINE:../.libbn.$MACHINE:../.librt.$MACHINE:../.libfb.$MACHINE:../.libpkg.$MACHINE:../.libsysv.$MACHINE:$LD_LIBRARY_PATH
else
if test -f ../util/pixdiff
then
PIXDIFF=../util/pixdiff
PIX_FB=../fb/pix-fb
else
echo "Can't find pixdiff"
exit 1
fi
LD_LIBRARY_PATH=../libbu:../libbn:../librt:../libfb:../libpkg:../libsysv:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
# Alliant NFS hack
if test x${MACHINE} = xfx
then
cp ${PIXDIFF} /tmp/pixdiff
cp ${PIX_FB} /tmp/pix-fb
PIXDIFF=/tmp/pixdiff
PIX_FB=/tmp/pix-fb
fi
echo +++++ moss.pix
${PIXDIFF} ../pix/moss.pix moss.pix | ${PIX_FB}
echo +++++ world.pix
${PIXDIFF} ../pix/world.pix world.pix | ${PIX_FB}
echo +++++ star.pix
${PIXDIFF} ../pix/star.pix star.pix | ${PIX_FB}
echo +++++ bldg391.pix
${PIXDIFF} ../pix/bldg391.pix bldg391.pix | ${PIX_FB}
echo +++++ m35.pix
${PIXDIFF} ../pix/m35.pix m35.pix | ${PIX_FB}
echo +++++ sphflake.pix
${PIXDIFF} ../pix/sphflake.pix sphflake.pix | ${PIX_FB}
-207
View File
@@ -1,207 +0,0 @@
#!/bin/sh
# A Shell script to run the BRL-CAD Benchmark Test
# @(#)$Header$ (BRL)
# Ensure /bin/sh
export PATH || (echo "This isn't sh."; sh $0 $*; kill $$)
eval `machinetype.sh -b` # sets MACHINE, UNIXTYPE, HAS_TCP
if test -f ../.rt.$MACHINE/rt
then
RT=../.rt.$MACHINE/rt
DB=../.db.$MACHINE
LD_LIBRARY_PATH=../.libbu.$MACHINE:../.libbn.$MACHINE:../.librt.$MACHINE:../.libfb.$MACHINE:../.libpkg.$MACHINE:../.libsysv.$MACHINE:$LD_LIBRARY_PATH
else
if test ! -f ../rt/rt
then
echo "Can't find RT"
exit 1
fi
RT=../rt/rt
DB=../db
LD_LIBRARY_PATH=../libbu:../libbn:../librt:../libfb:../libpkg:../libsysv:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
CMP=./pixcmp
if test ! -f $CMP
then
cake pixcmp
fi
# Alliant NFS hack
if test x${MACHINE} = xfx
then
cp ${RT} /tmp/rt
cp ${CMP} /tmp/pixcmp
RT=/tmp/rt
CMP=/tmp/pixcmp
fi
# Run the tests
echo +++++ moss
if test -f moss.pix; then mv -f moss.pix moss.pix.$$; fi
if test -f moss.log; then mv -f moss.log moss.log.$$; fi
time $RT -B -M -s512 $* \
-o moss.pix \
$DB/moss.g all.g \
2> moss.log \
<< EOF
viewsize 1.572026215e+02;
eye_pt 6.379990387e+01 3.271768951e+01 3.366661453e+01;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
${CMP} ../pix/moss.pix moss.pix
if test $? = 0
then
echo moss.pix: answers are RIGHT
else
echo moss.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo +++++ world
if test -f world.pix; then mv -f world.pix world.pix.$$; fi
if test -f world.log; then mv -f world.log world.log.$$; fi
time $RT -B -M -s512 $* \
-o world.pix \
$DB/world.g all.g \
2> world.log \
<< EOF
viewsize 1.572026215e+02;
eye_pt 6.379990387e+01 3.271768951e+01 3.366661453e+01;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
${CMP} ../pix/world.pix world.pix
if test $? = 0
then
echo world.pix: answers are RIGHT
else
echo world.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo +++++ star
if test -f star.pix; then mv -f star.pix star.pix.$$; fi
if test -f star.log; then mv -f star.log star.log.$$; fi
time $RT -B -M -s512 $* \
-o star.pix \
$DB/star.g all \
2> star.log \
<<EOF
viewsize 2.500000000e+05;
eye_pt 2.102677960e+05 8.455500000e+04 2.934714650e+04;
viewrot -6.733560560e-01 6.130643360e-01 4.132114880e-01 0.000000000e+00
5.539599410e-01 4.823888300e-02 8.311441420e-01 0.000000000e+00
4.896120540e-01 7.885590550e-01 -3.720948210e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00 ;
start 0;
end;
EOF
${CMP} ../pix/star.pix star.pix
if test $? = 0
then
echo star.pix: answers are RIGHT
else
echo star.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo +++++ bldg391
if test -f bldg391.pix; then mv -f bldg391.pix bldg391.pix.$$; fi
if test -f bldg391.log; then mv -f bldg391.log bldg391.log.$$; fi
time $RT -B -M -s512 $* \
-o bldg391.pix \
$DB/bldg391.g all.g \
2> bldg391.log \
<<EOF
viewsize 1.800000000e+03;
eye_pt 6.345012207e+02 8.633251343e+02 8.310771484e+02;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
${CMP} ../pix/bldg391.pix bldg391.pix
if test $? = 0
then
echo bldg391.pix: answers are RIGHT
else
echo bldg391.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo +++++ m35
if test -f m35.pix; then mv -f m35.pix m35.pix.$$; fi
if test -f m35.log; then mv -f m35.log m35.log.$$; fi
time $RT -B -M -s512 $* \
-o m35.pix \
$DB/m35.g all.g \
2> m35.log \
<< EOF
viewsize 6.787387985e+03;
eye_pt 3.974533127e+03 1.503320754e+03 2.874633221e+03;
viewrot -5.527838919e-01 8.332423558e-01 1.171090926e-02 0.000000000e+00
-4.815587087e-01 -3.308784486e-01 8.115544728e-01 0.000000000e+00
6.800964482e-01 4.429747496e-01 5.841593895e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00 ;
start 0;
end;
EOF
${CMP} ../pix/m35.pix m35.pix
if test $? = 0
then
echo m35.pix: answers are RIGHT
else
echo m35.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo +++++ sphflake
if test -f sphflake.pix; then mv -f sphflake.pix sphflake.pix.$$; fi
if test -f sphflake.log; then mv -f sphflake.log sphflake.log.$$; fi
time $RT -B -M -s512 $* \
-o sphflake.pix \
$DB/sphflake.g \
"scene.r" \
2> sphflake.log \
<< EOF
viewsize 2.556283261452611e+04;
orientation 4.406810841785839e-01 4.005093234738861e-01 5.226451688385938e-01 6.101102288499644e-01;
eye_pt 2.418500583758302e+04 -3.328563644344796e+03 8.489926952850350e+03;
start 0;
end;
EOF
${CMP} ../pix/sphflake.pix sphflake.pix
if test $? = 0
then
echo sphflake.pix: answers are RIGHT
else
echo sphflake.pix: WRONG WRONG WRONG WRONG WRONG WRONG
fi
echo
echo Testing complete, check times against reference files in ../pix/.
if test x$UNIXTYPE = xBSD
then HOST=`hostname`
else HOST=`uname -n`
fi
sh ../bench/perf.sh "$HOST" "`date`" "$*" >> summary
-133
View File
@@ -1,133 +0,0 @@
#!/bin/sh
# A Shell script to run the BRL-CAD Benchmark Test,
# with output going to the current framebuffer, rather than a file.
# @(#)$Header$ (BRL)
# Ensure /bin/sh
export PATH || (echo "This isn't sh."; sh $0 $*; kill $$)
eval `machinetype.sh -b` # sets MACHINE, UNIXTYPE, HAS_TCP
if test -f ../.rt.$MACHINE/rt
then
RT=../.rt.$MACHINE/rt
DB=../.db.$MACHINE
LD_LIBRARY_PATH=../.libbu.$MACHINE:../.libbn.$MACHINE:../.librt.$MACHINE:../.libfb.$MACHINE:../.libpkg.$MACHINE:../.libsysv.$MACHINE:$LD_LIBRARY_PATH
else
if test ! -f ../rt/rt
then
echo "Can't find RT"
exit 1
fi
RT=../rt/rt
DB=../db
LD_LIBRARY_PATH=../libbu:../libbn:../librt:../libfb:../libpkg:../libsysv:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
CMP=./pixcmp
if test ! -f $CMP
then
cake pixcmp
fi
# Alliant NFS hack
if test x${MACHINE} = xfx
then
cp ${RT} /tmp/rt
cp ${CMP} /tmp/pixcmp
RT=/tmp/rt
CMP=/tmp/pixcmp
fi
# Run the tests
echo +++++ moss
time $RT -B -M -s512 $* \
$DB/moss.g all.g \
<< EOF
viewsize 1.572026215e+02;
eye_pt 6.379990387e+01 3.271768951e+01 3.366661453e+01;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
echo +++++ world
time $RT -B -M -s512 $* \
$DB/world.g all.g \
<< EOF
viewsize 1.572026215e+02;
eye_pt 6.379990387e+01 3.271768951e+01 3.366661453e+01;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
echo +++++ star
time $RT -B -M -s512 $* \
$DB/star.g all \
<<EOF
viewsize 2.500000000e+05;
eye_pt 2.102677960e+05 8.455500000e+04 2.934714650e+04;
viewrot -6.733560560e-01 6.130643360e-01 4.132114880e-01 0.000000000e+00
5.539599410e-01 4.823888300e-02 8.311441420e-01 0.000000000e+00
4.896120540e-01 7.885590550e-01 -3.720948210e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00 ;
start 0;
end;
EOF
echo +++++ bldg391
time $RT -B -M -s512 $* \
$DB/bldg391.g all.g \
<<EOF
viewsize 1.800000000e+03;
eye_pt 6.345012207e+02 8.633251343e+02 8.310771484e+02;
viewrot -5.735764503e-01 8.191520572e-01 0.000000000e+00
0.000000000e+00 -3.461886346e-01 -2.424038798e-01 9.063078165e-01
0.000000000e+00 7.424039245e-01 5.198368430e-01 4.226182699e-01
0.000000000e+00 0.000000000e+00 0.000000000e+00 0.000000000e+00
1.000000000e+00 ;
start 0;
end;
EOF
echo +++++ m35
time $RT -B -M -s512 $* \
$DB/m35.g all.g \
<< EOF
viewsize 6.787387985e+03;
eye_pt 3.974533127e+03 1.503320754e+03 2.874633221e+03;
viewrot -5.527838919e-01 8.332423558e-01 1.171090926e-02 0.000000000e+00
-4.815587087e-01 -3.308784486e-01 8.115544728e-01 0.000000000e+00
6.800964482e-01 4.429747496e-01 5.841593895e-01 0.000000000e+00
0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00 ;
start 0;
end;
EOF
echo +++++ sphflake
time $RT -B -M -s512 $* \
$DB/sphflake.g scene.r \
<< EOF
viewsize 2.556283261452611e+04;
orientation 4.406810841785839e-01 4.005093234738861e-01 5.226451688385938e-01 6.101102288499644e-01;
eye_pt 2.418500583758302e+04 -3.328563644344796e+03 8.489926952850350e+03;
start 0;
end;
EOF
-26
View File
@@ -1,26 +0,0 @@
/*
* brlman/Cakefile
*
* Note: The file "awf" needs to know where ../awf/Cakefile put the
* pieces (ETCDIR by default).
*/
#include "../Cakefile.defs"
#define PRODUCTS awf brlman
#define SRCDIR brlman
#define FILES /**/
#define SRCSUFF /**/
#define MANSECTION 1
#define STATIC_PRODUCTS PRODUCTS /* Force PRODUCTS into dist */
/*
* There is nothing to compile.
* The "install-prod" rule should install PRODUCTS,
* and "inst-dist" rule shoudl take care of copying to distribution dir.
* Nothing else to do.
*/
all&:
@echo "SRCDIR: all done"
#include "../Cakefile.rules"
-61
View File
@@ -1,61 +0,0 @@
#! /bin/sh
eval `machinetype.sh -v` # BRL mod: sets $BASEDIR
PATH=/bin:/usr/bin ; export PATH
# AWFLIB is where the pieces live
AWFLIB=${AWFLIB-$BASEDIR/etc} # BRL mod
tmp=/tmp/awp$$ # tempfile for building pass 2
errs=/tmp/awe$$ # error messages (awk can't send to stderr)
case "$1" in
-ms) mac=ms ;;
-man) mac=man ;;
*) echo "$0: must specify -ms or -man" >&2
exit 2
;;
esac
shift
dev="$AWFLIB/dev.$TERM"
if test ! -r $dev
then
dev="$AWFLIB/dev.dumb"
fi
trap "rm -f $tmp $errs ; exit 0" 0 1 2
# build the full, macro-set-dependent, pass-2 awk program
(
sed -n '1,/^#include/p' $AWFLIB/pass2.base
cat $AWFLIB/pass2.$mac
sed -n '/^#include/,$p' $AWFLIB/pass2.base
) >$tmp
# do it
(
echo ".^x $errs"
echo ".^b"
echo ".^# 1 <prolog>"
cat $dev $AWFLIB/common $AWFLIB/mac.$mac
if test " $*" = " "
then
echo ".^# 1 <stdin>"
cat
else
for f
do
echo ".^# 1 $f"
cat $f
done
fi
echo ".^e"
) | awk -f $AWFLIB/pass1 | awk -f $tmp | awk -f $AWFLIB/pass3
# error messages, if any
if test -s $errs
then
cat $errs >&2
exit 1
else
exit 0
fi
-54
View File
@@ -1,54 +0,0 @@
#!/bin/sh
# B R L M A N
#
# A substitute for the "man" command for those systems that do not
# have NROFF. Henry Spencer's "nroff -man" replacement called AWF
# is used instead.
#
# Michael John Muuss, BRL, 23-June-1991.
# Public Domain, Distribution Unlimited
#
# @(#) $Header$ (BRL)
if test $# -lt 1
then
echo "Usage: $0 command"
echo " To obtain help about that command"
exit 1
fi
# Use MANPAGER, else use PAGER, else use "more" command.
MORE="more -s -f"
if test "$PAGER" != ""
then
MORE="${PAGER}"
fi
if test "${MANPAGER}" != ""
then
MORE="${MANPAGER}"
fi
eval `machinetype.sh -v` # sets $BASEDIR
# Ensure that MANPATH is set and has BRL-CAD materials listed first.
MANPATH=${BASEDIR}/man:${MANPATH}
PATH_ELEMENTS=`echo ${MANPATH} | sed 's/^://
s/:://g
s/:$//
s/:\\.:/:/g
s/:/ /g'`
for PLACE in ${PATH_ELEMENTS}
do
PATTERN="${PLACE}/man?/$1.?"
TRY=`eval echo ${PATTERN}`
if test "${TRY}" != "${PATTERN}"
then
# Found something(s), format it/them
echo ${TRY}
awf -man ${TRY} | ${MORE}
fi
done
exit 0
-43
View File
@@ -1,43 +0,0 @@
.TH BRLMAN 1 BRL/CAD
.SH NAME
brlman \- display manual pages for BRL-CAD software
.SH SYNOPSIS
.B brlman
title
.SH DESCRIPTION
.I Brlman
provides a substitute for the
.I man
command for those systems that do not
have
.I nroff.
Henry Spencer's
.I nroff -man
replacement called
.I awf
is used instead.
.I Brlman
uses the environment variable
.I MANPATH
to determine where to search for the manual pages (
.I /usr/brlcad/man
is the default). The pager used is taken from the environment variable
.I MANPAGER
or, if that is nor set
.I PAGER
is used. The default is to use the
.I more -s -f
command.
.SH "SEE ALSO"
awf(1)
.SH AUTHOR
Michael John Muuss
.SH SOURCE
SECAD/VLD Computing Consortium, Bldg 394
.br
The U. S. Army Ballistic Research Laboratory
.br
Aberdeen Proving Ground, Maryland 21005
.SH "BUG REPORTS"
Reports of bugs or problems should be submitted via electronic
mail to <CAD@BRL.MIL>.
-55
View File
@@ -1,55 +0,0 @@
/*
burst/Cakefile
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/* Remove the following line if you have BRLCAD 4.0 or later. */
/* #define LIBFB_LIBES /**/
#define CONFIGDEFS LGT_CONFIG -I. -U_POSIX_SOURCE /*-DDEBUG*/
#define SRCDIR burst
#define PRODUCTS burst
#define SRCSUFF .c
#define MANSECTION 1
#define FILES burst error fb glob grid gridrotate idents\
paint plot prnt trie ui\
Hm HmGetc HmGlob Sc
#include "../Cakefile.defs"
#include "../Cakefile.prog"
/* Explicit composition of each product */
PRODUCTS: OBJ LIBRT_DEP LIBBN_DEP LIBFB_DEP LIBBU_DEP LIBTERMIO_DEP
CC LDFLAGS -o burst OBJ LIBRT LIBBN LIBBU LIBBU_LIBES LIBTERMIO LIBTERMLIB LIBFB LIBFB_LIBES LIBES -lm
all&: PRODUCTS
test&: ../.burst.MTYPE/burst tfiles/ktank.g
../.burst.MTYPE/burst -b < tfiles/ktank.in
@if test $? -ne 0 \\
then echo "Test failed."; exit 1 \\
fi
diff tfiles/ktank.burst tfiles/ktank.burst.bak4.0
@if test $? -ne 0 \\
then echo "Test failed."; exit 1 \\
fi
diff tfiles/ktank.shotlines tfiles/ktank.shotlines.bak4.0
@if test $? -ne 0 \\
then echo "Test failed."; exit 1 \\
fi
@echo "Tested OK."
untest&:
rm -f tfiles/ktank.burst tfiles/ktank.shotlines tfiles/ktank.plot \\
tfiles/ktank.pix tfiles/ktank.g tfiles/ktank.log
tfiles/ktank.g:
asc2g < ../burst/tfiles/ktank.asc > tfiles/ktank.g
#include "../Cakefile.rules"
-1335
View File
File diff suppressed because it is too large Load Diff
-325
View File
@@ -1,325 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/**
<Hm.h> -- MUVES "Hm" (hierarchical menu) package definitions
**/
#ifndef Hm_H_INCLUDE
#define Hm_H_INCLUDE
/**
This software and documentation is derived in part from the
menuhit(9.3) manual pages (not source code) in AT&T 9th Edition
UNIX, Version 1 Programmer's Manual.
The Hm package provides a pop-up menu implementation which uses
a terminal-independent screen management facility (Sc package)
to simulate the necessary graphics using the ASCII character set.
Only a few keyboard characters are required to control the menus,
but when possible, as with DMD terminals running a MYX terminal
emulator, the menus can be controlled with the mouse.
**/
/**
Each menu is defined by the following structure:
typedef struct
{
HmItem *item;
HmItem *(*generator)();
short prevtop;
short prevhit;
bool sticky;
}
HmMenu;
A menu can be built as an array of HmItem's, pointed to by item,
or with a generator function. If item is (HmItem *) 0, the
generator field is assumed to be valid. The generator function
is passed an integer parameter, and must return the pointer to
an HmItem in a static area (the result is only needed until the
next call). The n's are guaranteed to start at 0 and increase
by 1 each invocation until generator returns (HmItem *) 0.
Prevtop will contain the index of the menu item which appeared
at the top of the menu the last time it was displayed. Prevhit
will contain the index of the last item traversed (indices begin
at 0). If sticky is true, the menu will hang around after an
entry is selected so that another entry may be chosen and the
menu must be exited explicitly with the appropriate key-stroke
or equivalent mouse operation. Otherwise, the menu will exit
after selection of an item (and any actions resulting from that
selection such as submenus have finished). WARNING: if a menu
is to be used more than once during recursive calls to HmHit,
there needs to be distinct copies (allocated storage) since the
item field is filled in by the generator function, and the
prevtop and prevhit fields should be private to the current
invocation of HmHit.
**/
struct HmMenu;
typedef struct
{
char *text; /* menu item string */
char *help; /* help string */
struct HmMenu *next; /* sub-menu pointer or NULL */
void (*dfn)();
void (*bfn)();
void (*hfn)();
long data;
}
HmItem;
/**
Menu items are defined by the following structure:
typedef struct
{
char *text;
char *help;
HmMenu *next;
void (*dfn)();
void (*bfn)();
void (*hfn)();
long data;
}
HmItem;
The text field will be displayed as the name of the item.
Characters with the 0200 bit set are regarded as fill characters.
For example, the string "\240X" will appear in the menu as a
right-justified X (040 is the ASCII space character). Menu
strings without fill characters are drawn centered in the menu.
Whether generated statically or dynamically, the list of HmItem's
must be terminated by a NULL text field. The help string will be
displayed when the user presses the help key. If next is not
equal to (HmMenu *) 0, it is assumed to point to a submenu,
"dfn()" if non-zero is called just before the submenu is invoked,
and "bfn()" likewise just afterwards. These functions are passed
the current menu item. If the menu item is selected and next is
0, "hfn()" is called (if non-zero), also with the current menu
item. The "data" field is reserved for the user to pass
information between these functions and the calling routine.
**/
typedef struct HmMenu
{
HmItem *item; /* List of menu items or 0. */
HmItem *(*generator)();/* If item == 0, generates items. */
short prevtop; /* Top entry currently visable */
short prevhit; /* Offset from top of last select */
bool sticky; /* If true, menu stays around after SELECT,
and until QUIT. */
}
HmMenu;
/* Structure used internally for screen management. These are stacked
dynamically with calls to HmHit() such that the head of the chain
is the current menu, and the end of the chain such that next is
0, is the top-level menu.
*/
typedef struct HmWin
{
struct HmWin *next; /* Parent of this menu. */
HmMenu *menup; /* Address of menu data structure. */
int menux; /* Position on screen where top-left */
int menuy; /* corner of menu will be displayed. */
int width; /* Width of menu, not including border. */
int height; /* Number of menu entries. */
int *dirty; /* Dynamically allocated bitmap. ON bits
mean character needs a redraw. */
}
HmWindow;
/**
bool HmInit( int x, int y, int maxvis )
HmInit() must be called before any other routines in the
Hm package to initialize the screen position of the top-left
corner of the top-level menu to x and y and to set the
maximum number of menu entries which will be visable at one
time to maxvis. If the number of entries in a menu exceeds
maxvis, the menu will scroll to accommodate them. The values
of x, y and maxvis are stored in these external variables:
int HmLftMenu
int HmTopMenu
int HmMaxVis
If this routine is not called, default parameters will be used.
HmInit() also opens "/dev/tty" for input and stores it's file
descriptor in HmTtyFd and associated stream handle in HmTtyFp.
int HmTtyFd
FILE *HmTtyFp
This routine returns true or false on success or failure to open
"/dev/tty".
**/
#if __STDC__
extern bool HmInit( int x, int y, int maxvis );
#else
extern bool HmInit();
#endif
extern FILE *HmTtyFp;
extern int HmLftMenu;
extern int HmTopMenu;
extern int HmMaxVis;
extern int HmLastMaxVis;
extern int HmTtyFd;
/**
HmItem *HmHit( HmMenu *menup )
HmHit() presents the user with a menu specified by HmMenu
pointer menup and returns a pointer to the selected HmItem
or 0 if nothing was selected. The menu is presented to
the user with the item corresponding to prevhit (current
item) highlighted. If a menu has not been accessed yet,
prevhit will be set to the first item. The user may move
the cursor to the item below the current one by pressing the
'd' key, or move up by pressing the 'u'. If the user
presses 'h', the help message for the current item will be
displayed until another key is struck. To select an item,
the user presses the space bar. An actual selection has
been made when the selected item does not have a submenu,
otherwise, it may be termed a traversal of that item.
Traversing an item does change the value of prevhit, but
is not final as the submenu can be exited by the user
pressing 'q', before selecting an item. In case the screen
becomes disturbed (i.e. by the output of another process),
holding down the <control> key and striking an 'l' will
re-display all of the menus.
Both the help and warning (non-fatal error) messages will
be displayed in the one-line window at HmYCOMMO. For
instance, if the user hits any keys other than the ones
mentioned above, an error message will appear in this
window. Also, a one-line window is reserved for application
prompts at HmYPROMPT. The prompt window is cleared just
prior to blocking on user input, and the message window
is cleared when the user provides input (strikes a key).
If a menu has more items than can be displayed at once,
the corners of the menu will indicate this as follows:
'+' means the adjacent displayed item is the actual first
(or last if a bottom corner) item in the menu.
'v' means that the entry displayed in the previous line
is not the last, and the menu can be scrolled upwards.
'^' means that the entry displayed on the next line is
not actually the first, and the menu can be scrolled
downwards.
Attempting to move the cursor below the bottom entry of
the menu will cause the menu to scroll half a page or
until the entries run out, which ever comes first. If
there are no entries to scroll the terminal will beep.
The analagous holds true for attempting to move upward
past the top entry of the menu. If a DMD terminal with
MYX running is used, a special cursor will appear, and
the user may use the mouse rather than the keyboard as
follows: Clicking button 1 of the mouse while the
cursor is outside the "current menu", will cause the
terminal to beep. If the cursor is on an item, that item
will be made "current". If on the "current" item, that
item will be selected. If on the top border of the
current menu, that menu will scroll down if possible, and
if not, that menu will exit. If on the bottom border,
that menu will scroll upward if possible and beep if not.
**/
#if __STDC__
extern HmItem *HmHit( HmMenu *menup );
#else
extern HmItem *HmHit();
#endif
/**
void HmRedraw( void )
HmRedraw() will force the entire set of active menus to
be redrawn on the next call to HmHit(). This is useful
when an application interferes with the portion of the
screen used by the Hm package (from HmTopMenu to HmYCOMMO).
**/
#if __STDC__
extern void HmRedraw( void );
#else
extern void HmRedraw();
#endif
/**
void HmError( char *string )
HmError() will display string on line HmYCOMMO.
**/
#if __STDC__
extern void HmError( char *str );
#else
extern void HmError();
#endif
#define HmYCOMMO (HmTopMenu+HmMaxVis+HmHGTBORDER)
#define HmYPROMPT (HmYCOMMO+1)
#define HmXPROMPT 1
#define HmYBORDER (HmYPROMPT+1)
/**
int HmGetchar( void )
int HmUngetchar( int c )
HmGetchar() and HmUngetchar() are used by the Hm package to
read a character from the keyboard and to stuff one character
back on the input stream. They may be both be supplied by
the application if the default behavior is not desirable.
HmGetchar() returns the next character on the standard input.
This command will block until input is available.
HmUngetchar() inserts the character c on the standard input.
An EOF will be returned if this is not possible or c is
equal to EOF. In general, this is guaranteed to work for one
character assuming that something has already been read with
HmGetchar() and the input stream is buffered.
**/
#if __STDC__
extern int HmGetchar( void );
extern int HmUngetchar( int c );
#else
extern int HmGetchar();
extern int HmUngetchar();
#endif
/**
void HmTtySet( void )
void HmTtyReset( void )
HmTtySet() and HmTtyReset() set/restore the terminal modes for
the menus to work properly. These are mainly internal routines
which are called from HmHit(), but are provided in case an
escape from the program is provided by the application or job
control is enabled in the underlying shell, in which case,
these routines can be called from a menu function or signal
handler.
**/
extern void HmTtySet();
extern void HmTtyReset();
#define HmMAXLINE 132
#define HmHGTBORDER 2
#endif /* Hm_H_INCLUDE */
-36
View File
@@ -1,36 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
#if ! defined( lint )
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
#include "./burst.h"
#include "./Hm.h"
/*LINTLIBRARY*/
int
#if __STDC__
HmGetchar( void )
#else
HmGetchar()
#endif
{ int c;
while( (c = getc( HmTtyFp )) == EOF )
;
return c;
}
int
#if __STDC__
HmUngetchar( int c )
#else
HmUngetchar( c )
#endif
{
return ungetc( c, HmTtyFp );
}
-19
View File
@@ -1,19 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/*LINTLIBRARY*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
FILE *HmTtyFp = NULL; /* read keyboard, not stdin */
int HmLftMenu = 1; /* default top-level menu position */
int HmTopMenu = 1;
int HmMaxVis = 10; /* default maximum menu items displayed */
int HmLastMaxVis = 10; /* track changes in above parameter */
int HmTtyFd; /* read keyboard, not stdin */
-22
View File
@@ -1,22 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/* Emulate MUVES Mm package using malloc. */
#if __STDC__
#include <stdlib.h>
#include <string.h>
#else
extern char *malloc();
extern char *strcpy();
#endif
#define MmAllo( typ ) (typ *) malloc( sizeof(typ) )
#define MmFree( typ, ptr ) free( (char *) ptr )
#define MmVAllo( ct, typ ) (typ *) malloc( (ct)*sizeof(typ) )
#define MmVFree( ct, typ, ptr ) free( (char *) ptr )
#define MmStrDup( str ) strcpy( malloc( strlen(str)+1 ), str )
#define MmStrFree( str ) free( str )
-451
View File
@@ -1,451 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/*LINTLIBRARY*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
#ifdef BSD
#include <strings.h>
#endif
#ifdef SYSV
#include <string.h>
#endif
#ifndef cray
#if defined( VLDSYSV )
#include <sys/_ioctl.h>
#else
#include <sys/ioctl.h>
#define _winsize winsize /* For compatibility with _ioctl.h. */
#endif
#endif
#include "./Sc.h"
/* Externals from termlib(3). */
#if __STDC__
extern char *tgoto( char *cm, int destcol, int destline );
extern char *tgetstr( char *id, char **area );
extern int tgetent( char *bp, char *name );
#else
extern char *tgoto();
extern char *tgetstr();
extern int tgetent();
#endif
/* Externals from the C library. */
#if __STDC__
extern char *getenv( char *s );
#else
extern char *getenv();
extern char *strncpy();
#endif
static FILE *out_fp; /* Output stream. */
static char tstrings[ScTCAPSIZ]; /* Individual TCS. */
static char *tstr_addr = tstrings; /* Used by tgetstr(). */
static int fd_stdout = 1;
/* This is a global buffer for the terminal capabilities entry. */
char ScTermcap[ScTCAPSIZ];
/* This is a global buffer for the name of the terminal. */
char ScTermname[ScTERMSIZ] = "UNKNOWN";
/* Individual terminal control strings (TCS). */
char *ScBC, /* Backspace character. */
*ScPC, /* Padding character. */
*ScUP, /* Cursor up one line. */
*ScCS, /* Change scrolling region. */
*ScSO, /* Begin standout mode. */
*ScSE, /* End standout mode. */
*ScCE, /* Clear to end of line. */
*ScCL, /* Clear display and home cursor. */
*ScHO, /* Home cursor. */
*ScCM, /* Screen-relative cursor motion. */
*ScTI, /* Initialize terminal. */
*ScAL, /* Insert line. */
*ScDL, /* Delete line. */
*ScSR, /* Scroll text down. */
*ScSF; /* Scroll text up. */
/* Individual terminal parameters. */
int ScLI, /* Number of lines on screen. */
ScCO; /* Number of columns on screen. */
/*
static void ScLoadTP( void )
Get the terminal parameters.
*/
static void
#if __STDC__
ScLoadTP( void )
#else
ScLoadTP()
#endif
{
#ifdef TIOCGWINSZ
/* Get window size for DMD layers support. */
struct _winsize window;
if( ioctl( fd_stdout, TIOCGWINSZ, &window ) == 0
&& window.ws_row != 0 && window.ws_col != 0
)
{
ScLI = (int) window.ws_row;
ScCO = (int) window.ws_col;
}
else
#endif
{
ScLI = tgetnum( "li" );
ScCO = tgetnum( "co" );
}
return;
}
/*
static void ScLoadTCS( void )
Get the terminal control strings.
*/
static void
#if __STDC__
ScLoadTCS( void )
#else
ScLoadTCS()
#endif
{;
ScCS = tgetstr( "cs", &tstr_addr );
ScSE = tgetstr( "se", &tstr_addr );
ScSO = tgetstr( "so", &tstr_addr );
ScCE = tgetstr( "ce", &tstr_addr );
ScCL = tgetstr( "cl", &tstr_addr );
ScHO = tgetstr( "ho", &tstr_addr );
ScCM = tgetstr( "cm", &tstr_addr );
ScBC = tgetstr( "bc", &tstr_addr );
ScPC = tgetstr( "pc", &tstr_addr );
ScUP = tgetstr( "up", &tstr_addr );
ScTI = tgetstr( "ti", &tstr_addr );
ScAL = tgetstr( "al", &tstr_addr );
ScDL = tgetstr( "dl", &tstr_addr );
ScSR = tgetstr( "sr", &tstr_addr );
ScSF = tgetstr( "sf", &tstr_addr );
return;
}
/*
int PutChr( char c )
This function prevents the default "PutChr" from being pulled in
from the termcap library (-ltermlib). DO NOT change its name or
STDOUT will be assumed as the output stream for terminal control.
Some applications might want to open "/dev/tty" so that they can
use STDOUT for something else.
*/
int
#if __STDC__
PutChr( char c )
#else
PutChr( c )
char c;
#endif
{
return putc( c, out_fp );
}
/*
bool ScInit( FILE *fp )
ScInit() must be invoked before any other function in the Sc package.
Stream fp must be open for writing and all terminal control sequences
will be sent to fp, giving the application the option of using STDOUT
for other things. Besides setting the output stream, ScInit() does
the following:
Initializes the terminal. Fills terminal name and capabilities
into external buffers. Gets terminal control strings into external
variables. Gets individual terminal parameters into external
variables. Returns "true" for success, "false" for failure and
prints appropriate diagnostics on STDERR if $TERM is not set or
there is a problem in retrieving the corresponding termcap entry.
*/
bool
#if __STDC__
ScInit( FILE *fp )
#else
ScInit( fp )
FILE *fp;
#endif
{ char *term; /* Name of terminal from environment. */
out_fp = fp;
fd_stdout = fileno( out_fp );
if( (term = getenv( "TERM" )) == NULL )
{
(void) fprintf( stderr, "TERM not set or exported!\n" );
return false;
}
(void) strncpy( ScTermname, term, ScTERMSIZ-1 );
/* Get terminal entry. */
switch( tgetent( ScTermcap, term ) )
{
case -1 :
(void) fprintf( stderr, "Can't open termcap file!\n" );
return false;
case 0 :
(void) fprintf( stderr,
"Terminal type not in termcap file!\n"
);
return false;
}
/* Get individual terminal parameters and control strings. */
ScLoadTP();
ScLoadTCS();
tputs( ScTI, 1, PutChr ); /* Initialize terminal. */
return true; /* All is well. */
}
/*
bool ScClrEOL( void )
Clear from the cursor to the end of that line.
*/
bool
#if __STDC__
ScClrEOL( void )
#else
ScClrEOL()
#endif
{
if( ScCE == NULL )
return false;
tputs( ScCE, 1, PutChr );
return true;
}
/*
bool ScClrScrlReg( void )
Reset the scrolling region to the entire screen.
*/
bool
#if __STDC__
ScClrScrlReg( void )
#else
ScClrScrlReg()
#endif
{
if( ScCS == NULL )
return false;
tputs( tgoto( ScCS, ScLI-1, 0 ), 1, PutChr );
return true;
}
/*
bool ScClrStandout( void )
End standout mode.
*/
bool
#if __STDC__
ScClrStandout( void )
#else
ScClrStandout()
#endif
{
if( ScSE == NULL )
return false;
tputs( ScSE, 1, PutChr );
return true;
}
/* bool ScClrText( void )
Clear the screen and "home" the cursor.
*/
bool
#if __STDC__
ScClrText( void )
#else
ScClrText()
#endif
{
if( ScCL == NULL )
return false;
tputs( ScCL, ScLI, PutChr );
return true;
}
/*
bool ScInsertLn( void )
Insert a the line under the cursor.
*/
bool
#if __STDC__
ScInsertLn( void )
#else
ScInsertLn()
#endif
{
if( ScAL == NULL )
return false;
tputs( ScAL, 1, PutChr );
return true;
}
/*
bool ScDeleteLn( void )
Delete the line under the cursor.
*/
bool
#if __STDC__
ScDeleteLn( void )
#else
ScDeleteLn()
#endif
{
if( ScDL == NULL )
return false;
tputs( ScDL, 1, PutChr );
return true;
}
/*
bool ScDnScroll( void )
Scroll backward 1 line.
*/
bool
#if __STDC__
ScDnScroll( void )
#else
ScDnScroll()
#endif
{
if( ScSR == NULL )
return false;
tputs( ScSR, 1, PutChr );
return true;
}
/*
bool ScHmCursor( void )
Move the cursor to the top-left corner of the screen.
*/
bool
#if __STDC__
ScHmCursor( void )
#else
ScHmCursor()
#endif
{
if( ScHO == NULL )
return false;
tputs( ScHO, 1, PutChr );
return true;
}
/*
bool ScMvCursor( int x, int y )
Move the cursor to screen coordinates x, y (for column and row,
respectively).
*/
bool
#if __STDC__
ScMvCursor( int x, int y )
#else
ScMvCursor( x, y )
int x, y;
#endif
{
if( ScCM == NULL )
return false;
--x; --y; /* Tgoto() adds 1 to each coordinate!? */
tputs( tgoto( ScCM, x, y ), 1, PutChr );
return true;
}
/*
bool ScSetScrlReg( int top, int btm )
Set the scrolling region to be from "top" line to "btm" line,
inclusive.
*/
bool
#if __STDC__
ScSetScrlReg( int top, int btm )
#else
ScSetScrlReg( top, btm )
int top, btm;
#endif
{
if( ScCS == NULL )
return false;
tputs( tgoto( ScCS, btm-1, top-1 ), 1, PutChr );
return true;
}
/*
bool ScSetStandout( void )
Begin standout mode.
*/
bool
#if __STDC__
ScSetStandout( void )
#else
ScSetStandout()
#endif
{
if( ScSO == NULL )
return false;
tputs( ScSO, 1, PutChr );
return true;
}
/*
bool ScUpScroll( void )
Scroll text forward 1 line.
*/
bool
#if __STDC__
ScUpScroll( void )
#else
ScUpScroll()
#endif
{
if( ScSF == NULL )
return false;
tputs( ScSF, 1, PutChr );
return true;
}
-174
View File
@@ -1,174 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
/**
<Sc.h> -- MUVES "Sc" (Screen manager) package definitions
**/
/**
The Sc package provides an interface to the termcap library
(termlib(3)) for doing cursor movement, character attribute,
and other low-level screen management operations. It is
intended for use in building terminal-independent full-screen
user interfaces. Do to its use of the tgoto() termlib(3)
routine, programs that use this package should turn off TAB3
in the terminal handler.
**/
#ifndef Sc_H_INCLUDE
#define Sc_H_INCLUDE
#include "./burst.h"
#include "./Tc.h"
/**
bool ScInit( FILE *fp )
ScInit() must be invoked before any other function in the Sc
package. Stream fp must be open for writing and all terminal
control sequences will be sent to fp, giving the application
the option of using STDOUT for other things. Besides setting
the output stream, ScInit() does the following:
Initializes the terminal.
Fills terminal name and capabilities into these externals:
char ScTermname[ScTERMSIZ] (terminal name from $TERM)
char ScTermcap[ScTCAPSIZ] (terminal capabilities entry)
Gets terminal control strings into external variables (here
are some that don't have individual functions to output them,
the ones that DO are below):
char *ScBC (backspace character)
char *ScPC (padding character)
char *ScUP (move the cursor up one line)
char *ScTI (initialize the terminal)
Gets individual terminal parameters into these externals:
int ScLI (number of lines on screen)
int ScCO (number of columns on screen)
Returns "true" for success, "false" for failure and prints
appropriate diagnostics on STDERR if $TERM is not set or
there is a problem in retrieving the corresponding termcap
entry.
**/
#if _STDC_
extern bool ScInit( FILE *fp );
#else
extern bool ScInit();
#endif
/**
Below are functions paired with terminal control strings that
they output to the stream specified with ScInit(). It is not
recommended that the control strings be used directly, but it
may be useful in certain applications to check their value;
if ScInit() has not been invoked or the corresponding terminal
capability does not exist, its control string will be NULL,
AND the function will return "false". Otherwise, they will
return "true" (assuming that it worked). There is no way to
be sure of this.
char *ScCE (clear from under the cursor to end of line)
bool ScClrEOL( void )
char *ScCS (change scrolling region)
bool ScClrScrlReg( void )
char *ScSE (end standout mode)
bool ScClrStandout( void )
char *ScCL (clear screen, and home cursor)
bool ScClrText( void )
char *ScAL (insert a line under the cursor)
bool ScInsertLn( void )
char *ScDL (delete the line under the cursor)
bool ScDeleteLn( void )
char *ScSR (scroll text backwards 1 line)
bool ScDnScroll( void )
char *ScHO (move cursor to top-left corner of screen)
bool ScHmCursor( void )
char *ScCM (move cursor to column and row <x,y>)
bool ScMvCursor( x, y )
char *ScCS (set scrolling region from top to btm incl.)
bool ScSetScrlReg( top, btm )
char *ScSO (begin standout mode)
bool ScSetStandout( void )
char *ScSF (scroll text forwards 1 line)
bool ScUpScroll( void )
**/
extern char *ScBC;
extern char *ScPC;
extern char *ScUP;
extern char *ScCS;
extern char *ScSO;
extern char *ScSE;
extern char *ScCE;
extern char *ScCL;
extern char *ScHO;
extern char *ScCM;
extern char *ScTI;
extern char *ScDL;
extern char *ScSR;
extern char *ScSF;
extern int ScLI;
extern int ScCO;
#if _STDC_
extern bool ScClrEOL( void );
extern bool ScClrScrlReg( void );
extern bool ScClrStandout( void );
extern bool ScClrText( void );
extern bool ScDeleteLn( void );
extern bool ScDnScroll( void );
extern bool ScHmCursor( void );
extern bool ScInsertLn( void );
extern bool ScMvCursor( int x, int y );
extern bool ScSetScrlReg( int top, int btm );
extern bool ScSetStandout( void );
extern bool ScUpScroll( void );
#else
extern bool ScClrEOL();
extern bool ScClrScrlReg();
extern bool ScClrStandout();
extern bool ScClrText();
extern bool ScDeleteLn();
extern bool ScDnScroll();
extern bool ScHmCursor();
extern bool ScInsertLn();
extern bool ScMvCursor();
extern bool ScSetScrlReg();
extern bool ScSetStandout();
extern bool ScUpScroll();
#endif
#define ScTCAPSIZ 1024
#define ScTERMSIZ 80
extern char ScTermcap[];
extern char ScTermname[];
#endif /* Sc_H_INCLUDE */
-397
View File
@@ -1,397 +0,0 @@
/*
XXX Outdated : should not be used
SCCS id: %Z% %M% %I%
Modified: %G% at %U%
Retrieved: %H% at %T%
SCCS archive: %P%
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#if 0
/*LINTLIBRARY*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
static char sccsTag[] = "%Z% %M% %I%, modified %G% at %U%, archive %P%";
#endif
#include <stdio.h>
#include <fcntl.h>
#ifdef SYSV
/**#ifndef TANDEM */
/* USG derivatives */
#include <termio.h>
#include <memory.h>
#ifndef _NFILE
#define _NFILE 32
#endif /* _NFILE */
static struct termio save_tio[_NFILE], curr_tio[_NFILE];
#endif /* SYSV */
#ifdef BSD
#include <sys/ioctl.h>
#ifdef HAVE_IOCTL_COMPAT_H
#include <sys/ioctl_compat.h>
#endif
#ifndef _NFILE
#define _NFILE 32
#endif /* _NFILE */
/****#ifdef TANDEM */
/* 7th Edition derivatives */
#define TCSETA TIOCSETP
#define TCGETA TIOCGETP
#ifndef XTABS
#define XTABS (TAB1 | TAB2)
#endif /* XTABS */
static struct sgttyb save_tio[_NFILE], curr_tio[_NFILE];
#endif /* BSD */
void TcSaveTty(), TcResetTty();
void TcSetCbreak(), TcClrCbreak();
void TcSetRaw(), TcClrRaw();
void TcSetEcho(), TcClrEcho();
void TcSetTabs(), TcClrTabs();
void TcSetHUPCL();
void TcClrCRNL();
void prnt_Tio();
static void copy_Tio();
/*
void TcClrCbreak( int fd )
Clear CBREAK mode, for file descriptor "fd".
*/
void
#if __STDC__
TcClrCbreak( int fd )
#else
TcClrCbreak( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags &= ~CBREAK; /* CBREAK mode OFF. */
#else
curr_tio[fd].c_lflag |= ICANON; /* Canonical input ON. */
#ifndef CRAY2
curr_tio[fd].c_cc[VEOF] = 4; /* defaults! */
curr_tio[fd].c_cc[VEOL] = 0; /* best we can do.... */
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcSetCbreak( int fd )
Set CBREAK mode, "fd".
*/
void
#if __STDC__
TcSetCbreak( int fd )
#else
TcSetCbreak( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags |= CBREAK; /* CBREAK mode ON. */
#else
curr_tio[fd].c_lflag &= ~ICANON; /* Canonical input OFF. */
#ifndef CRAY2
curr_tio[fd].c_cc[VMIN] = 1;
curr_tio[fd].c_cc[VTIME] = 0;
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcClrRaw( int fd )
Set cooked mode, "fd".
*/
void
clr_Raw( fd )
int fd;
{
#ifdef BSD
curr_tio[fd].sg_flags &= ~RAW; /* Raw mode OFF. */
#else
curr_tio[fd].c_lflag |= ICANON; /* Canonical input ON. */
#ifndef CRAY2
curr_tio[fd].c_lflag |= ISIG; /* Signals ON. */
curr_tio[fd].c_cc[VEOF] = 4; /* defaults! */
curr_tio[fd].c_cc[VEOL] = 0; /* best we can do.... */
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcSetRaw( int fd )
Set raw mode, "fd".
*/
void
#if __STDC__
TcSetRaw( int fd )
#else
TcSetRaw( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags |= RAW; /* Raw mode ON. */
#else
curr_tio[fd].c_lflag &= ~ICANON; /* Canonical input OFF. */
#ifndef CRAY2
curr_tio[fd].c_lflag &= ~ISIG; /* Signals OFF. */
curr_tio[fd].c_cc[VMIN] = 1;
curr_tio[fd].c_cc[VTIME] = 0;
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcSetEcho( int fd )
Set echo mode, "fd".
*/
void
#if __STDC__
TcSetEcho( int fd )
#else
TcSetEcho( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags |= ECHO; /* Echo mode ON. */
#else
curr_tio[fd].c_lflag |= ECHO; /* Echo mode ON. */
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcClrEcho( int fd )
Clear echo mode, "fd".
*/
void
#if __STDC__
TcClrEcho( int fd )
#else
TcClrEcho( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags &= ~ECHO; /* Echo mode OFF. */
#else
curr_tio[fd].c_lflag &= ~ECHO; /* Echo mode OFF. */
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcSetTabs( int fd )
Turn on tab expansion, "fd".
*/
void
#if __STDC__
TcSetTabs( int fd )
#else
TcSetTabs( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags |= XTABS; /* Tab expansion ON. */
#else
#ifndef CRAY2
curr_tio[fd].c_oflag |= TAB3; /* Tab expansion ON. */
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcClrTabs( int fd )
Turn off tab expansion, "fd".
*/
void
#if __STDC__
TcClrTabs( int fd )
#else
TcClrTabs( fd )
int fd;
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags &= ~XTABS; /* Tab expans. OFF. */
#else
#ifndef CRAY2
curr_tio[fd].c_oflag &= ~TAB3; /* Tab expans. OFF. */
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
return;
}
/*
void TcSetHUPCL( int fd )
Turn on "Hang up on last close", "fd".
*/
void
#if __STDC__
TcSetHUPCL( int fd )
#else
TcSetHUPCL( fd )
int fd;
#endif
{
#ifndef CRAY2
#ifdef BSD
(void) ioctl( fd, TIOCHPCL, NULL );
#else
curr_tio[fd].c_cflag |= HUPCL;
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
#endif
#endif
return;
}
/*
void TcClrCRNL( int fd )
Turn off CR/LF mapping, "fd".
*/
void
#if __STDC__
TcClrCRNL( int fd )
#else
TcClrCRNL( fd )
#endif
{
#ifdef BSD
curr_tio[fd].sg_flags &= ~CRMOD;
#else
#ifndef CRAY2
curr_tio[fd].c_oflag &= ~(ONLCR|OCRNL);
curr_tio[fd].c_iflag &= ~(ICRNL|INLCR);
#endif
#endif
(void) ioctl( fd, TCSETA, &curr_tio[fd] );
}
/*
void TcSaveTty( int fd )
Get and save terminal parameters, "fd".
*/
void
#if __STDC__
TcSaveTty( int fd )
#else
TcSaveTty( fd )
int fd;
#endif
{
(void) ioctl( fd, TCGETA, &save_tio[fd] );
copy_Tio( &curr_tio[fd], &save_tio[fd] );
return;
}
/*
void TcResetTty( int fd )
Set the terminal back to the mode that the user had last time
TcSaveTty() was called for "fd".
*/
void
#if __STDC__
TcResetTty( int fd )
#else
TcResetTty( fd )
int fd;
#endif
{
(void) ioctl( fd, TCSETA, &save_tio[fd] ); /* Write setting. */
return;
}
/* c o p y _ T i o ( ) */
static void
copy_Tio( to, from )
#ifdef BSD
struct sgttyb *to, *from;
#else
struct termio *to, *from;
#endif
{
#ifdef BSD
(void) bcopy( (char *)from, (char*)to, sizeof(struct sgttyb) );
#else
(void) memcpy( (char *) to, (char *) from, (int) sizeof(struct termio) );
#endif
return;
}
/* p r n t _ T i o ( ) */
void
prnt_Tio( msg, tio_ptr )
char *msg;
#ifdef BSD
struct sgttyb *tio_ptr;
#else
struct termio *tio_ptr;
#endif
{ register int i;
(void) fprintf( stderr, "%s :\n\r", msg );
#ifdef BSD
(void) fprintf( stderr, "\tsg_ispeed=%d\n\r", (int) tio_ptr->sg_ispeed );
(void) fprintf( stderr, "\tsg_ospeed=%d\n\r", (int) tio_ptr->sg_ospeed );
(void) fprintf( stderr, "\tsg_erase='%c'\n\r", tio_ptr->sg_erase );
(void) fprintf( stderr, "\tsg_kill='%c'\n\r", tio_ptr->sg_kill );
(void) fprintf( stderr, "\tsg_flags=0x%x\n\r", tio_ptr->sg_flags );
#else
(void) fprintf( stderr, "\tc_iflag=0x%x\n\r", tio_ptr->c_iflag );
(void) fprintf( stderr, "\tc_oflag=0x%x\n\r", tio_ptr->c_oflag );
(void) fprintf( stderr, "\tc_cflag=0x%x\n\r", tio_ptr->c_cflag );
(void) fprintf( stderr, "\tc_lflag=0x%x\n\r", tio_ptr->c_lflag );
(void) fprintf( stderr, "\tc_line=%c\n\r", tio_ptr->c_line );
for( i = 0; i < NCC; ++i )
{
(void) fprintf( stderr,
"\tc_cc[%d]=0%o\n\r",
i,
tio_ptr->c_cc[i]
);
}
#endif
return;
}
#endif
-114
View File
@@ -1,114 +0,0 @@
/*
SCCS id: %Z% %M% %I%
Modified: %G% at %U%
Retrieved: %H% at %T%
SCCS archive: %P%
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
/**
<Tc.h> -- MUVES "Tc" (terminal control) package definitions
Rewritten to use BRL-CAD's libtermio
**/
/**
The Tc package provides an interface to the terminal handler
for controlling I/O processing.
**/
#ifndef Tc_H_INCLUDE
#define Tc_H_INCLUDE
#if 0
/**
All of these functions take effect on the stream specified
by fd. Fd is assumed to be open. This enables the application
to control several terminal-style devices at once.
void TcSaveTty( int fd )
Saves the current terminal modes. This function should be
called once at the beginning of the program to save the user's
settings so that they can be restored via TcResetTty() when the
program exits, is suspended via job control, or for whatever
reason wishes to revert to the default terminal handler settings.
void TcResetTty( int fd ) restore the terminal modes
void TcClrCRNL( int fd ) turn off CR to NL mapping
void TcClrCbreak( int fd ) turn off cbreak mode
void TcClrEcho( int fd ) turn off echo mode
void TcClrRaw( int fd ) turn off raw mode
void TcClrTabs( int fd ) turn off tab expansion
void TcSetCbreak( int fd ) turn on cbreak mode
void TcSetEcho( int fd ) turn on echo mode
void TcSetHUPCL( int fd ) turn on "hang up on next close"
void TcSetRaw( int fd ) turn on raw mode
void TcSetTabs( int fd ) turn on tab expansion
**/
#if _STDC_
extern void TcClrCRNL( int fd );
extern void TcClrCbreak( int fd );
extern void TcClrEcho( int fd );
extern void TcClrRaw( int fd );
extern void TcClrTabs( int fd );
extern void TcResetTty( int fd );
extern void TcSaveTty( int fd );
extern void TcSetCbreak( int fd );
extern void TcSetEcho( int fd );
extern void TcSetHUPCL( int fd );
extern void TcSetRaw( int fd );
extern void TcSetTabs( int fd );
#else
extern void TcClrCRNL();
extern void TcClrCbreak();
extern void TcClrEcho();
extern void TcClrRaw();
extern void TcClrTabs();
extern void TcResetTty();
extern void TcSaveTty();
extern void TcSetCbreak();
extern void TcSetEcho();
extern void TcSetHUPCL();
extern void TcSetRaw();
extern void TcSetTabs();
#endif
#else
#define TcClrCRNL clr_CRNL
#define TcClrCbreak clr_Cbreak
#define TcClrEcho clr_Echo
#define TcClrRaw clr_Raw
#define TcClrTabs clr_Tabs
#define TcResetTty reset_Tty
#define TcSaveTty save_Tty
#define TcSetCbreak set_Cbreak
#define TcSetEcho set_Echo
#define TcSetHUPCL set_HUPCL
#define TcSetRaw set_Raw
#define TcSetTabs set_Tabs
#endif
#endif /* Tc_H_INCLUDE */
-35
View File
@@ -1,35 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$
*/
#define NUL '\000'
#define SOH '\001'
#define STX '\002'
#define INTR '\003'
#define EOT '\004'
#define ACK '\006'
#define BEL '\007'
#define BS '\010'
#define HT '\011'
#define LF '\012'
#define FF '\014'
#define CR '\015'
#define DLE '\020'
#define DC1 '\021'
#define DC2 '\022'
#define DC3 '\023'
#define DC4 '\024'
#define KILL '\025'
#define CAN '\030'
#define ESC '\033'
#define GS '\035'
#define RS '\036'
#define US '\037'
#define SP '\040'
#define DEL '\177'
#define Ctrl(chr) ((int)chr&037)
-267
View File
@@ -1,267 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#ifndef DEBUG
#define NDEBUG
#define STATIC static
#else
#define STATIC
#endif
#include <assert.h>
#include <stdio.h>
#include <signal.h>
#include "./burst.h"
#include "./trie.h"
#include "./ascii.h"
#include "./extern.h"
#define DEBUG_BURST 0 /* 1 enables debugging for this module */
/*
bool getCommand( char *name, char *buf, int len, FILE *fp )
Read next command line into buf and stuff the command name into name
from input stream fp. buf must be at least len bytes long.
RETURN: true for success
false for end of file
*/
STATIC bool
#if STD_C
getCommand( char *name, char *buf, int len, FILE *fp )
#else
getCommand( name, buf, len, fp )
char *name;
char *buf;
int len;
FILE *fp;
#endif
{
assert( name != NULL );
assert( buf != NULL );
assert( fp != NULL );
while( fgets( buf, len, fp ) != NULL )
{
if( buf[0] != CHAR_COMMENT )
{
if( sscanf( buf, "%s", name ) == 1 )
{
buf[strlen(buf)-1] = NUL; /* clobber newline */
return true;
}
else /* Skip over blank lines. */
continue;
}
else
{ /* Generate comment command. */
(void) strcpy( name, CMD_COMMENT );
return true;
}
}
return false; /* EOF */
}
/*
void setupSigs( void )
Initialize all signal handlers.
*/
STATIC void
#if STD_C
setupSigs( void )
#else
setupSigs()
#endif
{ register int i;
for( i = 0; i < NSIG; i++ )
switch( i )
{
case SIGINT :
if( (norml_sig = signal( i, SIG_IGN )) == SIG_IGN )
abort_sig = SIG_IGN;
else
{
norml_sig = intr_sig;
abort_sig = abort_RT;
(void) signal( i, norml_sig );
}
break;
#if defined( BSD )
case SIGCHLD :
#else
case SIGCLD :
#endif
break; /* leave SIGCLD alone */
case SIGPIPE :
(void) signal( i, SIG_IGN );
break;
case SIGQUIT :
break;
#if ! defined( SYSV )
#if ! defined( SIGTSTP )
#define SIGTSTP 18
#endif
case SIGTSTP :
break;
#endif
}
return;
}
/*
int parsArgv( int argc, char **argv )
Parse program command line.
*/
STATIC int
#if STD_C
parsArgv( int argc, char **argv )
#else
parsArgv( argc, argv )
int argc;
char **argv;
#endif
{ register int c;
extern int optind;
extern char *optarg;
/* Parse options. */
while( (c = getopt( argc, argv, "b" )) != EOF )
{
switch( c )
{
case 'b' :
tty = false;
break;
case '?' :
return 0;
}
}
return true;
}
/*
void readBatchInput( FILE *fp )
Read and execute commands from input stream fp.
*/
void
#if STD_C
readBatchInput( FILE *fp )
#else
readBatchInput( fp )
FILE *fp;
#endif
{
assert( fp != (FILE *) NULL );
batchmode = true;
while( getCommand( cmdname, cmdbuf, LNBUFSZ, fp ) )
{ Func *cmdfunc;
if( (cmdfunc = getTrie( cmdname, cmdtrie )) == NULL )
{ register int i, len = strlen( cmdname );
brst_log( "ERROR -- command syntax:\n" );
brst_log( "\t%s\n", cmdbuf );
brst_log( "\t" );
for( i = 0; i < len; i++ )
brst_log( " " );
brst_log( "^\n" );
}
else
if( strcmp( cmdname, CMD_COMMENT ) == 0 )
{ /* special handling for comments */
cmdptr = cmdbuf;
cmdbuf[strlen(cmdbuf)-1] = '\0'; /* clobber newline */
(*cmdfunc)( (HmItem *) 0 );
}
else
{ /* Advance pointer past nul at end of
command name. */
cmdptr = cmdbuf + strlen( cmdname ) + 1;
(*cmdfunc)( (HmItem *) 0 );
}
}
batchmode = false;
return;
}
/*
int main( int argc, char *argv[] )
*/
int
#if STD_C
main( int argc, char *argv[] )
#else
main( argc, argv )
int argc;
char *argv[];
#endif
{
#if ! defined( BSD ) && ! defined( sgi )
setvbuf( stderr, (char *) NULL, _IOLBF, BUFSIZ );
#endif
if( tmpnam( tmpfname ) == NULL
|| (tmpfp = fopen( tmpfname, "w" )) == (FILE *) NULL
)
{
perror( tmpfname );
(void) fprintf( stderr,
"Write access denied for file (%s).\n",
tmpfname );
goto death;
}
if( ! parsArgv( argc, argv ) )
{
prntUsage();
goto clean;
}
setupSigs();
if( ! initUi() ) /* must be called before any output is produced */
goto clean;
#if DEBUG_BURST
prntTrie( cmdtrie, 0 );
#endif
assert( airids.i_next == NULL );
assert( armorids.i_next == NULL );
assert( critids.i_next == NULL );
if( ! isatty( 0 ) || ! tty )
readBatchInput( stdin );
if( tty )
(void) HmHit( mainhmenu );
exitCleanly( EXIT_SUCCESS );
clean: (void) unlink( tmpfname );
death: return EXIT_FAILURE;
}
/*
void exitCleanly( int code )
Should be only exit from program after success of initUi().
*/
void
#if STD_C
exitCleanly( int code )
#else
exitCleanly( code )
int code;
#endif
{
if( tty )
closeUi(); /* keep screen straight */
(void) fclose( tmpfp );
if( unlink( tmpfname ) == -1 )
locPerror( tmpfname );
exit( code );
}
-84
View File
@@ -1,84 +0,0 @@
Shotline file output format from burst program:
record type: 1
description: header line for each aspect
ICD reference: Line Number 1, Figure 19.
format: '1',1x,f9.4,1x,f8.4,5(1x,f7.2),1x,6a
data: attack azimuth in degrees
attack elevation in degrees
shotline separation
maximum Y'-coordinate of target
minimum Y'-coordinate of target
maximum Z'-coordinate of target
minimum Z'-coordinate of target
units (mm,cm,inches,feet,meters)
record type: 2
description: information about shotline
format: '2',2(1x,f8.3)
data: horizontal coordinate of shotline in grid plane (Y')
vertical coordinate of shotline in grid plane (Z')
record type: 3
description: information about component intersected by shotline
format: '3',1x,f8.2,1x,f7.3,1x,f7.2,1x,i4,2(1x,f8.2),1x,i2,2(1x,f7.2)
data: X'-coordinate of intersection with component
sine of fallback angle of component exit normal
rotation angle in degrees of exit normal
component code number
normal thickness of component
line-of-sight thickness of component
space code following component
obliquity angle at entry to component in degrees
obliquity angle at exit from component in degrees
Burst Point Library output format from burst program:
record type: 1
description: header line for each aspect
ICD reference: Line Number 1, Figure 20.
format: '1',1x,f9.4,1x,f8.4,1x,f5.2,1x,f10.2,1x,6a,1x,f9.6
data: attack azimuth in degrees
attack elevation in degrees
burst distance
projected area associated with burst point
units (mm,cm,inches,feet,meters)
solid angle of each ray in steradians
record type: 2
description: information about shotline
ICD reference: Line Number 2, Figure 20.
format: '2',2(1x,f8.3) [format of record type '4' compatible]
data: horizontal coordinate of shotline in grid plane (Y')
vertical coordinate of shotline in grid plane (Z')
record type: 3
description: information about component intersected by shotline
ICD reference: Line Number 3, Figure 20.
format: '3',2(1x,f8.2),1x,i4,1x,i2,1x,f7.3,1x,f7.2,1x,f7.3
data: X'-coordinate of intersection with component
line-of-sight thickness of component
component code number
space code
sine of fallback angle of component exit normal
rotation angle in degrees of component exit normal
cosine of obliquity angle at entry to component
record type: 4
description: information about burst ray
ICD reference: Line Number 19, Figure 20.
format: '4',2(1x,f8.3),1x,i6 [format of record type '2' compatible]
data: ray azimuth angle WRT shotline in radians
sine of ray elevation angle WRT shotline
sequential ray number for this burst point
record type: 5
description: information about component intersected by burst ray
ICD reference: Line Number 20, Figure 20.
format: '5',1x,f10.3,2(1x,f9.3),2(1x,i4),1x,f6.3
data: distance to first contact with component from burst point
line-of-sight thickness of component
normal thickness of component
space code
component code number
cosine of obliquity angle at entry
-247
View File
@@ -1,247 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
#ifndef INCL_BURST
#define INCL_BURST
/* NSIG not always defined in <signal.h> */
#ifndef NSIG
#define NSIG 64
#endif
/* Some useful stuff from Doug Gwyn's std.h. */
/* Extended data types */
typedef int bool; /* Boolean data */
#define false 0
#define true 1
/* ANSI C definitions */
/* Defense against some silly systems defining __STDC__ to random things. */
#ifdef STD_C
#undef STD_C
#endif
#ifdef __STDC__
#if __STDC__ > 0
#define STD_C __STDC__ /* use this instead of __STDC__ */
#endif
#endif
#if STD_C
typedef void *pointer; /* generic pointer */
#else
typedef char *pointer; /* generic pointer */
#define const /* nothing */ /* ANSI C type qualifier */
/* There really is no substitute for the following, but these might work: */
#define signed /* nothing */ /* ANSI C type specifier */
#define volatile /* nothing */ /* ANSI C type qualifier */
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#define DEGRAD 57.2957795130823208767981548141051703324054724665642
/* allow for SGI screw-up, the single-precision math libraries */
#if defined( sgi ) && ! defined( mips )
#define SINGLE_PRECISION 1
#else
#define SINGLE_PRECISION 0
#endif
/* allow for SGI screw-up, winclose() dumps core on some systems */
#if defined(SGI4D_Rel2)
#define SGI_WINCLOSE_BUG 1
#else
#define SGI_WINCLOSE_BUG 0
#endif
/* allow for BSD screw-up, declaring signal handlers as 'int' functions */
#if STD_C || (defined(SYSV) && ! defined(cray))
#define STD_SIGNAL_DECLS 1
#else
#define STD_SIGNAL_DECLS 0
#endif
/* menu configuration */
#define MENU_LFT 1
#define MENU_TOP 2
#define MENU_MAXVISITEMS 10
/* prompt line configuration */
#define PROMPT_X HmXPROMPT
#define PROMPT_Y HmYPROMPT
/* banner (border) configuration */
#define BORDER_CHR '_'
#define BORDER_Y (PROMPT_Y+1)
/* grid offset printing window */
#define GRID_X 55 /* where grid indices are printed */
#define GRID_Y BORDER_Y
/* scroll region configuration */
#define SCROLL_TOP (BORDER_Y+1)
#define SCROLL_BTM (ScLI-1) /* bottom line causes scroll */
/* timer (cpu statistics) window configuration */
#define TIMER_X 1
#define TIMER_Y 1
/* buffer sizes */
#define LNBUFSZ 133 /* buffer for one-line messages */
#define MAXDEVWID 1024 /* maximum width of frame buffer */
#define CHAR_COMMENT '#'
#define CMD_COMMENT "comment"
/* default parameters */
#define DFL_AZIMUTH 0.0
#define DFL_BARRIERS 100
#define DFL_BDIST 0.0
#define DFL_CELLSIZE 101.6
#define DFL_CONEANGLE (45.0/DEGRAD)
#define DFL_DEFLECT false
#define DFL_DITHER false
#define DFL_ELEVATION 0.0
#define DFL_NRAYS 200
#define DFL_OVERLAPS true
#define DFL_RIPLEVELS 1
#define DFL_UNITS U_MILLIMETERS
/* firing mode bit definitions */
#define ASNBIT(w,b) (w = (b))
#define SETBIT(w,b) (w |= (b))
#define CLRBIT(w,b) (w &= ~(b))
#define TSTBIT(w,b) ((w)&(b))
#define FM_GRID 0 /* generate grid of shotlines */
#define FM_DFLT FM_GRID
#define FM_PART (1) /* bit 0: ON = partial envelope, OFF = full */
#define FM_SHOT (1<<1) /* bit 1: ON = discrete shots, OFF = gridding */
#define FM_FILE (1<<2) /* bit 2: ON = file input, OFF = direct input */
#define FM_3DIM (1<<3) /* bit 3: ON = 3-D coords., OFF = 2-D coords */
#define FM_BURST (1<<4) /* bit 4: ON = discrete burst points, OFF = shots */
/* flags for notify() */
#define NOTIFY_APPEND 1
#define NOTIFY_DELETE 2
#define NOTIFY_ERASE 4
#define NOTIFY_DELIM ':'
#define PB_ASPECT_INIT '1'
#define PB_CELL_IDENT '2'
#define PB_RAY_INTERSECT '3'
#define PB_RAY_HEADER '4'
#define PB_REGION_HEADER '5'
#define PS_ASPECT_INIT '1'
#define PS_CELL_IDENT '2'
#define PS_SHOT_INTERSECT '3'
#define TITLE_LEN 72
#define TIMER_LEN 72
#define U_INCHES 0
#define U_FEET 1
#define U_MILLIMETERS 2
#define U_CENTIMETERS 3
#define U_METERS 4
#define U_BAD -1
#define UNITS_INCHES "inches"
#define UNITS_FEET "feet"
#define UNITS_MILLIMETERS "millimeters"
#define UNITS_CENTIMETERS "centimeters"
#define UNITS_METERS "meters"
/* white space in input tokens */
#define WHITESPACE " \t"
/* colors for UNIX plot files */
#define R_GRID 255 /* grid - yellow */
#define G_GRID 255
#define B_GRID 0
#define R_BURST 255 /* burst cone - red */
#define G_BURST 0
#define B_BURST 0
#define R_OUTAIR 100 /* outside air - light blue */
#define G_OUTAIR 100
#define B_OUTAIR 255
#define R_INAIR 100 /* inside air - light green */
#define G_INAIR 255
#define B_INAIR 100
#define R_COMP 0 /* component (default) - blue */
#define G_COMP 0
#define B_COMP 255
#define R_CRIT 255 /* critical component (default) - purple */
#define G_CRIT 0
#define B_CRIT 255
#define C_MAIN 0
#define C_CRIT 1
#define TWO_PI 6.28318530717958647692528676655900576839433879875022
#define COS_TOL 0.01
#define LOS_TOL 0.1
#define VEC_TOL 0.001
#define OVERLAP_TOL 0.25 /* thinner overlaps not reported */
#define EXIT_AIR 9 /* exit air is called 09 air */
#define OUTSIDE_AIR 1 /* outside air is called 01 air */
#define Air(rp) ((rp)->reg_aircode > 0)
#define DiffAir(rp,sp) ((rp)->reg_aircode != (sp)->reg_aircode)
#define SameAir(rp,sp) ((rp)->reg_aircode == (sp)->reg_aircode)
#define SameCmp(rp,sp) ((rp)->reg_regionid == (sp)->reg_regionid)
#define OutsideAir(rp) ((rp)->reg_aircode == OUTSIDE_AIR)
#define InsideAir(rp) (Air(rp)&& !OutsideAir(rp))
#define Malloc_Bomb( _bytes_ ) \
brst_log( "\"%s\"(%d) : allocation of %d bytes failed.\n",\
__FILE__, __LINE__, _bytes_ )
#define Swap_Doubles( a_, b_ ) \
{ fastf_t f_ = a_; \
a_ = b_; \
b_ = f_; \
}
#define Toggle(f) (f) = !(f)
typedef struct ids Ids;
struct ids
{
short i_lower;
short i_upper;
Ids *i_next;
};
#define IDS_NULL (Ids *) 0
typedef struct colors Colors;
struct colors
{
short c_lower;
short c_upper;
unsigned char c_rgb[3];
Colors *c_next;
};
#define COLORS_NULL (Colors *) 0
typedef struct pt_queue Pt_Queue;
struct pt_queue
{
struct partition *q_part;
Pt_Queue *q_next;
};
#define PT_Q_NULL (Pt_Queue *) 0
#endif /* INCL_BURST */
-138
View File
@@ -1,138 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
/*
* E R R O R
*
* Ray Tracing library and Framebuffer library, error handling routines.
*
* Functions -
* rt_bomb Called upon fatal RT library error.
* brst_log Called to log RT library events.
* fb_log Called to log FB library events.
*
* Idea originated by Mike John Muuss
*/
#include <stdio.h>
#include "./Sc.h"
#include "./extern.h"
/*
* R T _ B O M B
*
* Abort the RT library
*/
void
rt_bomb(str)
char *str;
{
brst_log( "%s (librt.a) : Fatal error, aborting!\n", str );
(void) fflush( stdout );
(void) abort(); /* Should dump. */
/* exit(12); XXX - this shouldn't be needed */
}
/*
* B R S T _ L O G
*
* Log an RT library event
*/
/* VARARGS */
void
#if defined(HAVE_STDARG_H)
brst_log( char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
#else
brst_log( va_alist )
va_dcl
{
register char *fmt; /* picked up by va_arg() */
va_list ap;
va_start( ap );
fmt = va_arg( ap, char * );
#endif
if( tty && (errfile[0] == '\0' || ! strcmp( errfile, "/dev/tty" )) )
{
TcClrTabs( HmTtyFd );
if( ScDL != NULL )
{
(void) ScMvCursor( 1, SCROLL_TOP );
(void) ScDeleteLn();
(void) ScMvCursor( 1, SCROLL_BTM );
(void) ScClrEOL();
(void) vprintf( fmt, ap );
}
else
if( ScSetScrlReg( SCROLL_TOP, SCROLL_BTM+1 ) )
{ char buf[LNBUFSZ];
char *p;
(void) ScMvCursor( 1, SCROLL_BTM+1 );
(void) ScClrEOL();
/* Work around for problem with vprintf(): it doesn't
cause the screen to scroll, don't know why. */
(void) vsprintf( buf, fmt, ap );
/* Newline will cause double scroll. */
p = buf+strlen(buf)-1;
if( *p == '\n' )
*p = '\0'; /* clobber newline */
(void) puts( buf );
/*(void) vprintf( fmt, ap );*/
(void) ScMvCursor( 1, SCROLL_BTM+1 );
(void) ScClrScrlReg();
}
else
{
(void) fprintf( stderr,
"%s %s %s %s!\n",
"This terminal has no delete line",
"or scrolling region capability,",
"please dump it somewhere and get",
"a real terminal"
);
exit( 1 );
}
(void) fflush( stdout );
}
else
{
(void) vfprintf( stderr, fmt, ap );
}
va_end( ap );
}
/*
* F B _ L O G
*
* Log an FB library event
*/
/*VARARGS*/
void
#if __STDC__
fb_log(char *fmt, ...)
#else
fb_log( va_alist )
va_dcl
#endif
{
#if ! __STDC__
register char *fmt;
#endif
va_list ap;
#if __STDC__
va_start( ap, fmt );
#else
va_start( ap );
fmt = va_arg( ap, char * );
#endif
(void) brst_log( fmt, ap );
va_end( ap );
}
-233
View File
@@ -1,233 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
#include "conf.h"
#if defined(HAVE_STDARG_H)
# include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <string.h>
#include "machine.h"
#include "fb.h"
#include "./burst.h"
#include "./trie.h"
#include "./Hm.h"
/* External functions from C library. */
#if (__STDC__ && ! apollo) || (sgi && mips && BRLCAD4_0)
#include <stdlib.h>
extern pointer sbrk( int );
#else
extern char *fgets();
extern char *getenv();
extern char *malloc();
extern char *tmpnam();
extern pointer sbrk();
#endif
#ifdef SYSV
extern long lrand48();
#else
#if !defined(linux)
extern long random();
#endif
#endif
/* External variables from termlib. */
extern char *CS, *DL;
extern int CO, LI;
/* External functions from application. */
extern Colors *findColors();
extern Func *getTrie();
extern Trie *addTrie();
extern bool chkEntryNorm();
extern bool chkExitNorm();
extern bool closFbDevice();
extern bool imageInit();
extern bool initUi();
extern bool openFbDevice();
extern bool findIdents();
extern bool readColors();
extern bool readIdents();
extern int notify();
extern int round();
extern void closeUi();
extern void colorPartition();
extern void exitCleanly();
extern void freeIdents();
extern void getRtHitNorm();
extern void gridInit();
extern void gridModel();
extern void gridToFb();
extern void locPerror();
extern void logCmd();
extern void paintCellFb();
extern void paintGridFb();
extern void paintSpallFb();
extern void plotGrid();
extern void plotInit();
extern void plotPartition();
extern void plotRay();
extern void prntAspectInit();
extern void prntBurstHdr();
extern void prntCellIdent();
extern void prntDbgPartitions();
extern void prntFiringCoords();
extern void prntFusingComp();
extern void prntGridOffsets();
extern void prntIdents();
extern void prntPhantom();
extern void prntRayHeader();
extern void prntRayIntersect();
extern void prntTimer();
extern void prompt();
extern void readCmdFile();
#if defined(HAVE_STDARG_H)
extern void prntScr( char *, ...);
extern void brst_log( char *, ... );
#else
extern void brst_log();
extern void prntScr();
#endif
extern void warning();
#if STD_SIGNAL_DECLS
extern void (*norml_sig)(), (*abort_sig)();
extern void abort_RT();
extern void intr_sig();
#else
extern int (*norml_sig)(), (*abort_sig)();
extern int abort_RT();
extern int intr_sig();
#endif
extern Colors colorids;
extern FBIO *fbiop;
extern FILE *burstfp;
extern FILE *gridfp;
extern FILE *histfp;
extern FILE *outfp;
extern FILE *plotfp;
extern FILE *shotfp;
extern FILE *shotlnfp;
extern FILE *tmpfp;
extern HmMenu *mainhmenu;
extern Ids airids;
extern Ids armorids;
extern Ids critids;
extern unsigned char *pixgrid;
extern unsigned char pixaxis[3];
extern unsigned char pixbkgr[3];
extern unsigned char pixbhit[3];
extern unsigned char pixblack[3];
extern unsigned char pixcrit[3];
extern unsigned char pixghit[3];
extern unsigned char pixmiss[3];
extern unsigned char pixtarg[3];
extern Trie *cmdtrie;
extern bool batchmode;
extern bool cantwarhead;
extern bool deflectcone;
extern bool dithercells;
extern bool fatalerror;
extern bool groundburst;
extern bool reportoverlaps;
extern bool reqburstair;
extern bool shotburst;
extern bool tty;
extern bool userinterrupt;
extern char airfile[];
extern char armorfile[];
extern char burstfile[];
extern char cmdbuf[];
extern char cmdname[];
extern char colorfile[];
extern char critfile[];
extern char errfile[];
extern char fbfile[];
extern char gedfile[];
extern char gridfile[];
extern char histfile[];
extern char objects[];
extern char outfile[];
extern char plotfile[];
extern char scrbuf[];
extern char scriptfile[];
extern char shotfile[];
extern char shotlnfile[];
extern char title[];
extern char timer[];
extern char tmpfname[];
extern char *cmdptr;
extern char **template;
extern fastf_t bdist;
extern fastf_t burstpoint[];
extern fastf_t cellsz;
extern fastf_t conehfangle;
extern fastf_t fire[];
extern fastf_t griddn;
extern fastf_t gridlf;
extern fastf_t gridrt;
extern fastf_t gridup;
extern fastf_t gridhor[];
extern fastf_t gridsoff[];
extern fastf_t gridver[];
extern fastf_t grndbk;
extern fastf_t grndht;
extern fastf_t grndfr;
extern fastf_t grndlf;
extern fastf_t grndrt;
extern fastf_t modlcntr[];
extern fastf_t modldn;
extern fastf_t modllf;
extern fastf_t modlrt;
extern fastf_t modlup;
extern fastf_t pitch;
extern fastf_t raysolidangle;
extern fastf_t standoff;
extern fastf_t unitconv;
extern fastf_t viewazim;
extern fastf_t viewelev;
extern fastf_t viewsize;
extern fastf_t yaw;
extern fastf_t xaxis[];
extern fastf_t zaxis[];
extern fastf_t negzaxis[];
extern int co;
extern int devhgt;
extern int devwid;
extern int firemode;
extern int gridsz;
extern int gridxfin;
extern int gridyfin;
extern int gridxorg;
extern int gridyorg;
extern int gridheight;
extern int gridwidth;
extern int li;
extern int nbarriers;
extern int noverlaps;
extern int nprocessors;
extern int nriplevels;
extern int nspallrays;
extern int units;
extern int zoom;
extern struct rt_i *rtip;
-135
View File
@@ -1,135 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include "fb.h"
#include "./burst.h"
#include "./ascii.h"
#include "./extern.h"
bool
imageInit()
{ bool needopen = false;
static char lastfbfile[LNBUFSZ]={0}; /* last fbfile */
devwid = 512;
devhgt = 512;
if( fbfile[0] == NUL )
return true;
zoom = devwid / gridsz - 1;
while( zoom < 3 && devwid < MAXDEVWID )
{
devwid *= 2;
devhgt *= 2;
zoom = devwid / gridsz;
}
if( zoom * gridsz == devwid )
zoom--;
if( zoom < 1 )
zoom = 1;
/* Determine whether it is necessary to open fbfile. */
if( fbiop == FBIO_NULL || fb_getwidth( fbiop ) != devwid )
needopen = true; /* not currently open or size changed */
else
if( lastfbfile[0] != NUL && strcmp( fbfile, lastfbfile ) != 0 )
needopen = true; /* name changed */
(void) strcpy( lastfbfile, fbfile );
if( needopen )
{
if( ! openFbDevice( fbfile ) )
return false;
paintGridFb();
}
else
if( !(firemode & FM_SHOT) || (firemode & FM_FILE) )
paintGridFb();
return true;
}
/* openFbDevice( char *devname )
Must be called after gridInit() so that gridsz is setup.
*/
bool
openFbDevice( devname )
char *devname;
{ bool ret = true;
notify( "Opening frame buffer", NOTIFY_APPEND );
if( zoom < 1 )
{
prntScr( "Device is too small to display image." );
ret = false;
goto safe_exit;
}
if( ( (fbiop != FBIO_NULL && fb_getwidth( fbiop ) != devwid)
|| pixgrid == NULL)
&& (pixgrid = (unsigned char *) calloc( devwid*3, sizeof(unsigned char) ))
== (unsigned char *) NULL )
{
prntScr( "Memory allocation of %d bytes failed.",
sizeof(unsigned char)*devwid );
ret = false;
goto safe_exit;
}
(void) memset( (char *) pixgrid, NUL, sizeof(unsigned char)*devwid*3 );
if( fbiop != FBIO_NULL )
{
#if SGI_WINCLOSE_BUG
if( strncmp( fbiop->if_name, "/dev/sgi", 8 ) == 0 )
{
prntScr( "IRIS can't change window size." );
ret = false;
goto safe_exit;
}
else
#endif
if( ! closFbDevice() )
{
ret = false;
goto safe_exit;
}
}
if( (fbiop = fb_open( devname, devwid, devhgt )) == NULL )
{
ret = false;
goto safe_exit;
}
else
if( fb_clear( fbiop, pixblack ) == -1
|| notify( "Zooming", NOTIFY_APPEND ),
fb_zoom( fbiop, 1, 1 ) == -1
|| notify( "Windowing", NOTIFY_DELETE ),
fb_window( fbiop, devwid/2, devhgt/2 ) == -1
)
{
ret = false;
goto safe_exit;
}
safe_exit : notify( NULL, NOTIFY_DELETE );
return ret;
}
bool
closFbDevice()
{ int ret;
notify( "Closing frame buffer", NOTIFY_APPEND );
if( fb_close( fbiop ) == -1 )
ret = false;
else
{
ret = true;
fbiop = FBIO_NULL;
}
notify( NULL, NOTIFY_DELETE );
return ret;
}
-159
View File
@@ -1,159 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
#include "machine.h"
#include "vmath.h"
#include "fb.h"
#include "raytrace.h"
#include "./burst.h"
#include "./extern.h"
Colors colorids; /* ident range to color mappings for plots */
FBIO *fbiop = NULL; /* frame buffer specific access from libfb */
FILE *burstfp = NULL; /* input stream for burst point locations */
FILE *gridfp = NULL; /* grid file output stream (2-d shots) */
FILE *histfp = NULL; /* histogram output stream (statistics) */
FILE *outfp = NULL; /* burst point library output stream */
FILE *plotfp = NULL; /* 3-D UNIX plot stream (debugging) */
FILE *shotfp = NULL; /* input stream for shot positions */
FILE *shotlnfp = NULL; /* shotline file output stream */
FILE *tmpfp = NULL; /* temporary file output stream for logging input */
HmMenu *mainhmenu;
Ids airids; /* burst air idents */
Ids armorids; /* burst armor idents */
Ids critids; /* critical component idents */
unsigned char *pixgrid;
unsigned char pixaxis[3] = { 255, 0, 0 }; /* grid axis */
unsigned char pixbhit[3] = { 200, 255, 200 }; /* burst ray hit non-critical comps */
unsigned char pixbkgr[3] = { 150, 100, 255 }; /* outside grid */
unsigned char pixblack[3] = { 0, 0, 0 }; /* black */
unsigned char pixcrit[3] = { 255, 200, 200 }; /* burst ray hit critical component */
unsigned char pixghit[3] = { 255, 0, 255 }; /* ground burst */
unsigned char pixmiss[3] = { 200, 200, 200 }; /* shot missed target */
unsigned char pixtarg[3] = { 255, 255, 255 }; /* shot hit target */
Trie *cmdtrie = NULL;
bool batchmode = false; /* are we processing batch input now */
bool cantwarhead = false; /* pitch or yaw will be applied to warhead */
bool deflectcone = DFL_DEFLECT; /* cone axis deflects towards normal */
bool dithercells = DFL_DITHER; /* if true, randomize shot within cell */
bool fatalerror; /* must abort ray tracing */
bool groundburst = false; /* if true, burst on imaginary ground */
bool reportoverlaps = DFL_OVERLAPS;
/* if true, overlaps are reported */
bool reqburstair = true; /* if true, burst air required for shotburst */
bool shotburst = false; /* if true, burst along shotline */
bool tty = true; /* if true, full screen display is used */
bool userinterrupt; /* has the ray trace been interrupted */
char airfile[LNBUFSZ]={0}; /* input file name for burst air ids */
char armorfile[LNBUFSZ]={0}; /* input file name for burst armor ids */
char burstfile[LNBUFSZ]={0}; /* input file name for burst points */
char cmdbuf[LNBUFSZ];
char cmdname[LNBUFSZ];
char colorfile[LNBUFSZ]={0}; /* ident range-to-color file name */
char critfile[LNBUFSZ]={0}; /* input file for critical components */
char errfile[LNBUFSZ]={0}; /* errors/diagnostics log file name */
char fbfile[LNBUFSZ]={0}; /* frame buffer image file name */
char gedfile[LNBUFSZ]={0}; /* MGED data base file name */
char gridfile[LNBUFSZ]={0}; /* saved grid (2-d shots) file name */
char histfile[LNBUFSZ]={0}; /* histogram file name (statistics) */
char objects[LNBUFSZ]={0}; /* list of objects from MGED file */
char outfile[LNBUFSZ]={0}; /* burst point library output file name */
char plotfile[LNBUFSZ]={0}; /* 3-D UNIX plot file name (debugging) */
char scrbuf[LNBUFSZ]; /* scratch buffer for temporary use */
char scriptfile[LNBUFSZ]={0}; /* shell script file name */
char shotfile[LNBUFSZ]; /* input file of firing coordinates */
char shotlnfile[LNBUFSZ]={0}; /* shotline output file name */
char title[TITLE_LEN]; /* title of MGED target description */
char timer[TIMER_LEN]; /* CPU usage statistics */
char tmpfname[TIMER_LEN]; /* temporary file for logging input */
char *cmdptr;
fastf_t bdist = DFL_BDIST;
/* fusing distance for warhead */
fastf_t burstpoint[3]; /* explicit burst point coordinates */
fastf_t cellsz = DFL_CELLSIZE;
/* shotline separation */
fastf_t conehfangle = DFL_CONEANGLE;
/* spall cone half angle */
fastf_t fire[3]; /* explicit firing coordinates (2-D or 3-D) */
fastf_t griddn; /* distance in model coordinates from origin to
bottom border of grid */
fastf_t gridlf; /* distance to left border */
fastf_t gridrt; /* distance to right border */
fastf_t gridup; /* distance to top border */
fastf_t gridhor[3]; /* horizontal grid direction cosines */
fastf_t gridsoff[3]; /* origin of grid translated by stand-off */
fastf_t gridver[3]; /* vertical grid direction cosines */
fastf_t grndbk = 0.0; /* distance to back border of ground plane (-X) */
fastf_t grndht = 0.0; /* distance of ground plane below target origin (-Z) */
fastf_t grndfr = 0.0; /* distance to front border of ground plane (+X) */
fastf_t grndlf = 0.0; /* distance to left border of ground plane (+Y) */
fastf_t grndrt = 0.0; /* distance to right border of ground plane (-Y) */
fastf_t modlcntr[3]; /* centroid of target's bounding RPP */
fastf_t modldn = 0.0; /* distance in model coordinates from origin to bottom
extent of projection of model in grid plane */
fastf_t modllf = 0.0; /* distance to left extent */
fastf_t modlrt = 0.0; /* distance to right extent */
fastf_t modlup = 0.0; /* distance to top extent */
fastf_t raysolidangle; /* solid angle per spall sampling ray */
fastf_t standoff; /* distance from model origin to grid */
fastf_t unitconv = 1.0; /* units conversion factor (mm to "units") */
fastf_t viewazim = DFL_AZIMUTH;
/* degrees from X-axis to firing position */
fastf_t viewelev = DFL_ELEVATION;
/* degrees from XY-plane to firing position */
/* These are the angles and fusing distance used to specify the path of
the canted warhead in Bob Wilson's simulation.
*/
fastf_t pitch = 0.0; /* elevation above path of main penetrator */
fastf_t yaw = 0.0; /* deviation right of path of main penetrator */
/* useful vectors */
fastf_t xaxis[3] = { 1.0, 0.0, 0.0 };
fastf_t zaxis[3] = { 0.0, 0.0, 1.0 };
fastf_t negzaxis[3] = { 0.0, 0.0, -1.0 };
int co; /* columns of text displayable on video screen */
int devwid; /* width in pixels of frame buffer window */
int devhgt; /* height in pixels of frame buffer window */
int firemode = FM_DFLT; /* mode of specifying shots */
int gridsz = 512;
int gridxfin;
int gridyfin;
int gridxorg;
int gridyorg;
int gridwidth; /* Grid width in cells. */
int gridheight; /* Grid height in cells. */
int li; /* lines of text displayable on video screen */
int nbarriers = DFL_BARRIERS;
/* no. of barriers allowed to critical comp */
int noverlaps = 0; /* no. of overlaps encountered in this view */
int nprocessors; /* no. of processors running concurrently */
int nriplevels = DFL_RIPLEVELS;
/* no. of levels of ripping (0 = no ripping) */
int nspallrays = DFL_NRAYS;
/* no. of spall rays at each burst point */
int units = DFL_UNITS; /* target units (default is millimeters) */
int zoom = 1; /* magnification factor on frame buffer */
struct rt_i *rtip = RTI_NULL; /* model specific access from librt */
/* signal handlers */
#if STD_SIGNAL_DECLS
void (*norml_sig)(); /* active during interactive operation */
void (*abort_sig)(); /* active during ray tracing only */
#else
int (*norml_sig)();
int (*abort_sig)();
#endif
-1835
View File
File diff suppressed because it is too large Load Diff
-60
View File
@@ -1,60 +0,0 @@
/*
Author: Jeff Hanes
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
Modified: Gary S. Moss (Added roll rotation.)
*/
#ifndef lint
static char RCSid[] = "$Header$ (BRL)";
#endif
#include <math.h>
#include "machine.h"
#include "./vecmath.h"
void gridRotate();
/*
void gridRotate( fastf_t azim, fastf_t elev, fastf_t roll,
register fastf_t *des_H, register fastf_t *des_V )
Creates the unit vectors H and V which are the horizontal
and vertical components of the grid in target coordinates.
The vectors are found from the azimuth and elivation of the
viewing angle according to a simplification of the rotation
matrix from grid coordinates to target coordinates.
To see that the vectors are, indeed, unit vectors, recall
the trigonometric relation:
sin( A )^2 + cos( A )^2 = 1 .
*/
void
gridRotate( azim, elev, roll, des_H, des_V )
fastf_t azim, elev, roll;
register fastf_t *des_H, *des_V;
{ fastf_t sn_azm = sin( azim );
fastf_t cs_azm = cos( azim );
fastf_t sn_elv = sin( elev );
des_H[0] = -sn_azm;
des_H[1] = cs_azm;
des_H[2] = 0.0;
des_V[0] = -sn_elv*cs_azm;
des_V[1] = -sn_elv*sn_azm;
des_V[2] = cos( elev );
if( roll != 0.0 )
{ fastf_t tmp_V[3], tmp_H[3], prime_V[3];
fastf_t sn_roll = sin( roll );
fastf_t cs_roll = cos( roll );
Scale2Vec( des_V, cs_roll, tmp_V );
Scale2Vec( des_H, sn_roll, tmp_H );
Add2Vec( tmp_V, tmp_H, prime_V );
Scale2Vec( des_V, -sn_roll, tmp_V );
Scale2Vec( des_H, cs_roll, tmp_H );
Add2Vec( tmp_V, tmp_H, des_H );
CopyVec( des_V, prime_V );
}
return;
}
-152
View File
@@ -1,152 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#ifndef DEBUG
#define NDEBUG
#define STATIC static
#else
#define STATIC
#endif
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "./burst.h"
#include "./vecmath.h"
#define DEBUG_IDENTS false
bool
findIdents( ident, idp )
int ident;
register Ids *idp;
{
#if DEBUG_IDENTS
brst_log( "findIdents(%d)\n", ident );
#endif
for( idp = idp->i_next ; idp != IDS_NULL; idp = idp->i_next )
{
#if DEBUG_IDENTS
brst_log( "lower=%d, upper=%d\n", (int) idp->i_lower,
(int) idp->i_upper );
#endif
if( ident >= (int) idp->i_lower
&& ident <= (int) idp->i_upper
)
return true;
}
#if DEBUG_IDENTS
brst_log( "returned false\n" );
#endif
return false;
}
Colors *
findColors( ident, colp )
int ident;
register Colors *colp;
{
for( colp = colp->c_next; colp != COLORS_NULL; colp = colp->c_next )
{
if( ident >= (int) colp->c_lower
&& ident <= (int) colp->c_upper
)
return colp;
}
return COLORS_NULL;
}
/*
void freeIdents( register Ids *idp )
Free up linked list, except for the head node.
*/
STATIC void
freeIdents( idp )
register Ids *idp;
{
if( idp->i_next == NULL )
return; /* finished */
freeIdents( idp->i_next );
free( (char *) idp->i_next );
}
bool
readIdents( idlist, fp )
Ids *idlist;
FILE *fp;
{ char input_buf[BUFSIZ];
int lower, upper;
register Ids *idp;
freeIdents( idlist ); /* free old list if it exists */
for( idp = idlist;
fgets( input_buf, BUFSIZ, fp ) != NULL;
)
{ char *token;
token = strtok( input_buf, ",-:; \t" );
if( token == NULL || sscanf( token, "%d", &lower ) < 1 )
continue;
token = strtok( NULL, " \t" );
if( token == NULL || sscanf( token, "%d", &upper ) < 1 )
upper = lower;
if( (idp->i_next = (Ids *) malloc( sizeof(Ids) )) == NULL )
{
Malloc_Bomb( sizeof(Ids) );
return false;
}
idp = idp->i_next;
idp->i_lower = lower;
idp->i_upper = upper;
}
idp->i_next = NULL;
return true;
}
bool
readColors( colorlist, fp )
Colors *colorlist;
FILE *fp;
{ char input_buf[BUFSIZ];
int lower, upper;
int rgb[3];
register Colors *colp;
for( colp = colorlist;
fgets( input_buf, BUFSIZ, fp ) != NULL;
)
{ int items;
if( (items =
sscanf( input_buf,
"%d %d %d %d %d\n",
&lower, &upper, &rgb[0], &rgb[1], &rgb[2]
)) < 5
)
{
if( items == EOF )
break;
else
{
brst_log( "readColors(): only %d items read\n",
items );
continue;
}
}
if( (colp->c_next = (Colors *) malloc( sizeof(Colors) ))
== NULL )
{
Malloc_Bomb( sizeof(Colors) );
return false;
}
colp = colp->c_next;
colp->c_lower = lower;
colp->c_upper = upper;
CopyVec( colp->c_rgb, rgb );
}
colp->c_next = NULL;
return true;
}
-203
View File
@@ -1,203 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#ifndef DEBUG
#define NDEBUG
#define STATIC static
#else
#define STATIC
#endif
#include <assert.h>
#include <stdio.h>
#include "conf.h"
#include "./vecmath.h"
#include "machine.h"
#include "vmath.h"
#include "raytrace.h"
#include "fb.h"
#include "./extern.h"
#define DEBUG_CELLFB 0
#define DEBUG_SPALLFB 0
/* Offset frame buffer coordinates to center of cell from grid lines. */
#define CenterCell(b) (b += round( (fastf_t) zoom / 2.0 ))
/* Compare one RGB pixel to another. */
#define SAMERGB(a,b) ((a)[RED] == (b)[RED] &&\
(a)[GRN] == (b)[GRN] &&\
(a)[BLU] == (b)[BLU])
static unsigned char pixbuf[MAXDEVWID][3];
static int gridxmargin;
static int gridymargin;
void
gridToFb( gx, gy, fxp, fyp )
int gx, gy;
int *fxp, *fyp;
{
/* map grid offsets to frame buffer coordinates */
*fxp = (gx - gridxorg)*zoom + gridxmargin;
*fyp = (gy - gridyorg)*zoom + gridymargin;
return;
}
void
paintGridFb()
{ register int gx, gy;
register int fx, fy;
int fxbeg, fybeg;
int fxfin, fyfin;
int fxorg, fyorg;
int fgridwid;
if( fb_clear( fbiop, pixbkgr ) == -1 )
return;
gridxmargin = (devwid - (gridwidth*zoom)) / 2.0;
gridymargin = (devhgt - (gridheight*zoom)) / 2.0;
gridToFb( gridxorg, gridyorg, &fxbeg, &fybeg );
gridToFb( gridxfin+1, gridyfin+1, &fxfin, &fyfin );
gridToFb( 0, 0, &fxorg, &fyorg );
CenterCell( fxorg ); /* center of cell */
CenterCell( fyorg );
if( zoom == 1 )
{
fgridwid = gridwidth + 2;
fxfin++;
}
else
fgridwid = gridwidth * zoom + 1;
/* draw vertical lines */
for( fx = 1; fx < fgridwid; fx++ )
COPYRGB( &pixbuf[fx][0], pixbkgr );
for( fx = fxbeg; fx <= fxfin; fx += zoom )
COPYRGB( &pixbuf[fx-fxbeg][0], &pixgrid[0] );
for( fy = fybeg; fy <= fyfin; fy++ )
(void) fb_write( fbiop, fxbeg, fy, (unsigned char *)pixbuf, fgridwid );
for( fy = 0; fy < devwid; fy++ )
(void) fb_write( fbiop, fxorg, fy, pixaxis, 1 );
/* draw horizontal lines */
if( zoom > 1 )
for( fy = fybeg; fy <= fyfin; fy += zoom )
(void) fb_write( fbiop,
fxbeg, fy, pixgrid, fgridwid );
for( fx = 0; fx < devwid; fx++ )
COPYRGB( &pixbuf[fx][0], pixaxis );
(void) fb_write( fbiop, 0, fyorg, (unsigned char *)pixbuf, devwid );
return;
}
void
paintCellFb( ap, pixpaint, pixexpendable )
register struct application *ap;
unsigned char *pixpaint;
unsigned char *pixexpendable;
{ int gx, gy;
register int gyfin, gxfin;
register int gxorg, gyorg;
register int x, y;
int cnt;
#if DEBUG_CELLFB
brst_log( "paintCellFb: expendable {%d,%d,%d}\n",
pixexpendable[RED],
pixexpendable[GRN],
pixexpendable[BLU] );
#endif
gridToFb( ap->a_x, ap->a_y, &gx, &gy );
gxorg = gx+1;
gyorg = gy+1;
gxfin = zoom == 1 ? gx+zoom+1 : gx+zoom;
gyfin = zoom == 1 ? gy+zoom+1 : gy+zoom;
cnt = gxfin - gxorg;
for( y = gyorg; y < gyfin; y++ )
{
if( zoom != 1 && (y - gy) % zoom == 0 )
continue;
bu_semaphore_acquire( RT_SEM_STATS );
(void) fb_read( fbiop, gxorg, y, (unsigned char *)pixbuf, cnt );
bu_semaphore_release( RT_SEM_STATS );
for( x = gxorg; x < gxfin; x++ )
{
if( SAMERGB( &pixbuf[x-gxorg][0], pixexpendable )
)
{
#if DEBUG_CELLFB
brst_log( "Clobbering:<%d,%d>{%d,%d,%d}\n",
x, y,
pixbuf[x-gxorg][RED],
pixbuf[x-gxorg][GRN],
pixbuf[x-gxorg][BLU] );
#endif
COPYRGB( &pixbuf[x-gxorg][0], pixpaint );
}
#if DEBUG_CELLFB
else
brst_log( "Preserving:<%d,%d>{%d,%d,%d}\n",
x, y,
pixbuf[x-gxorg][RED],
pixbuf[x-gxorg][GRN],
pixbuf[x-gxorg][BLU] );
#endif
}
bu_semaphore_acquire( RT_SEM_STATS );
(void) fb_write( fbiop, gxorg, y, (unsigned char *)pixbuf, cnt );
bu_semaphore_release( RT_SEM_STATS );
#if DEBUG_CELLFB
brst_log( "paintCellFb: fb_write(%d,%d)\n", x, y );
#endif
}
return;
}
void
paintSpallFb( ap )
register struct application *ap;
{ unsigned char pixel[3];
int x, y;
int err;
fastf_t celldist;
#if DEBUG_SPALLFB
brst_log( "paintSpallFb: a_x=%d a_y=%d a_cumlen=%g cellsz=%g zoom=%d\n",
ap->a_x, ap->a_y, ap->a_cumlen, cellsz, zoom );
#endif
pixel[RED] = ap->a_color[RED] * 255;
pixel[GRN] = ap->a_color[GRN] * 255;
pixel[BLU] = ap->a_color[BLU] * 255;
gridToFb( ap->a_x, ap->a_y, &x, &y );
CenterCell( x ); /* center of cell */
CenterCell( y );
celldist = ap->a_cumlen/cellsz * zoom;
x = round( x + Dot( ap->a_ray.r_dir, gridhor ) * celldist );
y = round( y + Dot( ap->a_ray.r_dir, gridver ) * celldist );
bu_semaphore_acquire( RT_SEM_STATS );
err = fb_write( fbiop, x, y, pixel, 1 );
bu_semaphore_release( RT_SEM_STATS );
#if DEBUG_SPALLFB
brst_log( "paintSpallFb:gridhor=<%g,%g,%g> gridver=<%g,%g,%g>\n",
gridhor[X], gridhor[Y], gridhor[Z],
gridver[X], gridver[Y], gridver[Z] );
brst_log( "paintSpallFb:fb_write(x=%d,y=%d,pixel={%d,%d,%d})\n",
x, y,
(int) pixel[RED],
(int) pixel[GRN],
(int) pixel[BLU]
);
#endif
if( err == -1 )
brst_log( "Write failed to pixel <%d,%d> from cell <%d,%d>.\n",
x, y, ap->a_x, ap->a_y );
return;
}
-91
View File
@@ -1,91 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#include <stdio.h>
#include <math.h>
#include "machine.h"
#include "vmath.h"
#include "raytrace.h"
#include "./vecmath.h"
#include "./burst.h"
#include "./extern.h"
void
plotInit()
{ int x1, y1, z1, x2, y2, z2;
if( plotfp == NULL )
return;
x1 = (int) rtip->mdl_min[X] - 1;
y1 = (int) rtip->mdl_min[Y] - 1;
z1 = (int) rtip->mdl_min[Z] - 1;
x2 = (int) rtip->mdl_max[X] + 1;
y2 = (int) rtip->mdl_max[Y] + 1;
z2 = (int) rtip->mdl_max[Z] + 1;
pl_3space( plotfp, x1, y1, z1, x2, y2, z2 );
return;
}
void
plotGrid( r_pt )
register fastf_t *r_pt;
{
if( plotfp == NULL )
return;
pl_color( plotfp, R_GRID, G_GRID, B_GRID );
pl_3point( plotfp, (int) r_pt[X], (int) r_pt[Y], (int) r_pt[Z] );
return;
}
void
plotRay( rayp )
register struct xray *rayp;
{ int endpoint[3];
if( plotfp == NULL )
return;
VJOIN1( endpoint, rayp->r_pt, cellsz, rayp->r_dir );
bu_semaphore_acquire( BU_SEM_SYSCALL );
pl_color( plotfp, R_BURST, G_BURST, B_BURST );
#if 0
pl_3line( plotfp,
(int) rayp->r_pt[X],
(int) rayp->r_pt[Y],
(int) rayp->r_pt[Z],
endpoint[X],
endpoint[Y],
endpoint[Z]
);
#else
pl_3point( plotfp, (int) endpoint[X], (int) endpoint[Y], (int) endpoint[Z] );
#endif
bu_semaphore_release( BU_SEM_SYSCALL );
return;
}
void
plotPartition( ihitp, ohitp, rayp, regp )
struct hit *ihitp;
register struct hit *ohitp ;
register struct xray *rayp;
struct region *regp;
{
if( plotfp == NULL )
return;
bu_semaphore_acquire( BU_SEM_SYSCALL );
pl_3line( plotfp,
(int) ihitp->hit_point[X],
(int) ihitp->hit_point[Y],
(int) ihitp->hit_point[Z],
(int) ohitp->hit_point[X],
(int) ohitp->hit_point[Y],
(int) ohitp->hit_point[Z]
);
bu_semaphore_release( BU_SEM_SYSCALL );
return;
}
-1012
View File
File diff suppressed because it is too large Load Diff
-471
View File
@@ -1,471 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
*/
#ifndef lint
static char RCSid[] = "@(#)$Header$ (BRL)";
#endif
#ifndef DEBUG
#define NDEBUG
#define STATIC static
#else
#define STATIC
#endif
#include <assert.h>
#include <stdio.h>
#include "./burst.h"
#include "./trie.h"
#include "./ascii.h"
#include "./extern.h"
STATIC Func *matchTrie();
/*
Trie *addTrie( char *name, Trie **triepp )
Insert the name in the trie specified by triepp, if it
doesn't already exist there.
Return pointer to leaf node associated with name.
*/
Trie *
addTrie( name, triepp )
register char *name;
register Trie **triepp;
{ register Trie *curp;
if( *name == NUL )
{ /* End of name, see if name already exists. */
if( *triepp == TRIE_NULL )
{ /* Name does not exist, make leaf node. */
NewTrie( *triepp );
(*triepp)->l.t_altr = (*triepp)->l.t_next
= TRIE_NULL;
(*triepp)->l.t_func = FUNC_NULL;
}
else
if( (*triepp)->n.t_next != TRIE_NULL )
/* Name is subset of another name. */
return addTrie( name, &(*triepp)->n.t_altr );
/* else -- Name already inserted, so do nothing. */
return *triepp;
}
/* Find matching letter, this level. */
for( curp = *triepp;
curp != TRIE_NULL && *name != curp->n.t_char;
curp = curp->n.t_altr
)
;
if( curp == TRIE_NULL )
{ /* No Match, this level, so create new alternate. */
curp = *triepp;
NewTrie( *triepp );
(*triepp)->n.t_altr = curp;
(*triepp)->n.t_char = *name;
(*triepp)->n.t_next = TRIE_NULL;
return addTrie( ++name, &(*triepp)->n.t_next );
}
else
/* Found matching character. */
return addTrie( ++name, &curp->n.t_next );
}
Func *
getTrie( name, triep )
register char *name;
register Trie *triep;
{ register Trie *curp = NULL;
assert( triep != TRIE_NULL );
/* Traverse next links to end of region name. */
for( ; triep != TRIE_NULL; triep = triep->n.t_next )
{
curp = triep;
if( *name == NUL )
{ /* End of user-typed name. */
if( triep->n.t_altr != TRIE_NULL )
/* Ambiguous at this point. */
return FUNC_NULL;
else /* Complete next character. */
{
*name++ = triep->n.t_char;
*name = NUL;
}
}
else
if( *name == '*' )
return matchTrie( triep );
else /* Not at end of user-typed name yet, traverse
alternate list to find current letter.
*/
{
for( ;
triep != TRIE_NULL
&& *name != triep->n.t_char;
triep = triep->n.t_altr
)
;
if( triep == TRIE_NULL )
/* Non-existant name, truncate bad part. */
{
*name = NUL;
return FUNC_NULL;
}
else
name++;
}
}
/* Clobber key-stroke, and return it. */
--name;
*name = NUL;
assert( curp != TRIE_NULL );
return curp->l.t_func;
}
#define MAX_TRIE_LEVEL (32*16)
STATIC Func *
matchTrie( triep )
register Trie *triep;
{ Func *func;
if( triep == TRIE_NULL )
func = FUNC_NULL;
else
if( triep->n.t_altr != TRIE_NULL )
func = FUNC_NULL; /* Ambiguous root, no match. */
else
if( triep->n.t_next == TRIE_NULL )
func = triep->l.t_func; /* At leaf node, return datum. */
else /* Keep going to leaf. */
func = matchTrie( triep->n.t_next );
return func;
}
void
prntTrie( triep, level )
Trie *triep;
int level;
{ register Trie *tp = triep;
static char name_buf[MAX_TRIE_LEVEL+1], *namep;
#if DEBUG_TRIE
brst_log( "prntTrie(triep=0x%x,level=%d)\n", triep, level );
#endif
if( tp == TRIE_NULL )
return;
if( tp->n.t_altr != TRIE_NULL )
prntTrie( tp->n.t_altr, level );
if( level == 0 )
namep = name_buf;
*namep = tp->n.t_char;
if( tp->n.t_next == TRIE_NULL )
{
/* At end of name, so print it out. */
*namep = NUL;
brst_log( "%s\n", name_buf );
}
else
{
namep++;
prntTrie( tp->n.t_next, level+1 );
namep--;
}
return;
}
int
writeTrie( triep, level, fp )
Trie *triep;
int level;
FILE *fp;
{ register Trie *tp = triep;
static char name_buf[MAX_TRIE_LEVEL+1], *namep;
if( tp == TRIE_NULL )
return 1;
if( tp->n.t_altr != TRIE_NULL )
(void) writeTrie( tp->n.t_altr, level, fp );
if( level == 0 )
namep = name_buf;
*namep = tp->n.t_char;
if( tp->n.t_next == TRIE_NULL )
{
/* At end of name, so print it out. */
*namep = NUL;
(void) fprintf( fp, "%s\n", name_buf );
}
else
{
namep++;
(void) writeTrie( tp->n.t_next, level+1, fp );
namep--;
}
return 1;
}
int
readTrie( fp, triepp )
FILE *fp;
Trie **triepp;
{ static char name_buf[MAX_TRIE_LEVEL+1];
while( fgets( name_buf, MAX_TRIE_LEVEL, fp ) != NULL )
{
name_buf[strlen(name_buf)-1] = '\0'; /* Clobber new-line. */
(void) addTrie( name_buf, triepp );
}
return 1;
}
void
ring_Bell()
{
(void) putchar( BEL );
return;
}
char *
char_To_String( i )
int i;
{ static char buf[4];
if( i >= SP && i < DEL )
{
buf[0] = i;
buf[1] = NUL;
}
else
if( i >= NUL && i < SP )
{
buf[0] = '^';
buf[1] = i + 64;
buf[2] = NUL;
}
else
if( i == DEL )
return "DL";
else
return "EOF";
return buf;
}
#if false
/*
Func *getFuncNm( char *inbuf, int bufsz, char *msg, Trie **triepp )
TENEX-style name completion.
Returns a function pointer.
*/
Func *
getFuncNm( inbuf, bufsz, msg, triepp )
char *inbuf;
int bufsz;
char *msg;
Trie **triepp;
{ static char buffer[BUFSIZ];
register char *p = buffer;
register int c;
Func *funcp;
if( tty )
{
save_Tty( 0 );
set_Raw( 0 );
clr_Echo( 0 );
}
prompt( msg );
*p = NUL;
do
{
(void) fflush( stdout );
c = hm_getchar();
switch( c )
{
case SP :
{
if( *triepp == TRIE_NULL
|| (funcp = getTrie( buffer, *triepp ))
== FUNC_NULL
)
(void) putchar( BEL );
for( ; p > buffer; p-- )
(void) putchar( BS );
(void) printf( "%s", buffer );
(void) ClrEOL();
(void) fflush( stdout );
p += strlen( buffer );
break;
}
case Ctrl('A') : /* Cursor to beginning of line. */
if( p == buffer )
{
ring_Bell();
break;
}
for( ; p > buffer; p-- )
(void) putchar( BS );
break;
case Ctrl('B') :
case BS : /* Move cursor back one character. */
if( p == buffer )
{
ring_Bell();
break;
}
(void) putchar( BS );
--p;
break;
case Ctrl('D') : /* Delete character under cursor. */
{ register char *q = p;
if( *p == NUL )
{
ring_Bell();
break;
}
for( ; *q != NUL; ++q )
{
*q = *(q+1);
(void) putchar( *q != NUL ? *q : SP );
}
for( ; q > p; --q )
(void) putchar( BS );
break;
}
case Ctrl('E') : /* Cursor to end of line. */
if( *p == NUL )
{
ring_Bell();
break;
}
(void) printf( "%s", p );
p += strlen( p );
break;
case Ctrl('F') : /* Cursor forward one character. */
if( *p == NUL || p-buffer >= bufsz-2 )
{
ring_Bell();
break;
}
(void) putchar( *p++ );
break;
case Ctrl('G') : /* Abort input. */
ring_Bell();
notify( "Aborted.", NOTIFY_APPEND );
goto clean_return;
case Ctrl('K') : /* Erase from cursor to end of line. */
if( *p == NUL )
{
ring_Bell();
break;
}
ClrEOL();
*p = NUL;
break;
case Ctrl('P') : /* Yank previous contents of "inbuf". */
{ register int len = strlen( inbuf );
if( (p + len) - buffer >= BUFSIZ )
{
ring_Bell();
break;
}
(void) strncpy( p, inbuf, bufsz );
(void) printf( "%s", p );
p += len;
break;
}
case Ctrl('U') : /* Erase from start of line to cursor. */
if( p == buffer )
{
ring_Bell();
break;
}
for( ; p > buffer; --p )
{ register char *q = p;
(void) putchar( BS );
for( ; *(q-1) != NUL; ++q )
{
*(q-1) = *q;
(void) putchar( *q != NUL ? *q : SP );
}
for( ; q > p; --q )
(void) putchar( BS );
}
break;
case Ctrl('R') : /* Print line, cursor doesn't move. */
{ register int i;
if( buffer[0] == NUL )
break;
for( i = p - buffer; i > 0; i-- )
(void) putchar( BS );
(void) printf( "%s", buffer );
for( i = strlen( buffer ) - (p - buffer); i > 0; i-- )
(void) putchar( BS );
break;
}
case DEL : /* Delete character behind cursor. */
{ register char *q = p;
if( p == buffer )
{
ring_Bell();
break;
}
(void) putchar( BS );
for( ; *(q-1) != NUL; ++q )
{
*(q-1) = *q;
(void) putchar( *q != NUL ? *q : SP );
}
for( ; q > p; --q )
(void) putchar( BS );
p--;
break;
}
case CR :
case LF :
case EOF :
if( *triepp == TRIE_NULL
|| (funcp = getTrie( buffer, *triepp ))
== FUNC_NULL
)
{
(void) putchar( BEL );
break;
}
else
{
(void) strncpy( inbuf, buffer, bufsz );
notify( NULL, NOTIFY_DELETE );
goto clean_return;
}
case Ctrl('V') :
/* Escape character, do not process next char. */
c = hm_getchar();
/* Fall through to default case! */
default : /* Insert character at cursor. */
{ register char *q = p;
register int len = strlen( p );
/* Scroll characters forward. */
if( c >= NUL && c < SP )
(void) printf( "%s", char_To_String( c ) );
else
(void) putchar( c );
for( ; len >= 0; len--, q++ )
(void) putchar( *q == NUL ? SP : *q );
for( ; q > p; q-- )
{
(void) putchar( BS );
*q = *(q-1);
}
*p++ = c;
break;
}
} /* End switch. */
}
while( strlen( buffer ) < BUFSIZ);
ring_Bell();
notify( "Buffer full.", NOTIFY_APPEND );
clean_return :
prompt( "" );
if( tty )
reset_Tty( 0 );
return funcp;
}
#endif
-48
View File
@@ -1,48 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$ (BRL)
*/
#ifndef INCL_TRIE
#define INCL_TRIE
#ifdef FUNC_NULL
#undef FUNC_NULL
#endif
#define FUNC_NULL ((Func *) NULL)
#define TRIE_NULL ((Trie *) NULL)
/* Datum for trie leaves. */
typedef void Func();
/* Trie tree node. */
typedef union trie Trie;
union trie
{
struct /* Internal nodes: datum is current letter. */
{
int t_char; /* Current letter. */
Trie *t_altr; /* Alternate letter node link. */
Trie *t_next; /* Next letter node link. */
}
n;
struct /* Leaf nodes: datum is function ptr. */
{
Func *t_func; /* Function pointer. */
Trie *t_altr; /* Alternate letter node link. */
Trie *t_next; /* Next letter node link. */
}
l;
};
#define NewTrie( p ) \
if( ((p) = (Trie *) malloc( sizeof(Trie) )) == TRIE_NULL )\
{\
Malloc_Bomb(sizeof(Trie));\
return TRIE_NULL;\
}
extern Trie *cmd_trie;
#endif /* INCL_TRIE */
-1625
View File
File diff suppressed because it is too large Load Diff
-102
View File
@@ -1,102 +0,0 @@
/*
Author: Gary S. Moss
U. S. Army Ballistic Research Laboratory
Aberdeen Proving Ground
Maryland 21005-5066
$Header$
*/
#ifndef _POLY9
#include <math.h>
#endif
#ifndef Abs
#define Abs( a ) ((a) > 0 ? (a) : -(a))
#endif
#define AbsDotProd( A, B ) (Abs( Dot( A, B ) ))
#define AddVec( A, B ) { (A)[X] += (B)[X]; \
(A)[Y] += (B)[Y]; \
(A)[Z] += (B)[Z]; }
#define Add2Vec( A, B, C ) { (C)[X] = (A)[X]+(B)[X]; \
(C)[Y] = (A)[Y]+(B)[Y]; \
(C)[Z] = (A)[Z]+(B)[Z]; }
#define AproxEq( a, b, e ) (Abs( (a)-(b) ) < (e))
#define AproxEqVec( A, B, e ) ( AproxEq((A)[X],(B)[X],(e)) && \
AproxEq((A)[Y],(B)[Y],(e)) && \
AproxEq((A)[Z],(B)[Z],(e)) )
#define CopyVec( A, B ) { (A)[X] = (B)[X]; \
(A)[Y] = (B)[Y]; \
(A)[Z] = (B)[Z]; }
#define CrossProd( A, B, C ) { (C)[X] = (A)[Y]*(B)[Z]-(A)[Z]*(B)[Y]; \
(C)[Y] = (A)[Z]*(B)[X]-(A)[X]*(B)[Z]; \
(C)[Z] = (A)[X]*(B)[Y]-(A)[Y]*(B)[X]; }
#define DEGRAD 57.2957795130823208767981548141051703324054724665642
/* degrees per radian */
#define DiffVec( A, B ) { (A)[X] -= (B)[X]; \
(A)[Y] -= (B)[Y]; \
(A)[Z] -= (B)[Z]; }
#define Diff2Vec( A, B, C ) { (C)[X] = (A)[X]-(B)[X]; \
(C)[Y] = (A)[Y]-(B)[Y]; \
(C)[Z] = (A)[Z]-(B)[Z]; }
#define Dist3d( A, B ) (sqrt( Sqr((A)[X]-(B)[X])+\
Sqr((A)[Y]-(B)[Y])+\
Sqr((A)[Z]-(B)[Z]))\
)
#define DivideVec( A, S ) { (A)[X] /= (S); \
(A)[Y] /= (S); \
(A)[Z] /= (S); }
#define Dot( A, B ) ((A)[X]*(B)[X]+(A)[Y]*(B)[Y]+(A)[Z]*(B)[Z])
#ifndef EPSILON
#define EPSILON 0.000001
#endif
#define Expand_Vec_Int( V ) (int)(V)[X], (int)(V)[Y], (int)(V)[Z]
#define LOG10E 0.43429448190325182765112891891660508229439700580367
/* log of e to the base 10 */
#define Mag( A ) sqrt( AbsDotProd(A,A) )
#define Mag3(a1,a2,a3) (sqrt(Sqr(a1)+Sqr(a2)+Sqr(a3)))
#ifndef Min
#define Min( a, b ) ((a) < (b) ? (a) : (b))
#define Max( a, b ) ((a) > (b) ? (a) : (b))
#endif
#define MinMax( m, M, a ) { m = Min( m, a ); M = Max( M, a ); }
#define MinMaxVec( A, B, C ) { (A)[X] = Min( (A)[X], (C)[X] ); \
(A)[Y] = Min( (A)[Y], (C)[Y] ); \
(A)[Z] = Min( (A)[Z], (C)[Z] ); \
(B)[X] = Max( (B)[X], (C)[X] ); \
(B)[Y] = Max( (B)[Y], (C)[Y] ); \
(B)[Z] = Max( (B)[Z], (C)[Z] ); }
#define NearZero( a ) ((a) < EPSILON && (a) > -EPSILON)
#define NonZeroVec( V ) (!NearZero((V)[X]) || !NearZero((V)[Y])|| !NearZero((V)[Z]))
#ifndef PI
#define PI 3.14159265358979323846264338327950288419716939937511
#endif
/* ratio of circumf. to diam. */
#define RelDist3d( A, B ) (Sqr((A)[X]-(B)[X])+\
Sqr((A)[Y]-(B)[Y])+\
Sqr((A)[Z]-(B)[Z]))
#define ScaleVec( A, s ) { (A)[X] *= (s); \
(A)[Y] *= (s); \
(A)[Z] *= (s); }
#define Scale2Vec( A, s, B ) { (B)[X] = (A)[X] * (s); \
(B)[Y] = (A)[Y] * (s); \
(B)[Z] = (A)[Z] * (s); }
#define Sqr(a) ((a)*(a))
#define TWO_PI 6.28318530717958647692528676655900576839433879875022
/* Scale vector 'a' to have magnitude 'l'. */
#define V_Length( a, l ) \
{ double f, m; \
if( (m=Mag(a)) == 0.0 ) \
brst_log( "Magnitude is zero!\n" ); \
else \
{ \
f = (l)/m; \
(a)[X] *= f; (a)[Y] *= f; (a)[Z] *= f; \
} \
}
#define V_Print(a,b,func) \
func( "%s\t<%12.6f,%12.6f,%12.6f>\n", a, (b)[0], (b)[1], (b)[2] )
#ifndef X
#define X 0
#define Y 1
#define Z 2
#endif
-43
View File
@@ -1,43 +0,0 @@
Cake copying permission notice Copyright (C) 1987 Zoltan Somogyi
Cake is distributed in the hope that it will be useful, but without any
warranty. No author or distributor accepts responsibility to anyone for
the consequences of using it or for whether it serves any particular purpose
or works at all, unless he/she says so in writing.
Everyone is granted permission to copy, modify and redistribute Cake
under the following conditions:
Permission is granted to anyone to make or distribute verbatim copies
of Cake source code as received, in any medium, provided that all
copyright notices and permission and nonwarranty notices are preserved,
and that the distributor grants the recipient permission for further
redistribution as permitted by this document, and gives him/her and
points out to him/her an exact copy of this document to inform him/her
of his/her rights.
Permission is granted to distribute modified versions of Cake source
code, or of portions of it, under the above conditions, provided also
that all changed files carry prominent notices stating who last changed
them and that all the Cake-derived material, including everything
packaged together with it and not independently usable, is distributed
under the conditions stated in this document.
Permission is granted to distribute Cake in compiled or executable form
under the same conditions applying for source code, provided that either
A it is accompanied by the corresponding machine-readable source
code, or
B it is accompanied by a written offer, with no time limit, to
give anyone a machine-readable copy of the corresponding source
code in return for reimbursement of the cost of distribution.
This written offer must permit verbatim duplication by anyone.
C it is distributed by someone who received only the executable
form, and is accompanied by a copy of the written offer of
source code which he/she received along with it.
In other words, you are welcome to use, share and improve Cake.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
This copyright notice was adapted from the one supplied with GNU Emacs.
-124
View File
@@ -1,124 +0,0 @@
# Makefile for Cake
#
#$Header$
SHELL=/bin/sh
# -DATT for SystemV, -DBSD for Berkeley, done by machinetype.sh
#
# For Apollo, may need to add -Tbsd4.3
#
# For gnu compiler use the following two lines:
# CC = gcc
# COPTS = -DCAKEDEBUG=1 `machinetype.sh -d` -fwritable-strings
#
COPTS = -DCAKEDEBUG `machinetype.sh -d`
# for gnu or Linux use "flex" instead of "lex"
LEX = lex -n
# Some systems (such as NetBSD 0.9a), need to add -l to get yylineno.
LEXOPTS=
# LEXOPTS= -l
#LDFLAGS=-k 64k
HDR = cake.h conf.h port.h
SRC = act.c chase.c entry.c error.c expand.c file.c \
list.c main.c make.c mem.c pat.c print.c proc.c \
sym.c sys.c table.c test.c trail.c
OBJ = act.o chase.o entry.o error.o expand.o file.o \
list.o main.o make.o mem.o pat.o print.o proc.o \
sym.o sys.o table.o test.o trail.o
GEN = cake_g.y cake_s.l
GHDR = cake_g.h
GSRC = cake_g.c cake_s.c
GOBJ = cake_g.o cake_s.o
CFLAGS= $(COPTS)
cake: $(OBJ) $(GOBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o cake $(OBJ) $(GOBJ)
# -/bin/rm fake
# ln cake fake
all: cake lint tags
# This needs to be run all as one line, so variables are not lost.
# echo BINDIR=$${BINDIR};
install: cake
eval `machinetype.sh -v` ; \
BINDIR=$${BASEDIR}/bin; \
MANDIR=$${BASEDIR}/man/man1; \
if test -f $${BINDIR}/cake; then \
mv -f $${BINDIR}/cake $${BINDIR}/cake.bak; fi; \
mv cake $${BINDIR}/cake; \
rm -f $${BINDIR}/fake; \
ln -s $${BINDIR}/cake $${BINDIR}/fake; \
rm -f $${MANDIR}/cake.1 $${MANDIR}/fake.1; \
cp cake.1 $${MANDIR}; \
ln -s $${MANDIR}/cake.1 $${MANDIR}/fake.1
$(OBJ): $(HDR)
$(GOBJ): $(HDR)
cake_g.c: cake_g.y
# for bison instead of yacc, use the following line, you may need to remove the "void" declaration for
# yyerror() in "cake_g.y"
# bison -ydv cake_g.y
yacc -dv cake_g.y
mv -f y.tab.h cake_g.h
mv -f y.tab.c cake_g.c
mv -f y.output cake_g.t
cake_s.c: cake_s.l
$(LEX) $(LEXOPTS) cake_s.l
mv -f lex.yy.c cake_s.c
var: $(SRC) $(GSRC)
var -DATT $(COPTS) $(SRC) $(GSRC) > Var
plint: $(SRC) $(GSRC)
lint -acpx $(COPTS) $(SRC) $(GSRC) > Lint_errs
ulint: $(SRC) $(GSRC)
lint -v $(COPTS) $(SRC) $(GSRC) > Lint_errs
lint: $(SRC) $(GSRC)
lint -v $(COPTS) $(SRC) $(GSRC) > Lint_errs
@gred yy Lint_errs
@gred malloc Lint_errs
@gred strcpy Lint_errs
@gred strcat Lint_errs
@gred printf Lint_errs
@gred flsbuf Lint_errs
@gred setbuf Lint_errs
@gred rcs_id Lint_errs
@gred longjmp Lint_errs
@gred sbrk Lint_errs
cchk: $(SRC)
cchk $(SRC) > Cchk_errs
tags: $(SRC) $(GSRC)
ctags $(SRC) $(GSRC)
cxref: $(SRC)
cxref -C $(SRC) > Cxref
ssize:
ssize $(SRC) $(GEN)
asize:
ssize $(SRC) $(GEN) $(GSRC)
clean:
/bin/rm -f cake_g.h cake_g.t \
Make_errs Lint_errs Cchk_errs core \
$(OBJ) $(GOBJ) $(GSRC)
gclean:
/bin/rm -f $(GSRC) $(GHDR)
clobber: clean
/bin/rm -f cake fake

Some files were not shown because too many files have changed in this diff Show More