00001
00002
00003 #ifndef HKL_SYMMETRY_HEADER
00004 #define HKL_SYMMETRY_HEADER
00005
00006 #include <vector>
00007
00008 #include <clipper/clipper.h>
00009 using clipper::Message;
00010 using clipper::Message_fatal;
00011 using clipper::Message_info;
00012
00013 #include "hkl_datatypes.hh"
00014 #include "lattice.hh"
00015
00016 namespace scala {
00017
00025 std::string SGnameHtoR(const std::string& sgname, const char& HorR = ' ');
00026
00028
00031 class SpaceGroup : public clipper::Spacegroup
00032
00033
00034 {
00035 public:
00036
00037 SpaceGroup() : Nsymp(0) {}
00038 SpaceGroup(std::vector<clipper::Symop>& symops);
00039 SpaceGroup(const std::string& spgname);
00040 SpaceGroup(const int& SpgNumber);
00041 SpaceGroup(const clipper::Spacegroup& ClpSG);
00042
00043 void init(std::vector<clipper::Symop>& symops);
00044 void init(const std::string& spgname);
00045 void init(const int& SpgNumber);
00046 void init(const clipper::Spacegroup& ClpSG);
00047
00049 bool Null() const {return (Nsymp == 0);}
00050
00051 clipper::Symop Symop(const int& symN) const
00052 {return csymops.at(symN);}
00053 clipper::Symop RotSymop(const int& symN) const
00054 {return rotsymops.at(symN);}
00055 clipper::Symop InvRotSymop(const int& symN) const
00056 {return invrotsymops.at(symN);}
00057
00059 clipper::Symop_code RotSymopCode(const int& symN) const
00060 {return clipper::Symop_code(rotsymops.at(symN));}
00062 clipper::Symop_code InvRotSymopCode(const int& symN) const
00063 {return clipper::Symop_code(invrotsymops.at(symN));}
00064
00066 SpaceGroup PattersonGroup() const;
00068 SpaceGroup PointGroup() const;
00069
00071 char LatType() const {return lattype;}
00073 SpaceGroup NewLatticePointGroup(const char& Lattype) const;
00074
00076 std::vector<clipper::Symop_code> SymopCodes() const;
00077
00078 bool IsSymopIdentity(const int& symN) const;
00079
00080 std::string formatAllSymops_as_xyz() const;
00081 std::string formatAllSymops_as_hkl() const;
00082
00084 std::string Symbol_hm() const {return spacegroupname;}
00086 std::string Symbol_hall() const;
00088 int Spacegroup_number() const {return spacegroupnumber;}
00090 int CCP4_Spacegroup_number() const {return CCP4spacegroupnumber;}
00091
00093 clipper::HKL put_in_asu(const clipper::HKL& hkl, int& isym) const;
00095 clipper::HKL get_from_asu(const clipper::HKL& hkl, const int& isym) const;
00096
00098 friend bool operator == (const SpaceGroup& a,const SpaceGroup& b);
00099 friend bool operator != (const SpaceGroup& a,const SpaceGroup& b);
00100
00102 void ChangeBasis(const scala::ReindexOp& reindex);
00103
00104 private:
00105 int Nsymp;
00106 char lattype;
00107 std::string spacegroupname;
00108 int spacegroupnumber;
00109 int CCP4spacegroupnumber;
00110
00111
00112
00113
00114
00115
00116
00117 std::vector<clipper::Symop> csymops;
00118 std::vector<clipper::Symop> rotsymops;
00119 std::vector<clipper::Symop> invrotsymops;
00120
00121
00122 void init();
00123
00124 void SetLatType();
00125
00126 CSym::ccp4_symop MakeCCP4symop(const clipper::Symop& S) const;
00127
00128 std::string CCP4spaceGroupName() const;
00129
00130 void CCP4spaceGroupNumber();
00131
00132 clipper::Symop MakeClippersymop(const CSym::ccp4_symop& S) const;
00133
00134 std::string AllSymopsfromCCP4(const CSym::CCP4SPG* ccp4sg) const;
00135 };
00136
00137 class SymElement {
00139 public:
00140 int Nfold;
00141 clipper::Vec3<int> iaxis;
00142 std::vector<int> symops;
00143 SymElement() : Nfold(0) {};
00144 void print() const;
00145 };
00146
00147 class hkl_symmetry
00148
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 {
00175 public:
00176
00177 hkl_symmetry();
00178 hkl_symmetry(const clipper::Spacegroup& cspgp);
00179 hkl_symmetry(const scala::SpaceGroup& cspgp);
00180 hkl_symmetry(const std::string SpgName);
00181 hkl_symmetry(const int& SpgNumber);
00182
00184 bool IsNull() const {return (Nsymp == 0);}
00186 void set_reindex(const ReindexOp& op) {ReindexToZeroFrame = op;}
00187
00189 SpaceGroup GetSpaceGroup() const {return spaceGroup;}
00191 clipper::Spacegroup ClipperGroup() const {return spaceGroup;}
00192
00194 Hkl put_in_asu(const Hkl& hkl, int& isym) const;
00196 clipper::HKL put_in_asu(const clipper::HKL& hkl, int& isym) const;
00198 Hkl get_from_asu(const Hkl& hkl, const int& isym) const;
00199 bool is_centric(const Hkl& hkl) const;
00200 float epsilon(const Hkl& hkl) const;
00201
00202 bool IsCentro() const {return centro;}
00203 bool IsChiral() const {return chiral;}
00204
00206 bool LatticePresent(const Hkl& hkl) const;
00208 void ChangeBasis(const scala::ReindexOp& reindex);
00209
00210
00211
00213 int Nelement() const {return Nelement_;}
00215 bool IsElementIdent(const int& kelement) const;
00217 clipper::Vec3<int> AxisDirection(const SymElement& elmt) const;
00219 std::string format_element(const int& kelement) const;
00221 std::string XML_element(const int& kelement) const;
00222 void print_element(const int& idx) const;
00223 void print_elements() const;
00224
00225
00227 int NopInElement(const int& kelement) const;
00229 std::vector<double> SymopInElement(const int& j,
00230 const int& kelement) const;
00232
00235 int get_symelmt(const int& isym1, const int& isym2) const;
00236
00238
00241 std::vector<int> get_symelmt(const Hkl& h1, const Hkl& h2) const;
00242
00243
00244 std::string symbol_Hall() const;
00245 std::string symbol_xHM(const char& HorR=' ') const;
00246 std::string symbol() const {return spgname;}
00247
00249 char lattice_type() const {return LatType;}
00251 int NsymP() const {return Nsymp;}
00253 int Nsym() const {return spaceGroup.num_symops();}
00254
00256 std::vector<clipper::Symop> RotSymopsInElement(const int& kelement) const;
00258 std::vector<clipper::Symop> PrimRotSymops() const;
00259
00260
00262 CrystalSystem CrysSys() const {return cryssys;}
00264
00266 std::vector<int> CellConstraint() const;
00267
00269
00270 bool equals_rt(const hkl_symmetry& other) const;
00271 bool equals_r(const hkl_symmetry& other) const;
00272
00274 bool operator==(const hkl_symmetry& other) const {return equals_r(other);}
00276 bool operator!=(const hkl_symmetry& other) const {return !equals_r(other);}
00277
00279 bool equalElement(const int& jel, const hkl_symmetry& other, const int& jel2) const;
00280
00281 private:
00282 int Nsymp;
00283 SpaceGroup spaceGroup;
00284 std::string spgname;
00285 char LatType;
00286 int Nelement_;
00287 CrystalSystem cryssys;
00288 bool centro;
00289 bool chiral;
00290
00291 std::vector<clipper::Symop_code> inv_rot_symcodes;
00292 std::vector<clipper::Symop_code> rot_symcodes;
00293 std::vector<SymElement> elements;
00294 std::vector<int> element_index;
00295 std::vector<int> symelmt;
00296
00297
00298
00299
00300
00301 ReindexOp ReindexToZeroFrame;
00302
00303
00304 bool ElementEqual(const SymElement& a, const SymElement& b) const;
00305 void set_symmetry();
00306
00307 CrystalSystem CrysSysfromSGnumber(const int& SpaceGroupNumber);
00308
00309 bool ChiralTest();
00310 };
00311
00312 }
00313 #endif