forked from lijiext/lammps
Merge pull request #427 from akohlmey/small-updates-and-corrections
Various updates and corrections for upcoming stable release
This commit is contained in:
commit
145e682ad3
|
@ -39,7 +39,7 @@ directory name created when you unpack a tarball, and at the top of
|
|||
the first page of the manual (this page).
|
||||
|
||||
If you browse the HTML doc pages on the LAMMPS WWW site, they always
|
||||
describe the most current version of LAMMPS. :ulb,l
|
||||
describe the most current [development] version of LAMMPS. :ulb,l
|
||||
|
||||
If you browse the HTML doc pages included in your tarball, they
|
||||
describe the version you have. :l
|
||||
|
@ -67,7 +67,7 @@ Labs and Temple University:
|
|||
|
||||
"Steve Plimpton"_sjp, sjplimp at sandia.gov :ulb,l
|
||||
Aidan Thompson, athomps at sandia.gov :l
|
||||
Stan Moore, stamoore at sandia.gov :l
|
||||
Stan Moore, stamoor at sandia.gov :l
|
||||
"Axel Kohlmeyer"_ako, akohlmey at gmail.com :l
|
||||
:ule
|
||||
|
||||
|
|
|
@ -12,9 +12,12 @@ Section"_Section_modify.html :c
|
|||
|
||||
LAMMPS is designed to be a computational kernel for performing
|
||||
molecular dynamics computations. Additional pre- and post-processing
|
||||
steps are often necessary to setup and analyze a simulation. A few
|
||||
additional tools are provided with the LAMMPS distribution and are
|
||||
described in this section.
|
||||
steps are often necessary to setup and analyze a simulation. A
|
||||
list of such tools can be found on the LAMMPS home page
|
||||
at "http://lammps.sandia.gov/prepost.html"_http://lammps.sandia.gov/prepost.html
|
||||
|
||||
A few additional tools are provided with the LAMMPS distribution
|
||||
and are described in this section.
|
||||
|
||||
Our group has also written and released a separate toolkit called
|
||||
"Pizza.py"_pizza which provides tools for doing setup, analysis,
|
||||
|
@ -45,7 +48,6 @@ own sub-directories with their own Makefiles.
|
|||
"chain"_#chain
|
||||
"colvars"_#colvars
|
||||
"createatoms"_#create
|
||||
"data2xmovie"_#data
|
||||
"eam database"_#eamdb
|
||||
"eam generate"_#eamgn
|
||||
"eff"_#eff
|
||||
|
@ -56,7 +58,6 @@ own sub-directories with their own Makefiles.
|
|||
"kate"_#kate
|
||||
"lmp2arc"_#arc
|
||||
"lmp2cfg"_#cfg
|
||||
"lmp2vmd"_#vmd
|
||||
"matlab"_#matlab
|
||||
"micelle2d"_#micelle
|
||||
"moltemplate"_#moltemplate
|
||||
|
@ -69,7 +70,6 @@ own sub-directories with their own Makefiles.
|
|||
"restart2data"_#restart
|
||||
"vim"_#vim
|
||||
"xmgrace"_#xmgrace
|
||||
"xmovie"_#xmovie :ul
|
||||
|
||||
:line
|
||||
|
||||
|
@ -171,19 +171,6 @@ The tool is authored by Xiaowang Zhou (Sandia), xzhou at sandia.gov.
|
|||
|
||||
:line
|
||||
|
||||
data2xmovie tool :h4,link(data)
|
||||
|
||||
The file data2xmovie.c converts a LAMMPS data file into a snapshot
|
||||
suitable for visualizing with the "xmovie"_#xmovie tool, as if it had
|
||||
been output with a dump command from LAMMPS itself. The syntax for
|
||||
running the tool is
|
||||
|
||||
data2xmovie \[options\] < infile > outfile :pre
|
||||
|
||||
See the top of the data2xmovie.c file for a discussion of the options.
|
||||
|
||||
:line
|
||||
|
||||
eam database tool :h4,link(eamdb)
|
||||
|
||||
The tools/eam_database directory contains a Fortran program that will
|
||||
|
@ -317,18 +304,6 @@ This tool was written by Ara Kooser at Sandia (askoose at sandia.gov).
|
|||
|
||||
:line
|
||||
|
||||
lmp2vmd tool :h4,link(vmd)
|
||||
|
||||
The lmp2vmd sub-directory contains a README.txt file that describes
|
||||
details of scripts and plugin support within the "VMD
|
||||
package"_http://www.ks.uiuc.edu/Research/vmd for visualizing LAMMPS
|
||||
dump files.
|
||||
|
||||
The VMD plugins and other supporting scripts were written by Axel
|
||||
Kohlmeyer (akohlmey at cmm.chem.upenn.edu) at U Penn.
|
||||
|
||||
:line
|
||||
|
||||
matlab tool :h4,link(matlab)
|
||||
|
||||
The matlab sub-directory contains several "MATLAB"_matlabhome scripts for
|
||||
|
@ -381,16 +356,14 @@ supports it. It has its own WWW page at
|
|||
msi2lmp tool :h4,link(msi)
|
||||
|
||||
The msi2lmp sub-directory contains a tool for creating LAMMPS input
|
||||
data files from Accelrys' Insight MD code (formerly MSI/Biosym and
|
||||
its Discover MD code). See the README file for more information.
|
||||
data files from BIOVIA's Materias Studio files (formerly Accelrys'
|
||||
Insight MD code, formerly MSI/Biosym and its Discover MD code).
|
||||
|
||||
This tool was written by John Carpenter (Cray), Michael Peachey
|
||||
(Cray), and Steve Lustig (Dupont). John is now at the Mayo Clinic
|
||||
(jec at mayo.edu), but still fields questions about the tool.
|
||||
(Cray), and Steve Lustig (Dupont). Several people contributed changes
|
||||
to remove bugs and adapt its output to changes in LAMMPS.
|
||||
|
||||
This tool may be out-of-date with respect to the current LAMMPS and
|
||||
Insight versions. Since we don't use it at Sandia, you'll need to
|
||||
experiment with it yourself.
|
||||
See the README file for more information.
|
||||
|
||||
:line
|
||||
|
||||
|
@ -484,32 +457,13 @@ read_restart restartfile
|
|||
write_data datafile
|
||||
|
||||
which will produce the same data file that the restart2data tool used
|
||||
to create. The following information is included in case you have an
|
||||
older version of LAMMPS which still includes the restart2data tool.
|
||||
to create.
|
||||
|
||||
The file restart2data.cpp converts a binary LAMMPS restart file into
|
||||
an ASCII data file. The syntax for running the tool is
|
||||
|
||||
restart2data restart-file data-file (input-file) :pre
|
||||
|
||||
Input-file is optional and if specified will contain LAMMPS input
|
||||
commands for the masses and force field parameters, instead of putting
|
||||
those in the data-file. Only a few force field styles currently
|
||||
support this option.
|
||||
|
||||
This tool must be compiled on a platform that can read the binary file
|
||||
created by a LAMMPS run, since binary files are not compatible across
|
||||
all platforms.
|
||||
|
||||
Note that a text data file has less precision than a binary restart
|
||||
file. Hence, continuing a run from a converted data file will
|
||||
typically not conform as closely to a previous run as will restarting
|
||||
from a binary restart file.
|
||||
|
||||
If a "%" appears in the specified restart-file, the tool expects a set
|
||||
of multiple files to exist. See the "restart"_restart.html and
|
||||
"write_restart"_write_restart.html commands for info on how such sets
|
||||
of files are written by LAMMPS, and how the files are named.
|
||||
IMPORTANT NOTE: LAMMPS' binary restart files are generally not portable
|
||||
between platforms, compiler settings and LAMMPS versions. Changes in
|
||||
the format itself are rare, but no effort is made to maintain backward
|
||||
compatibility. Data files are mostly backward and forward portable,
|
||||
if no features are used that exist in only one LAMMPS version.
|
||||
|
||||
:line
|
||||
|
||||
|
@ -537,32 +491,3 @@ See the README file for details.
|
|||
|
||||
These files were provided by Vikas Varshney (vv0210 at gmail.com)
|
||||
|
||||
:line
|
||||
|
||||
xmovie tool :h4,link(xmovie)
|
||||
|
||||
The xmovie tool is an X-based visualization package that can read
|
||||
LAMMPS dump files and animate them. It is in its own sub-directory
|
||||
with the tools directory. You may need to modify its Makefile so that
|
||||
it can find the appropriate X libraries to link against.
|
||||
|
||||
The syntax for running xmovie is
|
||||
|
||||
xmovie \[options\] dump.file1 dump.file2 ... :pre
|
||||
|
||||
If you just type "xmovie" you will see a list of options. Note that
|
||||
by default, LAMMPS dump files are in scaled coordinates, so you
|
||||
typically need to use the -scale option with xmovie. When xmovie runs
|
||||
it opens a visualization window and a control window. The control
|
||||
options are straightforward to use.
|
||||
|
||||
Xmovie was mostly written by Mike Uttormark (U Wisconsin) while he
|
||||
spent a summer at Sandia. It displays 2d projections of a 3d domain.
|
||||
While simple in design, it is an amazingly fast program that can
|
||||
render large numbers of atoms very quickly. It's a useful tool for
|
||||
debugging LAMMPS input and output and making sure your simulation is
|
||||
doing what you think it should. The animations on the Examples page
|
||||
of the "LAMMPS WWW site"_lws were created with xmovie.
|
||||
|
||||
I've lost contact with Mike, so I hope he's comfortable with us
|
||||
distributing his great tool!
|
||||
|
|
|
@ -464,7 +464,7 @@ supported.
|
|||
|
||||
[References:]
|
||||
|
||||
Brown, W.M., Carrillo, J.-M.Y., Mishra, B., Gavhane, N., Thakker, F.M., De Kraker, A.R., Yamada, M., Ang, J.A., Plimpton, S.J., “Optimizing Classical Molecular Dynamics in LAMMPS,” in Intel Xeon Phi Processor High Performance Programming: Knights Landing Edition, J. Jeffers, J. Reinders, A. Sodani, Eds. Morgan Kaufmann. :ulb,l
|
||||
Brown, W.M., Carrillo, J.-M.Y., Mishra, B., Gavhane, N., Thakker, F.M., De Kraker, A.R., Yamada, M., Ang, J.A., Plimpton, S.J., "Optimizing Classical Molecular Dynamics in LAMMPS," in Intel Xeon Phi Processor High Performance Programming: Knights Landing Edition, J. Jeffers, J. Reinders, A. Sodani, Eds. Morgan Kaufmann. :ulb,l
|
||||
|
||||
Brown, W. M., Semin, A., Hebenstreit, M., Khvostov, S., Raman, K., Plimpton, S.J. Increasing Molecular Dynamics Simulation Rates with an 8-Fold Increase in Electrical Power Efficiency. 2016 International Conference for High Performance Computing. In press. :l
|
||||
|
||||
|
|
|
@ -466,16 +466,6 @@ to undergo a slow random walk. This can be mitigated by resetting
|
|||
the momentum at infrequent intervals using the
|
||||
"fix momentum"_fix_momentum.html command.
|
||||
|
||||
NOTE: This implementation has been shown to conserve linear momentum
|
||||
up to machine precision under NVT dynamics. Under NPT dynamics,
|
||||
for a system with zero initial total linear momentum, the total
|
||||
momentum fluctuates close to zero. It may occasionally undergo brief
|
||||
excursions to non-negligible values, before returning close to zero.
|
||||
Over long simulations, this has the effect of causing the center-of-mass
|
||||
to undergo a slow random walk. This can be mitigated by resetting
|
||||
the momentum at infrequent intervals using the
|
||||
"fix momentum"_fix_momentum.html command.
|
||||
|
||||
:line
|
||||
|
||||
The fix npt and fix nph commands can be used with rigid bodies or
|
||||
|
|
|
@ -67,6 +67,6 @@ LAMMPS"_Section_start.html#start_3 section for more info.
|
|||
:link(KC05)
|
||||
[(KC05)] A. N. Kolmogorov, V. H. Crespi, Phys. Rev. B 71, 235415 (2005)
|
||||
|
||||
:link(vanWijk)
|
||||
[(vanWijk)] M. M. van Wijk, A. Schuring, M. I. Katsnelson, and A. Fasolino,
|
||||
:link(vanWijk)
|
||||
[(vanWijk)] M. M. van Wijk, A. Schuring, M. I. Katsnelson, and A. Fasolino,
|
||||
Physical Review Letters, 113, 135504 (2014)
|
||||
|
|
|
@ -50,7 +50,7 @@ NOTE: These pair styles have to be used together with the related oxDNA bond sty
|
|||
"bond_style oxdna/fene"_bond_oxdna.html). The coefficients
|
||||
in the above example have to be kept fixed and cannot be changed without reparametrizing the entire model.
|
||||
|
||||
Example input and data files can be found in examples/USER/cgdna/examples/duplex1/ and /duplex2/.
|
||||
Example input and data files can be found in examples/USER/cgdna/examples/duplex1/ and /duplex2/.
|
||||
A simple python setup tool which creates single straight or helical DNA strands,
|
||||
DNA duplexes or arrays of DNA duplexes can be found in examples/USER/cgdna/util/.
|
||||
A technical report with more information on the model, the structure of the input file,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
<div style="text-align: center; margin-bottom: -1.5em; display: block"><b>LAMMPS</b> {{ version }}</div>
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="{{ pathto(master_doc) }}">Docs</a> »</li>
|
||||
{% for doc in parents %}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
// Syntax: binary2txt file1 file2 ...
|
||||
// Creates: file1.txt file2.txt ...
|
||||
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// these must match settings in src/lmptype.h which builds LAMMPS with
|
||||
// -DLAMMPS_SMALLBIG (the default), -DLAMMPS_BIGBIG, or -DLAMMPS_SMALLSMALL
|
||||
|
|
|
@ -12,13 +12,12 @@ ABFdata::ABFdata(const char *gradFileName)
|
|||
|
||||
std::ifstream gradFile;
|
||||
std::ifstream countFile;
|
||||
int n;
|
||||
char hash;
|
||||
double xi;
|
||||
char *countFileName;
|
||||
|
||||
countFileName = new char[strlen (gradFileName) + 2];
|
||||
strcpy (countFileName, gradFileName);
|
||||
strcpy (countFileName, gradFileName);
|
||||
countFileName[strlen (gradFileName) - 4] = '\0';
|
||||
strcat (countFileName, "count");
|
||||
|
||||
|
@ -152,7 +151,8 @@ ABFdata::ABFdata(const char *gradFileName)
|
|||
}
|
||||
// Could check for end-of-file string here
|
||||
countFile.close();
|
||||
delete [] countFileName;
|
||||
delete[] countFileName;
|
||||
delete[] pos;
|
||||
|
||||
// for metadynamics
|
||||
bias = new double[scalar_dim];
|
||||
|
@ -269,7 +269,7 @@ void ABFdata::write_bias(const char *fileName)
|
|||
if (minbias == 0.0 || (bias[index] > 0.0 && bias[index] < minbias))
|
||||
minbias = bias[index];
|
||||
}
|
||||
|
||||
|
||||
for (index = 0; index < scalar_dim; index++) {
|
||||
// Here we do the Euclidian division iteratively
|
||||
for (i = Nvars - 1; i > 0; i--) {
|
||||
|
|
|
@ -22,10 +22,7 @@ int main(int argc, char *argv[])
|
|||
char *out_file;
|
||||
unsigned int step, nsteps, total, out_freq;
|
||||
int *pos, *dpos, *newpos;
|
||||
unsigned int *histogram;
|
||||
const double *grad, *newgrad;
|
||||
unsigned int offset, newoffset;
|
||||
int not_accepted;
|
||||
double dA;
|
||||
double temp;
|
||||
double mbeta;
|
||||
|
@ -47,7 +44,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (!(data_file = parse_cl(argc, argv, &nsteps, &temp, &meta, &hill, &hill_fact))) {
|
||||
std::cerr << "\nabf_integrate: MC-based integration of multidimensional free energy gradient\n";
|
||||
std::cerr << "Version 20110511\n\n";
|
||||
std::cerr << "Version 20160420\n\n";
|
||||
std::cerr << "Syntax: " << argv[0] <<
|
||||
" <filename> [-n <nsteps>] [-t <temp>] [-m [0|1] (metadynamics)]"
|
||||
" [-h <hill_height>] [-f <variable_hill_factor>]\n\n";
|
||||
|
@ -62,7 +59,7 @@ int main(int argc, char *argv[])
|
|||
} else {
|
||||
std::cout << "\nUsing unbiased MC sampling\n";
|
||||
}
|
||||
|
||||
|
||||
if (nsteps) {
|
||||
std::cout << "Sampling " << nsteps << " steps at temperature " << temp << "\n\n";
|
||||
out_freq = nsteps / 10;
|
||||
|
@ -74,7 +71,7 @@ int main(int argc, char *argv[])
|
|||
converged = false;
|
||||
}
|
||||
|
||||
// Inverse temperature in (kcal/mol)-1
|
||||
// Inverse temperature in (kcal/mol)-1
|
||||
mbeta = -1 / (0.001987 * temp);
|
||||
|
||||
ABFdata data(data_file);
|
||||
|
@ -91,12 +88,16 @@ int main(int argc, char *argv[])
|
|||
dpos = new int[data.Nvars];
|
||||
newpos = new int[data.Nvars];
|
||||
|
||||
// TODO: this will be an infinite loop if there is no sampling
|
||||
// it would be more robust to build a list of non-empty bins, and
|
||||
// pick from there (or just treat the special case of no sampling
|
||||
// and output a null PMF)
|
||||
do {
|
||||
for (int i = 0; i < data.Nvars; i++) {
|
||||
pos[i] = rand() % data.sizes[i];
|
||||
}
|
||||
offset = data.offset(pos);
|
||||
} while ( !data.allowed (offset) );
|
||||
} while ( !data.allowed (offset) );
|
||||
|
||||
rmsd = compute_deviation(&data, meta, 0.001987 * temp);
|
||||
std::cout << "\nInitial gradient RMS is " << rmsd << "\n";
|
||||
|
@ -128,9 +129,9 @@ int main(int argc, char *argv[])
|
|||
data.bias[offset] += hill;
|
||||
}
|
||||
|
||||
grad = data.gradients + offset * data.Nvars;
|
||||
const double *grad = data.gradients + offset * data.Nvars;
|
||||
|
||||
not_accepted = 1;
|
||||
int not_accepted = 1;
|
||||
while (not_accepted) {
|
||||
dA = 0.0;
|
||||
total++;
|
||||
|
@ -206,7 +207,7 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
|
|||
double *dev = data->deviation;
|
||||
double *est = data->estimate;
|
||||
const double *grad = data->gradients;
|
||||
int *pos, *dpos, *newpos;
|
||||
int *pos, *newpos;
|
||||
double rmsd = 0.0;
|
||||
unsigned int offset, newoffset;
|
||||
double sum;
|
||||
|
@ -215,7 +216,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
|
|||
unsigned int norm = 0; // number of data points summmed
|
||||
|
||||
pos = new int[data->Nvars];
|
||||
dpos = new int[data->Nvars];
|
||||
newpos = new int[data->Nvars];
|
||||
|
||||
for (int i = 0; i < data->Nvars; i++)
|
||||
|
@ -287,7 +287,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
|
|||
|
||||
delete [] pos;
|
||||
delete [] newpos;
|
||||
delete [] dpos;
|
||||
|
||||
return sqrt(rmsd / norm);
|
||||
}
|
||||
|
@ -296,8 +295,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
|
|||
char *parse_cl(int argc, char *argv[], unsigned int *nsteps, double *temp,
|
||||
bool * meta, double *hill, double *hill_fact)
|
||||
{
|
||||
char *filename = NULL;
|
||||
float f_temp, f_hill;
|
||||
int meta_int;
|
||||
|
||||
// getting default value for the integer
|
||||
|
|
|
@ -1,366 +0,0 @@
|
|||
/* data2xmovie tool
|
||||
|
||||
read LAMMPS data file as input
|
||||
write a snapshot in XMOVIE format
|
||||
|
||||
Syntax: data2xmovie [options] < infile > outfile
|
||||
|
||||
Options:
|
||||
|
||||
-style atom_style
|
||||
|
||||
use the LAMMPS atom style that corresponds to this file
|
||||
e.g. atomic or bond or angle or full or eam or granular
|
||||
will be used for reading and writing files
|
||||
if not specified, atom_style = full
|
||||
|
||||
-unmap
|
||||
|
||||
unmap all input atom positions using input image flags
|
||||
image flags must be specified in infile
|
||||
default is to leave atoms mapped to periodic box
|
||||
|
||||
-inbox xlo xhi ylo yhi zlo zhi
|
||||
|
||||
use these values for the output bounding box of the system
|
||||
useful if are unmapping atoms into a larger domain
|
||||
if not specified use the box bounds read in from infile
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
struct box {
|
||||
double xlo,xhi,xsize;
|
||||
double ylo,yhi,ysize;
|
||||
double zlo,zhi,zsize;
|
||||
};
|
||||
|
||||
#define MAXLINE 1000
|
||||
|
||||
#define ATOMIC 1
|
||||
#define BOND 2
|
||||
#define ANGLE 3
|
||||
#define FULL 4
|
||||
#define EAM 5
|
||||
#define GRANULAR 6
|
||||
|
||||
main(int argc, char *argv[])
|
||||
|
||||
{
|
||||
char line[1000]; /* strings for reading/parsing input file */
|
||||
char linetoken[1000];
|
||||
char *token;
|
||||
/* numbers of various quantities as read in */
|
||||
|
||||
int natoms,nbonds,nangles,ndihedrals,nimpropers;
|
||||
int ntypes,nbondtypes,nangletypes,ndihedtypes,nimprotypes;
|
||||
|
||||
int nmolecules; /* total # of mols specified by mol tags */
|
||||
|
||||
int atomstyle; /* atomstyle for read/write of Atoms */
|
||||
int unmap; /* 0 = no unmapping, 1 = unmap from input box */
|
||||
int outbox; /* flag for whether out box is explicitly set */
|
||||
|
||||
struct box in,out; /* input/output bounding box */
|
||||
|
||||
char *gettoken(char *, int); /* function defs */
|
||||
void skipline(int);
|
||||
|
||||
/* default input values */
|
||||
|
||||
atomstyle = 0;
|
||||
unmap = 0;
|
||||
outbox = 0;
|
||||
|
||||
/* read input options from command line
|
||||
should do more error checking for missing args */
|
||||
|
||||
int i = 1;
|
||||
while (i < argc) {
|
||||
|
||||
if (!strcmp(argv[i],"-style")) {
|
||||
if (strcmp(argv[i+1],"atomic") == 0) atomstyle = ATOMIC;
|
||||
else if (strcmp(argv[i+1],"bond") == 0) atomstyle = BOND;
|
||||
else if (strcmp(argv[i+1],"angle") == 0) atomstyle = ANGLE;
|
||||
else if (strcmp(argv[i+1],"full") == 0) atomstyle = FULL;
|
||||
else if (strcmp(argv[i+1],"eam") == 0) atomstyle = EAM;
|
||||
else if (strcmp(argv[i+1],"granular") == 0) atomstyle = GRANULAR;
|
||||
else {
|
||||
fprintf(stderr,"Error with command-line arg style\n");
|
||||
exit(1);
|
||||
}
|
||||
i += 2;
|
||||
} else if (!strcmp(argv[i],"-unmap")) {
|
||||
unmap = 1;
|
||||
i += 1;
|
||||
} else if (!strcmp(argv[i],"-inbox")) {
|
||||
outbox = 1;
|
||||
sscanf(argv[i+1],"%lg",&out.xlo);
|
||||
sscanf(argv[i+2],"%lg",&out.xhi);
|
||||
sscanf(argv[i+3],"%lg",&out.ylo);
|
||||
sscanf(argv[i+4],"%lg",&out.yhi);
|
||||
sscanf(argv[i+5],"%lg",&out.zlo);
|
||||
sscanf(argv[i+6],"%lg",&out.zhi);
|
||||
i += 7;
|
||||
} else {
|
||||
fprintf(stderr,"Syntax error: data2xmovie [options] < infile > outfile\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* error checks */
|
||||
|
||||
if (atomstyle == 0) {
|
||||
fprintf(stderr,"ERROR: must use -style to set atom style\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* defaults */
|
||||
|
||||
natoms = nbonds = nangles = ndihedrals = nimpropers = 0;
|
||||
ntypes = nbondtypes = nangletypes = ndihedtypes = nimprotypes = 0;
|
||||
|
||||
/* read header */
|
||||
|
||||
fgets(line,MAXLINE,stdin);
|
||||
|
||||
while (1) {
|
||||
fgets(line,MAXLINE,stdin);
|
||||
|
||||
if (strspn(line," \t\n\r") == strlen(line)) continue;
|
||||
else if (strstr(line,"atoms")) sscanf(line,"%d",&natoms);
|
||||
else if (strstr(line,"bonds")) sscanf(line,"%d",&nbonds);
|
||||
else if (strstr(line,"angles")) sscanf(line,"%d",&nangles);
|
||||
else if (strstr(line,"dihedrals")) sscanf(line,"%d",&ndihedrals);
|
||||
else if (strstr(line,"impropers")) sscanf(line,"%d",&nimpropers);
|
||||
else if (strstr(line,"atom types")) sscanf(line,"%d",&ntypes);
|
||||
else if (strstr(line,"bond types")) sscanf(line,"%d",&nbondtypes);
|
||||
else if (strstr(line,"angle types")) sscanf(line,"%d",&nangletypes);
|
||||
else if (strstr(line,"dihedral types")) sscanf(line,"%d",&ndihedtypes);
|
||||
else if (strstr(line,"improper types")) sscanf(line,"%d",&nimprotypes);
|
||||
else if (strstr(line,"xlo xhi")) sscanf(line,"%lg %lg",&in.xlo,&in.xhi);
|
||||
else if (strstr(line,"ylo yhi")) sscanf(line,"%lg %lg",&in.ylo,&in.yhi);
|
||||
else if (strstr(line,"zlo zhi")) sscanf(line,"%lg %lg",&in.zlo,&in.zhi);
|
||||
else break;
|
||||
}
|
||||
|
||||
/* compute input box size */
|
||||
|
||||
in.xsize = in.xhi - in.xlo;
|
||||
in.ysize = in.yhi - in.ylo;
|
||||
in.zsize = in.zhi - in.zlo;
|
||||
|
||||
/* write XMOVIE header */
|
||||
|
||||
printf("ITEM: TIMESTEP\n");
|
||||
printf("%d\n",0);
|
||||
printf("ITEM: NUMBER OF ATOMS\n");
|
||||
printf("%d\n",natoms);
|
||||
printf("ITEM: BOX BOUNDS\n");
|
||||
if (outbox) {
|
||||
printf("%g %g\n",out.xlo,out.xhi);
|
||||
printf("%g %g\n",out.ylo,out.yhi);
|
||||
printf("%g %g\n",out.zlo,out.zhi);
|
||||
} else {
|
||||
printf("%g %g\n",in.xlo,in.xhi);
|
||||
printf("%g %g\n",in.ylo,in.yhi);
|
||||
printf("%g %g\n",in.zlo,in.zhi);
|
||||
}
|
||||
|
||||
/* read identifier strings one by one in free-form part of data file */
|
||||
|
||||
token = gettoken(line,1);
|
||||
|
||||
while (token) {
|
||||
|
||||
/* read atoms */
|
||||
|
||||
if (!strcmp(token,"Atoms")) {
|
||||
|
||||
printf("ITEM: ATOMS\n");
|
||||
|
||||
int tag,type,molecule,imagex,imagey,imagez;
|
||||
double x,y,z,radius,density,q;
|
||||
|
||||
for (i = 0; i < natoms; i++) {
|
||||
fgets(line,MAXLINE,stdin);
|
||||
if (unmap) {
|
||||
if (atomstyle == ATOMIC)
|
||||
sscanf(line,"%d %d %lg %lg %lg %d %d %d",
|
||||
&tag,&type,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
else if (atomstyle == BOND)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg %d %d %d",
|
||||
&tag,&molecule,&type,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
else if (atomstyle == ANGLE)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg %d %d %d",
|
||||
&tag,&molecule,&type,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
else if (atomstyle == FULL)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg %lg %d %d %d",
|
||||
&tag,&molecule,&type,&q,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
else if (atomstyle == EAM)
|
||||
sscanf(line,"%d %d %lg %lg %lg %d %d %d",
|
||||
&tag,&type,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
else if (atomstyle == GRANULAR)
|
||||
sscanf(line,"%d %d %lg %lg %lg %lg %lg %d %d %d",
|
||||
&tag,&type,&radius,&density,&x,&y,&z,
|
||||
&imagex,&imagey,&imagez);
|
||||
} else {
|
||||
if (atomstyle == ATOMIC)
|
||||
sscanf(line,"%d %d %lg %lg %lg",
|
||||
&tag,&type,&x,&y,&z);
|
||||
else if (atomstyle == BOND)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg",
|
||||
&tag,&molecule,&type,&x,&y,&z);
|
||||
else if (atomstyle == ANGLE)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg",
|
||||
&tag,&molecule,&type,&x,&y,&z);
|
||||
else if (atomstyle == FULL)
|
||||
sscanf(line,"%d %d %d %lg %lg %lg %lg",
|
||||
&tag,&molecule,&type,&q,&x,&y,&z);
|
||||
else if (atomstyle == EAM)
|
||||
sscanf(line,"%d %d %lg %lg %lg",
|
||||
&tag,&type,&x,&y,&z);
|
||||
else if (atomstyle == GRANULAR)
|
||||
sscanf(line,"%d %d %lg %lg %lg %lg %lg",
|
||||
&tag,&type,&radius,&density,&x,&y,&z);
|
||||
imagez = imagey = imagex = 0;
|
||||
}
|
||||
|
||||
/* unmap atom position if requested */
|
||||
|
||||
if (unmap) {
|
||||
x = x + imagex*in.xsize;
|
||||
y = y + imagey*in.ysize;
|
||||
z = z + imagez*in.zsize;
|
||||
}
|
||||
|
||||
printf("%d %d %g %g %g\n",tag,type,x,y,z);
|
||||
}
|
||||
}
|
||||
|
||||
/* read bonds and replicate */
|
||||
|
||||
else if (!strcmp(token,"Bonds")) {
|
||||
|
||||
printf("ITEM: BONDS\n");
|
||||
|
||||
int n,btype,bond1,bond2;
|
||||
|
||||
for (i = 0; i < nbonds; i++) {
|
||||
fgets(line,MAXLINE,stdin);
|
||||
sscanf(line,"%d %d %d %d",&n,&btype,&bond1,&bond2);
|
||||
printf("%d %d %d\n",btype,bond1,bond2);
|
||||
}
|
||||
}
|
||||
|
||||
/* non-replicated sections - just skip lines */
|
||||
|
||||
else if (!strcmp(token,"Velocities"))
|
||||
skipline(natoms);
|
||||
else if (!strcmp(token,"Angles"))
|
||||
skipline(nangles);
|
||||
else if (!strcmp(token,"Dihedrals"))
|
||||
skipline(ndihedrals);
|
||||
else if (!strcmp(token,"Impropers"))
|
||||
skipline(nimpropers);
|
||||
else if (!strcmp(token,"Masses"))
|
||||
skipline(ntypes);
|
||||
else if (!strcmp(token,"Dipoles"))
|
||||
skipline(ntypes);
|
||||
else if (!strcmp(token,"Pair Coeffs"))
|
||||
skipline(ntypes);
|
||||
else if (!strcmp(token,"Bond Coeffs"))
|
||||
skipline(nbondtypes);
|
||||
else if (!strcmp(token,"Angle Coeffs"))
|
||||
skipline(nangletypes);
|
||||
else if (!strcmp(token,"Dihedral Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"Improper Coeffs"))
|
||||
skipline(nimprotypes);
|
||||
else if (!strcmp(token,"BondBond Coeffs"))
|
||||
skipline(nangletypes);
|
||||
else if (!strcmp(token,"BondAngle Coeffs"))
|
||||
skipline(nangletypes);
|
||||
else if (!strcmp(token,"MiddleBondTorsion Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"EndBondTorsion Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"AngleTorsion Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"AngleAngleTorsion Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"BondBond13 Coeffs"))
|
||||
skipline(ndihedtypes);
|
||||
else if (!strcmp(token,"AngleAngle Coeffs"))
|
||||
skipline(nimprotypes);
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Error in input data file - unknown identifier %s\n",token);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
token = gettoken(line,0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
/* return a LAMMPS keyword from data file
|
||||
if first is 1, non-blank line with token is in line
|
||||
else read until find a non-blank line
|
||||
keyword is all text on line w/out leading & trailing white space
|
||||
read one additional line after non-blank line (assumed blank)
|
||||
return ptr to keyword
|
||||
return NULL if end of file */
|
||||
|
||||
char *gettoken(char *line, int first)
|
||||
{
|
||||
char buffer[MAXLINE];
|
||||
|
||||
/* read upto non-blank line plus 1 following line
|
||||
eof is set to 1 if any read hits end-of-file */
|
||||
|
||||
int eof = 0;
|
||||
|
||||
if (!first) if (fgets(line,MAXLINE,stdin) == NULL) eof = 1;
|
||||
while (eof == 0 && strspn(line," \t\n\r") == strlen(line))
|
||||
if (fgets(line,MAXLINE,stdin) == NULL) eof = 1;
|
||||
if (fgets(buffer,MAXLINE,stdin) == NULL) eof = 1;
|
||||
|
||||
/* if eof, return NULL */
|
||||
|
||||
if (eof) return NULL;
|
||||
|
||||
/* bracket non-whitespace portion of line */
|
||||
|
||||
int start = strspn(line," \t\n\r");
|
||||
int stop = strlen(line) - 1;
|
||||
while (line[stop] == ' ' || line[stop] == '\t'
|
||||
|| line[stop] == '\n' || line[stop] == '\r') stop--;
|
||||
line[stop+1] = '\0';
|
||||
|
||||
/* return ptr to keyword */
|
||||
|
||||
return &line[start];
|
||||
}
|
||||
|
||||
/* read n lines and ignore */
|
||||
|
||||
void skipline(int n)
|
||||
{
|
||||
char line[1000];
|
||||
|
||||
while (n) {
|
||||
fgets(line,MAXLINE,stdin);
|
||||
n--;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
This directory used to contain utility scripts for using VMD to
|
||||
visualize and analyze LAMMPS trajectories. As of April 2010 all of the
|
||||
scripts and many additional features have been merged into the topotools
|
||||
plugin that is bundled with VMD. Updates between VMD releases are here:
|
||||
http://sites.google.com/site/akohlmey/software/topotools
|
||||
This page also contains detailed documentation and some tutorials.
|
||||
|
||||
These scripts within VMD and the plugin for native LAMMPS dump files are
|
||||
are maintained by Axel Kohlmeyer <akohlmey@gmail.com>; please contact
|
||||
him through the LAMMPS mailing list in case of problems.
|
||||
|
||||
Below are a few comments on support for LAMMPS in VMD.
|
||||
|
||||
-------------------------
|
||||
|
||||
1. File formats and VMD limitations
|
||||
|
||||
VMD currently supports reading several but not all file formats
|
||||
that LAMMPS can generate. Supported are: atom (text mode), custom
|
||||
(text mode, only some fields are directly supported, please see
|
||||
below for more details), dcd, xyz and xtc. Cfg and binary native
|
||||
dump files are not supported (06/2012). The new molfile dump style
|
||||
in addition allows to use VMD molfile plugins to write dumps in
|
||||
any format that is supported by VMD.
|
||||
|
||||
However VMD requires all frames of a file to have the same number of
|
||||
atoms. If the number of atoms changes between two frames, the file
|
||||
reader will stop. The topotools plugin has a special scripted file
|
||||
reader for .xyz files that can generate the necessary padding so that
|
||||
the file can still be read into VMD. Whether an atom is real or
|
||||
"invisible" is then flagged in the "user" field. For efficiency
|
||||
reasons this script will not preserve atom identity between frames.
|
||||
|
||||
2. Topology files, a.k.a. as "data" files
|
||||
|
||||
The topotools plugin also contains a read and write option for LAMMPS
|
||||
data files. This reader will try to preserve as much information as
|
||||
possible and will also store useful information as comments upon
|
||||
writing. It does not store or read coefficient data. In combination
|
||||
with other functionality in topotools complete topologies for rather
|
||||
complicated systems for LAMMPS can be build with VMD scripting.
|
||||
|
||||
3. Reading custom data fields into VMD
|
||||
|
||||
At this moment VMD only supports reading coordinates and velocities
|
||||
(if present) as per timestep data. Everthing else is just taken
|
||||
from the first frame or whatever file was used to generate this
|
||||
structure information. Through setting the environment variable
|
||||
LAMMPSREMAPFIELDS, custom properties can be mapped to the x, y, z,
|
||||
vx, vy, vz data fields and then accessed from within VMD. For
|
||||
example to store radius and charge of a particle in the vx and vy
|
||||
fields, respectively set this variable to "vx=radius,vy=q". Future
|
||||
versions of VMD will allow more flexibility.
|
||||
|
||||
4. Recovering information about elements
|
||||
|
||||
Colorization in VMD is by default based on atom names, yet LAMMPS
|
||||
requires identification of atoms by consecutive numbers starting at
|
||||
1. With the option of reading a LAMMPS data file, additional
|
||||
information is provided that can help to recover some of this
|
||||
data. 'topo guessatom element mass' will guess the atom's element
|
||||
name from it mass (with fuzz, where possible).
|
||||
|
||||
5. Reading files from the command line
|
||||
|
||||
Converting a LAMMPS data file to a .psf file can be very convenient
|
||||
for loading trajectories from the command line. This conversion is
|
||||
done with
|
||||
|
||||
topo readlammpsdata data.rhodo full
|
||||
animate write psf rhodo.psf
|
||||
|
||||
In the future you can now load this PSF file first and then the
|
||||
LAMMPS dump file(s) (or a more compact and faster loading DCD or
|
||||
XTC file) with:
|
||||
|
||||
vmd micelle.psf -lammpstrj dump.micelle
|
||||
|
||||
Note how the -lammpstrj flag will tell VMD that dump.micelle is a
|
||||
lammps trajectory file.
|
|
@ -57,8 +57,8 @@ ifeq ($(COMPILER),gnu)
|
|||
CPP = g++ # C++ Compiler
|
||||
CC = gcc # C compiler
|
||||
AR = ar
|
||||
DBUG = -O2 # -g -DDEBUG -DNANCHECK -Wall -pedantic #-ansi
|
||||
OPT = #-O3
|
||||
DBUG = -O2 -g -Wall #-DDEBUG -DNANCHECK -Wall -pedantic #-ansi
|
||||
OPT = #-O3 -g -Wall
|
||||
endif
|
||||
|
||||
ifeq ($(COMPILER),mpi)
|
||||
|
@ -111,7 +111,12 @@ OBJ_DIR = $(HOBJ_DIR)
|
|||
THIS_OBJ = $(OBJ_DIR)/asphere_vis.o $(GRPHICS_LIB) $(MATH_LIB) $(ALL_LIB)
|
||||
EXECS = $(BIN_DIR)/asphere_vis
|
||||
|
||||
all: $(EXECS)
|
||||
all: paths $(EXECS)
|
||||
|
||||
paths: $(HOBJ_DIR) $(BIN_DIR)
|
||||
|
||||
$(HOBJ_DIR) $(BIN_DIR):
|
||||
mkdir $@
|
||||
|
||||
libraries:
|
||||
cd $(ALL_DIR); make; cd $(MATH_DIR); make; cd $(GRID_DIR); make; \
|
||||
|
|
|
@ -86,28 +86,6 @@ To use the logplot.py script you need to have GnuPlot installed on
|
|||
your system and its executable "gnuplot" in your path.
|
||||
|
||||
To use any of the scripts which load the dump module to read LAMMPS
|
||||
dump files, you must have the Python package Numeric installed in your
|
||||
Python. See http://numeric.scipy.org.
|
||||
dump files, you must have the Python package NumPy installed in your
|
||||
Python. See https://www.numpy.org and https://www.scipy.org/scipylib/download.html
|
||||
|
||||
Note that the Pizza.py modules use the older (but still popular)
|
||||
Numeric package, not the newer numarray package.
|
||||
|
||||
If Numeric is already installed in your Python, you should be able to
|
||||
type the following without getting an error:
|
||||
|
||||
>>> import Numeric
|
||||
|
||||
Numeric can be downloaded from SourceForge at this WWW site:
|
||||
|
||||
http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351
|
||||
|
||||
As of July 2007, Version 24.2 was fine. Once unpacked, you can type
|
||||
the following from the Numeric directory to install it in your Python.
|
||||
|
||||
sudo python setup.py install
|
||||
|
||||
On my Linux box, when Numeric installed itself under the Python lib in
|
||||
/usr/local, it did not set all file permsissions correctly to allow a
|
||||
user to import it. So I also needed to do this:
|
||||
|
||||
sudo chmod -R 755 /usr/local/lib/python2.5/site-packages/Numeric
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
CC = gcc
|
||||
LN = gcc
|
||||
OPTIM = -O2 -finline-functions -g
|
||||
XLIBDIR = -L/usr/X11R6/lib
|
||||
XINCLUDE =
|
||||
DEFINES = -DMISSINGDEFS -D_POSIX_SOURCE -DUSEPRIVATE -DINCL_FLOAT
|
||||
WARNS = -Wimplicit -Wunused -Wmissing-prototypes
|
||||
CCOPTS = -c $(OPTIM) $(DEFINES) $(WARNS) $(XINCLUDE)
|
||||
LNOPTS = $(OPTIM)
|
||||
|
||||
LIBS = $(XLIBDIR) -lX11 -lXaw -lm
|
||||
|
||||
# try this version on a Mac
|
||||
#LIBS = $(XLIBDIR) -lX11 -lXaw -lXt -lXext -lXmu -lXpm
|
||||
|
||||
OBJS = xmovie.o \
|
||||
control.o \
|
||||
scene.o \
|
||||
read.o \
|
||||
hpsort.o
|
||||
|
||||
EXES = xmovie dummy tobinary toascii
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CCOPTS) $*.c
|
||||
|
||||
xmovie: $(OBJS)
|
||||
$(CC) $(CCOPTS) version.c
|
||||
$(LN) -o xmovie $(LNOPTS) version.o $(OBJS) $(LIBS)
|
||||
|
||||
xmovie.o: xmovie.h resource.h xmovie.c
|
||||
control.o: xmovie.h control.c
|
||||
scene.o: xmovie.h scene.c
|
||||
read.o: xmovie.h read.c
|
||||
hpsort.o: hpsort.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ $(EXES)
|
||||
|
||||
tar:
|
||||
tar cvf xmovie.tar Makefile *.c *.h
|
||||
compress xmovie.tar
|
||||
uuencode xmovie.tar.Z xmovie.tar.Z > xmovie.tar.Z.uu
|
||||
|
||||
clean_obj:
|
||||
rm -f *.o
|
||||
|
||||
all: $(EXES)
|
||||
|
||||
dummy: dummy.o
|
||||
$(LN) $(LNOPTS) -o dummy dummy.o -lm
|
||||
|
||||
dummy.o: dummy.c
|
||||
|
||||
toascii: toascii.o
|
||||
$(LN) $(LNOPTS) -o toascii toascii.o
|
||||
|
||||
toascii.o: toascii.c
|
||||
|
||||
tobinary: tobinary.o
|
||||
$(LN) $(LNOPTS) -o tobinary tobinary.o
|
||||
|
||||
tobinary.o: tobinary.c
|
|
@ -1,51 +0,0 @@
|
|||
Xmovie is an X-based visualization package that can reads particle
|
||||
data in a simple text format. LAMMPS output files are in this format
|
||||
(by default). Xmovie displays 2d projections of 3d (or 2d) data sets.
|
||||
While simple, it is extremely fast, and often useful for debugging.
|
||||
|
||||
Xmovie was written by Mike Uttormark, while visiting Sandia, in the
|
||||
summer of 1994. Subsequent small changes have been made by Steve
|
||||
Plimpton.
|
||||
|
||||
To make xmovie for your platform, edit the top section of the Makefile
|
||||
appropriately for your machine. You will need to point at the correct
|
||||
X libraries for xmovie to compile and link properly.
|
||||
|
||||
Once you have an xmovie executable you can test it by typing:
|
||||
|
||||
xmovie dummy.dat
|
||||
|
||||
A control window and a display window should pop open. Move the
|
||||
"thickness" slider all the way to the right and click "Start". You
|
||||
should see a small white ball oscillate back and forth in the display.
|
||||
|
||||
The examples directory in the LAMMPS distribution has several
|
||||
simulations that can be run with LAMMPS to produce dump.* files that
|
||||
you can use xmovie to visualize. The Movies page of the LAMMPS WWW
|
||||
Site has animations of these simulations that were produced by
|
||||
converting saved xmovie snapshots to MPEG files (via ImageMagick's
|
||||
convert program). Note that LAMMPS output is scaled by default (so
|
||||
all coordinates are from 0 to 1). Thus you need to run xmovie like
|
||||
this:
|
||||
|
||||
xmovie -scale dump.*
|
||||
|
||||
to see the snapshot you expect.
|
||||
|
||||
The xmovie control window options should be self-explanatory. You are
|
||||
always viewing a 2d projection of your 2d or 3d snapshot; the
|
||||
"position" and "thickness" sliders control the range of the slab of
|
||||
atoms being projected. You will not always see a snapshot when xmovie
|
||||
begins, unless you push the "thickness" slider to the right.
|
||||
|
||||
Type xmovie to see a list of command-line options and info on file
|
||||
formats.
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
If the xpm.h file is not on a system, it must be downloaded from
|
||||
somewhere
|
||||
|
||||
Needed to build on IBM cheetah at ORNL:
|
||||
#include </apps/xpm/3.4k/rs_aix51/include/X11/xpm.h>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
! Resources that users may want to change.
|
||||
! Add these lines to your .Xdefaults file or
|
||||
! merge them using xrdb -merge
|
||||
!
|
||||
|
||||
!
|
||||
! colors used for drawing atoms
|
||||
!
|
||||
|
||||
#ifdef COLOR
|
||||
|
||||
XMovie.*.scene.*.foreground: red
|
||||
XMovie.*.scene.*.background: black
|
||||
XMovie.*.scene.width: 600
|
||||
XMovie.*.scene.height: 600
|
||||
|
||||
#else
|
||||
|
||||
XMovie.*.scene.*.foreground: black
|
||||
XMovie.*.scene.*.background: white
|
||||
|
||||
#endif
|
||||
|
||||
!
|
||||
! Default slider positions (0.0 -> 1.0)
|
||||
!
|
||||
|
||||
XMovie.*.speedbar.topOfThumb: 1.0
|
||||
XMovie.*.positionbar.topOfThumb: 0.50
|
||||
XMovie.*.thicknessbar.topOfThumb: 1.0
|
||||
|
||||
!
|
||||
! Default viewing axis
|
||||
! set only one, or chaos will surely ensue.
|
||||
! need to turn z off before turning others on
|
||||
!
|
||||
|
||||
! XMovie.*.z.state: False
|
||||
! XMovie.*.y.state: True
|
||||
|
||||
! XMovie.*.x.state: True
|
||||
! XMovie.*.z.state: True
|
||||
|
||||
!
|
||||
! Default viewing direction
|
||||
! again, set only one.
|
||||
! turn vminus off before turning vplus on
|
||||
!
|
||||
|
||||
! XMovie.*.vminus.state: False
|
||||
! XMovie.*.vplus.state: True
|
File diff suppressed because it is too large
Load Diff
|
@ -1,63 +0,0 @@
|
|||
/* program to generate dummy data set */
|
||||
/* Mike Uttormark 7/16/92 */
|
||||
/* Sandia Nat'l Labs 1421 */
|
||||
/* On leave from University of Wisconsin--Madison */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define RANGE 5.0
|
||||
#define STEPS 2000
|
||||
#define PI 3.14159
|
||||
#define S 50
|
||||
|
||||
#ifdef MISSINGDEFS
|
||||
int printf(char *, ...);
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j, step, npart;
|
||||
int nsteps;
|
||||
|
||||
if (argc < 2)
|
||||
nsteps = STEPS;
|
||||
else
|
||||
nsteps = atoi(argv[1]);
|
||||
|
||||
if (argc < 3)
|
||||
npart = 1;
|
||||
else
|
||||
npart = atoi(argv[2]);
|
||||
|
||||
for(step = 0; step < nsteps; step++) {
|
||||
|
||||
printf("ITEM: TIME\n%g\n", (float) step);
|
||||
|
||||
if (step == 0) {
|
||||
printf("ITEM: BOUNDS\n");
|
||||
for (i = 3; i; i--)
|
||||
printf("%g, %g\n", -RANGE, RANGE);
|
||||
}
|
||||
printf("ITEM: POSITIONS\n");
|
||||
|
||||
for( j = 0; j < npart; j++)
|
||||
printf("%i, %i, %g, %g, %g\n",
|
||||
j+1,
|
||||
1 + j%4,
|
||||
RANGE*sin(2*PI*(step+j)/S),
|
||||
RANGE*cos(0.25*PI*(step+j)/S),
|
||||
RANGE*sin(5*PI*(step+j)/S));
|
||||
|
||||
if (npart > 1) {
|
||||
printf("ITEM: BONDS\n");
|
||||
for ( j = 0; j < npart-1; j++)
|
||||
printf("%i %i %i\n", 1 + j%4, j+1, j+2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,43 +0,0 @@
|
|||
/* Numerical Recipes heap sort, modified to be like C library qsort */
|
||||
|
||||
/* accepts arbitrary objects to be sorted, user provides compare function
|
||||
this routine sorts a F77-style array indexed from 1-n
|
||||
thus you MUST call it from C with hpsort(ra-1, ) to offset C ptr by -1
|
||||
also added multiply-array-index-by-size to enable arbitrary objects
|
||||
*/
|
||||
|
||||
void hpsort(char *ra, int n, int size,
|
||||
int (*cmp)(const void *, const void *))
|
||||
{
|
||||
unsigned long i,ir,j,l;
|
||||
char *rra;
|
||||
|
||||
if (n < 2) return;
|
||||
l = (n >> 1)+1;
|
||||
ir = n;
|
||||
rra = (char *) malloc(size);
|
||||
for (;;) {
|
||||
if (l > 1) {
|
||||
memcpy(rra,&ra[(--l)*size],size);
|
||||
} else {
|
||||
memcpy(rra,&ra[ir*size],size);
|
||||
memcpy(&ra[ir*size],&ra[1*size],size);
|
||||
if (--ir == 1) {
|
||||
memcpy(&ra[1*size],rra,size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = l;
|
||||
j = l+l;
|
||||
while (j <= ir) {
|
||||
if (j < ir && (*cmp)(&ra[j*size],&ra[(j+1)*size]) < 0) j++;
|
||||
if ((*cmp)(rra,&ra[j*size]) < 0) {
|
||||
memcpy(&ra[i*size],&ra[j*size],size);
|
||||
i = j;
|
||||
j <<= 1;
|
||||
} else j = ir+1;
|
||||
}
|
||||
memcpy(&ra[i*size],rra,size);
|
||||
}
|
||||
free(rra);
|
||||
}
|
1239
tools/xmovie/read.c
1239
tools/xmovie/read.c
File diff suppressed because it is too large
Load Diff
|
@ -1,244 +0,0 @@
|
|||
/* **************************************************************** */
|
||||
/* Resource database values */
|
||||
/* Can be overridden from .Xdefaults */
|
||||
|
||||
String FallbackResources[] = {
|
||||
"*.foreground: black",
|
||||
"*.background: white",
|
||||
|
||||
"*.horizDistance: 4",
|
||||
"*.vertDistance: 4",
|
||||
|
||||
"*Dialog*Translations: #override \\n\
|
||||
<Key>Return: NoOp()\\n\
|
||||
<Key>Up: NoOp()\\n\
|
||||
<Key>Down: NoOp()\\n\
|
||||
Ctrl<Key>C: NoOp()\\n\
|
||||
Ctrl<Key>I: NoOp()\\n\
|
||||
Ctrl<Key>J: NoOp()\\n\
|
||||
Ctrl<Key>M: NoOp()\\n\
|
||||
Ctrl<Key>N: NoOp()\\n\
|
||||
Ctrl<Key>O: NoOp()\\n\
|
||||
Ctrl<Key>P: NoOp()\\n\
|
||||
Ctrl<Key>Q: NoOp()\\n\
|
||||
Ctrl<Key>R: NoOp()\\n\
|
||||
Ctrl<Key>S: NoOp()\\n\
|
||||
Ctrl<Key>V: NoOp()\\n\
|
||||
Ctrl<Key>X: NoOp()\\n\
|
||||
Ctrl<Key>Z: NoOp()\\n\
|
||||
Meta<Key>V: NoOp()",
|
||||
|
||||
"*.Toggle.Translations: #replace \\n\
|
||||
<EnterWindow>: highlight(Always) \\n\
|
||||
<LeaveWindow>: unhighlight() \\n\
|
||||
<Btn1Down>,<Btn1Up>: set()notify() \\n\
|
||||
<Btn2Down>,<Btn2Up>: set()notify() \\n\
|
||||
<Btn3Down>,<Btn3Up>: set()notify()",
|
||||
|
||||
"*.quit.label: Quit",
|
||||
"*.start.label: Start",
|
||||
"*.stop.label: Stop",
|
||||
"*.restart.label: Restart",
|
||||
"*.step.label: +Step",
|
||||
"*.back.label: -Step",
|
||||
"*.save.label: Save",
|
||||
"*.color.label: Color",
|
||||
|
||||
"*.start.fromHoriz: quit",
|
||||
"*.stop.fromHoriz: start",
|
||||
"*.restart.fromHoriz: stop",
|
||||
"*.step.fromHoriz: restart",
|
||||
"*.back.fromHoriz: step",
|
||||
"*.save.fromHoriz: back",
|
||||
"*.color.fromHoriz: save",
|
||||
|
||||
"*.quit.popup.dialog.label: Do you really want to Quit?",
|
||||
"*.quit.popup.dialog.ok.label: Ok",
|
||||
"*.quit.popup.dialog.cancel.label: Cancel",
|
||||
"*.quit.popup.overrideRedirect: True",
|
||||
|
||||
"*.save.menu.atoms.label: Animaton Off",
|
||||
"*.save.menu.bonds.label: Animation On",
|
||||
"*.save.menu.background.label: This Snapshot",
|
||||
|
||||
"*.color.menu.atoms.label: Atoms",
|
||||
"*.color.menu.bonds.label: Bonds",
|
||||
"*.color.menu.background.label: Background",
|
||||
"*.color.menu.filecolor.label: from File",
|
||||
|
||||
"*.atomcolors.title: xmovie atom colors",
|
||||
|
||||
"*.atomcolors.*.apply.label: Apply",
|
||||
"*.atomcolors.*.cancel.label: Dismiss",
|
||||
|
||||
"*.atomcolors.*.Form.Dialog.borderWidth: 2",
|
||||
"*.atomcolors.*.Dialog.*.resizable: True",
|
||||
"*.atomcolors.*.Dialog.Text.width: 200",
|
||||
"*.atomcolors.*.Form.Form.Dialog.borderWidth: 0",
|
||||
"*.atomcolors.*.Form.Form.borderWidth: 2",
|
||||
|
||||
"*.bondcolors.title: xmovie bond colors",
|
||||
|
||||
"*.bondcolors.*.apply.label: Apply",
|
||||
"*.bondcolors.*.cancel.label: Dismiss",
|
||||
|
||||
"*.bondcolors.*.Form.Dialog.borderWidth: 2",
|
||||
"*.bondcolors.*.Dialog.*.resizable: True",
|
||||
"*.bondcolors.*.Dialog.Text.width: 200",
|
||||
"*.bondcolors.*.Form.Form.Dialog.borderWidth: 0",
|
||||
"*.bondcolors.*.Form.Form.borderWidth: 2",
|
||||
|
||||
"*.backcolors.title: xmovie background colors",
|
||||
|
||||
"*.backcolors.*.apply.label: Apply",
|
||||
"*.backcolors.*.cancel.label: Dismiss",
|
||||
|
||||
"*.backcolors.*.bg.label: Background Color",
|
||||
"*.backcolors.*.bg.value: black",
|
||||
"*.backcolors.*.Dialog.Text.width: 200",
|
||||
"*.backcolors.*.Dialog.*.resizable: True",
|
||||
|
||||
"*.filecolors.title: xmovie colors from file",
|
||||
|
||||
"*.filecolors.*.apply.label: Apply",
|
||||
"*.filecolors.*.cancel.label: Dismiss",
|
||||
|
||||
"*.filecolors.*.file.label: File of color settings",
|
||||
"*.filecolors.*.file.value: xmovie.colors",
|
||||
"*.filecolors.*.Dialog.Text.width: 200",
|
||||
"*.filecolors.*.Dialog.*.resizable: True",
|
||||
|
||||
"*.sceneshell.title: xmovie scene",
|
||||
"*.scene.foreground: white",
|
||||
"*.scene.background: black",
|
||||
"*.scene.width: 400",
|
||||
"*.scene.height: 400",
|
||||
"*.scene.Translations: #override \\n\
|
||||
<Expose>: ExposeScene()",
|
||||
|
||||
"*.Scrollbar.orientation: horizontal",
|
||||
"*.Scrollbar.height: 25",
|
||||
"*.Scrollbar.width: 200",
|
||||
"*.Scrollbar.shown: 0.06",
|
||||
|
||||
"*.Label.resize: False",
|
||||
|
||||
"*.time.label: Time: ?",
|
||||
"*.time.width: 406",
|
||||
"*.time.fromVert: quit",
|
||||
|
||||
"*.speedbar.fromVert: time",
|
||||
"*.speedbar.topOfThumb: 0.25",
|
||||
|
||||
"*.speed.fromHoriz: speedbar",
|
||||
"*.speed.fromVert: time",
|
||||
"*.speed.label: Speed: ?",
|
||||
"*.speed.width: 200",
|
||||
"*.speed.height: 25",
|
||||
"*.speed.resize: False",
|
||||
|
||||
"*.positionbar.fromVert: speedbar",
|
||||
"*.positionbar.topOfThumb: 0.5",
|
||||
|
||||
"*.position.fromHoriz: positionbar",
|
||||
"*.position.fromVert: speed",
|
||||
"*.position.label: Position: ?",
|
||||
"*.position.width: 200",
|
||||
"*.position.height: 25",
|
||||
"*.position.resize: False",
|
||||
|
||||
"*.thicknessbar.fromVert: positionbar",
|
||||
"*.thicknessbar.topOfThumb: 0.1",
|
||||
|
||||
"*.thickness.fromHoriz: thicknessbar",
|
||||
"*.thickness.fromVert: position",
|
||||
"*.thickness.label: Speed: ?",
|
||||
"*.thickness.width: 200",
|
||||
"*.thickness.height: 25",
|
||||
"*.thickness.resize: False",
|
||||
|
||||
"*.Scrollbar.Translations: #override \\n\
|
||||
<Btn1Down>: StartScroll(Continuous)MoveThumb()NotifyThumb() \\n\
|
||||
<Btn3Down>: StartScroll(Continuous)MoveThumb()NotifyThumb() \\n\
|
||||
<Btn1Motion>: MoveThumb()NotifyThumb() \\n\
|
||||
<Btn3Motion>: MoveThumb()NotifyThumb()",
|
||||
|
||||
"*.axis.label: Viewing Axis",
|
||||
"*.axis.fromVert: thicknessbar",
|
||||
"*.axis.width: 200",
|
||||
"*.axis.height: 25",
|
||||
|
||||
"*.x.fromVert: axis",
|
||||
"*.x.label: X",
|
||||
"*.x.width: 26",
|
||||
"*.x.height: 25",
|
||||
"*.x.horizDistance: 61",
|
||||
|
||||
"*.y.fromVert: axis",
|
||||
"*.y.fromHoriz: x",
|
||||
"*.y.label: Y",
|
||||
"*.y.width: 26",
|
||||
"*.y.height: 25",
|
||||
"*.y.radioGroup: x",
|
||||
|
||||
"*.z.fromVert: axis",
|
||||
"*.z.fromHoriz: y",
|
||||
"*.z.label: Z",
|
||||
"*.z.width: 26",
|
||||
"*.z.height: 25",
|
||||
"*.z.radioGroup: x",
|
||||
"*.z.state: True",
|
||||
|
||||
"*.viewdir.label: Viewing Direction",
|
||||
"*.viewdir.fromVert: x",
|
||||
"*.viewdir.width: 200",
|
||||
"*.viewdir.height: 25",
|
||||
|
||||
"*.vplus.fromVert: viewdir",
|
||||
"*.vplus.horizDistance: 76",
|
||||
"*.vplus.label: +",
|
||||
"*.vplus.height: 25",
|
||||
"*.vplus.width: 26",
|
||||
|
||||
"*.vminus.fromVert: viewdir",
|
||||
"*.vminus.fromHoriz: vplus",
|
||||
"*.vminus.label: -",
|
||||
"*.vminus.width: 26",
|
||||
"*.vminus.height: 25",
|
||||
"*.vminus.radioGroup: vplus",
|
||||
"*.vminus.state: True",
|
||||
|
||||
"*.motiondir.label: Movie Direction",
|
||||
"*.motiondir.fromVert: vplus",
|
||||
"*.motiondir.width: 200",
|
||||
"*.motiondir.height: 25",
|
||||
|
||||
"*.mplus.fromVert: motiondir",
|
||||
"*.mplus.horizDistance: 12",
|
||||
"*.mplus.label: Forward",
|
||||
"*.mplus.width: 90",
|
||||
"*.mplus.height: 25",
|
||||
"*.mplus.state: True",
|
||||
|
||||
"*.mminus.fromVert: motiondir",
|
||||
"*.mminus.fromHoriz: mplus",
|
||||
"*.mminus.label: Backward",
|
||||
"*.mminus.width: 90",
|
||||
"*.mminus.height: 25",
|
||||
"*.mminus.radioGroup: mplus",
|
||||
|
||||
"*.axes.fromVert: thickness",
|
||||
"*.axes.fromHoriz: axis",
|
||||
"*.axes.width: 200",
|
||||
"*.axes.height: 177",
|
||||
"*.axes.resize: False",
|
||||
"*.axes.Translations: #override \\n\
|
||||
<Expose>: ExposeAxes()",
|
||||
|
||||
"*.read.fromVert: mplus",
|
||||
"*.read.height: 100",
|
||||
"*.read.width: 406",
|
||||
"*.read.resize: False",
|
||||
|
||||
NULL,
|
||||
};
|
|
@ -1,673 +0,0 @@
|
|||
/* **************************************************************** */
|
||||
/* functions to deal with drawing atoms, etc. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Shell.h>
|
||||
|
||||
#include <X11/Xaw/Label.h>
|
||||
#include <X11/Xaw/Cardinals.h>
|
||||
|
||||
#include <X11/xpm.h>
|
||||
|
||||
#include "xmovie.h"
|
||||
|
||||
/* hard offsets so we dont draw on exact edge of screen */
|
||||
|
||||
#define HOFFSET 5
|
||||
#define VOFFSET 5
|
||||
|
||||
typedef XArc POINT;
|
||||
typedef XSegment LINE;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local prototypes */
|
||||
|
||||
PRIVATE LINE *ClipAndScaleLines(BOND *b, int cnt, int *nlines);
|
||||
PRIVATE POINT *ClipAndScalePoints(POSITION *p, int cnt, Dimension diam,
|
||||
int *npoints);
|
||||
PRIVATE void DrawPoints(Display *display, Drawable drawable, GC gc,
|
||||
POINT *points, int npoints);
|
||||
PRIVATE void DrawLines(Display *display, Drawable drawable, GC gc,
|
||||
LINE *lines, int nlines);
|
||||
PRIVATE void SceneDraw(void);
|
||||
PRIVATE void SetAllColors(void);
|
||||
PRIVATE void MotionUpdate(void);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local data */
|
||||
|
||||
static Widget Scene;
|
||||
static Widget Shell;
|
||||
static Pixmap Buffer;
|
||||
|
||||
static GC *gc = (GC *) NULL;
|
||||
static GC *bondgc = (GC *) NULL;
|
||||
static GC bggc;
|
||||
static int first = 1;
|
||||
static Dimension Height, Width;
|
||||
|
||||
XtIntervalId TimeOut = (XtIntervalId) NULL;
|
||||
static String null_string = "";
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
Widget CreateScene(Widget parent, char *name)
|
||||
{
|
||||
Shell = XtCreatePopupShell("sceneshell", transientShellWidgetClass,
|
||||
parent, NULL, ZERO);
|
||||
|
||||
Scene = XtVaCreateManagedWidget(name, labelWidgetClass, Shell,
|
||||
XtNlabel, &null_string, NULL);
|
||||
|
||||
gc = (GC *) XtMalloc(Common.natomcolors * sizeof(GC));
|
||||
bondgc = (GC *) XtMalloc(Common.nbondcolors * sizeof(GC));
|
||||
|
||||
XtPopup(Shell, XtGrabNone);
|
||||
|
||||
return(Scene);
|
||||
}
|
||||
|
||||
PRIVATE void SceneDraw(void)
|
||||
{
|
||||
DATA *dptr;
|
||||
POINT *points;
|
||||
LINE *lines;
|
||||
POSITION *p;
|
||||
BOND *b;
|
||||
int i;
|
||||
int npoints, nlines;
|
||||
char s[40];
|
||||
static int last_step = -1;
|
||||
|
||||
if (!XtIsRealized(Scene)) return;
|
||||
|
||||
if (first) {
|
||||
SetAllColors();
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/* Clear everything */
|
||||
|
||||
if (Common.step >= Common.ndata) return;
|
||||
if (Common.step < 0) return;
|
||||
|
||||
XFillRectangle(XtDisplay(Scene), Buffer, bggc, 0, 0,
|
||||
Width, Height);
|
||||
|
||||
/* XClearWindow(XtDisplay(Scene), XtWindow(Scene)); */
|
||||
|
||||
/* find the data */
|
||||
|
||||
dptr = Common.dataptr + Common.step;
|
||||
|
||||
/* loop over colors */
|
||||
|
||||
b = dptr->bonds;
|
||||
for(i = 0; i < Common.nbondcolors; i++) {
|
||||
if (Common.bonds_visible[i]) {
|
||||
lines = ClipAndScaleLines(b, dptr->nbtypes[i],&nlines);
|
||||
DrawLines(XtDisplay(Scene), Buffer, bondgc[i],
|
||||
lines, nlines);
|
||||
}
|
||||
b += dptr->nbtypes[i];
|
||||
}
|
||||
|
||||
p = dptr->positions;
|
||||
for(i = 0; i < Common.natomcolors; i++){
|
||||
if (Common.atoms_visible[i]) {
|
||||
points = ClipAndScalePoints(p, dptr->natypes[i],
|
||||
Common.diameter[i], &npoints);
|
||||
DrawPoints(XtDisplay(Scene), Buffer, gc[i], points,
|
||||
npoints);
|
||||
}
|
||||
p += dptr->natypes[i];
|
||||
}
|
||||
|
||||
XCopyArea(XtDisplay(Scene), Buffer, XtWindow(Scene), bggc,
|
||||
0, 0, Width, Height, 0, 0);
|
||||
|
||||
XFlush(XtDisplay(Scene));
|
||||
|
||||
if (Common.step == last_step) return;
|
||||
last_step = Common.step;
|
||||
|
||||
sprintf(s,"Time: %g Frame: %i", dptr->time, Common.step+1);
|
||||
SetTime(s);
|
||||
}
|
||||
|
||||
PRIVATE void MotionUpdate(void)
|
||||
{
|
||||
int next_step;
|
||||
|
||||
SceneUpdate();
|
||||
|
||||
if (Common.saveflag) {
|
||||
char str[24];
|
||||
if (Common.step < 10)
|
||||
sprintf(str,"image00%d.xpm",Common.step);
|
||||
else if (Common.step < 100)
|
||||
sprintf(str,"image0%d.xpm",Common.step);
|
||||
else
|
||||
sprintf(str,"image%d.xpm",Common.step);
|
||||
XpmWriteFileFromPixmap(XtDisplay(Scene),str,Buffer,NULL,NULL);
|
||||
}
|
||||
|
||||
if (!Common.motion) return;
|
||||
|
||||
next_step = CoerceStep(Common.step + Common.dstep);
|
||||
|
||||
if (next_step == Common.step) {
|
||||
RemoveMotion();
|
||||
return;
|
||||
}
|
||||
|
||||
Common.step = next_step;
|
||||
|
||||
TimeOut = (XtIntervalId) NULL;
|
||||
|
||||
InstallMotion();
|
||||
}
|
||||
|
||||
void SceneUpdate(void)
|
||||
{
|
||||
|
||||
if (!Common.init) return;
|
||||
|
||||
/* Common.step = CoerceStep(Common.step); */
|
||||
|
||||
SceneDraw();
|
||||
}
|
||||
|
||||
void SceneSave(void)
|
||||
{
|
||||
char str[24];
|
||||
sprintf(str,"image.%d.xpm",Common.step);
|
||||
XpmWriteFileFromPixmap(XtDisplay(Scene),str,Buffer,NULL,NULL);
|
||||
}
|
||||
|
||||
int CoerceStep(int step)
|
||||
{
|
||||
if (step >= Common.ndata) return (Common.ndata-1);
|
||||
if (step < 0) return(0);
|
||||
return(step);
|
||||
}
|
||||
|
||||
void ExposeScene(Widget w, XEvent *event, String *strings,
|
||||
Cardinal *nstrings)
|
||||
{
|
||||
NewDataSetup();
|
||||
SceneDraw();
|
||||
}
|
||||
|
||||
|
||||
void InstallMotion(void)
|
||||
{
|
||||
Common.motion = 1;
|
||||
|
||||
if (TimeOut == (XtIntervalId) NULL)
|
||||
TimeOut = XtAppAddTimeOut(XtWidgetToApplicationContext(Scene),
|
||||
Common.delay,
|
||||
(XtTimerCallbackProc) MotionUpdate, NULL);
|
||||
}
|
||||
|
||||
void RemoveMotion(void)
|
||||
{
|
||||
if (!Common.motion) return;
|
||||
|
||||
Common.motion = 0;
|
||||
Common.step = CoerceStep(Common.step - Common.dstep);
|
||||
|
||||
if (TimeOut != (XtIntervalId) NULL) XtRemoveTimeOut(TimeOut);
|
||||
TimeOut = (XtIntervalId) NULL;
|
||||
}
|
||||
|
||||
void SceneSize(Dimension *width, Dimension *height)
|
||||
{
|
||||
XtVaGetValues(Scene, XtNwidth, width, XtNheight, height, NULL);
|
||||
}
|
||||
|
||||
PRIVATE POINT *ClipAndScalePoints(POSITION *pos, int cnt, Dimension diam,
|
||||
int *npoints)
|
||||
{
|
||||
register int i;
|
||||
BOUND range;
|
||||
register POINT *p;
|
||||
Dimension width, height;
|
||||
static int max_points = 0;
|
||||
static POINT *points = (POINT *) NULL;
|
||||
|
||||
range.low = Common.position - Common.thickness * 0.5;
|
||||
range.high = Common.position + Common.thickness * 0.5;
|
||||
|
||||
/* use a static buffer so minimize number of allocations */
|
||||
/* didnt use Realloc because dont want data copied */
|
||||
|
||||
*npoints = cnt;
|
||||
if (*npoints > max_points) {
|
||||
XtFree((char *) points);
|
||||
points = (POINT *) XtMalloc( *npoints * sizeof(POINT));
|
||||
max_points = *npoints;
|
||||
}
|
||||
p = points;
|
||||
|
||||
if (cnt < 1) return(points);
|
||||
|
||||
SceneSize(&width, &height);
|
||||
width -= 2*HOFFSET;
|
||||
height -= 2*VOFFSET;
|
||||
|
||||
/* translate x, y, z to x and y in window. */
|
||||
/* note: index and type are also passed, but may not be used */
|
||||
|
||||
switch(3*Common.direction + Common.axis){
|
||||
case 0: /* negative direction, x axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->x > range.high) continue;
|
||||
if (pos->x < range.low) continue;
|
||||
p->x = width -
|
||||
(pos->z * Common.scale + Common.offset[2]);
|
||||
p->y = height -
|
||||
(pos->y * Common.scale + Common.offset[1]);
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
case 1: /* negative direction, y axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->y > range.high) continue;
|
||||
if (pos->y < range.low) continue;
|
||||
p->x = pos->x * Common.scale + Common.offset[0];
|
||||
p->y = pos->z * Common.scale + Common.offset[2];
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
case 2: /* negative direction, z axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->z > range.high) continue;
|
||||
if (pos->z < range.low) continue;
|
||||
p->x = pos->x * Common.scale + Common.offset[0];
|
||||
p->y = height -
|
||||
(pos->y * Common.scale + Common.offset[1]);
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
case 3: /* positive direction, x axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->x > range.high) continue;
|
||||
if (pos->x < range.low) continue;
|
||||
p->x = pos->z * Common.scale + Common.offset[2];
|
||||
p->y = height -
|
||||
(pos->y * Common.scale + Common.offset[1]);
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: /* positive direction, y axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->y > range.high) continue;
|
||||
if (pos->y < range.low) continue;
|
||||
p->x = pos->x * Common.scale + Common.offset[0];
|
||||
p->y = height -
|
||||
(pos->z * Common.scale + Common.offset[2]);
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 5: /* postive direction, z axis */
|
||||
for(i = cnt; i; i--, pos++) {
|
||||
if (pos->z > range.high) continue;
|
||||
if (pos->z < range.low) continue;
|
||||
p->x = pos->x * Common.scale + Common.offset[0];
|
||||
p->y = pos->y * Common.scale + Common.offset[1];
|
||||
p->width = diam;
|
||||
p->height = diam;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*npoints = p - points;
|
||||
|
||||
/* add the hard offsets so we dont draw on edge of screen */
|
||||
/* center drawing based on width, height */
|
||||
|
||||
for(i = *npoints, p = points; i; i--, p++) {
|
||||
p->x += HOFFSET - p->width/2;
|
||||
p->y += VOFFSET - p->height/2;
|
||||
}
|
||||
|
||||
return(points);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void DrawPoints(Display *display, Drawable drawable, GC gc,
|
||||
POINT *points, int npoints)
|
||||
{
|
||||
register int full_circle;
|
||||
register int i;
|
||||
register POINT *p;
|
||||
|
||||
if (npoints <= 0) return;
|
||||
|
||||
/* this version has POINT typedef'd to XArc, so we need to */
|
||||
/* fill in other fields before drawing */
|
||||
|
||||
full_circle = 64*360;
|
||||
|
||||
for(i = npoints, p = points; i ; i--, p++){
|
||||
p->angle1 = 0;
|
||||
p->angle2 = full_circle;
|
||||
}
|
||||
|
||||
if (Common.hollow) {
|
||||
if (Common.opaque)
|
||||
XFillArcs(display, drawable, bggc, points, npoints);
|
||||
XDrawArcs(display, drawable, gc, points, npoints);
|
||||
}
|
||||
else
|
||||
XFillArcs(display, drawable, gc, points, npoints);
|
||||
|
||||
}
|
||||
|
||||
PRIVATE LINE *ClipAndScaleLines(BOND *bond, int cnt, int *nlines)
|
||||
{
|
||||
register int i;
|
||||
BOUND range;
|
||||
register LINE *l;
|
||||
Dimension width, height;
|
||||
static int max_lines = 0;
|
||||
static LINE *lines = (LINE *) NULL;
|
||||
|
||||
range.low = Common.position - Common.thickness * 0.5;
|
||||
range.high = Common.position + Common.thickness * 0.5;
|
||||
|
||||
/* use a static buffer so minimize number of allocations */
|
||||
/* didnt use Realloc because dont want data copied */
|
||||
|
||||
*nlines = cnt;
|
||||
if (*nlines > max_lines) {
|
||||
XtFree((char *) lines);
|
||||
lines = (LINE *) XtMalloc( *nlines * sizeof(LINE));
|
||||
max_lines = *nlines;
|
||||
}
|
||||
l = lines;
|
||||
|
||||
if (cnt < 1) return(lines);
|
||||
|
||||
SceneSize(&width, &height);
|
||||
width -= 2*HOFFSET;
|
||||
height -= 2*VOFFSET;
|
||||
|
||||
/* translate x, y, z to x and y in window. */
|
||||
|
||||
switch(3*Common.direction + Common.axis){
|
||||
case 0: /* negative direction, x axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->x > range.high) continue;
|
||||
if (bond->atom1->x < range.low) continue;
|
||||
if (bond->atom2->x > range.high) continue;
|
||||
if (bond->atom2->x < range.low) continue;
|
||||
l->x1 = width -
|
||||
(bond->atom1->z*Common.scale+Common.offset[2]);
|
||||
l->y1 = height -
|
||||
(bond->atom1->y*Common.scale+Common.offset[1]);
|
||||
l->x2 = width -
|
||||
(bond->atom2->z*Common.scale+Common.offset[2]);
|
||||
l->y2 = height -
|
||||
(bond->atom2->y*Common.scale+Common.offset[1]);
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
case 1: /* negative direction, y axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->y > range.high) continue;
|
||||
if (bond->atom1->y < range.low) continue;
|
||||
if (bond->atom2->y > range.high) continue;
|
||||
if (bond->atom2->y < range.low) continue;
|
||||
l->x1 = bond->atom1->x*Common.scale + Common.offset[0];
|
||||
l->y1 = bond->atom1->z*Common.scale + Common.offset[2];
|
||||
l->x2 = bond->atom2->x*Common.scale + Common.offset[0];
|
||||
l->y2 = bond->atom2->z*Common.scale + Common.offset[2];
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
case 2: /* negative direction, z axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->z > range.high) continue;
|
||||
if (bond->atom1->z < range.low) continue;
|
||||
if (bond->atom2->z > range.high) continue;
|
||||
if (bond->atom2->z < range.low) continue;
|
||||
l->x1 = bond->atom1->x*Common.scale + Common.offset[0];
|
||||
l->y1 = height -
|
||||
(bond->atom1->y*Common.scale+Common.offset[1]);
|
||||
l->x2 = bond->atom2->x*Common.scale + Common.offset[0];
|
||||
l->y2 = height -
|
||||
(bond->atom2->y*Common.scale+Common.offset[1]);
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
case 3: /* positive direction, x axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->x > range.high) continue;
|
||||
if (bond->atom1->x < range.low) continue;
|
||||
if (bond->atom2->x > range.high) continue;
|
||||
if (bond->atom2->x < range.low) continue;
|
||||
l->x1 = bond->atom1->z*Common.scale + Common.offset[2];
|
||||
l->y1 = height -
|
||||
(bond->atom1->y*Common.scale+Common.offset[1]);
|
||||
l->x2 = bond->atom2->z*Common.scale + Common.offset[2];
|
||||
l->y2 = height -
|
||||
(bond->atom2->y*Common.scale+Common.offset[1]);
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: /* positive direction, y axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->y > range.high) continue;
|
||||
if (bond->atom1->y < range.low) continue;
|
||||
if (bond->atom2->y > range.high) continue;
|
||||
if (bond->atom2->y < range.low) continue;
|
||||
l->x1 = bond->atom1->x*Common.scale + Common.offset[0];
|
||||
l->y1 = height -
|
||||
(bond->atom1->z*Common.scale+Common.offset[2]);
|
||||
l->x2 = bond->atom2->x*Common.scale + Common.offset[0];
|
||||
l->y2 = height -
|
||||
(bond->atom2->z*Common.scale+Common.offset[2]);
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 5: /* postive direction, z axis */
|
||||
for(i = cnt; i; i--, bond++) {
|
||||
if (bond->atom1->z > range.high) continue;
|
||||
if (bond->atom1->z < range.low) continue;
|
||||
if (bond->atom2->z > range.high) continue;
|
||||
if (bond->atom2->z < range.low) continue;
|
||||
l->x1 = bond->atom1->x*Common.scale + Common.offset[0];
|
||||
l->y1 = bond->atom1->y*Common.scale + Common.offset[1];
|
||||
l->x2 = bond->atom2->x*Common.scale + Common.offset[0];
|
||||
l->y2 = bond->atom2->y*Common.scale + Common.offset[1];
|
||||
l++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*nlines = l - lines;
|
||||
|
||||
/* add the hard offsets so we dont draw on edge of screen */
|
||||
|
||||
for(i = *nlines, l = lines; i; i--, l++) {
|
||||
l->x1 += HOFFSET;
|
||||
l->y1 += VOFFSET;
|
||||
l->x2 += HOFFSET;
|
||||
l->y2 += VOFFSET;
|
||||
}
|
||||
|
||||
return(lines);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void DrawLines(Display *display, Drawable drawable, GC gc,
|
||||
LINE *lines, int nlines)
|
||||
{
|
||||
if (nlines <= 0) return;
|
||||
|
||||
XDrawSegments(display, drawable, gc, lines, nlines);
|
||||
}
|
||||
|
||||
void Setup(void)
|
||||
{
|
||||
NewDataSetup();
|
||||
SpeedUpdate();
|
||||
UpdateRadios();
|
||||
}
|
||||
|
||||
void NewDataSetup(void)
|
||||
{
|
||||
static int have_pixmap = 0;
|
||||
|
||||
BOUND *cb;
|
||||
int i;
|
||||
float longest, f;
|
||||
Dimension width, height;
|
||||
|
||||
SceneSize(&Width, &Height);
|
||||
|
||||
if (have_pixmap) XFreePixmap(XtDisplay(Scene), Buffer);
|
||||
|
||||
Buffer = XCreatePixmap(XtDisplay(Scene),
|
||||
RootWindowOfScreen(XtScreen(Scene)), Width, Height,
|
||||
DefaultDepthOfScreen(XtScreen(Scene)));
|
||||
|
||||
have_pixmap = 1;
|
||||
|
||||
/* determine global scaling and offset factors */
|
||||
/* offset + scale * coordinate = pixel */
|
||||
|
||||
longest = 0.0;
|
||||
for(i = 3, cb = Common.bounds; i ; i--, cb++)
|
||||
if ((f = (cb->high) - (cb->low)) > longest) longest = f;
|
||||
|
||||
SceneSize(&Width, &Height);
|
||||
width = Width;
|
||||
height = Height;
|
||||
|
||||
width -= HOFFSET*2;
|
||||
height -= VOFFSET*2;
|
||||
|
||||
Common.scale = (width < height) ? width/longest : height/longest;
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
Common.offset[i] = - Common.bounds[i].low * Common.scale;
|
||||
|
||||
PositionUpdate();
|
||||
ThicknessUpdate();
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void SetAtomColors(Pixel *fg)
|
||||
{
|
||||
int i;
|
||||
XGCValues xgc;
|
||||
|
||||
XtVaGetValues(Scene, XtNbackground, &xgc.background, NULL);
|
||||
|
||||
xgc.function = GXcopy;
|
||||
|
||||
for(i = 0; i < Common.natomcolors; i++) {
|
||||
if (gc[i]) XFreeGC(XtDisplay(Scene), gc[i]);
|
||||
xgc.foreground = fg[i];
|
||||
gc[i] = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground, &xgc);
|
||||
}
|
||||
|
||||
if (bggc) XFreeGC(XtDisplay(Scene), bggc);
|
||||
xgc.foreground = xgc.background;
|
||||
bggc = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground, &xgc);
|
||||
|
||||
}
|
||||
|
||||
void SetBGColor(Pixel bg)
|
||||
{
|
||||
XGCValues xgc;
|
||||
|
||||
XtVaSetValues(Scene, XtNbackground, bg, NULL);
|
||||
|
||||
if (bggc) XFreeGC(XtDisplay(Scene), bggc);
|
||||
|
||||
xgc.function = GXcopy;
|
||||
xgc.foreground = xgc.background = bg;
|
||||
|
||||
bggc = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground, &xgc);
|
||||
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void SetBondColors(Pixel *fg, Dimension *thick)
|
||||
{
|
||||
int i;
|
||||
XGCValues xgc;
|
||||
|
||||
XtVaGetValues(Scene, XtNbackground, &xgc.background, NULL);
|
||||
|
||||
xgc.function = GXcopy;
|
||||
|
||||
for(i = 0; i < Common.nbondcolors; i++) {
|
||||
if (bondgc[i]) XFreeGC(XtDisplay(Scene), bondgc[i]);
|
||||
xgc.foreground = fg[i];
|
||||
xgc.line_width = thick[i];
|
||||
bondgc[i] = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground | GCLineWidth,
|
||||
&xgc);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
PRIVATE void SetAllColors(void)
|
||||
{
|
||||
int i;
|
||||
XGCValues xgc;
|
||||
|
||||
xgc.function = GXcopy;
|
||||
xgc.line_width = 1;
|
||||
|
||||
XtVaGetValues(Scene,
|
||||
XtNbackground, &xgc.background,
|
||||
XtNforeground, &xgc.foreground,
|
||||
NULL);
|
||||
|
||||
for(i = 0; i < Common.natomcolors; i++)
|
||||
gc[i] = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground, &xgc);
|
||||
|
||||
for(i = 0; i < Common.nbondcolors; i++)
|
||||
bondgc[i] = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground | GCLineWidth,
|
||||
&xgc);
|
||||
|
||||
xgc.foreground = xgc.background;
|
||||
bggc = XCreateGC(XtDisplay(Scene), XtWindow(Scene),
|
||||
GCFunction | GCBackground | GCForeground, &xgc);
|
||||
|
||||
}
|
||||
|
|
@ -1,425 +0,0 @@
|
|||
/* **************************************************************** */
|
||||
/* toascii.c - binary to ascii xmovie format converter */
|
||||
/* */
|
||||
/* Mike Uttormark - 8/11/92 */
|
||||
/* Sandia Nat'l Labs 1421 */
|
||||
/* On leave from University of Wisconsin--Madison */
|
||||
/* **************************************************************** */
|
||||
/* format of binary file: */
|
||||
/* */
|
||||
/* magic number - 4-byte integer */
|
||||
/* version - 4-byte integer */
|
||||
/* <records> */
|
||||
/* */
|
||||
/* generic record format: */
|
||||
/* record id - 4-byte integer */
|
||||
/* length (bytes) - 4-byte integer */
|
||||
/* data */
|
||||
/* **************************************************************** */
|
||||
|
||||
#define MagicNumber 12344321
|
||||
#define Version 1001
|
||||
|
||||
#define TimeID 100
|
||||
#define BoundID 101
|
||||
#define PositionID 102
|
||||
#define BondID 103
|
||||
#define CopyBondID 104
|
||||
#define CopyAtomID 105
|
||||
|
||||
#define LINELEN 256
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef MISSINGDEFS
|
||||
#include <unistd.h>
|
||||
int fprintf(FILE *, char *, ...);
|
||||
int fread(void *, size_t, size_t, FILE *);
|
||||
int fseek(FILE *, long int, int);
|
||||
#endif
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local typedefs */
|
||||
|
||||
typedef long INT4;
|
||||
typedef float REAL4;
|
||||
typedef void (*PFV)();
|
||||
|
||||
typedef struct {
|
||||
INT4 index;
|
||||
INT4 type;
|
||||
REAL4 coord[3];
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
INT4 type;
|
||||
INT4 index1;
|
||||
INT4 index2;
|
||||
} BOND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 low[3];
|
||||
REAL4 high[3];
|
||||
} BOUND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 time;
|
||||
} TIME;
|
||||
|
||||
typedef INT4 RECORD;
|
||||
typedef INT4 LENGTH;
|
||||
typedef INT4 MAGIC;
|
||||
typedef INT4 VERSION;
|
||||
|
||||
typedef struct {
|
||||
RECORD record_id;
|
||||
PFV writer;
|
||||
} WRITER;
|
||||
|
||||
typedef struct {
|
||||
RECORD record_id;
|
||||
PFV reader;
|
||||
} READER;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* function proto-types */
|
||||
|
||||
int main(int argc, char **argv);
|
||||
int GetRecord(FILE *file);
|
||||
void PutRecord(FILE *file);
|
||||
|
||||
void PutTime(FILE *f);
|
||||
void PutBound(FILE *f);
|
||||
void PutPosition(FILE *f);
|
||||
void PutBond(FILE *f);
|
||||
void PutCopyBond(FILE *f);
|
||||
void PutCopyAtom(FILE *f);
|
||||
|
||||
WRITER *GetWriter(RECORD record);
|
||||
|
||||
void PrintError(char *s);
|
||||
void *Realloc(void *ptr, size_t amt);
|
||||
|
||||
READER *GetReader(RECORD record);
|
||||
|
||||
void ReadHeader(FILE *f);
|
||||
int ReadRecordHeader(FILE *f);
|
||||
void ReadTime(FILE *f);
|
||||
void ReadBound(FILE *f);
|
||||
void ReadPosition(FILE *f);
|
||||
void ReadBond(FILE *f);
|
||||
void ReadDummy(FILE *f);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local data */
|
||||
|
||||
static MAGIC magic = MagicNumber;
|
||||
static VERSION version = Version;
|
||||
static RECORD record;
|
||||
static LENGTH length;
|
||||
static POSITION *positions = (POSITION *) NULL;
|
||||
static INT4 npositions = 0;
|
||||
static INT4 maxpositions = 0;
|
||||
static BOUND bounds;
|
||||
static TIME time;
|
||||
static BOND *bonds = (BOND *) NULL;
|
||||
static INT4 nbonds = 0;
|
||||
static INT4 maxbonds = 0;
|
||||
|
||||
static WRITER write_table[] = {
|
||||
{ TimeID, PutTime },
|
||||
{ BoundID, PutBound },
|
||||
{ PositionID, PutPosition },
|
||||
{ BondID, PutBond },
|
||||
{ CopyBondID, PutCopyBond },
|
||||
{ CopyAtomID, PutCopyAtom },
|
||||
};
|
||||
|
||||
static READER read_table[] = {
|
||||
{ TimeID, ReadTime },
|
||||
{ BoundID, ReadBound },
|
||||
{ PositionID, ReadPosition },
|
||||
{ BondID, ReadBond },
|
||||
{ CopyBondID, ReadDummy },
|
||||
{ CopyAtomID, ReadDummy },
|
||||
};
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
/* ARGSUSED */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ReadHeader(stdin);
|
||||
|
||||
while(GetRecord(stdin))
|
||||
PutRecord(stdout);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
int GetRecord(FILE *f)
|
||||
{
|
||||
register READER *r;
|
||||
|
||||
while(1) {
|
||||
if (!ReadRecordHeader(f)) return(FALSE);
|
||||
r = GetReader(record);
|
||||
if (r == (READER *) NULL) { /* dont recognize */
|
||||
fseek(f, length, SEEK_CUR); /* skip */
|
||||
continue;
|
||||
}
|
||||
(*r->reader)(f);
|
||||
break;
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
READER *GetReader(RECORD record)
|
||||
{
|
||||
register READER *r;
|
||||
register int i;
|
||||
|
||||
i = sizeof(read_table)/sizeof(read_table[0]);
|
||||
for(r = read_table; i ; i--, r++)
|
||||
if (r->record_id == record) return(r);
|
||||
|
||||
return((READER *) NULL);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutTime(FILE *f)
|
||||
{
|
||||
fprintf(f, "ITEM: TIME\n"
|
||||
"%g\n", time.time);
|
||||
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutBound(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
|
||||
fprintf(f, "ITEM: BOUNDS\n");
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
fprintf(f, "%g %g\n", bounds.low[i], bounds.high[i]);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutPosition(FILE *f)
|
||||
{
|
||||
register POSITION *p;
|
||||
register int i;
|
||||
|
||||
fprintf(f,"ITEM: POSITIONS %i\n", npositions);
|
||||
|
||||
for(p = positions, i = npositions; i; i--, p++)
|
||||
fprintf(f, "%i %i %g %g %g\n",p->index, p->type,
|
||||
p->coord[0], p->coord[1], p->coord[2]);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutBond(FILE *f)
|
||||
{
|
||||
register BOND *b;
|
||||
register int i;
|
||||
|
||||
fprintf(f,"ITEM: BONDS %i\n", nbonds);
|
||||
|
||||
for(b = bonds, i = nbonds; i; i--, b++)
|
||||
fprintf(f, "%i %i %i\n", b->type, b->index1, b->index2);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutCopyBond(FILE *f)
|
||||
{
|
||||
fprintf(f, "ITEM: COPYBONDS\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutCopyAtom(FILE *f)
|
||||
{
|
||||
fprintf(f, "ITEM: COPYATOMS\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PrintError(char *s)
|
||||
{
|
||||
fprintf(stderr,"%s", s);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void *Realloc(void *ptr, size_t amt)
|
||||
{
|
||||
ptr = (ptr == NULL) ? malloc(amt) : realloc(ptr, amt);
|
||||
|
||||
if (ptr != NULL) return(ptr);
|
||||
|
||||
PrintError("Error: unable to allocate space.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutRecord(FILE *f)
|
||||
{
|
||||
register WRITER *w;
|
||||
|
||||
w = GetWriter(record);
|
||||
if (w == (WRITER *) NULL)
|
||||
PrintError("Internal error: no writer.\n");
|
||||
|
||||
(*w->writer)(f);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
WRITER *GetWriter(RECORD r)
|
||||
{
|
||||
register int i;
|
||||
register WRITER *w;
|
||||
|
||||
i = sizeof(write_table)/sizeof(write_table[0]);
|
||||
for(w = write_table; i; i--, w++)
|
||||
if (w->record_id == r) return(w);
|
||||
|
||||
return((WRITER *) NULL);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
|
||||
void ReadHeader(FILE *f)
|
||||
{
|
||||
if (1 > fread(&magic, sizeof(magic), 1, f)) goto error;
|
||||
if (1 > fread(&version, sizeof(version), 1, f)) goto error;
|
||||
|
||||
if (magic == MagicNumber) return;
|
||||
|
||||
error:
|
||||
|
||||
PrintError( "Error: magic number not found.\n"
|
||||
"File is probably not binary.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadTime(FILE *f)
|
||||
{
|
||||
if (1 == fread(&time.time, length, 1, f)) return;
|
||||
|
||||
PrintError("Error: unable to read time.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadBound(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
if (1 > fread(&bounds.low[i], sizeof(bounds.low[0]), 1, f))
|
||||
goto error;
|
||||
if (1 > fread(&bounds.high[i], sizeof(bounds.high[0]), 1, f))
|
||||
goto error;
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
PrintError("Error: unable to read bounds.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadPosition(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
register POSITION *p;
|
||||
|
||||
npositions = length /
|
||||
(sizeof(p->index) + sizeof(p->type) + 3*sizeof(p->coord[0]));
|
||||
|
||||
if (npositions > maxpositions) {
|
||||
maxpositions = npositions + 16;
|
||||
positions = (POSITION *)
|
||||
Realloc(positions, maxpositions * sizeof(*positions));
|
||||
}
|
||||
|
||||
for(i = npositions, p = positions; i; i--, p++) {
|
||||
if (1 > fread(&p->index, sizeof(p->index), 1, f)) goto error;
|
||||
if (1 > fread(&p->type, sizeof(p->type), 1, f)) goto error;
|
||||
if (1 > fread(&p->coord[0], sizeof(p->coord[0]), 1, f)) goto error;
|
||||
if (1 > fread(&p->coord[1], sizeof(p->coord[0]), 1, f)) goto error;
|
||||
if (1 > fread(&p->coord[2], sizeof(p->coord[0]), 1, f)) goto error;
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
PrintError("Error: unable to get atom positions.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadBond(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
register BOND *b;
|
||||
|
||||
nbonds = length /
|
||||
(sizeof(b->type) + sizeof(b->index1) + sizeof(b->index2));
|
||||
|
||||
if (nbonds > maxbonds) {
|
||||
maxbonds = nbonds + 16;
|
||||
bonds = (BOND *)
|
||||
Realloc(bonds, maxbonds * sizeof(*bonds));
|
||||
}
|
||||
|
||||
for(i = nbonds, b = bonds; i; i--, b++) {
|
||||
if (1 > fread(&b->type, sizeof(b->type), 1, f)) goto error;
|
||||
if (1 > fread(&b->index1, sizeof(b->index1), 1, f)) goto error;
|
||||
if (1 > fread(&b->index2, sizeof(b->index2), 1, f)) goto error;
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
PrintError("Error: unable to get bonds.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
int ReadRecordHeader(FILE *f)
|
||||
{
|
||||
if (1 > fread(&record, sizeof(record), 1, f)) return(FALSE);
|
||||
if (1 > fread(&length, sizeof(length), 1, f)) return(FALSE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadDummy(FILE *f)
|
||||
{}
|
|
@ -1,525 +0,0 @@
|
|||
/* **************************************************************** */
|
||||
/* tobinary.c - binary xmovie format converter */
|
||||
/* */
|
||||
/* Mike Uttormark - 8/11/92 */
|
||||
/* Sandia Nat'l Labs 1421 */
|
||||
/* On leave from University of Wisconsin--Madison */
|
||||
/* **************************************************************** */
|
||||
/* format of binary file: */
|
||||
/* */
|
||||
/* magic number - 4-byte integer */
|
||||
/* version - 4-byte integer */
|
||||
/* <records> */
|
||||
/* */
|
||||
/* generic record format: */
|
||||
/* record id - 4-byte integer */
|
||||
/* length (bytes) - 4-byte integer */
|
||||
/* data */
|
||||
/* **************************************************************** */
|
||||
|
||||
#define MagicNumber 12344321
|
||||
#define Version 1001
|
||||
|
||||
#define TimeID 100
|
||||
#define BoundID 101
|
||||
#define PositionID 102
|
||||
#define BondID 103
|
||||
#define CopyBondID 104
|
||||
#define CopyAtomID 105
|
||||
|
||||
#define LINELEN 256
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef MISSINGDEFS
|
||||
long strtol(char *s, char **t, int base);
|
||||
double strtod(char *s, char **t);
|
||||
int fprintf(FILE *, char *, ...);
|
||||
int fwrite(void *, size_t, size_t, FILE *);
|
||||
#endif
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define WHITESPACE " \t\n\v\r"
|
||||
#define SEPARATORS WHITESPACE ",;"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local typedefs */
|
||||
|
||||
typedef long INT4;
|
||||
typedef float REAL4;
|
||||
typedef void (*PFV)();
|
||||
|
||||
typedef struct {
|
||||
INT4 index;
|
||||
INT4 type;
|
||||
REAL4 coord[3];
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
INT4 type;
|
||||
INT4 index1;
|
||||
INT4 index2;
|
||||
} BOND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 low[3];
|
||||
REAL4 high[3];
|
||||
} BOUND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 time;
|
||||
} TIME;
|
||||
|
||||
typedef INT4 RECORD;
|
||||
typedef INT4 LENGTH;
|
||||
typedef INT4 MAGIC;
|
||||
typedef INT4 VERSION;
|
||||
|
||||
typedef struct {
|
||||
char *item;
|
||||
RECORD record_id;
|
||||
PFV reader;
|
||||
} PARSER;
|
||||
|
||||
typedef struct {
|
||||
RECORD record_id;
|
||||
PFV writer;
|
||||
} WRITER;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* function proto-types */
|
||||
|
||||
int main(int argc, char **argv);
|
||||
int GetRecord(FILE *file);
|
||||
void PutRecord(FILE *file);
|
||||
|
||||
void ReadTime(FILE *f);
|
||||
void ReadBound(FILE *f);
|
||||
void ReadPosition(FILE *f);
|
||||
void ReadBond(FILE *);
|
||||
void ReadDummy(FILE *F);
|
||||
|
||||
int GetLine(char *s, FILE *f);
|
||||
void UnGetLine(char *s);
|
||||
int LineIsBlank(char *s);
|
||||
int IsItem(char *s, char **t);
|
||||
PARSER *GetParser(char *s);
|
||||
|
||||
int GetInt4(char *s, char **t, INT4 *i);
|
||||
int GetReal4(char *s, char **t, REAL4 *r);
|
||||
|
||||
void PrintError(char *s);
|
||||
void *Realloc(void *ptr, size_t amt);
|
||||
|
||||
WRITER *GetWriter(RECORD record);
|
||||
|
||||
void WriteHeader(FILE *f);
|
||||
void WriteRecordHeader(FILE *f);
|
||||
void WriteTime(FILE *f);
|
||||
void WriteBound(FILE *f);
|
||||
void WritePosition(FILE *f);
|
||||
void WriteBond(FILE *f);
|
||||
void WriteDummy(FILE *f);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local data */
|
||||
|
||||
static MAGIC magic = MagicNumber;
|
||||
static VERSION version = Version;
|
||||
static RECORD record;
|
||||
static LENGTH length;
|
||||
static POSITION *positions = (POSITION *) NULL;
|
||||
static INT4 npositions = 0;
|
||||
static INT4 maxpositions = 0;
|
||||
static BOUND bounds;
|
||||
static TIME time;
|
||||
static BOND *bonds = (BOND *) NULL;
|
||||
static INT4 nbonds = 0;
|
||||
static INT4 maxbonds = 0;
|
||||
|
||||
static PARSER parse_table[] = {
|
||||
{ "TIME", TimeID, ReadTime },
|
||||
{ "BOUNDS", BoundID, ReadBound },
|
||||
{ "POSITIONS", PositionID, ReadPosition },
|
||||
{ "BONDS", BondID, ReadBond },
|
||||
{ "COPYBONDS", CopyBondID, ReadDummy },
|
||||
{ "COPYATOMS", CopyAtomID, ReadDummy },
|
||||
};
|
||||
|
||||
static WRITER write_table[] = {
|
||||
{ TimeID, WriteTime },
|
||||
{ BoundID, WriteBound },
|
||||
{ PositionID, WritePosition },
|
||||
{ BondID, WriteBond },
|
||||
{ CopyBondID, WriteDummy },
|
||||
{ CopyAtomID, WriteDummy },
|
||||
};
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
/* ARGSUSED */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
WriteHeader(stdout);
|
||||
|
||||
while(GetRecord(stdin))
|
||||
PutRecord(stdout);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
int GetRecord(FILE *f)
|
||||
{
|
||||
char line[LINELEN];
|
||||
char *t;
|
||||
PARSER *p;
|
||||
|
||||
while(1) {
|
||||
if (!GetLine(line, f)) return(FALSE);
|
||||
if (!IsItem(line, &t)) continue;
|
||||
p = GetParser(t);
|
||||
if (p == (PARSER *) NULL) continue;
|
||||
record = p->record_id;
|
||||
(*p->reader)(f);
|
||||
break;
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
static int have_line = 0;
|
||||
static char hold_line[LINELEN];
|
||||
|
||||
int GetLine(char *s, FILE *f)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (have_line) {
|
||||
have_line = FALSE;
|
||||
strcpy(s, hold_line);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
do {
|
||||
result = (NULL != fgets(s, LINELEN, f));
|
||||
}
|
||||
while ( result && LineIsBlank(s) );
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
void UnGetLine(char *s)
|
||||
{
|
||||
have_line = TRUE;
|
||||
strcpy(hold_line, s);
|
||||
}
|
||||
|
||||
int LineIsBlank(char *s)
|
||||
{
|
||||
register char *t;
|
||||
|
||||
t = s + strspn(s, WHITESPACE);
|
||||
return(*t == '\0');
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
int IsItem(char *s, char **t)
|
||||
{
|
||||
register char *item;
|
||||
|
||||
item = strtok(s, WHITESPACE );
|
||||
if (strcmp(item, "ITEM:")) return(FALSE);
|
||||
|
||||
*t = strtok(NULL, WHITESPACE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
PARSER *GetParser(char *s)
|
||||
{
|
||||
register PARSER *p;
|
||||
register int i;
|
||||
|
||||
i = sizeof(parse_table)/sizeof(parse_table[0]);
|
||||
for(p = parse_table; i ; i--, p++)
|
||||
if (!strcmp(p->item, s)) return(p);
|
||||
|
||||
return((PARSER *) NULL);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadTime(FILE *f)
|
||||
{
|
||||
char line[80];
|
||||
char *t;
|
||||
|
||||
if (!GetLine(line, f))
|
||||
PrintError("Error: unable to get line for time.\n");
|
||||
|
||||
if (!GetReal4(line, &t, &time.time))
|
||||
PrintError("Error: unable to convert time.\n");
|
||||
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadBound(FILE *f)
|
||||
{
|
||||
char line[80];
|
||||
char *t;
|
||||
register int i;
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
if (!GetLine(line, f))
|
||||
PrintError("Error: unable to get line for bounds.\n");
|
||||
if (!GetReal4(line, &t, &bounds.low[i]))
|
||||
PrintError("Error: unable to get low bound.\n");
|
||||
if (!GetReal4(t, &t, &bounds.high[i]))
|
||||
PrintError("Error: unable to get high bound.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadPosition(FILE *f)
|
||||
{
|
||||
char line[LINELEN];
|
||||
char *t;
|
||||
POSITION p;
|
||||
register int i;
|
||||
|
||||
npositions = 0;
|
||||
|
||||
while(1) {
|
||||
if (!GetLine(line, f)) return;
|
||||
if (!GetInt4(line, &t, &p.index)) {
|
||||
UnGetLine(line);
|
||||
return;
|
||||
}
|
||||
if (!GetInt4(t, &t, &p.type))
|
||||
PrintError("Error: unable to get atoms type.\n");
|
||||
for(i = 0; i < 3; i++)
|
||||
if (!GetReal4(t, &t, &p.coord[i]))
|
||||
PrintError("Error: unable to atom position.\n");
|
||||
|
||||
if (npositions >= maxpositions) {
|
||||
maxpositions += 128;
|
||||
positions = (POSITION *) Realloc(positions,
|
||||
maxpositions * sizeof(*positions));
|
||||
}
|
||||
positions[npositions++] = p;
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadBond(FILE *f)
|
||||
{
|
||||
char line[LINELEN];
|
||||
char *t;
|
||||
BOND b;
|
||||
|
||||
nbonds = 0;
|
||||
|
||||
while(1) {
|
||||
if (!GetLine(line, f)) return;
|
||||
if (!GetInt4(line, &t, &b.type)) {
|
||||
UnGetLine(line);
|
||||
return;
|
||||
}
|
||||
if (!GetInt4(t, &t, &b.index1))
|
||||
PrintError("Error: unable to get bond index 1.\n");
|
||||
|
||||
if (!GetInt4(t, &t, &b.index2))
|
||||
PrintError("Error: unable to get bond index 2.\n");
|
||||
|
||||
if (nbonds >= maxbonds) {
|
||||
maxbonds += 128;
|
||||
bonds = (BOND *) Realloc(bonds,
|
||||
maxbonds * sizeof(*bonds));
|
||||
}
|
||||
bonds[nbonds++] = b;
|
||||
}
|
||||
}
|
||||
/* **************************************************************** */
|
||||
|
||||
void ReadDummy(FILE *f)
|
||||
{}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
int GetInt4(char *s, char **t, INT4 *i)
|
||||
{
|
||||
s += strspn(s, SEPARATORS);
|
||||
|
||||
*i = strtol(s, t, 10);
|
||||
|
||||
return(*t > s);
|
||||
}
|
||||
|
||||
int GetReal4(char *s, char **t, REAL4 *r)
|
||||
{
|
||||
s += strspn(s, SEPARATORS);
|
||||
|
||||
*r = strtod(s, t);
|
||||
|
||||
return(*t > s);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PrintError(char *s)
|
||||
{
|
||||
fprintf(stderr,"%s", s);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void *Realloc(void *ptr, size_t amt)
|
||||
{
|
||||
ptr = (ptr == NULL) ? malloc(amt) : realloc(ptr, amt);
|
||||
|
||||
if (ptr != NULL) return(ptr);
|
||||
|
||||
PrintError("Error: unable to allocate space.\n");
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void PutRecord(FILE *f)
|
||||
{
|
||||
WRITER *w;
|
||||
|
||||
w = GetWriter(record);
|
||||
if (w == (WRITER *) NULL)
|
||||
PrintError("Internal error: no writer.\n");
|
||||
|
||||
(*w->writer)(f);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
WRITER *GetWriter(RECORD r)
|
||||
{
|
||||
register int i;
|
||||
register WRITER *w;
|
||||
|
||||
i = sizeof(write_table)/sizeof(write_table[0]);
|
||||
for(w = write_table; i; i--, w++)
|
||||
if (w->record_id == r) return(w);
|
||||
|
||||
return((WRITER *) NULL);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
|
||||
void WriteHeader(FILE *f)
|
||||
{
|
||||
fwrite(&magic, sizeof(magic), 1, f);
|
||||
fwrite(&version, sizeof(version), 1, f);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WriteTime(FILE *f)
|
||||
{
|
||||
length = sizeof(time.time);
|
||||
|
||||
WriteRecordHeader(f);
|
||||
|
||||
fwrite(&time.time, length, 1, f);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WriteBound(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
|
||||
length = 3 * (sizeof(bounds.low[0]) + sizeof(bounds.high[0]));
|
||||
|
||||
WriteRecordHeader(f);
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
fwrite(&bounds.low[i], sizeof(bounds.low[0]), 1, f);
|
||||
fwrite(&bounds.high[i], sizeof(bounds.high[0]), 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WritePosition(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
register POSITION *p;
|
||||
|
||||
length = npositions *
|
||||
(sizeof(p->index) + sizeof(p->type) + 3*sizeof(p->coord[0]));
|
||||
|
||||
WriteRecordHeader(f);
|
||||
|
||||
for(i = npositions, p = positions; i; i--, p++) {
|
||||
fwrite(&p->index, sizeof(p->index), 1, f);
|
||||
fwrite(&p->type, sizeof(p->type), 1, f);
|
||||
fwrite(&p->coord[0], sizeof(p->coord[0]), 1, f);
|
||||
fwrite(&p->coord[1], sizeof(p->coord[0]), 1, f);
|
||||
fwrite(&p->coord[2], sizeof(p->coord[0]), 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WriteBond(FILE *f)
|
||||
{
|
||||
register int i;
|
||||
register BOND *b;
|
||||
|
||||
length = nbonds *
|
||||
(sizeof(b->type) + sizeof(b->index1) + sizeof(b->index2));
|
||||
|
||||
WriteRecordHeader(f);
|
||||
|
||||
for(i = nbonds, b = bonds; i; i--, b++) {
|
||||
fwrite(&b->type, sizeof(b->type), 1, f);
|
||||
fwrite(&b->index1, sizeof(b->index1), 1, f);
|
||||
fwrite(&b->index2, sizeof(b->index2), 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WriteDummy(FILE *f)
|
||||
{
|
||||
length = 0;
|
||||
|
||||
WriteRecordHeader(f);
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
||||
void WriteRecordHeader(FILE *f)
|
||||
{
|
||||
fwrite(&record, sizeof(record), 1, f);
|
||||
fwrite(&length, sizeof(length), 1, f);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include "xmovie.h"
|
||||
|
||||
void Version(void)
|
||||
{
|
||||
fprintf(stderr,"%s %s, compiled %s %s\n"
|
||||
"Copyright 1992 Michael Uttormark, All rights reserved.\n",
|
||||
Progname, VERSION, __DATE__, __TIME__);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
/* ****************************************************************
|
||||
* xmovie - a simple X based movie program
|
||||
*
|
||||
* Mike Uttormark - 7/13/92
|
||||
* Sandia Nat'l Labs 1421
|
||||
* On leave from University of Wisconsin--Madison
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xaw/Form.h>
|
||||
#include <X11/Xaw/Cardinals.h>
|
||||
|
||||
#include "xmovie.h"
|
||||
#include "resource.h"
|
||||
|
||||
extern FILE *popen(const char *, const char *);
|
||||
extern int pclose(FILE *);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local function prototypes */
|
||||
|
||||
int main(int argc, char **argv);
|
||||
PRIVATE void CheckResources(void);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* common data */
|
||||
|
||||
CommonData Common = {
|
||||
NULL, /* atoms visible */
|
||||
NULL, /* bonds visible */
|
||||
FALSE, /* hollow */
|
||||
FALSE, /* opaque */
|
||||
FALSE, /* 2d mode */
|
||||
FALSE, /* periodic boundary conditions on bond drawing */
|
||||
FALSE, /* remap atoms into box bounds if necessary */
|
||||
FALSE, /* scale atoms to fill box bounds */
|
||||
FALSE, /* bond copying */
|
||||
FALSE, /* version */
|
||||
4, /* number of atom types */
|
||||
4, /* number of bond types */
|
||||
NULL, /* atom diameters */
|
||||
0, /* init */
|
||||
0, /* motion off */
|
||||
0, /* saveflag off */
|
||||
250L, /* delay interval (ms) */
|
||||
0, /* next drawing position */
|
||||
0, /* step number */
|
||||
1, /* dstep */
|
||||
2, /* z axis */
|
||||
0, /* view direction */
|
||||
{ { 1e20, 1e-20 }, { 1e20, 1e-20 }, { 1e20, 1e-20 } }, /* bounds */
|
||||
0, /* ndata */
|
||||
0, /* maxdata */
|
||||
NULL,
|
||||
};
|
||||
|
||||
Widget TopLevel;
|
||||
char *Progname;
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* local data */
|
||||
|
||||
static XrmOptionDescRec options[] = {
|
||||
{ "-2D", "*twoDimensions", XrmoptionNoArg, "True" },
|
||||
{ "-2d", "*twoDimensions", XrmoptionNoArg, "True" },
|
||||
{ "-pbc", "*pbcBond", XrmoptionNoArg, "True" },
|
||||
{ "-remap", "*remap", XrmoptionNoArg, "True" },
|
||||
{ "-scale", "*scale", XrmoptionNoArg, "True" },
|
||||
{ "-copy", "*copyBond", XrmoptionNoArg, "True" },
|
||||
{ "-hollow", "*hollow", XrmoptionNoArg, "True" },
|
||||
{ "-opaque", "*opaque", XrmoptionNoArg, "True" },
|
||||
{ "-V", "*version", XrmoptionNoArg, "True" },
|
||||
{ "-atomcolors","*atomColors", XrmoptionSepArg, NULL },
|
||||
{ "-bondcolors","*bondColors", XrmoptionSepArg, NULL },
|
||||
};
|
||||
|
||||
#define Offset(x,y) (((char *) &(x.y)) - ((char *) &(x)))
|
||||
|
||||
static XtResource resources[] = {
|
||||
{ "hollow", "Hollow",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, hollow),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "opaque", "Opaque",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, opaque),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "twoDimensions", "TwoDimensions",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, two_d),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "pbcBond", "PbcBond",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, pbc_bond),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "remap", "Remap",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, remap),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "scale", "Scale",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, scaleflag),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "copyBond", "CopyBond",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, copy_bond),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "version", "Version",
|
||||
XtRBool, sizeof(Bool),
|
||||
Offset(Common, version),
|
||||
XtRImmediate, (XtPointer) FALSE },
|
||||
|
||||
{ "atomColors", "AtomColors",
|
||||
XtRInt, sizeof(int),
|
||||
Offset(Common,natomcolors),
|
||||
XtRImmediate, (XtPointer) NCOLORS },
|
||||
|
||||
{ "bondColors", "BondColors",
|
||||
XtRInt, sizeof(int),
|
||||
Offset(Common,nbondcolors),
|
||||
XtRImmediate, (XtPointer) NCOLORS },
|
||||
|
||||
};
|
||||
|
||||
static XtActionsRec actions[] = {
|
||||
{ "ExposeScene", ExposeScene },
|
||||
{ "ExposeAxes", ExposeAxes },
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
XtAppContext AppContext; /* the whole process variable */
|
||||
|
||||
/* Get X stuff going */
|
||||
|
||||
Progname = argv[0];
|
||||
|
||||
TopLevel = XtAppInitialize(&AppContext, "XMovie", options,
|
||||
XtNumber(options), &argc, argv,
|
||||
FallbackResources, NULL, ZERO);
|
||||
|
||||
XtVaGetApplicationResources(TopLevel, (XtPointer) &Common,
|
||||
resources, XtNumber(resources), NULL);
|
||||
|
||||
CheckResources();
|
||||
|
||||
XtAppAddActions(AppContext, actions, XtNumber(actions));
|
||||
|
||||
/* initialize the reading stuff */
|
||||
|
||||
InitRead(argc-1, argv+1);
|
||||
|
||||
/* Create the scene box */
|
||||
|
||||
(void) CreateScene(TopLevel,"scene");
|
||||
|
||||
/* Create the Control panel */
|
||||
|
||||
(void) CreateControl(TopLevel,"control");
|
||||
|
||||
XtRealizeWidget(TopLevel);
|
||||
|
||||
/* put reading into background */
|
||||
|
||||
XtAppAddWorkProc(AppContext, ReadProc, (XtPointer) NULL);
|
||||
|
||||
Setup();
|
||||
Common.init = 1;
|
||||
|
||||
/* Enter Event Loop */
|
||||
|
||||
XtAppMainLoop(AppContext);
|
||||
}
|
||||
|
||||
int Usage(void)
|
||||
{
|
||||
static char *msg[] = {
|
||||
"xmovie - a simple & fast atom/molecule visualizer",
|
||||
" written by Mike Uttormark while at Sandia, 1992",
|
||||
" updated by Steve Plimpton, Sandia National Labs",
|
||||
" contact info: sjplimp@sandia.gov",
|
||||
"",
|
||||
"Usage: xmovie [-Xoptions] [-options] file1 [file2 ...]",
|
||||
" xmovie [-Xoptions] [-options] < file",
|
||||
"",
|
||||
"where -Xoptions are any standard XToolkit options",
|
||||
"-options are any of",
|
||||
" -2d reads two dimensional data files",
|
||||
" -hollow draws hollow atoms",
|
||||
" -opaque draws opaque hollow atoms (implies -hollow)",
|
||||
" -V prints version number and exits",
|
||||
" -pbc does not draw bonds > 1/2 box size",
|
||||
" -remap remap atoms back into bounding box if necessary",
|
||||
" -scale scale atom positions to fill bounding box",
|
||||
" -copy copies bonds from one timestep to next",
|
||||
" -atomcolors n sets number of colors for atoms",
|
||||
" -bondcolors n sets number of colors for bonds",
|
||||
"",
|
||||
"and 'files' are data files in the format",
|
||||
"",
|
||||
" ITEM: TIMESTEP",
|
||||
" time",
|
||||
" ITEM: BOX BOUNDS",
|
||||
" xlow xhigh",
|
||||
" ylow yhigh",
|
||||
" zlow zhigh",
|
||||
" ITEM: BONDS",
|
||||
" type1 atom1a atom1b",
|
||||
" type2 atom2a atom2b",
|
||||
" etc.",
|
||||
" ITEM: ATOMS",
|
||||
" index1 type1 x1 y1 z1",
|
||||
" index2 type2 x2 y2 z2",
|
||||
" etc.",
|
||||
"",
|
||||
"Notes:",
|
||||
" A TIMESTEP item starts a new frame",
|
||||
" A new item (or EOF) ends the list of ATOMS or BONDS",
|
||||
" BOX BOUNDS persist unless reset",
|
||||
" Any items not matching these patterns are skipped",
|
||||
" Data files can be gzipped - e.g. xmovie dump.gz",
|
||||
|
||||
NULL,
|
||||
};
|
||||
|
||||
char **s;
|
||||
char *pager;
|
||||
FILE *pipe;
|
||||
|
||||
/* find user's pager */
|
||||
|
||||
pager = getenv("PAGER");
|
||||
if (!pager || !*pager) pager = "more";
|
||||
pipe = popen(pager, "w");
|
||||
if (!pipe) pipe = stderr;
|
||||
|
||||
for(s = msg; *s; s++)
|
||||
fprintf(pipe,"%s\n", *s);
|
||||
|
||||
if (pipe != stderr) pclose(pipe);
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
PRIVATE void CheckResources(void)
|
||||
{
|
||||
if (Common.version) Version();
|
||||
|
||||
if (Common.natomcolors < 0 || Common.natomcolors > MAXCOLORS)
|
||||
Common.natomcolors = 1;
|
||||
|
||||
if (Common.nbondcolors < 0 || Common.nbondcolors > MAXCOLORS)
|
||||
Common.nbondcolors = 1;
|
||||
|
||||
if (Common.opaque) Common.hollow = TRUE;
|
||||
|
||||
Common.atoms_visible =
|
||||
(Bool *) XtMalloc(Common.natomcolors * sizeof(Bool));
|
||||
|
||||
Common.diameter =
|
||||
(Dimension *) XtMalloc(Common.natomcolors * sizeof(Dimension));
|
||||
|
||||
Common.bonds_visible =
|
||||
(Bool *) XtMalloc(Common.nbondcolors * sizeof(Bool));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
#ifndef PRIVATE
|
||||
#ifdef USEPRIVATE
|
||||
#define PRIVATE static
|
||||
#else
|
||||
#define PRIVATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define VERSION "Version 9.0"
|
||||
|
||||
#define NCOLORS 4
|
||||
#define MAXCOLORS 24
|
||||
#define MAXDIAM 100
|
||||
#define MAXTHICK 100
|
||||
|
||||
#define MagicNumber 12344321
|
||||
#define TimeID 100
|
||||
#define BoundID 101
|
||||
#define PositionID 102
|
||||
#define BondID 103
|
||||
#define CopyBondID 104
|
||||
#define CopyAtomID 105
|
||||
|
||||
typedef long INT4;
|
||||
typedef float REAL4;
|
||||
|
||||
typedef INT4 RECORD;
|
||||
typedef INT4 LENGTH;
|
||||
|
||||
typedef struct {
|
||||
INT4 index;
|
||||
INT4 type;
|
||||
REAL4 x;
|
||||
REAL4 y;
|
||||
REAL4 z;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
INT4 type;
|
||||
INT4 index1;
|
||||
INT4 index2;
|
||||
POSITION *atom1;
|
||||
POSITION *atom2;
|
||||
} BOND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 low;
|
||||
REAL4 high;
|
||||
} BOUND;
|
||||
|
||||
typedef struct {
|
||||
REAL4 time;
|
||||
BOUND bounds[3];
|
||||
INT4 natoms;
|
||||
INT4 maxatoms;
|
||||
POSITION *positions;
|
||||
INT4 *natypes;
|
||||
INT4 nbonds;
|
||||
INT4 maxbonds;
|
||||
BOND *bonds;
|
||||
INT4 *nbtypes;
|
||||
} DATA;
|
||||
|
||||
typedef struct {
|
||||
Bool *atoms_visible;
|
||||
Bool *bonds_visible;
|
||||
Bool hollow;
|
||||
Bool opaque;
|
||||
Bool two_d;
|
||||
Bool pbc_bond;
|
||||
Bool remap;
|
||||
Bool scaleflag;
|
||||
Bool copy_bond;
|
||||
Bool version;
|
||||
int natomcolors;
|
||||
int nbondcolors;
|
||||
Dimension *diameter;
|
||||
int init;
|
||||
int motion;
|
||||
int saveflag;
|
||||
unsigned long delay;
|
||||
int next_pos;
|
||||
int step;
|
||||
int dstep;
|
||||
int axis;
|
||||
int direction;
|
||||
BOUND bounds[3];
|
||||
int ndata;
|
||||
int maxdata;
|
||||
DATA *dataptr;
|
||||
float position;
|
||||
float thickness;
|
||||
float offset[3];
|
||||
float scale;
|
||||
} CommonData;
|
||||
|
||||
extern CommonData Common;
|
||||
extern Widget TopLevel;
|
||||
extern char *Progname;
|
||||
|
||||
Widget CreateScene(Widget parent, char *name);
|
||||
Widget CreateControl(Widget parent, char *name);
|
||||
|
||||
void InitRead(int argc, char **argv);
|
||||
Boolean ReadProc(XtPointer client_data);
|
||||
|
||||
void RemoveMotion(void);
|
||||
void InstallMotion(void);
|
||||
void SceneUpdate(void);
|
||||
void SceneSave(void);
|
||||
void SetTime(char *s);
|
||||
int Usage(void);
|
||||
|
||||
void PositionUpdate(void);
|
||||
void SpeedUpdate(void);
|
||||
void ThicknessUpdate(void);
|
||||
void UpdateRadios(void);
|
||||
void SceneSize(Dimension *width, Dimension *height);
|
||||
void Setup(void);
|
||||
void NewDataSetup(void);
|
||||
|
||||
void ExposeScene(Widget w, XEvent *event, String *strings,
|
||||
Cardinal *nstrings);
|
||||
|
||||
void ExposeAxes(Widget w, XEvent *event, String *strings,
|
||||
Cardinal *nstrings);
|
||||
|
||||
int CoerceStep(int step);
|
||||
|
||||
void SetReadString(char *s);
|
||||
|
||||
void SetAtomColors(Pixel *fg);
|
||||
void SetBondColors(Pixel *fg, Dimension *thick);
|
||||
void SetBGColor(Pixel bg);
|
||||
|
||||
void Version(void);
|
||||
|
||||
#ifdef MISSINGDEFS
|
||||
|
||||
/* commented this out for SGI gcc compiler
|
||||
#ifdef stdin
|
||||
int fprintf(FILE *file, char *fmt, ... );
|
||||
int fclose(FILE *file);
|
||||
int printf(char *fmt, ...);
|
||||
int fflush(FILE *f);
|
||||
int pclose(FILE *);
|
||||
int fread(void *, size_t, size_t, FILE *);
|
||||
int fseek(FILE *, long int, int);
|
||||
int ungetc(int c, FILE *f);
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if 0
|
||||
void XtTranslateCoords(Widget w, Position x, Position y, Position *rx,
|
||||
Position *ry);
|
||||
#endif
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue