Clipper
|
00001 00004 //C Copyright (C) 2000-2006 Kevin Cowtan and University of York 00005 //L 00006 //L This library is free software and is distributed under the terms 00007 //L and conditions of version 2.1 of the GNU Lesser General Public 00008 //L Licence (LGPL) with the following additional clause: 00009 //L 00010 //L `You may also combine or link a "work that uses the Library" to 00011 //L produce a work containing portions of the Library, and distribute 00012 //L that work under terms of your choice, provided that you give 00013 //L prominent notice with each copy of the work that the specified 00014 //L version of the Library is used in it, and that you include or 00015 //L provide public access to the complete corresponding 00016 //L machine-readable source code for the Library including whatever 00017 //L changes were used in the work. (i.e. If you make changes to the 00018 //L Library you must distribute those, but you do not need to 00019 //L distribute source or object code to those portions of the work 00020 //L not covered by this licence.)' 00021 //L 00022 //L Note that this clause grants an additional right and does not impose 00023 //L any additional restriction, and so does not affect compatibility 00024 //L with the GNU General Public Licence (GPL). If you wish to negotiate 00025 //L other terms, please contact the maintainer. 00026 //L 00027 //L You can redistribute it and/or modify the library under the terms of 00028 //L the GNU Lesser General Public License as published by the Free Software 00029 //L Foundation; either version 2.1 of the License, or (at your option) any 00030 //L later version. 00031 //L 00032 //L This library is distributed in the hope that it will be useful, but 00033 //L WITHOUT ANY WARRANTY; without even the implied warranty of 00034 //L MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00035 //L Lesser General Public License for more details. 00036 //L 00037 //L You should have received a copy of the CCP4 licence and/or GNU 00038 //L Lesser General Public License along with this library; if not, write 00039 //L to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK. 00040 //L The GNU Lesser General Public can also be obtained by writing to the 00041 //L Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00042 //L MA 02111-1307 USA 00043 /* some code & data converted from CCP4 library symlib.f (various authors) */ 00044 00045 00046 #ifndef CLIPPER_SPACEGROUP 00047 #define CLIPPER_SPACEGROUP 00048 00049 00050 #include "symop.h" 00051 #include "spacegroup_data.h" 00052 00053 00054 namespace clipper { 00055 00056 // forward definitions 00057 class HKL; 00058 class HKL_class; 00059 class Coord_frac; 00060 00061 00063 00073 class Spgr_descr 00074 { 00075 public: 00076 enum TYPE { Hall, HM, XHM, Symops, Number, Unknown }; 00078 Spgr_descr(); 00080 explicit Spgr_descr( const String& symb, TYPE type = Unknown ); 00082 explicit Spgr_descr( const int& num ); 00084 int spacegroup_number() const; 00086 String symbol_hall() const; 00088 String symbol_hm() const; 00090 String symbol_xhm() const; 00092 String symbol_hm_ext() const; 00094 static void set_preferred( const char& c ); 00095 00097 class Symop_codes : public std::vector<Symop_code> 00098 { 00099 public: 00101 void init_hall( const String& symb ); 00103 void init_symops( const String& symb ); 00105 Symop_codes expand() const; 00107 Symop_codes primitive_noninversion_ops() const; 00109 Symop_codes inversion_ops() const; 00111 Symop_codes primitive_ops() const; 00113 Symop_codes centering_ops() const; 00115 Symop_codes laue_ops() const; 00117 Symop_codes pgrp_ops() const; 00119 Symop_codes patterson_ops() const; 00121 Symop_codes generator_ops() const; 00123 Symop_codes product( const Symop_codes& ops2 ) const; 00125 unsigned int hash() const; 00126 }; 00127 00129 explicit Spgr_descr( const Symop_codes& ops ); 00131 const Symop_codes& generator_ops() const { return generators_; } 00133 const unsigned int& hash() const { return hash_; } 00134 00135 protected: 00136 unsigned int hash_; 00137 Symop_codes generators_; 00138 00139 static char pref_12, pref_hr; 00140 }; 00141 00142 00143 // ObjectCache data type 00144 class Spgr_cacheobj 00145 { 00146 public: 00147 typedef Spgr_descr Key; 00148 Spgr_cacheobj( const Key& spgr_cachekey ); 00149 bool matches( const Key& spgr_cachekey ) const; 00150 String format() const; 00151 // data 00152 Key spgr_cachekey_; 00153 int nsym, nsymn, nsymi, nsymc, nsymp; 00154 int lgrp; 00155 std::vector<Symop> symops; 00156 std::vector<Isymop> isymops; 00157 Vec3<> asu_min_, asu_max_; 00158 static Mutex mutex; 00159 }; 00160 00161 00163 00172 class Spacegroup : public Spgr_descr 00173 { 00174 public: 00176 enum TYPE { Null, P1 }; 00178 enum AXIS { A=0, B=1, C=2 }; 00180 Spacegroup() {}; 00182 explicit Spacegroup( TYPE type ); 00184 explicit Spacegroup( const Spgr_descr& spgr_descr ); 00186 void init( const Spgr_descr& spgr_descr ); 00187 00189 bool is_null() const; 00190 00191 // methods 00193 inline const Spgr_descr& descr() const { return (*this); } 00195 inline const int& num_symops() const { return nsym; } 00197 inline const int& num_primops() const { return num_primitive_symops(); } 00199 inline const int& num_primitive_symops() const { return nsymp; } 00201 inline const int& num_centering_symops() const { return nsymc; } 00203 inline const int& num_inversion_symops() const { return nsymi; } 00205 inline const int& num_primitive_noninversion_symops() const { return nsymn;} 00207 inline const Symop& symop( const int& sym_no ) const 00208 { return symops[sym_no]; } 00210 inline const Symop& primitive_symop( const int& sym_no ) const 00211 { return symops[sym_no]; } 00213 inline const Symop& inversion_symop( const int& sym_no ) const 00214 { return symops[nsymn*sym_no]; } 00216 inline const Symop& centering_symop( const int& sym_no ) const 00217 { return symops[nsymp*sym_no]; } 00219 int order_of_symmetry_about_axis( const AXIS axis ) const; 00220 00222 HKL_class hkl_class( const HKL& hkl ) const; 00224 bool recip_asu( const HKL& hkl ) const; 00225 00227 int product_op( const int& s1, int& s2 ) const; 00229 int inverse_op( const int& s ) const; 00230 00232 Coord_frac asu_max() const; 00234 Coord_frac asu_min() const; 00235 00237 bool invariant_under_change_of_hand() const; 00238 00239 // inherited functions listed for documentation purposes 00240 //-- int spacegroup_number() const; 00241 //-- String symbol_hall() const; 00242 //-- String symbol_hm() const; 00244 String symbol_laue() const; 00245 00247 static Spacegroup p1() { return Spacegroup( P1 ); } 00249 static Spacegroup null() { return Spacegroup( Null ); } 00250 00251 void debug() const; 00252 00253 private: 00254 ObjectCache<Spgr_cacheobj>::Reference cacheref; 00255 const Symop* symops; 00256 const Isymop* isymops; 00257 data::ASUfn asufn; 00258 int nsym, nsymn, nsymi, nsymc, nsymp; 00259 }; 00260 00261 00262 } // namespace clipper 00263 00264 #endif