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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* image.h
*
* Handle images and image features
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
* pattern_sim - Simulate diffraction patterns from small crystals
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef IMAGE_H
#define IMAGE_H
#include <stdint.h>
#include <complex.h>
/* How is the scaling of the image described? */
typedef enum {
FORMULATION_CLEN,
FORMULATION_PIXELSIZE
} FormulationMode;
/* Structure describing a feature in an image */
struct imagefeature {
struct image *parent;
double x;
double y;
double intensity;
/* Partner for this feature (in another feature list) or NULL */
struct imagefeature_struct *partner;
/* Distance between this feature and its partner, if any. */
double partner_d;
};
/* An opaque type representing a list of image features */
typedef struct _imagefeaturelist ImageFeatureList;
/* A 3D vector in reciprocal space */
struct threevec
{
double u;
double v;
double w;
};
struct mol_species
{
char species[4]; /* Species name */
int n_atoms; /* Number of atoms of this species */
float x[32*1024];
float y[32*1024];
float z[32*1024];
float occ[32*1024];
float B[32*1024];
};
struct molecule
{
int n_species;
struct mol_species *species[32];
};
/* Structure describing an image */
struct image {
uint16_t *data;
complex *sfacs;
struct threevec *qvecs;
double *twotheta;
struct molecule *molecule;
/* Radians. Defines where the pattern lies in reciprocal space */
double tilt;
/* Radians. Defines where the pattern lies in reciprocal space */
double omega;
/* Image parameters can be given as camera length or pixel size.
* If FORMULATION_CLEN, then camera_len and resolution must be given.
* If FORMULATION_PIXELSIZE, then pixel_size only is needed.*/
FormulationMode fmode;
double pixel_size;
double camera_len;
double resolution; /* pixels per metre */
/* Wavelength must always be given */
double lambda; /* Wavelength in m */
double xray_energy; /* X-ray energy
* in J (per photon) */
int width;
int height;
double x_centre;
double y_centre;
ImageFeatureList *features; /* "Experimental" features */
ImageFeatureList *rflist; /* "Predicted" features */
};
/* An opaque type representing a list of images */
typedef struct _imagelist ImageList;
/* Image lists */
extern ImageList *image_list_new(void);
extern int image_add(ImageList *list, struct image *image);
/* Feature lists */
extern ImageFeatureList *image_feature_list_new(void);
extern void image_feature_list_free(ImageFeatureList *flist);
extern void image_add_feature(ImageFeatureList *flist, double x, double y,
struct image *parent, double intensity);
extern struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double x, double y, double *d,
int *idx);
extern int image_feature_count(ImageFeatureList *flist);
extern struct imagefeature *image_get_feature(ImageFeatureList *flist, int idx);
#endif /* IMAGE_H */
|