-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCrystal.h
216 lines (171 loc) · 4.58 KB
/
Crystal.h
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// Mandexing: a manual indexing program for crystallographic data.
// Copyright (C) 2017-2018 Helen Ginn
//
// This program 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.
//
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
//
// Please email: vagabond @ hginn.co.uk for more details.
#ifndef __Windexing__Crystal__
#define __Windexing__Crystal__
#include "mat3x3.h"
#include <iostream>
#include "shared_ptrs.h"
#define STARTING_WAVELENGTH 1.000
#define STARTING_DISTANCE 500.000
typedef struct
{
vec3 miller; // the transformed coordinates in reciprocal space
vec3 position; // updated by detector when needed
int h;
int k;
int l; // before transformation on a integer grid
double weight; // proportional to closeness to Ewald sphere
bool onImage; // whether it is to be displayed on overlay
bool watched;
} Reflection;
class Tinker;
class Crystal
{
public:
Crystal();
void setUnitCell(std::vector<double> cellDims);
void bringAxisToScreen(std::vector<double> axis);
void applyRotation(double diffX, double diffY, double diffZ);
mat3x3 getScaledBasisVectors();
mat3x3 getNudge(double diffX, double diffY, double diffZ);
void clearUpRefinement();
bool isBeingWatched(int i);
void quickCheckMillers();
void populateMillers();
static double ewaldSphereClosenessScore(void *crystal)
{
return static_cast<Crystal *>(crystal)->ewaldSphereCloseness();
}
static void setHorizontal(void *crystal, double horiz)
{
static_cast<Crystal *>(crystal)->_horiz = horiz;
}
static void setVertical(void *crystal, double vert)
{
static_cast<Crystal *>(crystal)->_vert = vert;
}
static double getVertical(void *crystal)
{
return static_cast<Crystal *>(crystal)->_vert;
}
static double getHorizontal(void *crystal)
{
return static_cast<Crystal *>(crystal)->_horiz;
}
void setResolution(double resolution)
{
_resolution = resolution;
}
Reflection *refl(int i)
{
return &_reflections[i];
}
size_t millerCount()
{
return _reflections.size();
}
vec3 miller(int i)
{
//Transformed into reciprocal space. Already fractional.
return _reflections[i].miller;
}
void setPositionForMiller(int i, vec3 pos)
{
_reflections[i].position = pos;
}
vec3 position(int i)
{
return _reflections[i].position;
}
void toggleWatched(int i)
{
_reflections[i].watched = ((_reflections[i].watched == 0) ? 1 : 0);
}
void getMillerHKL(int i, int *h, int *k, int *l)
{
*h = _reflections[i].h;
*k = _reflections[i].k;
*l = _reflections[i].l;
}
double weightForMiller(int i)
{
return _reflections[i].weight;
}
bool shouldDisplayMiller(int i)
{
return _reflections[i].onImage;
}
void setFixedAxis(vec3 axis)
{
_fixedAxis = axis;
}
vec3 getFixedAxis()
{
return _fixedAxis;
}
void setWavelength(double wavelength)
{
_wavelength = wavelength;
}
double getRlpSize()
{
return _rlpSize;
}
void setRlpSize(double rlpSize)
{
_rlpSize = rlpSize;
}
void setTinker(Tinker *tinker)
{
_tinker = tinker;
}
mat3x3 getRotation()
{
return _rotation;
}
void setRotation(mat3x3 rot)
{
_rotation = rot;
}
mat3x3 getUnitCell()
{
return _unitCell;
}
void setUnitCell(mat3x3 unitCell);
void setBravaisLattice(BravaisLatticeType type)
{
_latticeType = type;
}
private:
double ewaldSphereCloseness();
bool isSysabs(int a, int b, int c);
Tinker *_tinker;
std::vector<double> _cellDims;
mat3x3 _rotation;
mat3x3 _unitCell;
std::vector<Reflection> _reflections;
double _resolution;
double _rlpSize;
double _wavelength;
double _horiz;
double _vert;
BravaisLatticeType _latticeType;
static vec3 _cube[8];
vec3 _fixedAxis;
};
#endif