aboutsummaryrefslogtreecommitdiff
path: root/src/templates.c
blob: 98182bbe69582772a095ea349d3a5a3b279e790f (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
/*
 * templates.c
 *
 * Indexing by template matching
 *
 * (c) 2006-2010 Thomas White <taw@physics.org>
 *
 * Part of CrystFEL - crystallography with a FEL
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif


#include "index.h"
#include "index-priv.h"
#include "symmetry.h"
#include "utils.h"


/* Private data for template indexing */
struct _indexingprivate_template
{
	struct _indexingprivate base;
};


/* Generate templates for the given cell using a representative image */
IndexingPrivate *generate_templates(UnitCell *cell, const char *filename)
{
	struct _indexingprivate_template *priv;
	const char *holo;
	double omega_max, phi_max;

	priv = calloc(1, sizeof(struct _indexingprivate_template));
	priv->base.indm = INDEXING_TEMPLATE;

	/* We can only distinguish orientations within the holohedral cell */
	holo = get_holohedral(cell_get_pointgroup(cell));
	STATUS("%s\n", holo);

	/* These define the orientation in space */
	if ( is_polyhedral(holo) ) {
		ERROR("WARNING: Holohedral point group is polyhedral.\n");
		ERROR("This means I can't properly determine the orientation");
		ERROR(" ranges for template matching.  Expect trouble.\n");
	}
	omega_max = 2.0*M_PI / rotational_order(holo);
	if ( has_bisecting_mirror_or_diad(holo) ) omega_max /= 2.0;
	phi_max = M_PI;
	if ( has_perpendicular_mirror(holo) ) phi_max /= 2.0;

	/* One more axis would define the rotation in the plane of the image */

	STATUS("Orientation ranges: %5.0f -> %5.0f, %5.0f -> %5.0f deg.\n",
	       0.0, rad2deg(omega_max), 0.0, rad2deg(phi_max));

	return (struct _indexingprivate *)priv;
}


void match_templates(struct image *image, IndexingPrivate *ipriv)
{
}