00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef CLIPPER_HKL_INFO
00046 #define CLIPPER_HKL_INFO
00047
00048
00049 #include "hkl_lookup.h"
00050
00051
00052 namespace clipper
00053 {
00054 class HKL_data_base;
00055
00056
00058
00062 class HKL_info
00063 {
00064 public:
00066 HKL_info();
00068 HKL_info( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resolution, const bool& generate = false );
00070 void init( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resolution, const bool& generate = false );
00072 void init( const Spacegroup& spacegroup, const Cell& cell, const HKL_sampling& hkl_sampling, const bool& generate = true );
00073
00075 bool is_null() const;
00076
00078 const Cell& cell() const { return cell_; }
00080 const Spacegroup& spacegroup() const { return spacegroup_; }
00082 const HKL_sampling& hkl_sampling() const { return hkl_sampling_; }
00084 const Resolution& resolution() const { return resolution_; }
00085
00087 void generate_hkl_list();
00089 void add_hkl_list( const std::vector<HKL>& add );
00090
00092 inline int num_reflections() const { return hkl.size(); }
00093
00095
00096 inline const HKL& hkl_of( const int& index ) const { return hkl[index]; }
00098
00100 inline int index_of( const HKL& rfl ) const
00101 { return lookup.index_of( rfl ); }
00102
00104 inline const ftype32& invresolsq( const int& index ) const
00105 { return invresolsq_lookup[index]; }
00107 inline const Range<ftype>& invresolsq_range() const
00108 { return invresolsq_range_; }
00110 const HKL_class& hkl_class( const int& index ) const
00111 { return hkl_class_lookup[index]; }
00113 HKL find_sym( const HKL& rfl, int& sym, bool& friedel ) const;
00114
00115
00117
00121 class HKL_reference_base
00122 {
00123 public:
00125 inline const HKL_info& base_hkl_info() const { return *hklinfo; }
00127 inline const int& index() const { return index_; }
00129 inline ftype invresolsq( const HKL_data_base& hkldata ) const;
00131 inline ftype invresolsq() const
00132 { return hklinfo->invresolsq( index_ ); }
00134 inline bool last() const
00135 { return ( index_ >= hklinfo->num_reflections() ); }
00136 protected:
00137 const HKL_info* hklinfo;
00138 int index_;
00139 };
00140
00142
00151 class HKL_reference_index : public HKL_reference_base
00152 {
00153 public:
00155 HKL_reference_index() {}
00157 HKL_reference_index( const HKL_info& hklinfo_, const int& index )
00158 { hklinfo = &hklinfo_; index_ = index; }
00160 inline const HKL& hkl() const { return hklinfo->hkl_of( index_ ); }
00162 inline const HKL_class& hkl_class() const
00163 { return hklinfo->hkl_class( index_ ); }
00165 inline HKL_reference_index& next() { index_++; return *this; }
00166
00167
00168
00169
00170
00171 };
00172
00174
00183 class HKL_reference_coord : public HKL_reference_base
00184 {
00185 public:
00187 HKL_reference_coord() {}
00189 HKL_reference_coord( const HKL_info& hklinfo_, const HKL& hkl ) {
00190 hklinfo = &hklinfo_;
00191 hkl_ = hkl;
00192 index_ = hklinfo->index_of( hklinfo->find_sym( hkl_, sym_, friedel_ ) );
00193 if ( index_ < 0 ) Message::message( Message_fatal( "HKL_reference_coord: hkl not found" ) );
00194 }
00196 inline const HKL& hkl() const { return hkl_; }
00198 inline const int& sym() const { return sym_; }
00200 inline const bool& friedel() const { return friedel_; }
00202
00205 inline HKL_reference_coord& set_hkl( const HKL& hkl__ ) {
00206 hkl_ = hkl__;
00207 HKL equiv = hkl__.transform(hklinfo->isymop[sym_]);
00208 if ( friedel_ ) equiv = -equiv;
00209 index_ = hklinfo->index_of( equiv );
00210 if ( index_ < 0 ) index_ =
00211 hklinfo->index_of( hklinfo->find_sym( hkl_, sym_, friedel_ ) );
00212 return *this;
00213 }
00215 inline HKL_reference_coord& next() {
00216 sym_ = 0; friedel_ = false;
00217 index_++;
00218 if ( !last() ) hkl_ = hklinfo->hkl_of( index_ );
00219 return *this;
00220 }
00221
00222 inline HKL_reference_coord& next_h() { hkl_.h()++; set_hkl( hkl_ ); return *this; }
00223 inline HKL_reference_coord& next_k() { hkl_.k()++; set_hkl( hkl_ ); return *this; }
00224 inline HKL_reference_coord& next_l() { hkl_.l()++; set_hkl( hkl_ ); return *this; }
00225 inline HKL_reference_coord& prev_h() { hkl_.h()--; set_hkl( hkl_ ); return *this; }
00226 inline HKL_reference_coord& prev_k() { hkl_.k()--; set_hkl( hkl_ ); return *this; }
00227 inline HKL_reference_coord& prev_l() { hkl_.l()--; set_hkl( hkl_ ); return *this; }
00228
00229 inline HKL_reference_coord& operator =( const HKL& hkl__ )
00230 { return set_hkl( hkl__ ); }
00231
00232
00233
00234
00235
00236 protected:
00237 HKL hkl_;
00238 int sym_;
00239 bool friedel_;
00240 };
00241
00243 HKL_reference_index first() const { return HKL_reference_index( *this, 0 ); }
00244
00245 void debug() const;
00246
00247 protected:
00248 Spacegroup spacegroup_;
00249 Cell cell_;
00250 HKL_sampling hkl_sampling_;
00251 Resolution resolution_;
00252 std::vector<Isymop> isymop;
00253
00255 std::vector<HKL> hkl;
00257 std::vector<HKL_class> hkl_class_lookup;
00259 std::vector<ftype32> invresolsq_lookup;
00260
00262 HKL_lookup lookup;
00264 Range<ftype> invresolsq_range_;
00265
00266
00268 void update_hkl_list();
00269
00270 friend class HKL_info::HKL_reference_base;
00271 friend class HKL_info::HKL_reference_index;
00272 friend class HKL_info::HKL_reference_coord;
00273 };
00274
00275
00276 }
00277
00278 #endif