summaryrefslogtreecommitdiff
path: root/sim/src/experimental/dumpxyz.c
blob: a538575f41b7dedafa6e9c8bd639529fb4a9d3d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2004-2006 Nanorex, Inc.  See LICENSE file for details. 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mol.h"

/**
 * @file
 *
 * Instead of sending frames to an OpenGL pane, let's dump frames as a
 * sequence of XYZ snapshots. Because it's a 3D representation, the
 * display animation program can place light sources and the camera
 * wherever we want.
 *
 * Info about sequential XYZ file format:
 * http://willware.net:8080/xyz2rgb.html
 */


FILE *outf;


/**
 */
void display(void) {
}

/**
 */
void snapshot(int n) {
	int i,j;
	fwrite(&Nexatom, sizeof(int), 1, outf);
	for (i=0; i<Nexatom; i++) {
		if (atom[i].disp == 0)
			continue;
		fwrite(&atom[i].elt, sizeof(int), 1, outf);
		fwrite(&avg[i], sizeof(struct xyz), 1, outf);
	}
}


/**
 */
void display_init(int *argc, char *argv[]) {
	outf = fopen("dumpstruct.xyz", "w");  // humorously homophonic with "dumptruck"
}


/**
 */
void display_fini(void) {
	fclose(outf);
}

/**
 */
void display_mainloop() {
	int x;
	printf("making movie\n");
	for (x=0; x<100; x++) {
		printf(" %d", x);
		fflush(stdout);
		if ((x & 15) == 15)
			printf("\n");
		calcloop(15);
		snapshot(x);
	}
	printf("\n");
}

/*
 * Local Variables:
 * c-basic-offset: 8
 * tab-width: 8
 * End:
 */