aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.h
blob: 419d73b85dc282908477a914a5b37a739ceb6e89 (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
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
/*
 * datatemplate.h
 *
 * Template for loading data
 *
 * Copyright © 2019-2021 Deutsches Elektronen-Synchrotron DESY,
 *                       a research centre of the Helmholtz Association.
 *
 * Authors:
 *   2019-2020 Thomas White <taw@physics.org>
 *
 * This file is part of CrystFEL.
 *
 * CrystFEL is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * CrystFEL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CrystFEL.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef DATATEMPLATE_H
#define DATATEMPLATE_H

#include "detgeom.h"

/**
 * \file datatemplate.h
 * Template for loading data.
 */

/**
 * This data structure is opaque.  You must use the available accessor functions
 * to read and write its contents.
 **/
typedef struct _datatemplate DataTemplate;


struct dg_group_info
{
	const char *name;
	int serial;
	int hierarchy_level;
};


#ifdef __cplusplus
extern "C" {
#endif

extern DataTemplate *data_template_new_from_file(const char *filename);
extern DataTemplate *data_template_new_from_string(const char *string_in);
extern void data_template_free(DataTemplate *dt);

extern const char *data_template_panel_number_to_name(const DataTemplate *dt,
                                                      int pn);

extern int data_template_panel_name_to_number(const DataTemplate *dt,
                                              const char *panel_name,
                                              int *pn);

extern int data_template_file_to_panel_coords(const DataTemplate *dt,
                                              float *pfs, float *pss,
                                              int pn);

extern int data_template_slabby_file_to_panel_coords(const DataTemplate *dt,
                                                     float *pfs, float *pss,
                                                     int *ppn);

extern int data_template_panel_to_file_coords(const DataTemplate *dt,
                                              int pn,
                                              float *pfs, float *pss);

extern void data_template_add_copy_header(DataTemplate *dt,
                                          const char *header);

extern int data_template_get_slab_extents(const DataTemplate *dt, int *pw, int *ph);

extern double data_template_get_wavelength_if_possible(const DataTemplate *dt);

extern double data_template_get_clen_if_possible(const DataTemplate *dt);

extern struct detgeom *data_template_get_2d_detgeom_if_possible(const DataTemplate *dt);

extern void data_template_show_hierarchy(const DataTemplate *dtempl);

extern int data_template_translate_group_px(DataTemplate *dtempl,
                                            const char *group_name,
                                            double x, double y, double z);

extern int data_template_translate_group_m(DataTemplate *dtempl,
                                           const char *group_name,
                                           double x, double y, double z);

extern int data_template_rotate_group(DataTemplate *dtempl,
                                      const char *group_name,
                                      double ang, char axis);

extern int data_template_write_to_fh(const DataTemplate *dtempl, FILE *fh);

extern int data_template_write_to_file(const DataTemplate *dtempl,
                                       const char *filename);

extern struct dg_group_info *data_template_group_info(const DataTemplate *dtempl, int *n);

#ifdef __cplusplus
}
#endif

#endif	/* DATATEMPLATE_H */