00001
00002
00003
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 #ifndef __MMDB_Cryst__
00044 #define __MMDB_Cryst__
00045
00046 #include "mmdb_io_stream.h"
00047 #include "mmdb_symop.h"
00048 #include "mmdb_defs.h"
00049 #include "mmdb_utils.h"
00050
00051 namespace mmdb {
00052
00053
00054
00055 DefineClass(CrystContainer);
00056 DefineStreamFunctions(CrystContainer);
00057
00058 class CrystContainer : public ClassContainer {
00059
00060 public :
00061
00062 CrystContainer () : ClassContainer() {}
00063 CrystContainer ( io::RPStream Object )
00064 : ClassContainer ( Object ) {}
00065 ~CrystContainer() {}
00066
00067 PContainerClass MakeContainerClass ( int ClassID );
00068
00069 ERROR_CODE AddMTRIXLine ( cpstr S );
00070
00071 };
00072
00073
00074
00075
00076 enum NCSM_SET {
00077 NCSMSET_Matrix1 = 0x00000001,
00078 NCSMSET_Matrix2 = 0x00000002,
00079 NCSMSET_Matrix3 = 0x00000004,
00080 NCSMSET_All = 0x00000007
00081 };
00082
00083 DefineClass(NCSMatrix);
00084 DefineStreamFunctions(NCSMatrix);
00085
00086 class NCSMatrix : public ContainerClass {
00087
00088 friend class Cryst;
00089
00090 public :
00091
00092 int serNum;
00093 mat33 m;
00094 vect3 v;
00095 int iGiven;
00096
00097 NCSMatrix ();
00098 NCSMatrix ( cpstr S );
00099 NCSMatrix ( io::RPStream Object );
00100 ~NCSMatrix();
00101
00102 bool PDBASCIIDump1 ( io::RFile f );
00103 ERROR_CODE ConvertPDBASCII ( cpstr S );
00104 void MakeCIF ( mmcif::PData CIF, int N );
00105 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00106 CLASS_ID GetClassID () { return ClassID_NCSMatrix; }
00107
00108 void SetNCSMatrix ( int serialNum,
00109 mat33 & ncs_m, vect3 & ncs_v,
00110 int i_Given );
00111
00112 void Copy ( PContainerClass NCSMatrix );
00113
00114 void write ( io::RFile f );
00115 void read ( io::RFile f );
00116
00117 protected :
00118 word WhatIsSet;
00119
00120
00121
00122
00123 void Init();
00124
00125 };
00126
00127
00128
00129
00130 DefineClass(TVect);
00131 DefineStreamFunctions(TVect);
00132
00133 class TVect : public ContainerClass {
00134
00135 public :
00136
00137 int serNum;
00138 vect3 t;
00139 pstr comment;
00140
00141 TVect ();
00142 TVect ( cpstr S );
00143 TVect ( io::RPStream Object );
00144 ~TVect();
00145
00146 void PDBASCIIDump ( pstr S, int N );
00147 ERROR_CODE ConvertPDBASCII ( cpstr S );
00148 void MakeCIF ( mmcif::PData CIF, int N );
00149 ERROR_CODE GetCIF ( mmcif::PData CIF, int & n );
00150 CLASS_ID GetClassID () { return ClassID_TVect; }
00151
00152 void Copy ( PContainerClass TVect );
00153
00154 void write ( io::RFile f );
00155 void read ( io::RFile f );
00156
00157 protected :
00158
00159 void Init();
00160
00161 };
00162
00163
00164
00165
00166 DefineClass(Cryst);
00167 DefineStreamFunctions(Cryst);
00168
00169
00170 enum CELL_CHECK {
00171 CCHK_Ok = 0x00000000,
00172 CCHK_NoCell = 0x00000001,
00173 CCHK_Error = 0x00000002,
00174 CCHK_Disagreement = 0x00000004,
00175 CCHK_NoOrthCode = 0x00000008,
00176 CCHK_Translations = 0x00000010,
00177 CCHK_Unchecked = 0x00001000
00178 };
00179
00180
00181 enum CELL_SET {
00182 CSET_CellParams1 = 0x00000001,
00183 CSET_CellParams2 = 0x00000002,
00184 CSET_CellParams = 0x00000003,
00185 CSET_SpaceGroup = 0x00000004,
00186 CSET_ZValue = 0x00000008,
00187 CSET_CrystCard = 0x0000000F,
00188 CSET_OrigMatrix1 = 0x00000010,
00189 CSET_OrigMatrix2 = 0x00000020,
00190 CSET_OrigMatrix3 = 0x00000040,
00191 CSET_OrigMatrix = 0x00000070,
00192 CSET_ScaleMatrix1 = 0x00000080,
00193 CSET_ScaleMatrix2 = 0x00000100,
00194 CSET_ScaleMatrix3 = 0x00000200,
00195 CSET_ScaleMatrix = 0x00000380,
00196 CSET_Transforms = 0x00000400,
00197 CSET_DummyCell = 0x00001000
00198 };
00199
00200 extern cpstr OrthCode[6];
00201
00202 class Cryst : public io::Stream {
00203
00204 friend class Channel;
00205
00206 public :
00207 realtype a,b,c;
00208 realtype alpha,beta,gamma;
00209 mat44 RO,RF;
00210
00211 mat44 ROU,RFU;
00212
00213 mat633 RR;
00214 realtype Vol;
00215 int NCode;
00216 SymGroup spaceGroup;
00217
00218 SymGroup spaceGroupFix;
00219 int Z;
00220
00221 mat33 o;
00222 vect3 t;
00223 mat33 s;
00224 vect3 u;
00225
00226 word CellCheck;
00227
00228
00229
00230
00231
00232
00233
00234 word WhatIsSet;
00235 bool ignoreScalei;
00236 bool processSG;
00237
00238 bool fixSpaceGroup;
00239
00240 Cryst ();
00241 Cryst ( io::RPStream Object );
00242 ~Cryst();
00243
00244 void FreeMemory();
00245 void Reset ();
00246
00247
00248
00249
00250
00251
00252 ERROR_CODE ConvertPDBString ( pstr PDBString );
00253
00254
00255
00256 void RWBROOKReadPrintout();
00257
00258 void SetCell ( realtype cell_a,
00259 realtype cell_b,
00260 realtype cell_c,
00261 realtype cell_alpha,
00262 realtype cell_beta,
00263 realtype cell_gamma,
00264 int OrthCode );
00265 void PutCell ( realtype cell_a,
00266 realtype cell_b,
00267 realtype cell_c,
00268 realtype cell_alpha,
00269 realtype cell_beta,
00270 realtype cell_gamma,
00271 int OrthCode );
00272
00273 void GetCell ( realtype & cell_a,
00274 realtype & cell_b,
00275 realtype & cell_c,
00276 realtype & cell_alpha,
00277 realtype & cell_beta,
00278 realtype & cell_gamma,
00279 realtype & vol );
00280
00281 void GetRCell ( realtype & cell_as,
00282 realtype & cell_bs,
00283 realtype & cell_cs,
00284 realtype & cell_alphas,
00285 realtype & cell_betas,
00286 realtype & cell_gammas,
00287 realtype & vols );
00288
00289 void SetSyminfoLib ( cpstr syminfoLib );
00290 pstr GetSyminfoLib ();
00291
00292 int SetSpaceGroup ( cpstr spGroup );
00293 pstr GetSpaceGroup ();
00294 pstr GetSpaceGroupFix();
00295
00296
00297
00298
00299
00300
00301 void CalcCoordTransforms();
00302
00303
00304 void PDBASCIIDump ( io::RFile f );
00305
00306 ERROR_CODE GetCIF ( mmcif::PData CIF );
00307 void MakeCIF ( mmcif::PData CIF );
00308
00309 bool areMatrices();
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 bool Frac2Orth (
00320 realtype x, realtype y, realtype z,
00321 realtype & xx, realtype & yy, realtype & zz );
00322 bool Orth2Frac (
00323 realtype x, realtype y, realtype z,
00324 realtype & xx, realtype & yy, realtype & zz );
00325
00326
00327
00328 bool Frac2Orth ( mat44 & F, mat44 & T );
00329 bool Orth2Frac ( mat44 & T, mat44 & F );
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 bool Cryst2Orth ( rvector U );
00342 bool Orth2Cryst ( rvector U );
00343
00344 void CalcOrthMatrices();
00345
00346 bool isNCSMatrix ();
00347 bool isScaleMatrix ();
00348 bool isCellParameters();
00349
00350 int GetNumberOfSymOps();
00351 pstr GetSymOp ( int Nop );
00352
00353 int GetNumberOfNCSMatrices();
00354 int GetNumberOfNCSMates ();
00355
00356
00357
00358 bool GetNCSMatrix ( int NCSMatrixNo, mat33 & ncs_m,
00359 vect3 & ncs_v );
00360 bool GetNCSMatrix ( int NCSMatrixNo, mat44 & ncs_m,
00361 int & iGiven );
00362 int AddNCSMatrix ( mat33 & ncs_m, vect3 & ncs_v, int iGiven );
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 int GetTMatrix ( mat44 & TMatrix, int Nop,
00376 int cellshift_a, int cellshift_b,
00377 int cellshift_c, PSymOps symOpers=NULL );
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 int GetUCTMatrix ( mat44 & TMatrix, int Nop,
00394 realtype x, realtype y, realtype z,
00395 int cellshift_a, int cellshift_b,
00396 int cellshift_c, PSymOps symOpers=NULL );
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 int GetFractMatrix ( mat44 & TMatrix, int Nop,
00410 int cellshift_a, int cellshift_b,
00411 int cellshift_c, PSymOps symOpers=NULL );
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 int GetSymOpMatrix ( mat44 & TMatrix, int Nop );
00423
00424 void Copy ( PCryst Cryst );
00425
00426 void write ( io::RFile f );
00427 void read ( io::RFile f );
00428
00429 protected :
00430
00431 CrystContainer ncsMatrix;
00432 CrystContainer tVect;
00433
00434 realtype as,bs,cs;
00435 realtype alphas,betas,gammas;
00436 realtype AC[6];
00437 realtype VolChk,VolErr;
00438
00439 pstr syminfo_lib;
00440 SymOps symOps;
00441
00442 void Init ( bool fullInit );
00443 int FixSpaceGroup();
00444
00445 };
00446
00447 extern cpstr getOrthCodeName ( int NCode );
00448
00449 }
00450
00451
00452
00453
00454
00455
00456
00457 #endif
00458