aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-07-14 11:31:42 +0200
committerThomas White <taw@physics.org>2021-07-14 11:31:42 +0200
commit1a60c142dc919cf9765547c3c79be10155d3a873 (patch)
tree8e2c21ef511537260abaf5aad07da9cebddfdce1 /libcrystfel
parent4960248e89b3083ebdeddbfdef6bea83ad5225c8 (diff)
Make all the indexer-specific option structures non-opaque
Making them opaque seemed like a nice idea, because all the indexers could take care of their own command-line arguments. However, it doesn't work at all when indexing is run via the API.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/index.c14
-rw-r--r--libcrystfel/src/index.h75
-rw-r--r--libcrystfel/src/indexers/felix.c20
-rw-r--r--libcrystfel/src/indexers/felix.h2
-rw-r--r--libcrystfel/src/indexers/fromfile.c10
-rw-r--r--libcrystfel/src/indexers/fromfile.h2
-rw-r--r--libcrystfel/src/indexers/pinkindexer.c24
-rw-r--r--libcrystfel/src/indexers/pinkindexer.h4
-rw-r--r--libcrystfel/src/indexers/taketwo.c12
-rw-r--r--libcrystfel/src/indexers/taketwo.h2
-rw-r--r--libcrystfel/src/indexers/xgandalf.c15
-rw-r--r--libcrystfel/src/indexers/xgandalf.h2
12 files changed, 94 insertions, 88 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index c6876468..ce341197 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -204,7 +204,7 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell,
double wavelength_estimate,
double clen_estimate,
struct xgandalf_options *xgandalf_opts,
- struct pinkIndexer_options* pinkIndexer_opts,
+ struct pinkindexer_options* pinkIndexer_opts,
struct felix_options *felix_opts,
struct taketwo_options *taketwo_opts,
struct fromfile_options *fromfile_opts)
@@ -335,7 +335,7 @@ IndexingPrivate *setup_indexing(const char *method_list,
int n_threads,
struct taketwo_options *ttopts,
struct xgandalf_options *xgandalf_opts,
- struct pinkIndexer_options *pinkIndexer_opts,
+ struct pinkindexer_options *pinkIndexer_opts,
struct felix_options *felix_opts,
struct fromfile_options *fromfile_opts)
{
@@ -1189,11 +1189,11 @@ char *detect_indexing_methods(UnitCell *cell)
}
-void default_method_options(TakeTwoOptions **ttopts,
- XGandalfOptions **xgandalf_opts,
- PinkIndexerOptions **pinkIndexer_opts,
- FelixOptions **felix_opts,
- FromFileOptions **fromfile_opts)
+void default_method_options(struct taketwo_options **ttopts,
+ struct xgandalf_options **xgandalf_opts,
+ struct pinkindexer_options **pinkIndexer_opts,
+ struct felix_options **felix_opts,
+ struct fromfile_options **fromfile_opts)
{
taketwo_default_options(ttopts);
xgandalf_default_options(xgandalf_opts);
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index a4aef671..30bfa7c7 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -125,6 +125,63 @@ typedef enum {
} IndexingFlags;
+
+/**
+ * Indexer-specific "private" options
+ */
+struct pinkindexer_options {
+ unsigned int considered_peaks_count;
+ unsigned int angle_resolution;
+ unsigned int refinement_type;
+ float maxResolutionForIndexing_1_per_A;
+ float tolerance;
+ float reflectionRadius; /* In m^-1 */
+ float customBandwidth;
+ float maxRefinementDisbalance;
+};
+
+
+struct xgandalf_options {
+ unsigned int sampling_pitch;
+ unsigned int grad_desc_iterations;
+ float tolerance;
+ unsigned int no_deviation_from_provided_cell;
+ float minLatticeVectorLength_A;
+ float maxLatticeVectorLength_A;
+ int maxPeaksForIndexing;
+};
+
+
+struct taketwo_options
+{
+ int member_thresh;
+ double len_tol;
+ double angle_tol;
+ double trace_tol;
+};
+
+
+struct fromfile_options
+{
+ char *filename;
+};
+
+
+struct felix_options
+{
+ double ttmin; /* radians */
+ double ttmax; /* radians */
+ int min_visits;
+ double min_completeness;
+ double max_uniqueness;
+ int n_voxels;
+ double fraction_max_visits;
+ double sigma;
+ double domega;
+ double max_internal_angle;
+};
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -148,23 +205,17 @@ extern char *base_indexer_str(IndexingMethod indm);
#include "image.h"
#include "datatemplate.h"
-typedef struct felix_options FelixOptions;
-typedef struct taketwo_options TakeTwoOptions;
-typedef struct xgandalf_options XGandalfOptions;
-typedef struct pinkIndexer_options PinkIndexerOptions;
-typedef struct fromfile_options FromFileOptions;
-
extern struct argp felix_argp;
extern struct argp pinkIndexer_argp;
extern struct argp taketwo_argp;
extern struct argp xgandalf_argp;
extern struct argp fromfile_argp;
-extern void default_method_options(TakeTwoOptions **ttopts,
- XGandalfOptions **xgandalf_opts,
- PinkIndexerOptions **pinkIndexer_opts,
- FelixOptions **felix_opts,
- FromFileOptions **fromfile_opts);
+extern void default_method_options(struct taketwo_options **ttopts,
+ struct xgandalf_options **xgandalf_opts,
+ struct pinkindexer_options **pinkIndexer_opts,
+ struct felix_options **felix_opts,
+ struct fromfile_options **fromfile_opts);
extern IndexingPrivate *setup_indexing(const char *methods,
UnitCell *cell,
@@ -175,7 +226,7 @@ extern IndexingPrivate *setup_indexing(const char *methods,
int n_threads,
struct taketwo_options *ttopts,
struct xgandalf_options *xgandalf_opts,
- struct pinkIndexer_options *pinkIndexer_opts,
+ struct pinkindexer_options *pinkIndexer_opts,
struct felix_options *felix_opts,
struct fromfile_options *fromfile_opts);
diff --git a/libcrystfel/src/indexers/felix.c b/libcrystfel/src/indexers/felix.c
index dcd50613..db9cccf8 100644
--- a/libcrystfel/src/indexers/felix.c
+++ b/libcrystfel/src/indexers/felix.c
@@ -62,26 +62,12 @@
#include "cell.h"
#include "cell-utils.h"
#include "felix.h"
+#include "index.h"
#define FELIX_VERBOSE 0
-struct felix_options
-{
- double ttmin; /* radians */
- double ttmax; /* radians */
- int min_visits;
- double min_completeness;
- double max_uniqueness;
- int n_voxels;
- double fraction_max_visits;
- double sigma;
- double domega;
- double max_internal_angle;
-};
-
-
/* Global private data, prepared once */
struct felix_private
{
@@ -820,9 +806,9 @@ static void felix_show_help()
}
-int felix_default_options(FelixOptions **opts_ptr)
+int felix_default_options(struct felix_options **opts_ptr)
{
- FelixOptions *opts;
+ struct felix_options *opts;
opts = malloc(sizeof(struct felix_options));
if ( opts == NULL ) return ENOMEM;
diff --git a/libcrystfel/src/indexers/felix.h b/libcrystfel/src/indexers/felix.h
index 83179d6f..6379c4ee 100644
--- a/libcrystfel/src/indexers/felix.h
+++ b/libcrystfel/src/indexers/felix.h
@@ -39,7 +39,7 @@
* Felix indexer interface
*/
-extern int felix_default_options(FelixOptions **opts_ptr);
+extern int felix_default_options(struct felix_options **opts_ptr);
extern void *felix_prepare(IndexingMethod *indm, UnitCell *cell,
struct felix_options *opts);
diff --git a/libcrystfel/src/indexers/fromfile.c b/libcrystfel/src/indexers/fromfile.c
index 9a99b242..f0372489 100644
--- a/libcrystfel/src/indexers/fromfile.c
+++ b/libcrystfel/src/indexers/fromfile.c
@@ -42,14 +42,10 @@
#include "image.h"
#include "uthash.h"
+#include "index.h"
/** \file fromfile.h */
-struct fromfile_options
-{
- char *filename;
-};
-
#define MAX_KEY_LEN (256)
#define MAX_CRYSTALS (16)
@@ -373,9 +369,9 @@ static void fromfile_show_help()
}
-int fromfile_default_options(FromFileOptions **opts_ptr)
+int fromfile_default_options(struct fromfile_options **opts_ptr)
{
- FromFileOptions *opts;
+ struct fromfile_options *opts;
opts = malloc(sizeof(struct fromfile_options));
if ( opts == NULL ) return ENOMEM;
opts->filename = NULL;
diff --git a/libcrystfel/src/indexers/fromfile.h b/libcrystfel/src/indexers/fromfile.h
index 375a54e5..caff07c5 100644
--- a/libcrystfel/src/indexers/fromfile.h
+++ b/libcrystfel/src/indexers/fromfile.h
@@ -36,7 +36,7 @@
#include "image.h"
-extern int fromfile_default_options(FromFileOptions **opts_ptr);
+extern int fromfile_default_options(struct fromfile_options **opts_ptr);
extern void *fromfile_prepare(IndexingMethod *indm,
struct fromfile_options *opts);
extern int fromfile_index(struct image *image, void *mpriv);
diff --git a/libcrystfel/src/indexers/pinkindexer.c b/libcrystfel/src/indexers/pinkindexer.c
index 7da44f73..7522aad1 100644
--- a/libcrystfel/src/indexers/pinkindexer.c
+++ b/libcrystfel/src/indexers/pinkindexer.c
@@ -39,19 +39,9 @@
#include "utils.h"
#include "cell-utils.h"
#include "peaks.h"
+#include "index.h"
-struct pinkIndexer_options {
- unsigned int considered_peaks_count;
- unsigned int angle_resolution;
- unsigned int refinement_type;
- float maxResolutionForIndexing_1_per_A;
- float tolerance;
- float reflectionRadius; /* In m^-1 */
- float customBandwidth;
- float maxRefinementDisbalance;
-};
-
#ifdef HAVE_PINKINDEXER
#include <pinkIndexer/adaptions/crystfel/Lattice.h>
@@ -190,7 +180,7 @@ int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
- struct pinkIndexer_options *pinkIndexer_opts,
+ struct pinkindexer_options *pinkIndexer_opts,
double wavelength_estimate,
double clen_estimate)
{
@@ -383,7 +373,7 @@ int run_pinkIndexer(struct image *image, void *ipriv, int n_threads)
extern void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
- struct pinkIndexer_options *pinkIndexer_opts,
+ struct pinkindexer_options *pinkIndexer_opts,
double wavelength_estimate,
double clen_estimate)
{
@@ -431,11 +421,11 @@ static void pinkIndexer_show_help()
}
-int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr)
+int pinkIndexer_default_options(struct pinkindexer_options **opts_ptr)
{
- PinkIndexerOptions *opts;
+ struct pinkindexer_options *opts;
- opts = malloc(sizeof(struct pinkIndexer_options));
+ opts = malloc(sizeof(struct pinkindexer_options));
if ( opts == NULL ) return ENOMEM;
opts->considered_peaks_count = 4;
@@ -456,7 +446,7 @@ static error_t pinkindexer_parse_arg(int key, char *arg,
{
float tmp;
int r;
- struct pinkIndexer_options **opts_ptr = state->input;
+ struct pinkindexer_options **opts_ptr = state->input;
switch ( key ) {
diff --git a/libcrystfel/src/indexers/pinkindexer.h b/libcrystfel/src/indexers/pinkindexer.h
index 122bac87..c75b5551 100644
--- a/libcrystfel/src/indexers/pinkindexer.h
+++ b/libcrystfel/src/indexers/pinkindexer.h
@@ -35,13 +35,13 @@
#include "index.h"
#include "datatemplate.h"
-extern int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr);
+extern int pinkIndexer_default_options(struct pinkindexer_options **opts_ptr);
extern int run_pinkIndexer(struct image *image, void *ipriv, int n_threads);
extern void *pinkIndexer_prepare(IndexingMethod *indm,
UnitCell *cell,
- struct pinkIndexer_options *pinkIndexer_opts,
+ struct pinkindexer_options *pinkIndexer_opts,
double wavelength_estimate,
double clen_estimate);
diff --git a/libcrystfel/src/indexers/taketwo.c b/libcrystfel/src/indexers/taketwo.c
index 8ce33083..60bb6fed 100644
--- a/libcrystfel/src/indexers/taketwo.c
+++ b/libcrystfel/src/indexers/taketwo.c
@@ -102,14 +102,6 @@
#include "peaks.h"
#include "symmetry.h"
-struct taketwo_options
-{
- int member_thresh;
- double len_tol;
- double angle_tol;
- double trace_tol;
-};
-
/**
* \param obsvec an observed vector between two spots
* \param matches array of matching theoretical vectors from unit cell
@@ -2284,9 +2276,9 @@ static void taketwo_show_help()
}
-int taketwo_default_options(TakeTwoOptions **opts_ptr)
+int taketwo_default_options(struct taketwo_options **opts_ptr)
{
- TakeTwoOptions *opts;
+ struct taketwo_options *opts;
opts = malloc(sizeof(struct taketwo_options));
if ( opts == NULL ) return ENOMEM;
diff --git a/libcrystfel/src/indexers/taketwo.h b/libcrystfel/src/indexers/taketwo.h
index f3157d72..471b08b2 100644
--- a/libcrystfel/src/indexers/taketwo.h
+++ b/libcrystfel/src/indexers/taketwo.h
@@ -38,7 +38,7 @@
/** \file taketwo.h */
-extern int taketwo_default_options(TakeTwoOptions **opts_ptr);
+extern int taketwo_default_options(struct taketwo_options **opts_ptr);
extern void *taketwo_prepare(IndexingMethod *indm, struct taketwo_options *opts,
UnitCell *cell);
extern const char *taketwo_probe(UnitCell *cell);
diff --git a/libcrystfel/src/indexers/xgandalf.c b/libcrystfel/src/indexers/xgandalf.c
index ada0507a..d83af6cb 100644
--- a/libcrystfel/src/indexers/xgandalf.c
+++ b/libcrystfel/src/indexers/xgandalf.c
@@ -35,6 +35,7 @@
#include "utils.h"
#include "cell-utils.h"
#include "peaks.h"
+#include "index.h"
#ifdef HAVE_XGANDALF
#include "xgandalf/adaptions/crystfel/Lattice.h"
@@ -44,16 +45,6 @@
/** \file xgandalf.h */
-struct xgandalf_options {
- unsigned int sampling_pitch;
- unsigned int grad_desc_iterations;
- float tolerance;
- unsigned int no_deviation_from_provided_cell;
- float minLatticeVectorLength_A;
- float maxLatticeVectorLength_A;
- int maxPeaksForIndexing;
-};
-
#ifdef HAVE_XGANDALF
struct xgandalf_private_data {
@@ -387,9 +378,9 @@ static void xgandalf_show_help()
}
-int xgandalf_default_options(XGandalfOptions **opts_ptr)
+int xgandalf_default_options(struct xgandalf_options **opts_ptr)
{
- XGandalfOptions *opts;
+ struct xgandalf_options *opts;
opts = malloc(sizeof(struct xgandalf_options));
if ( opts == NULL ) return ENOMEM;
diff --git a/libcrystfel/src/indexers/xgandalf.h b/libcrystfel/src/indexers/xgandalf.h
index 79078410..b43f09ea 100644
--- a/libcrystfel/src/indexers/xgandalf.h
+++ b/libcrystfel/src/indexers/xgandalf.h
@@ -39,7 +39,7 @@
#include "index.h"
-extern int xgandalf_default_options(XGandalfOptions **opts_ptr);
+extern int xgandalf_default_options(struct xgandalf_options **opts_ptr);
extern int run_xgandalf(struct image *image, void *ipriv);