Clipper
hkl_info.h
1
4//C Copyright (C) 2000-2006 Kevin Cowtan and University of York
5//L
6//L This library is free software and is distributed under the terms
7//L and conditions of version 2.1 of the GNU Lesser General Public
8//L Licence (LGPL) with the following additional clause:
9//L
10//L `You may also combine or link a "work that uses the Library" to
11//L produce a work containing portions of the Library, and distribute
12//L that work under terms of your choice, provided that you give
13//L prominent notice with each copy of the work that the specified
14//L version of the Library is used in it, and that you include or
15//L provide public access to the complete corresponding
16//L machine-readable source code for the Library including whatever
17//L changes were used in the work. (i.e. If you make changes to the
18//L Library you must distribute those, but you do not need to
19//L distribute source or object code to those portions of the work
20//L not covered by this licence.)'
21//L
22//L Note that this clause grants an additional right and does not impose
23//L any additional restriction, and so does not affect compatibility
24//L with the GNU General Public Licence (GPL). If you wish to negotiate
25//L other terms, please contact the maintainer.
26//L
27//L You can redistribute it and/or modify the library under the terms of
28//L the GNU Lesser General Public License as published by the Free Software
29//L Foundation; either version 2.1 of the License, or (at your option) any
30//L later version.
31//L
32//L This library is distributed in the hope that it will be useful, but
33//L WITHOUT ANY WARRANTY; without even the implied warranty of
34//L MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35//L Lesser General Public License for more details.
36//L
37//L You should have received a copy of the CCP4 licence and/or GNU
38//L Lesser General Public License along with this library; if not, write
39//L to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
40//L The GNU Lesser General Public can also be obtained by writing to the
41//L Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42//L MA 02111-1307 USA
43
44
45#ifndef CLIPPER_HKL_INFO
46#define CLIPPER_HKL_INFO
47
48
49#include "hkl_lookup.h"
50
51
52namespace clipper
53{
54 class HKL_data_base;
55
56
58
63 {
64 public:
66 HKL_info();
68 HKL_info( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resolution, const bool& generate = false );
70 void init( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resolution, const bool& generate = false );
72 void init( const Spacegroup& spacegroup, const Cell& cell, const HKL_sampling& hkl_sampling, const bool& generate = true );
73
75 bool is_null() const;
76
78 const Cell& cell() const { return cell_; }
80 const Spacegroup& spacegroup() const { return spacegroup_; }
82 const HKL_sampling& hkl_sampling() const { return hkl_sampling_; }
84 const Resolution& resolution() const { return resolution_; }
85
87 void generate_hkl_list();
89 void add_hkl_list( const std::vector<HKL>& add );
90
92 inline int num_reflections() const { return hkl.size(); }
93
95
96 inline const HKL& hkl_of( const int& index ) const { return hkl[index]; }
98
100 inline int index_of( const HKL& rfl ) const
101 { return lookup.index_of( rfl ); }
102
104 inline const ftype32& invresolsq( const int& index ) const
105 { return invresolsq_lookup[index]; }
107 inline const Range<ftype>& invresolsq_range() const
108 { return invresolsq_range_; }
110 const HKL_class& hkl_class( const int& index ) const
111 { return hkl_class_lookup[index]; }
113 HKL find_sym( const HKL& rfl, int& sym, bool& friedel ) const;
114
115
117
122 {
123 public:
125 inline const HKL_info& base_hkl_info() const { return *hklinfo; }
127 inline const int& index() const { return index_; }
129 inline ftype invresolsq( const HKL_data_base& hkldata ) const;
131 inline ftype invresolsq() const
132 { return hklinfo->invresolsq( index_ ); }
134 inline bool last() const
135 { return ( index_ >= hklinfo->num_reflections() ); }
136 protected:
137 const HKL_info* hklinfo;
138 int index_;
139 };
140
142
152 {
153 public:
157 HKL_reference_index( const HKL_info& hklinfo_, const int& index )
158 { hklinfo = &hklinfo_; index_ = index; }
160 inline const HKL& hkl() const { return hklinfo->hkl_of( index_ ); }
162 inline const HKL_class& hkl_class() const
163 { return hklinfo->hkl_class( index_ ); }
165 inline HKL_reference_index& next() { index_++; return *this; }
166 // inherited functions listed for documentation purposes
167 //-- const HKL_info& base_hkl_info() const;
168 //-- const int& index() const;
169 //-- const ftype invresolsq() const;
170 //-- bool last() const;
171 };
172
174
184 {
185 public:
189 HKL_reference_coord( const HKL_info& hklinfo_, const HKL& hkl ) {
190 hklinfo = &hklinfo_;
191 hkl_ = hkl;
192 index_ = hklinfo->index_of( hklinfo->find_sym( hkl_, sym_, friedel_ ) );
193 if ( index_ < 0 ) Message::message( Message_fatal( "HKL_reference_coord: hkl not found" ) );
194 }
196 inline const HKL& hkl() const { return hkl_; }
198 inline const int& sym() const { return sym_; }
200 inline const bool& friedel() const { return friedel_; }
202
205 inline HKL_reference_coord& set_hkl( const HKL& hkl__ ) {
206 hkl_ = hkl__;
207 HKL equiv = hkl__.transform(hklinfo->isymop[sym_]);
208 if ( friedel_ ) equiv = -equiv;
209 index_ = hklinfo->index_of( equiv );
210 if ( index_ < 0 ) index_ =
211 hklinfo->index_of( hklinfo->find_sym( hkl_, sym_, friedel_ ) );
212 return *this;
213 }
216 sym_ = 0; friedel_ = false;
217 index_++;
218 if ( !last() ) hkl_ = hklinfo->hkl_of( index_ );
219 return *this;
220 }
221 // increment h,k,l
222 inline HKL_reference_coord& next_h() { hkl_.h()++; set_hkl( hkl_ ); return *this; }
223 inline HKL_reference_coord& next_k() { hkl_.k()++; set_hkl( hkl_ ); return *this; }
224 inline HKL_reference_coord& next_l() { hkl_.l()++; set_hkl( hkl_ ); return *this; }
225 inline HKL_reference_coord& prev_h() { hkl_.h()--; set_hkl( hkl_ ); return *this; }
226 inline HKL_reference_coord& prev_k() { hkl_.k()--; set_hkl( hkl_ ); return *this; }
227 inline HKL_reference_coord& prev_l() { hkl_.l()--; set_hkl( hkl_ ); return *this; }
229 inline HKL_reference_coord& operator =( const HKL& hkl__ )
230 { return set_hkl( hkl__ ); }
231 // inherited functions listed for documentation purposes
232 //-- const HKL_info& base_hkl_info() const;
233 //-- const int& index() const;
234 //-- const ftype invresolsq() const;
235 //-- bool last() const;
236 protected:
237 HKL hkl_;
238 int sym_;
239 bool friedel_;
240 };
241
243 HKL_reference_index first() const { return HKL_reference_index( *this, 0 ); }
244
245 void debug() const;
246
247 protected:
252 std::vector<Isymop> isymop;
253
255 std::vector<HKL> hkl;
257 std::vector<HKL_class> hkl_class_lookup;
259 std::vector<ftype32> invresolsq_lookup;
260
265
266 // internal methods:
268 void update_hkl_list();
269
270 friend class HKL_info::HKL_reference_base;
273 };
274
275
276} // namespace clipper
277
278#endif
Cell object.
Definition: cell.h:122
reflection class
Definition: coords.h:87
HKL_data_base.
Definition: hkl_data.h:137
HKL reference base class.
Definition: hkl_info.h:122
const HKL_info & base_hkl_info() const
return the parent HKL_info
Definition: hkl_info.h:125
const int & index() const
return the current index (-1 if invalid)
Definition: hkl_info.h:127
bool last() const
test if index has gone past last reflection
Definition: hkl_info.h:134
ftype invresolsq() const
return the inv resol sq for the reflection (assumes index valid)
Definition: hkl_info.h:131
HKL reference with coord-like behaviour.
Definition: hkl_info.h:184
HKL_reference_coord & prev_h()
decrement h
Definition: hkl_info.h:225
HKL_reference_coord()
Null constructor.
Definition: hkl_info.h:187
const int & sym() const
get current symop number
Definition: hkl_info.h:198
const bool & friedel() const
get current friedel flag
Definition: hkl_info.h:200
const HKL & hkl() const
return the current HKL
Definition: hkl_info.h:196
HKL_reference_coord & next_l()
increment l
Definition: hkl_info.h:224
HKL_reference_coord & prev_k()
decrement k
Definition: hkl_info.h:226
HKL_reference_coord & next()
increment to next reflection
Definition: hkl_info.h:215
HKL_reference_coord & next_h()
increment h
Definition: hkl_info.h:222
HKL_reference_coord & operator=(const HKL &hkl__)
operator assign from HKL
Definition: hkl_info.h:229
HKL_reference_coord & next_k()
increment k
Definition: hkl_info.h:223
HKL_reference_coord & set_hkl(const HKL &hkl__)
assign from HKL
Definition: hkl_info.h:205
HKL_reference_coord(const HKL_info &hklinfo_, const HKL &hkl)
Constructor: takes parent HKL_info and initial HKL.
Definition: hkl_info.h:189
HKL_reference_coord & prev_l()
decrement l
Definition: hkl_info.h:227
HKL reference with index-like behaviour.
Definition: hkl_info.h:152
HKL_reference_index(const HKL_info &hklinfo_, const int &index)
Constructor: takes parent HKL_info and initial index.
Definition: hkl_info.h:157
const HKL & hkl() const
return the current HKL
Definition: hkl_info.h:160
const HKL_class & hkl_class() const
return the reflection class for the reflection
Definition: hkl_info.h:162
HKL_reference_index()
Null constructor.
Definition: hkl_info.h:155
HKL_reference_index & next()
increment to next reflection
Definition: hkl_info.h:165
HKL list container and tree root.
Definition: hkl_info.h:63
const HKL_class & hkl_class(const int &index) const
get reflection class using lookup
Definition: hkl_info.h:110
int num_reflections() const
get number of reflections in the object
Definition: hkl_info.h:92
HKL_reference_index first() const
return HKL_reference_index pointing to first reflection
Definition: hkl_info.h:243
std::vector< Isymop > isymop
integer symops
Definition: hkl_info.h:252
int index_of(const HKL &rfl) const
reflection index from hkl
Definition: hkl_info.h:100
const Spacegroup & spacegroup() const
get the spacegroup
Definition: hkl_info.h:80
Cell cell_
unit cell
Definition: hkl_info.h:249
Range< ftype > invresolsq_range_
resolution limit of the current reflection list
Definition: hkl_info.h:264
const Range< ftype > & invresolsq_range() const
get resolution limits of the list
Definition: hkl_info.h:107
HKL_info()
null constructor
Definition: hkl_info.cpp:74
Resolution resolution_
resolution limit
Definition: hkl_info.h:251
std::vector< ftype32 > invresolsq_lookup
fast resolution lookup table
Definition: hkl_info.h:259
std::vector< HKL > hkl
the reflection list
Definition: hkl_info.h:255
HKL find_sym(const HKL &rfl, int &sym, bool &friedel) const
find symop no and friedel to bring an HKL into ASU
Definition: hkl_info.cpp:238
void update_hkl_list()
finalise reflection list
Definition: hkl_info.cpp:58
bool is_null() const
test if object has been initialised
Definition: hkl_info.cpp:190
void generate_hkl_list()
synthesize hkl list
Definition: hkl_info.cpp:195
HKL_sampling hkl_sampling_
hkl sampling
Definition: hkl_info.h:250
const HKL_sampling & hkl_sampling() const
[CLIPPER2] get HKL_sampling
Definition: hkl_info.h:82
std::vector< HKL_class > hkl_class_lookup
fast epsilon/centricity lookup table
Definition: hkl_info.h:257
void add_hkl_list(const std::vector< HKL > &add)
add new reflections to the list
Definition: hkl_info.cpp:224
HKL_lookup lookup
fast reflection lookup table
Definition: hkl_info.h:262
Spacegroup spacegroup_
spacegroup
Definition: hkl_info.h:248
const Resolution & resolution() const
get the resolution
Definition: hkl_info.h:84
const Cell & cell() const
get the cell
Definition: hkl_info.h:78
void init(const Spacegroup &spacegroup, const Cell &cell, const Resolution &resolution, const bool &generate=false)
initialiser: Takes spacegroup, cell, and resolution
Definition: hkl_info.cpp:112
const HKL & hkl_of(const int &index) const
reflection hkl from index
Definition: hkl_info.h:96
const ftype32 & invresolsq(const int &index) const
get reflection resolution using lookup
Definition: hkl_info.h:104
Fast reflection lookup object.
Definition: hkl_lookup.h:59
int index_of(const HKL &rfl) const
lookup function
Definition: hkl_lookup.cpp:105
HKL sampling of reciprocal space.
Definition: coords.h:553
reflection 'Miller' index
Definition: coords.h:146
const int & h() const
get h
Definition: coords.h:153
HKL transform(const Symop &op) const
return transformed hkl
Definition: coords.h:696
const int & k() const
get k
Definition: coords.h:154
const int & l() const
get l
Definition: coords.h:155
Fatal message (level = 9)
Definition: clipper_message.h:129
static void message(const T &message)
pass a message
Definition: clipper_message.h:93
Resolution in angstroms.
Definition: coords.h:69
Spacegroup object.
Definition: spacegroup.h:173
ftype64 ftype
ftype definition for floating point representation
Definition: clipper_precision.h:58